From d7784a393df87285135a7ae02d6c825b41ee62b9 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Wed, 25 Mar 2015 21:35:42 -0400 Subject: [PATCH] Tuner debug, spinner index working --- src/visual/TuningCanvas.cpp | 17 +++++++++++++++++ src/visual/TuningContext.cpp | 18 +++++++++++++++--- src/visual/TuningContext.h | 2 ++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 2b16016..4b3743c 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -110,6 +110,23 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) { void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { InteractiveCanvas::OnMouseMoved(event); + int index; + + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),11,-1.0,(1.0/3.0)*2.0); // freq + if (index > 0) { + std::cout << "freq " << index << std::endl; + } + + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),7,-1.0+(2.25/3.0),(1.0/4.0)*2.0); // bw + if (index > 0) { + std::cout << "bw " << index << std::endl; + } + + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(),11,-1.0+(2.0/3.0)*2.0,(1.0/3.0)*2.0); // center + if (index > 0) { + std::cout << "ctr " << index << std::endl; + } + } void TuningCanvas::OnMouseDown(wxMouseEvent& event) { diff --git a/src/visual/TuningContext.cpp b/src/visual/TuningContext.cpp index 9526802..b3a184f 100644 --- a/src/visual/TuningContext.cpp +++ b/src/visual/TuningContext.cpp @@ -108,6 +108,21 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float glEnd(); } +int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth) { + mPos -= 0.5; + mPos *= 2.0; + + float delta = mPos-displayPos; + + if (delta < 0 || delta > displayWidth) { + return 0; + } + + int index = floor((delta/displayWidth)*(count)); + + return count-index; +} + void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long center) { GLint vp[4]; glGetIntegerv( GL_VIEWPORT, vp); @@ -115,9 +130,6 @@ void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long c float viewHeight = (float) vp[3]; float viewWidth = (float) vp[2]; - #define NUM_BINS 11 - short num_bin[NUM_BINS] = { 0, 0, 1, 0, 5, 7, 0, 0, 0, 0, 0 }; - DrawTuner(freq,11,-1.0,(1.0/3.0)*2.0); DrawTuner(bw,7,-1.0+(2.25/3.0),(1.0/4.0)*2.0); DrawTuner(center,11,-1.0+(2.0/3.0)*2.0,(1.0/3.0)*2.0); diff --git a/src/visual/TuningContext.h b/src/visual/TuningContext.h index 55a547e..afbb6e5 100644 --- a/src/visual/TuningContext.h +++ b/src/visual/TuningContext.h @@ -14,6 +14,8 @@ public: void DrawBegin(); void Draw(float r, float g, float b, float a, float p1, float p2); void DrawTuner(long long freq, int count, float displayPos, float displayWidth); + int GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth); + void DrawDemodFreqBw(long long freq, unsigned int bw, long long center); void DrawEnd();