From de2b25e14864380e5c2a3341d7521c1b9e9695d6 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 24 Mar 2015 20:33:07 -0400 Subject: [PATCH 01/19] Prototype visual layout for new tuner widget --- src/visual/TuningContext.cpp | 57 ++++++++++++++++++++++++++++++++++-- src/visual/TuningContext.h | 2 ++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/visual/TuningContext.cpp b/src/visual/TuningContext.cpp index f348c70..9526802 100644 --- a/src/visual/TuningContext.cpp +++ b/src/visual/TuningContext.cpp @@ -24,7 +24,7 @@ TuningContext::TuningContext(TuningCanvas *canvas, wxGLContext *sharedContext) : glLoadIdentity(); comma_locale = std::locale(std::locale(), new comma_numpunct()); - freqStr.imbue(comma_locale); + freqStrFormatted.imbue(comma_locale); } void TuningContext::DrawBegin() { @@ -63,6 +63,51 @@ void TuningContext::DrawEnd() { CheckGLError(); } +void TuningContext::DrawTuner(long long freq, int count, float displayPos, float displayWidth) { + GLint vp[4]; + glGetIntegerv( GL_VIEWPORT, vp); + + float viewHeight = (float) vp[3]; + float viewWidth = (float) vp[2]; + + freqStr.str(""); + freqStr << freq; + std::string freqChars = freqStr.str(); + + PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE24; + int fontHeight = 24; + + if (viewHeight < 28) { + fontSize = GLFONT_SIZE18; + fontHeight = 18; + } + if (viewHeight < 24) { + fontSize = GLFONT_SIZE16; + fontHeight = 16; + } + if (viewHeight < 18) { + fontSize = GLFONT_SIZE12; + fontHeight = 12; + } + + glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b); + int numChars = freqChars.length(); + int ofs = count-numChars; + for (int i = ofs; i < count; i++) { + float xpos = displayPos + (displayWidth/(float)count)*(float)i+((displayWidth/2.0)/(float)count); + getFont(fontSize).drawString(freqStr.str().substr(i-ofs,1), xpos, 0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); + } + + glColor3f(0.65, 0.65, 0.65); + glBegin(GL_LINES); + for (int i = count; i >= 0; i--) { + float xpos = displayPos + (displayWidth/(float)count)*(float)i; + glVertex2f(xpos, -1.0); + glVertex2f(xpos, 1.0); + } + glEnd(); +} + void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long center) { GLint vp[4]; glGetIntegerv( GL_VIEWPORT, vp); @@ -70,6 +115,14 @@ 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); + + /* PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE16; int fontHeight = 16; @@ -118,6 +171,6 @@ void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long c glVertex2f(0.275, -1.0); glVertex2f(0.275, 1.0); glEnd(); - + */ } diff --git a/src/visual/TuningContext.h b/src/visual/TuningContext.h index f64a351..55a547e 100644 --- a/src/visual/TuningContext.h +++ b/src/visual/TuningContext.h @@ -13,10 +13,12 @@ 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); void DrawDemodFreqBw(long long freq, unsigned int bw, long long center); void DrawEnd(); private: std::locale comma_locale; std::stringstream freqStr; + std::stringstream freqStrFormatted; }; From d7784a393df87285135a7ae02d6c825b41ee62b9 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Wed, 25 Mar 2015 21:35:42 -0400 Subject: [PATCH 02/19] 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(); From 2893a1ab17b2e485c1b2161a25b9dbd6c8f3ab19 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Wed, 25 Mar 2015 22:47:54 -0400 Subject: [PATCH 03/19] Tuner index up/down debug visual test --- src/visual/TuningCanvas.cpp | 55 ++++++++----- src/visual/TuningContext.cpp | 150 +++++++++++++++++++++-------------- src/visual/TuningContext.h | 1 + 3 files changed, 127 insertions(+), 79 deletions(-) diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 4b3743c..a030043 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -49,17 +49,49 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); + long long freq = 0; if (activeDemod != NULL) { - glContext->DrawDemodFreqBw(activeDemod->getFrequency(), activeDemod->getBandwidth(), wxGetApp().getFrequency()); - } else { - glContext->DrawDemodFreqBw(0, wxGetApp().getDemodMgr().getLastBandwidth(), wxGetApp().getFrequency()); + freq = activeDemod->getFrequency(); } + long long bw = wxGetApp().getDemodMgr().getLastBandwidth(); + long long center = wxGetApp().getFrequency(); + + float freqDP = -1.0; + float freqW = (1.0 / 3.0) * 2.0; + + float bwDP = -1.0 + (2.25 / 3.0); + float bwW = (1.0 / 4.0) * 2.0; + + float centerDP = -1.0 + (2.0 / 3.0) * 2.0; + float centerW = (1.0 / 3.0) * 2.0; + + glContext->DrawTuner(freq, 11, freqDP, freqW); + glContext->DrawTuner(bw, 7, bwDP, bwW); + glContext->DrawTuner(center, 11, centerDP, centerW); if (mouseTracker.mouseDown()) { glContext->Draw(ThemeMgr::mgr.currentTheme->tuningBar.r, ThemeMgr::mgr.currentTheme->tuningBar.g, ThemeMgr::mgr.currentTheme->tuningBar.b, 0.6, mouseTracker.getOriginMouseX(), mouseTracker.getMouseX()); } + int index; + bool top = mouseTracker.getMouseY()>=0.5; + bool bottom = mouseTracker.getMouseY()<=0.5; + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, freqDP, freqW); // freq + if (index > 0) { + glContext->DrawTunerBarIndexed(1, index, 11, freqDP, freqW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // freq + } + + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw + if (index > 0) { + glContext->DrawTunerBarIndexed(1, index, 7, bwDP, bwW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // bw + } + + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center + if (index > 0) { + glContext->DrawTunerBarIndexed(1, index, 11, centerDP, centerW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // center + } + glContext->DrawEnd(); SwapBuffers(); @@ -110,23 +142,6 @@ 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 b3a184f..ac1d72b 100644 --- a/src/visual/TuningContext.cpp +++ b/src/visual/TuningContext.cpp @@ -28,7 +28,8 @@ TuningContext::TuningContext(TuningCanvas *canvas, wxGLContext *sharedContext) : } void TuningContext::DrawBegin() { - glClearColor(ThemeMgr::mgr.currentTheme->generalBackground.r, ThemeMgr::mgr.currentTheme->generalBackground.g, ThemeMgr::mgr.currentTheme->generalBackground.b, 1.0); + glClearColor(ThemeMgr::mgr.currentTheme->generalBackground.r, ThemeMgr::mgr.currentTheme->generalBackground.g, + ThemeMgr::mgr.currentTheme->generalBackground.b, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); @@ -41,18 +42,18 @@ void TuningContext::Draw(float r, float g, float b, float a, float p1, float p2) glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glBegin(GL_QUADS); - glColor4f(r*0.5, g*0.5, b*0.5, a); - glVertex2f(-1.0+p2*2.0, 1.0); - glVertex2f(-1.0+p1*2.0, 1.0); + glColor4f(r * 0.5, g * 0.5, b * 0.5, a); + glVertex2f(-1.0 + p2 * 2.0, 1.0); + glVertex2f(-1.0 + p1 * 2.0, 1.0); glColor4f(r, g, b, a); - glVertex2f(-1.0+p1*2.0, 0.0); - glVertex2f(-1.0+p2*2.0, 0.0); + glVertex2f(-1.0 + p1 * 2.0, 0.0); + glVertex2f(-1.0 + p2 * 2.0, 0.0); - glVertex2f(-1.0+p2*2.0, 0.0); - glVertex2f(-1.0+p1*2.0, 0.0); - glColor4f(r*0.5, g*0.5, b*0.5, a); - glVertex2f(-1.0+p1*2.0, -1.0); - glVertex2f(-1.0+p2*2.0, -1.0); + glVertex2f(-1.0 + p2 * 2.0, 0.0); + glVertex2f(-1.0 + p1 * 2.0, 0.0); + glColor4f(r * 0.5, g * 0.5, b * 0.5, a); + glVertex2f(-1.0 + p1 * 2.0, -1.0); + glVertex2f(-1.0 + p2 * 2.0, -1.0); glEnd(); glDisable(GL_BLEND); } @@ -92,16 +93,16 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b); int numChars = freqChars.length(); - int ofs = count-numChars; + int ofs = count - numChars; for (int i = ofs; i < count; i++) { - float xpos = displayPos + (displayWidth/(float)count)*(float)i+((displayWidth/2.0)/(float)count); - getFont(fontSize).drawString(freqStr.str().substr(i-ofs,1), xpos, 0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); + float xpos = displayPos + (displayWidth / (float) count) * (float) i + ((displayWidth / 2.0) / (float) count); + getFont(fontSize).drawString(freqStr.str().substr(i - ofs, 1), xpos, 0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); } glColor3f(0.65, 0.65, 0.65); glBegin(GL_LINES); for (int i = count; i >= 0; i--) { - float xpos = displayPos + (displayWidth/(float)count)*(float)i; + float xpos = displayPos + (displayWidth / (float) count) * (float) i; glVertex2f(xpos, -1.0); glVertex2f(xpos, 1.0); } @@ -112,15 +113,46 @@ int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, f mPos -= 0.5; mPos *= 2.0; - float delta = mPos-displayPos; + float delta = mPos - displayPos; if (delta < 0 || delta > displayWidth) { return 0; } - int index = floor((delta/displayWidth)*(count)); + int index = floor((delta / displayWidth) * (count)); - return count-index; + return count - index; +} + +void TuningContext::DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGBColor color, float alpha, bool top, +bool bottom) { + float ofs = (displayWidth / (float) count); + float p2 = displayPos + ofs * (float) (count - start + 1); + float p1 = displayPos + ofs * (float) (count - end); + + float r = color.r, g = color.g, b = color.b, a = 0.6; + + glEnable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ONE); + glBegin(GL_QUADS); + if (top) { + glColor4f(r * 0.5, g * 0.5, b * 0.5, a); + glVertex2f(p2, 1.0); + glVertex2f(p1, 1.0); + glColor4f(r, g, b, a); + glVertex2f(p1, 0.0); + glVertex2f(p2, 0.0); + } + if (bottom) { + glColor4f(r, g, b, a); + glVertex2f(p2, 0.0); + glVertex2f(p1, 0.0); + glColor4f(r * 0.5, g * 0.5, b * 0.5, a); + glVertex2f(p1, -1.0); + glVertex2f(p2, -1.0); + } + glEnd(); + glDisable(GL_BLEND); } void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long center) { @@ -130,59 +162,59 @@ void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long c float viewHeight = (float) vp[3]; float viewWidth = (float) vp[2]; - 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); + 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); /* - PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE16; + PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE16; - int fontHeight = 16; + int fontHeight = 16; - if (viewWidth < 400) { - fontSize = GLFONT_SIZE12; - fontHeight = 12; - } + if (viewWidth < 400) { + fontSize = GLFONT_SIZE12; + fontHeight = 12; + } - glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b); + glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b); - getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); - if (freq) { - freqStr.str(""); - freqStr << std::fixed << freq << " Hz"; - } else { - freqStr.str("---"); - } - getFont(fontSize).drawString(freqStr.str(), -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); + getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); + if (freq) { + freqStr.str(""); + freqStr << std::fixed << freq << " Hz"; + } else { + freqStr.str("---"); + } + getFont(fontSize).drawString(freqStr.str(), -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); - getFont(fontSize).drawString("BW: ", -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); - if (bw) { - freqStr.str(""); - freqStr << std::fixed << bw << " Hz"; - } else { - freqStr.str("---"); - } - getFont(fontSize).drawString(freqStr.str(), -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); + getFont(fontSize).drawString("BW: ", -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); + if (bw) { + freqStr.str(""); + freqStr << std::fixed << bw << " Hz"; + } else { + freqStr.str("---"); + } + getFont(fontSize).drawString(freqStr.str(), -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); - getFont(fontSize).drawString("CTR: ", 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); - if (center) { - freqStr.str(""); - freqStr << std::fixed << center << " Hz"; - } else { - freqStr.str("---"); - } - getFont(fontSize).drawString(freqStr.str(), 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); + getFont(fontSize).drawString("CTR: ", 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); + if (center) { + freqStr.str(""); + freqStr << std::fixed << center << " Hz"; + } else { + freqStr.str("---"); + } + getFont(fontSize).drawString(freqStr.str(), 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); - glColor3f(0.65, 0.65, 0.65); - glBegin(GL_LINES); - glVertex2f(-0.275, -1.0); - glVertex2f(-0.275, 1.0); - glVertex2f(0.275, -1.0); - glVertex2f(0.275, 1.0); - glEnd(); + glColor3f(0.65, 0.65, 0.65); + glBegin(GL_LINES); + glVertex2f(-0.275, -1.0); + glVertex2f(-0.275, 1.0); + glVertex2f(0.275, -1.0); + glVertex2f(0.275, 1.0); + glEnd(); */ } diff --git a/src/visual/TuningContext.h b/src/visual/TuningContext.h index afbb6e5..dd4c77b 100644 --- a/src/visual/TuningContext.h +++ b/src/visual/TuningContext.h @@ -15,6 +15,7 @@ public: 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 DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGBColor color, float alpha, bool top, bool bottom); void DrawDemodFreqBw(long long freq, unsigned int bw, long long center); void DrawEnd(); From 36f1bd6b01e82bbbd250b84ef232b808f69a9217 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Thu, 26 Mar 2015 20:12:54 -0400 Subject: [PATCH 04/19] tuner hover states and visual test --- src/CubicSDRDefs.h | 2 +- src/visual/ColorTheme.cpp | 2 + src/visual/ColorTheme.h | 2 + src/visual/TuningCanvas.cpp | 118 +++++++++++++++++++++++++++--------- src/visual/TuningCanvas.h | 14 +++++ 5 files changed, 107 insertions(+), 31 deletions(-) diff --git a/src/CubicSDRDefs.h b/src/CubicSDRDefs.h index de171dc..df6d892 100644 --- a/src/CubicSDRDefs.h +++ b/src/CubicSDRDefs.h @@ -1,6 +1,6 @@ #pragma once -#define CUBICSDR_TITLE "CubicSDR " CUBICSDR_VERSION " by Charles J. Cliffe (@ccliffe)" +#define CUBICSDR_TITLE "CubicSDR " CUBICSDR_VERSION " by Charles J. Cliffe (@ccliffe) :: www.cubicsdr.com" #ifndef __BYTE_ORDER #ifdef _WIN32 diff --git a/src/visual/ColorTheme.cpp b/src/visual/ColorTheme.cpp index bbb438c..4278876 100644 --- a/src/visual/ColorTheme.cpp +++ b/src/visual/ColorTheme.cpp @@ -49,6 +49,8 @@ DefaultColorTheme::DefaultColorTheme() { fftHighlight = RGBColor(1, 1, 1); scopeLine = RGBColor(0.9, 0.9, 0.9); tuningBar = RGBColor(0.2, 0.2, 0.9); + tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(0.1, 0.75, 0.1); meterValue = RGBColor(0.75, 0.1, 0.1); text = RGBColor(1, 1, 1); diff --git a/src/visual/ColorTheme.h b/src/visual/ColorTheme.h index 398dd3f..7101760 100644 --- a/src/visual/ColorTheme.h +++ b/src/visual/ColorTheme.h @@ -48,6 +48,8 @@ public: RGBColor fftHighlight; RGBColor scopeLine; RGBColor tuningBar; + RGBColor tuningBarUp; + RGBColor tuningBarDown; RGBColor meterLevel; RGBColor meterValue; RGBColor text; diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index a030043..152bfef 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -28,6 +28,18 @@ TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) : InteractiveCanvas(parent, attribList), dragAccum(0) { glContext = new TuningContext(this, &wxGetApp().GetContext(this)); + + hoverIndex = 0; + hoverState = TUNING_HOVER_NONE; + + freqDP = -1.0; + freqW = (1.0 / 3.0) * 2.0; + + bwDP = -1.0 + (2.25 / 3.0); + bwW = (1.0 / 4.0) * 2.0; + + centerDP = -1.0 + (2.0 / 3.0) * 2.0; + centerW = (1.0 / 3.0) * 2.0; } TuningCanvas::~TuningCanvas() { @@ -56,41 +68,57 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { long long bw = wxGetApp().getDemodMgr().getLastBandwidth(); long long center = wxGetApp().getFrequency(); - float freqDP = -1.0; - float freqW = (1.0 / 3.0) * 2.0; - - float bwDP = -1.0 + (2.25 / 3.0); - float bwW = (1.0 / 4.0) * 2.0; - - float centerDP = -1.0 + (2.0 / 3.0) * 2.0; - float centerW = (1.0 / 3.0) * 2.0; - - glContext->DrawTuner(freq, 11, freqDP, freqW); - glContext->DrawTuner(bw, 7, bwDP, bwW); - glContext->DrawTuner(center, 11, centerDP, centerW); - if (mouseTracker.mouseDown()) { glContext->Draw(ThemeMgr::mgr.currentTheme->tuningBar.r, ThemeMgr::mgr.currentTheme->tuningBar.g, ThemeMgr::mgr.currentTheme->tuningBar.b, 0.6, mouseTracker.getOriginMouseX(), mouseTracker.getMouseX()); } - int index; - bool top = mouseTracker.getMouseY()>=0.5; - bool bottom = mouseTracker.getMouseY()<=0.5; - index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, freqDP, freqW); // freq - if (index > 0) { - glContext->DrawTunerBarIndexed(1, index, 11, freqDP, freqW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // freq + bool top = mouseTracker.getMouseY() >= 0.5; + bool bottom = mouseTracker.getMouseY() <= 0.5; + + RGBColor clr = top ? ThemeMgr::mgr.currentTheme->tuningBarUp : ThemeMgr::mgr.currentTheme->tuningBarDown; + + RGBColor clrDark = ThemeMgr::mgr.currentTheme->tuningBar; + RGBColor clrMid = ThemeMgr::mgr.currentTheme->tuningBar; + RGBColor clrLight = ThemeMgr::mgr.currentTheme->tuningBar; + + clrDark.r*=0.5;clrDark.g*=0.5;clrDark.b*=0.5; + clrLight.r*=2.0;clrLight.g*=2.0;clrLight.b*=2.0; + + glContext->DrawTunerBarIndexed(1, 3, 11, freqDP, freqW, clrDark, 0.25, true, true); // freq + glContext->DrawTunerBarIndexed(4, 6, 11, freqDP, freqW, clrMid, 0.25, true, true); + glContext->DrawTunerBarIndexed(7, 9, 11, freqDP, freqW, clrDark, 0.25, true, true); + glContext->DrawTunerBarIndexed(10, 11, 11, freqDP, freqW, clrMid, 0.25, true, true); + + glContext->DrawTunerBarIndexed(1, 3, 7, bwDP, bwW, clrDark, 0.25, true, true); // bw + glContext->DrawTunerBarIndexed(4, 6, 7, bwDP, bwW, clrMid, 0.25, true, true); + glContext->DrawTunerBarIndexed(7, 7, 7, bwDP, bwW, clrDark, 0.25, true, true); + + glContext->DrawTunerBarIndexed(1, 3, 11, centerDP, centerW, clrDark, 0.25, true, true); // freq + glContext->DrawTunerBarIndexed(4, 6, 11, centerDP, centerW, clrMid, 0.25, true, true); + glContext->DrawTunerBarIndexed(7, 9, 11, centerDP, centerW, clrDark, 0.25, true, true); + glContext->DrawTunerBarIndexed(10, 11, 11, centerDP, centerW, clrMid, 0.25, true, true); + + if (hoverIndex > 0) { + switch (hoverState) { + + case TUNING_HOVER_FREQ: + glContext->DrawTunerBarIndexed(hoverIndex, hoverIndex, 11, freqDP, freqW, clr, 0.25, top, bottom); // freq + break; + case TUNING_HOVER_BW: + glContext->DrawTunerBarIndexed(hoverIndex, hoverIndex, 7, bwDP, bwW, clr, 0.25, top, bottom); // bw + break; + case TUNING_HOVER_CENTER: + glContext->DrawTunerBarIndexed(hoverIndex, hoverIndex, 11, centerDP, centerW, clr, 0.25, top, bottom); // center + break; + case TUNING_HOVER_NONE: + break; + } } - index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw - if (index > 0) { - glContext->DrawTunerBarIndexed(1, index, 7, bwDP, bwW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // bw - } - - index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center - if (index > 0) { - glContext->DrawTunerBarIndexed(1, index, 11, centerDP, centerW, ThemeMgr::mgr.currentTheme->tuningBar, 0.6, top, bottom); // center - } + glContext->DrawTuner(freq, 11, freqDP, freqW); + glContext->DrawTuner(bw, 7, bwDP, bwW); + glContext->DrawTuner(center, 11, centerDP, centerW); glContext->DrawEnd(); @@ -142,6 +170,32 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) { void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { InteractiveCanvas::OnMouseMoved(event); + + int index = 0; + + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, freqDP, freqW); // freq + if (index > 0) { + hoverIndex = index; + hoverState = TUNING_HOVER_FREQ; + return; + } + + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw + if (index > 0) { + hoverIndex = index; + hoverState = TUNING_HOVER_BW; + return; + } + + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center + if (index > 0) { + hoverIndex = index; + hoverState = TUNING_HOVER_CENTER; + return; + } + + hoverIndex = 0; + hoverState = TUNING_HOVER_NONE; } void TuningCanvas::OnMouseDown(wxMouseEvent& event) { @@ -161,17 +215,21 @@ void TuningCanvas::OnMouseWheelMoved(wxMouseEvent& event) { void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { InteractiveCanvas::OnMouseReleased(event); mouseTracker.setVertDragLock(false); - SetCursor(wxCURSOR_SIZEWE); + SetCursor(wxCURSOR_ARROW); } void TuningCanvas::OnMouseLeftWindow(wxMouseEvent& event) { InteractiveCanvas::OnMouseLeftWindow(event); SetCursor(wxCURSOR_CROSS); + hoverIndex = 0; + hoverState = TUNING_HOVER_NONE; } void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event); - SetCursor(wxCURSOR_SIZEWE); + SetCursor(wxCURSOR_ARROW); + hoverIndex = 0; + hoverState = TUNING_HOVER_NONE; } void TuningCanvas::setHelpTip(std::string tip) { diff --git a/src/visual/TuningCanvas.h b/src/visual/TuningCanvas.h index 1bd23ee..2f2db8a 100644 --- a/src/visual/TuningCanvas.h +++ b/src/visual/TuningCanvas.h @@ -15,6 +15,9 @@ class TuningCanvas: public InteractiveCanvas { public: + enum HoverState { + TUNING_HOVER_NONE, TUNING_HOVER_FREQ, TUNING_HOVER_BW, TUNING_HOVER_CENTER + }; TuningCanvas(wxWindow *parent, int *attribList = NULL); ~TuningCanvas(); @@ -36,6 +39,17 @@ private: std::string helpTip; float dragAccum; float uxDown; + HoverState hoverState; + int hoverIndex; + + float freqDP; + float freqW; + + float bwDP; + float bwW; + + float centerDP; + float centerW; // wxDECLARE_EVENT_TABLE(); }; From 3af564037ca465a0b8b68d8b3656d8d15dbdd8c8 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Thu, 26 Mar 2015 22:45:52 -0400 Subject: [PATCH 05/19] New tuning bar now functional --- src/demod/DemodulatorInstance.cpp | 8 ++ src/demod/DemodulatorInstance.h | 3 + src/demod/DemodulatorPreThread.cpp | 10 +- src/sdr/SDRPostThread.cpp | 12 +- src/visual/ColorTheme.cpp | 12 ++ src/visual/ScopeContext.cpp | 13 +++ src/visual/TuningCanvas.cpp | 173 +++++++++++++++++++---------- src/visual/TuningCanvas.h | 4 + src/visual/TuningContext.cpp | 5 +- 9 files changed, 171 insertions(+), 69 deletions(-) diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index 12a27fb..e27a913 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -335,3 +335,11 @@ void DemodulatorInstance::setGain(float gain_in) { float DemodulatorInstance::getGain() { return audioThread->getGain(); } + +bool DemodulatorInstance::isFollow() { + return follow; +} + +void DemodulatorInstance::setFollow(bool follow) { + this->follow = follow; +} diff --git a/src/demod/DemodulatorInstance.h b/src/demod/DemodulatorInstance.h index 15743b6..5f53a38 100644 --- a/src/demod/DemodulatorInstance.h +++ b/src/demod/DemodulatorInstance.h @@ -77,6 +77,8 @@ public: void setAudioSampleRate(int sampleRate); int getAudioSampleRate(); + bool isFollow(); + void setFollow(bool follow); private: @@ -96,4 +98,5 @@ private: int currentDemodType; int currentOutputDevice; int currentAudioSampleRate; + bool follow; }; diff --git a/src/demod/DemodulatorPreThread.cpp b/src/demod/DemodulatorPreThread.cpp index 3d5345d..1dad193 100644 --- a/src/demod/DemodulatorPreThread.cpp +++ b/src/demod/DemodulatorPreThread.cpp @@ -151,12 +151,10 @@ void DemodulatorPreThread::threadMain() { } // Requested frequency is not center, shift it into the center! - if (inp->frequency != params.frequency) { - if ((params.frequency - inp->frequency) != shiftFrequency || rateChanged) { - shiftFrequency = params.frequency - inp->frequency; - if (abs(shiftFrequency) <= (int) ((double) (wxGetApp().getSampleRate() / 2) * 1.5)) { - nco_crcf_set_frequency(freqShifter, (2.0 * M_PI) * (((double) abs(shiftFrequency)) / ((double) wxGetApp().getSampleRate()))); - } + if ((params.frequency - inp->frequency) != shiftFrequency || rateChanged) { + shiftFrequency = params.frequency - inp->frequency; + if (abs(shiftFrequency) <= (int) ((double) (wxGetApp().getSampleRate() / 2) * 1.5)) { + nco_crcf_set_frequency(freqShifter, (2.0 * M_PI) * (((double) abs(shiftFrequency)) / ((double) wxGetApp().getSampleRate()))); } } diff --git a/src/sdr/SDRPostThread.cpp b/src/sdr/SDRPostThread.cpp index 34b8942..f07b2b2 100644 --- a/src/sdr/SDRPostThread.cpp +++ b/src/sdr/SDRPostThread.cpp @@ -185,15 +185,18 @@ void SDRPostThread::threadMain() { DemodulatorInstance *demod = *i; DemodulatorThreadInputQueue *demodQueue = demod->threadQueueDemod; - if (demod->getFrequency() != data_in->frequency - && abs(data_in->frequency - demod->getFrequency()) > (wxGetApp().getSampleRate() / 2)) { - if (demod->isActive()) { + if (abs(data_in->frequency - demod->getFrequency()) > (wxGetApp().getSampleRate() / 2)) { + if (demod->isActive() && !demod->isFollow()) { demod->setActive(false); DemodulatorThreadIQData *dummyDataOut = new DemodulatorThreadIQData; dummyDataOut->frequency = data_in->frequency; dummyDataOut->sampleRate = data_in->sampleRate; demodQueue->push(dummyDataOut); } + + if (demod->isFollow() && wxGetApp().getFrequency() != demod->getFrequency()) { + wxGetApp().setFrequency(demod->getFrequency()); + } } else if (!demod->isActive()) { demod->setActive(true); if (wxGetApp().getDemodMgr().getLastActiveDemodulator() == NULL) { @@ -204,6 +207,9 @@ void SDRPostThread::threadMain() { if (!demod->isActive()) { continue; } + if (demod->isFollow()) { + demod->setFollow(false); + } demodQueue->push(demodDataOut); pushedData = true; diff --git a/src/visual/ColorTheme.cpp b/src/visual/ColorTheme.cpp index 4278876..038461f 100644 --- a/src/visual/ColorTheme.cpp +++ b/src/visual/ColorTheme.cpp @@ -79,6 +79,8 @@ RadarColorTheme::RadarColorTheme() { fftHighlight = RGBColor(1, 1, 1); scopeLine = RGBColor(0.8, 1.0, 0.8); tuningBar = RGBColor(0.2, 0.9, 0.2); + tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(0, 0.5, 0); meterValue = RGBColor(0, 0.5, 0); text = RGBColor(0.8, 1.0, 0.8); @@ -105,6 +107,8 @@ BlackAndWhiteColorTheme::BlackAndWhiteColorTheme() { fftHighlight = RGBColor(1, 1, 0.9); scopeLine = RGBColor(0.9, 0.9, 0.9); tuningBar = RGBColor(0.4, 0.4, 0.4); + tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(0.5, 0.5, 0.5); meterValue = RGBColor(0.5, 0.5, 0.5); text = RGBColor(1, 1, 1); @@ -140,6 +144,8 @@ SharpColorTheme::SharpColorTheme() { fftHighlight = RGBColor(0.9, 0.9, 1.0); scopeLine = RGBColor(0.85, 0.85, 1.0); tuningBar = RGBColor(0.2, 0.2, 0.9); + tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(28.0 / 255.0, 106.0 / 255.0, 179.0 / 255.0); meterValue = RGBColor(190.0 / 255.0, 190.0 / 255.0, 60.0 / 255.0); text = RGBColor(0.9, 0.9, 1); @@ -168,6 +174,8 @@ RadColorTheme::RadColorTheme() { fftHighlight = RGBColor(1, 1, 1); scopeLine = RGBColor(1.0, 0.9, 0.9); tuningBar = RGBColor(0.2, 0.2, 0.9); + tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(0, 0.5, 0); meterValue = RGBColor(0.5, 0, 0); text = RGBColor(1, 1, 1); @@ -199,6 +207,8 @@ TouchColorTheme::TouchColorTheme() { fftHighlight = RGBColor(1.0, 1.0, 1.0); scopeLine = RGBColor(234.0 / 255.0, 232.0 / 255.0, 247.0 / 255.0); tuningBar = RGBColor(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); + tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); meterValue = RGBColor(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); text = RGBColor(1, 1, 1); @@ -231,6 +241,8 @@ HDColorTheme::HDColorTheme() { fftHighlight = RGBColor(1, 1, 1); scopeLine = RGBColor(0.9, 0.9, 0.9); tuningBar = RGBColor(0, 0.7, 0.7); + tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(0, 0.5, 0); meterValue = RGBColor(0.0, 0.0, 1.0); text = RGBColor(1, 1, 1); diff --git a/src/visual/ScopeContext.cpp b/src/visual/ScopeContext.cpp index 9c5bf2e..6b72c4a 100644 --- a/src/visual/ScopeContext.cpp +++ b/src/visual/ScopeContext.cpp @@ -73,6 +73,19 @@ void ScopeContext::Plot(std::vector &points, bool stereo) { } glLineWidth(1.0); + + GLint vp[4]; + glGetIntegerv(GL_VIEWPORT, vp); + float viewHeight = (float) vp[3]; + float hPos = (float) (13) / viewHeight; + + glColor3f(0.65, 0.65, 0.65); + + getFont(PrimaryGLContext::GLFONT_SIZE12).drawString("Frequency", -0.66, -1.0+hPos, 12, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); + getFont(PrimaryGLContext::GLFONT_SIZE12).drawString("Bandwidth", 0.0, -1.0+hPos, 12, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); + getFont(PrimaryGLContext::GLFONT_SIZE12).drawString("Center Frequency", 0.66, -1.0+hPos, 12, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); + + if (stereo) { glColor3f(ThemeMgr::mgr.currentTheme->scopeLine.r, ThemeMgr::mgr.currentTheme->scopeLine.g, ThemeMgr::mgr.currentTheme->scopeLine.b); glBegin (GL_LINES); diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 152bfef..5b8ae67 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -25,7 +25,7 @@ EVT_ENTER_WINDOW(TuningCanvas::OnMouseEnterWindow) wxEND_EVENT_TABLE() TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) : - InteractiveCanvas(parent, attribList), dragAccum(0) { + InteractiveCanvas(parent, attribList), dragAccum(0), top(false), bottom(false), uxDown(0) { glContext = new TuningContext(this, &wxGetApp().GetContext(this)); @@ -73,31 +73,32 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { 0.6, mouseTracker.getOriginMouseX(), mouseTracker.getMouseX()); } - bool top = mouseTracker.getMouseY() >= 0.5; - bool bottom = mouseTracker.getMouseY() <= 0.5; - RGBColor clr = top ? ThemeMgr::mgr.currentTheme->tuningBarUp : ThemeMgr::mgr.currentTheme->tuningBarDown; RGBColor clrDark = ThemeMgr::mgr.currentTheme->tuningBar; RGBColor clrMid = ThemeMgr::mgr.currentTheme->tuningBar; RGBColor clrLight = ThemeMgr::mgr.currentTheme->tuningBar; - clrDark.r*=0.5;clrDark.g*=0.5;clrDark.b*=0.5; - clrLight.r*=2.0;clrLight.g*=2.0;clrLight.b*=2.0; + clrDark.r *= 0.5; + clrDark.g *= 0.5; + clrDark.b *= 0.5; + clrLight.r *= 2.0; + clrLight.g *= 2.0; + clrLight.b *= 2.0; - glContext->DrawTunerBarIndexed(1, 3, 11, freqDP, freqW, clrDark, 0.25, true, true); // freq - glContext->DrawTunerBarIndexed(4, 6, 11, freqDP, freqW, clrMid, 0.25, true, true); - glContext->DrawTunerBarIndexed(7, 9, 11, freqDP, freqW, clrDark, 0.25, true, true); - glContext->DrawTunerBarIndexed(10, 11, 11, freqDP, freqW, clrMid, 0.25, true, true); + glContext->DrawTunerBarIndexed(1, 3, 11, freqDP, freqW, clrMid, 0.25, true, true); // freq + glContext->DrawTunerBarIndexed(4, 6, 11, freqDP, freqW, clrDark, 0.25, true, true); + glContext->DrawTunerBarIndexed(7, 9, 11, freqDP, freqW, clrMid, 0.25, true, true); + glContext->DrawTunerBarIndexed(10, 11, 11, freqDP, freqW, clrDark, 0.25, true, true); - glContext->DrawTunerBarIndexed(1, 3, 7, bwDP, bwW, clrDark, 0.25, true, true); // bw - glContext->DrawTunerBarIndexed(4, 6, 7, bwDP, bwW, clrMid, 0.25, true, true); - glContext->DrawTunerBarIndexed(7, 7, 7, bwDP, bwW, clrDark, 0.25, true, true); + glContext->DrawTunerBarIndexed(1, 3, 7, bwDP, bwW, clrMid, 0.25, true, true); // bw + glContext->DrawTunerBarIndexed(4, 6, 7, bwDP, bwW, clrDark, 0.25, true, true); + glContext->DrawTunerBarIndexed(7, 7, 7, bwDP, bwW, clrMid, 0.25, true, true); - glContext->DrawTunerBarIndexed(1, 3, 11, centerDP, centerW, clrDark, 0.25, true, true); // freq - glContext->DrawTunerBarIndexed(4, 6, 11, centerDP, centerW, clrMid, 0.25, true, true); - glContext->DrawTunerBarIndexed(7, 9, 11, centerDP, centerW, clrDark, 0.25, true, true); - glContext->DrawTunerBarIndexed(10, 11, 11, centerDP, centerW, clrMid, 0.25, true, true); + glContext->DrawTunerBarIndexed(1, 3, 11, centerDP, centerW, clrMid, 0.25, true, true); // freq + glContext->DrawTunerBarIndexed(4, 6, 11, centerDP, centerW, clrDark, 0.25, true, true); + glContext->DrawTunerBarIndexed(7, 9, 11, centerDP, centerW, clrMid, 0.25, true, true); + glContext->DrawTunerBarIndexed(10, 11, 11, centerDP, centerW, clrDark, 0.25, true, true); if (hoverIndex > 0) { switch (hoverState) { @@ -126,44 +127,44 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { } void TuningCanvas::OnIdle(wxIdleEvent &event) { - if (mouseTracker.mouseDown()) { - DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); - - float dragDelta = mouseTracker.getMouseX() - mouseTracker.getOriginMouseX(); - - dragAccum += dragDelta; - - float moveVal = dragAccum * 10.0; - - if (uxDown > 0.275) { - wxGetApp().setFrequency( - wxGetApp().getFrequency() - + (int) (dragAccum * fabs(dragAccum * 10.0) * fabs(dragAccum * 10.0) * (float) wxGetApp().getSampleRate())); - } else if (fabs(moveVal) >= 1.0) { - if (uxDown < -0.275) { - if (activeDemod != NULL) { - long long freq = activeDemod->getFrequency() + (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)); - activeDemod->setFrequency(freq); - activeDemod->updateLabel(freq); - } - } else { - int amt = (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)); - if (activeDemod != NULL) { - activeDemod->setBandwidth(activeDemod->getBandwidth() + amt); - } else { - wxGetApp().getDemodMgr().setLastBandwidth(wxGetApp().getDemodMgr().getLastBandwidth() + amt); - } - } - } - - while (fabs(dragAccum * 10.0) >= 1.0) { - if (dragAccum > 0) { - dragAccum -= 1.0 / 10.0; - } else { - dragAccum += 1.0 / 10.0; - } - } - } +// if (mouseTracker.mouseDown()) { +// DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); +// +// float dragDelta = mouseTracker.getMouseX() - mouseTracker.getOriginMouseX(); +// +// dragAccum += dragDelta; +// +// float moveVal = dragAccum * 10.0; +// +// if (uxDown > 0.275) { +// wxGetApp().setFrequency( +// wxGetApp().getFrequency() +// + (int) (dragAccum * fabs(dragAccum * 10.0) * fabs(dragAccum * 10.0) * (float) wxGetApp().getSampleRate())); +// } else if (fabs(moveVal) >= 1.0) { +// if (uxDown < -0.275) { +// if (activeDemod != NULL) { +// long long freq = activeDemod->getFrequency() + (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)); +// activeDemod->setFrequency(freq); +// activeDemod->updateLabel(freq); +// } +// } else { +// int amt = (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)); +// if (activeDemod != NULL) { +// activeDemod->setBandwidth(activeDemod->getBandwidth() + amt); +// } else { +// wxGetApp().getDemodMgr().setLastBandwidth(wxGetApp().getDemodMgr().getLastBandwidth() + amt); +// } +// } +// } +// +// while (fabs(dragAccum * 10.0) >= 1.0) { +// if (dragAccum > 0) { +// dragAccum -= 1.0 / 10.0; +// } else { +// dragAccum += 1.0 / 10.0; +// } +// } +// } Refresh(false); } @@ -173,6 +174,9 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { int index = 0; + top = mouseTracker.getMouseY() >= 0.5; + bottom = mouseTracker.getMouseY() <= 0.5; + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, freqDP, freqW); // freq if (index > 0) { hoverIndex = index; @@ -200,12 +204,9 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { void TuningCanvas::OnMouseDown(wxMouseEvent& event) { InteractiveCanvas::OnMouseDown(event); - mouseTracker.setVertDragLock(true); uxDown = 2.0 * (mouseTracker.getMouseX() - 0.5); - dragAccum = 0; - SetCursor(wxCURSOR_IBEAM); } void TuningCanvas::OnMouseWheelMoved(wxMouseEvent& event) { @@ -213,8 +214,62 @@ void TuningCanvas::OnMouseWheelMoved(wxMouseEvent& event) { } void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { + GLint vp[4]; + glGetIntegerv( GL_VIEWPORT, vp); + + float viewHeight = (float) vp[3]; + float viewWidth = (float) vp[2]; + InteractiveCanvas::OnMouseReleased(event); - mouseTracker.setVertDragLock(false); + + DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); + + int hExponent = hoverIndex - 1; + + if (hoverState == TUNING_HOVER_FREQ && activeDemod) { + long long freq = activeDemod->getFrequency(); + if (top) { + freq += pow(10, hExponent); + } else { + freq -= pow(10, hExponent); + } + + long long diff = abs(wxGetApp().getFrequency() - freq); + + if (wxGetApp().getSampleRate() / 2 < diff) { + wxGetApp().setFrequency(freq); + } + + activeDemod->setFrequency(freq); + activeDemod->updateLabel(freq); + } + + if (hoverState == TUNING_HOVER_BW) { + long bw = wxGetApp().getDemodMgr().getLastBandwidth(); + if (bw > wxGetApp().getSampleRate()) { + bw = wxGetApp().getSampleRate(); + } + if (top) { + bw += pow(10, hExponent); + } else { + bw -= pow(10, hExponent); + } + + wxGetApp().getDemodMgr().setLastBandwidth(bw); + + if (activeDemod) { + activeDemod->setBandwidth(wxGetApp().getDemodMgr().getLastBandwidth()); + } + } + + if (hoverState == TUNING_HOVER_CENTER) { + if (top) { + wxGetApp().setFrequency(wxGetApp().getFrequency() + pow(10, hExponent)); + } else { + wxGetApp().setFrequency(wxGetApp().getFrequency() - pow(10, hExponent)); + } + } + SetCursor(wxCURSOR_ARROW); } diff --git a/src/visual/TuningCanvas.h b/src/visual/TuningCanvas.h index 2f2db8a..53bc2c3 100644 --- a/src/visual/TuningCanvas.h +++ b/src/visual/TuningCanvas.h @@ -50,6 +50,10 @@ private: float centerDP; float centerW; + + bool top; + bool bottom; + // wxDECLARE_EVENT_TABLE(); }; diff --git a/src/visual/TuningContext.cpp b/src/visual/TuningContext.cpp index ac1d72b..d5c0115 100644 --- a/src/visual/TuningContext.cpp +++ b/src/visual/TuningContext.cpp @@ -99,7 +99,9 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float getFont(fontSize).drawString(freqStr.str().substr(i - ofs, 1), xpos, 0, fontHeight, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER); } - glColor3f(0.65, 0.65, 0.65); + glColor4f(0.65, 0.65, 0.65, 0.25); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBegin(GL_LINES); for (int i = count; i >= 0; i--) { float xpos = displayPos + (displayWidth / (float) count) * (float) i; @@ -107,6 +109,7 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float glVertex2f(xpos, 1.0); } glEnd(); + glDisable(GL_BLEND); } int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth) { From b74e0d0fad4ec99b0173d2503209f51a613c0d4e Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Fri, 27 Mar 2015 21:15:24 -0400 Subject: [PATCH 06/19] Experimental shift key click to prevent carry for frequency tuner --- src/visual/TuningCanvas.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 5b8ae67..2b90655 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -225,17 +225,20 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); int hExponent = hoverIndex - 1; + double exp = pow(10, hExponent); + long long amount = top?exp:-exp; if (hoverState == TUNING_HOVER_FREQ && activeDemod) { long long freq = activeDemod->getFrequency(); - if (top) { - freq += pow(10, hExponent); - } else { - freq -= pow(10, hExponent); - } - long long diff = abs(wxGetApp().getFrequency() - freq); + if (shiftDown) { + bool carried = (long long)((freq) / (exp * 10)) != (long long)((freq + amount) / (exp * 10)); + freq += carried?(9*-amount):amount; + } else { + freq += amount; + } + if (wxGetApp().getSampleRate() / 2 < diff) { wxGetApp().setFrequency(freq); } @@ -245,15 +248,10 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { } if (hoverState == TUNING_HOVER_BW) { - long bw = wxGetApp().getDemodMgr().getLastBandwidth(); + long bw = wxGetApp().getDemodMgr().getLastBandwidth()+amount; if (bw > wxGetApp().getSampleRate()) { bw = wxGetApp().getSampleRate(); } - if (top) { - bw += pow(10, hExponent); - } else { - bw -= pow(10, hExponent); - } wxGetApp().getDemodMgr().setLastBandwidth(bw); @@ -263,11 +261,7 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { } if (hoverState == TUNING_HOVER_CENTER) { - if (top) { - wxGetApp().setFrequency(wxGetApp().getFrequency() + pow(10, hExponent)); - } else { - wxGetApp().setFrequency(wxGetApp().getFrequency() - pow(10, hExponent)); - } + wxGetApp().setFrequency(wxGetApp().getFrequency() + amount); } SetCursor(wxCURSOR_ARROW); From 3127868895a817f29e8ec8d6e46836582d6f0833 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Fri, 27 Mar 2015 23:25:59 -0400 Subject: [PATCH 07/19] Add shift key no-carry for bandwidth and center --- src/visual/TuningCanvas.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 2b90655..c9d71da 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -245,10 +245,19 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { activeDemod->setFrequency(freq); activeDemod->updateLabel(freq); + activeDemod->setFollow(true); } if (hoverState == TUNING_HOVER_BW) { - long bw = wxGetApp().getDemodMgr().getLastBandwidth()+amount; + long bw = wxGetApp().getDemodMgr().getLastBandwidth(); + + if (shiftDown) { + bool carried = (long)((bw) / (exp * 10)) != (long)((bw + amount) / (exp * 10)); + bw += carried?(9*-amount):amount; + } else { + bw += amount; + } + if (bw > wxGetApp().getSampleRate()) { bw = wxGetApp().getSampleRate(); } @@ -261,7 +270,15 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { } if (hoverState == TUNING_HOVER_CENTER) { - wxGetApp().setFrequency(wxGetApp().getFrequency() + amount); + long long ctr = wxGetApp().getFrequency(); + if (shiftDown) { + bool carried = (long long)((ctr) / (exp * 10)) != (long long)((ctr + amount) / (exp * 10)); + ctr += carried?(9*-amount):amount; + } else { + ctr += amount; + } + + wxGetApp().setFrequency(ctr); } SetCursor(wxCURSOR_ARROW); From 6213623e0fff88afb250060be5077439bb3d834c Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sat, 28 Mar 2015 00:04:42 -0400 Subject: [PATCH 08/19] fix for no-carry on leading digits --- src/visual/TuningCanvas.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index c9d71da..8513a3a 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -233,7 +233,7 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { long long diff = abs(wxGetApp().getFrequency() - freq); if (shiftDown) { - bool carried = (long long)((freq) / (exp * 10)) != (long long)((freq + amount) / (exp * 10)); + bool carried = (long long)((freq) / (exp * 10)) != (long long)((freq + amount) / (exp * 10)) || (bottom && freq < exp); freq += carried?(9*-amount):amount; } else { freq += amount; @@ -252,7 +252,7 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { long bw = wxGetApp().getDemodMgr().getLastBandwidth(); if (shiftDown) { - bool carried = (long)((bw) / (exp * 10)) != (long)((bw + amount) / (exp * 10)); + bool carried = (long)((bw) / (exp * 10)) != (long)((bw + amount) / (exp * 10)) || (bottom && bw < exp); bw += carried?(9*-amount):amount; } else { bw += amount; @@ -272,7 +272,7 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { if (hoverState == TUNING_HOVER_CENTER) { long long ctr = wxGetApp().getFrequency(); if (shiftDown) { - bool carried = (long long)((ctr) / (exp * 10)) != (long long)((ctr + amount) / (exp * 10)); + bool carried = (long long)((ctr) / (exp * 10)) != (long long)((ctr + amount) / (exp * 10)) || (bottom && ctr < exp); ctr += carried?(9*-amount):amount; } else { ctr += amount; From a1567628c06cc83793fe6afb6c1783fe77fb79c5 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sat, 28 Mar 2015 00:59:04 -0400 Subject: [PATCH 09/19] allow dragging digits to seek tuner value at that exponent --- src/visual/TuningCanvas.cpp | 176 +++++++++++++++++------------------- src/visual/TuningCanvas.h | 7 +- 2 files changed, 88 insertions(+), 95 deletions(-) diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 8513a3a..3962d5b 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -100,7 +100,7 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { glContext->DrawTunerBarIndexed(7, 9, 11, centerDP, centerW, clrMid, 0.25, true, true); glContext->DrawTunerBarIndexed(10, 11, 11, centerDP, centerW, clrDark, 0.25, true, true); - if (hoverIndex > 0) { + if (hoverIndex > 0 && !mouseTracker.mouseDown()) { switch (hoverState) { case TUNING_HOVER_FREQ: @@ -126,45 +126,82 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { SwapBuffers(); } +void TuningCanvas::StepTuner(ActiveState state, int exponent, bool up) { + double exp = pow(10, exponent); + long long amount = up?exp:-exp; + + DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); + if (state == TUNING_HOVER_FREQ && activeDemod) { + long long freq = activeDemod->getFrequency(); + long long diff = abs(wxGetApp().getFrequency() - freq); + + if (shiftDown) { + bool carried = (long long)((freq) / (exp * 10)) != (long long)((freq + amount) / (exp * 10)) || (bottom && freq < exp); + freq += carried?(9*-amount):amount; + } else { + freq += amount; + } + + if (wxGetApp().getSampleRate() / 2 < diff) { + wxGetApp().setFrequency(freq); + } + + activeDemod->setFrequency(freq); + activeDemod->updateLabel(freq); + activeDemod->setFollow(true); + } + + if (state == TUNING_HOVER_BW) { + long bw = wxGetApp().getDemodMgr().getLastBandwidth(); + + if (shiftDown) { + bool carried = (long)((bw) / (exp * 10)) != (long)((bw + amount) / (exp * 10)) || (bottom && bw < exp); + bw += carried?(9*-amount):amount; + } else { + bw += amount; + } + + if (bw > wxGetApp().getSampleRate()) { + bw = wxGetApp().getSampleRate(); + } + + wxGetApp().getDemodMgr().setLastBandwidth(bw); + + if (activeDemod) { + activeDemod->setBandwidth(wxGetApp().getDemodMgr().getLastBandwidth()); + } + } + + if (state == TUNING_HOVER_CENTER) { + long long ctr = wxGetApp().getFrequency(); + if (shiftDown) { + bool carried = (long long)((ctr) / (exp * 10)) != (long long)((ctr + amount) / (exp * 10)) || (bottom && ctr < exp); + ctr += carried?(9*-amount):amount; + } else { + ctr += amount; + } + + wxGetApp().setFrequency(ctr); + } +} + void TuningCanvas::OnIdle(wxIdleEvent &event) { -// if (mouseTracker.mouseDown()) { -// DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); -// -// float dragDelta = mouseTracker.getMouseX() - mouseTracker.getOriginMouseX(); -// -// dragAccum += dragDelta; -// -// float moveVal = dragAccum * 10.0; -// -// if (uxDown > 0.275) { -// wxGetApp().setFrequency( -// wxGetApp().getFrequency() -// + (int) (dragAccum * fabs(dragAccum * 10.0) * fabs(dragAccum * 10.0) * (float) wxGetApp().getSampleRate())); -// } else if (fabs(moveVal) >= 1.0) { -// if (uxDown < -0.275) { -// if (activeDemod != NULL) { -// long long freq = activeDemod->getFrequency() + (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)); -// activeDemod->setFrequency(freq); -// activeDemod->updateLabel(freq); -// } -// } else { -// int amt = (int) (moveVal * fabs(moveVal) * fabs(moveVal) * fabs(moveVal)); -// if (activeDemod != NULL) { -// activeDemod->setBandwidth(activeDemod->getBandwidth() + amt); -// } else { -// wxGetApp().getDemodMgr().setLastBandwidth(wxGetApp().getDemodMgr().getLastBandwidth() + amt); -// } -// } -// } -// -// while (fabs(dragAccum * 10.0) >= 1.0) { -// if (dragAccum > 0) { -// dragAccum -= 1.0 / 10.0; -// } else { -// dragAccum += 1.0 / 10.0; -// } -// } -// } + if (mouseTracker.mouseDown()) { + if (downState != TUNING_HOVER_NONE) { + dragAccum += 5.0*mouseTracker.getOriginDeltaMouseX(); + while (dragAccum > 1.0) { + StepTuner(downState, downIndex-1, true); + dragAccum -= 1.0; + } + while (dragAccum < -1.0) { + StepTuner(downState, downIndex-1, false); + dragAccum += 1.0; + } + } else { + dragAccum = 0; + } +std::cout << dragAccum << std::endl; + } Refresh(false); } @@ -207,6 +244,10 @@ void TuningCanvas::OnMouseDown(wxMouseEvent& event) { uxDown = 2.0 * (mouseTracker.getMouseX() - 0.5); dragAccum = 0; + + mouseTracker.setVertDragLock(true); + downIndex = hoverIndex; + downState = hoverState; } void TuningCanvas::OnMouseWheelMoved(wxMouseEvent& event) { @@ -222,64 +263,13 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { InteractiveCanvas::OnMouseReleased(event); - DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); - int hExponent = hoverIndex - 1; - double exp = pow(10, hExponent); - long long amount = top?exp:-exp; - if (hoverState == TUNING_HOVER_FREQ && activeDemod) { - long long freq = activeDemod->getFrequency(); - long long diff = abs(wxGetApp().getFrequency() - freq); - - if (shiftDown) { - bool carried = (long long)((freq) / (exp * 10)) != (long long)((freq + amount) / (exp * 10)) || (bottom && freq < exp); - freq += carried?(9*-amount):amount; - } else { - freq += amount; - } - - if (wxGetApp().getSampleRate() / 2 < diff) { - wxGetApp().setFrequency(freq); - } - - activeDemod->setFrequency(freq); - activeDemod->updateLabel(freq); - activeDemod->setFollow(true); + if (hoverState != TUNING_HOVER_NONE) { + StepTuner(hoverState, hExponent, top); } - if (hoverState == TUNING_HOVER_BW) { - long bw = wxGetApp().getDemodMgr().getLastBandwidth(); - - if (shiftDown) { - bool carried = (long)((bw) / (exp * 10)) != (long)((bw + amount) / (exp * 10)) || (bottom && bw < exp); - bw += carried?(9*-amount):amount; - } else { - bw += amount; - } - - if (bw > wxGetApp().getSampleRate()) { - bw = wxGetApp().getSampleRate(); - } - - wxGetApp().getDemodMgr().setLastBandwidth(bw); - - if (activeDemod) { - activeDemod->setBandwidth(wxGetApp().getDemodMgr().getLastBandwidth()); - } - } - - if (hoverState == TUNING_HOVER_CENTER) { - long long ctr = wxGetApp().getFrequency(); - if (shiftDown) { - bool carried = (long long)((ctr) / (exp * 10)) != (long long)((ctr + amount) / (exp * 10)) || (bottom && ctr < exp); - ctr += carried?(9*-amount):amount; - } else { - ctr += amount; - } - - wxGetApp().setFrequency(ctr); - } + mouseTracker.setVertDragLock(false); SetCursor(wxCURSOR_ARROW); } diff --git a/src/visual/TuningCanvas.h b/src/visual/TuningCanvas.h index 53bc2c3..46037c3 100644 --- a/src/visual/TuningCanvas.h +++ b/src/visual/TuningCanvas.h @@ -15,7 +15,7 @@ class TuningCanvas: public InteractiveCanvas { public: - enum HoverState { + enum ActiveState { TUNING_HOVER_NONE, TUNING_HOVER_FREQ, TUNING_HOVER_BW, TUNING_HOVER_CENTER }; TuningCanvas(wxWindow *parent, int *attribList = NULL); @@ -33,14 +33,17 @@ private: void OnMouseReleased(wxMouseEvent& event); void OnMouseEnterWindow(wxMouseEvent& event); void OnMouseLeftWindow(wxMouseEvent& event); + void StepTuner(ActiveState state, int factor, bool up = true); TuningContext *glContext; std::string helpTip; float dragAccum; float uxDown; - HoverState hoverState; + ActiveState hoverState; + ActiveState downState; int hoverIndex; + int downIndex; float freqDP; float freqW; From d945c58579ba406b4bfaea1fa9dd9600c73160cd Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sat, 28 Mar 2015 00:59:54 -0400 Subject: [PATCH 10/19] remove debug line --- src/visual/TuningCanvas.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 3962d5b..a10ca11 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -200,7 +200,6 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) { } else { dragAccum = 0; } -std::cout << dragAccum << std::endl; } Refresh(false); From b4fb0984d34b5babf59f8f3099e575348c96778a Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sat, 28 Mar 2015 01:11:33 -0400 Subject: [PATCH 11/19] prevent mouseup tuner step on drag stop --- src/visual/TuningCanvas.cpp | 9 ++++++++- src/visual/TuningCanvas.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index a10ca11..e8686e0 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -30,7 +30,10 @@ TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) : glContext = new TuningContext(this, &wxGetApp().GetContext(this)); hoverIndex = 0; + downIndex = 0; hoverState = TUNING_HOVER_NONE; + downState = TUNING_HOVER_NONE; + dragging = false; freqDP = -1.0; freqW = (1.0 / 3.0) * 2.0; @@ -192,13 +195,16 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) { while (dragAccum > 1.0) { StepTuner(downState, downIndex-1, true); dragAccum -= 1.0; + dragging = true; } while (dragAccum < -1.0) { StepTuner(downState, downIndex-1, false); dragAccum += 1.0; + dragging = true; } } else { dragAccum = 0; + dragging = false; } } @@ -264,12 +270,13 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { int hExponent = hoverIndex - 1; - if (hoverState != TUNING_HOVER_NONE) { + if (hoverState != TUNING_HOVER_NONE && !dragging) { StepTuner(hoverState, hExponent, top); } mouseTracker.setVertDragLock(false); + dragging = false; SetCursor(wxCURSOR_ARROW); } diff --git a/src/visual/TuningCanvas.h b/src/visual/TuningCanvas.h index 46037c3..21b22c5 100644 --- a/src/visual/TuningCanvas.h +++ b/src/visual/TuningCanvas.h @@ -44,6 +44,7 @@ private: ActiveState downState; int hoverIndex; int downIndex; + bool dragging; float freqDP; float freqW; From 2e340609015302873e9d9c3ef88a99873410939f Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sat, 28 Mar 2015 03:36:51 -0400 Subject: [PATCH 12/19] fix for tuner not updating spectrum view --- src/AppFrame.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index d9c4f20..5e296b4 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -516,7 +516,9 @@ void AppFrame::OnIdle(wxIdleEvent& event) { demodGainMeter->setLevel(demodGainMeter->getInputValue()); } - if (wxGetApp().getFrequency() != demodWaterfallCanvas->getCenterFrequency()) { + if (wxGetApp().getFrequency() != waterfallCanvas->getCenterFrequency()) { + spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); + waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); } From d95925a3c4b38829bd8354cc8c0c4aaab8b31814 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sat, 28 Mar 2015 03:51:22 -0400 Subject: [PATCH 13/19] fix locked view on zoomed view after demodulators are deactivated --- src/AppFrame.cpp | 4 +++- src/visual/InteractiveCanvas.cpp | 4 ++++ src/visual/InteractiveCanvas.h | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 5e296b4..bc298ae 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -517,7 +517,9 @@ void AppFrame::OnIdle(wxIdleEvent& event) { } if (wxGetApp().getFrequency() != waterfallCanvas->getCenterFrequency()) { - spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); + if (!spectrumCanvas->getMouseTracker()->mouseDown()) { + spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); + } waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); diff --git a/src/visual/InteractiveCanvas.cpp b/src/visual/InteractiveCanvas.cpp index 226d8f5..cdd5903 100644 --- a/src/visual/InteractiveCanvas.cpp +++ b/src/visual/InteractiveCanvas.cpp @@ -73,6 +73,10 @@ unsigned int InteractiveCanvas::getBandwidth() { } } +MouseTracker *InteractiveCanvas::getMouseTracker() { + return &mouseTracker; +} + void InteractiveCanvas::OnKeyUp(wxKeyEvent& event) { shiftDown = event.ShiftDown(); altDown = event.AltDown(); diff --git a/src/visual/InteractiveCanvas.h b/src/visual/InteractiveCanvas.h index 6699d49..cb94a4f 100644 --- a/src/visual/InteractiveCanvas.h +++ b/src/visual/InteractiveCanvas.h @@ -22,6 +22,8 @@ public: void setBandwidth(unsigned int bandwidth_in); unsigned int getBandwidth(); + MouseTracker *getMouseTracker(); + protected: void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); From efa2cd75c97e0ec0530c5a40e7fca0016aee654c Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sun, 29 Mar 2015 20:24:00 -0400 Subject: [PATCH 14/19] tuning tweaks, zoomed view following fix --- src/AppFrame.cpp | 93 ++++++++++++++----------------- src/demod/DemodulatorInstance.cpp | 6 +- src/visual/InteractiveCanvas.cpp | 4 ++ src/visual/InteractiveCanvas.h | 1 + src/visual/TuningCanvas.cpp | 45 ++++++++++----- 5 files changed, 81 insertions(+), 68 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index bc298ae..fb92aab 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -38,7 +38,7 @@ EVT_IDLE(AppFrame::OnIdle) wxEND_EVENT_TABLE() AppFrame::AppFrame() : -wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { + wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { #ifdef __linux__ SetIcon(wxICON(cubicsdr)); @@ -50,13 +50,7 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL); - int attribList[] = { - WX_GL_RGBA, - WX_GL_STENCIL_SIZE, 8, - WX_GL_BUFFER_SIZE, 24, - WX_GL_DOUBLEBUFFER, - 0 - }; + int attribList[] = { WX_GL_RGBA, WX_GL_STENCIL_SIZE, 8, WX_GL_BUFFER_SIZE, 24, WX_GL_DOUBLEBUFFER, 0 }; demodModeSelector = new ModeSelectorCanvas(this, attribList); demodModeSelector->addChoice(DEMOD_TYPE_FM, "FM"); @@ -164,7 +158,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { i++; } - for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) { wxMenuItem *itm = menu->AppendRadioItem(wxID_RT_AUDIO_DEVICE + mdevices_i->first, mdevices_i->second.name, wxT("Description?")); itm->SetId(wxID_RT_AUDIO_DEVICE + mdevices_i->first); @@ -232,31 +225,30 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { menuBar->Append(menu, wxT("Input &Device")); } - menu = new wxMenu; - - #define NUM_RATES_DEFAULT 4 +#define NUM_RATES_DEFAULT 4 int desired_rates[NUM_RATES_DEFAULT] = { 48000, 44100, 96000, 192000 }; for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) { - int desired_rate = 0; - int desired_rank = NUM_RATES_DEFAULT+1; + int desired_rate = 0; + int desired_rank = NUM_RATES_DEFAULT + 1; - for (std::vector::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) { - for (i = 0; i < NUM_RATES_DEFAULT; i++) { - if (desired_rates[i] == (*srate)) { - if (desired_rank > i) { - desired_rank = i; - desired_rate = (*srate); - } - } - } + for (std::vector::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); + srate++) { + for (i = 0; i < NUM_RATES_DEFAULT; i++) { + if (desired_rates[i] == (*srate)) { + if (desired_rank > i) { + desired_rank = i; + desired_rate = (*srate); + } + } + } } - if (desired_rank > NUM_RATES_DEFAULT) { - desired_rate = mdevices_i->second.sampleRates.back(); - } + if (desired_rank > NUM_RATES_DEFAULT) { + desired_rate = mdevices_i->second.sampleRates.back(); + } AudioThread::deviceSampleRate[mdevices_i->first] = desired_rate; } @@ -264,18 +256,19 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { new wxMenu; int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first; wxMenu *subMenu = new wxMenu; - menu->AppendSubMenu(subMenu,mdevices_i->second.name, wxT("Description?")); + menu->AppendSubMenu(subMenu, mdevices_i->second.name, wxT("Description?")); int j = 0; - for (std::vector::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) { + for (std::vector::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); + srate++) { std::stringstream srateName; - srateName << ((float)(*srate)/1000.0f) << "kHz"; - wxMenuItem *itm = subMenu->AppendRadioItem(menu_id+j, srateName.str(), wxT("Description?")); + srateName << ((float) (*srate) / 1000.0f) << "kHz"; + wxMenuItem *itm = subMenu->AppendRadioItem(menu_id + j, srateName.str(), wxT("Description?")); if ((*srate) == AudioThread::deviceSampleRate[mdevices_i->first]) { itm->Check(true); } - audioSampleRateMenuItems[menu_id+j] = itm; + audioSampleRateMenuItems[menu_id + j] = itm; j++; } @@ -283,7 +276,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { menuBar->Append(menu, wxT("Audio &Bandwidth")); - SetMenuBar(menuBar); CreateStatusBar(); @@ -291,7 +283,6 @@ wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(NULL) { Centre(); Show(); - #ifdef _WIN32 SetIcon(wxICON(frame_icon)); #endif @@ -398,7 +389,6 @@ void AppFrame::OnMenu(wxCommandEvent& event) { wxGetApp().setDevice(event.GetId() - wxID_DEVICE_ID); } - if (event.GetId() >= wxID_AUDIO_BANDWIDTH_BASE) { int evId = event.GetId(); std::vector::iterator devices_i; @@ -406,21 +396,22 @@ void AppFrame::OnMenu(wxCommandEvent& event) { int i = 0; for (mdevices_i = outputDevices.begin(); mdevices_i != outputDevices.end(); mdevices_i++) { - int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first; + int menu_id = wxID_AUDIO_BANDWIDTH_BASE + wxID_AUDIO_DEVICE_MULTIPLIER * mdevices_i->first; - int j = 0; - for (std::vector::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); srate++) { + int j = 0; + for (std::vector::iterator srate = mdevices_i->second.sampleRates.begin(); srate != mdevices_i->second.sampleRates.end(); + srate++) { - if (evId == menu_id + j) { - //audioSampleRateMenuItems[menu_id+j]; - //std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl; - AudioThread::setDeviceSampleRate(mdevices_i->first, *srate); - } + if (evId == menu_id + j) { + //audioSampleRateMenuItems[menu_id+j]; + //std::cout << "Would set audio sample rate on device " << mdevices_i->second.name << " (" << mdevices_i->first << ") to " << (*srate) << "Hz" << std::endl; + AudioThread::setDeviceSampleRate(mdevices_i->first, *srate); + } - j++; - } - i++; - } + j++; + } + i++; + } } } @@ -463,12 +454,12 @@ void AppFrame::OnIdle(wxIdleEvent& event) { if (demod->getDemodulatorType() == DEMOD_TYPE_USB) { demodBw /= 2; - centerFreq += demod->getBandwidth()/4; + centerFreq += demod->getBandwidth() / 4; } if (demod->getDemodulatorType() == DEMOD_TYPE_LSB) { demodBw /= 2; - centerFreq -= demod->getBandwidth()/4; + centerFreq -= demod->getBandwidth() / 4; } if (demodBw > wxGetApp().getSampleRate() / 2) { @@ -516,11 +507,11 @@ void AppFrame::OnIdle(wxIdleEvent& event) { demodGainMeter->setLevel(demodGainMeter->getInputValue()); } - if (wxGetApp().getFrequency() != waterfallCanvas->getCenterFrequency()) { - if (!spectrumCanvas->getMouseTracker()->mouseDown()) { + if (wxGetApp().getFrequency() != demodWaterfallCanvas->getCenterFrequency()) { + if (spectrumCanvas->getViewState() && abs(wxGetApp().getFrequency()-spectrumCanvas->getCenterFrequency()) > (wxGetApp().getSampleRate()/2)) { spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); + waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); } - waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); } diff --git a/src/demod/DemodulatorInstance.cpp b/src/demod/DemodulatorInstance.cpp index e27a913..52b4047 100644 --- a/src/demod/DemodulatorInstance.cpp +++ b/src/demod/DemodulatorInstance.cpp @@ -236,9 +236,9 @@ int DemodulatorInstance::getOutputDevice() { } void DemodulatorInstance::checkBandwidth() { - if ((currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB) && (getBandwidth() % 2)) { - setBandwidth(getBandwidth()+1); - } +// if ((currentDemodType == DEMOD_TYPE_USB || currentDemodType == DEMOD_TYPE_LSB) && (getBandwidth() % 2)) { +// setBandwidth(getBandwidth()+1); +// } } void DemodulatorInstance::setDemodulatorType(int demod_type_in) { diff --git a/src/visual/InteractiveCanvas.cpp b/src/visual/InteractiveCanvas.cpp index cdd5903..9a24165 100644 --- a/src/visual/InteractiveCanvas.cpp +++ b/src/visual/InteractiveCanvas.cpp @@ -41,6 +41,10 @@ void InteractiveCanvas::disableView() { lastBandwidth = 0; } +bool InteractiveCanvas::getViewState() { + return isView; +} + long long InteractiveCanvas::getFrequencyAt(float x) { long long iqCenterFreq = getCenterFrequency(); long long iqBandwidth = getBandwidth(); diff --git a/src/visual/InteractiveCanvas.h b/src/visual/InteractiveCanvas.h index cb94a4f..055dcc9 100644 --- a/src/visual/InteractiveCanvas.h +++ b/src/visual/InteractiveCanvas.h @@ -15,6 +15,7 @@ public: void setView(long long center_freq_in, int bandwidth_in); void disableView(); + bool getViewState(); void setCenterFrequency(long long center_freq_in); long long getCenterFrequency(); diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index e8686e0..11854fa 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -223,25 +223,42 @@ void TuningCanvas::OnMouseMoved(wxMouseEvent& event) { if (index > 0) { hoverIndex = index; hoverState = TUNING_HOVER_FREQ; - return; } - index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw - if (index > 0) { - hoverIndex = index; - hoverState = TUNING_HOVER_BW; - return; + if (!index) { + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 7, bwDP, bwW); // bw + if (index > 0) { + hoverIndex = index; + hoverState = TUNING_HOVER_BW; + } } - index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center - if (index > 0) { - hoverIndex = index; - hoverState = TUNING_HOVER_CENTER; - return; + if (!index) { + index = glContext->GetTunerDigitIndex(mouseTracker.getMouseX(), 11, centerDP, centerW); // center + if (index > 0) { + hoverIndex = index; + hoverState = TUNING_HOVER_CENTER; + } } - hoverIndex = 0; - hoverState = TUNING_HOVER_NONE; + if (!index) { + hoverIndex = 0; + hoverState = TUNING_HOVER_NONE; + } else { + switch (hoverState) { + case TUNING_HOVER_FREQ: + setStatusText("Click or drag a digit to change frequency. Hold shift to disable carry."); + break; + case TUNING_HOVER_BW: + setStatusText("Click or drag a digit to change bandwidth. Hold shift to disable carry."); + break; + case TUNING_HOVER_CENTER: + setStatusText("Click or drag a digit to change center frequency. Hold shift to disable carry."); + break; + } + } + + } void TuningCanvas::OnMouseDown(wxMouseEvent& event) { @@ -270,7 +287,7 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) { int hExponent = hoverIndex - 1; - if (hoverState != TUNING_HOVER_NONE && !dragging) { + if (hoverState != TUNING_HOVER_NONE && !dragging && (downState == hoverState) && (downIndex == hoverIndex)) { StepTuner(hoverState, hExponent, top); } From 9b283fbcef14a21874f40bfce2602cb87d2f9d52 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 31 Mar 2015 17:51:56 -0400 Subject: [PATCH 15/19] Fix for following demod frequency --- src/AppFrame.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index fb92aab..925e7a3 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -508,13 +508,13 @@ void AppFrame::OnIdle(wxIdleEvent& event) { } if (wxGetApp().getFrequency() != demodWaterfallCanvas->getCenterFrequency()) { - if (spectrumCanvas->getViewState() && abs(wxGetApp().getFrequency()-spectrumCanvas->getCenterFrequency()) > (wxGetApp().getSampleRate()/2)) { - spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); - waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); - } demodWaterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); demodSpectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); } + if (spectrumCanvas->getViewState() && abs(wxGetApp().getFrequency()-spectrumCanvas->getCenterFrequency()) > (wxGetApp().getSampleRate()/2)) { + spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency()); + waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency()); + } } if (!waterfallCanvas->HasFocus()) { From 72edba4880b13250b78c3c8e8935c0164ad801e1 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Thu, 2 Apr 2015 20:52:33 -0400 Subject: [PATCH 16/19] better color theme values for new frequency tuning bar --- src/visual/ColorTheme.cpp | 39 ++++++++++++++++++++++--------------- src/visual/ColorTheme.h | 3 ++- src/visual/TuningCanvas.cpp | 16 ++++----------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/visual/ColorTheme.cpp b/src/visual/ColorTheme.cpp index 038461f..65b05b5 100644 --- a/src/visual/ColorTheme.cpp +++ b/src/visual/ColorTheme.cpp @@ -48,7 +48,8 @@ DefaultColorTheme::DefaultColorTheme() { fftLine = RGBColor(0.9, 0.9, 0.9); fftHighlight = RGBColor(1, 1, 1); scopeLine = RGBColor(0.9, 0.9, 0.9); - tuningBar = RGBColor(0.2, 0.2, 0.9); + tuningBarLight = RGBColor(0.2, 0.2, 0.9); + tuningBarDark = RGBColor(0.0, 0.0, 0.35); tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(0.1, 0.75, 0.1); @@ -78,9 +79,10 @@ RadarColorTheme::RadarColorTheme() { fftLine = RGBColor(0.8, 1.0, 0.8); fftHighlight = RGBColor(1, 1, 1); scopeLine = RGBColor(0.8, 1.0, 0.8); - tuningBar = RGBColor(0.2, 0.9, 0.2); + tuningBarLight = RGBColor(0.0, 0.45, 0.0); + tuningBarDark = RGBColor(0.0, 0.1, 0.0); tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); + tuningBarDown = RGBColor(148.0/255.0, 0.0, 0.0); meterLevel = RGBColor(0, 0.5, 0); meterValue = RGBColor(0, 0.5, 0); text = RGBColor(0.8, 1.0, 0.8); @@ -106,9 +108,10 @@ BlackAndWhiteColorTheme::BlackAndWhiteColorTheme() { fftLine = RGBColor(0.9, 0.9, 0.9); fftHighlight = RGBColor(1, 1, 0.9); scopeLine = RGBColor(0.9, 0.9, 0.9); - tuningBar = RGBColor(0.4, 0.4, 0.4); - tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); + tuningBarLight = RGBColor(0.4, 0.4, 0.4); + tuningBarDark = RGBColor(0.1, 0.1, 0.1); + tuningBarUp = RGBColor(0.8, 0.8, 0.8); + tuningBarDown = RGBColor(0.4, 0.4, 0.4); meterLevel = RGBColor(0.5, 0.5, 0.5); meterValue = RGBColor(0.5, 0.5, 0.5); text = RGBColor(1, 1, 1); @@ -143,9 +146,10 @@ SharpColorTheme::SharpColorTheme() { fftLine = RGBColor(0.9, 0.9, 1.0); fftHighlight = RGBColor(0.9, 0.9, 1.0); scopeLine = RGBColor(0.85, 0.85, 1.0); - tuningBar = RGBColor(0.2, 0.2, 0.9); - tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); + tuningBarLight = RGBColor(28.0 / 255.0, 106.0 / 255.0, 179.0 / 255.0); + tuningBarDark = RGBColor(14.0 / 255.0, 53.0 / 255.0, 89.5 / 255.0); + tuningBarUp = RGBColor(0.7, 0.7, 0.7); + tuningBarDown = RGBColor(1.0, 0.0, 0.0); meterLevel = RGBColor(28.0 / 255.0, 106.0 / 255.0, 179.0 / 255.0); meterValue = RGBColor(190.0 / 255.0, 190.0 / 255.0, 60.0 / 255.0); text = RGBColor(0.9, 0.9, 1); @@ -173,9 +177,10 @@ RadColorTheme::RadColorTheme() { fftLine = RGBColor(1.0, 0.9, 0.9); fftHighlight = RGBColor(1, 1, 1); scopeLine = RGBColor(1.0, 0.9, 0.9); - tuningBar = RGBColor(0.2, 0.2, 0.9); - tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); + tuningBarLight = RGBColor(0.0, 0.45, 0.0); + tuningBarDark = RGBColor(0.0, 0.1, 0.0); + tuningBarUp = RGBColor(1.0, 0.0, 0.0); + tuningBarDown = RGBColor(0.0, 0.5, 1.0); meterLevel = RGBColor(0, 0.5, 0); meterValue = RGBColor(0.5, 0, 0); text = RGBColor(1, 1, 1); @@ -206,9 +211,10 @@ TouchColorTheme::TouchColorTheme() { fftLine = RGBColor(234.0 / 255.0, 232.0 / 255.0, 247.0 / 255.0); fftHighlight = RGBColor(1.0, 1.0, 1.0); scopeLine = RGBColor(234.0 / 255.0, 232.0 / 255.0, 247.0 / 255.0); - tuningBar = RGBColor(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); - tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); + tuningBarLight = RGBColor(0.2, 0.2, 0.7); + tuningBarDark = RGBColor(0.1, 0.1, 0.45); + tuningBarUp = RGBColor(0.5, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBColor(0.6, 108.0/255.0, 1.0); meterLevel = RGBColor(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); meterValue = RGBColor(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); text = RGBColor(1, 1, 1); @@ -240,7 +246,8 @@ HDColorTheme::HDColorTheme() { fftLine = RGBColor(0.9, 0.9, 0.9); fftHighlight = RGBColor(1, 1, 1); scopeLine = RGBColor(0.9, 0.9, 0.9); - tuningBar = RGBColor(0, 0.7, 0.7); + tuningBarLight = RGBColor(0.4, 0.4, 1.0); + tuningBarDark = RGBColor(0.1, 0.1, 0.45); tuningBarUp = RGBColor(1.0, 139.0/255.0, 96.0/255.0); tuningBarDown = RGBColor(148.0/255.0, 148.0/255.0, 1.0); meterLevel = RGBColor(0, 0.5, 0); diff --git a/src/visual/ColorTheme.h b/src/visual/ColorTheme.h index 7101760..f7d44e0 100644 --- a/src/visual/ColorTheme.h +++ b/src/visual/ColorTheme.h @@ -47,7 +47,8 @@ public: RGBColor fftLine; RGBColor fftHighlight; RGBColor scopeLine; - RGBColor tuningBar; + RGBColor tuningBarLight; + RGBColor tuningBarDark; RGBColor tuningBarUp; RGBColor tuningBarDown; RGBColor meterLevel; diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index 11854fa..b3f950a 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -72,22 +72,14 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { long long center = wxGetApp().getFrequency(); if (mouseTracker.mouseDown()) { - glContext->Draw(ThemeMgr::mgr.currentTheme->tuningBar.r, ThemeMgr::mgr.currentTheme->tuningBar.g, ThemeMgr::mgr.currentTheme->tuningBar.b, - 0.6, mouseTracker.getOriginMouseX(), mouseTracker.getMouseX()); + glContext->Draw(ThemeMgr::mgr.currentTheme->tuningBarDark.r, ThemeMgr::mgr.currentTheme->tuningBarDark.g, ThemeMgr::mgr.currentTheme->tuningBarDark.b, + 0.75, mouseTracker.getOriginMouseX(), mouseTracker.getMouseX()); } RGBColor clr = top ? ThemeMgr::mgr.currentTheme->tuningBarUp : ThemeMgr::mgr.currentTheme->tuningBarDown; - RGBColor clrDark = ThemeMgr::mgr.currentTheme->tuningBar; - RGBColor clrMid = ThemeMgr::mgr.currentTheme->tuningBar; - RGBColor clrLight = ThemeMgr::mgr.currentTheme->tuningBar; - - clrDark.r *= 0.5; - clrDark.g *= 0.5; - clrDark.b *= 0.5; - clrLight.r *= 2.0; - clrLight.g *= 2.0; - clrLight.b *= 2.0; + RGBColor clrDark = ThemeMgr::mgr.currentTheme->tuningBarDark; + RGBColor clrMid = ThemeMgr::mgr.currentTheme->tuningBarLight; glContext->DrawTunerBarIndexed(1, 3, 11, freqDP, freqW, clrMid, 0.25, true, true); // freq glContext->DrawTunerBarIndexed(4, 6, 11, freqDP, freqW, clrDark, 0.25, true, true); From 77c50558ca66affa57393b50f97b14cbf33614bf Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Thu, 2 Apr 2015 20:58:02 -0400 Subject: [PATCH 17/19] remove commented code --- src/visual/TuningContext.cpp | 51 ------------------------------------ 1 file changed, 51 deletions(-) diff --git a/src/visual/TuningContext.cpp b/src/visual/TuningContext.cpp index d5c0115..9a4dd4c 100644 --- a/src/visual/TuningContext.cpp +++ b/src/visual/TuningContext.cpp @@ -168,56 +168,5 @@ void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long c 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); - - /* - PrimaryGLContext::GLFontSize fontSize = GLFONT_SIZE16; - - int fontHeight = 16; - - if (viewWidth < 400) { - fontSize = GLFONT_SIZE12; - fontHeight = 12; - } - - glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b); - - getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); - if (freq) { - freqStr.str(""); - freqStr << std::fixed << freq << " Hz"; - } else { - freqStr.str("---"); - } - getFont(fontSize).drawString(freqStr.str(), -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); - - - getFont(fontSize).drawString("BW: ", -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); - if (bw) { - freqStr.str(""); - freqStr << std::fixed << bw << " Hz"; - } else { - freqStr.str("---"); - } - getFont(fontSize).drawString(freqStr.str(), -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); - - - getFont(fontSize).drawString("CTR: ", 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER); - if (center) { - freqStr.str(""); - freqStr << std::fixed << center << " Hz"; - } else { - freqStr.str("---"); - } - getFont(fontSize).drawString(freqStr.str(), 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER); - - - glColor3f(0.65, 0.65, 0.65); - glBegin(GL_LINES); - glVertex2f(-0.275, -1.0); - glVertex2f(-0.275, 1.0); - glVertex2f(0.275, -1.0); - glVertex2f(0.275, 1.0); - glEnd(); - */ } From 6ee745a517656c1f173202eae8be03479c6a9284 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Thu, 2 Apr 2015 20:58:57 -0400 Subject: [PATCH 18/19] version bump --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb3c5b5..2eb316e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.8) SET(CUBICSDR_VERSION_MAJOR "0") SET(CUBICSDR_VERSION_MINOR "1") -SET(CUBICSDR_VERSION_PATCH "1") +SET(CUBICSDR_VERSION_PATCH "2") SET(CUBICSDR_VERSION_REL "beta") SET(CUBICSDR_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}-${CUBICSDR_VERSION_REL}") From 1284a163110b35e25eaf9eec26ac3bf11c0b4865 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Thu, 2 Apr 2015 21:04:00 -0400 Subject: [PATCH 19/19] title missing version prefix --- src/CubicSDRDefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CubicSDRDefs.h b/src/CubicSDRDefs.h index df6d892..e06a4f3 100644 --- a/src/CubicSDRDefs.h +++ b/src/CubicSDRDefs.h @@ -1,6 +1,6 @@ #pragma once -#define CUBICSDR_TITLE "CubicSDR " CUBICSDR_VERSION " by Charles J. Cliffe (@ccliffe) :: www.cubicsdr.com" +#define CUBICSDR_TITLE "CubicSDR v" CUBICSDR_VERSION " by Charles J. Cliffe (@ccliffe) :: www.cubicsdr.com" #ifndef __BYTE_ORDER #ifdef _WIN32