From 8126cbeb5cc21b783470f703f10921a94066f9fb Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 15 Oct 2019 22:51:30 +0200 Subject: [PATCH] GLScope: modulo for trace color repetition --- sdrgui/gui/glscope.cpp | 8 +++++--- sdrgui/gui/glscope.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sdrgui/gui/glscope.cpp b/sdrgui/gui/glscope.cpp index 271f897e5..d185ec941 100644 --- a/sdrgui/gui/glscope.cpp +++ b/sdrgui/gui/glscope.cpp @@ -52,6 +52,7 @@ GLScope::GLScope(QWidget *parent) : QGLWidget(parent), m_timeOfsProMill(0), m_triggerPre(0), m_traceSize(0), + m_traceModulo(0), m_timeBase(1), m_timeOffset(0), m_focusedTraceIndex(0), @@ -891,7 +892,7 @@ void GLScope::setTraceSize(int traceSize, bool emitSignal) m_mutex.lock(); m_traceSize = traceSize; m_q3Colors.allocate(3*traceSize); - setColorPalette(traceSize, m_q3Colors.m_array); + setColorPalette(traceSize, m_traceModulo, m_q3Colors.m_array); m_configChanged = true; m_mutex.unlock(); update(); @@ -1972,11 +1973,12 @@ void GLScope::drawCircle(float cx, float cy, float r, int num_segments, bool dot } // https://stackoverflow.com/questions/19452530/how-to-render-a-rainbow-spectrum -void GLScope::setColorPalette(int nbVertices, GLfloat *colors) +void GLScope::setColorPalette(int nbVertices, int modulo, GLfloat *colors) { for (int v = 0; v < nbVertices; v++) { - float x = 0.8f*(((float) v)/nbVertices); + int ci = modulo < 2 ? v : v % modulo; + float x = 0.8f*(((float) ci)/modulo); QColor c = QColor::fromHslF(x, 0.8f, 0.6f); colors[3*v] = c.redF(); colors[3*v+1] = c.greenF(); diff --git a/sdrgui/gui/glscope.h b/sdrgui/gui/glscope.h index 8a25a047f..a3731aa31 100644 --- a/sdrgui/gui/glscope.h +++ b/sdrgui/gui/glscope.h @@ -81,6 +81,7 @@ public: void setDisplayXYPoints(bool value) { m_displayXYPoints = value; } void setDisplayXYPolarGrid(bool value) { m_displayPolGrid = value; } const QAtomicInt& getProcessingTraceIndex() const { return m_processingTraceIndex; } + void setTraceModulo(int modulo) { m_traceModulo = modulo; } signals: void sampleRateChanged(int); @@ -105,6 +106,7 @@ private: int m_timeOfsProMill; uint32_t m_triggerPre; int m_traceSize; + int m_traceModulo; //!< ineffective if <2 int m_timeBase; int m_timeOffset; uint32_t m_focusedTraceIndex; @@ -189,7 +191,7 @@ private: void drawRectGrid2(); void drawPolarGrid2(); static void drawCircle(float cx, float cy, float r, int num_segments, bool dotted, GLfloat *vertices); - static void setColorPalette(int nbVertices, GLfloat *colors); + static void setColorPalette(int nbVertices, int modulo, GLfloat *colors); protected slots: void cleanup();