diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index 7b284bcd5..553481529 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -1163,8 +1163,7 @@ void GLSpectrum::paintGL() void GLSpectrum::drawMarkers() { - QVector4D markerColor(1.0f, 1.0f, 1.0f, 0.3f); - QVector4D markerTextColor(1.0f, 1.0f, 1.0f, 0.8f); + QVector4D lineColor(1.0f, 1.0f, 1.0f, 0.3f); // paint histogram markers if (m_histogramMarkers.size() > 0) @@ -1178,7 +1177,9 @@ void GLSpectrum::drawMarkers() { ypoint.ry() = (m_powerScale.getRangeMax() - m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin]) / m_powerScale.getRange(); - ypoint.ry() = ypoint.ry() > 1 ? 1 : ypoint.ry(); + ypoint.ry() = ypoint.ry() < 0 ? + 0 : ypoint.ry() > 1 ? + 1 : ypoint.ry(); powerStr = displayScaledF( m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin], m_linear ? 'e' : 'f', @@ -1192,18 +1193,19 @@ void GLSpectrum::drawMarkers() (float) m_histogramMarkers.at(i).m_point.x(), 0, (float) m_histogramMarkers.at(i).m_point.x(), 1 }; - m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, h, 2); + m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, lineColor, h, 2); GLfloat v[] { 0, (float) ypoint.y(), 1, (float) ypoint.y() }; - m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, v, 2); + m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, lineColor, v, 2); + QColor textColor = m_histogramMarkers.at(i).m_markerColor; // text if (i == 0) { drawTextOverlay( m_histogramMarkers.at(i).m_frequencyStr, - QColor(255, 255, 255, 192), + textColor, m_textOverlayFont, m_histogramMarkers.at(i).m_point.x() * m_histogramRect.width(), (m_invertedWaterfall || (m_waterfallHeight == 0)) ? m_histogramRect.height() : 0, @@ -1212,7 +1214,7 @@ void GLSpectrum::drawMarkers() m_histogramRect); drawTextOverlay( powerStr, - QColor(255, 255, 255, 192), + textColor, m_textOverlayFont, 0, ypoint.y() * m_histogramRect.height(), @@ -1222,6 +1224,7 @@ void GLSpectrum::drawMarkers() } else { + textColor.setAlpha(192); float power0 = m_histogramMarkers.at(0).m_markerType == SpectrumHistogramMarkerTypePower ? m_currentSpectrum[m_histogramMarkers.at(0).m_fftBin] : m_linear ? m_histogramMarkers.at(0).m_power : CalcDb::dbPower(m_histogramMarkers.at(0).m_power); @@ -1238,7 +1241,7 @@ void GLSpectrum::drawMarkers() drawTextOverlay( m_histogramMarkers.at(i).m_deltaFrequencyStr, - QColor(255, 255, 255, 192), + textColor, m_textOverlayFont, m_histogramMarkers.at(i).m_point.x() * m_histogramRect.width(), (m_invertedWaterfall || (m_waterfallHeight == 0)) ? 0 : m_histogramRect.height(), @@ -1247,7 +1250,7 @@ void GLSpectrum::drawMarkers() m_histogramRect); drawTextOverlay( deltaPowerStr, - QColor(255, 255, 255, 192), + textColor, m_textOverlayFont, m_histogramRect.width(), ypoint.y() * m_histogramRect.height(), @@ -1268,21 +1271,24 @@ void GLSpectrum::drawMarkers() (float) m_waterfallMarkers.at(i).m_point.x(), 0, (float) m_waterfallMarkers.at(i).m_point.x(), 1 }; - m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, markerColor, h, 2); + m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, lineColor, h, 2); GLfloat v[] { 0, (float) m_waterfallMarkers.at(i).m_point.y(), 1, (float) m_waterfallMarkers.at(i).m_point.y() }; - m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, markerColor, v, 2); + m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, lineColor, v, 2); } // text for (int i = 0; i < m_waterfallMarkers.size(); i++) { + QColor textColor = m_waterfallMarkers.at(i).m_markerColor; + textColor.setAlpha(192); + if (i == 0) { drawTextOverlay( m_waterfallMarkers.at(i).m_frequencyStr, - QColor(255, 255, 255, 192), + textColor, m_textOverlayFont, m_waterfallMarkers.at(i).m_point.x() * m_waterfallRect.width(), (!m_invertedWaterfall || (m_histogramHeight == 0)) ? m_waterfallRect.height() : 0, @@ -1291,7 +1297,7 @@ void GLSpectrum::drawMarkers() m_waterfallRect); drawTextOverlay( m_waterfallMarkers.at(i).m_timeStr, - QColor(255, 255, 255, 192), + textColor, m_textOverlayFont, 0, m_waterfallMarkers.at(i).m_point.y() * m_waterfallRect.height(), @@ -1303,7 +1309,7 @@ void GLSpectrum::drawMarkers() { drawTextOverlay( m_waterfallMarkers.at(i).m_deltaFrequencyStr, - QColor(255, 255, 255, 192), + textColor, m_textOverlayFont, m_waterfallMarkers.at(i).m_point.x() * m_waterfallRect.width(), (!m_invertedWaterfall || (m_histogramHeight == 0)) ? 0 : m_waterfallRect.height(), @@ -1312,7 +1318,7 @@ void GLSpectrum::drawMarkers() m_waterfallRect); drawTextOverlay( m_waterfallMarkers.at(i).m_deltaTimeStr, - QColor(255, 255, 255, 192), + textColor, m_textOverlayFont, m_waterfallRect.width(), m_waterfallMarkers.at(i).m_point.y() * m_waterfallRect.height(), diff --git a/sdrgui/gui/spectrummarkers.h b/sdrgui/gui/spectrummarkers.h index a7f5118b1..e3f08f3aa 100644 --- a/sdrgui/gui/spectrummarkers.h +++ b/sdrgui/gui/spectrummarkers.h @@ -23,6 +23,7 @@ #include #include +#include enum SpectrumHistogramMarkerType { SpectrumHistogramMarkerTypeManual, @@ -36,6 +37,7 @@ struct SpectrumHistogramMarker int m_fftBin; float m_power; SpectrumHistogramMarkerType m_markerType; + QColor m_markerColor; QString m_frequencyStr; QString m_powerStr; QString m_deltaFrequencyStr; @@ -48,6 +50,7 @@ struct SpectrumHistogramMarker m_fftBin(0), m_power(0), m_markerType(SpectrumHistogramMarkerTypeManual), + m_markerColor(QColorConstants::White), m_frequencyStr(), m_powerStr(), m_deltaFrequencyStr(), @@ -60,6 +63,7 @@ struct SpectrumHistogramMarker int fftBin, float power, SpectrumHistogramMarkerType markerType, + QColor markerColor, const QString& frequencyStr, const QString& powerStr, const QString& deltaFrequencyStr, @@ -70,6 +74,7 @@ struct SpectrumHistogramMarker m_fftBin(fftBin), m_power(power), m_markerType(markerType), + m_markerColor(markerColor), m_frequencyStr(frequencyStr), m_powerStr(powerStr), m_deltaFrequencyStr(deltaFrequencyStr), @@ -85,6 +90,7 @@ struct SpectrumWaterfallMarker QPointF m_point; float m_frequency; float m_time; + QColor m_markerColor; QString m_frequencyStr; QString m_timeStr; QString m_deltaFrequencyStr; @@ -95,6 +101,7 @@ struct SpectrumWaterfallMarker m_point(0, 0), m_frequency(0), m_time(0), + m_markerColor(QColorConstants::White), m_frequencyStr(), m_timeStr(), m_deltaFrequencyStr(), @@ -105,6 +112,7 @@ struct SpectrumWaterfallMarker const QPointF& point, float frequency, float time, + QColor markerColor, const QString& frequencyStr, const QString& timeStr, const QString& deltaFrequencyStr, @@ -113,6 +121,7 @@ struct SpectrumWaterfallMarker m_point(point), m_frequency(frequency), m_time(time), + m_markerColor(markerColor), m_frequencyStr(frequencyStr), m_timeStr(timeStr), m_deltaFrequencyStr(deltaFrequencyStr), diff --git a/sdrgui/gui/spectrummarkersdialog.cpp b/sdrgui/gui/spectrummarkersdialog.cpp index eda9ee68d..a20d483bf 100644 --- a/sdrgui/gui/spectrummarkersdialog.cpp +++ b/sdrgui/gui/spectrummarkersdialog.cpp @@ -16,6 +16,8 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#include + #include "util/db.h" #include "spectrummarkersdialog.h" @@ -68,6 +70,9 @@ void SpectrumMarkersDialog::displayHistogramMarker() float powerDB = CalcDb::dbPower(m_histogramMarkers[m_histogramMarkerIndex].m_power); ui->fixedPower->setValue(powerDB*10); ui->fixedPowerText->setText(QString::number(powerDB, 'f', 1)); + int r,g,b,a; + m_histogramMarkers[m_histogramMarkerIndex].m_markerColor.getRgb(&r, &g, &b, &a); + ui->markerColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); } } @@ -81,6 +86,37 @@ void SpectrumMarkersDialog::on_markerFrequency_changed(qint64 value) emit updateHistogram(); } +void SpectrumMarkersDialog::on_centerFrequency_clicked() +{ + if (m_histogramMarkers.size() == 0) { + return; + } + + m_histogramMarkers[m_histogramMarkerIndex].m_frequency = m_centerFrequency; + displayHistogramMarker(); + emit updateHistogram(); +} + +void SpectrumMarkersDialog::on_markerColor_clicked() +{ + if (m_histogramMarkers.size() == 0) { + return; + } + + QColor newColor = QColorDialog::getColor( + m_histogramMarkers[m_histogramMarkerIndex].m_markerColor, + this, + tr("Select Color for marker"), + QColorDialog::DontUseNativeDialog + ); + + if (newColor.isValid()) // user clicked OK and selected a color + { + m_histogramMarkers[m_histogramMarkerIndex].m_markerColor = newColor; + displayHistogramMarker(); + } +} + void SpectrumMarkersDialog::on_fixedPower_valueChanged(int value) { if (m_histogramMarkers.size() == 0) { @@ -103,25 +139,25 @@ void SpectrumMarkersDialog::on_marker_valueChanged(int value) displayHistogramMarker(); } -void SpectrumMarkersDialog::on_setReference_clicked(bool checked) +void SpectrumMarkersDialog::on_setReference_clicked() { - (void) checked; - if ((m_histogramMarkerIndex == 0) || (m_histogramMarkers.size() < 2)) { return; } SpectrumHistogramMarker marker0 = m_histogramMarkers.at(0); + QColor color0 = marker0.m_markerColor; // do not exchange colors + QColor colorI = m_histogramMarkers[m_histogramMarkerIndex].m_markerColor; m_histogramMarkers[0] = m_histogramMarkers[m_histogramMarkerIndex]; + m_histogramMarkers[0].m_markerColor = color0; m_histogramMarkers[m_histogramMarkerIndex] = marker0; + m_histogramMarkers[m_histogramMarkerIndex].m_markerColor = colorI; displayHistogramMarker(); emit updateHistogram(); } -void SpectrumMarkersDialog::on_markerAdd_clicked(bool checked) +void SpectrumMarkersDialog::on_markerAdd_clicked() { - (void) checked; - if (m_histogramMarkers.size() == SpectrumHistogramMarker::m_maxNbOfMarkers) { return; } @@ -134,10 +170,8 @@ void SpectrumMarkersDialog::on_markerAdd_clicked(bool checked) displayHistogramMarker(); } -void SpectrumMarkersDialog::on_markerDel_clicked(bool checked) +void SpectrumMarkersDialog::on_markerDel_clicked() { - (void) checked; - if (m_histogramMarkers.size() == 0) { return; } diff --git a/sdrgui/gui/spectrummarkersdialog.h b/sdrgui/gui/spectrummarkersdialog.h index 446f12259..1ab6150aa 100644 --- a/sdrgui/gui/spectrummarkersdialog.h +++ b/sdrgui/gui/spectrummarkersdialog.h @@ -54,11 +54,13 @@ private: private slots: void on_markerFrequency_changed(qint64 value); + void on_centerFrequency_clicked(); + void on_markerColor_clicked(); void on_fixedPower_valueChanged(int value); void on_marker_valueChanged(int value); - void on_setReference_clicked(bool checked); - void on_markerAdd_clicked(bool checked); - void on_markerDel_clicked(bool checked); + void on_setReference_clicked(); + void on_markerAdd_clicked(); + void on_markerDel_clicked(); void on_powerMode_currentIndexChanged(int index); signals: diff --git a/sdrgui/gui/spectrummarkersdialog.ui b/sdrgui/gui/spectrummarkersdialog.ui index 529cf2e0f..2b1a4995e 100644 --- a/sdrgui/gui/spectrummarkersdialog.ui +++ b/sdrgui/gui/spectrummarkersdialog.ui @@ -6,7 +6,7 @@ 0 0 - 324 + 364 125 @@ -23,7 +23,7 @@ - + @@ -103,10 +103,48 @@ + + + + + 24 + 24 + + + + Set marker as reference (index 0) + + + C + + + + + + + + 16 + 16 + + + + + 16 + 16 + + + + Current marker color (click to change) + + + + + + - + @@ -167,7 +205,7 @@ Set marker as reference (index 0) - R + 0 @@ -406,6 +444,11 @@
gui/valuedialz.h
1 + + ClickableLabel + QLabel +
gui/clickablelabel.h
+
buttonBox