From 62858abbf582160d422f35b8c40c2e7d15548a73 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 17 Aug 2015 21:52:38 -0400 Subject: [PATCH 1/3] Spectrum peak and floor dB are now displayed --- src/AppFrame.cpp | 1 + src/panel/SpectrumPanel.cpp | 59 ++++- src/panel/SpectrumPanel.h | 11 +- src/panel/WaterfallPanel.cpp | 2 +- src/process/SpectrumVisualProcessor.cpp | 5 +- src/ui/GLPanel.cpp | 97 ++++---- src/ui/GLPanel.h | 15 +- src/ui/UITestContext.cpp | 12 +- src/visual/ColorTheme.cpp | 280 ++++++++++++------------ src/visual/ColorTheme.h | 61 +++--- src/visual/PrimaryGLContext.cpp | 8 +- src/visual/PrimaryGLContext.h | 8 +- src/visual/SpectrumCanvas.cpp | 9 + src/visual/SpectrumCanvas.h | 2 + src/visual/TuningCanvas.cpp | 8 +- src/visual/TuningContext.cpp | 4 +- src/visual/TuningContext.h | 4 +- 17 files changed, 336 insertions(+), 250 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index adafee8..9091e36 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -128,6 +128,7 @@ AppFrame::AppFrame() : wxBoxSizer *spectrumSizer = new wxBoxSizer(wxHORIZONTAL); wxGetApp().getSpectrumProcessor()->setup(2048); spectrumCanvas = new SpectrumCanvas(this, attribList); + spectrumCanvas->setShowDb(true); wxGetApp().getSpectrumProcessor()->attachOutput(spectrumCanvas->getVisualDataQueue()); spectrumAvgMeter = new MeterCanvas(this, attribList); diff --git a/src/panel/SpectrumPanel.cpp b/src/panel/SpectrumPanel.cpp index 81f62f6..c615490 100644 --- a/src/panel/SpectrumPanel.cpp +++ b/src/panel/SpectrumPanel.cpp @@ -2,15 +2,24 @@ #include #include +#include #include "ColorTheme.h" -SpectrumPanel::SpectrumPanel() : floorValue(0), ceilValue(1) { +SpectrumPanel::SpectrumPanel() : floorValue(0), ceilValue(1), showDb(false) { setFill(GLPANEL_FILL_GRAD_Y); setFillColor(ThemeMgr::mgr.currentTheme->fftBackground * 2.0, ThemeMgr::mgr.currentTheme->fftBackground); + + dbPanelCeil.setMarginPx(0); + dbPanelCeil.setFill(GLPanel::GLPANEL_FILL_GRAD_X); + dbPanelCeil.setFillColor(RGBA4f(0.2,0.2,0.2,5.0), RGBA4f(0.2,0.2,0.2,0.0)); + + dbPanelFloor.setMarginPx(0); + dbPanelFloor.setFill(GLPanel::GLPANEL_FILL_GRAD_X); + dbPanelFloor.setFillColor(RGBA4f(0.2,0.2,0.2,5.), RGBA4f(0.2,0.2,0.2,0.0)); } -float SpectrumPanel::getFloorValue() const { +float SpectrumPanel::getFloorValue() { return floorValue; } @@ -18,7 +27,7 @@ void SpectrumPanel::setFloorValue(float floorValue) { this->floorValue = floorValue; } -float SpectrumPanel::getCeilValue() const { +float SpectrumPanel::getCeilValue() { return ceilValue; } @@ -42,6 +51,23 @@ long long SpectrumPanel::getBandwidth() { return bandwidth; } +void SpectrumPanel::setShowDb(bool showDb) { + this->showDb = showDb; + if (showDb) { + addChild(&dbPanelCeil); + addChild(&dbPanelFloor); + } else { + removeChild(&dbPanelCeil); + removeChild(&dbPanelFloor); + } + +} + +bool SpectrumPanel::getShowDb() { + return showDb; +} + + void SpectrumPanel::setPoints(std::vector &points) { this->points.assign(points.begin(), points.end()); } @@ -95,14 +121,14 @@ void SpectrumPanel::drawPanelContents() { glDrawArrays(GL_LINE_STRIP, 0, points.size() / 2); glDisableClientState(GL_VERTEX_ARRAY); } - - glLoadMatrixf(transform); - + GLint vp[4]; glGetIntegerv( GL_VIEWPORT, vp); float viewHeight = (float) vp[3]; float viewWidth = (float) vp[2]; + glLoadMatrixf(transform); + long long leftFreq = (double) freq - ((double) bandwidth / 2.0); long long rightFreq = leftFreq + (double) bandwidth; @@ -162,4 +188,25 @@ void SpectrumPanel::drawPanelContents() { } glLineWidth(1.0); + + + if (showDb) { + float dbPanelWidth = (1.0/viewWidth)*75.0; + float dbPanelHeight = (1.0/viewHeight)*14.0; + + + std::stringstream ssLabel; + ssLabel << std::fixed << std::setprecision(1) << (20.0 * log10(2.0*(getCeilValue())/2048.0)) << "dB"; + + dbPanelCeil.setText(ssLabel.str(), GLFont::GLFONT_ALIGN_RIGHT); + dbPanelCeil.setSize(dbPanelWidth, dbPanelHeight); + dbPanelCeil.setPosition(-1.0 + dbPanelWidth, 1.0 - dbPanelHeight); + + ssLabel.str(""); + ssLabel << (20.0 * log10(2.0*(getFloorValue())/2048.0)) << "dB"; + + dbPanelFloor.setText(ssLabel.str(), GLFont::GLFONT_ALIGN_RIGHT); + dbPanelFloor.setSize(dbPanelWidth, dbPanelHeight); + dbPanelFloor.setPosition(-1.0 + dbPanelWidth, - 1.0 + dbPanelHeight); + } } diff --git a/src/panel/SpectrumPanel.h b/src/panel/SpectrumPanel.h index af2d2f7..6ffa3f8 100644 --- a/src/panel/SpectrumPanel.h +++ b/src/panel/SpectrumPanel.h @@ -8,10 +8,10 @@ public: void setPoints(std::vector &points); - float getFloorValue() const; + float getFloorValue(); void setFloorValue(float floorValue); - float getCeilValue() const; + float getCeilValue(); void setCeilValue(float ceilValue); void setFreq(long long freq); @@ -20,6 +20,9 @@ public: void setBandwidth(long long bandwidth); long long getBandwidth(); + void setShowDb(bool showDb); + bool getShowDb(); + protected: void drawPanelContents(); @@ -28,4 +31,8 @@ private: long long freq; long long bandwidth; std::vector points; + + GLTextPanel dbPanelCeil; + GLTextPanel dbPanelFloor; + bool showDb; }; \ No newline at end of file diff --git a/src/panel/WaterfallPanel.cpp b/src/panel/WaterfallPanel.cpp index d3b0224..5de721a 100644 --- a/src/panel/WaterfallPanel.cpp +++ b/src/panel/WaterfallPanel.cpp @@ -1,7 +1,7 @@ #include "WaterfallPanel.h" WaterfallPanel::WaterfallPanel() : GLPanel(), fft_size(0), waterfall_lines(0), waterfall_slice(NULL), activeTheme(NULL) { - setFillColor(RGB3f(0,0,0)); + setFillColor(RGBA4f(0,0,0)); for (int i = 0; i < 2; i++) { waterfall[i] = 0; } diff --git a/src/process/SpectrumVisualProcessor.cpp b/src/process/SpectrumVisualProcessor.cpp index 06c65c2..baa9099 100644 --- a/src/process/SpectrumVisualProcessor.cpp +++ b/src/process/SpectrumVisualProcessor.cpp @@ -283,9 +283,6 @@ void SpectrumVisualProcessor::process() { } } - fft_ceil += 0.25; - fft_floor -= 1; - fft_ceil_ma = fft_ceil_ma + (fft_ceil - fft_ceil_ma) * 0.05; fft_ceil_maa = fft_ceil_maa + (fft_ceil_ma - fft_ceil_maa) * 0.05; @@ -293,7 +290,7 @@ void SpectrumVisualProcessor::process() { fft_floor_maa = fft_floor_maa + (fft_floor_ma - fft_floor_maa) * 0.05; for (int i = 0, iMax = fftSize; i < iMax; i++) { - float v = (log10(fft_result_maa[i] - fft_floor_maa) / log10(fft_ceil_maa - fft_floor_maa)); + float v = (log10(fft_result_maa[i]+0.25 - (fft_floor_maa-1.0)) / log10((fft_ceil_maa+0.25) - (fft_floor_maa-1.0))); output->spectrum_points[i * 2] = ((float) i / (float) iMax); output->spectrum_points[i * 2 + 1] = v; } diff --git a/src/ui/GLPanel.cpp b/src/ui/GLPanel.cpp index c7e2bca..b10a642 100644 --- a/src/ui/GLPanel.cpp +++ b/src/ui/GLPanel.cpp @@ -9,9 +9,9 @@ GLPanel::GLPanel() : fillType(GLPANEL_FILL_SOLID), contentsVisible(true), transf pos[1] = 0.0f; size[0] = 1.0f; size[1] = 1.0f; - fill[0] = RGB3f(0.5,0.5,0.5); - fill[1] = RGB3f(0.1,0.1,0.1); - borderColor = RGB3f(0.8, 0.8, 0.8); + fill[0] = RGBA4f(0.5,0.5,0.5); + fill[1] = RGBA4f(0.1,0.1,0.1); + borderColor = RGBA4f(0.8, 0.8, 0.8); setCoordinateSystem(GLPANEL_Y_UP); setMarginPx(0); setBorderPx(0); @@ -23,8 +23,8 @@ void GLPanel::genArrays() { if (fillType == GLPANEL_FILL_SOLID || fillType == GLPANEL_FILL_GRAD_X || fillType == GLPANEL_FILL_GRAD_Y) { glPoints.reserve(2 * 4); glPoints.resize(2 * 4); - glColors.reserve(3 * 4); - glColors.resize(3 * 4); + glColors.reserve(4 * 4); + glColors.resize(4 * 4); float pts[2 * 4] = { min, min, @@ -33,7 +33,7 @@ void GLPanel::genArrays() { max, min }; - RGB3f c[4]; + RGBA4f c[4]; if (fillType == GLPANEL_FILL_SOLID) { c[0] = c[1] = c[2] = c[3] = fill[0]; @@ -45,22 +45,22 @@ void GLPanel::genArrays() { c[1] = c[2] = fill[1]; } - float clr[3 * 4] = { - c[0].r, c[0].g, c[0].b, - c[1].r, c[1].g, c[1].b, - c[2].r, c[2].g, c[2].b, - c[3].r, c[3].g, c[3].b - }; + float clr[4 * 4] = { + c[0].r, c[0].g, c[0].b, c[0].a, + c[1].r, c[1].g, c[1].b, c[1].a, + c[2].r, c[2].g, c[2].b, c[2].a, + c[3].r, c[3].g, c[3].b, c[3].a + }; glPoints.assign(pts, pts + (2 * 4)); - glColors.assign(clr, clr + (3 * 4)); + glColors.assign(clr, clr + (4 * 4)); } else { glPoints.reserve(2 * 8); glPoints.resize(2 * 8); - glColors.reserve(3 * 8); - glColors.resize(3 * 8); + glColors.reserve(4 * 8); + glColors.resize(4 * 8); - RGB3f c[8]; + RGBA4f c[8]; if (fillType == GLPANEL_FILL_GRAD_BAR_X) { float pts[2 * 8] = { @@ -103,18 +103,18 @@ void GLPanel::genArrays() { c[5] = c[6] = fill[0]; } - float clr[3 * 8] = { - c[0].r, c[0].g, c[0].b, - c[1].r, c[1].g, c[1].b, - c[2].r, c[2].g, c[2].b, - c[3].r, c[3].g, c[3].b, - c[4].r, c[4].g, c[4].b, - c[5].r, c[5].g, c[5].b, - c[6].r, c[6].g, c[6].b, - c[7].r, c[7].g, c[7].b + float clr[4 * 8] = { + c[0].r, c[0].g, c[0].b, c[0].a, + c[1].r, c[1].g, c[1].b, c[1].a, + c[2].r, c[2].g, c[2].b, c[2].a, + c[3].r, c[3].g, c[3].b, c[3].a, + c[4].r, c[4].g, c[4].b, c[4].a, + c[5].r, c[5].g, c[5].b, c[5].a, + c[6].r, c[6].g, c[6].b, c[6].a, + c[7].r, c[7].g, c[7].b, c[7].a }; - glColors.assign(clr, clr + (3 * 8)); + glColors.assign(clr, clr + (4 * 8)); } } @@ -175,12 +175,12 @@ void GLPanel::setFill(GLPanelFillType fill_mode) { genArrays(); } -void GLPanel::setFillColor(RGB3f color1) { +void GLPanel::setFillColor(RGBA4f color1) { fill[0] = color1; genArrays(); } -void GLPanel::setFillColor(RGB3f color1, RGB3f color2) { +void GLPanel::setFillColor(RGBA4f color1, RGBA4f color2) { fill[0] = color1; fill[1] = color2; genArrays(); @@ -191,7 +191,7 @@ void GLPanel::setMarginPx(float marg) { } -void GLPanel::setBorderColor(RGB3f clr) { +void GLPanel::setBorderColor(RGBA4f clr) { borderColor = clr; } @@ -207,7 +207,19 @@ void GLPanel::setBorderPx(float bordl, float bordr, float bordt, float bordb) { } void GLPanel::addChild(GLPanel *childPanel) { - children.push_back(childPanel); + std::vector::iterator i = std::find(children.begin(), children.end(), childPanel); + + if (i == children.end()) { + children.push_back(childPanel); + } +} + +void GLPanel::removeChild(GLPanel *childPanel) { + std::vector::iterator i = std::find(children.begin(), children.end(), childPanel); + + if (i != children.end()) { + children.erase(i); + } } void GLPanel::drawChildren() { @@ -265,10 +277,12 @@ void GLPanel::draw() { glLoadMatrixf(transform); if (fillType != GLPANEL_FILL_NONE) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glVertexPointer(2, GL_FLOAT, 0, &glPoints[0]); - glColorPointer(3, GL_FLOAT, 0, &glColors[0]); + glColorPointer(4, GL_FLOAT, 0, &glColors[0]); glDrawArrays(GL_QUADS, 0, glPoints.size() / 2); @@ -277,7 +291,7 @@ void GLPanel::draw() { if (borderPx.left || borderPx.right || borderPx.top || borderPx.bottom) { glEnable(GL_LINE_SMOOTH); - glColor3f(borderColor.r, borderColor.g, borderColor.b); + glColor4f(borderColor.r, borderColor.g, borderColor.b, borderColor.a); if (borderPx.left) { glLineWidth(borderPx.left); @@ -313,6 +327,7 @@ void GLPanel::draw() { glDisable(GL_LINE_SMOOTH); } + glDisable(GL_BLEND); } if (contentsVisible) { @@ -337,6 +352,8 @@ void GLPanel::draw() { GLTextPanel::GLTextPanel() : GLPanel() { coord = GLPANEL_Y_UP; + horizAlign = GLFont::GLFONT_ALIGN_CENTER; + vertAlign = GLFont::GLFONT_ALIGN_CENTER; } void GLTextPanel::drawPanelContents() { @@ -346,19 +363,19 @@ void GLTextPanel::drawPanelContents() { float size; - if (pdim.y < 16) { + if (pdim.y <= 16) { sz = GLFont::GLFONT_SIZE12; size = 12; - } else if (pdim.y < 18) { + } else if (pdim.y <= 18) { sz = GLFont::GLFONT_SIZE16; size = 16; - } else if(pdim.y < 24) { + } else if(pdim.y <= 24) { sz = GLFont::GLFONT_SIZE18; size = 18; - } else if(pdim.y < 32) { + } else if(pdim.y <= 32) { sz = GLFont::GLFONT_SIZE24; size = 24; - } else if(pdim.y < 48) { + } else if(pdim.y <= 48) { sz = GLFont::GLFONT_SIZE32; size = 32; } else { @@ -367,11 +384,13 @@ void GLTextPanel::drawPanelContents() { } - GLFont::getFont(sz).drawString(textVal, mid, mid, size, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, (int)pdim.x, (int)pdim.y); + GLFont::getFont(sz).drawString(textVal, mid, mid, size, horizAlign, vertAlign, (int)pdim.x, (int)pdim.y); } -void GLTextPanel::setText(std::string text) { +void GLTextPanel::setText(std::string text, GLFont::Align hAlign, GLFont::Align vAlign) { textVal = text; + horizAlign = hAlign; + vertAlign = vAlign; } std::string GLTextPanel::getText() { diff --git a/src/ui/GLPanel.h b/src/ui/GLPanel.h index db16fe2..b87bac2 100644 --- a/src/ui/GLPanel.h +++ b/src/ui/GLPanel.h @@ -42,8 +42,8 @@ public: GLPanelCoordinateSystem coord; float marginPx; GLPanelEdges borderPx; - RGB3f fill[2]; - RGB3f borderColor; + RGBA4f fill[2]; + RGBA4f borderColor; bool contentsVisible; CubicVR::mat4 transform; CubicVR::mat4 localTransform; @@ -68,15 +68,16 @@ public: void setCoordinateSystem(GLPanelCoordinateSystem coord); void setFill(GLPanelFillType fill_mode); - void setFillColor(RGB3f color1); - void setFillColor(RGB3f color1, RGB3f color2); + void setFillColor(RGBA4f color1); + void setFillColor(RGBA4f color1, RGBA4f color2); void setMarginPx(float marg); - void setBorderColor(RGB3f clr); + void setBorderColor(RGBA4f clr); void setBorderPx(float bord); void setBorderPx(float bordl, float bordr, float bordt, float bordb); void addChild(GLPanel *childPanel); + void removeChild(GLPanel *childPanel); void drawChildren(); virtual void drawPanelContents(); @@ -88,11 +89,13 @@ public: class GLTextPanel : public GLPanel { private: std::string textVal; + GLFont::Align horizAlign; + GLFont::Align vertAlign; public: GLTextPanel(); void drawPanelContents(); - void setText(std::string text); + void setText(std::string text, GLFont::Align hAlign = GLFont::GLFONT_ALIGN_CENTER, GLFont::Align vAlign = GLFont::GLFONT_ALIGN_CENTER); std::string getText(); }; diff --git a/src/ui/UITestContext.cpp b/src/ui/UITestContext.cpp index ec2722d..bb91cdc 100644 --- a/src/ui/UITestContext.cpp +++ b/src/ui/UITestContext.cpp @@ -9,30 +9,30 @@ PrimaryGLContext(canvas, sharedContext) { testPanel.setSize(1.0, 1.0); testPanel.setMarginPx(10); testPanel.setFill(GLPanel::GLPANEL_FILL_GRAD_BAR_Y); - testPanel.setFillColor(RGB3f(0.0,0.0,1.0), RGB3f(0.0,1.0,0.0)); + testPanel.setFillColor(RGBA4f(0.0,0.0,1.0), RGBA4f(0.0,1.0,0.0)); testChildPanel.setPosition(0.0, 0.0); testChildPanel.setMarginPx(5); testChildPanel.setSize(1.0, 0.33); testChildPanel.setCoordinateSystem(GLPanel::GLPANEL_Y_DOWN_ZERO_ONE); testChildPanel.setFill(GLPanel::GLPANEL_FILL_GRAD_BAR_X); - testChildPanel.setFillColor(RGB3f(0.0,0.0,1.0), RGB3f(0.0,1.0,0.0)); + testChildPanel.setFillColor(RGBA4f(0.0,0.0,1.0), RGBA4f(0.0,1.0,0.0)); testChildPanel.setBorderPx(1); testChildPanel2.setPosition(0.0, -0.66); testChildPanel2.setSize(1.0, 0.33); testChildPanel2.setMarginPx(5); testChildPanel2.setFill(GLPanel::GLPANEL_FILL_GRAD_X); - testChildPanel2.setFillColor(RGB3f(0.0,0.0,1.0), RGB3f(0.0,1.0,0.0)); - testChildPanel2.setBorderColor(RGB3f(1.0,0.0,0.0)); + testChildPanel2.setFillColor(RGBA4f(0.0,0.0,1.0), RGBA4f(0.0,1.0,0.0)); + testChildPanel2.setBorderColor(RGBA4f(1.0,0.0,0.0)); testChildPanel2.setBorderPx(1); testChildPanel3.setPosition(0.0, 0.66); testChildPanel3.setSize(1.0, 0.33); testChildPanel3.setMarginPx(5); testChildPanel3.setFill(GLPanel::GLPANEL_FILL_GRAD_X); - testChildPanel3.setFillColor(RGB3f(0.0,0.0,1.0), RGB3f(0.0,1.0,0.0)); - testChildPanel3.setBorderColor(RGB3f(1.0,0.0,0.0)); + testChildPanel3.setFillColor(RGBA4f(0.0,0.0,1.0), RGBA4f(0.0,1.0,0.0)); + testChildPanel3.setBorderColor(RGBA4f(1.0,0.0,0.0)); testChildPanel3.setBorderPx(1); testText1.setText("Testing 123.."); diff --git a/src/visual/ColorTheme.cpp b/src/visual/ColorTheme.cpp index 7c0b5ef..3590c83 100644 --- a/src/visual/ColorTheme.cpp +++ b/src/visual/ColorTheme.cpp @@ -41,27 +41,27 @@ DefaultColorTheme::DefaultColorTheme() { waterfallGradient.addColor(GradientColor(1.0, 1.0, 0)); waterfallGradient.addColor(GradientColor(1.0, 0.2, 0.0)); waterfallGradient.generate(256); - waterfallHighlight = RGB3f(1, 1, 1); - waterfallNew = RGB3f(0, 1, 0); - waterfallHover = RGB3f(1, 1, 0); - waterfallDestroy = RGB3f(1, 0, 0); - fftLine = RGB3f(0.9, 0.9, 0.9); - fftHighlight = RGB3f(1, 1, 1); - scopeLine = RGB3f(0.9, 0.9, 0.9); - tuningBarLight = RGB3f(0.2, 0.2, 0.9); - tuningBarDark = RGB3f(0.0, 0.0, 0.35); - tuningBarUp = RGB3f(1.0, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGB3f(148.0/255.0, 148.0/255.0, 1.0); - meterLevel = RGB3f(0.1, 0.75, 0.1); - meterValue = RGB3f(0.75, 0.1, 0.1); - text = RGB3f(1, 1, 1); - freqLine = RGB3f(1, 1, 1); - button = RGB3f(0.65, 0.65, 0.65); - buttonHighlight = RGB3f(1, 1, 0); + waterfallHighlight = RGBA4f(1, 1, 1); + waterfallNew = RGBA4f(0, 1, 0); + waterfallHover = RGBA4f(1, 1, 0); + waterfallDestroy = RGBA4f(1, 0, 0); + fftLine = RGBA4f(0.9, 0.9, 0.9); + fftHighlight = RGBA4f(1, 1, 1); + scopeLine = RGBA4f(0.9, 0.9, 0.9); + tuningBarLight = RGBA4f(0.2, 0.2, 0.9); + tuningBarDark = RGBA4f(0.0, 0.0, 0.35); + tuningBarUp = RGBA4f(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBA4f(148.0/255.0, 148.0/255.0, 1.0); + meterLevel = RGBA4f(0.1, 0.75, 0.1); + meterValue = RGBA4f(0.75, 0.1, 0.1); + text = RGBA4f(1, 1, 1); + freqLine = RGBA4f(1, 1, 1); + button = RGBA4f(0.65, 0.65, 0.65); + buttonHighlight = RGBA4f(1, 1, 0); - scopeBackground = RGB3f(0.1, 0.1, 0.1); - fftBackground = RGB3f(0.1, 0.1, 0.1); - generalBackground = RGB3f(0.1, 0.1, 0.1); + scopeBackground = RGBA4f(0.1, 0.1, 0.1); + fftBackground = RGBA4f(0.1, 0.1, 0.1); + generalBackground = RGBA4f(0.1, 0.1, 0.1); } @@ -72,27 +72,27 @@ RadarColorTheme::RadarColorTheme() { waterfallGradient.addColor(GradientColor(40.0 / 255.0, 240.0 / 255.0, 60.0 / 255.0)); waterfallGradient.addColor(GradientColor(250.0 / 255.0, 250.0 / 255.0, 250.0 / 255.0)); waterfallGradient.generate(256); - waterfallHighlight = RGB3f(1, 1, 1); - waterfallNew = RGB3f(0, 1, 0); - waterfallHover = RGB3f(1, 1, 0); - waterfallDestroy = RGB3f(1, 0, 0); - fftLine = RGB3f(0.8, 1.0, 0.8); - fftHighlight = RGB3f(1, 1, 1); - scopeLine = RGB3f(0.8, 1.0, 0.8); - tuningBarLight = RGB3f(0.0, 0.45, 0.0); - tuningBarDark = RGB3f(0.0, 0.1, 0.0); - tuningBarUp = RGB3f(1.0, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGB3f(148.0/255.0, 0.0, 0.0); - meterLevel = RGB3f(0, 0.5, 0); - meterValue = RGB3f(0, 0.5, 0); - text = RGB3f(0.8, 1.0, 0.8); - freqLine = RGB3f(1, 1, 1); - button = RGB3f(0.65, 0.75, 0.65); - buttonHighlight = RGB3f(0.65, 1.0, 0.65); + waterfallHighlight = RGBA4f(1, 1, 1); + waterfallNew = RGBA4f(0, 1, 0); + waterfallHover = RGBA4f(1, 1, 0); + waterfallDestroy = RGBA4f(1, 0, 0); + fftLine = RGBA4f(0.8, 1.0, 0.8); + fftHighlight = RGBA4f(1, 1, 1); + scopeLine = RGBA4f(0.8, 1.0, 0.8); + tuningBarLight = RGBA4f(0.0, 0.45, 0.0); + tuningBarDark = RGBA4f(0.0, 0.1, 0.0); + tuningBarUp = RGBA4f(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBA4f(148.0/255.0, 0.0, 0.0); + meterLevel = RGBA4f(0, 0.5, 0); + meterValue = RGBA4f(0, 0.5, 0); + text = RGBA4f(0.8, 1.0, 0.8); + freqLine = RGBA4f(1, 1, 1); + button = RGBA4f(0.65, 0.75, 0.65); + buttonHighlight = RGBA4f(0.65, 1.0, 0.65); - scopeBackground = RGB3f(0.05, 0.1, 0.05); - fftBackground = RGB3f(0.05, 0.1, 0.05); - generalBackground = RGB3f(0.05, 0.1, 0.05); + scopeBackground = RGBA4f(0.05, 0.1, 0.05); + fftBackground = RGBA4f(0.05, 0.1, 0.05); + generalBackground = RGBA4f(0.05, 0.1, 0.05); } BlackAndWhiteColorTheme::BlackAndWhiteColorTheme() { @@ -101,27 +101,27 @@ BlackAndWhiteColorTheme::BlackAndWhiteColorTheme() { waterfallGradient.addColor(GradientColor(0.75, 0.75, 0.75)); waterfallGradient.addColor(GradientColor(1.0, 1.0, 1.0)); waterfallGradient.generate(256); - waterfallHighlight = RGB3f(1, 1, 0.9); - waterfallNew = RGB3f(0, 1, 0); - waterfallHover = RGB3f(1, 1, 0); - waterfallDestroy = RGB3f(1, 0, 0); - fftLine = RGB3f(0.9, 0.9, 0.9); - fftHighlight = RGB3f(1, 1, 0.9); - scopeLine = RGB3f(0.9, 0.9, 0.9); - tuningBarLight = RGB3f(0.4, 0.4, 0.4); - tuningBarDark = RGB3f(0.1, 0.1, 0.1); - tuningBarUp = RGB3f(0.8, 0.8, 0.8); - tuningBarDown = RGB3f(0.4, 0.4, 0.4); - meterLevel = RGB3f(0.5, 0.5, 0.5); - meterValue = RGB3f(0.5, 0.5, 0.5); - text = RGB3f(1, 1, 1); - freqLine = RGB3f(1, 1, 1); - button = RGB3f(0.65, 0.65, 0.65); - buttonHighlight = RGB3f(1, 1, 1); + waterfallHighlight = RGBA4f(1, 1, 0.9); + waterfallNew = RGBA4f(0, 1, 0); + waterfallHover = RGBA4f(1, 1, 0); + waterfallDestroy = RGBA4f(1, 0, 0); + fftLine = RGBA4f(0.9, 0.9, 0.9); + fftHighlight = RGBA4f(1, 1, 0.9); + scopeLine = RGBA4f(0.9, 0.9, 0.9); + tuningBarLight = RGBA4f(0.4, 0.4, 0.4); + tuningBarDark = RGBA4f(0.1, 0.1, 0.1); + tuningBarUp = RGBA4f(0.8, 0.8, 0.8); + tuningBarDown = RGBA4f(0.4, 0.4, 0.4); + meterLevel = RGBA4f(0.5, 0.5, 0.5); + meterValue = RGBA4f(0.5, 0.5, 0.5); + text = RGBA4f(1, 1, 1); + freqLine = RGBA4f(1, 1, 1); + button = RGBA4f(0.65, 0.65, 0.65); + buttonHighlight = RGBA4f(1, 1, 1); - scopeBackground = RGB3f(0.1, 0.1, 0.1); - fftBackground = RGB3f(0.1, 0.1, 0.1); - generalBackground = RGB3f(0.1, 0.1, 0.1); + scopeBackground = RGBA4f(0.1, 0.1, 0.1); + fftBackground = RGBA4f(0.1, 0.1, 0.1); + generalBackground = RGBA4f(0.1, 0.1, 0.1); } @@ -139,27 +139,27 @@ SharpColorTheme::SharpColorTheme() { waterfallGradient.addColor(GradientColor(1.0, 0.25, 0.0)); waterfallGradient.addColor(GradientColor(0.5, 0.1, 0.0)); waterfallGradient.generate(256); - waterfallHighlight = RGB3f(0.9, 0.9, 1.0); - waterfallNew = RGB3f(0, 1, 0); - waterfallHover = RGB3f(1, 1, 0); - waterfallDestroy = RGB3f(1, 0, 0); - fftLine = RGB3f(0.9, 0.9, 1.0); - fftHighlight = RGB3f(0.9, 0.9, 1.0); - scopeLine = RGB3f(0.85, 0.85, 1.0); - tuningBarLight = RGB3f(28.0 / 255.0, 106.0 / 255.0, 179.0 / 255.0); - tuningBarDark = RGB3f(14.0 / 255.0, 53.0 / 255.0, 89.5 / 255.0); - tuningBarUp = RGB3f(0.7, 0.7, 0.7); - tuningBarDown = RGB3f(1.0, 0.0, 0.0); - meterLevel = RGB3f(28.0 / 255.0, 106.0 / 255.0, 179.0 / 255.0); - meterValue = RGB3f(190.0 / 255.0, 190.0 / 255.0, 60.0 / 255.0); - text = RGB3f(0.9, 0.9, 1); - freqLine = RGB3f(0.85, 0.85, 1.0); - button = RGB3f(217.0 / 255.0, 218.0 / 255.0, 228.0 / 255.0); - buttonHighlight = RGB3f(208.0 / 255.0, 249.0 / 255.0, 255.0 / 255.0); + waterfallHighlight = RGBA4f(0.9, 0.9, 1.0); + waterfallNew = RGBA4f(0, 1, 0); + waterfallHover = RGBA4f(1, 1, 0); + waterfallDestroy = RGBA4f(1, 0, 0); + fftLine = RGBA4f(0.9, 0.9, 1.0); + fftHighlight = RGBA4f(0.9, 0.9, 1.0); + scopeLine = RGBA4f(0.85, 0.85, 1.0); + tuningBarLight = RGBA4f(28.0 / 255.0, 106.0 / 255.0, 179.0 / 255.0); + tuningBarDark = RGBA4f(14.0 / 255.0, 53.0 / 255.0, 89.5 / 255.0); + tuningBarUp = RGBA4f(0.7, 0.7, 0.7); + tuningBarDown = RGBA4f(1.0, 0.0, 0.0); + meterLevel = RGBA4f(28.0 / 255.0, 106.0 / 255.0, 179.0 / 255.0); + meterValue = RGBA4f(190.0 / 255.0, 190.0 / 255.0, 60.0 / 255.0); + text = RGBA4f(0.9, 0.9, 1); + freqLine = RGBA4f(0.85, 0.85, 1.0); + button = RGBA4f(217.0 / 255.0, 218.0 / 255.0, 228.0 / 255.0); + buttonHighlight = RGBA4f(208.0 / 255.0, 249.0 / 255.0, 255.0 / 255.0); - scopeBackground = RGB3f(0.05, 0.05, 0.15); - fftBackground = RGB3f(0.05, 0.05, 0.15); - generalBackground = RGB3f(0.05, 0.05, 0.15); + scopeBackground = RGBA4f(0.05, 0.05, 0.15); + fftBackground = RGBA4f(0.05, 0.05, 0.15); + generalBackground = RGBA4f(0.05, 0.05, 0.15); } RadColorTheme::RadColorTheme() { @@ -170,27 +170,27 @@ RadColorTheme::RadColorTheme() { waterfallGradient.addColor(GradientColor(1.0, 40.0 / 255.0, 40.0 / 255.0)); waterfallGradient.addColor(GradientColor(1.0, 1.0, 1.0)); waterfallGradient.generate(256); - waterfallHighlight = RGB3f(1, 1, 1); - waterfallNew = RGB3f(0, 1, 0); - waterfallHover = RGB3f(1, 1, 0); - waterfallDestroy = RGB3f(1, 0, 0); - fftLine = RGB3f(1.0, 0.9, 0.9); - fftHighlight = RGB3f(1, 1, 1); - scopeLine = RGB3f(1.0, 0.9, 0.9); - tuningBarLight = RGB3f(0.0, 0.45, 0.0); - tuningBarDark = RGB3f(0.0, 0.1, 0.0); - tuningBarUp = RGB3f(1.0, 0.0, 0.0); - tuningBarDown = RGB3f(0.0, 0.5, 1.0); - meterLevel = RGB3f(0, 0.5, 0); - meterValue = RGB3f(0.5, 0, 0); - text = RGB3f(1, 1, 1); - freqLine = RGB3f(1, 1, 1); - button = RGB3f(0.65, 0.65, 0.65); - buttonHighlight = RGB3f(0.76, 0.65, 0); + waterfallHighlight = RGBA4f(1, 1, 1); + waterfallNew = RGBA4f(0, 1, 0); + waterfallHover = RGBA4f(1, 1, 0); + waterfallDestroy = RGBA4f(1, 0, 0); + fftLine = RGBA4f(1.0, 0.9, 0.9); + fftHighlight = RGBA4f(1, 1, 1); + scopeLine = RGBA4f(1.0, 0.9, 0.9); + tuningBarLight = RGBA4f(0.0, 0.45, 0.0); + tuningBarDark = RGBA4f(0.0, 0.1, 0.0); + tuningBarUp = RGBA4f(1.0, 0.0, 0.0); + tuningBarDown = RGBA4f(0.0, 0.5, 1.0); + meterLevel = RGBA4f(0, 0.5, 0); + meterValue = RGBA4f(0.5, 0, 0); + text = RGBA4f(1, 1, 1); + freqLine = RGBA4f(1, 1, 1); + button = RGBA4f(0.65, 0.65, 0.65); + buttonHighlight = RGBA4f(0.76, 0.65, 0); - scopeBackground = RGB3f(13.0 / 255.0, 47.0 / 255.0, 9.0 / 255.0); - fftBackground = RGB3f(0, 0, 50.0 / 255.0); - generalBackground = RGB3f(13.0 / 255.0, 47.0 / 255.0, 9.0 / 255.0); + scopeBackground = RGBA4f(13.0 / 255.0, 47.0 / 255.0, 9.0 / 255.0); + fftBackground = RGBA4f(0, 0, 50.0 / 255.0); + generalBackground = RGBA4f(13.0 / 255.0, 47.0 / 255.0, 9.0 / 255.0); } TouchColorTheme::TouchColorTheme() { @@ -204,27 +204,27 @@ TouchColorTheme::TouchColorTheme() { waterfallGradient.addColor(GradientColor(255.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0)); waterfallGradient.addColor(GradientColor(255.0 / 255.0, 255.0 / 255.0, 255.0 / 255.0)); waterfallGradient.generate(256); - waterfallHighlight = RGB3f(1, 1, 1); - waterfallNew = RGB3f(0, 1, 0); - waterfallHover = RGB3f(1, 1, 0); - waterfallDestroy = RGB3f(1, 0, 0); - fftLine = RGB3f(234.0 / 255.0, 232.0 / 255.0, 247.0 / 255.0); - fftHighlight = RGB3f(1.0, 1.0, 1.0); - scopeLine = RGB3f(234.0 / 255.0, 232.0 / 255.0, 247.0 / 255.0); - tuningBarLight = RGB3f(0.2, 0.2, 0.7); - tuningBarDark = RGB3f(0.1, 0.1, 0.45); - tuningBarUp = RGB3f(0.5, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGB3f(0.6, 108.0/255.0, 1.0); - meterLevel = RGB3f(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); - meterValue = RGB3f(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); - text = RGB3f(1, 1, 1); - freqLine = RGB3f(1, 1, 1); - button = RGB3f(1.0, 1.0, 1.0); - buttonHighlight = RGB3f(208.0 / 255.0, 202.0 / 255.0, 247.0 / 255.0); + waterfallHighlight = RGBA4f(1, 1, 1); + waterfallNew = RGBA4f(0, 1, 0); + waterfallHover = RGBA4f(1, 1, 0); + waterfallDestroy = RGBA4f(1, 0, 0); + fftLine = RGBA4f(234.0 / 255.0, 232.0 / 255.0, 247.0 / 255.0); + fftHighlight = RGBA4f(1.0, 1.0, 1.0); + scopeLine = RGBA4f(234.0 / 255.0, 232.0 / 255.0, 247.0 / 255.0); + tuningBarLight = RGBA4f(0.2, 0.2, 0.7); + tuningBarDark = RGBA4f(0.1, 0.1, 0.45); + tuningBarUp = RGBA4f(0.5, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBA4f(0.6, 108.0/255.0, 1.0); + meterLevel = RGBA4f(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); + meterValue = RGBA4f(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); + text = RGBA4f(1, 1, 1); + freqLine = RGBA4f(1, 1, 1); + button = RGBA4f(1.0, 1.0, 1.0); + buttonHighlight = RGBA4f(208.0 / 255.0, 202.0 / 255.0, 247.0 / 255.0); - scopeBackground = RGB3f(39.0 / 255.0, 36.0 / 255.0, 56.0 / 255.0); - fftBackground = RGB3f(39.0 / 255.0, 36.0 / 255.0, 56.0 / 255.0); - generalBackground = RGB3f(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); + scopeBackground = RGBA4f(39.0 / 255.0, 36.0 / 255.0, 56.0 / 255.0); + fftBackground = RGBA4f(39.0 / 255.0, 36.0 / 255.0, 56.0 / 255.0); + generalBackground = RGBA4f(61.0 / 255.0, 57.0 / 255.0, 88.0 / 255.0); } @@ -239,27 +239,27 @@ HDColorTheme::HDColorTheme() { waterfallGradient.addColor(GradientColor(255.0 / 255.0, 235.0 / 255.0, 100.0 / 255.0)); waterfallGradient.addColor(GradientColor(250.0 / 255.0, 250.0 / 255.0, 250.0 / 255.0)); waterfallGradient.generate(256); - waterfallHighlight = RGB3f(1, 1, 1); - waterfallNew = RGB3f(0, 1, 0); - waterfallHover = RGB3f(1, 1, 0); - waterfallDestroy = RGB3f(1, 0, 0); - fftLine = RGB3f(0.9, 0.9, 0.9); - fftHighlight = RGB3f(1, 1, 1); - scopeLine = RGB3f(0.9, 0.9, 0.9); - tuningBarLight = RGB3f(0.4, 0.4, 1.0); - tuningBarDark = RGB3f(0.1, 0.1, 0.45); - tuningBarUp = RGB3f(1.0, 139.0/255.0, 96.0/255.0); - tuningBarDown = RGB3f(148.0/255.0, 148.0/255.0, 1.0); - meterLevel = RGB3f(0, 0.5, 0); - meterValue = RGB3f(0.0, 0.0, 1.0); - text = RGB3f(1, 1, 1); - freqLine = RGB3f(1, 1, 1); - button = RGB3f(0, 0.7, 0.7); - buttonHighlight = RGB3f(1, 1, 1); + waterfallHighlight = RGBA4f(1, 1, 1); + waterfallNew = RGBA4f(0, 1, 0); + waterfallHover = RGBA4f(1, 1, 0); + waterfallDestroy = RGBA4f(1, 0, 0); + fftLine = RGBA4f(0.9, 0.9, 0.9); + fftHighlight = RGBA4f(1, 1, 1); + scopeLine = RGBA4f(0.9, 0.9, 0.9); + tuningBarLight = RGBA4f(0.4, 0.4, 1.0); + tuningBarDark = RGBA4f(0.1, 0.1, 0.45); + tuningBarUp = RGBA4f(1.0, 139.0/255.0, 96.0/255.0); + tuningBarDown = RGBA4f(148.0/255.0, 148.0/255.0, 1.0); + meterLevel = RGBA4f(0, 0.5, 0); + meterValue = RGBA4f(0.0, 0.0, 1.0); + text = RGBA4f(1, 1, 1); + freqLine = RGBA4f(1, 1, 1); + button = RGBA4f(0, 0.7, 0.7); + buttonHighlight = RGBA4f(1, 1, 1); - scopeBackground = RGB3f(0.0, 0.0, 48.0 / 255.0); - fftBackground = RGB3f(0.0, 0.0, 48.0 / 255.0); - generalBackground = RGB3f(0.0, 0.0, 0.0); + scopeBackground = RGBA4f(0.0, 0.0, 48.0 / 255.0); + fftBackground = RGBA4f(0.0, 0.0, 48.0 / 255.0); + generalBackground = RGBA4f(0.0, 0.0, 0.0); } diff --git a/src/visual/ColorTheme.h b/src/visual/ColorTheme.h index 52b431a..6f35324 100644 --- a/src/visual/ColorTheme.h +++ b/src/visual/ColorTheme.h @@ -15,55 +15,56 @@ #define COLOR_THEME_RADAR 6 #define COLOR_THEME_MAX 7 -class RGB3f { +class RGBA4f { public: - float r, g, b; - RGB3f(float r, float g, float b) : - r(r), g(g), b(b) { + float r, g, b, a; + RGBA4f(float r, float g, float b, float a = 1.0) : + r(r), g(g), b(b), a(a) { } - RGB3f() : - RGB3f(0, 0, 0) { + RGBA4f() : + RGBA4f(0, 0, 0) { } - ~RGB3f() { + ~RGBA4f() { } - RGB3f & operator=(const RGB3f &other) { + RGBA4f & operator=(const RGBA4f &other) { r = other.r; g = other.g; b = other.b; + a = other.a; return *this; } - RGB3f operator*(float v) { return RGB3f(r*v, g*v, b*v); } + RGBA4f operator*(float v) { return RGBA4f(r*v, g*v, b*v); } }; class ColorTheme { public: - RGB3f waterfallHighlight; - RGB3f waterfallNew; - RGB3f wfHighlight; - RGB3f waterfallHover; - RGB3f waterfallDestroy; - RGB3f fftLine; - RGB3f fftHighlight; - RGB3f scopeLine; - RGB3f tuningBarLight; - RGB3f tuningBarDark; - RGB3f tuningBarUp; - RGB3f tuningBarDown; - RGB3f meterLevel; - RGB3f meterValue; - RGB3f text; - RGB3f freqLine; - RGB3f button; - RGB3f buttonHighlight; + RGBA4f waterfallHighlight; + RGBA4f waterfallNew; + RGBA4f wfHighlight; + RGBA4f waterfallHover; + RGBA4f waterfallDestroy; + RGBA4f fftLine; + RGBA4f fftHighlight; + RGBA4f scopeLine; + RGBA4f tuningBarLight; + RGBA4f tuningBarDark; + RGBA4f tuningBarUp; + RGBA4f tuningBarDown; + RGBA4f meterLevel; + RGBA4f meterValue; + RGBA4f text; + RGBA4f freqLine; + RGBA4f button; + RGBA4f buttonHighlight; - RGB3f scopeBackground; - RGB3f fftBackground; - RGB3f generalBackground; + RGBA4f scopeBackground; + RGBA4f fftBackground; + RGBA4f generalBackground; Gradient waterfallGradient; diff --git a/src/visual/PrimaryGLContext.cpp b/src/visual/PrimaryGLContext.cpp index 15d96f8..29d2391 100644 --- a/src/visual/PrimaryGLContext.cpp +++ b/src/visual/PrimaryGLContext.cpp @@ -59,7 +59,7 @@ PrimaryGLContext::PrimaryGLContext(wxGLCanvas *canvas, wxGLContext *sharedContex //#endif } -void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGB3f color, long long center_freq, long long srate) { +void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, long long center_freq, long long srate) { if (!demod) { return; } @@ -151,7 +151,7 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGB3f color, lo } -void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGB3f color, long long center_freq, long long srate) { +void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBA4f color, long long center_freq, long long srate) { if (!demod) { return; } @@ -248,7 +248,7 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGB3f color, long l } -void PrimaryGLContext::DrawFreqSelector(float uxPos, RGB3f color, float w, long long center_freq, long long srate) { +void PrimaryGLContext::DrawFreqSelector(float uxPos, RGBA4f color, float w, long long center_freq, long long srate) { DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); long long bw = 0; @@ -299,7 +299,7 @@ void PrimaryGLContext::DrawFreqSelector(float uxPos, RGB3f color, float w, long } -void PrimaryGLContext::DrawRangeSelector(float uxPos1, float uxPos2, RGB3f color) { +void PrimaryGLContext::DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f color) { if (uxPos2 < uxPos1) { float temp = uxPos2; uxPos2=uxPos1; diff --git a/src/visual/PrimaryGLContext.h b/src/visual/PrimaryGLContext.h index 4f87e4d..254d2e7 100644 --- a/src/visual/PrimaryGLContext.h +++ b/src/visual/PrimaryGLContext.h @@ -21,10 +21,10 @@ public: void BeginDraw(float r, float g, float b); void EndDraw(); - void DrawFreqSelector(float uxPos, RGB3f color, float w = 0, long long center_freq = -1, long long srate = 0); - void DrawRangeSelector(float uxPos1, float uxPos2, RGB3f color); - void DrawDemod(DemodulatorInstance *demod, RGB3f color, long long center_freq = -1, long long srate = 0); - void DrawDemodInfo(DemodulatorInstance *demod, RGB3f color, long long center_freq = -1, long long srate = 0); + void DrawFreqSelector(float uxPos, RGBA4f color, float w = 0, long long center_freq = -1, long long srate = 0); + void DrawRangeSelector(float uxPos1, float uxPos2, RGBA4f color); + void DrawDemod(DemodulatorInstance *demod, RGBA4f color, long long center_freq = -1, long long srate = 0); + void DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, long long center_freq = -1, long long srate = 0); void setHoverAlpha(float hoverAlpha); diff --git a/src/visual/SpectrumCanvas.cpp b/src/visual/SpectrumCanvas.cpp index a35aca5..bc8870e 100644 --- a/src/visual/SpectrumCanvas.cpp +++ b/src/visual/SpectrumCanvas.cpp @@ -73,6 +73,8 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { spectrumPanel.calcTransform(CubicVR::mat4::identity()); spectrumPanel.draw(); + glLoadIdentity(); + std::vector &demods = wxGetApp().getDemodMgr().getDemodulators(); for (int i = 0, iMax = demods.size(); i < iMax; i++) { @@ -81,6 +83,8 @@ void SpectrumCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { glContext->EndDraw(); + spectrumPanel.drawChildren(); + SwapBuffers(); } @@ -126,6 +130,11 @@ void SpectrumCanvas::moveCenterFrequency(long long freqChange) { } } +void SpectrumCanvas::setShowDb(bool showDb) { + spectrumPanel.setShowDb(showDb); +} + + void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) { InteractiveCanvas::OnMouseMoved(event); if (mouseTracker.mouseDown()) { diff --git a/src/visual/SpectrumCanvas.h b/src/visual/SpectrumCanvas.h index af07f6c..6160111 100644 --- a/src/visual/SpectrumCanvas.h +++ b/src/visual/SpectrumCanvas.h @@ -19,6 +19,8 @@ public: void attachWaterfallCanvas(WaterfallCanvas *canvas_in); void moveCenterFrequency(long long freqChange); + void setShowDb(bool showDb); + SpectrumVisualDataQueue *getVisualDataQueue(); private: diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index b6fa267..a9fe015 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -98,10 +98,10 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { 0.75, mouseTracker.getOriginMouseX(), mouseTracker.getMouseX()); } - RGB3f clr = top ? ThemeMgr::mgr.currentTheme->tuningBarUp : ThemeMgr::mgr.currentTheme->tuningBarDown; + RGBA4f clr = top ? ThemeMgr::mgr.currentTheme->tuningBarUp : ThemeMgr::mgr.currentTheme->tuningBarDown; - RGB3f clrDark = ThemeMgr::mgr.currentTheme->tuningBarDark; - RGB3f clrMid = ThemeMgr::mgr.currentTheme->tuningBarLight; + RGBA4f clrDark = ThemeMgr::mgr.currentTheme->tuningBarDark; + RGBA4f 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); @@ -143,7 +143,7 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { glContext->DrawTuner(freq, 11, freqDP, freqW); int snap = wxGetApp().getFrequencySnap(); if (snap != 1) { - glContext->DrawTunerDigitBox((int)log10(snap), 11, freqDP, freqW, RGB3f(1.0,0.0,0.0)); + glContext->DrawTunerDigitBox((int)log10(snap), 11, freqDP, freqW, RGBA4f(1.0,0.0,0.0)); } } glContext->DrawTuner(bw, 7, bwDP, bwW); diff --git a/src/visual/TuningContext.cpp b/src/visual/TuningContext.cpp index bd9ca4a..a499da0 100644 --- a/src/visual/TuningContext.cpp +++ b/src/visual/TuningContext.cpp @@ -112,7 +112,7 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float } -void TuningContext::DrawTunerDigitBox(int index, int count, float displayPos, float displayWidth, RGB3f c) { +void TuningContext::DrawTunerDigitBox(int index, int count, float displayPos, float displayWidth, RGBA4f c) { GLint vp[4]; glGetIntegerv( GL_VIEWPORT, vp); @@ -152,7 +152,7 @@ int TuningContext::GetTunerDigitIndex(float mPos, int count, float displayPos, f return count - index; } -void TuningContext::DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGB3f color, float alpha, bool top, +void TuningContext::DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGBA4f color, float alpha, bool top, bool bottom) { float ofs = (displayWidth / (float) count); float p2 = displayPos + ofs * (float) (count - start + 1); diff --git a/src/visual/TuningContext.h b/src/visual/TuningContext.h index 61dc9f3..3bbec2f 100644 --- a/src/visual/TuningContext.h +++ b/src/visual/TuningContext.h @@ -14,9 +14,9 @@ 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 DrawTunerDigitBox(int index, int count, float displayPos, float displayWidth, RGB3f c); + void DrawTunerDigitBox(int index, int count, float displayPos, float displayWidth, RGBA4f c); int GetTunerDigitIndex(float mPos, int count, float displayPos, float displayWidth); - void DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGB3f color, float alpha, bool top, bool bottom); + void DrawTunerBarIndexed(int start, int end, int count, float displayPos, float displayWidth, RGBA4f color, float alpha, bool top, bool bottom); void DrawDemodFreqBw(long long freq, unsigned int bw, long long center); void DrawEnd(); From 3c822e1bd86947426d28b8ebbbf759d98d06fc24 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 17 Aug 2015 23:31:22 -0400 Subject: [PATCH 2/3] Make decibels display toggleable --- src/visual/SpectrumCanvas.cpp | 7 +++++-- src/visual/SpectrumCanvas.h | 1 + src/visual/WaterfallCanvas.cpp | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/visual/SpectrumCanvas.cpp b/src/visual/SpectrumCanvas.cpp index bc8870e..adcc96c 100644 --- a/src/visual/SpectrumCanvas.cpp +++ b/src/visual/SpectrumCanvas.cpp @@ -126,7 +126,6 @@ void SpectrumCanvas::moveCenterFrequency(long long freqChange) { freq -= freqChange; } wxGetApp().setFrequency(freq); - setStatusText("Set center frequency: %s", freq); } } @@ -134,6 +133,10 @@ void SpectrumCanvas::setShowDb(bool showDb) { spectrumPanel.setShowDb(showDb); } +bool SpectrumCanvas::getShowDb() { + return spectrumPanel.getShowDb(); +} + void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) { InteractiveCanvas::OnMouseMoved(event); @@ -144,7 +147,7 @@ void SpectrumCanvas::OnMouseMoved(wxMouseEvent& event) { moveCenterFrequency(freqChange); } } else { - setStatusText("Click and drag to adjust center frequency."); + setStatusText("Click and drag to adjust center frequency. 'B' to toggle decibels display."); } } diff --git a/src/visual/SpectrumCanvas.h b/src/visual/SpectrumCanvas.h index 6160111..238c48f 100644 --- a/src/visual/SpectrumCanvas.h +++ b/src/visual/SpectrumCanvas.h @@ -20,6 +20,7 @@ public: void moveCenterFrequency(long long freqChange); void setShowDb(bool showDb); + bool getShowDb(); SpectrumVisualDataQueue *getVisualDataQueue(); diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 204473f..c2571d7 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -338,6 +338,11 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) { activeDemod->setStereo(true); } break; + case 'B': + if (spectrumCanvas) { + spectrumCanvas->setShowDb(!spectrumCanvas->getShowDb()); + } + break; case WXK_SPACE: wxGetApp().showFrequencyInput(); break; From 2b7edb9b0fe4eedff8be0332db550418e22b503d Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 18 Aug 2015 00:08:22 -0400 Subject: [PATCH 3/3] spectrum visual spacing/floor tweak --- src/AppFrame.cpp | 3 +++ src/process/SpectrumVisualProcessor.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 9091e36..d4ac828 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -784,6 +784,9 @@ void AppFrame::OnIdle(wxIdleEvent& event) { if (val < 0.01) { val = 0.01; } + if (val > 0.99) { + val = 0.99; + } spectrumAvgMeter->setLevel(val); proc->setFFTAverageRate(val); diff --git a/src/process/SpectrumVisualProcessor.cpp b/src/process/SpectrumVisualProcessor.cpp index baa9099..9322462 100644 --- a/src/process/SpectrumVisualProcessor.cpp +++ b/src/process/SpectrumVisualProcessor.cpp @@ -290,7 +290,7 @@ void SpectrumVisualProcessor::process() { fft_floor_maa = fft_floor_maa + (fft_floor_ma - fft_floor_maa) * 0.05; for (int i = 0, iMax = fftSize; i < iMax; i++) { - float v = (log10(fft_result_maa[i]+0.25 - (fft_floor_maa-1.0)) / log10((fft_ceil_maa+0.25) - (fft_floor_maa-1.0))); + float v = (log10(fft_result_maa[i]+0.25 - (fft_floor_maa-0.75)) / log10((fft_ceil_maa+0.25) - (fft_floor_maa-0.75))); output->spectrum_points[i * 2] = ((float) i / (float) iMax); output->spectrum_points[i * 2 + 1] = v; }