1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

GLScope: modulo for trace color repetition

This commit is contained in:
f4exb 2019-10-15 22:51:30 +02:00
parent db3e75154c
commit 8126cbeb5c
2 changed files with 8 additions and 4 deletions

View File

@ -52,6 +52,7 @@ GLScope::GLScope(QWidget *parent) : QGLWidget(parent),
m_timeOfsProMill(0), m_timeOfsProMill(0),
m_triggerPre(0), m_triggerPre(0),
m_traceSize(0), m_traceSize(0),
m_traceModulo(0),
m_timeBase(1), m_timeBase(1),
m_timeOffset(0), m_timeOffset(0),
m_focusedTraceIndex(0), m_focusedTraceIndex(0),
@ -891,7 +892,7 @@ void GLScope::setTraceSize(int traceSize, bool emitSignal)
m_mutex.lock(); m_mutex.lock();
m_traceSize = traceSize; m_traceSize = traceSize;
m_q3Colors.allocate(3*traceSize); m_q3Colors.allocate(3*traceSize);
setColorPalette(traceSize, m_q3Colors.m_array); setColorPalette(traceSize, m_traceModulo, m_q3Colors.m_array);
m_configChanged = true; m_configChanged = true;
m_mutex.unlock(); m_mutex.unlock();
update(); 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 // 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++) 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); QColor c = QColor::fromHslF(x, 0.8f, 0.6f);
colors[3*v] = c.redF(); colors[3*v] = c.redF();
colors[3*v+1] = c.greenF(); colors[3*v+1] = c.greenF();

View File

@ -81,6 +81,7 @@ public:
void setDisplayXYPoints(bool value) { m_displayXYPoints = value; } void setDisplayXYPoints(bool value) { m_displayXYPoints = value; }
void setDisplayXYPolarGrid(bool value) { m_displayPolGrid = value; } void setDisplayXYPolarGrid(bool value) { m_displayPolGrid = value; }
const QAtomicInt& getProcessingTraceIndex() const { return m_processingTraceIndex; } const QAtomicInt& getProcessingTraceIndex() const { return m_processingTraceIndex; }
void setTraceModulo(int modulo) { m_traceModulo = modulo; }
signals: signals:
void sampleRateChanged(int); void sampleRateChanged(int);
@ -105,6 +106,7 @@ private:
int m_timeOfsProMill; int m_timeOfsProMill;
uint32_t m_triggerPre; uint32_t m_triggerPre;
int m_traceSize; int m_traceSize;
int m_traceModulo; //!< ineffective if <2
int m_timeBase; int m_timeBase;
int m_timeOffset; int m_timeOffset;
uint32_t m_focusedTraceIndex; uint32_t m_focusedTraceIndex;
@ -189,7 +191,7 @@ private:
void drawRectGrid2(); void drawRectGrid2();
void drawPolarGrid2(); void drawPolarGrid2();
static void drawCircle(float cx, float cy, float r, int num_segments, bool dotted, GLfloat *vertices); 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: protected slots:
void cleanup(); void cleanup();