More AppFrame cleanup, active/current modem verbage adjustments

This commit is contained in:
Charles J. Cliffe 2019-02-11 22:59:43 -05:00
parent abaf458ea1
commit 9ed085123a
14 changed files with 390 additions and 307 deletions

View File

@ -2092,42 +2092,278 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
updateDeviceParams(); updateDeviceParams();
} }
//Refresh the current TX antenna on, if any: handleTXAntennaChange();
DemodulatorInstancePtr demod = wxGetApp().getDemodMgr().getCurrentModem();
if (demod && demod->isModemInitialized()) {
handleCurrentModem();
} else if (demod) {
// Wait state for current demodulator modem to activate..
} else {
handleModeSelector();
handleGainMeter();
handleDemodWaterfallSpectrum();
handleSpectrumWaterfall();
handleMuteButton();
}
handleScopeProcessor();
handleScopeSpectrumProcessors();
handleModemProperties();
handlePeakHold();
#if USE_HAMLIB
handleRigMenu();
#endif
#ifdef _WIN32
if (scopeCanvas && scopeCanvas->HasFocus()) {
waterfallCanvas->SetFocus();
}
#endif
if (!this->IsActive()) {
std::this_thread::sleep_for(std::chrono::milliseconds(30));
} else {
if (wxGetApp().getConfig()->getPerfMode() == AppConfig::PERF_LOW) {
std::this_thread::sleep_for(std::chrono::milliseconds(30));
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
event.RequestMore();
}
void AppFrame::handleTXAntennaChange() {//Refresh the current TX antenna on, if any:
if ((antennaMenuItems.find(wxID_ANTENNA_CURRENT_TX) != antennaMenuItems.end()) && devInfo) { if ((antennaMenuItems.find(wxID_ANTENNA_CURRENT_TX) != antennaMenuItems.end()) && devInfo) {
std::string actualTxAntenna = devInfo->getAntennaName(SOAPY_SDR_TX, 0); string actualTxAntenna = devInfo->getAntennaName(SOAPY_SDR_TX, 0);
if (currentTXantennaName != actualTxAntenna) { if (currentTXantennaName != actualTxAntenna) {
currentTXantennaName = actualTxAntenna; currentTXantennaName = actualTxAntenna;
antennaMenuItems[wxID_ANTENNA_CURRENT_TX]->SetItemLabel(getSettingsLabel("TX Antenna", currentTXantennaName)); antennaMenuItems[wxID_ANTENNA_CURRENT_TX]->SetItemLabel(getSettingsLabel("TX Antenna", currentTXantennaName));
} }
} }
}
DemodulatorInstancePtr demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
if (demod && demod->isModemInitialized()) { #if USE_HAMLIB
if (demod->isTracking()) { void AppFrame::handleRigMenu() {
if (rigEnableMenuItem->IsChecked()) {
if (!wxGetApp().rigIsActive()) {
rigEnableMenuItem->Check(false);
wxGetApp().getConfig()->setRigEnabled(false);
}
}
}
#endif
void AppFrame::handlePeakHold() {
int peakHoldMode = peakHoldButton->getSelection();
if (peakHoldButton->modeChanged()) {
wxGetApp().getSpectrumProcessor()->setPeakHold(peakHoldMode == 1);
//make the peak hold act on the current dmod also, like a zoomed-in version.
if (wxGetApp().getDemodSpectrumProcessor()) {
wxGetApp().getDemodSpectrumProcessor()->setPeakHold(peakHoldMode == 1);
}
peakHoldButton->clearModeChanged();
}
}
void AppFrame::handleModemProperties() {
DemodulatorInstancePtr demod = wxGetApp().getDemodMgr().getCurrentModem();
if (modemPropertiesUpdated.load() && demod && demod->isModemInitialized()) {
//reset notification flag
modemPropertiesUpdated.store(false);
modemProps->initProperties(demod->getModemArgs(), demod);
modemProps->updateTheme();
demodTray->Layout();
modemProps->fitColumns();
#if ENABLE_DIGITAL_LAB
if (demod->getModemType() == "digital") {
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)demod->getOutput();
if (!outp->getDialog()) {
outp->setTitle(demod->getDemodulatorType() + ": " + frequencyToStr(demod->getFrequency()));
outp->setDialog(new DigitalConsole(this, outp)) ;
}
demod->showOutput();
}
#endif
} else if (!demod && modemPropertiesUpdated.load()) {
ModemArgInfoList dummyInfo;
modemProps->initProperties(dummyInfo, nullptr);
modemProps->updateTheme();
demodTray->Layout();
}
if (modemProps->IsShown() && modemProps->isCollapsed() && modemProps->GetMinWidth() > 22) {
modemProps->SetMinSize(wxSize(APPFRAME_MODEMPROPS_MINSIZE, -1));
modemProps->SetMaxSize(wxSize(APPFRAME_MODEMPROPS_MINSIZE, -1));
demodTray->Layout();
modemProps->fitColumns();
} else if (modemProps->IsShown() && !modemProps->isCollapsed() && modemProps->GetMinWidth() < 200) {
modemProps->SetMinSize(wxSize(APPFRAME_MODEMPROPS_MAXSIZE, -1));
modemProps->SetMaxSize(wxSize(APPFRAME_MODEMPROPS_MAXSIZE, -1));
demodTray->Layout();
modemProps->fitColumns();
}
}
void AppFrame::handleScopeSpectrumProcessors() {
SpectrumVisualProcessor *proc = wxGetApp().getSpectrumProcessor();
if (spectrumAvgMeter->inputChanged()) {
float val = spectrumAvgMeter->getInputValue();
if (val < 0.01) {
val = 0.01f;
}
if (val > 0.99) {
val = 0.99f;
}
spectrumAvgMeter->setLevel(val);
proc->setFFTAverageRate(val);
GetStatusBar()->SetStatusText(wxString::Format(wxT("Spectrum averaging speed changed to %0.2f%%."), val * 100.0));
}
SpectrumVisualProcessor *dproc = wxGetApp().getDemodSpectrumProcessor();
if (dproc) {
dproc->setView(demodWaterfallCanvas->getViewState(), demodWaterfallCanvas->getCenterFrequency(),
demodWaterfallCanvas->getBandwidth());
}
SpectrumVisualProcessor *wproc = waterfallDataThread->getProcessor();
if (waterfallSpeedMeter->inputChanged()) {
float val = waterfallSpeedMeter->getInputValue();
waterfallSpeedMeter->setLevel(val);
waterfallDataThread->setLinesPerSecond((int)ceil(val * val));
waterfallCanvas->setLinesPerSecond((int)ceil(val * val));
GetStatusBar()->SetStatusText(
wxString::Format(wxT("Waterfall max speed changed to %d lines per second."), (int)ceil(val * val)));
}
wproc->setView(waterfallCanvas->getViewState(), waterfallCanvas->getCenterFrequency(), waterfallCanvas->getBandwidth());
proc->setView(wproc->isView(), wproc->getCenterFrequency(), wproc->getBandwidth());
}
void AppFrame::handleScopeProcessor() {
if (scopeCanvas) {
scopeCanvas->setPPMMode(demodTuner->isAltDown());
wxGetApp().getScopeProcessor()->setScopeEnabled(scopeCanvas->scopeVisible());
wxGetApp().getScopeProcessor()->setSpectrumEnabled(scopeCanvas->spectrumVisible());
wxGetApp().getAudioVisualQueue()->set_max_num_items((scopeCanvas->scopeVisible() ? 1 : 0) + (scopeCanvas->spectrumVisible() ? 1 : 0));
wxGetApp().getScopeProcessor()->run();
}
}
void AppFrame::handleMuteButton() {
if (demodMuteButton->modeChanged()) {
int muteMode = demodMuteButton->getSelection();
if (muteMode == -1) {
wxGetApp().getDemodMgr().setLastMuted(false);
} else if (muteMode == 1) {
wxGetApp().getDemodMgr().setLastMuted(true);
}
demodMuteButton->clearModeChanged();
}
}
void AppFrame::handleSpectrumWaterfall() {
if (spectrumCanvas->getViewState() && abs(wxGetApp().getFrequency() - spectrumCanvas->getCenterFrequency()) > (wxGetApp().getSampleRate() / 2)) {
spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
}
}
void AppFrame::handleDemodWaterfallSpectrum() {
if (demodWaterfallCanvas && wxGetApp().getFrequency() != demodWaterfallCanvas->getCenterFrequency()) {
demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
if (demodSpectrumCanvas) {
demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
}
}
}
void AppFrame::handleGainMeter() {
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();
demodGainMeter->setLevel(mgr->getLastGain());
if (demodSignalMeter->inputChanged()) {
mgr->setLastSquelchLevel(demodSignalMeter->getInputValue());
}
if (demodGainMeter->inputChanged()) {
mgr->setLastGain(demodGainMeter->getInputValue());
demodGainMeter->setLevel(demodGainMeter->getInputValue());
}
}
void AppFrame::handleModeSelector() {
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();
string dSelection = demodModeSelector->getSelectionLabel();
#ifdef ENABLE_DIGITAL_LAB
string dSelectionadv = demodModeSelectorAdv->getSelectionLabel();
// basic demodulators
if (dSelection != "" && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection);
mgr->setLastBandwidth(Modem::getModemDefaultSampleRate(dSelection));
demodTuner->setHalfBand(dSelection == "USB" || dSelection == "LSB");
demodModeSelectorAdv->setSelection(-1);
}
// advanced demodulators
else if(dSelectionadv != "" && dSelectionadv != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelectionadv);
mgr->setLastBandwidth(Modem::getModemDefaultSampleRate(dSelectionadv));
demodTuner->setHalfBand(false);
demodModeSelector->setSelection(-1);
}
#else
// basic demodulators
if (dSelection != "" && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection);
mgr->setLastBandwidth(Modem::getModemDefaultSampleRate(dSelection));
demodTuner->setHalfBand(dSelection=="USB" || dSelection=="LSB");
}
#endif
}
void AppFrame::handleCurrentModem() {
DemodulatorInstancePtr demod = wxGetApp().getDemodMgr().getCurrentModem();
if (demod->isTracking()) {
if (spectrumCanvas->getViewState()) { if (spectrumCanvas->getViewState()) {
long long diff = abs(demod->getFrequency() - spectrumCanvas->getCenterFrequency()) + (demod->getBandwidth()/2) + (demod->getBandwidth()/4); long long diff = abs(demod->getFrequency() - spectrumCanvas->getCenterFrequency()) + (demod->getBandwidth() / 2) + (demod->getBandwidth() / 4);
if (diff > spectrumCanvas->getBandwidth()/2) { if (diff > spectrumCanvas->getBandwidth() / 2) {
if (demod->getBandwidth() > (int)spectrumCanvas->getBandwidth()) { if (demod->getBandwidth() > (int) spectrumCanvas->getBandwidth()) {
diff = abs(demod->getFrequency() - spectrumCanvas->getCenterFrequency()); diff = abs(demod->getFrequency() - spectrumCanvas->getCenterFrequency());
} else { } else {
diff = diff - spectrumCanvas->getBandwidth()/2; diff = diff - spectrumCanvas->getBandwidth() / 2;
} }
spectrumCanvas->moveCenterFrequency((demod->getFrequency() < spectrumCanvas->getCenterFrequency())?diff:-diff); spectrumCanvas->moveCenterFrequency((demod->getFrequency() < spectrumCanvas->getCenterFrequency()) ? diff : -diff);
demod->setTracking(false); demod->setTracking(false);
} }
} else { } else {
demod->setTracking(false); demod->setTracking(false);
} }
} }
if (demod->getBandwidth() != wxGetApp().getDemodMgr().getLastBandwidth()) { if (demod->getBandwidth() != wxGetApp().getDemodMgr().getLastBandwidth()) {
wxGetApp().getDemodMgr().setLastBandwidth(demod->getBandwidth()); wxGetApp().getDemodMgr().setLastBandwidth(demod->getBandwidth());
} }
if (demod.get() != activeDemodulator) { if (demod.get() != activeDemodulator) {
demodSignalMeter->setInputValue(demod->getSquelchLevel()); demodSignalMeter->setInputValue(demod->getSquelchLevel());
demodGainMeter->setInputValue(demod->getGain()); demodGainMeter->setInputValue(demod->getGain());
wxGetApp().getDemodMgr().setLastGain(demod->getGain()); wxGetApp().getDemodMgr().setLastGain(demod->getGain());
@ -2137,17 +2373,17 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
scopeCanvas->setDeviceName(outputDevices[outputDevice].name); scopeCanvas->setDeviceName(outputDevices[outputDevice].name);
} }
// outputDeviceMenuItems[outputDevice]->Check(true); // outputDeviceMenuItems[outputDevice]->Check(true);
std::string dType = demod->getDemodulatorType(); string dType = demod->getDemodulatorType();
demodModeSelector->setSelection(dType); demodModeSelector->setSelection(dType);
#ifdef ENABLE_DIGITAL_LAB #ifdef ENABLE_DIGITAL_LAB
demodModeSelectorAdv->setSelection(dType); demodModeSelectorAdv->setSelection(dType);
#endif #endif
deltaLockButton->setSelection(demod->isDeltaLock()?1:-1); deltaLockButton->setSelection(demod->isDeltaLock() ? 1 : -1);
demodMuteButton->setSelection(demod->isMuted()?1:-1); demodMuteButton->setSelection(demod->isMuted() ? 1 : -1);
modemPropertiesUpdated.store(true); modemPropertiesUpdated.store(true);
demodTuner->setHalfBand(dType=="USB" || dType=="LSB"); demodTuner->setHalfBand(dType == "USB" || dType == "LSB");
} }
if (!demodWaterfallCanvas || demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) { if (!demodWaterfallCanvas || demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) {
long long centerFreq = demod->getFrequency(); long long centerFreq = demod->getFrequency();
unsigned int demodBw = (unsigned int) ceil((float) demod->getBandwidth() * 2.25); unsigned int demodBw = (unsigned int) ceil((float) demod->getBandwidth() * 2.25);
@ -2172,14 +2408,15 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
demodWaterfallCanvas->setCenterFrequency(centerFreq); demodWaterfallCanvas->setCenterFrequency(centerFreq);
demodSpectrumCanvas->setCenterFrequency(centerFreq); demodSpectrumCanvas->setCenterFrequency(centerFreq);
} }
std::string dSelection = demodModeSelector->getSelectionLabel();
string dSelection = demodModeSelector->getSelectionLabel();
#ifdef ENABLE_DIGITAL_LAB #ifdef ENABLE_DIGITAL_LAB
std::string dSelectionadv = demodModeSelectorAdv->getSelectionLabel(); string dSelectionadv = demodModeSelectorAdv->getSelectionLabel();
// basic demodulators // basic demodulators
if (dSelection != "" && dSelection != demod->getDemodulatorType()) { if (dSelection != "" && dSelection != demod->getDemodulatorType()) {
demod->setDemodulatorType(dSelection); demod->setDemodulatorType(dSelection);
demodTuner->setHalfBand(dSelection=="USB" || dSelection=="LSB"); demodTuner->setHalfBand(dSelection == "USB" || dSelection == "LSB");
demodModeSelectorAdv->setSelection(-1); demodModeSelectorAdv->setSelection(-1);
} }
// advanced demodulators // advanced demodulators
@ -2249,216 +2486,30 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
soloModeButton->clearModeChanged(); soloModeButton->clearModeChanged();
} else { } else {
if (wxGetApp().getSoloMode() != (soloMode==1)) { if (wxGetApp().getSoloMode() != (soloMode==1)) {
soloModeButton->setSelection(wxGetApp().getSoloMode()?1:-1); soloModeButton->setSelection(wxGetApp().getSoloMode() ? 1 : -1);
soloModeButton->Refresh(); soloModeButton->Refresh();
} }
} }
if (demodWaterfallCanvas) { if (demodWaterfallCanvas) {
demodWaterfallCanvas->setBandwidth(demodBw); demodWaterfallCanvas->setBandwidth(demodBw);
demodSpectrumCanvas->setBandwidth(demodBw); demodSpectrumCanvas->setBandwidth(demodBw);
} }
} }
demodSignalMeter->setLevel(demod->getSignalLevel()); demodSignalMeter->setLevel(demod->getSignalLevel());
demodSignalMeter->setMin(demod->getSignalFloor()); demodSignalMeter->setMin(demod->getSignalFloor());
demodSignalMeter->setMax(demod->getSignalCeil()); demodSignalMeter->setMax(demod->getSignalCeil());
demodGainMeter->setLevel(demod->getGain()); demodGainMeter->setLevel(demod->getGain());
if (demodSignalMeter->inputChanged()) { if (demodSignalMeter->inputChanged()) {
demod->setSquelchLevel(demodSignalMeter->getInputValue()); demod->setSquelchLevel(demodSignalMeter->getInputValue());
} }
if (demodGainMeter->inputChanged()) { if (demodGainMeter->inputChanged()) {
demod->setGain(demodGainMeter->getInputValue()); demod->setGain(demodGainMeter->getInputValue());
demodGainMeter->setLevel(demodGainMeter->getInputValue()); demodGainMeter->setLevel(demodGainMeter->getInputValue());
} }
activeDemodulator = demod.get(); activeDemodulator = demod.get();
} else if (demod) {
// Wait state for current demodulator modem to activate..
} else {
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();
std::string dSelection = demodModeSelector->getSelectionLabel();
#ifdef ENABLE_DIGITAL_LAB
std::string dSelectionadv = demodModeSelectorAdv->getSelectionLabel();
// basic demodulators
if (dSelection != "" && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection);
mgr->setLastBandwidth(Modem::getModemDefaultSampleRate(dSelection));
demodTuner->setHalfBand(dSelection=="USB" || dSelection=="LSB");
demodModeSelectorAdv->setSelection(-1);
}
// advanced demodulators
else if(dSelectionadv != "" && dSelectionadv != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelectionadv);
mgr->setLastBandwidth(Modem::getModemDefaultSampleRate(dSelectionadv));
demodTuner->setHalfBand(false);
demodModeSelector->setSelection(-1);
}
#else
// basic demodulators
if (dSelection != "" && dSelection != mgr->getLastDemodulatorType()) {
mgr->setLastDemodulatorType(dSelection);
mgr->setLastBandwidth(Modem::getModemDefaultSampleRate(dSelection));
demodTuner->setHalfBand(dSelection=="USB" || dSelection=="LSB");
}
#endif
demodGainMeter->setLevel(mgr->getLastGain());
if (demodSignalMeter->inputChanged()) {
mgr->setLastSquelchLevel(demodSignalMeter->getInputValue());
}
if (demodGainMeter->inputChanged()) {
mgr->setLastGain(demodGainMeter->getInputValue());
demodGainMeter->setLevel(demodGainMeter->getInputValue());
}
if (demodWaterfallCanvas && wxGetApp().getFrequency() != demodWaterfallCanvas->getCenterFrequency()) {
demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
if (demodSpectrumCanvas) {
demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
}
}
if (spectrumCanvas->getViewState() && abs(wxGetApp().getFrequency()-spectrumCanvas->getCenterFrequency()) > (wxGetApp().getSampleRate()/2)) {
spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
}
if (demodMuteButton->modeChanged()) {
int muteMode = demodMuteButton->getSelection();
if (muteMode == -1) {
wxGetApp().getDemodMgr().setLastMuted(false);
} else if (muteMode == 1) {
wxGetApp().getDemodMgr().setLastMuted(true);
}
demodMuteButton->clearModeChanged();
}
}
if (scopeCanvas) {
scopeCanvas->setPPMMode(demodTuner->isAltDown());
wxGetApp().getScopeProcessor()->setScopeEnabled(scopeCanvas->scopeVisible());
wxGetApp().getScopeProcessor()->setSpectrumEnabled(scopeCanvas->spectrumVisible());
wxGetApp().getAudioVisualQueue()->set_max_num_items((scopeCanvas->scopeVisible()?1:0) + (scopeCanvas->spectrumVisible()?1:0));
wxGetApp().getScopeProcessor()->run();
}
SpectrumVisualProcessor *proc = wxGetApp().getSpectrumProcessor();
if (spectrumAvgMeter->inputChanged()) {
float val = spectrumAvgMeter->getInputValue();
if (val < 0.01) {
val = 0.01f;
}
if (val > 0.99) {
val = 0.99f;
}
spectrumAvgMeter->setLevel(val);
proc->setFFTAverageRate(val);
GetStatusBar()->SetStatusText(wxString::Format(wxT("Spectrum averaging speed changed to %0.2f%%."),val*100.0));
}
SpectrumVisualProcessor *dproc = wxGetApp().getDemodSpectrumProcessor();
if (dproc) {
dproc->setView(demodWaterfallCanvas->getViewState(), demodWaterfallCanvas->getCenterFrequency(),demodWaterfallCanvas->getBandwidth());
}
SpectrumVisualProcessor *wproc = waterfallDataThread->getProcessor();
if (waterfallSpeedMeter->inputChanged()) {
float val = waterfallSpeedMeter->getInputValue();
waterfallSpeedMeter->setLevel(val);
waterfallDataThread->setLinesPerSecond((int)ceil(val*val));
waterfallCanvas->setLinesPerSecond((int)ceil(val*val));
GetStatusBar()->SetStatusText(wxString::Format(wxT("Waterfall max speed changed to %d lines per second."),(int)ceil(val*val)));
}
wproc->setView(waterfallCanvas->getViewState(), waterfallCanvas->getCenterFrequency(), waterfallCanvas->getBandwidth());
proc->setView(wproc->isView(), wproc->getCenterFrequency(), wproc->getBandwidth());
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
if (modemPropertiesUpdated.load() && demod && demod->isModemInitialized()) {
//reset notification flag
modemPropertiesUpdated.store(false);
modemProps->initProperties(demod->getModemArgs(), demod);
modemProps->updateTheme();
demodTray->Layout();
modemProps->fitColumns();
#if ENABLE_DIGITAL_LAB
if (demod->getModemType() == "digital") {
ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)demod->getOutput();
if (!outp->getDialog()) {
outp->setTitle(demod->getDemodulatorType() + ": " + frequencyToStr(demod->getFrequency()));
outp->setDialog(new DigitalConsole(this, outp)) ;
}
demod->showOutput();
}
#endif
} else if (!demod && modemPropertiesUpdated.load()) {
ModemArgInfoList dummyInfo;
modemProps->initProperties(dummyInfo, nullptr);
modemProps->updateTheme();
demodTray->Layout();
}
if (modemProps->IsShown() && modemProps->isCollapsed() && modemProps->GetMinWidth() > 22) {
modemProps->SetMinSize(wxSize(APPFRAME_MODEMPROPS_MINSIZE,-1));
modemProps->SetMaxSize(wxSize(APPFRAME_MODEMPROPS_MINSIZE,-1));
demodTray->Layout();
modemProps->fitColumns();
} else if (modemProps->IsShown() && !modemProps->isCollapsed() && modemProps->GetMinWidth() < 200) {
modemProps->SetMinSize(wxSize(APPFRAME_MODEMPROPS_MAXSIZE,-1));
modemProps->SetMaxSize(wxSize(APPFRAME_MODEMPROPS_MAXSIZE,-1));
demodTray->Layout();
modemProps->fitColumns();
}
int peakHoldMode = peakHoldButton->getSelection();
if (peakHoldButton->modeChanged()) {
wxGetApp().getSpectrumProcessor()->setPeakHold(peakHoldMode == 1);
//make the peak hold act on the current dmod also, like a zoomed-in version.
if (wxGetApp().getDemodSpectrumProcessor()) {
wxGetApp().getDemodSpectrumProcessor()->setPeakHold(peakHoldMode == 1);
}
peakHoldButton->clearModeChanged();
}
#if USE_HAMLIB
if (rigEnableMenuItem->IsChecked()) {
if (!wxGetApp().rigIsActive()) {
rigEnableMenuItem->Check(false);
wxGetApp().getConfig()->setRigEnabled(false);
}
}
#endif
#ifdef _WIN32
if (scopeCanvas && scopeCanvas->HasFocus()) {
waterfallCanvas->SetFocus();
}
#endif
if (!this->IsActive()) {
std::this_thread::sleep_for(std::chrono::milliseconds(30));
} else {
if (wxGetApp().getConfig()->getPerfMode() == AppConfig::PERF_LOW) {
std::this_thread::sleep_for(std::chrono::milliseconds(30));
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
event.RequestMore();
} }
@ -2586,9 +2637,9 @@ bool AppFrame::isUserDemodBusy() {
return (modemProps && modemProps->isMouseInView()) return (modemProps && modemProps->isMouseInView())
|| (waterfallCanvas->isMouseInView() && waterfallCanvas->isMouseDown()) || (waterfallCanvas->isMouseInView() && waterfallCanvas->isMouseDown())
|| (demodWaterfallCanvas && demodWaterfallCanvas->isMouseInView() && demodWaterfallCanvas->isMouseDown()) || (demodWaterfallCanvas && demodWaterfallCanvas->isMouseInView() && demodWaterfallCanvas->isMouseDown())
|| (wxGetApp().getDemodMgr().getLastActiveDemodulator() && || (wxGetApp().getDemodMgr().getCurrentModem() &&
wxGetApp().getDemodMgr().getActiveDemodulator() && wxGetApp().getDemodMgr().getActiveContextModem() &&
wxGetApp().getDemodMgr().getLastActiveDemodulator() != wxGetApp().getDemodMgr().getActiveDemodulator()); wxGetApp().getDemodMgr().getCurrentModem() != wxGetApp().getDemodMgr().getActiveContextModem());
} }
BookmarkView *AppFrame::getBookmarkView() { BookmarkView *AppFrame::getBookmarkView() {
@ -2671,7 +2722,7 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
DemodulatorInstancePtr demod = nullptr; DemodulatorInstancePtr demod = nullptr;
DemodulatorInstancePtr lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstancePtr lastDemod = wxGetApp().getDemodMgr().getCurrentModem();
int snap = wxGetApp().getFrequencySnap(); int snap = wxGetApp().getFrequencySnap();
@ -2739,7 +2790,7 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) {
return 1; return 1;
break; break;
case WXK_TAB: case WXK_TAB:
lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); lastDemod = wxGetApp().getDemodMgr().getCurrentModem();
if (!lastDemod) { if (!lastDemod) {
break; break;
} }
@ -2798,8 +2849,8 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) {
return 1; return 1;
} }
DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator(); DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getActiveContextModem();
DemodulatorInstancePtr lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstancePtr lastDemod = wxGetApp().getDemodMgr().getCurrentModem();
#ifdef wxHAS_RAW_KEY_CODES #ifdef wxHAS_RAW_KEY_CODES
switch (event.GetRawKeyCode()) { switch (event.GetRawKeyCode()) {
@ -2920,7 +2971,7 @@ void AppFrame::toggleActiveDemodRecording() {
return; return;
} }
DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator(); DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getActiveContextModem();
if (activeDemod) { if (activeDemod) {
activeDemod->setRecording(!activeDemod->isRecording()); activeDemod->setRecording(!activeDemod->isRecording());

View File

@ -325,4 +325,19 @@ private:
wxMenu *makeRigMenu(); wxMenu *makeRigMenu();
#endif #endif
void handleTXAntennaChange();
void handleCurrentModem();
void handleModeSelector();
void handleGainMeter();
void handleDemodWaterfallSpectrum();
void handleSpectrumWaterfall();
void handleMuteButton();
void handleScopeProcessor();
void handleScopeSpectrumProcessors();
void handleModemProperties();
void handlePeakHold();
#if USE_HAMLIB
void handleRigMenu();
#endif
}; };

View File

@ -944,7 +944,7 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM
switch (targetMode) { switch (targetMode) {
case FrequencyDialog::FDIALOG_TARGET_DEFAULT: case FrequencyDialog::FDIALOG_TARGET_DEFAULT:
case FrequencyDialog::FDIALOG_TARGET_FREQ: case FrequencyDialog::FDIALOG_TARGET_FREQ:
title = demodMgr.getActiveDemodulator()?demodTitle:freqTitle; title = demodMgr.getActiveContextModem()?demodTitle:freqTitle;
break; break;
case FrequencyDialog::FDIALOG_TARGET_BANDWIDTH: case FrequencyDialog::FDIALOG_TARGET_BANDWIDTH:
title = bwTitle; title = bwTitle;
@ -965,13 +965,13 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM
break; break;
} }
FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(350, 75), wxDEFAULT_DIALOG_STYLE, targetMode, initString); FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveContextModem(), wxPoint(-100,-100), wxSize(350, 75), wxDEFAULT_DIALOG_STYLE, targetMode, initString);
fdialog.ShowModal(); fdialog.ShowModal();
} }
void CubicSDR::showLabelInput() { void CubicSDR::showLabelInput() {
DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator(); DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getActiveContextModem();
if (activeDemod != nullptr) { if (activeDemod != nullptr) {

View File

@ -469,7 +469,8 @@ void DemodulatorInstance::setFrequency(long long freq) {
} }
#endif #endif
#if USE_HAMLIB #if USE_HAMLIB
if (wxGetApp().rigIsActive() && wxGetApp().getRigThread()->getFollowModem() && wxGetApp().getDemodMgr().getLastActiveDemodulator().get() == this) { if (wxGetApp().rigIsActive() && wxGetApp().getRigThread()->getFollowModem() &&
wxGetApp().getDemodMgr().getCurrentModem().get() == this) {
wxGetApp().getRigThread()->setFrequency(freq,true); wxGetApp().getRigThread()->setFrequency(freq,true);
} }
#endif #endif

View File

@ -97,7 +97,7 @@ std::vector<DemodulatorInstancePtr> DemodulatorMgr::getOrderedDemodulators(bool
DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(DemodulatorInstancePtr demod, bool actives) { DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(DemodulatorInstancePtr demod, bool actives) {
std::lock_guard < std::recursive_mutex > lock(demods_busy); std::lock_guard < std::recursive_mutex > lock(demods_busy);
if (!getLastActiveDemodulator()) { if (!getCurrentModem()) {
return nullptr; return nullptr;
} }
auto demods_ordered = getOrderedDemodulators(actives); auto demods_ordered = getOrderedDemodulators(actives);
@ -114,7 +114,7 @@ DemodulatorInstancePtr DemodulatorMgr::getPreviousDemodulator(DemodulatorInstanc
DemodulatorInstancePtr DemodulatorMgr::getNextDemodulator(DemodulatorInstancePtr demod, bool actives) { DemodulatorInstancePtr DemodulatorMgr::getNextDemodulator(DemodulatorInstancePtr demod, bool actives) {
std::lock_guard < std::recursive_mutex > lock(demods_busy); std::lock_guard < std::recursive_mutex > lock(demods_busy);
if (!getLastActiveDemodulator()) { if (!getCurrentModem()) {
return nullptr; return nullptr;
} }
auto demods_ordered = getOrderedDemodulators(actives); auto demods_ordered = getOrderedDemodulators(actives);
@ -152,11 +152,11 @@ void DemodulatorMgr::deleteThread(DemodulatorInstancePtr demod) {
auto i = std::find(demods.begin(), demods.end(), demod); auto i = std::find(demods.begin(), demods.end(), demod);
if (activeDemodulator == demod) { if (activeContextModem == demod) {
activeDemodulator = nullptr; activeContextModem = nullptr;
} }
if (lastActiveDemodulator == demod) { if (currentModem == demod) {
lastActiveDemodulator = nullptr; currentModem = nullptr;
} }
if (activeVisualDemodulator == demod) { if (activeVisualDemodulator == demod) {
activeVisualDemodulator = nullptr; activeVisualDemodulator = nullptr;
@ -215,25 +215,30 @@ bool DemodulatorMgr::anyDemodulatorsAt(long long freq, int bandwidth) {
void DemodulatorMgr::setActiveDemodulator(DemodulatorInstancePtr demod, bool temporary) { void DemodulatorMgr::setActiveDemodulator(DemodulatorInstancePtr demod, bool temporary) {
std::lock_guard < std::recursive_mutex > lock(demods_busy); std::lock_guard < std::recursive_mutex > lock(demods_busy);
// Should this be made the current modem (i.e. clicked, toggled)
if (!temporary) { if (!temporary) {
if (activeDemodulator != nullptr) { if (activeContextModem != nullptr) {
lastActiveDemodulator = activeDemodulator; currentModem = activeContextModem;
updateLastState(); updateLastState();
} else { } else {
lastActiveDemodulator = demod; currentModem = demod;
} }
updateLastState(); updateLastState();
wxGetApp().getBookmarkMgr().updateActiveList();
#if USE_HAMLIB #if USE_HAMLIB
if (wxGetApp().rigIsActive() && wxGetApp().getRigThread()->getFollowModem() && lastActiveDemodulator) { if (wxGetApp().rigIsActive() && wxGetApp().getRigThread()->getFollowModem() && currentModem) {
wxGetApp().getRigThread()->setFrequency(lastActiveDemodulator->getFrequency(),true); wxGetApp().getRigThread()->setFrequency(currentModem->getFrequency(),true);
} }
#endif #endif
wxGetApp().getBookmarkMgr().updateActiveList(); }
}
// TODO: This is probably unnecessary and confusing
if (activeVisualDemodulator) { if (activeVisualDemodulator) {
activeVisualDemodulator->setVisualOutputQueue(nullptr); activeVisualDemodulator->setVisualOutputQueue(nullptr);
} }
@ -241,15 +246,15 @@ void DemodulatorMgr::setActiveDemodulator(DemodulatorInstancePtr demod, bool tem
demod->setVisualOutputQueue(wxGetApp().getAudioVisualQueue()); demod->setVisualOutputQueue(wxGetApp().getAudioVisualQueue());
activeVisualDemodulator = demod; activeVisualDemodulator = demod;
} else { } else {
DemodulatorInstancePtr last = getLastActiveDemodulator(); DemodulatorInstancePtr last = getCurrentModem();
if (last) { if (last) {
last->setVisualOutputQueue(wxGetApp().getAudioVisualQueue()); last->setVisualOutputQueue(wxGetApp().getAudioVisualQueue());
} }
activeVisualDemodulator = last; activeVisualDemodulator = last;
} }
// :ODOT
activeDemodulator = demod; activeContextModem = demod;
} }
//Dangerous: this is only intended by some internal classes //Dangerous: this is only intended by some internal classes
@ -266,17 +271,27 @@ void DemodulatorMgr::setActiveDemodulatorByRawPointer(DemodulatorInstance* demod
} }
} }
DemodulatorInstancePtr DemodulatorMgr::getActiveDemodulator() { /**
* Get the currently focused modem, i.e. the one hovered by interaction
* If no active context modem is available the current modem is returned
* @return Active Context Modem
*/
DemodulatorInstancePtr DemodulatorMgr::getActiveContextModem() {
std::lock_guard < std::recursive_mutex > lock(demods_busy); std::lock_guard < std::recursive_mutex > lock(demods_busy);
if (activeDemodulator && !activeDemodulator->isActive()) { if (activeContextModem && !activeContextModem->isActive()) {
activeDemodulator = getLastActiveDemodulator(); activeContextModem = getCurrentModem();
} }
return activeDemodulator; return activeContextModem;
} }
DemodulatorInstancePtr DemodulatorMgr::getLastActiveDemodulator() { /**
return lastActiveDemodulator; * Get the last selected / focused modem
* This is the currently active modem
* @return Current Modem
*/
DemodulatorInstancePtr DemodulatorMgr::getCurrentModem() {
return currentModem;
} }
DemodulatorInstancePtr DemodulatorMgr::getLastDemodulatorWith(const std::string& type, DemodulatorInstancePtr DemodulatorMgr::getLastDemodulatorWith(const std::string& type,
@ -304,27 +319,27 @@ DemodulatorInstancePtr DemodulatorMgr::getLastDemodulatorWith(const std::string&
void DemodulatorMgr::updateLastState() { void DemodulatorMgr::updateLastState() {
std::lock_guard < std::recursive_mutex > lock(demods_busy); std::lock_guard < std::recursive_mutex > lock(demods_busy);
if (std::find(demods.begin(), demods.end(), lastActiveDemodulator) == demods.end()) { if (std::find(demods.begin(), demods.end(), currentModem) == demods.end()) {
if (activeDemodulator && activeDemodulator->isActive()) { if (activeContextModem && activeContextModem->isActive()) {
lastActiveDemodulator = activeDemodulator; currentModem = activeContextModem;
} else if (activeDemodulator && !activeDemodulator->isActive()){ } else if (activeContextModem && !activeContextModem->isActive()){
activeDemodulator = nullptr; activeContextModem = nullptr;
lastActiveDemodulator = nullptr; currentModem = nullptr;
} }
} }
if (lastActiveDemodulator && !lastActiveDemodulator->isActive()) { if (currentModem && !currentModem->isActive()) {
lastActiveDemodulator = nullptr; currentModem = nullptr;
} }
if (lastActiveDemodulator) { if (currentModem) {
lastBandwidth = lastActiveDemodulator->getBandwidth(); lastBandwidth = currentModem->getBandwidth();
lastDemodType = lastActiveDemodulator->getDemodulatorType(); lastDemodType = currentModem->getDemodulatorType();
lastDemodLock = lastActiveDemodulator->getDemodulatorLock()?true:false; lastDemodLock = currentModem->getDemodulatorLock()?true:false;
lastSquelchEnabled = lastActiveDemodulator->isSquelchEnabled(); lastSquelchEnabled = currentModem->isSquelchEnabled();
lastSquelch = lastActiveDemodulator->getSquelchLevel(); lastSquelch = currentModem->getSquelchLevel();
lastGain = lastActiveDemodulator->getGain(); lastGain = currentModem->getGain();
lastModemSettings[lastDemodType] = lastActiveDemodulator->readModemSettings(); lastModemSettings[lastDemodType] = currentModem->readModemSettings();
} }
} }
@ -424,7 +439,7 @@ void DemodulatorMgr::saveInstance(DataNode *node, DemodulatorInstancePtr inst) {
*node->newChild("delta_lock") = inst->isDeltaLock() ? 1 : 0; *node->newChild("delta_lock") = inst->isDeltaLock() ? 1 : 0;
*node->newChild("delta_ofs") = inst->getDeltaLockOfs(); *node->newChild("delta_ofs") = inst->getDeltaLockOfs();
} }
if (inst == getLastActiveDemodulator()) { if (inst == getCurrentModem()) {
*node->newChild("active") = 1; *node->newChild("active") = 1;
} }

View File

@ -39,8 +39,8 @@ public:
// and only set a pre-existing demod // and only set a pre-existing demod
void setActiveDemodulatorByRawPointer(DemodulatorInstance* demod, bool temporary = true); void setActiveDemodulatorByRawPointer(DemodulatorInstance* demod, bool temporary = true);
DemodulatorInstancePtr getActiveDemodulator(); DemodulatorInstancePtr getActiveContextModem();
DemodulatorInstancePtr getLastActiveDemodulator(); DemodulatorInstancePtr getCurrentModem();
DemodulatorInstancePtr getLastDemodulatorWith(const std::string& type, DemodulatorInstancePtr getLastDemodulatorWith(const std::string& type,
const std::wstring& userLabel, const std::wstring& userLabel,
long long frequency, long long frequency,
@ -87,8 +87,8 @@ private:
std::vector<DemodulatorInstancePtr> demods; std::vector<DemodulatorInstancePtr> demods;
DemodulatorInstancePtr activeDemodulator; DemodulatorInstancePtr activeContextModem;
DemodulatorInstancePtr lastActiveDemodulator; DemodulatorInstancePtr currentModem;
DemodulatorInstancePtr activeVisualDemodulator; DemodulatorInstancePtr activeVisualDemodulator;
int lastBandwidth; int lastBandwidth;

View File

@ -322,7 +322,8 @@ void DemodulatorThread::run() {
} }
if (!squelched && ati != nullptr) { if (!squelched && ati != nullptr) {
if (!muted.load() && (!wxGetApp().getSoloMode() || (demodInstance == wxGetApp().getDemodMgr().getLastActiveDemodulator().get()))) { if (!muted.load() && (!wxGetApp().getSoloMode() || (demodInstance ==
wxGetApp().getDemodMgr().getCurrentModem().get()))) {
//non-blocking push needed for audio out //non-blocking push needed for audio out
if (!audioOutputQueue->try_push(ati)) { if (!audioOutputQueue->try_push(ati)) {

View File

@ -356,7 +356,7 @@ wxTreeItemId BookmarkView::refreshBookmarks() {
void BookmarkView::doUpdateActiveList() { void BookmarkView::doUpdateActiveList() {
auto demods = wxGetApp().getDemodMgr().getDemodulators(); auto demods = wxGetApp().getDemodMgr().getDemodulators();
auto lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); auto lastActiveDemodulator = wxGetApp().getDemodMgr().getCurrentModem();
//capture the previously selected item info BY COPY (because the original will be destroyed together with the destroyed tree items) to restore it again after //capture the previously selected item info BY COPY (because the original will be destroyed together with the destroyed tree items) to restore it again after
//having rebuilding the whole tree. //having rebuilding the whole tree.

View File

@ -73,8 +73,8 @@ void RigThread::run() {
while (!stopping) { while (!stopping) {
std::this_thread::sleep_for(std::chrono::milliseconds(150)); std::this_thread::sleep_for(std::chrono::milliseconds(150));
auto activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator(); auto activeDemod = wxGetApp().getDemodMgr().getActiveContextModem();
auto lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); auto lastDemod = wxGetApp().getDemodMgr().getCurrentModem();
if (freqChanged.load() && (controlMode.load() || setOneShot.load())) { if (freqChanged.load() && (controlMode.load() || setOneShot.load())) {
status = rig_get_freq(rig, RIG_VFO_CURR, &freq); status = rig_get_freq(rig, RIG_VFO_CURR, &freq);

View File

@ -69,7 +69,7 @@ void SDRPostThread::updateActiveDemodulators() {
if (abs(frequency - demod->getFrequency()) > (sampleRate / 2)) { if (abs(frequency - demod->getFrequency()) > (sampleRate / 2)) {
// deactivate if active // deactivate if active
if (wxGetApp().getDemodMgr().getLastActiveDemodulator() == demod) { if (wxGetApp().getDemodMgr().getCurrentModem() == demod) {
demod->setActive(false); demod->setActive(false);
} }
@ -84,7 +84,7 @@ void SDRPostThread::updateActiveDemodulators() {
} }
} else if (!demod->isActive()) { // in range, activate if not activated } else if (!demod->isActive()) { // in range, activate if not activated
demod->setActive(true); demod->setActive(true);
if (wxGetApp().getDemodMgr().getLastActiveDemodulator() == nullptr) { if (wxGetApp().getDemodMgr().getCurrentModem() == nullptr) {
wxGetApp().getDemodMgr().setActiveDemodulator(demod); wxGetApp().getDemodMgr().setActiveDemodulator(demod);
} }
@ -305,7 +305,7 @@ void SDRPostThread::runSingleCH(SDRThreadIQData *data_in) {
// Handle active channels, channel 0 offset correction, de-interlacing and push data to demodulators // Handle active channels, channel 0 offset correction, de-interlacing and push data to demodulators
void SDRPostThread::runDemodChannels(int channelBandwidth) { void SDRPostThread::runDemodChannels(int channelBandwidth) {
DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstancePtr activeDemod = wxGetApp().getDemodMgr().getCurrentModem();
// Calculate channel data size // Calculate channel data size
size_t chanDataSize = dataOut.size()/numChannels; size_t chanDataSize = dataOut.size()/numChannels;

View File

@ -108,7 +108,7 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstancePtr demod, RGBA4f color,
bool soloMode = wxGetApp().getSoloMode(); bool soloMode = wxGetApp().getSoloMode();
bool isRecording = demod->isRecording(); bool isRecording = demod->isRecording();
bool isSolo = soloMode && demod == wxGetApp().getDemodMgr().getLastActiveDemodulator(); bool isSolo = soloMode && demod == wxGetApp().getDemodMgr().getCurrentModem();
RGBA4f labelBg(0, 0, 0, 0.35f); RGBA4f labelBg(0, 0, 0, 0.35f);
@ -433,7 +433,7 @@ void PrimaryGLContext::drawSingleDemodLabel(const std::wstring& demodStr, float
void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long long /* center_freq */, long long srate) { void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long long /* center_freq */, long long srate) {
DemodulatorInstancePtr demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstancePtr demod = wxGetApp().getDemodMgr().getCurrentModem();
long long bw = 0; long long bw = 0;

View File

@ -91,7 +91,7 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glLoadIdentity(); glLoadIdentity();
auto demods = wxGetApp().getDemodMgr().getDemodulators(); auto demods = wxGetApp().getDemodMgr().getDemodulators();
auto activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); auto activeDemodulator = wxGetApp().getDemodMgr().getActiveContextModem();
for (int i = 0, iMax = demods.size(); i < iMax; i++) { for (int i = 0, iMax = demods.size(); i < iMax; i++) {
if (!demods[i]->isActive()) { if (!demods[i]->isActive()) {
@ -111,7 +111,7 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
freq = roundf((float)freq/(float)snap)*snap; freq = roundf((float)freq/(float)snap)*snap;
} }
auto lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); auto lastActiveDemodulator = wxGetApp().getDemodMgr().getCurrentModem();
bool isNew = (((waterfallCanvas->isShiftDown() || (lastActiveDemodulator && !lastActiveDemodulator->isActive())) && lastActiveDemodulator) || (!lastActiveDemodulator)); bool isNew = (((waterfallCanvas->isShiftDown() || (lastActiveDemodulator && !lastActiveDemodulator->isActive())) && lastActiveDemodulator) || (!lastActiveDemodulator));

View File

@ -62,7 +62,7 @@ TuningCanvas::~TuningCanvas() {
bool TuningCanvas::changed() { bool TuningCanvas::changed() {
auto activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); auto activeDemod = wxGetApp().getDemodMgr().getCurrentModem();
long long current_freq = 0; long long current_freq = 0;
if (activeDemod != nullptr) { if (activeDemod != nullptr) {
@ -93,7 +93,7 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->DrawBegin(); glContext->DrawBegin();
auto activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); auto activeDemod = wxGetApp().getDemodMgr().getCurrentModem();
freq = 0; freq = 0;
if (activeDemod != nullptr) { if (activeDemod != nullptr) {
@ -171,7 +171,7 @@ void TuningCanvas::StepTuner(ActiveState state, int exponent, bool up) {
amount *= 2; amount *= 2;
} }
auto activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); auto activeDemod = wxGetApp().getDemodMgr().getCurrentModem();
if (state == TUNING_HOVER_FREQ && activeDemod) { if (state == TUNING_HOVER_FREQ && activeDemod) {
long long freq = activeDemod->getFrequency(); long long freq = activeDemod->getFrequency();
long long diff = abs(wxGetApp().getFrequency() - freq); long long diff = abs(wxGetApp().getFrequency() - freq);
@ -328,7 +328,7 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
} }
if (hoverState == TUNING_HOVER_BW || hoverState == TUNING_HOVER_FREQ) { if (hoverState == TUNING_HOVER_BW || hoverState == TUNING_HOVER_FREQ) {
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator()); wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getCurrentModem());
} else { } else {
wxGetApp().getDemodMgr().setActiveDemodulator(nullptr); wxGetApp().getDemodMgr().setActiveDemodulator(nullptr);
} }

View File

@ -267,11 +267,11 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
auto demods = wxGetApp().getDemodMgr().getDemodulators(); auto demods = wxGetApp().getDemodMgr().getDemodulators();
auto activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); auto activeDemodulator = wxGetApp().getDemodMgr().getActiveContextModem();
auto lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); auto lastActiveDemodulator = wxGetApp().getDemodMgr().getCurrentModem();
bool isNew = shiftDown bool isNew = shiftDown
|| (wxGetApp().getDemodMgr().getLastActiveDemodulator() && !wxGetApp().getDemodMgr().getLastActiveDemodulator()->isActive()); || (wxGetApp().getDemodMgr().getCurrentModem() && !wxGetApp().getDemodMgr().getCurrentModem()->isActive());
int currentBandwidth = getBandwidth(); int currentBandwidth = getBandwidth();
long long currentCenterFreq = getCenterFrequency(); long long currentCenterFreq = getCenterFrequency();
@ -279,7 +279,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
ColorTheme *currentTheme = ThemeMgr::mgr.currentTheme; ColorTheme *currentTheme = ThemeMgr::mgr.currentTheme;
std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType(); std::string last_type = wxGetApp().getDemodMgr().getLastDemodulatorType();
if (mouseTracker.mouseInView() || wxGetApp().getDemodMgr().getActiveDemodulator()) { if (mouseTracker.mouseInView() || wxGetApp().getDemodMgr().getActiveContextModem()) {
hoverAlpha += (1.0f-hoverAlpha)*0.1f; hoverAlpha += (1.0f-hoverAlpha)*0.1f;
if (hoverAlpha > 1.5f) { if (hoverAlpha > 1.5f) {
hoverAlpha = 1.5f; hoverAlpha = 1.5f;
@ -392,7 +392,7 @@ void WaterfallCanvas::OnKeyUp(wxKeyEvent& event) {
void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) { void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
InteractiveCanvas::OnKeyDown(event); InteractiveCanvas::OnKeyDown(event);
auto activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator(); auto activeDemod = wxGetApp().getDemodMgr().getActiveContextModem();
long long originalFreq = getCenterFrequency(); long long originalFreq = getCenterFrequency();
long long freq = originalFreq; long long freq = originalFreq;
@ -449,8 +449,8 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
wxGetApp().showLabelInput(); wxGetApp().showLabelInput();
break; break;
case 'C': case 'C':
if (wxGetApp().getDemodMgr().getActiveDemodulator()) { if (wxGetApp().getDemodMgr().getActiveContextModem()) {
wxGetApp().setFrequency(wxGetApp().getDemodMgr().getActiveDemodulator()->getFrequency()); wxGetApp().setFrequency(wxGetApp().getDemodMgr().getActiveContextModem()->getFrequency());
} else if (mouseTracker.mouseInView()) { } else if (mouseTracker.mouseInView()) {
long long freq = getFrequencyAt(mouseTracker.getMouseX()); long long freq = getFrequencyAt(mouseTracker.getMouseX());
@ -589,7 +589,7 @@ void WaterfallCanvas::updateHoverState() {
void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
InteractiveCanvas::OnMouseMoved(event); InteractiveCanvas::OnMouseMoved(event);
auto demod = wxGetApp().getDemodMgr().getActiveDemodulator(); auto demod = wxGetApp().getDemodMgr().getActiveContextModem();
if (mouseTracker.mouseDown()) { if (mouseTracker.mouseDown()) {
if (demod == nullptr) { if (demod == nullptr) {
@ -654,12 +654,12 @@ void WaterfallCanvas::OnMouseDown(wxMouseEvent& event) {
wxGetApp().getDemodMgr().updateLastState(); wxGetApp().getDemodMgr().updateLastState();
if (dragState && dragState != WF_DRAG_RANGE) { if (dragState && dragState != WF_DRAG_RANGE) {
auto demod = wxGetApp().getDemodMgr().getActiveDemodulator(); auto demod = wxGetApp().getDemodMgr().getActiveContextModem();
if (demod) { if (demod) {
dragOfs = (long long) (mouseTracker.getMouseX() * (float) getBandwidth()) + getCenterFrequency() - (getBandwidth() / 2) - demod->getFrequency(); dragOfs = (long long) (mouseTracker.getMouseX() * (float) getBandwidth()) + getCenterFrequency() - (getBandwidth() / 2) - demod->getFrequency();
dragBW = demod->getBandwidth(); dragBW = demod->getBandwidth();
} }
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getActiveDemodulator(), false); wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getActiveContextModem(), false);
} }
} }
@ -674,14 +674,14 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
InteractiveCanvas::OnMouseReleased(event); InteractiveCanvas::OnMouseReleased(event);
wxGetApp().getDemodMgr().updateLastState(); wxGetApp().getDemodMgr().updateLastState();
bool isNew = shiftDown || (wxGetApp().getDemodMgr().getLastActiveDemodulator() == nullptr) bool isNew = shiftDown || (wxGetApp().getDemodMgr().getCurrentModem() == nullptr)
|| (wxGetApp().getDemodMgr().getLastActiveDemodulator() && !wxGetApp().getDemodMgr().getLastActiveDemodulator()->isActive()); || (wxGetApp().getDemodMgr().getCurrentModem() && !wxGetApp().getDemodMgr().getCurrentModem()->isActive());
mouseTracker.setVertDragLock(false); mouseTracker.setVertDragLock(false);
mouseTracker.setHorizDragLock(false); mouseTracker.setHorizDragLock(false);
DemodulatorInstancePtr demod = isNew?nullptr:wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstancePtr demod = isNew?nullptr: wxGetApp().getDemodMgr().getCurrentModem();
DemodulatorInstancePtr activeDemod = isNew?nullptr:wxGetApp().getDemodMgr().getActiveDemodulator(); DemodulatorInstancePtr activeDemod = isNew?nullptr: wxGetApp().getDemodMgr().getActiveContextModem();
DemodulatorMgr *mgr = &wxGetApp().getDemodMgr(); DemodulatorMgr *mgr = &wxGetApp().getDemodMgr();
@ -710,7 +710,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
if (dragState == WF_DRAG_NONE) { if (dragState == WF_DRAG_NONE) {
if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) { if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) {
mgr->updateLastState(); mgr->updateLastState();
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); demod = wxGetApp().getDemodMgr().getCurrentModem();
} else { } else {
isNew = true; isNew = true;
demod = wxGetApp().getDemodMgr().newThread(); demod = wxGetApp().getDemodMgr().newThread();
@ -811,7 +811,7 @@ void WaterfallCanvas::OnMouseReleased(wxMouseEvent& event) {
if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) { if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) {
mgr->updateLastState(); mgr->updateLastState();
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); demod = wxGetApp().getDemodMgr().getCurrentModem();
} else { } else {
demod = wxGetApp().getDemodMgr().newThread(); demod = wxGetApp().getDemodMgr().newThread();
demod->setFrequency(freq); demod->setFrequency(freq);