diff --git a/src/gui/controls/plot.h b/src/gui/controls/plot.h index f9b49335..2052ede1 100644 --- a/src/gui/controls/plot.h +++ b/src/gui/controls/plot.h @@ -116,7 +116,7 @@ class PlotPanel : public wxPanel virtual void OnMouseLeftDown(wxMouseEvent& event); void OnMouseLeftUp(wxMouseEvent& event); virtual void OnMouseRightDown(wxMouseEvent& event); - void OnMouseWheelMoved(wxMouseEvent& event); + virtual void OnMouseWheelMoved(wxMouseEvent& event); void OnClose(wxCloseEvent& event ){ event.Skip(); } virtual void OnSize( wxSizeEvent& event ) = 0; void OnErase(wxEraseEvent& event); diff --git a/src/gui/controls/plot_spectrum.cpp b/src/gui/controls/plot_spectrum.cpp index 7bc88a65..c0c541f6 100644 --- a/src/gui/controls/plot_spectrum.cpp +++ b/src/gui/controls/plot_spectrum.cpp @@ -22,8 +22,10 @@ #include #include "plot_spectrum.h" +#include "codec2_fdmdv.h" // for FDMDV_FCENTRE void clickTune(float frequency); // callback to pass new click freq +extern float g_RxFreqOffsetHz; BEGIN_EVENT_TABLE(PlotSpectrum, PlotPanel) EVT_MOTION (PlotSpectrum::OnMouseMove) @@ -328,3 +330,27 @@ void PlotSpectrum::OnMouseRightDoubleClick(wxMouseEvent& event) { OnDoubleClickCommon(event); } + +//------------------------------------------------------------------------- +// OnMouseWheelMoved() +//------------------------------------------------------------------------- +void PlotSpectrum::OnMouseWheelMoved(wxMouseEvent& event) +{ + float currRxFreq = FDMDV_FCENTRE - g_RxFreqOffsetHz; + float direction = 1.0; + if (event.GetWheelRotation() < 0) + { + direction = -1.0; + } + + currRxFreq += direction * (event.GetLinesPerAction() * 10); + if (currRxFreq < MIN_F_HZ) + { + currRxFreq = MIN_F_HZ; + } + else if (currRxFreq > MAX_F_HZ) + { + currRxFreq = MAX_F_HZ; + } + clickTune(currRxFreq); +} \ No newline at end of file diff --git a/src/gui/controls/plot_spectrum.h b/src/gui/controls/plot_spectrum.h index f227b2ed..86fe362b 100644 --- a/src/gui/controls/plot_spectrum.h +++ b/src/gui/controls/plot_spectrum.h @@ -47,6 +47,7 @@ class PlotSpectrum : public PlotPanel void draw(wxGraphicsContext* ctx); void OnMouseLeftDoubleClick(wxMouseEvent& event); void OnMouseRightDoubleClick(wxMouseEvent& event); + void OnMouseWheelMoved(wxMouseEvent& event); private: float m_rxFreq; diff --git a/src/gui/controls/plot_waterfall.cpp b/src/gui/controls/plot_waterfall.cpp index 4fc769c9..201b0a47 100644 --- a/src/gui/controls/plot_waterfall.cpp +++ b/src/gui/controls/plot_waterfall.cpp @@ -25,11 +25,13 @@ #include "os/os_interface.h" #include "plot_waterfall.h" +#include "codec2_fdmdv.h" // for FDMDV_FCENTRE // Tweak accordingly #define Y_PER_SECOND (30) extern float g_avmag[]; // av mag spec passed in to draw() +extern float g_RxFreqOffsetHz; void clickTune(float frequency); // callback to pass new click freq BEGIN_EVENT_TABLE(PlotWaterfall, PlotPanel) @@ -459,6 +461,30 @@ void PlotWaterfall::OnDoubleClickCommon(wxMouseEvent& event) } } +//------------------------------------------------------------------------- +// OnMouseWheelMoved() +//------------------------------------------------------------------------- +void PlotWaterfall::OnMouseWheelMoved(wxMouseEvent& event) +{ + float currRxFreq = FDMDV_FCENTRE - g_RxFreqOffsetHz; + float direction = 1.0; + if (event.GetWheelRotation() < 0) + { + direction = -1.0; + } + + currRxFreq += direction * (event.GetLinesPerAction() * 10); + if (currRxFreq < MIN_F_HZ) + { + currRxFreq = MIN_F_HZ; + } + else if (currRxFreq > MAX_F_HZ) + { + currRxFreq = MAX_F_HZ; + } + clickTune(currRxFreq); +} + //------------------------------------------------------------------------- // OnMouseLeftDown() //------------------------------------------------------------------------- diff --git a/src/gui/controls/plot_waterfall.h b/src/gui/controls/plot_waterfall.h index 0d1fef52..8c40d86b 100644 --- a/src/gui/controls/plot_waterfall.h +++ b/src/gui/controls/plot_waterfall.h @@ -59,6 +59,7 @@ class PlotWaterfall : public PlotPanel void plotPixelData(); void OnMouseLeftDoubleClick(wxMouseEvent& event); void OnMouseRightDoubleClick(wxMouseEvent& event); + void OnMouseWheelMoved(wxMouseEvent& event); private: float m_dT;