From 82d55764a93f9c2745f8f446230144408404cab0 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 26 Feb 2017 06:06:59 +0100 Subject: [PATCH] New scope: changed channel overlay font and set it to trace color --- sdrbase/dsp/scopevisng.cpp | 4 +++- sdrbase/gui/glscopeng.cpp | 20 ++++++++++++++++---- sdrbase/gui/glscopeng.h | 3 ++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/sdrbase/dsp/scopevisng.cpp b/sdrbase/dsp/scopevisng.cpp index e0ab5415d..f3cbb9f7a 100644 --- a/sdrbase/dsp/scopevisng.cpp +++ b/sdrbase/dsp/scopevisng.cpp @@ -471,7 +471,7 @@ int ScopeVisNG::processTraces(const SampleVector::const_iterator& cbegin, const { double avgPow = itCtl->m_sumPow / itCtl->m_nbPow; double peakToAvgPow = itCtl->m_maxPow - avgPow; - itData->m_textOverlay = QString("%1 %2 %3").arg(itCtl->m_maxPow, 0, 'f', 1).arg(avgPow, 0, 'f', 1).arg(peakToAvgPow, 0, 'f', 1); + itData->m_textOverlay = QString("%1 %2 %3").arg(itCtl->m_maxPow, 0, 'f', 1).arg(avgPow, 0, 'f', 1).arg(peakToAvgPow, 4, 'f', 1, ' '); itCtl->m_nbPow = 0; } } @@ -701,6 +701,7 @@ bool ScopeVisNG::handleMessage(const Message& message) bool oneShot = conf.getOneShot(); m_triggerOneShot = oneShot; if (m_triggerWaitForReset && !oneShot) m_triggerWaitForReset = false; + return true; } else if (MsgScopeVisNGMemoryTrace::match(message)) { @@ -715,6 +716,7 @@ bool ScopeVisNG::handleMessage(const Message& message) processMemoryTrace(); } } + return true; } else { diff --git a/sdrbase/gui/glscopeng.cpp b/sdrbase/gui/glscopeng.cpp index bc8522d33..c1854b6eb 100644 --- a/sdrbase/gui/glscopeng.cpp +++ b/sdrbase/gui/glscopeng.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,7 @@ GLScopeNG::GLScopeNG(QWidget* parent) : m_x2Scale.setFont(font()); m_x2Scale.setOrientation(Qt::Horizontal); + m_channelOverlayFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); m_channelOverlayFont.setBold(true); m_channelOverlayFont.setPointSize(font().pointSize()+1); @@ -719,7 +721,11 @@ void GLScopeNG::paintGL() // Paint overlay if any if ((i == m_focusedTraceIndex) && (traceData.m_hasTextOverlay)) { - drawChannelOverlay(traceData.m_textOverlay, m_channelOverlayPixmap1, m_glScopeRect1); + drawChannelOverlay( + traceData.m_textOverlay, + traceData.m_traceColor, + m_channelOverlayPixmap1, + m_glScopeRect1); } } // all traces display } // trace length > 0 @@ -1830,7 +1836,11 @@ void GLScopeNG::setYScale(ScaleEngine& scale, uint32_t highlightedTraceIndex) } } -void GLScopeNG::drawChannelOverlay(const QString& text, QPixmap& channelOverlayPixmap, QRectF& glScopeRect) +void GLScopeNG::drawChannelOverlay( + const QString& text, + const QColor& color, + QPixmap& channelOverlayPixmap, + const QRectF& glScopeRect) { if (text.isEmpty()) { return; @@ -1843,7 +1853,9 @@ void GLScopeNG::drawChannelOverlay(const QString& text, QPixmap& channelOverlayP QPainter painter(&channelOverlayPixmap); painter.setRenderHints(QPainter::Antialiasing|QPainter::TextAntialiasing, false); painter.fillRect(rect, QColor(0, 0, 0, 0x80)); - painter.setPen(QColor(0xff, 0xff, 0xff, 0x80)); + QColor textColor(color); + textColor.setAlpha(0xC0); + painter.setPen(textColor); painter.setFont(m_channelOverlayFont); painter.drawText(QPointF(0, rect.height() - 2.0f), text); painter.end(); @@ -1872,7 +1884,7 @@ void GLScopeNG::drawChannelOverlay(const QString& text, QPixmap& channelOverlayP QMatrix4x4 mat; mat.setToIdentity(); - mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); + mat.translate(-1.0f + 2.0f * rectX, 0.96f - 2.0f * rectY); mat.scale(2.0f * rectW, -2.0f * rectH); m_glShaderPowerOverlay.drawSurface(mat, tex1, vtx1, 4); } diff --git a/sdrbase/gui/glscopeng.h b/sdrbase/gui/glscopeng.h index 0274a452c..c49d07c93 100644 --- a/sdrbase/gui/glscopeng.h +++ b/sdrbase/gui/glscopeng.h @@ -149,8 +149,9 @@ private: void drawChannelOverlay( //!< Draws a text overlay const QString& text, + const QColor& color, QPixmap& channelOverlayPixmap, - QRectF& glScopeRect); + const QRectF& glScopeRect); protected slots: void cleanup();