diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 4463da5..66291dd 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -35,10 +35,11 @@ EVT_CLOSE(AppFrame::OnClose) EVT_MENU(wxID_ANY, AppFrame::OnMenu) EVT_COMMAND(wxID_ANY, wxEVT_THREAD, AppFrame::OnThread) EVT_IDLE(AppFrame::OnIdle) +EVT_TIMER(FRAME_TIMER_ID, AppFrame::OnTimer) wxEND_EVENT_TABLE() AppFrame::AppFrame() : - wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { + wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL), frame_timer(this, FRAME_TIMER_ID) { #ifdef __linux__ SetIcon(wxICON(cubicsdr)); @@ -350,6 +351,7 @@ AppFrame::AppFrame() : wxAcceleratorTable accel(3, entries); SetAcceleratorTable(accel); + frame_timer.Start(30); // static const int attribs[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 }; // wxLogStatus("Double-buffered display %s supported", wxGLCanvas::IsDisplaySupported(attribs) ? "is" : "not"); // ShowFullScreen(true); @@ -561,6 +563,10 @@ void AppFrame::OnThread(wxCommandEvent& event) { } void AppFrame::OnIdle(wxIdleEvent& event) { + event.Skip(); +} + +void AppFrame::OnTimer(wxTimerEvent& event) { DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); @@ -691,6 +697,26 @@ void AppFrame::OnIdle(wxIdleEvent& event) { dproc->setCenterFrequency(demodWaterfallCanvas->getCenterFrequency()); dproc->run(); + + scopeCanvas->Refresh(); + + waterfallCanvas->Refresh(); + spectrumCanvas->Refresh(); + + demodWaterfallCanvas->Refresh(); + demodSpectrumCanvas->Refresh(); + + demodSignalMeter->Refresh(); + + if (demodTuner->getMouseTracker()->mouseInView() || demodTuner->changed()) { + demodTuner->Refresh(); + } + if (demodModeSelector->getMouseTracker()->mouseInView()) { + demodModeSelector->Refresh(); + } + if (demodGainMeter->getMouseTracker()->mouseInView()) { + demodGainMeter->Refresh(); + } event.Skip(); } diff --git a/src/AppFrame.h b/src/AppFrame.h index 4d335a0..de90215 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -50,7 +50,7 @@ #define wxID_AUDIO_BANDWIDTH_BASE 9000 #define wxID_AUDIO_DEVICE_MULTIPLIER 50 - +#define FRAME_TIMER_ID 1000 // Define a new frame type class AppFrame: public wxFrame { @@ -69,6 +69,7 @@ private: void OnClose(wxCloseEvent& event); void OnNewWindow(wxCommandEvent& event); void OnIdle(wxIdleEvent& event); + void OnTimer(wxTimerEvent& event); ScopeCanvas *scopeCanvas; SpectrumCanvas *spectrumCanvas; @@ -93,6 +94,7 @@ private: wxMenuItem *iqSwapMenuItem; std::string currentSessionFile; - + wxTimer frame_timer; + wxDECLARE_EVENT_TABLE(); }; diff --git a/src/ui/UITestCanvas.cpp b/src/ui/UITestCanvas.cpp index e94a993..e3bf7d2 100644 --- a/src/ui/UITestCanvas.cpp +++ b/src/ui/UITestCanvas.cpp @@ -36,9 +36,6 @@ UITestCanvas::~UITestCanvas() { void UITestCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); -#ifdef __APPLE__ // force half-rate? - glFinish(); -#endif const wxSize ClientSize = GetClientSize(); glContext->SetCurrent(*this); diff --git a/src/visual/MeterCanvas.cpp b/src/visual/MeterCanvas.cpp index bb3c20b..423fc20 100644 --- a/src/visual/MeterCanvas.cpp +++ b/src/visual/MeterCanvas.cpp @@ -60,9 +60,6 @@ float MeterCanvas::getInputValue() { void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); -#ifdef __APPLE__ // force half-rate? - glFinish(); -#endif const wxSize ClientSize = GetClientSize(); glContext->SetCurrent(*this); @@ -82,7 +79,7 @@ void MeterCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { } void MeterCanvas::OnIdle(wxIdleEvent &event) { - Refresh(false); + event.Skip(); } void MeterCanvas::OnMouseMoved(wxMouseEvent& event) { @@ -115,6 +112,7 @@ void MeterCanvas::OnMouseReleased(wxMouseEvent& event) { void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) { InteractiveCanvas::OnMouseLeftWindow(event); SetCursor(wxCURSOR_CROSS); + Refresh(); } void MeterCanvas::OnMouseEnterWindow(wxMouseEvent& event) { diff --git a/src/visual/ModeSelectorCanvas.cpp b/src/visual/ModeSelectorCanvas.cpp index 1b859e3..98172b5 100644 --- a/src/visual/ModeSelectorCanvas.cpp +++ b/src/visual/ModeSelectorCanvas.cpp @@ -47,10 +47,7 @@ int ModeSelectorCanvas::getHoveredSelection() { void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); -#ifdef __APPLE__ // force half-rate? - glFinish(); -#endif - const wxSize ClientSize = GetClientSize(); + const wxSize ClientSize = GetClientSize(); glContext->SetCurrent(*this); initGLExtensions(); @@ -75,7 +72,7 @@ void ModeSelectorCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { } void ModeSelectorCanvas::OnIdle(wxIdleEvent &event) { - Refresh(false); + event.Skip(); } void ModeSelectorCanvas::OnMouseMoved(wxMouseEvent& event) { @@ -109,6 +106,7 @@ void ModeSelectorCanvas::OnMouseReleased(wxMouseEvent& event) { void ModeSelectorCanvas::OnMouseLeftWindow(wxMouseEvent& event) { InteractiveCanvas::OnMouseLeftWindow(event); SetCursor (wxCURSOR_CROSS); + Refresh(); } void ModeSelectorCanvas::OnMouseEnterWindow(wxMouseEvent& event) { diff --git a/src/visual/ScopeCanvas.cpp b/src/visual/ScopeCanvas.cpp index 5c6bd54..88d6a33 100644 --- a/src/visual/ScopeCanvas.cpp +++ b/src/visual/ScopeCanvas.cpp @@ -50,9 +50,6 @@ bool ScopeCanvas::getPPMMode() { void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); -#ifdef __APPLE__ // force half-rate? - glFinish(); -#endif const wxSize ClientSize = GetClientSize(); wxGetApp().getScopeProcessor()->run(); @@ -94,7 +91,7 @@ void ScopeCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { } void ScopeCanvas::OnIdle(wxIdleEvent &event) { - Refresh(false); + event.Skip(); } ScopeRenderDataQueue *ScopeCanvas::getInputQueue() { diff --git a/src/visual/SpectrumCanvas.cpp b/src/visual/SpectrumCanvas.cpp index e618cc5..5052f24 100644 --- a/src/visual/SpectrumCanvas.cpp +++ b/src/visual/SpectrumCanvas.cpp @@ -42,26 +42,22 @@ SpectrumCanvas::~SpectrumCanvas() { void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); -#ifdef __APPLE__ // force half-rate? - glFinish(); -#endif const wxSize ClientSize = GetClientSize(); - if (visualDataQueue.empty()) { - return; + if (!visualDataQueue.empty()) { + SpectrumVisualData *vData; + + visualDataQueue.pop(vData); + + if (!vData) { + return; + } + + spectrum_points.assign(vData->spectrum_points.begin(),vData->spectrum_points.end()); + + vData->decRefCount(); } - SpectrumVisualData *vData; - - visualDataQueue.pop(vData); - - if (!vData) { - return; - } - - spectrum_points.assign(vData->spectrum_points.begin(),vData->spectrum_points.end()); - - vData->decRefCount(); glContext->SetCurrent(*this); initGLExtensions(); @@ -84,7 +80,7 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { void SpectrumCanvas::OnIdle(wxIdleEvent &event) { - Refresh(false); + event.Skip(); } diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index daed27e..cb618f6 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -31,7 +31,7 @@ EVT_KEY_UP(TuningCanvas::OnKeyUp) wxEND_EVENT_TABLE() TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) : - InteractiveCanvas(parent, attribList), dragAccum(0), uxDown(0), top(false), bottom(false) { + InteractiveCanvas(parent, attribList), dragAccum(0), uxDown(0), top(false), bottom(false), freq(-1), bw(-1), center(-1) { glContext = new TuningContext(this, &wxGetApp().GetContext(this)); @@ -57,13 +57,27 @@ TuningCanvas::~TuningCanvas() { } +bool TuningCanvas::changed() { + DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); + + long long current_freq = 0; + if (activeDemod != NULL) { + freq = activeDemod->getFrequency(); + } + long long current_bw = wxGetApp().getDemodMgr().getLastBandwidth(); + long long current_center = wxGetApp().getFrequency(); + + if (current_freq != freq || current_bw != bw || current_center != center) { + return true; + } + + return false; +} + void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); -#ifdef __APPLE__ // force half-rate? - glFinish(); -#endif const wxSize ClientSize = GetClientSize(); - + glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); @@ -71,13 +85,13 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { glContext->DrawBegin(); DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); - - long long freq = 0; + + freq = 0; if (activeDemod != NULL) { freq = activeDemod->getFrequency(); } - long long bw = wxGetApp().getDemodMgr().getLastBandwidth(); - long long center = wxGetApp().getFrequency(); + bw = wxGetApp().getDemodMgr().getLastBandwidth(); + center = wxGetApp().getFrequency(); if (mouseTracker.mouseDown()) { glContext->Draw(ThemeMgr::mgr.currentTheme->tuningBarDark.r, ThemeMgr::mgr.currentTheme->tuningBarDark.g, ThemeMgr::mgr.currentTheme->tuningBarDark.b, @@ -238,8 +252,6 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) { dragging = false; } } - - Refresh(false); } void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { @@ -373,6 +385,7 @@ void TuningCanvas::OnMouseLeftWindow(wxMouseEvent& event) { if (currentPPM != lastPPM) { wxGetApp().saveConfig(); } + Refresh(); } void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) { diff --git a/src/visual/TuningCanvas.h b/src/visual/TuningCanvas.h index 1fea2e2..2826363 100644 --- a/src/visual/TuningCanvas.h +++ b/src/visual/TuningCanvas.h @@ -22,7 +22,8 @@ public: ~TuningCanvas(); void setHelpTip(std::string tip); - + bool changed(); + private: void OnPaint(wxPaintEvent& event); void OnIdle(wxIdleEvent &event); @@ -66,6 +67,7 @@ private: int currentPPM; int lastPPM; + long long freq, bw, center; // wxDECLARE_EVENT_TABLE(); }; diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 7fe2011..be6639e 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -70,9 +70,6 @@ void WaterfallCanvas::attachSpectrumCanvas(SpectrumCanvas *canvas_in) { void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); -#ifdef __APPLE__ // force half-rate? - glFinish(); -#endif const wxSize ClientSize = GetClientSize(); long double currentZoom = zoom; @@ -139,28 +136,29 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { } } - if (visualDataQueue.empty()) { - return; + bool step = false; + if (!visualDataQueue.empty()) { + SpectrumVisualData *vData; + + visualDataQueue.pop(vData); + + if (!vData) { + return; + } + + spectrum_points.assign(vData->spectrum_points.begin(),vData->spectrum_points.end()); + + vData->decRefCount(); + step = true; } - SpectrumVisualData *vData; - - visualDataQueue.pop(vData); - - if (!vData) { - return; - } - - spectrum_points.assign(vData->spectrum_points.begin(),vData->spectrum_points.end()); - - vData->decRefCount(); glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); glContext->BeginDraw(0,0,0); - glContext->Draw(spectrum_points); + glContext->Draw(spectrum_points, step); std::vector &demods = wxGetApp().getDemodMgr().getDemodulators(); @@ -352,7 +350,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) { } } void WaterfallCanvas::OnIdle(wxIdleEvent &event) { - Refresh(false); + event.Skip(); } void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) { diff --git a/src/visual/WaterfallContext.cpp b/src/visual/WaterfallContext.cpp index 733cfc9..8ba0f45 100644 --- a/src/visual/WaterfallContext.cpp +++ b/src/visual/WaterfallContext.cpp @@ -36,7 +36,7 @@ void WaterfallContext::refreshTheme() { } } -void WaterfallContext::Draw(std::vector &points) { +void WaterfallContext::Draw(std::vector &points, bool step) { int half_fft_size = fft_size / 2; diff --git a/src/visual/WaterfallContext.h b/src/visual/WaterfallContext.h index f42b5f9..e993747 100644 --- a/src/visual/WaterfallContext.h +++ b/src/visual/WaterfallContext.h @@ -10,7 +10,7 @@ class WaterfallContext: public PrimaryGLContext { public: WaterfallContext(WaterfallCanvas *canvas, wxGLContext *sharedContext); - void Draw(std::vector &points); + void Draw(std::vector &points, bool step); void Setup(int fft_size_in, int num_waterfall_lines_in); void refreshTheme();