diff --git a/CMakeLists.txt b/CMakeLists.txt index acecc559f..ecaf08b76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,6 +139,7 @@ set(sdrbase_SOURCES sdrbase/gui/basicchannelsettingswidget.cpp sdrbase/gui/buttonswitch.cpp sdrbase/gui/channelwindow.cpp + sdrbase/gui/clickablelabel.cpp sdrbase/gui/colormapper.cpp sdrbase/gui/cwkeyergui.cpp sdrbase/gui/glscope.cpp diff --git a/sdrbase/dsp/scopevisng.h b/sdrbase/dsp/scopevisng.h index c731d5522..85549d238 100644 --- a/sdrbase/dsp/scopevisng.h +++ b/sdrbase/dsp/scopevisng.h @@ -19,6 +19,7 @@ #define SDRBASE_DSP_SCOPEVISNG_H_ #include +#include #include #include @@ -52,6 +53,10 @@ public: float m_ofs; //!< Offset factor int m_traceDelay; //!< Trace delay in number of samples float m_triggerDisplayLevel; //!< Displayable trigger display level in -1:+1 scale. Off scale if not displayable. + QColor m_traceColor; //!< Trace display color + float m_traceColorR; //!< Trace display color - red shortcut + float m_traceColorG; //!< Trace display color - green shortcut + float m_traceColorB; //!< Trace display color - blue shortcut TraceData() : m_projectionType(ProjectionReal), @@ -59,10 +64,23 @@ public: m_amp(1.0f), m_ofs(0.0f), m_traceDelay(0), - m_triggerDisplayLevel(2.0) // OVer scale by default (2.0) - {} + m_triggerDisplayLevel(2.0), // OVer scale by default (2.0) + m_traceColor(255,255,64) + { + setColor(m_traceColor); + } + + void setColor(QColor color) { + m_traceColor = color; + qreal r,g,b,a; + m_traceColor.getRgbF(&r, &g, &b, &a); + m_traceColorR = r; + m_traceColorG = g; + m_traceColorB = b; + } }; + struct TriggerData { ProjectionType m_projectionType; //!< Complex to real projection type @@ -114,13 +132,18 @@ public: { if (triggerIndex < m_triggerConditions.size()) { - qDebug() << "copeVisNG::getTriggerData:" - << " index: " << triggerIndex - << " projection: " << (int) m_triggerConditions[triggerIndex].m_triggerData.m_projectionType; triggerData = m_triggerConditions[triggerIndex].m_triggerData; } } + void getTraceData(TraceData& traceData, uint32_t traceIndex) + { + if (traceIndex < m_traces.m_tracesData.size()) + { + traceData = m_traces.m_tracesData[traceIndex]; + } + } + virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly); virtual void start(); virtual void stop(); diff --git a/sdrbase/gui/clickablelabel.cpp b/sdrbase/gui/clickablelabel.cpp new file mode 100644 index 000000000..6d7c7c360 --- /dev/null +++ b/sdrbase/gui/clickablelabel.cpp @@ -0,0 +1,39 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 F4EXB // +// written by Edouard Griffiths // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "gui/clickablelabel.h" + +ClickableLabel::ClickableLabel(QWidget* parent) + : QLabel(parent) +{ +} + +ClickableLabel::ClickableLabel(const QString& text, QWidget* parent) + : QLabel(parent) +{ + setText(text); +} + +ClickableLabel::~ClickableLabel() +{ +} + +void ClickableLabel::mousePressEvent(QMouseEvent* event) +{ + emit clicked(); +} + diff --git a/sdrbase/gui/clickablelabel.h b/sdrbase/gui/clickablelabel.h new file mode 100644 index 000000000..93ae151a5 --- /dev/null +++ b/sdrbase/gui/clickablelabel.h @@ -0,0 +1,38 @@ +/////////////////////////////////////////////////////////////////////////////////// +// Copyright (C) 2017 F4EXB // +// written by Edouard Griffiths // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation as version 3 of the License, or // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License V3 for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program. If not, see . // +/////////////////////////////////////////////////////////////////////////////////// + +#ifndef SDRBASE_GUI_CLICKABLELABEL_H_ +#define SDRBASE_GUI_CLICKABLELABEL_H_ + +#include +#include + +class ClickableLabel : public QLabel +{ +Q_OBJECT +public: + explicit ClickableLabel( QWidget* parent=0 ); + explicit ClickableLabel( const QString& text="", QWidget* parent=0 ); + ~ClickableLabel(); +signals: + void clicked(); +protected: + void mousePressEvent(QMouseEvent* event); +}; + + +#endif /* SDRBASE_GUI_CLICKABLELABEL_H_ */ diff --git a/sdrbase/gui/glscopeng.cpp b/sdrbase/gui/glscopeng.cpp index 70080d9dc..920b3f515 100644 --- a/sdrbase/gui/glscopeng.cpp +++ b/sdrbase/gui/glscopeng.cpp @@ -308,7 +308,8 @@ void GLScopeNG::paintGL() //float rectH = -(m_glScopeRect1.height() / 2.0f) * traceData.m_amp; float rectH = -m_glScopeRect1.height() / 2.0f; - QVector4D color(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0f); + //QVector4D color(1.0f, 1.0f, 0.25f, m_displayTraceIntensity / 100.0f); + QVector4D color(traceData.m_traceColorR, traceData.m_traceColorG, traceData.m_traceColorB, m_displayTraceIntensity / 100.0f); QMatrix4x4 mat; mat.setToIdentity(); mat.translate(-1.0f + 2.0f * rectX, 1.0f - 2.0f * rectY); diff --git a/sdrbase/gui/glscopenggui.cpp b/sdrbase/gui/glscopenggui.cpp index 30f76c44e..6faa085c8 100644 --- a/sdrbase/gui/glscopenggui.cpp +++ b/sdrbase/gui/glscopenggui.cpp @@ -15,6 +15,8 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#include + #include "glscopenggui.h" #include "glscopeng.h" #include "ui_glscopenggui.h" @@ -37,6 +39,8 @@ GLScopeNGGUI::GLScopeNGGUI(QWidget* parent) : setEnabled(false); ui->setupUi(this); ui->trigDelayFine->setMaximum(ScopeVisNG::m_traceChunkSize / 10.0); + ui->traceColor->setStyleSheet("QLabel { background-color : rgb(255,255,64); }"); + m_focusedTraceColor.setRgb(255,255,64); } GLScopeNGGUI::~GLScopeNGGUI() @@ -329,6 +333,17 @@ void GLScopeNGGUI::on_traceDelay_valueChanged(int value) // TODO } +void GLScopeNGGUI::on_traceColor_clicked() +{ + qDebug("GLScopeNGGUI::on_traceColor_clicked"); + QColor newColor = QColorDialog::getColor(); + m_focusedTraceColor = newColor; + int r,g,b,a; + m_focusedTraceColor.getRgb(&r, &g, &b, &a); + ui->traceColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); + changeCurrentTrace(); +} + void GLScopeNGGUI::on_trigMode_currentIndexChanged(int index) { setTrigLevelDisplay(); @@ -689,6 +704,8 @@ void GLScopeNGGUI::fillTraceData(ScopeVisNG::TraceData& traceData) } else { traceData.m_ofs = ((10.0 * ui->ofsCoarse->value()) + (ui->ofsFine->value() / 20.0)) / 1000.0f; } + + traceData.setColor(m_focusedTraceColor); } void GLScopeNGGUI::fillTriggerData(ScopeVisNG::TriggerData& triggerData) diff --git a/sdrbase/gui/glscopenggui.h b/sdrbase/gui/glscopenggui.h index 1a027fd26..6b1d719ce 100644 --- a/sdrbase/gui/glscopenggui.h +++ b/sdrbase/gui/glscopenggui.h @@ -60,6 +60,7 @@ private: int m_timeBase; int m_timeOffset; int m_traceLenMult; + QColor m_focusedTraceColor; static const double amps[11]; @@ -107,6 +108,7 @@ private slots: void on_ofsCoarse_valueChanged(int value); void on_ofsFine_valueChanged(int value); void on_traceDelay_valueChanged(int value); + void on_traceColor_clicked(); // Third row void on_trig_valueChanged(int value); void on_trigAdd_clicked(bool checked); diff --git a/sdrbase/gui/glscopenggui.ui b/sdrbase/gui/glscopenggui.ui index 4d3e96299..0c76474da 100644 --- a/sdrbase/gui/glscopenggui.ui +++ b/sdrbase/gui/glscopenggui.ui @@ -903,6 +903,25 @@ kS/s + + + + + 16 + 16 + + + + + 16 + 16 + + + + + + + @@ -1612,6 +1631,11 @@ kS/s QToolButton
gui/buttonswitch.h
+ + ClickableLabel + QLabel +
gui/clickablelabel.h
+
diff --git a/sdrbase/sdrbase.pro b/sdrbase/sdrbase.pro index f5612645e..32181cd49 100644 --- a/sdrbase/sdrbase.pro +++ b/sdrbase/sdrbase.pro @@ -82,6 +82,7 @@ SOURCES += mainwindow.cpp\ gui/basicchannelsettingswidget.cpp\ gui/buttonswitch.cpp\ gui/channelwindow.cpp\ + gui/clickablelabel.cpp\ gui/colormapper.cpp\ gui/cwkeyergui.cpp\ gui/glscope.cpp\ @@ -188,6 +189,7 @@ HEADERS += mainwindow.h\ gui/basicchannelsettingswidget.h\ gui/buttonswitch.h\ gui/channelwindow.h\ + gui/clickablelabel.h\ gui/colormapper.h\ gui/cwkeyergui.h\ gui/glscope.h\