void WaterfallCanvas::setLinesPerSecond(int lps) { tex_update.lock(); linesPerSecond = lps; while (!visualDataQueue.empty()) { SpectrumVisualData *vData; visualDataQueue.pop(vData); if (vData) { vData->decRefCount(); } } tex_update.unlock(); }
void WaterfallCanvas::processInputQueue() { tex_update.lock(); gTimer.update(); double targetVis = 1.0 / (double)linesPerSecond; lpsIndex += gTimer.lastUpdateSeconds(); bool updated = false; if (linesPerSecond) { if (lpsIndex >= targetVis) { while (lpsIndex >= targetVis) { SpectrumVisualData *vData; if (!visualDataQueue.empty()) { visualDataQueue.pop(vData); if (vData) { if (vData->spectrum_points.size() == fft_size * 2) { waterfallPanel.setPoints(vData->spectrum_points); } waterfallPanel.step(); vData->decRefCount(); updated = true; } lpsIndex-=targetVis; } else { break; } } } } if (updated) { wxClientDC(this); glContext->SetCurrent(*this); waterfallPanel.update(); } tex_update.unlock(); }
void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); const wxSize ClientSize = GetClientSize(); if (!visualDataQueue.empty()) { SpectrumVisualData *vData; visualDataQueue.pop(vData); if (vData) { spectrumPanel.setPoints(vData->spectrum_points); spectrumPanel.setPeakPoints(vData->spectrum_hold_points); spectrumPanel.setFloorValue(vData->fft_floor); spectrumPanel.setCeilValue(vData->fft_ceiling); vData->decRefCount(); } } if (resetScaleFactor) { scaleFactor += (1.0-scaleFactor)*0.05; if (fabs(scaleFactor-1.0) < 0.01) { scaleFactor = 1.0; resetScaleFactor = false; } updateScaleFactor(scaleFactor); } glContext->SetCurrent(*this); initGLExtensions(); glViewport(0, 0, ClientSize.x, ClientSize.y); glContext->BeginDraw(0,0,0); spectrumPanel.setFreq(getCenterFrequency()); spectrumPanel.setBandwidth(getBandwidth()); spectrumPanel.calcTransform(CubicVR::mat4::identity()); spectrumPanel.draw(); glLoadIdentity(); std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators(); DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); for (int i = 0, iMax = demods.size(); i < iMax; i++) { if (!demods[i]->isActive()) { continue; } glContext->DrawDemodInfo(demods[i], ThemeMgr::mgr.currentTheme->fftHighlight, getCenterFrequency(), getBandwidth(), activeDemodulator==demods[i]); } if (waterfallCanvas && !activeDemodulator) { MouseTracker *wfmt = waterfallCanvas->getMouseTracker(); if (wfmt->mouseInView()) { int snap = wxGetApp().getFrequencySnap(); long long freq = getFrequencyAt(wfmt->getMouseX()); if (snap > 1) { freq = roundf((float)freq/(float)snap)*snap; } DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); bool isNew = (((waterfallCanvas->isShiftDown() || (lastActiveDemodulator && !lastActiveDemodulator->isActive())) && lastActiveDemodulator) || (!lastActiveDemodulator)); glContext->DrawFreqBwInfo(freq, wxGetApp().getDemodMgr().getLastBandwidth(), isNew?ThemeMgr::mgr.currentTheme->waterfallNew:ThemeMgr::mgr.currentTheme->waterfallHover, getCenterFrequency(), getBandwidth(), true, true); } } glContext->EndDraw(); spectrumPanel.drawChildren(); SwapBuffers(); }