From 2295b47d697c169bc02280a8f4e3a59745074262 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sun, 7 Feb 2016 18:01:11 -0500 Subject: [PATCH 01/11] Initial global keyboard handler setup --- src/AppFrame.cpp | 115 ++++++++++++++++++++++++++++--- src/AppFrame.h | 3 + src/CubicSDR.cpp | 16 +++++ src/CubicSDR.h | 2 + src/visual/InteractiveCanvas.cpp | 2 +- src/visual/TuningCanvas.cpp | 4 +- src/visual/TuningCanvas.h | 4 +- src/visual/WaterfallCanvas.cpp | 8 +-- src/visual/WaterfallCanvas.h | 4 +- 9 files changed, 135 insertions(+), 23 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index cdc68ea..e93f0b0 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -288,7 +288,7 @@ AppFrame::AppFrame() : this->SetSizer(vbox); // waterfallCanvas->SetFocusFromKbd(); - waterfallCanvas->SetFocus(); +// waterfallCanvas->SetFocus(); // SetIcon(wxICON(sample)); @@ -1196,15 +1196,15 @@ void AppFrame::OnIdle(wxIdleEvent& event) { } } - if (demodTuner->getMouseTracker()->mouseInView()) { - if (!demodTuner->HasFocus()) { - demodTuner->SetFocus(); - } - } else if (!wxGetApp().isDeviceSelectorOpen() && (!modemProps || !modemProps->isMouseInView())) { - if (!waterfallCanvas->HasFocus()) { - waterfallCanvas->SetFocus(); - } - } +// if (demodTuner->getMouseTracker()->mouseInView()) { +// if (!demodTuner->HasFocus()) { +// demodTuner->SetFocus(); +// } +// } else if (!wxGetApp().isDeviceSelectorOpen() && (!modemProps || !modemProps->isMouseInView())) { +// if (!waterfallCanvas->HasFocus()) { +// waterfallCanvas->SetFocus(); +// } +// } scopeCanvas->setPPMMode(demodTuner->isAltDown()); @@ -1276,6 +1276,8 @@ void AppFrame::OnIdle(wxIdleEvent& event) { if (!this->IsActive()) { std::this_thread::sleep_for(std::chrono::milliseconds(25)); + } else { + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } event.RequestMore(); @@ -1540,3 +1542,96 @@ void AppFrame::setMainWaterfallFFTSize(int fftSize) { waterfallDataThread->getProcessor()->setFFTSize(fftSize); waterfallCanvas->setFFTSize(fftSize); } + +int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) { + if (!this->IsActive()) { + return -1; + } + + switch (event.GetKeyCode()) { + case WXK_UP: + case WXK_NUMPAD_UP: + case WXK_DOWN: + case WXK_NUMPAD_DOWN: + case WXK_LEFT: + case WXK_NUMPAD_LEFT: + case WXK_RIGHT: + case WXK_NUMPAD_RIGHT: + waterfallCanvas->OnKeyDown(event); + return 0; + case 'A': + case 'F': + case 'L': + case 'U': + return 0; + default: + break; + } + + if (demodTuner->getMouseTracker()->mouseInView()) { + demodTuner->OnKeyDown(event); + return 0; + } else if (waterfallCanvas->getMouseTracker()->mouseInView()) { + waterfallCanvas->OnKeyDown(event); + return 0; + } + + return 0; +} + +int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) { + if (!this->IsActive()) { + return -1; + } + + switch (event.GetKeyCode()) { + case WXK_SPACE: + if (!demodTuner->getMouseTracker()->mouseInView()) { + wxGetApp().showFrequencyInput(); + return 0; + } + break; + case WXK_UP: + case WXK_NUMPAD_UP: + case WXK_DOWN: + case WXK_NUMPAD_DOWN: + case WXK_LEFT: + case WXK_NUMPAD_LEFT: + case WXK_RIGHT: + case WXK_NUMPAD_RIGHT: + waterfallCanvas->OnKeyUp(event); + return 0; + case 'A': + demodModeSelector->setSelection("AM"); + break; + case 'F': + if (demodModeSelector->getSelectionLabel() == "FM") { + demodModeSelector->setSelection("FMS"); + } else { + demodModeSelector->setSelection("FM"); + } + break; + case 'L': + demodModeSelector->setSelection("LSB"); + break; + case 'U': + demodModeSelector->setSelection("USB"); + break; + default: + break; + } + + if (demodTuner->getMouseTracker()->mouseInView()) { + demodTuner->OnKeyUp(event); + return 0; + } else if (waterfallCanvas->getMouseTracker()->mouseInView()) { + waterfallCanvas->OnKeyUp(event); + return 0; + } + + + // TODO: Catch key-ups outside of original target + + return 0; +} + diff --git a/src/AppFrame.h b/src/AppFrame.h index cfa549c..84d32ba 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -75,6 +75,9 @@ public: void updateModemProperties(ModemArgInfoList args); void setMainWaterfallFFTSize(int fftSize); + int OnGlobalKeyDown(wxKeyEvent &event); + int OnGlobalKeyUp(wxKeyEvent &event); + private: void OnMenu(wxCommandEvent& event); void OnClose(wxCloseEvent& event); diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index d023ad1..4d1517b 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -749,6 +749,22 @@ std::string CubicSDR::getModulePath() { return modulePath; } +int CubicSDR::FilterEvent(wxEvent& event) { + if (!appframe) { + return -1; + } + + if (event.GetEventType() == wxEVT_KEY_DOWN) { + return appframe->OnGlobalKeyDown((wxKeyEvent&)event); + } + + if (event.GetEventType() == wxEVT_KEY_UP) { + return appframe->OnGlobalKeyUp((wxKeyEvent&)event); + } + + return -1; // process normally +} + #ifdef USE_HAMLIB RigThread *CubicSDR::getRigThread() { return rigThread; diff --git a/src/CubicSDR.h b/src/CubicSDR.h index caa997f..83ad557 100644 --- a/src/CubicSDR.h +++ b/src/CubicSDR.h @@ -161,6 +161,8 @@ public: #endif private: + int FilterEvent(wxEvent& event); + AppFrame *appframe; AppConfig config; PrimaryGLContext *m_glContext; diff --git a/src/visual/InteractiveCanvas.cpp b/src/visual/InteractiveCanvas.cpp index 228277f..edd85dc 100644 --- a/src/visual/InteractiveCanvas.cpp +++ b/src/visual/InteractiveCanvas.cpp @@ -19,7 +19,7 @@ InteractiveCanvas::InteractiveCanvas(wxWindow *parent, int *attribList) : wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize, - wxFULL_REPAINT_ON_RESIZE| wxWANTS_CHARS), parent(parent), shiftDown(false), altDown(false), ctrlDown(false), centerFreq(0), bandwidth(0), lastBandwidth(0), isView( + wxFULL_REPAINT_ON_RESIZE), parent(parent), shiftDown(false), altDown(false), ctrlDown(false), centerFreq(0), bandwidth(0), lastBandwidth(0), isView( false) { mouseTracker.setTarget(this); } diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 3616463..bd21503 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -26,8 +26,8 @@ EVT_RIGHT_UP(TuningCanvas::OnMouseRightReleased) EVT_LEAVE_WINDOW(TuningCanvas::OnMouseLeftWindow) EVT_ENTER_WINDOW(TuningCanvas::OnMouseEnterWindow) EVT_MOUSEWHEEL(TuningCanvas::OnMouseWheelMoved) -EVT_KEY_DOWN(TuningCanvas::OnKeyDown) -EVT_KEY_UP(TuningCanvas::OnKeyUp) +//EVT_KEY_DOWN(TuningCanvas::OnKeyDown) +//EVT_KEY_UP(TuningCanvas::OnKeyUp) wxEND_EVENT_TABLE() TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) : diff --git a/src/visual/TuningCanvas.h b/src/visual/TuningCanvas.h index daf41ff..3482163 100644 --- a/src/visual/TuningCanvas.h +++ b/src/visual/TuningCanvas.h @@ -25,6 +25,8 @@ public: bool changed(); void setHalfBand(bool hb); + void OnKeyDown(wxKeyEvent& event); + void OnKeyUp(wxKeyEvent& event); private: void OnPaint(wxPaintEvent& event); @@ -36,8 +38,6 @@ private: void OnMouseReleased(wxMouseEvent& event); void OnMouseEnterWindow(wxMouseEvent& event); void OnMouseLeftWindow(wxMouseEvent& event); - void OnKeyDown(wxKeyEvent& event); - void OnKeyUp(wxKeyEvent& event); void OnMouseRightDown(wxMouseEvent& event); void OnMouseRightReleased(wxMouseEvent& event); diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 6d5b5c9..522c82d 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -19,8 +19,8 @@ wxBEGIN_EVENT_TABLE(WaterfallCanvas, wxGLCanvas) EVT_PAINT(WaterfallCanvas::OnPaint) -EVT_KEY_DOWN(WaterfallCanvas::OnKeyDown) -EVT_KEY_UP(WaterfallCanvas::OnKeyUp) +//EVT_KEY_DOWN(WaterfallCanvas::OnKeyDown) +//EVT_KEY_UP(WaterfallCanvas::OnKeyUp) EVT_IDLE(WaterfallCanvas::OnIdle) EVT_MOTION(WaterfallCanvas::OnMouseMoved) EVT_LEFT_DOWN(WaterfallCanvas::OnMouseDown) @@ -345,7 +345,6 @@ void WaterfallCanvas::OnKeyUp(wxKeyEvent& event) { altDown = event.AltDown(); ctrlDown = event.ControlDown(); switch (event.GetKeyCode()) { - case 'A': case WXK_UP: case WXK_NUMPAD_UP: scaleMove = 0.0; @@ -354,7 +353,6 @@ void WaterfallCanvas::OnKeyUp(wxKeyEvent& event) { mouseZoom = 0.95; } break; - case 'Z': case WXK_DOWN: case WXK_NUMPAD_DOWN: scaleMove = 0.0; @@ -381,7 +379,6 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) { long long freq = originalFreq; switch (event.GetKeyCode()) { - case 'A': case WXK_UP: case WXK_NUMPAD_UP: if (!shiftDown) { @@ -391,7 +388,6 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) { scaleMove = 1.0; } break; - case 'Z': case WXK_DOWN: case WXK_NUMPAD_DOWN: if (!shiftDown) { diff --git a/src/visual/WaterfallCanvas.h b/src/visual/WaterfallCanvas.h index 013e3fc..9aff56b 100644 --- a/src/visual/WaterfallCanvas.h +++ b/src/visual/WaterfallCanvas.h @@ -33,11 +33,11 @@ public: void setLinesPerSecond(int lps); void setMinBandwidth(int min); -private: - void OnPaint(wxPaintEvent& event); void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); +private: + void OnPaint(wxPaintEvent& event); void OnIdle(wxIdleEvent &event); void OnMouseMoved(wxMouseEvent& event); From d7bb214d42a20e1625b4814e8eeff7b06276c86d Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sun, 7 Feb 2016 19:32:05 -0500 Subject: [PATCH 02/11] Start typing number to set center frequency --- src/AppFrame.cpp | 13 +++++++++++++ src/CubicSDR.cpp | 4 ++-- src/CubicSDR.h | 2 +- src/FrequencyDialog.cpp | 10 ++++++++-- src/FrequencyDialog.h | 3 ++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index e93f0b0..afecb5d 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -1564,6 +1564,19 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) { case 'L': case 'U': return 0; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + wxGetApp().showFrequencyInput(FrequencyDialog::FDIALOG_TARGET_DEFAULT, std::to_string(event.GetKeyCode() - '0')); + return 0; + break; default: break; } diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index 4d1517b..1db3ac9 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -650,7 +650,7 @@ int CubicSDR::getPPM() { } -void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode) { +void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode, wxString initString) { const wxString demodTitle("Set Demodulator Frequency"); const wxString freqTitle("Set Center Frequency"); const wxString bwTitle("Set Demodulator Bandwidth"); @@ -668,7 +668,7 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM break; } - FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(320, 75 ), wxDEFAULT_DIALOG_STYLE, targetMode); + FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(320, 75 ), wxDEFAULT_DIALOG_STYLE, targetMode, initString); fdialog.ShowModal(); } diff --git a/src/CubicSDR.h b/src/CubicSDR.h index 83ad557..d15adbc 100644 --- a/src/CubicSDR.h +++ b/src/CubicSDR.h @@ -125,7 +125,7 @@ public: void setPPM(int ppm_in); int getPPM(); - void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT); + void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT, wxString initString = ""); AppFrame *getAppFrame(); bool areDevicesReady(); diff --git a/src/FrequencyDialog.cpp b/src/FrequencyDialog.cpp index 6d4b848..eda526e 100644 --- a/src/FrequencyDialog.cpp +++ b/src/FrequencyDialog.cpp @@ -9,7 +9,7 @@ EVT_CHAR_HOOK(FrequencyDialog::OnChar) wxEND_EVENT_TABLE() FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstance *demod, const wxPoint & position, - const wxSize & size, long style, FrequencyDialogTarget targetMode) : + const wxSize & size, long style, FrequencyDialogTarget targetMode, wxString initString) : wxDialog(parent, id, title, position, size, style) { wxString freqStr; activeDemod = demod; @@ -38,7 +38,13 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin Centre(); - dialogText->SetSelection(-1, -1); + if (initString != "") { + dialogText->SetValue(initString); + dialogText->SetSelection(initString.length(), initString.length()); + dialogText->SetFocus(); + } else { + dialogText->SetSelection(-1, -1); + } } diff --git a/src/FrequencyDialog.h b/src/FrequencyDialog.h index d0c57b0..03859b8 100644 --- a/src/FrequencyDialog.h +++ b/src/FrequencyDialog.h @@ -17,7 +17,8 @@ public: const wxPoint & pos = wxDefaultPosition, const wxSize & size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, - FrequencyDialogTarget targetMode = FDIALOG_TARGET_DEFAULT); + FrequencyDialogTarget targetMode = FDIALOG_TARGET_DEFAULT, + wxString initString = ""); wxTextCtrl * dialogText; From 96d22ee8f77de31a248f4fa9bbd2947c5029e1cc Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sun, 7 Feb 2016 21:05:49 -0500 Subject: [PATCH 03/11] Set waterfall lps or spectrum avg by space/typing --- src/AppFrame.cpp | 39 +++++++++++++++++++++++++++-- src/AppFrame.h | 6 +++++ src/CubicSDR.cpp | 20 +++++++++++++-- src/CubicSDR.h | 2 ++ src/FrequencyDialog.cpp | 50 ++++++++++++++++++++++++++++++++++--- src/FrequencyDialog.h | 9 ++++++- src/visual/MeterCanvas.cpp | 5 ++++ src/visual/MeterCanvas.h | 1 + src/visual/TuningCanvas.cpp | 4 +++ src/visual/TuningCanvas.h | 2 ++ 10 files changed, 130 insertions(+), 8 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index afecb5d..24556c1 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -1543,6 +1543,32 @@ void AppFrame::setMainWaterfallFFTSize(int fftSize) { waterfallCanvas->setFFTSize(fftSize); } +FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() { + FrequencyDialog::FrequencyDialogTarget target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT; + + if (waterfallSpeedMeter->getMouseTracker()->mouseInView()) { + target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_WATERFALL_LPS; + } + else if (spectrumAvgMeter->getMouseTracker()->mouseInView()) { + target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_SPECTRUM_AVG; + } else if (demodTuner->getMouseTracker()->mouseInView()) { + switch (demodTuner->getHoverState()) { + case TuningCanvas::ActiveState::TUNING_HOVER_BW: + target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH; + break; + case TuningCanvas::ActiveState::TUNING_HOVER_FREQ: + target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_FREQ; + break; + case TuningCanvas::ActiveState::TUNING_HOVER_CENTER: + default: + target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT; + break; + + } + } + return target; +} + int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) { if (!this->IsActive()) { return -1; @@ -1574,7 +1600,7 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) { case '7': case '8': case '9': - wxGetApp().showFrequencyInput(FrequencyDialog::FDIALOG_TARGET_DEFAULT, std::to_string(event.GetKeyCode() - '0')); + wxGetApp().showFrequencyInput(getFrequencyDialogTarget(), std::to_string(event.GetKeyCode() - '0')); return 0; break; default: @@ -1600,7 +1626,7 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) { switch (event.GetKeyCode()) { case WXK_SPACE: if (!demodTuner->getMouseTracker()->mouseInView()) { - wxGetApp().showFrequencyInput(); + wxGetApp().showFrequencyInput(getFrequencyDialogTarget()); return 0; } break; @@ -1648,3 +1674,12 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) { return 0; } + +void AppFrame::setWaterfallLinesPerSecond(int lps) { + waterfallSpeedMeter->setUserInputValue(sqrt(lps)); +} + +void AppFrame::setSpectrumAvgSpeed(double avg) { + spectrumAvgMeter->setUserInputValue(avg); +} + diff --git a/src/AppFrame.h b/src/AppFrame.h index 84d32ba..afd1f0e 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -18,6 +18,7 @@ #include "SDRDeviceInfo.h" #include "ModemProperties.h" //#include "UITestCanvas.h" +#include "FrequencyDialog.h" #include @@ -78,6 +79,11 @@ public: int OnGlobalKeyDown(wxKeyEvent &event); int OnGlobalKeyUp(wxKeyEvent &event); + void setWaterfallLinesPerSecond(int lps); + void setSpectrumAvgSpeed(double avg); + + FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget(); + private: void OnMenu(wxCommandEvent& event); void OnClose(wxCloseEvent& event); diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index 1db3ac9..5320cfe 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -134,6 +134,7 @@ CubicSDR::CubicSDR() : appframe(NULL), m_glContext(NULL), frequency(0), offset(0 sdrThread(NULL), sdrPostThread(NULL), spectrumVisualThread(NULL), demodVisualThread(NULL), pipeSDRIQData(NULL), pipeIQVisualData(NULL), pipeAudioVisualData(NULL), t_SDR(NULL), t_PostSDR(NULL) { sampleRateInitialized.store(false); agcMode.store(true); + fdlgTarget = FrequencyDialog::FDIALOG_TARGET_DEFAULT; } bool CubicSDR::OnInit() { @@ -649,14 +650,23 @@ int CubicSDR::getPPM() { return ppm; } +void CubicSDR::setFrequencyInputTarget(FrequencyDialog::FrequencyDialogTarget targetMode) { + fdlgTarget = targetMode; +} void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode, wxString initString) { const wxString demodTitle("Set Demodulator Frequency"); const wxString freqTitle("Set Center Frequency"); - const wxString bwTitle("Set Demodulator Bandwidth"); + const wxString bwTitle("Modem Bandwidth (150Hz - 500KHz)"); + const wxString lpsTitle("Lines-Per-Second (1-1024)"); + const wxString avgTitle("Average Rate (0.1 - 0.99)"); wxString title; +// if (targetMode == FrequencyDialog::FDIALOG_TARGET_DEFAULT && fdlgTarget != FrequencyDialog::FDIALOG_TARGET_DEFAULT) { +// targetMode = fdlgTarget; +// } + switch (targetMode) { case FrequencyDialog::FDIALOG_TARGET_DEFAULT: title = demodMgr.getActiveDemodulator()?demodTitle:freqTitle; @@ -664,11 +674,17 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM case FrequencyDialog::FDIALOG_TARGET_BANDWIDTH: title = bwTitle; break; + case FrequencyDialog::FDIALOG_TARGET_WATERFALL_LPS: + title = lpsTitle; + break; + case FrequencyDialog::FDIALOG_TARGET_SPECTRUM_AVG: + title = avgTitle; + break; default: break; } - FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(320, 75 ), wxDEFAULT_DIALOG_STYLE, targetMode, initString); + FrequencyDialog fdialog(appframe, -1, title, demodMgr.getActiveDemodulator(), wxPoint(-100,-100), wxSize(350, 75), wxDEFAULT_DIALOG_STYLE, targetMode, initString); fdialog.ShowModal(); } diff --git a/src/CubicSDR.h b/src/CubicSDR.h index d15adbc..c96f18a 100644 --- a/src/CubicSDR.h +++ b/src/CubicSDR.h @@ -125,6 +125,7 @@ public: void setPPM(int ppm_in); int getPPM(); + void setFrequencyInputTarget(FrequencyDialog::FrequencyDialogTarget targetMode); void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT, wxString initString = ""); AppFrame *getAppFrame(); @@ -207,6 +208,7 @@ private: std::mutex notify_busy; std::atomic_bool frequency_locked; std::atomic_llong lock_freq; + FrequencyDialog::FrequencyDialogTarget fdlgTarget; #ifdef USE_HAMLIB RigThread *rigThread; std::thread *t_Rig; diff --git a/src/FrequencyDialog.cpp b/src/FrequencyDialog.cpp index eda526e..09b0f19 100644 --- a/src/FrequencyDialog.cpp +++ b/src/FrequencyDialog.cpp @@ -31,18 +31,29 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth()); } } + + if (targetMode == FDIALOG_TARGET_WATERFALL_LPS) { + freqStr = std::to_string(wxGetApp().getAppFrame()->getWaterfallDataThread()->getLinesPerSecond()); + } + if (targetMode == FDIALOG_TARGET_SPECTRUM_AVG) { + freqStr = std::to_string(wxGetApp().getSpectrumProcessor()->getFFTAverageRate()); + } + dialogText = new wxTextCtrl(this, wxID_FREQ_INPUT, freqStr, wxPoint(6, 1), wxSize(size.GetWidth() - 20, size.GetHeight() - 70), wxTE_PROCESS_ENTER); dialogText->SetFont(wxFont(20, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); Centre(); - if (initString != "") { + if (initString != "" && initString.length() == 1) { dialogText->SetValue(initString); dialogText->SetSelection(initString.length(), initString.length()); dialogText->SetFocus(); } else { + if (initString != "") { + dialogText->SetValue(initString); + } dialogText->SetSelection(-1, -1); } } @@ -51,15 +62,17 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin void FrequencyDialog::OnChar(wxKeyEvent& event) { int c = event.GetKeyCode(); long long freq; + double dblval; std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType(); - + std::string strValue = dialogText->GetValue().ToStdString(); + switch (c) { case WXK_RETURN: case WXK_NUMPAD_ENTER: // Do Stuff - freq = strToFrequency(dialogText->GetValue().ToStdString()); if (targetMode == FDIALOG_TARGET_DEFAULT) { + freq = strToFrequency(strValue); if (activeDemod) { activeDemod->setTracking(true); activeDemod->setFollow(true); @@ -70,6 +83,7 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) { } } if (targetMode == FDIALOG_TARGET_BANDWIDTH) { + freq = strToFrequency(strValue); if (lastDemodType == "USB" || lastDemodType == "LSB") { freq *= 2; } @@ -79,6 +93,36 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) { wxGetApp().getDemodMgr().setLastBandwidth(freq); } } + if (targetMode == FDIALOG_TARGET_WATERFALL_LPS) { + try { + freq = std::stoi(strValue); + } catch (exception e) { + Close(); + break; + } + if (freq > 1024) { + freq = 1024; + } + if (freq < 1) { + freq = 1; + } + wxGetApp().getAppFrame()->setWaterfallLinesPerSecond(freq); + } + if (targetMode == FDIALOG_TARGET_SPECTRUM_AVG) { + try { + dblval = std::stod(strValue); + } catch (exception e) { + Close(); + break; + } + if (dblval > 0.99) { + dblval = 0.99; + } + if (dblval < 0.1) { + dblval = 0.1; + } + wxGetApp().getAppFrame()->setSpectrumAvgSpeed(dblval); + } Close(); break; case WXK_ESCAPE: diff --git a/src/FrequencyDialog.h b/src/FrequencyDialog.h index 03859b8..768401a 100644 --- a/src/FrequencyDialog.h +++ b/src/FrequencyDialog.h @@ -11,7 +11,14 @@ class FrequencyDialog: public wxDialog { public: - typedef enum FrequencyDialogTarget { FDIALOG_TARGET_DEFAULT, FDIALOG_TARGET_CENTERFREQ, FDIALOG_TARGET_FREQ, FDIALOG_TARGET_BANDWIDTH } FrequencyDialogTarget; + typedef enum FrequencyDialogTarget { + FDIALOG_TARGET_DEFAULT, + FDIALOG_TARGET_CENTERFREQ, + FDIALOG_TARGET_FREQ, + FDIALOG_TARGET_BANDWIDTH, + FDIALOG_TARGET_WATERFALL_LPS, + FDIALOG_TARGET_SPECTRUM_AVG + } FrequencyDialogTarget; FrequencyDialog ( wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstance *demod = NULL, const wxPoint & pos = wxDefaultPosition, diff --git a/src/visual/MeterCanvas.cpp b/src/visual/MeterCanvas.cpp index e696421..d5b6037 100644 --- a/src/visual/MeterCanvas.cpp +++ b/src/visual/MeterCanvas.cpp @@ -52,6 +52,11 @@ void MeterCanvas::setMin(float min_in) { Refresh(); } +void MeterCanvas::setUserInputValue(float slider_in) { + userInputValue = slider_in; + Refresh(); +} + void MeterCanvas::setInputValue(float slider_in) { userInputValue = inputValue = slider_in; Refresh(); diff --git a/src/visual/MeterCanvas.h b/src/visual/MeterCanvas.h index 12577b2..7da390e 100644 --- a/src/visual/MeterCanvas.h +++ b/src/visual/MeterCanvas.h @@ -24,6 +24,7 @@ public: void setMax(float max_in); void setMin(float max_in); + void setUserInputValue(float slider_in); void setInputValue(float slider_in); bool inputChanged(); float getInputValue(); diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index bd21503..d5e0160 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -428,3 +428,7 @@ void TuningCanvas::OnKeyDown(wxKeyEvent& event) { void TuningCanvas::OnKeyUp(wxKeyEvent& event) { InteractiveCanvas::OnKeyUp(event); } + +TuningCanvas::ActiveState TuningCanvas::getHoverState() { + return hoverState; +} diff --git a/src/visual/TuningCanvas.h b/src/visual/TuningCanvas.h index 3482163..403181f 100644 --- a/src/visual/TuningCanvas.h +++ b/src/visual/TuningCanvas.h @@ -28,6 +28,8 @@ public: void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); + ActiveState getHoverState(); + private: void OnPaint(wxPaintEvent& event); void OnIdle(wxIdleEvent &event); From 8737728cf9f480df772ab496100bbb73dbff144b Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sun, 7 Feb 2016 22:19:05 -0500 Subject: [PATCH 04/11] Control gains with space or numeric entry --- src/AppFrame.cpp | 26 ++++++++++++-------------- src/AppFrame.h | 1 + src/CubicSDR.cpp | 23 +++++++++++++++-------- src/CubicSDR.h | 5 ++++- src/FrequencyDialog.cpp | 29 +++++++++++++++++++++++++++++ src/FrequencyDialog.h | 3 ++- src/visual/GainCanvas.cpp | 3 +++ 7 files changed, 66 insertions(+), 24 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 24556c1..468a147 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -287,9 +287,6 @@ AppFrame::AppFrame() : this->SetSizer(vbox); - // waterfallCanvas->SetFocusFromKbd(); -// waterfallCanvas->SetFocus(); - // SetIcon(wxICON(sample)); // Make a menubar @@ -1196,16 +1193,6 @@ void AppFrame::OnIdle(wxIdleEvent& event) { } } -// if (demodTuner->getMouseTracker()->mouseInView()) { -// if (!demodTuner->HasFocus()) { -// demodTuner->SetFocus(); -// } -// } else if (!wxGetApp().isDeviceSelectorOpen() && (!modemProps || !modemProps->isMouseInView())) { -// if (!waterfallCanvas->HasFocus()) { -// waterfallCanvas->SetFocus(); -// } -// } - scopeCanvas->setPPMMode(demodTuner->isAltDown()); scopeCanvas->setShowDb(spectrumCanvas->getShowDb()); @@ -1543,6 +1530,13 @@ void AppFrame::setMainWaterfallFFTSize(int fftSize) { waterfallCanvas->setFFTSize(fftSize); } + +void AppFrame::refreshGainUI() { + gainCanvas->updateGainUI(); + gainCanvas->Refresh(); +} + + FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() { FrequencyDialog::FrequencyDialogTarget target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT; @@ -1551,7 +1545,8 @@ FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() { } else if (spectrumAvgMeter->getMouseTracker()->mouseInView()) { target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_SPECTRUM_AVG; - } else if (demodTuner->getMouseTracker()->mouseInView()) { + } + else if (demodTuner->getMouseTracker()->mouseInView()) { switch (demodTuner->getHoverState()) { case TuningCanvas::ActiveState::TUNING_HOVER_BW: target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_BANDWIDTH; @@ -1566,6 +1561,9 @@ FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() { } } + else if (gainCanvas->getMouseTracker()->mouseInView()) { + target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_GAIN; + } return target; } diff --git a/src/AppFrame.h b/src/AppFrame.h index afd1f0e..df38196 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -83,6 +83,7 @@ public: void setSpectrumAvgSpeed(double avg); FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget(); + void refreshGainUI(); private: void OnMenu(wxCommandEvent& event); diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index 5320cfe..836f41a 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -650,23 +650,16 @@ int CubicSDR::getPPM() { return ppm; } -void CubicSDR::setFrequencyInputTarget(FrequencyDialog::FrequencyDialogTarget targetMode) { - fdlgTarget = targetMode; -} - void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode, wxString initString) { const wxString demodTitle("Set Demodulator Frequency"); const wxString freqTitle("Set Center Frequency"); const wxString bwTitle("Modem Bandwidth (150Hz - 500KHz)"); const wxString lpsTitle("Lines-Per-Second (1-1024)"); const wxString avgTitle("Average Rate (0.1 - 0.99)"); + const wxString gainTitle("Gain Entry: "+wxGetApp().getActiveGainEntry()); wxString title; -// if (targetMode == FrequencyDialog::FDIALOG_TARGET_DEFAULT && fdlgTarget != FrequencyDialog::FDIALOG_TARGET_DEFAULT) { -// targetMode = fdlgTarget; -// } - switch (targetMode) { case FrequencyDialog::FDIALOG_TARGET_DEFAULT: title = demodMgr.getActiveDemodulator()?demodTitle:freqTitle; @@ -680,6 +673,12 @@ void CubicSDR::showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetM case FrequencyDialog::FDIALOG_TARGET_SPECTRUM_AVG: title = avgTitle; break; + case FrequencyDialog::FDIALOG_TARGET_GAIN: + title = gainTitle; + if (wxGetApp().getActiveGainEntry() == "") { + return; + } + break; default: break; } @@ -765,6 +764,14 @@ std::string CubicSDR::getModulePath() { return modulePath; } +void CubicSDR::setActiveGainEntry(std::string gainName) { + activeGain = gainName; +} + +std::string CubicSDR::getActiveGainEntry() { + return activeGain; +} + int CubicSDR::FilterEvent(wxEvent& event) { if (!appframe) { return -1; diff --git a/src/CubicSDR.h b/src/CubicSDR.h index c96f18a..4cc4f7e 100644 --- a/src/CubicSDR.h +++ b/src/CubicSDR.h @@ -125,7 +125,6 @@ public: void setPPM(int ppm_in); int getPPM(); - void setFrequencyInputTarget(FrequencyDialog::FrequencyDialogTarget targetMode); void showFrequencyInput(FrequencyDialog::FrequencyDialogTarget targetMode = FrequencyDialog::FDIALOG_TARGET_DEFAULT, wxString initString = ""); AppFrame *getAppFrame(); @@ -154,6 +153,9 @@ public: bool getUseLocalMod(); std::string getModulePath(); + void setActiveGainEntry(std::string gainName); + std::string getActiveGainEntry(); + #ifdef USE_HAMLIB RigThread *getRigThread(); void initRig(int rigModel, std::string rigPort, int rigSerialRate); @@ -209,6 +211,7 @@ private: std::atomic_bool frequency_locked; std::atomic_llong lock_freq; FrequencyDialog::FrequencyDialogTarget fdlgTarget; + std::string activeGain; #ifdef USE_HAMLIB RigThread *rigThread; std::thread *t_Rig; diff --git a/src/FrequencyDialog.cpp b/src/FrequencyDialog.cpp index 09b0f19..d36918b 100644 --- a/src/FrequencyDialog.cpp +++ b/src/FrequencyDialog.cpp @@ -39,6 +39,12 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin if (targetMode == FDIALOG_TARGET_SPECTRUM_AVG) { freqStr = std::to_string(wxGetApp().getSpectrumProcessor()->getFFTAverageRate()); } + + if (targetMode == FDIALOG_TARGET_GAIN) { + if (wxGetApp().getActiveGainEntry() != "") { + freqStr = std::to_string((int)wxGetApp().getGain(wxGetApp().getActiveGainEntry())); + } + } dialogText = new wxTextCtrl(this, wxID_FREQ_INPUT, freqStr, wxPoint(6, 1), wxSize(size.GetWidth() - 20, size.GetHeight() - 70), wxTE_PROCESS_ENTER); @@ -123,6 +129,29 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) { } wxGetApp().getAppFrame()->setSpectrumAvgSpeed(dblval); } + + if (targetMode == FDIALOG_TARGET_GAIN) { + try { + freq = std::stoi(strValue); + } catch (exception e) { + break; + } + SDRDeviceInfo *devInfo = wxGetApp().getDevice(); + std::string gainName = wxGetApp().getActiveGainEntry(); + if (gainName == "") { + break; + } + SDRRangeMap gains = devInfo->getGains(SOAPY_SDR_RX, 0); + if (freq > gains[gainName].maximum()) { + freq = gains[gainName].maximum(); + } + if (freq < gains[gainName].minimum()) { + freq = gains[gainName].minimum(); + } + wxGetApp().setGain(gainName, freq); + wxGetApp().getAppFrame()->refreshGainUI(); + } + Close(); break; case WXK_ESCAPE: diff --git a/src/FrequencyDialog.h b/src/FrequencyDialog.h index 768401a..681b4aa 100644 --- a/src/FrequencyDialog.h +++ b/src/FrequencyDialog.h @@ -17,7 +17,8 @@ public: FDIALOG_TARGET_FREQ, FDIALOG_TARGET_BANDWIDTH, FDIALOG_TARGET_WATERFALL_LPS, - FDIALOG_TARGET_SPECTRUM_AVG + FDIALOG_TARGET_SPECTRUM_AVG, + FDIALOG_TARGET_GAIN } FrequencyDialogTarget; FrequencyDialog ( wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstance *demod = NULL, diff --git a/src/visual/GainCanvas.cpp b/src/visual/GainCanvas.cpp index 3b82e82..33badba 100644 --- a/src/visual/GainCanvas.cpp +++ b/src/visual/GainCanvas.cpp @@ -132,6 +132,9 @@ void GainCanvas::OnMouseMoved(wxMouseEvent& event) { int i = 0; for (std::vector::iterator gi = gainInfo.begin(); gi != gainInfo.end(); gi++) { (*gi)->highlightPanel.visible = (i==panelHit); + if (i==panelHit) { + wxGetApp().setActiveGainEntry((*gi)->name); + } i++; } From 393cd5f635d62195d4b6c0f796671ebe3acbe36d Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 8 Feb 2016 22:43:11 -0500 Subject: [PATCH 05/11] Add hover helptips, show hover helptips by default for new users. --- src/AppConfig.cpp | 17 ++++++++++++++++- src/AppConfig.h | 5 ++++- src/AppFrame.cpp | 10 ++++++++++ src/AppFrame.h | 2 ++ src/visual/InteractiveCanvas.cpp | 5 +++++ 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/AppConfig.cpp b/src/AppConfig.cpp index 42d3b6a..63d7eb1 100644 --- a/src/AppConfig.cpp +++ b/src/AppConfig.cpp @@ -198,6 +198,7 @@ AppConfig::AppConfig() : configName("") { winW.store(0); winH.store(0); winMax.store(false); + showTips.store(true); themeId.store(0); snap.store(1); centerFreq.store(100000000); @@ -253,6 +254,14 @@ bool AppConfig::getWindowMaximized() { return winMax.load(); } +void AppConfig::setShowTips(bool show) { + showTips.store(show); +} + +bool AppConfig::getShowTips() { + return showTips.load(); +} + wxRect *AppConfig::getWindow() { wxRect *r = NULL; if (winH.load() && winW.load()) { @@ -347,6 +356,7 @@ bool AppConfig::save() { *window_node->newChild("h") = winH.load(); *window_node->newChild("max") = winMax.load(); + *window_node->newChild("tips") = showTips.load(); *window_node->newChild("theme") = themeId.load(); *window_node->newChild("snap") = snap.load(); *window_node->newChild("center_freq") = centerFreq.load(); @@ -426,7 +436,7 @@ bool AppConfig::load() { if (cfg.rootNode()->hasAnother("window")) { int x,y,w,h; - int max; + int max,tips; DataNode *win_node = cfg.rootNode()->getNext("window"); @@ -447,6 +457,11 @@ bool AppConfig::load() { winMax.store(max?true:false); } + if (win_node->hasAnother("tips")) { + win_node->getNext("tips")->element()->get(tips); + showTips.store(tips?true:false); + } + if (win_node->hasAnother("theme")) { int theme; win_node->getNext("theme")->element()->get(theme); diff --git a/src/AppConfig.h b/src/AppConfig.h index b40ec12..8227c3b 100644 --- a/src/AppConfig.h +++ b/src/AppConfig.h @@ -70,6 +70,9 @@ public: void setWindowMaximized(bool max); bool getWindowMaximized(); + void setShowTips(bool show); + bool getShowTips(); + void setTheme(int themeId); int getTheme(); @@ -109,7 +112,7 @@ private: std::string configName; std::map deviceConfig; std::atomic_int winX,winY,winW,winH; - std::atomic_bool winMax; + std::atomic_bool winMax, showTips; std::atomic_int themeId; std::atomic_llong snap; std::atomic_llong centerFreq; diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 468a147..668815e 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -552,6 +552,10 @@ void AppFrame::updateDeviceParams() { // Build settings menu wxMenu *newSettingsMenu = new wxMenu; + showTipMenuItem = newSettingsMenu->AppendCheckItem(wxID_SET_TIPS, "Show Hover Tips"); + if (wxGetApp().getConfig()->getShowTips()) { + showTipMenuItem->Check(); + } newSettingsMenu->Append(wxID_SET_FREQ_OFFSET, "Frequency Offset"); if (devInfo->hasCORR(SOAPY_SDR_RX, 0)) { newSettingsMenu->Append(wxID_SET_PPM, "Device PPM"); @@ -673,6 +677,12 @@ void AppFrame::OnMenu(wxCommandEvent& event) { activeDemodulator->setOutputDevice(event.GetId() - wxID_RT_AUDIO_DEVICE); activeDemodulator = NULL; } + } else if (event.GetId() == wxID_SET_TIPS ) { + if (wxGetApp().getConfig()->getShowTips()) { + wxGetApp().getConfig()->setShowTips(false); + } else { + wxGetApp().getConfig()->setShowTips(true); + } } else if (event.GetId() == wxID_SET_FREQ_OFFSET) { long ofs = wxGetNumberFromUser("Shift the displayed frequency by this amount.\ni.e. -125000000 for -125 MHz", "Frequency (Hz)", "Frequency Offset", wxGetApp().getOffset(), -2000000000, 2000000000, this); diff --git a/src/AppFrame.h b/src/AppFrame.h index df38196..a7eb54b 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -26,6 +26,7 @@ #define wxID_SET_FREQ_OFFSET 2001 #define wxID_RESET 2002 #define wxID_SET_PPM 2003 +#define wxID_SET_TIPS 2004 #define wxID_SDR_DEVICES 2008 #define wxID_AGC_CONTROL 2009 @@ -150,6 +151,7 @@ private: wxMenuItem *sdrIFMenuItem; std::map rigSerialMenuItems; std::map rigModelMenuItems; + wxMenuItem *showTipMenuItem; int rigModel; int rigSerialRate; long long rigSDRIF; diff --git a/src/visual/InteractiveCanvas.cpp b/src/visual/InteractiveCanvas.cpp index edd85dc..9ac9493 100644 --- a/src/visual/InteractiveCanvas.cpp +++ b/src/visual/InteractiveCanvas.cpp @@ -157,6 +157,11 @@ void InteractiveCanvas::OnMouseEnterWindow(wxMouseEvent& event) { void InteractiveCanvas::setStatusText(std::string statusText) { wxGetApp().getAppFrame()->GetStatusBar()->SetStatusText(statusText); + if (wxGetApp().getConfig()->getShowTips()) { + this->SetToolTip(statusText); + } else { + this->SetToolTip(""); + } } void InteractiveCanvas::setStatusText(std::string statusText, int value) { From e962ad4a56b8e3adb4d793754c49af86f15c6e04 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 8 Feb 2016 23:40:09 -0500 Subject: [PATCH 06/11] Fix keyboard input error system response (auditory beep in most cases) --- src/AppFrame.cpp | 18 +++++++----------- src/visual/WaterfallCanvas.cpp | 2 -- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 668815e..2cceb60 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -1592,12 +1592,12 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) { case WXK_RIGHT: case WXK_NUMPAD_RIGHT: waterfallCanvas->OnKeyDown(event); - return 0; + return 1; case 'A': case 'F': case 'L': case 'U': - return 0; + return 1; case '0': case '1': case '2': @@ -1609,7 +1609,7 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) { case '8': case '9': wxGetApp().showFrequencyInput(getFrequencyDialogTarget(), std::to_string(event.GetKeyCode() - '0')); - return 0; + return 1; break; default: break; @@ -1617,13 +1617,11 @@ int AppFrame::OnGlobalKeyDown(wxKeyEvent &event) { if (demodTuner->getMouseTracker()->mouseInView()) { demodTuner->OnKeyDown(event); - return 0; } else if (waterfallCanvas->getMouseTracker()->mouseInView()) { waterfallCanvas->OnKeyDown(event); - return 0; } - return 0; + return 1; } int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) { @@ -1635,7 +1633,7 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) { case WXK_SPACE: if (!demodTuner->getMouseTracker()->mouseInView()) { wxGetApp().showFrequencyInput(getFrequencyDialogTarget()); - return 0; + return 1; } break; case WXK_UP: @@ -1647,7 +1645,7 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) { case WXK_RIGHT: case WXK_NUMPAD_RIGHT: waterfallCanvas->OnKeyUp(event); - return 0; + return 1; case 'A': demodModeSelector->setSelection("AM"); break; @@ -1670,16 +1668,14 @@ int AppFrame::OnGlobalKeyUp(wxKeyEvent &event) { if (demodTuner->getMouseTracker()->mouseInView()) { demodTuner->OnKeyUp(event); - return 0; } else if (waterfallCanvas->getMouseTracker()->mouseInView()) { waterfallCanvas->OnKeyUp(event); - return 0; } // TODO: Catch key-ups outside of original target - return 0; + return 1; } diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 522c82d..77217b3 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -19,8 +19,6 @@ wxBEGIN_EVENT_TABLE(WaterfallCanvas, wxGLCanvas) EVT_PAINT(WaterfallCanvas::OnPaint) -//EVT_KEY_DOWN(WaterfallCanvas::OnKeyDown) -//EVT_KEY_UP(WaterfallCanvas::OnKeyUp) EVT_IDLE(WaterfallCanvas::OnIdle) EVT_MOTION(WaterfallCanvas::OnMouseMoved) EVT_LEFT_DOWN(WaterfallCanvas::OnMouseDown) From 987af4b997ee7d78ee78ef0bb9e7bb6baf699ac9 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 8 Feb 2016 23:52:40 -0500 Subject: [PATCH 07/11] Helptip updates --- src/AppFrame.cpp | 2 +- src/visual/TuningCanvas.cpp | 6 +++--- src/visual/WaterfallCanvas.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 2cceb60..205f6d6 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -78,7 +78,7 @@ AppFrame::AppFrame() : demodModeSelector->addChoice("DSB"); demodModeSelector->addChoice("I/Q"); demodModeSelector->setSelection("FM"); - demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation, Amplitude Modulation and Lower, Upper or Double Side-Band."); + demodModeSelector->setHelpTip("Choose modulation type: Frequency Modulation (Hotkey F), Amplitude Modulation (A) and Lower (L), Upper (U), Double Side-Band and more."); demodModeSelector->SetMinSize(wxSize(40,-1)); demodModeSelector->SetMaxSize(wxSize(40,-1)); demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0); diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index d5e0160..709eaff 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -303,13 +303,13 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { } else { switch (hoverState) { case TUNING_HOVER_FREQ: - setStatusText("Click, wheel or drag a digit to change frequency; SPACE for direct input. Right click to set/clear snap. Hold ALT to change PPM. Hold SHIFT to disable carry."); + setStatusText("Click, wheel or drag a digit to change frequency; SPACE or numeric key for direct input. Right click to set/clear snap. Hold ALT to change PPM. Hold SHIFT to disable carry."); break; case TUNING_HOVER_BW: - setStatusText("Click, wheel or drag a digit to change bandwidth; SPACE for direct input. Hold SHIFT to disable carry."); + setStatusText("Click, wheel or drag a digit to change bandwidth; SPACE or numeric key for direct input. Hold SHIFT to disable carry."); break; case TUNING_HOVER_CENTER: - setStatusText("Click, wheel or drag a digit to change center frequency; SPACE for direct input. Hold SHIFT to disable carry."); + setStatusText("Click, wheel or drag a digit to change center frequency; SPACE or numeric key for direct input. Hold SHIFT to disable carry."); break; case TUNING_HOVER_PPM: setStatusText("Click, wheel or drag a digit to change device PPM offset. Hold SHIFT to disable carry."); diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 77217b3..6f7e8ce 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -595,20 +595,20 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { mouseTracker.setVertDragLock(true); mouseTracker.setHorizDragLock(false); - setStatusText("Click and drag to change demodulator bandwidth. SPACE for direct frequency input. M for mute, D to delete, C to center."); + setStatusText("Click and drag to change demodulator bandwidth. SPACE or numeric key for direct frequency input. M for mute, D to delete, C to center."); } else { SetCursor(wxCURSOR_SIZING); nextDragState = WF_DRAG_FREQUENCY; mouseTracker.setVertDragLock(true); mouseTracker.setHorizDragLock(false); - setStatusText("Click and drag to change demodulator frequency; SPACE for direct input. M for mute, D to delete, C to center."); + setStatusText("Click and drag to change demodulator frequency; SPACE or numeric key for direct input. M for mute, D to delete, C to center."); } } else { SetCursor(wxCURSOR_CROSS); nextDragState = WF_DRAG_NONE; if (shiftDown) { - setStatusText("Click to create a new demodulator or hold ALT to drag range, SPACE for direct center frequency input."); + setStatusText("Click to create a new demodulator or hold ALT to drag range, SPACE or numeric key for direct center frequency input."); } else { setStatusText( "Click to move active demodulator frequency or hold ALT to drag range; hold SHIFT to create new. Right drag or wheel to Zoom. Arrow keys to navigate/zoom, C to center."); From 72a37e16d3e576aec1df0f6b147f50f264b648a8 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 9 Feb 2016 00:10:15 -0500 Subject: [PATCH 08/11] new var in wrong section.. --- src/AppFrame.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AppFrame.h b/src/AppFrame.h index a7eb54b..cbe6367 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -143,6 +143,7 @@ private: ModemProperties *modemProps; std::atomic_bool modemPropertiesUpdated; ModemArgInfoList newModemArgs; + wxMenuItem *showTipMenuItem; #ifdef USE_HAMLIB wxMenu *rigMenu; @@ -151,7 +152,6 @@ private: wxMenuItem *sdrIFMenuItem; std::map rigSerialMenuItems; std::map rigModelMenuItems; - wxMenuItem *showTipMenuItem; int rigModel; int rigSerialRate; long long rigSDRIF; From f377d4646757abb31d3024bf533f46576d77bc6e Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 9 Feb 2016 00:28:40 -0500 Subject: [PATCH 09/11] Better tooltip handling for Windows --- src/visual/InteractiveCanvas.cpp | 10 ++++++++-- src/visual/InteractiveCanvas.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/visual/InteractiveCanvas.cpp b/src/visual/InteractiveCanvas.cpp index 9ac9493..d4fe77c 100644 --- a/src/visual/InteractiveCanvas.cpp +++ b/src/visual/InteractiveCanvas.cpp @@ -157,8 +157,14 @@ void InteractiveCanvas::OnMouseEnterWindow(wxMouseEvent& event) { void InteractiveCanvas::setStatusText(std::string statusText) { wxGetApp().getAppFrame()->GetStatusBar()->SetStatusText(statusText); - if (wxGetApp().getConfig()->getShowTips()) { - this->SetToolTip(statusText); + if (wxGetApp().getConfig()->getShowTips()) { + if (statusText != lastToolTip) { + wxToolTip::Enable(false); + this->SetToolTip(statusText); + lastToolTip = statusText; + wxToolTip::SetDelay(1000); + wxToolTip::Enable(true); + } } else { this->SetToolTip(""); } diff --git a/src/visual/InteractiveCanvas.h b/src/visual/InteractiveCanvas.h index f310918..3fdb2be 100644 --- a/src/visual/InteractiveCanvas.h +++ b/src/visual/InteractiveCanvas.h @@ -58,5 +58,6 @@ protected: unsigned int lastBandwidth; bool isView; + std::string lastToolTip; }; From 33c27c5684771c7711cd6d81d1c015ecd57f34df Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 9 Feb 2016 00:46:39 -0500 Subject: [PATCH 10/11] Fix initial numeric input char for Windows --- src/FrequencyDialog.cpp | 11 ++++++++++- src/FrequencyDialog.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/FrequencyDialog.cpp b/src/FrequencyDialog.cpp index d36918b..d44274c 100644 --- a/src/FrequencyDialog.cpp +++ b/src/FrequencyDialog.cpp @@ -6,6 +6,7 @@ wxBEGIN_EVENT_TABLE(FrequencyDialog, wxDialog) EVT_CHAR_HOOK(FrequencyDialog::OnChar) +EVT_SHOW(FrequencyDialog::OnShow) wxEND_EVENT_TABLE() FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstance *demod, const wxPoint & position, @@ -14,6 +15,7 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin wxString freqStr; activeDemod = demod; this->targetMode = targetMode; + this->initialString = initString; if (targetMode == FDIALOG_TARGET_DEFAULT) { if (activeDemod) { @@ -54,7 +56,7 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin if (initString != "" && initString.length() == 1) { dialogText->SetValue(initString); - dialogText->SetSelection(initString.length(), initString.length()); + dialogText->SetSelection(2, 2); dialogText->SetFocus(); } else { if (initString != "") { @@ -183,3 +185,10 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) { event.Skip(); } } + +void FrequencyDialog::OnShow(wxShowEvent &event) { + if (initialString.length() == 1) { + dialogText->SetSelection(2, 2); + dialogText->SetFocus(); + } +} \ No newline at end of file diff --git a/src/FrequencyDialog.h b/src/FrequencyDialog.h index 681b4aa..6353c39 100644 --- a/src/FrequencyDialog.h +++ b/src/FrequencyDialog.h @@ -34,6 +34,8 @@ private: DemodulatorInstance *activeDemod; void OnEnter ( wxCommandEvent &event ); void OnChar ( wxKeyEvent &event ); + void OnShow(wxShowEvent &event); FrequencyDialogTarget targetMode; + std::string initialString; DECLARE_EVENT_TABLE() }; From 84ae52b6d202425f2549221060cd0d2559eddf70 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 9 Feb 2016 01:08:15 -0500 Subject: [PATCH 11/11] Fix numeric direct-input for linux --- src/FrequencyDialog.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/FrequencyDialog.cpp b/src/FrequencyDialog.cpp index d44274c..1d6fb04 100644 --- a/src/FrequencyDialog.cpp +++ b/src/FrequencyDialog.cpp @@ -187,8 +187,9 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) { } void FrequencyDialog::OnShow(wxShowEvent &event) { - if (initialString.length() == 1) { - dialogText->SetSelection(2, 2); - dialogText->SetFocus(); + if (initialString.length() == 1) { + dialogText->SetFocus(); + dialogText->SetSelection(2, 2); } -} \ No newline at end of file + event.Skip(); +}