diff --git a/sdrgui/dsp/scopevis.cpp b/sdrgui/dsp/scopevis.cpp index f39b272d8..0181bbd06 100644 --- a/sdrgui/dsp/scopevis.cpp +++ b/sdrgui/dsp/scopevis.cpp @@ -614,7 +614,7 @@ int ScopeVis::processTraces(const SampleVector::const_iterator& cbegin, const Sa float traceTime = ((float) m_traceSize) / m_sampleRate; if (traceTime >= 1.0f) { // display continuously if trace time is 1 second or more - m_glScope->newTraces(m_traces.m_traces, m_traces.currentBufferIndex()); + m_glScope->newTraces(m_traces.m_traces, m_traces.currentBufferIndex(), &m_traces.m_projectionTypes); } if (m_nbSamples == 0) // finished @@ -623,7 +623,7 @@ int ScopeVis::processTraces(const SampleVector::const_iterator& cbegin, const Sa if (traceTime < 1.0f) { if (m_glScope->getProcessingTraceIndex().load() < 0) { - m_glScope->newTraces(m_traces.m_traces, m_traces.currentBufferIndex()); + m_glScope->newTraces(m_traces.m_traces, m_traces.currentBufferIndex(), &m_traces.m_projectionTypes); } } diff --git a/sdrgui/dsp/scopevis.h b/sdrgui/dsp/scopevis.h index 0843315ae..ed9248938 100644 --- a/sdrgui/dsp/scopevis.h +++ b/sdrgui/dsp/scopevis.h @@ -878,6 +878,7 @@ private: std::vector m_tracesControl; //!< Corresponding traces control data std::vector m_tracesData; //!< Corresponding traces data std::vector m_traces[2]; //!< Double buffer of traces processed by glScope + std::vector m_projectionTypes; int m_traceSize; //!< Current size of a trace in buffer int m_maxTraceSize; //!< Maximum Size of a trace in buffer bool evenOddIndex; //!< Even (true) or odd (false) index @@ -924,6 +925,7 @@ private: m_traces[0].push_back(0); m_traces[1].push_back(0); m_tracesData.push_back(traceData); + m_projectionTypes.push_back(traceData.m_projectionType); m_tracesControl.push_back(new TraceControl()); TraceControl *traceControl = m_tracesControl.back(); traceControl->initProjector(traceData.m_projectionType); @@ -939,6 +941,7 @@ private: traceControl->releaseProjector(); traceControl->initProjector(traceData.m_projectionType); m_tracesData[traceIndex] = traceData; + m_projectionTypes[traceIndex] = traceData.m_projectionType; } } @@ -949,6 +952,7 @@ private: qDebug("ScopeVis::removeTrace"); m_traces[0].erase(m_traces[0].begin() + traceIndex); m_traces[1].erase(m_traces[1].begin() + traceIndex); + m_projectionTypes.erase(m_projectionTypes.begin() + traceIndex); TraceControl *traceControl = m_tracesControl[traceIndex]; traceControl->releaseProjector(); m_tracesControl.erase(m_tracesControl.begin() + traceIndex); @@ -967,6 +971,11 @@ private: int nextControlIndex = (traceIndex + (upElseDown ? 1 : -1)) % (m_tracesControl.size()); int nextDataIndex = (traceIndex + (upElseDown ? 1 : -1)) % (m_tracesData.size()); // should be the same + int nextProjectionTypeIndex = (traceIndex + (upElseDown ? 1 : -1)) % (m_projectionTypes.size()); // should be the same + + Projector::ProjectionType nextType = m_projectionTypes[traceIndex]; + m_projectionTypes[nextProjectionTypeIndex] = m_projectionTypes[traceIndex]; + m_projectionTypes[traceIndex] = nextType; TraceControl *traceControl = m_tracesControl[traceIndex]; TraceControl *nextTraceControl = m_tracesControl[nextControlIndex]; diff --git a/sdrgui/gui/glscope.cpp b/sdrgui/gui/glscope.cpp index c6e20b30a..a841a3706 100644 --- a/sdrgui/gui/glscope.cpp +++ b/sdrgui/gui/glscope.cpp @@ -16,24 +16,25 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// -#include +#include +#include #include #include #include +#include #include -#include -#include #include #include "glscope.h" -GLScope::GLScope(QWidget* parent) : - QGLWidget(parent), - m_tracesData(0), - m_traces(0), +GLScope::GLScope(QWidget *parent) : QGLWidget(parent), + m_tracesData(nullptr), + m_traces(nullptr), + m_projectionTypes(nullptr), m_processingTraceIndex(-1), m_bufferIndex(0), m_displayMode(DisplayX), + m_displayPolGrid(false), m_dataChanged(0), m_configChanged(false), m_sampleRate(0), @@ -62,7 +63,7 @@ GLScope::GLScope(QWidget* parent) : m_channelOverlayFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); m_channelOverlayFont.setBold(true); - m_channelOverlayFont.setPointSize(font().pointSize()+1); + m_channelOverlayFont.setPointSize(font().pointSize() + 1); //m_traceCounter = 0; } @@ -75,32 +76,36 @@ GLScope::~GLScope() void GLScope::setDisplayGridIntensity(int intensity) { m_displayGridIntensity = intensity; + if (m_displayGridIntensity > 100) { m_displayGridIntensity = 100; } else if (m_displayGridIntensity < 0) { m_displayGridIntensity = 0; } + update(); } void GLScope::setDisplayTraceIntensity(int intensity) { m_displayTraceIntensity = intensity; + if (m_displayTraceIntensity > 100) { m_displayTraceIntensity = 100; } else if (m_displayTraceIntensity < 0) { m_displayTraceIntensity = 0; } + update(); } -void GLScope::setTraces(std::vector* tracesData, std::vector* traces) +void GLScope::setTraces(std::vector *tracesData, std::vector *traces) { m_tracesData = tracesData; m_traces = traces; } -void GLScope::newTraces(std::vector* traces) +void GLScope::newTraces(std::vector *traces, int traceIndex, std::vector *projectionTypes) { if (traces->size() > 0) { @@ -108,26 +113,11 @@ void GLScope::newTraces(std::vector* traces) return; } - if (m_dataChanged.testAndSetOrdered(0, 1)) { - m_traces = traces; - } - - m_mutex.unlock(); - } -} - -void GLScope::newTraces(std::vector* traces, int traceIndex) -{ - if (traces->size() > 0) - { - if(!m_mutex.tryLock(0)) { - return; - } - if (m_dataChanged.testAndSetOrdered(0, 1)) { m_processingTraceIndex.store(traceIndex); m_traces = &traces[traceIndex]; + m_projectionTypes = projectionTypes; } m_mutex.unlock(); @@ -136,19 +126,24 @@ void GLScope::newTraces(std::vector* traces, int traceIndex) void GLScope::initializeGL() { - QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext(); + QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext(); - if (glCurrentContext) { - if (QOpenGLContext::currentContext()->isValid()) { + if (glCurrentContext) + { + if (QOpenGLContext::currentContext()->isValid()) + { qDebug() << "GLScope::initializeGL: context:" << " major: " << (QOpenGLContext::currentContext()->format()).majorVersion() << " minor: " << (QOpenGLContext::currentContext()->format()).minorVersion() << " ES: " << (QOpenGLContext::currentContext()->isOpenGLES() ? "yes" : "no"); } - else { + else + { qDebug() << "GLScope::initializeGL: current context is invalid"; } - } else { + } + else + { qCritical() << "GLScope::initializeGL: no current context"; return; } @@ -209,8 +204,8 @@ void GLScope::paintGL() m_configChanged = false; } -// qDebug("GLScope::paintGL: m_traceCounter: %d", m_traceCounter); -// m_traceCounter = 0; + // qDebug("GLScope::paintGL: m_traceCounter: %d", m_traceCounter); + // m_traceCounter = 0; QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions(); glFunctions->glClearColor(0.0f, 0.0f, 0.0f, 0.0f); @@ -220,20 +215,19 @@ void GLScope::paintGL() { // draw rect around { - GLfloat q3[] { + GLfloat q3[]{ 1, 1, 0, 1, 0, 0, - 1, 0 - }; + 1, 0}; QVector4D color(1.0f, 1.0f, 1.0f, 0.5f); m_glShaderSimple.drawContour(m_glScopeMatrix1, color, q3, 4); } // paint grid - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; // Y1 (X trace or trace #0) { @@ -243,27 +237,24 @@ void GLScope::paintGL() GLfloat *q3 = m_q3TickY1.m_array; int effectiveTicks = 0; - for (int i= 0; i < tickList->count(); i++) + for (int i = 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; - if (tick->major) + if ((tick->major) && (tick->textSize > 0)) { - if (tick->textSize > 0) - { - float y = 1 - (tick->pos / m_y1Scale.getSize()); - q3[4*effectiveTicks] = 0; - q3[4*effectiveTicks+1] = y; - q3[4*effectiveTicks+2] = 1; - q3[4*effectiveTicks+3] = y; - effectiveTicks++; - } + float y = 1 - (tick->pos / m_y1Scale.getSize()); + q3[4 * effectiveTicks] = 0; + q3[4 * effectiveTicks + 1] = y; + q3[4 * effectiveTicks + 2] = 1; + q3[4 * effectiveTicks + 3] = y; + effectiveTicks++; } } float blue = 1.0f; - QVector4D color(1.0f, 1.0f, blue, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks); + QVector4D color(1.0f, 1.0f, blue, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2 * effectiveTicks); } // X1 (time) @@ -273,55 +264,53 @@ void GLScope::paintGL() //GLfloat q3[4*tickList->count()]; GLfloat *q3 = m_q3TickX1.m_array; int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { + + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float x = tick->pos / m_x1Scale.getSize(); - q3[4*effectiveTicks] = x; - q3[4*effectiveTicks+1] = 0; - q3[4*effectiveTicks+2] = x; - q3[4*effectiveTicks+3] = 1; - effectiveTicks++; - } + + if ((tick->major) && (tick->textSize > 0)) + { + float x = tick->pos / m_x1Scale.getSize(); + q3[4 * effectiveTicks] = x; + q3[4 * effectiveTicks + 1] = 0; + q3[4 * effectiveTicks + 2] = x; + q3[4 * effectiveTicks + 3] = 1; + effectiveTicks++; } } - QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks); + QVector4D color(1.0f, 1.0f, 1.0f, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2 * effectiveTicks); } // paint left #1 scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderLeft1Scale.drawSurface(m_glLeft1ScaleMatrix, tex1, vtx1, 4); } // paint bottom #1 scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderBottom1Scale.drawSurface(m_glBot1ScaleMatrix, tex1, vtx1, 4); } @@ -329,15 +318,16 @@ void GLScope::paintGL() if (m_traceSize > 0) { const float *trace = (*m_traces)[0]; - const ScopeVis::TraceData& traceData = (*m_tracesData)[0]; + const ScopeVis::TraceData &traceData = (*m_tracesData)[0]; if (traceData.m_viewTrace) { - int start = (m_timeOfsProMill/1000.0) * m_traceSize; - int end = std::min(start + m_traceSize/m_timeBase, m_traceSize); + int start = (m_timeOfsProMill / 1000.0) * m_traceSize; + int end = std::min(start + m_traceSize / m_timeBase, m_traceSize); - if(end - start < 2) + if (end - start < 2) { start--; + } float rectX = m_glScopeRect1.x(); float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f; @@ -351,15 +341,14 @@ void GLScope::paintGL() mat.setToIdentity(); mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawPolyline(mat, color, (GLfloat *) &trace[2*start], end - start); + m_glShaderSimple.drawPolyline(mat, color, (GLfloat *)&trace[2 * start], end - start); // Paint trigger level if any if ((traceData.m_triggerDisplayLevel > -1.0f) && (traceData.m_triggerDisplayLevel < 1.0f)) { - GLfloat q3[] { + GLfloat q3[]{ 0, traceData.m_triggerDisplayLevel, - 1, traceData.m_triggerDisplayLevel - }; + 1, traceData.m_triggerDisplayLevel}; float rectX = m_glScopeRect1.x(); float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f; @@ -367,10 +356,10 @@ void GLScope::paintGL() float rectH = -m_glScopeRect1.height() / 2.0f; QVector4D color( - m_focusedTriggerData.m_triggerColorR, - m_focusedTriggerData.m_triggerColorG, - m_focusedTriggerData.m_triggerColorB, - 0.4f); + m_focusedTriggerData.m_triggerColorR, + m_focusedTriggerData.m_triggerColorG, + m_focusedTriggerData.m_triggerColorB, + 0.4f); QMatrix4x4 mat; mat.setToIdentity(); mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); @@ -382,10 +371,10 @@ void GLScope::paintGL() if ((m_focusedTraceIndex == 0) && (traceData.m_hasTextOverlay)) { drawChannelOverlay( - traceData.m_textOverlay, - traceData.m_traceColor, - m_channelOverlayPixmap1, - m_glScopeRect1); + traceData.m_textOverlay, + traceData.m_traceColor, + m_channelOverlayPixmap1, + m_glScopeRect1); } // display overlay } // displayable trace } // trace length > 0 @@ -395,20 +384,19 @@ void GLScope::paintGL() { // draw rect around { - GLfloat q3[] { + GLfloat q3[]{ 1, 1, 0, 1, 0, 0, - 1, 0 - }; + 1, 0}; QVector4D color(1.0f, 1.0f, 1.0f, 0.5f); m_glShaderSimple.drawContour(m_glScopeMatrix2, color, q3, 4); } // paint grid - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; // Y2 (Focused Y trace) { @@ -418,27 +406,24 @@ void GLScope::paintGL() GLfloat *q3 = m_q3TickY2.m_array; int effectiveTicks = 0; - for (int i= 0; i < tickList->count(); i++) + for (int i = 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; - if (tick->major) + if ((tick->major) && (tick->textSize > 0)) { - if (tick->textSize > 0) - { - float y = 1 - (tick->pos / m_y2Scale.getSize()); - q3[4*effectiveTicks] = 0; - q3[4*effectiveTicks+1] = y; - q3[4*effectiveTicks+2] = 1; - q3[4*effectiveTicks+3] = y; - effectiveTicks++; - } + float y = 1 - (tick->pos / m_y2Scale.getSize()); + q3[4 * effectiveTicks] = 0; + q3[4 * effectiveTicks + 1] = y; + q3[4 * effectiveTicks + 2] = 1; + q3[4 * effectiveTicks + 3] = y; + effectiveTicks++; } } float blue = 1.0f; - QVector4D color(1.0f, 1.0f, blue, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2*effectiveTicks); + QVector4D color(1.0f, 1.0f, blue, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2 * effectiveTicks); } // X2 (time) @@ -448,71 +433,70 @@ void GLScope::paintGL() //GLfloat q3[4*tickList->count()]; GLfloat *q3 = m_q3TickX2.m_array; int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { + + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float x = tick->pos / m_x2Scale.getSize(); - q3[4*effectiveTicks] = x; - q3[4*effectiveTicks+1] = 0; - q3[4*effectiveTicks+2] = x; - q3[4*effectiveTicks+3] = 1; - effectiveTicks++; - } + + if ((tick->major) && (tick->textSize > 0)) + { + float x = tick->pos / m_x2Scale.getSize(); + q3[4 * effectiveTicks] = x; + q3[4 * effectiveTicks + 1] = 0; + q3[4 * effectiveTicks + 2] = x; + q3[4 * effectiveTicks + 3] = 1; + effectiveTicks++; } } - QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2*effectiveTicks); + QVector4D color(1.0f, 1.0f, 1.0f, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2 * effectiveTicks); } // paint left #2 scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderLeft2Scale.drawSurface(m_glLeft2ScaleMatrix, tex1, vtx1, 4); } // paint bottom #2 scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderBottom2Scale.drawSurface(m_glBot2ScaleMatrix, tex1, vtx1, 4); } // paint traces #1..n if (m_traceSize > 0) { - int start = (m_timeOfsProMill/1000.0) * m_traceSize; - int end = std::min(start + m_traceSize/m_timeBase, m_traceSize); + int start = (m_timeOfsProMill / 1000.0) * m_traceSize; + int end = std::min(start + m_traceSize / m_timeBase, m_traceSize); - if(end - start < 2) + if (end - start < 2) { start--; + } for (unsigned int i = 1; i < m_traces->size(); i++) { const float *trace = (*m_traces)[i]; - const ScopeVis::TraceData& traceData = (*m_tracesData)[i]; + const ScopeVis::TraceData &traceData = (*m_tracesData)[i]; if (!traceData.m_viewTrace) { continue; @@ -530,15 +514,14 @@ void GLScope::paintGL() mat.setToIdentity(); mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawPolyline(mat, color, (GLfloat *) &trace[2*start], end - start); + m_glShaderSimple.drawPolyline(mat, color, (GLfloat *)&trace[2 * start], end - start); // Paint trigger level if any if ((traceData.m_triggerDisplayLevel > -1.0f) && (traceData.m_triggerDisplayLevel < 1.0f)) { - GLfloat q3[] { + GLfloat q3[]{ 0, traceData.m_triggerDisplayLevel, - 1, traceData.m_triggerDisplayLevel - }; + 1, traceData.m_triggerDisplayLevel}; float rectX = m_glScopeRect2.x(); float rectY = m_glScopeRect2.y() + m_glScopeRect2.height() / 2.0f; @@ -546,10 +529,10 @@ void GLScope::paintGL() float rectH = -m_glScopeRect2.height() / 2.0f; QVector4D color( - m_focusedTriggerData.m_triggerColorR, - m_focusedTriggerData.m_triggerColorG, - m_focusedTriggerData.m_triggerColorB, - 0.4f); + m_focusedTriggerData.m_triggerColorR, + m_focusedTriggerData.m_triggerColorG, + m_focusedTriggerData.m_triggerColorB, + 0.4f); QMatrix4x4 mat; mat.setToIdentity(); mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); @@ -561,10 +544,10 @@ void GLScope::paintGL() if ((i == m_focusedTraceIndex) && (traceData.m_hasTextOverlay)) { drawChannelOverlay( - traceData.m_textOverlay, - traceData.m_traceColor, - m_channelOverlayPixmap2, - m_glScopeRect2); + traceData.m_textOverlay, + traceData.m_traceColor, + m_channelOverlayPixmap2, + m_glScopeRect2); } } // one trace display @@ -577,89 +560,84 @@ void GLScope::paintGL() // draw rect around { - GLfloat q3[] { + GLfloat q3[]{ 1, 1, 0, 1, 0, 0, - 1, 0 - }; + 1, 0}; QVector4D color(1.0f, 1.0f, 1.0f, 0.5f); m_glShaderSimple.drawContour(m_glScopeMatrix1, color, q3, 4); - } // paint grid - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; - // Horizontal Y1 + // Horizontal grid Y1 tickList = &m_y1Scale.getTickList(); { //GLfloat q3[4*tickList->count()]; GLfloat *q3 = m_q3TickY1.m_array; int effectiveTicks = 0; - for (int i= 0; i < tickList->count(); i++) + for (int i = 0; i < tickList->count(); i++) { tick = &(*tickList)[i]; - if (tick->major) + if ((tick->major) && (tick->textSize > 0)) { - if (tick->textSize > 0) - { - float y = 1 - (tick->pos / m_y1Scale.getSize()); - q3[4*effectiveTicks] = 0; - q3[4*effectiveTicks+1] = y; - q3[4*effectiveTicks+2] = 1; - q3[4*effectiveTicks+3] = y; - effectiveTicks++; - } + float y = 1 - (tick->pos / m_y1Scale.getSize()); + q3[4 * effectiveTicks] = 0; + q3[4 * effectiveTicks + 1] = y; + q3[4 * effectiveTicks + 2] = 1; + q3[4 * effectiveTicks + 3] = y; + effectiveTicks++; } } - QVector4D color(1.0f, 1.0f, 0.25f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks); + QVector4D color(1.0f, 1.0f, 0.25f, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2 * effectiveTicks); } - // Vertical X1 + // Vertical grid X1 tickList = &m_x1Scale.getTickList(); { //GLfloat q3[4*tickList->count()]; GLfloat *q3 = m_q3TickX1.m_array; int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { + + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float x = tick->pos / m_x1Scale.getSize(); - q3[4*effectiveTicks] = x; - q3[4*effectiveTicks+1] = 0; - q3[4*effectiveTicks+2] = x; - q3[4*effectiveTicks+3] = 1; - effectiveTicks++; - } + + if ((tick->major) && (tick->textSize > 0)) + { + float x = tick->pos / m_x1Scale.getSize(); + q3[4 * effectiveTicks] = x; + q3[4 * effectiveTicks + 1] = 0; + q3[4 * effectiveTicks + 2] = x; + q3[4 * effectiveTicks + 3] = 1; + effectiveTicks++; } } - QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks); + QVector4D color(1.0f, 1.0f, 1.0f, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2 * effectiveTicks); } // paint left #1 scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderLeft1Scale.drawSurface(m_glLeft1ScaleMatrix, tex1, vtx1, 4); } @@ -667,61 +645,59 @@ void GLScope::paintGL() // paint bottom #1 scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderBottom1Scale.drawSurface(m_glBot1ScaleMatrix, tex1, vtx1, 4); } // Paint secondary grid - // Horizontal Y2 + // Horizontal secondary grid Y2 tickList = &m_y2Scale.getTickList(); { //GLfloat q3[4*tickList->count()]; GLfloat *q3 = m_q3TickY2.m_array; int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { + + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float y = 1 - (tick->pos / m_y2Scale.getSize()); - q3[4*effectiveTicks] = 0; - q3[4*effectiveTicks+1] = y; - q3[4*effectiveTicks+2] = 1; - q3[4*effectiveTicks+3] = y; - effectiveTicks++; - } + + if ((tick->major) && (tick->textSize > 0)) + { + float y = 1 - (tick->pos / m_y2Scale.getSize()); + q3[4 * effectiveTicks] = 0; + q3[4 * effectiveTicks + 1] = y; + q3[4 * effectiveTicks + 2] = 1; + q3[4 * effectiveTicks + 3] = y; + effectiveTicks++; } } - QVector4D color(0.25f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2*effectiveTicks); + QVector4D color(0.25f, 1.0f, 1.0f, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix1, color, q3, 2 * effectiveTicks); } // Paint secondary scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderLeft2Scale.drawSurface(m_glRight1ScaleMatrix, tex1, vtx1, 4); } @@ -729,16 +705,17 @@ void GLScope::paintGL() // paint all traces if (m_traceSize > 0) { - int start = (m_timeOfsProMill/1000.0) * m_traceSize; - int end = std::min(start + m_traceSize/m_timeBase, m_traceSize); + int start = (m_timeOfsProMill / 1000.0) * m_traceSize; + int end = std::min(start + m_traceSize / m_timeBase, m_traceSize); - if(end - start < 2) + if (end - start < 2) { start--; + } for (unsigned int i = 0; i < m_traces->size(); i++) { const float *trace = (*m_traces)[i]; - const ScopeVis::TraceData& traceData = (*m_tracesData)[i]; + const ScopeVis::TraceData &traceData = (*m_tracesData)[i]; if (!traceData.m_viewTrace) { continue; @@ -756,15 +733,14 @@ void GLScope::paintGL() mat.setToIdentity(); mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); mat.scale(2.0f * rectW, -2.0f * rectH); - m_glShaderSimple.drawPolyline(mat, color, (GLfloat *) &trace[2*start], end - start); + m_glShaderSimple.drawPolyline(mat, color, (GLfloat *)&trace[2 * start], end - start); // Paint trigger level if any if ((traceData.m_triggerDisplayLevel > -1.0f) && (traceData.m_triggerDisplayLevel < 1.0f)) { - GLfloat q3[] { + GLfloat q3[]{ 0, traceData.m_triggerDisplayLevel, - 1, traceData.m_triggerDisplayLevel - }; + 1, traceData.m_triggerDisplayLevel}; float rectX = m_glScopeRect1.x(); float rectY = m_glScopeRect1.y() + m_glScopeRect1.height() / 2.0f; @@ -772,10 +748,10 @@ void GLScope::paintGL() float rectH = -m_glScopeRect1.height() / 2.0f; QVector4D color( - m_focusedTriggerData.m_triggerColorR, - m_focusedTriggerData.m_triggerColorG, - m_focusedTriggerData.m_triggerColorB, - 0.4f); + m_focusedTriggerData.m_triggerColorR, + m_focusedTriggerData.m_triggerColorG, + m_focusedTriggerData.m_triggerColorB, + 0.4f); QMatrix4x4 mat; mat.setToIdentity(); mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); @@ -787,10 +763,10 @@ void GLScope::paintGL() if ((i == m_focusedTraceIndex) && (traceData.m_hasTextOverlay)) { drawChannelOverlay( - traceData.m_textOverlay, - traceData.m_traceColor, - m_channelOverlayPixmap1, - m_glScopeRect1); + traceData.m_textOverlay, + traceData.m_traceColor, + m_channelOverlayPixmap1, + m_glScopeRect1); } } // all traces display } // trace length > 0 @@ -799,12 +775,11 @@ void GLScope::paintGL() // draw rect around { - GLfloat q3[] { + GLfloat q3[]{ 1, 1, 0, 1, 0, 0, - 1, 0 - }; + 1, 0}; QVector4D color(1.0f, 1.0f, 1.0f, 0.5f); m_glShaderSimple.drawContour(m_glScopeMatrix2, color, q3, 4); @@ -818,22 +793,24 @@ void GLScope::paintGL() //GLfloat q3[4*tickList->count()]; GLfloat *q3 = m_q3TickY2.m_array; int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { + + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float y = 1 - (tick->pos / m_y2Scale.getSize()); - q3[4*effectiveTicks] = 0; - q3[4*effectiveTicks+1] = y; - q3[4*effectiveTicks+2] = 1; - q3[4*effectiveTicks+3] = y; - effectiveTicks++; - } + + if ((tick->major) && (tick->textSize > 0)) + { + float y = 1 - (tick->pos / m_y2Scale.getSize()); + q3[4 * effectiveTicks] = 0; + q3[4 * effectiveTicks + 1] = y; + q3[4 * effectiveTicks + 2] = 1; + q3[4 * effectiveTicks + 3] = y; + effectiveTicks++; } } - QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2*effectiveTicks); + QVector4D color(1.0f, 1.0f, 1.0f, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2 * effectiveTicks); } // Vertical X2 @@ -842,38 +819,38 @@ void GLScope::paintGL() //GLfloat q3[4*tickList->count()]; GLfloat *q3 = m_q3TickX2.m_array; int effectiveTicks = 0; - for(int i= 0; i < tickList->count(); i++) { + + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - float x = tick->pos / m_x2Scale.getSize(); - q3[4*effectiveTicks] = x; - q3[4*effectiveTicks+1] = 0; - q3[4*effectiveTicks+2] = x; - q3[4*effectiveTicks+3] = 1; - effectiveTicks++; - } + + if ((tick->major) && (tick->textSize > 0)) + { + float x = tick->pos / m_x2Scale.getSize(); + q3[4 * effectiveTicks] = x; + q3[4 * effectiveTicks + 1] = 0; + q3[4 * effectiveTicks + 2] = x; + q3[4 * effectiveTicks + 3] = 1; + effectiveTicks++; } } - QVector4D color(1.0f, 1.0f, 1.0f, (float) m_displayGridIntensity / 100.0f); - m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2*effectiveTicks); + QVector4D color(1.0f, 1.0f, 1.0f, (float)m_displayGridIntensity / 100.0f); + m_glShaderSimple.drawSegments(m_glScopeMatrix2, color, q3, 2 * effectiveTicks); } // paint left #2 scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderLeft2Scale.drawSurface(m_glLeft2ScaleMatrix, tex1, vtx1, 4); } @@ -881,17 +858,15 @@ void GLScope::paintGL() // paint bottom #2 scale { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; m_glShaderBottom2Scale.drawSurface(m_glBot2ScaleMatrix, tex1, vtx1, 4); } @@ -900,30 +875,61 @@ void GLScope::paintGL() if (m_traceSize > 0) { - int start = (m_timeOfsProMill/1000.0) * m_traceSize; - int end = std::min(start + m_traceSize/m_timeBase, m_traceSize); + int start = (m_timeOfsProMill / 1000.0) * m_traceSize; + int end = std::min(start + m_traceSize / m_timeBase, m_traceSize); - if(end - start < 2) + if (end - start < 2) start--; //GLfloat q3[2*(end - start)]; GLfloat *q3 = m_q3Polar.m_array; const float *trace0 = (*m_traces)[0]; - memcpy(q3, &(trace0[2*start+1]), (2*(end - start) - 1)*sizeof(float)); // copy X values + + // If X is an angle and XY display is in polar grid we will perform polar conversion of traces + bool polarConversion = m_projectionTypes ? + (*m_projectionTypes).size() > 0 ? (*m_projectionTypes)[0] == Projector::ProjectionPhase : false + : false; + polarConversion &= m_displayPolGrid; + + if (!polarConversion) { // When there is no polar conversion X values are fixed + memcpy(q3, &(trace0[2*start + 1]), (2*(end-start) - 1)*sizeof(float)); // copy X values + } // TODO: with polar conversion X can be converted to fixed sin(theta) and cos(theta) for (unsigned int i = 1; i < m_traces->size(); i++) { const float *trace = (*m_traces)[i]; - const ScopeVis::TraceData& traceData = (*m_tracesData)[i]; + const ScopeVis::TraceData &traceData = (*m_tracesData)[i]; + bool positiveProjection = m_projectionTypes && (i < m_projectionTypes->size()) ? + isPositiveProjection((*m_projectionTypes)[i]) : false; if (!traceData.m_viewTrace) { continue; } - for(int i = start; i < end; i++) + if (polarConversion) { - float y = trace[2*i+1]; - q3[2*(i-start)+1] = y; + for (int j = start; j < end; j++) + { + float r; + if (positiveProjection) { + r = 0.5f*trace[2*j + 1] + 0.5f; + } else { + r = trace[2*j + 1]; + } + float theta = M_PI*trace0[2*j + 1]; // TODO: fixed X to theta conversion (see above) + float x = r*cos(theta); + float y = r*sin(theta); + q3[2*(j-start)] = x; + q3[2*(j-start) + 1] = y; + } + } + else + { + for (int j = start; j < end; j++) + { + float y = trace[2*j + 1]; + q3[2*(j-start) + 1] = y; + } } float rectX = m_glScopeRect2.x() + m_glScopeRect2.width() / 2.0f; @@ -936,10 +942,11 @@ void GLScope::paintGL() mat.setToIdentity(); mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); mat.scale(2.0f * rectW, -2.0f * rectH); + if (m_displayXYPoints) { - m_glShaderSimple.drawPoints(mat, color, q3, end -start); + m_glShaderSimple.drawPoints(mat, color, q3, end - start); } else { - m_glShaderSimple.drawPolyline(mat, color, q3, end -start); + m_glShaderSimple.drawPolyline(mat, color, q3, end - start); } } // XY polar display } // trace length > 0 @@ -1034,67 +1041,53 @@ void GLScope::applyConfig() { QFontMetrics fm(font()); //float t_start = ((m_timeOfsProMill / 1000.0) * ((float) m_traceSize / m_sampleRate)) - ((float) m_triggerPre / m_sampleRate); - float t_start = (((m_timeOfsProMill / 1000.0f) * (float) m_traceSize) / m_sampleRate) - ((float) m_triggerPre / m_sampleRate); - float t_len = ((float) m_traceSize / m_sampleRate) / (float) m_timeBase; + float t_start = (((m_timeOfsProMill / 1000.0f) * (float)m_traceSize) / m_sampleRate) - ((float)m_triggerPre / m_sampleRate); + float t_len = ((float)m_traceSize / m_sampleRate) / (float)m_timeBase; // scales m_x1Scale.setRange(Unit::Time, t_start, t_start + t_len); // time scale - if (m_displayMode == DisplayPol) - { + if (m_displayMode == DisplayPol) { setYScale(m_x2Scale, 0); // polar scale (X) - } - else - { + } else { m_x2Scale.setRange(Unit::Time, t_start, t_start + t_len); // time scale } - if (m_traces->size() > 0) - { + if (m_traces->size() > 0) { setYScale(m_y1Scale, 0); // This is always the X trace (trace #0) } - if ((m_traces->size() > 1) && (m_focusedTraceIndex < m_traces->size())) - { + if ((m_traces->size() > 1) && (m_focusedTraceIndex < m_traces->size())) { setYScale(m_y2Scale, m_focusedTraceIndex > 0 ? m_focusedTraceIndex : 1); // if Highlighted trace is #0 (X trace) set it to first Y trace (trace #1) - } - else - { + } else { setYScale(m_y2Scale, 0); // Default to the X trace (trace #0) - If there is only one trace it should not get there (Y displays disabled in the UI) } // display arrangements - if ((m_displayMode == DisplayX) || (m_displayMode == DisplayY)) // unique displays - { + if ((m_displayMode == DisplayX) || (m_displayMode == DisplayY)) { // unique displays setUniqueDisplays(); - } - else if (m_displayMode == DisplayXYV) // both displays vertically arranged - { + } else if (m_displayMode == DisplayXYV) { // both displays vertically arranged setVerticalDisplays(); - } - else if (m_displayMode == DisplayXYH) // both displays horizontally arranged - { + } else if (m_displayMode == DisplayXYH) { // both displays horizontally arranged setHorizontalDisplays(); - } - else if (m_displayMode == DisplayPol) // horizontal arrangement: XY stacked on left and polar on right - { + } else if (m_displayMode == DisplayPol) { // horizontal arrangement: XY stacked on left and polar on right setPolarDisplays(); } - m_q3TickY1.allocate(4*m_y1Scale.getTickList().count()); - m_q3TickY2.allocate(4*m_y2Scale.getTickList().count()); - m_q3TickX1.allocate(4*m_x1Scale.getTickList().count()); - m_q3TickX2.allocate(4*m_x2Scale.getTickList().count()); + m_q3TickY1.allocate(4 * m_y1Scale.getTickList().count()); + m_q3TickY2.allocate(4 * m_y2Scale.getTickList().count()); + m_q3TickX1.allocate(4 * m_x1Scale.getTickList().count()); + m_q3TickX2.allocate(4 * m_x2Scale.getTickList().count()); - int start = (m_timeOfsProMill/1000.0) * m_traceSize; - int end = std::min(start + m_traceSize/m_timeBase, m_traceSize); + int start = (m_timeOfsProMill / 1000.0) * m_traceSize; + int end = std::min(start + m_traceSize / m_timeBase, m_traceSize); - if(end - start < 2) + if (end - start < 2) start--; - m_q3Polar.allocate(2*(end - start)); + m_q3Polar.allocate(2 * (end - start)); } void GLScope::setUniqueDisplays() @@ -1107,91 +1100,76 @@ void GLScope::setUniqueDisplays() // X display m_glScopeRect1 = QRectF( - (float) m_leftMargin / (float) width(), - (float) m_topMargin / (float) height(), - (float) scopeWidth / (float) width(), - (float) scopeHeight / (float) height() - ); + (float)m_leftMargin / (float)width(), + (float)m_topMargin / (float)height(), + (float)scopeWidth / (float)width(), + (float)scopeHeight / (float)height()); m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glScopeMatrix1.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glScopeMatrix1.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * scopeHeight / (float)height()); m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(m_botMargin - 1) / (float) height() - ); + m_glBot1ScaleMatrix.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * (scopeHeight + m_topMargin + 1) / (float)height())); + m_glBot1ScaleMatrix.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * (m_botMargin - 1) / (float)height()); m_glLeft1ScaleMatrix.setToIdentity(); - m_glLeft1ScaleMatrix.translate ( + m_glLeft1ScaleMatrix.translate( -1.0f, - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glLeft1ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glLeft1ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); // Y displays m_glScopeRect2 = QRectF( - (float) m_leftMargin / (float) width(), - (float) m_topMargin / (float) height(), - (float) scopeWidth / (float) width(), - (float) scopeHeight / (float) height() - ); + (float)m_leftMargin / (float)width(), + (float)m_topMargin / (float)height(), + (float)scopeWidth / (float)width(), + (float)scopeHeight / (float)height()); m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glScopeMatrix2.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glScopeMatrix2.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * scopeHeight / (float)height()); m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(m_botMargin - 1) / (float) height() - ); + m_glBot2ScaleMatrix.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * (scopeHeight + m_topMargin + 1) / (float)height())); + m_glBot2ScaleMatrix.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * (m_botMargin - 1) / (float)height()); m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( + m_glLeft2ScaleMatrix.translate( -1.0f, - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glLeft2ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); { // X horizontal scale (X1) m_x1Scale.setSize(scopeWidth); m_bot1ScalePixmap = QPixmap( scopeWidth, - m_botMargin - 1 - ); + m_botMargin - 1); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_bot1ScalePixmap.fill(Qt::black); QPainter painter(&m_bot1ScalePixmap); @@ -1199,12 +1177,12 @@ void GLScope::setUniqueDisplays() painter.setFont(font()); tickList = &m_x1Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); } } @@ -1216,11 +1194,10 @@ void GLScope::setUniqueDisplays() m_bot2ScalePixmap = QPixmap( scopeWidth, - m_botMargin - 1 - ); + m_botMargin - 1); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_bot2ScalePixmap.fill(Qt::black); QPainter painter(&m_bot2ScalePixmap); @@ -1228,12 +1205,12 @@ void GLScope::setUniqueDisplays() painter.setFont(font()); tickList = &m_x2Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); } } @@ -1245,11 +1222,10 @@ void GLScope::setUniqueDisplays() m_left1ScalePixmap = QPixmap( m_leftMargin - 1, - scopeHeight - ); + scopeHeight); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_left1ScalePixmap.fill(Qt::black); QPainter painter(&m_left1ScalePixmap); @@ -1257,12 +1233,12 @@ void GLScope::setUniqueDisplays() painter.setFont(font()); tickList = &m_y1Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent() / 2), tick->text); } } @@ -1274,11 +1250,10 @@ void GLScope::setUniqueDisplays() m_left2ScalePixmap = QPixmap( m_leftMargin - 1, - scopeHeight - ); + scopeHeight); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_left2ScalePixmap.fill(Qt::black); QPainter painter(&m_left2ScalePixmap); @@ -1286,12 +1261,12 @@ void GLScope::setUniqueDisplays() painter.setFont(font()); tickList = &m_y2Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent() / 2), tick->text); } } @@ -1309,91 +1284,76 @@ void GLScope::setVerticalDisplays() // X display m_glScopeRect1 = QRectF( - (float) m_leftMargin / (float) width(), - (float) m_topMargin / (float) height(), - (float) scopeWidth / (float) width(), - (float) scopeHeight / (float) height() - ); + (float)m_leftMargin / (float)width(), + (float)m_topMargin / (float)height(), + (float)scopeWidth / (float)width(), + (float)scopeHeight / (float)height()); m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glScopeMatrix1.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glScopeMatrix1.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * scopeHeight / (float)height()); m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(m_botMargin - 1) / (float) height() - ); + m_glBot1ScaleMatrix.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * (scopeHeight + m_topMargin + 1) / (float)height())); + m_glBot1ScaleMatrix.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * (m_botMargin - 1) / (float)height()); m_glLeft1ScaleMatrix.setToIdentity(); - m_glLeft1ScaleMatrix.translate ( + m_glLeft1ScaleMatrix.translate( -1.0f, - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glLeft1ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glLeft1ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); // Y display m_glScopeRect2 = QRectF( - (float) m_leftMargin / (float)width(), - (float) (m_botMargin + m_topMargin + scopeHeight) / (float)height(), - (float) scopeWidth / (float)width(), - (float) scopeHeight / (float)height() - ); + (float)m_leftMargin / (float)width(), + (float)(m_botMargin + m_topMargin + scopeHeight) / (float)height(), + (float)scopeWidth / (float)width(), + (float)scopeHeight / (float)height()); m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*(m_botMargin + m_topMargin + scopeHeight) / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glScopeMatrix2.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * (m_botMargin + m_topMargin + scopeHeight) / (float)height())); + m_glScopeMatrix2.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * scopeHeight / (float)height()); m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + m_topMargin + scopeHeight + m_botMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(m_botMargin - 1) / (float) height() - ); + m_glBot2ScaleMatrix.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * (scopeHeight + m_topMargin + scopeHeight + m_botMargin + 1) / (float)height())); + m_glBot2ScaleMatrix.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * (m_botMargin - 1) / (float)height()); m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( + m_glLeft2ScaleMatrix.translate( -1.0f, - 1.0f - ((float) 2*(m_topMargin + scopeHeight + m_botMargin) / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + 1.0f - ((float)2 * (m_topMargin + scopeHeight + m_botMargin) / (float)height())); + m_glLeft2ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); { // X horizontal scale (X1) m_x1Scale.setSize(scopeWidth); m_bot1ScalePixmap = QPixmap( scopeWidth, - m_botMargin - 1 - ); + m_botMargin - 1); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_bot1ScalePixmap.fill(Qt::black); QPainter painter(&m_bot1ScalePixmap); @@ -1401,12 +1361,12 @@ void GLScope::setVerticalDisplays() painter.setFont(font()); tickList = &m_x1Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); } } @@ -1417,11 +1377,10 @@ void GLScope::setVerticalDisplays() m_x2Scale.setSize(scopeWidth); m_bot2ScalePixmap = QPixmap( scopeWidth, - m_botMargin - 1 - ); + m_botMargin - 1); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_bot2ScalePixmap.fill(Qt::black); QPainter painter(&m_bot2ScalePixmap); @@ -1429,12 +1388,12 @@ void GLScope::setVerticalDisplays() painter.setFont(font()); tickList = &m_x2Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); } } @@ -1446,11 +1405,10 @@ void GLScope::setVerticalDisplays() m_left1ScalePixmap = QPixmap( m_leftMargin - 1, - scopeHeight - ); + scopeHeight); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_left1ScalePixmap.fill(Qt::black); QPainter painter(&m_left1ScalePixmap); @@ -1458,12 +1416,12 @@ void GLScope::setVerticalDisplays() painter.setFont(font()); tickList = &m_y1Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent() / 2), tick->text); } } @@ -1475,11 +1433,10 @@ void GLScope::setVerticalDisplays() m_left2ScalePixmap = QPixmap( m_leftMargin - 1, - scopeHeight - ); + scopeHeight); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_left2ScalePixmap.fill(Qt::black); QPainter painter(&m_left2ScalePixmap); @@ -1487,12 +1444,12 @@ void GLScope::setVerticalDisplays() painter.setFont(font()); tickList = &m_y2Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent() / 2), tick->text); } } @@ -1505,45 +1462,38 @@ void GLScope::setHorizontalDisplays() QFontMetrics fm(font()); int M = fm.width("-"); int scopeHeight = height() - m_topMargin - m_botMargin; - int scopeWidth = (width() - m_rightMargin)/2 - m_leftMargin; + int scopeWidth = (width() - m_rightMargin) / 2 - m_leftMargin; // X display m_glScopeRect1 = QRectF( - (float) m_leftMargin / (float) width(), - (float) m_topMargin / (float) height(), - (float) scopeWidth / (float) width(), - (float) scopeHeight / (float) height() - ); + (float)m_leftMargin / (float)width(), + (float)m_topMargin / (float)height(), + (float)scopeWidth / (float)width(), + (float)scopeHeight / (float)height()); m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glScopeMatrix1.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glScopeMatrix1.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * scopeHeight / (float)height()); m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(m_botMargin - 1) / (float) height() - ); + m_glBot1ScaleMatrix.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * (scopeHeight + m_topMargin + 1) / (float)height())); + m_glBot1ScaleMatrix.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * (m_botMargin - 1) / (float)height()); m_glLeft1ScaleMatrix.setToIdentity(); - m_glLeft1ScaleMatrix.translate ( + m_glLeft1ScaleMatrix.translate( -1.0f, - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glLeft1ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glLeft1ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); // Y display @@ -1551,48 +1501,40 @@ void GLScope::setHorizontalDisplays() (float)(m_leftMargin + m_leftMargin + ((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2)) / (float)width(), (float)m_topMargin / (float)height(), (float)((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2) / (float)width(), - (float)(height() - m_topMargin - m_botMargin) / (float)height() - ); + (float)(height() - m_topMargin - m_botMargin) / (float)height()); m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*(m_leftMargin + m_leftMargin + ((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2)) / (float) width()), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2) / (float) width(), - (float) -2*(height() - m_topMargin - m_botMargin) / (float) height() - ); + m_glScopeMatrix2.translate( + -1.0f + ((float)2 * (m_leftMargin + m_leftMargin + ((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2)) / (float)width()), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glScopeMatrix2.scale( + (float)2 * ((width() - m_leftMargin - m_leftMargin - m_rightMargin) / 2) / (float)width(), + (float)-2 * (height() - m_topMargin - m_botMargin) / (float)height()); m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*(m_leftMargin + m_leftMargin + scopeWidth) / (float) width()), - 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeWidth / (float) width(), - (float) -2*(m_botMargin - 1) / (float) height() - ); + m_glBot2ScaleMatrix.translate( + -1.0f + ((float)2 * (m_leftMargin + m_leftMargin + scopeWidth) / (float)width()), + 1.0f - ((float)2 * (scopeHeight + m_topMargin + 1) / (float)height())); + m_glBot2ScaleMatrix.scale( + (float)2 * scopeWidth / (float)width(), + (float)-2 * (m_botMargin - 1) / (float)height()); m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( - -1.0f + (float) 2*(m_leftMargin + scopeWidth) / (float) width(), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glLeft2ScaleMatrix.translate( + -1.0f + (float)2 * (m_leftMargin + scopeWidth) / (float)width(), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glLeft2ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); { // X horizontal scale (X1) m_x1Scale.setSize(scopeWidth); m_bot1ScalePixmap = QPixmap( scopeWidth, - m_botMargin - 1 - ); + m_botMargin - 1); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_bot1ScalePixmap.fill(Qt::black); QPainter painter(&m_bot1ScalePixmap); @@ -1600,12 +1542,12 @@ void GLScope::setHorizontalDisplays() painter.setFont(font()); tickList = &m_x1Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); } } @@ -1617,11 +1559,10 @@ void GLScope::setHorizontalDisplays() m_x2Scale.setSize(scopeWidth); m_bot2ScalePixmap = QPixmap( scopeWidth, - m_botMargin - 1 - ); + m_botMargin - 1); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_bot2ScalePixmap.fill(Qt::black); QPainter painter(&m_bot2ScalePixmap); @@ -1629,12 +1570,12 @@ void GLScope::setHorizontalDisplays() painter.setFont(font()); tickList = &m_x2Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); } } @@ -1646,11 +1587,10 @@ void GLScope::setHorizontalDisplays() m_left1ScalePixmap = QPixmap( m_leftMargin - 1, - scopeHeight - ); + scopeHeight); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_left1ScalePixmap.fill(Qt::black); QPainter painter(&m_left1ScalePixmap); @@ -1658,12 +1598,12 @@ void GLScope::setHorizontalDisplays() painter.setFont(font()); tickList = &m_y1Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent() / 2), tick->text); } } @@ -1675,11 +1615,10 @@ void GLScope::setHorizontalDisplays() m_left2ScalePixmap = QPixmap( m_leftMargin - 1, - scopeHeight - ); + scopeHeight); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_left2ScalePixmap.fill(Qt::black); QPainter painter(&m_left2ScalePixmap); @@ -1687,12 +1626,12 @@ void GLScope::setHorizontalDisplays() painter.setFont(font()); tickList = &m_y2Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent() / 2), tick->text); } } @@ -1705,106 +1644,89 @@ void GLScope::setPolarDisplays() QFontMetrics fm(font()); int M = fm.width("-"); int scopeHeight = height() - m_topMargin - m_botMargin; - int scopeWidth = (width() - m_rightMargin)/2 - m_leftMargin; + int scopeWidth = (width() - m_rightMargin) / 2 - m_leftMargin; int scopeDim = std::min(scopeWidth, scopeHeight); scopeWidth += scopeWidth - scopeDim; // Mixed XY display (left) m_glScopeRect1 = QRectF( - (float) m_leftMargin / (float) width(), - (float) m_topMargin / (float) height(), - (float) (scopeWidth-m_leftMargin) / (float) width(), - (float) scopeHeight / (float) height() - ); + (float)m_leftMargin / (float)width(), + (float)m_topMargin / (float)height(), + (float)(scopeWidth - m_leftMargin) / (float)width(), + (float)scopeHeight / (float)height()); m_glScopeMatrix1.setToIdentity(); - m_glScopeMatrix1.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glScopeMatrix1.scale ( - (float) 2*(scopeWidth-m_leftMargin) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glScopeMatrix1.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glScopeMatrix1.scale( + (float)2 * (scopeWidth - m_leftMargin) / (float)width(), + (float)-2 * scopeHeight / (float)height()); m_glBot1ScaleMatrix.setToIdentity(); - m_glBot1ScaleMatrix.translate ( - -1.0f + ((float) 2*m_leftMargin / (float) width()), - 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) - ); - m_glBot1ScaleMatrix.scale ( - (float) 2*(scopeWidth-m_leftMargin) / (float) width(), - (float) -2*(m_botMargin - 1) / (float) height() - ); + m_glBot1ScaleMatrix.translate( + -1.0f + ((float)2 * m_leftMargin / (float)width()), + 1.0f - ((float)2 * (scopeHeight + m_topMargin + 1) / (float)height())); + m_glBot1ScaleMatrix.scale( + (float)2 * (scopeWidth - m_leftMargin) / (float)width(), + (float)-2 * (m_botMargin - 1) / (float)height()); m_glLeft1ScaleMatrix.setToIdentity(); - m_glLeft1ScaleMatrix.translate ( + m_glLeft1ScaleMatrix.translate( -1.0f, - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glLeft1ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glLeft1ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); m_glRight1ScaleMatrix.setToIdentity(); - m_glRight1ScaleMatrix.translate ( - -1.0f + ((float) 2*scopeWidth / (float) width()), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glRight1ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glRight1ScaleMatrix.translate( + -1.0f + ((float)2 * scopeWidth / (float)width()), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glRight1ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); // Polar XY display (right) m_glScopeRect2 = QRectF( (float)(m_leftMargin + scopeWidth + m_leftMargin) / (float)width(), (float)m_topMargin / (float)height(), - (float) scopeDim / (float)width(), - (float)(height() - m_topMargin - m_botMargin) / (float)height() - ); + (float)scopeDim / (float)width(), + (float)(height() - m_topMargin - m_botMargin) / (float)height()); m_glScopeMatrix2.setToIdentity(); - m_glScopeMatrix2.translate ( - -1.0f + ((float) 2*(m_leftMargin + scopeWidth + m_leftMargin) / (float) width()), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glScopeMatrix2.scale ( - (float) 2*scopeDim / (float) width(), - (float) -2*(height() - m_topMargin - m_botMargin) / (float) height() - ); + m_glScopeMatrix2.translate( + -1.0f + ((float)2 * (m_leftMargin + scopeWidth + m_leftMargin) / (float)width()), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glScopeMatrix2.scale( + (float)2 * scopeDim / (float)width(), + (float)-2 * (height() - m_topMargin - m_botMargin) / (float)height()); m_glBot2ScaleMatrix.setToIdentity(); - m_glBot2ScaleMatrix.translate ( - -1.0f + ((float) 2*(m_leftMargin + m_leftMargin + scopeWidth) / (float) width()), - 1.0f - ((float) 2*(scopeHeight + m_topMargin + 1) / (float) height()) - ); - m_glBot2ScaleMatrix.scale ( - (float) 2*scopeDim / (float) width(), - (float) -2*(m_botMargin - 1) / (float) height() - ); + m_glBot2ScaleMatrix.translate( + -1.0f + ((float)2 * (m_leftMargin + m_leftMargin + scopeWidth) / (float)width()), + 1.0f - ((float)2 * (scopeHeight + m_topMargin + 1) / (float)height())); + m_glBot2ScaleMatrix.scale( + (float)2 * scopeDim / (float)width(), + (float)-2 * (m_botMargin - 1) / (float)height()); m_glLeft2ScaleMatrix.setToIdentity(); - m_glLeft2ScaleMatrix.translate ( - -1.0f + (float) 2*(m_leftMargin + scopeWidth) / (float) width(), - 1.0f - ((float) 2*m_topMargin / (float) height()) - ); - m_glLeft2ScaleMatrix.scale ( - (float) 2*(m_leftMargin-1) / (float) width(), - (float) -2*scopeHeight / (float) height() - ); + m_glLeft2ScaleMatrix.translate( + -1.0f + (float)2 * (m_leftMargin + scopeWidth) / (float)width(), + 1.0f - ((float)2 * m_topMargin / (float)height())); + m_glLeft2ScaleMatrix.scale( + (float)2 * (m_leftMargin - 1) / (float)width(), + (float)-2 * scopeHeight / (float)height()); { // Mixed XY horizontal scale (X1) m_x1Scale.setSize(scopeWidth); m_bot1ScalePixmap = QPixmap( scopeWidth, - m_botMargin - 1 - ); + m_botMargin - 1); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_bot1ScalePixmap.fill(Qt::black); QPainter painter(&m_bot1ScalePixmap); @@ -1812,12 +1734,12 @@ void GLScope::setPolarDisplays() painter.setFont(font()); tickList = &m_x1Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); } } @@ -1828,11 +1750,10 @@ void GLScope::setPolarDisplays() m_x2Scale.setSize(scopeDim); m_bot2ScalePixmap = QPixmap( scopeDim, - m_botMargin - 1 - ); + m_botMargin - 1); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_bot2ScalePixmap.fill(Qt::black); QPainter painter(&m_bot2ScalePixmap); @@ -1840,12 +1761,12 @@ void GLScope::setPolarDisplays() painter.setFont(font()); tickList = &m_x2Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(tick->textPos, fm.height() - 1), tick->text); } } @@ -1857,11 +1778,10 @@ void GLScope::setPolarDisplays() m_left1ScalePixmap = QPixmap( m_leftMargin - 1, - scopeHeight - ); + scopeHeight); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_left1ScalePixmap.fill(Qt::black); QPainter painter(&m_left1ScalePixmap); @@ -1869,12 +1789,12 @@ void GLScope::setPolarDisplays() painter.setFont(font()); tickList = &m_y1Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent() / 2), tick->text); } } @@ -1887,11 +1807,10 @@ void GLScope::setPolarDisplays() m_left2ScalePixmap = QPixmap( m_leftMargin - 1, - scopeHeight - ); + scopeHeight); - const ScaleEngine::TickList* tickList; - const ScaleEngine::Tick* tick; + const ScaleEngine::TickList *tickList; + const ScaleEngine::Tick *tick; m_left2ScalePixmap.fill(Qt::black); QPainter painter(&m_left2ScalePixmap); @@ -1899,12 +1818,12 @@ void GLScope::setPolarDisplays() painter.setFont(font()); tickList = &m_y2Scale.getTickList(); - for(int i = 0; i < tickList->count(); i++) { + for (int i = 0; i < tickList->count(); i++) + { tick = &(*tickList)[i]; - if(tick->major) { - if(tick->textSize > 0) { - painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent()/2), tick->text); - } + + if ((tick->major) && (tick->textSize > 0)) { + painter.drawText(QPointF(m_leftMargin - M - tick->textSize, m_topMargin + scopeHeight - tick->textPos - fm.ascent() / 2), tick->text); } } @@ -1912,9 +1831,9 @@ void GLScope::setPolarDisplays() } // Polar XY vertical scale (Y2) } -void GLScope::setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex) +void GLScope::setYScale(ScaleEngine &scale, uint32_t highlightedTraceIndex) { - ScopeVis::TraceData& traceData = (*m_tracesData)[highlightedTraceIndex]; + ScopeVis::TraceData &traceData = (*m_tracesData)[highlightedTraceIndex]; double amp_range = 2.0 / traceData.m_amp; double amp_ofs = traceData.m_ofs; double pow_floor = -100.0 + traceData.m_ofs * 100.0; @@ -1939,29 +1858,29 @@ void GLScope::setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex) break; case Projector::ProjectionPhase: // Phase or frequency case Projector::ProjectionDPhase: - scale.setRange(Unit::None, -1.0/traceData.m_amp + amp_ofs, 1.0/traceData.m_amp + amp_ofs); + scale.setRange(Unit::None, -1.0 / traceData.m_amp + amp_ofs, 1.0 / traceData.m_amp + amp_ofs); break; case Projector::ProjectionReal: // Linear generic case Projector::ProjectionImag: default: if (amp_range < 1e-6) { - scale.setRange(Unit::None, - amp_range * 5e8 + amp_ofs * 1e9, amp_range * 5e8 + amp_ofs * 1e9); + scale.setRange(Unit::None, -amp_range * 5e8 + amp_ofs * 1e9, amp_range * 5e8 + amp_ofs * 1e9); } else if (amp_range < 1e-3) { - scale.setRange(Unit::None, - amp_range * 5e5 + amp_ofs * 1e6, amp_range * 5e5 + amp_ofs * 1e6); + scale.setRange(Unit::None, -amp_range * 5e5 + amp_ofs * 1e6, amp_range * 5e5 + amp_ofs * 1e6); } else if (amp_range < 1.0) { - scale.setRange(Unit::None, - amp_range * 5e2 + amp_ofs * 1e3, amp_range * 5e2 + amp_ofs * 1e3); + scale.setRange(Unit::None, -amp_range * 5e2 + amp_ofs * 1e3, amp_range * 5e2 + amp_ofs * 1e3); } else { - scale.setRange(Unit::None, - amp_range * 0.5 + amp_ofs, amp_range * 0.5 + amp_ofs); + scale.setRange(Unit::None, -amp_range * 0.5 + amp_ofs, amp_range * 0.5 + amp_ofs); } break; } } void GLScope::drawChannelOverlay( - const QString& text, - const QColor& color, - QPixmap& channelOverlayPixmap, - const QRectF& glScopeRect) + const QString &text, + const QColor &color, + QPixmap &channelOverlayPixmap, + const QRectF &glScopeRect) { if (text.isEmpty()) { return; @@ -1969,11 +1888,11 @@ void GLScope::drawChannelOverlay( QFontMetricsF metrics(m_channelOverlayFont); QRectF textRect = metrics.boundingRect(text); - QRectF overlayRect(0, 0, textRect.width()*1.05f + 4.0f, textRect.height()); + QRectF overlayRect(0, 0, textRect.width() * 1.05f + 4.0f, textRect.height()); channelOverlayPixmap = QPixmap(overlayRect.width(), overlayRect.height()); channelOverlayPixmap.fill(Qt::transparent); QPainter painter(&channelOverlayPixmap); - painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing, false); + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing, false); painter.fillRect(overlayRect, QColor(0, 0, 0, 0x80)); QColor textColor(color); textColor.setAlpha(0xC0); @@ -1986,24 +1905,22 @@ void GLScope::drawChannelOverlay( { GLfloat vtx1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; GLfloat tex1[] = { - 0, 1, - 1, 1, - 1, 0, - 0, 0 - }; + 0, 1, + 1, 1, + 1, 0, + 0, 0}; float shiftX = glScopeRect.width() - ((overlayRect.width() + 4.0f) / width()); float shiftY = 4.0f / height(); float rectX = glScopeRect.x() + shiftX; float rectY = glScopeRect.y() + shiftY; - float rectW = overlayRect.width() / (float) width(); - float rectH = overlayRect.height() / (float) height(); + float rectW = overlayRect.width() / (float)width(); + float rectH = overlayRect.height() / (float)height(); QMatrix4x4 mat; mat.setToIdentity(); @@ -2020,7 +1937,7 @@ void GLScope::tick() } } -void GLScope::connectTimer(const QTimer& timer) +void GLScope::connectTimer(const QTimer &timer) { qDebug() << "GLScope::connectTimer"; disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick())); @@ -2038,4 +1955,3 @@ void GLScope::cleanup() m_glShaderPowerOverlay.cleanup(); //doneCurrent(); } - diff --git a/sdrgui/gui/glscope.h b/sdrgui/gui/glscope.h index 5955cf3a7..ff81427ef 100644 --- a/sdrgui/gui/glscope.h +++ b/sdrgui/gui/glscope.h @@ -56,8 +56,7 @@ public: void connectTimer(const QTimer& timer); void setTraces(std::vector* tracesData, std::vector* traces); - void newTraces(std::vector* traces); - void newTraces(std::vector* traces, int traceIndex); + void newTraces(std::vector* traces, int traceIndex, std::vector* projectionTypes); int getSampleRate() const { return m_sampleRate; } int getTraceSize() const { return m_traceSize; } @@ -79,6 +78,7 @@ public: bool getDataChanged() const { return m_dataChanged; } DisplayMode getDisplayMode() const { return m_displayMode; } void setDisplayXYPoints(bool value) { m_displayXYPoints = value; } + void setDisplayXYPolarGrid(bool value) { m_displayPolGrid = value; } const QAtomicInt& getProcessingTraceIndex() const { return m_processingTraceIndex; } signals: @@ -89,11 +89,13 @@ signals: private: std::vector *m_tracesData; std::vector *m_traces; + std::vector *m_projectionTypes; QAtomicInt m_processingTraceIndex; ScopeVis::TriggerData m_focusedTriggerData; //int m_traceCounter; uint32_t m_bufferIndex; DisplayMode m_displayMode; + bool m_displayPolGrid; QTimer m_timer; QMutex m_mutex; QAtomicInt m_dataChanged; @@ -170,6 +172,13 @@ private: QPixmap& channelOverlayPixmap, const QRectF& glScopeRect); + static bool isPositiveProjection(Projector::ProjectionType& projectionType) + { + return (projectionType == Projector::ProjectionMagLin) + || (projectionType == Projector::ProjectionMagDB) + || (projectionType == Projector::ProjectionMagSq); + } + protected slots: void cleanup(); void tick(); diff --git a/sdrgui/gui/glscopegui.cpp b/sdrgui/gui/glscopegui.cpp index 59cea3014..83ae2066e 100644 --- a/sdrgui/gui/glscopegui.cpp +++ b/sdrgui/gui/glscopegui.cpp @@ -540,6 +540,11 @@ void GLScopeGUI::on_polarPoints_toggled(bool checked) m_glScope->setDisplayXYPoints(checked); } +void GLScopeGUI::on_polarGrid_toggled(bool checked) +{ + m_glScope->setDisplayXYPolarGrid(checked); +} + void GLScopeGUI::on_traceIntensity_valueChanged(int value) { ui->traceIntensity->setToolTip(QString("Trace intensity: %1").arg(value)); diff --git a/sdrgui/gui/glscopegui.h b/sdrgui/gui/glscopegui.h index 0a6e745ba..db26b5916 100644 --- a/sdrgui/gui/glscopegui.h +++ b/sdrgui/gui/glscopegui.h @@ -196,6 +196,7 @@ private slots: void on_verticalXY_toggled(bool checked); void on_polar_toggled(bool checked); void on_polarPoints_toggled(bool checked); + void on_polarGrid_toggled(bool checked); void on_traceIntensity_valueChanged(int value); void on_gridIntensity_valueChanged(int value); void on_time_valueChanged(int value); diff --git a/sdrgui/gui/glscopegui.ui b/sdrgui/gui/glscopegui.ui index bcc06e97e..fa21b2416 100644 --- a/sdrgui/gui/glscopegui.ui +++ b/sdrgui/gui/glscopegui.ui @@ -280,6 +280,21 @@ + + + + Toggle between polar and rectangular grid for XY display + + + + + + + :/gridrect.png + :/gridpolar.png:/gridrect.png + + + diff --git a/sdrgui/resources/gridpolar.png b/sdrgui/resources/gridpolar.png new file mode 100644 index 000000000..112aa9554 Binary files /dev/null and b/sdrgui/resources/gridpolar.png differ diff --git a/sdrgui/resources/gridrect.png b/sdrgui/resources/gridrect.png new file mode 100644 index 000000000..46ecb3846 Binary files /dev/null and b/sdrgui/resources/gridrect.png differ diff --git a/sdrgui/resources/res.qrc b/sdrgui/resources/res.qrc index 897b8261f..b703d3858 100644 --- a/sdrgui/resources/res.qrc +++ b/sdrgui/resources/res.qrc @@ -1,5 +1,7 @@ + gridpolar.png + gridrect.png double_arrow_up.png no_film.png gps.png