1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-01 12:37:11 -05:00

Spectrum markers: implemented histogram markers display enable

This commit is contained in:
f4exb 2021-08-04 19:28:52 +02:00
parent 7a00e51dc6
commit deafa0833b
8 changed files with 152 additions and 8 deletions

View File

@ -37,6 +37,12 @@ public:
AvgModeMax AvgModeMax
}; };
enum MarkersDisplay
{
MarkersDisplayNone,
MarkersDisplaySpectrum
};
int m_fftSize; int m_fftSize;
int m_fftOverlap; int m_fftOverlap;
FFTWindow::Function m_fftWindow; FFTWindow::Function m_fftWindow;

View File

@ -41,6 +41,7 @@ const float GLSpectrum::m_maxFrequencyZoom = 10.0f;
GLSpectrum::GLSpectrum(QWidget* parent) : GLSpectrum::GLSpectrum(QWidget* parent) :
QGLWidget(parent), QGLWidget(parent),
m_markersDisplay(SpectrumSettings::MarkersDisplaySpectrum),
m_cursorState(CSNormal), m_cursorState(CSNormal),
m_cursorChannel(0), m_cursorChannel(0),
m_spectrumVis(nullptr), m_spectrumVis(nullptr),
@ -1019,7 +1020,9 @@ void GLSpectrum::paintGL()
} }
} }
drawMarkers(); if (m_markersDisplay == SpectrumSettings::MarkersDisplaySpectrum) {
drawSpectrumMarkers();
}
// paint waterfall grid // paint waterfall grid
if (m_displayWaterfall && m_displayGrid) if (m_displayWaterfall && m_displayGrid)
@ -1166,7 +1169,7 @@ void GLSpectrum::paintGL()
m_mutex.unlock(); m_mutex.unlock();
} }
void GLSpectrum::drawMarkers() void GLSpectrum::drawSpectrumMarkers()
{ {
QVector4D lineColor(1.0f, 1.0f, 1.0f, 0.3f); QVector4D lineColor(1.0f, 1.0f, 1.0f, 0.3f);
@ -1175,6 +1178,10 @@ void GLSpectrum::drawMarkers()
{ {
for (int i = 0; i < m_histogramMarkers.size(); i++) for (int i = 0; i < m_histogramMarkers.size(); i++)
{ {
if (!m_histogramMarkers.at(i).m_show) {
continue;
}
QPointF ypoint = m_histogramMarkers.at(i).m_point; QPointF ypoint = m_histogramMarkers.at(i).m_point;
QString powerStr = m_histogramMarkers.at(i).m_powerStr; QString powerStr = m_histogramMarkers.at(i).m_powerStr;
@ -1307,6 +1314,10 @@ void GLSpectrum::drawMarkers()
// crosshairs // crosshairs
for (int i = 0; i < m_waterfallMarkers.size(); i++) for (int i = 0; i < m_waterfallMarkers.size(); i++)
{ {
if (!m_waterfallMarkers.at(i).m_show) {
continue;
}
GLfloat h[] { GLfloat h[] {
(float) m_waterfallMarkers.at(i).m_point.x(), 0, (float) m_waterfallMarkers.at(i).m_point.x(), 0,
(float) m_waterfallMarkers.at(i).m_point.x(), 1 (float) m_waterfallMarkers.at(i).m_point.x(), 1
@ -1317,10 +1328,10 @@ void GLSpectrum::drawMarkers()
1, (float) m_waterfallMarkers.at(i).m_point.y() 1, (float) m_waterfallMarkers.at(i).m_point.y()
}; };
m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, lineColor, v, 2); m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, lineColor, v, 2);
} // }
// text // text
for (int i = 0; i < m_waterfallMarkers.size(); i++) // for (int i = 0; i < m_waterfallMarkers.size(); i++)
{ // {
QColor textColor = m_waterfallMarkers.at(i).m_markerColor; QColor textColor = m_waterfallMarkers.at(i).m_markerColor;
textColor.setAlpha(192); textColor.setAlpha(192);

View File

@ -34,6 +34,7 @@
#include "gui/glshadertextured.h" #include "gui/glshadertextured.h"
#include "gui/spectrummarkers.h" #include "gui/spectrummarkers.h"
#include "dsp/channelmarker.h" #include "dsp/channelmarker.h"
#include "dsp/spectrumsettings.h"
#include "export.h" #include "export.h"
#include "util/incrementalarray.h" #include "util/incrementalarray.h"
#include "util/message.h" #include "util/message.h"
@ -162,6 +163,7 @@ public:
void setWaterfallMarkers(const QList<SpectrumWaterfallMarker>& waterfallMarkers); void setWaterfallMarkers(const QList<SpectrumWaterfallMarker>& waterfallMarkers);
void updateHistogramMarkers(); void updateHistogramMarkers();
void updateWaterfallMarkers(); void updateWaterfallMarkers();
SpectrumSettings::MarkersDisplay& getMarkersDisplay() { return m_markersDisplay; }
private: private:
struct ChannelMarkerState { struct ChannelMarkerState {
@ -190,6 +192,7 @@ private:
QList<SpectrumHistogramMarker> m_histogramMarkers; QList<SpectrumHistogramMarker> m_histogramMarkers;
QList<SpectrumWaterfallMarker> m_waterfallMarkers; QList<SpectrumWaterfallMarker> m_waterfallMarkers;
SpectrumSettings::MarkersDisplay m_markersDisplay;
CursorState m_cursorState; CursorState m_cursorState;
int m_cursorChannel; int m_cursorChannel;
@ -296,7 +299,7 @@ private:
void initializeGL(); void initializeGL();
void resizeGL(int width, int height); void resizeGL(int width, int height);
void paintGL(); void paintGL();
void drawMarkers(); void drawSpectrumMarkers();
void stopDrag(); void stopDrag();
void applyChanges(); void applyChanges();

View File

@ -343,6 +343,7 @@ void GLSpectrumGUI::on_markers_clicked(bool checked)
SpectrumMarkersDialog markersDialog( SpectrumMarkersDialog markersDialog(
m_glSpectrum->getHistogramMarkers(), m_glSpectrum->getHistogramMarkers(),
m_glSpectrum->getWaterfallMarkers(), m_glSpectrum->getWaterfallMarkers(),
m_glSpectrum->getMarkersDisplay(),
this this
); );

View File

@ -41,6 +41,7 @@ struct SpectrumHistogramMarker
float m_powerMax; float m_powerMax;
SpectrumHistogramMarkerType m_markerType; SpectrumHistogramMarkerType m_markerType;
QColor m_markerColor; QColor m_markerColor;
bool m_show;
QString m_frequencyStr; QString m_frequencyStr;
QString m_powerStr; QString m_powerStr;
QString m_deltaFrequencyStr; QString m_deltaFrequencyStr;
@ -56,6 +57,7 @@ struct SpectrumHistogramMarker
m_powerMax(0), m_powerMax(0),
m_markerType(SpectrumHistogramMarkerTypeManual), m_markerType(SpectrumHistogramMarkerTypeManual),
m_markerColor(QColorConstants::White), m_markerColor(QColorConstants::White),
m_show(true),
m_frequencyStr(), m_frequencyStr(),
m_powerStr(), m_powerStr(),
m_deltaFrequencyStr(), m_deltaFrequencyStr(),
@ -71,6 +73,7 @@ struct SpectrumHistogramMarker
float powerMax, float powerMax,
SpectrumHistogramMarkerType markerType, SpectrumHistogramMarkerType markerType,
QColor markerColor, QColor markerColor,
bool show,
const QString& frequencyStr, const QString& frequencyStr,
const QString& powerStr, const QString& powerStr,
const QString& deltaFrequencyStr, const QString& deltaFrequencyStr,
@ -84,6 +87,7 @@ struct SpectrumHistogramMarker
m_powerMax(powerMax), m_powerMax(powerMax),
m_markerType(markerType), m_markerType(markerType),
m_markerColor(markerColor), m_markerColor(markerColor),
m_show(show),
m_frequencyStr(frequencyStr), m_frequencyStr(frequencyStr),
m_powerStr(powerStr), m_powerStr(powerStr),
m_deltaFrequencyStr(deltaFrequencyStr), m_deltaFrequencyStr(deltaFrequencyStr),
@ -100,6 +104,7 @@ struct SpectrumWaterfallMarker
float m_frequency; float m_frequency;
float m_time; float m_time;
QColor m_markerColor; QColor m_markerColor;
bool m_show;
QString m_frequencyStr; QString m_frequencyStr;
QString m_timeStr; QString m_timeStr;
QString m_deltaFrequencyStr; QString m_deltaFrequencyStr;
@ -111,6 +116,7 @@ struct SpectrumWaterfallMarker
m_frequency(0), m_frequency(0),
m_time(0), m_time(0),
m_markerColor(QColorConstants::White), m_markerColor(QColorConstants::White),
m_show(true),
m_frequencyStr(), m_frequencyStr(),
m_timeStr(), m_timeStr(),
m_deltaFrequencyStr(), m_deltaFrequencyStr(),
@ -122,6 +128,7 @@ struct SpectrumWaterfallMarker
float frequency, float frequency,
float time, float time,
QColor markerColor, QColor markerColor,
bool show,
const QString& frequencyStr, const QString& frequencyStr,
const QString& timeStr, const QString& timeStr,
const QString& deltaFrequencyStr, const QString& deltaFrequencyStr,
@ -131,6 +138,7 @@ struct SpectrumWaterfallMarker
m_frequency(frequency), m_frequency(frequency),
m_time(time), m_time(time),
m_markerColor(markerColor), m_markerColor(markerColor),
m_show(show),
m_frequencyStr(frequencyStr), m_frequencyStr(frequencyStr),
m_timeStr(timeStr), m_timeStr(timeStr),
m_deltaFrequencyStr(deltaFrequencyStr), m_deltaFrequencyStr(deltaFrequencyStr),

View File

@ -27,11 +27,13 @@
SpectrumMarkersDialog::SpectrumMarkersDialog( SpectrumMarkersDialog::SpectrumMarkersDialog(
QList<SpectrumHistogramMarker>& histogramMarkers, QList<SpectrumHistogramMarker>& histogramMarkers,
QList<SpectrumWaterfallMarker>& waterfallMarkers, QList<SpectrumWaterfallMarker>& waterfallMarkers,
SpectrumSettings::MarkersDisplay& markersDisplay,
QWidget* parent) : QWidget* parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::SpectrumMarkersDialog), ui(new Ui::SpectrumMarkersDialog),
m_histogramMarkers(histogramMarkers), m_histogramMarkers(histogramMarkers),
m_waterfallMarkers(waterfallMarkers), m_waterfallMarkers(waterfallMarkers),
m_markersDisplay(markersDisplay),
m_histogramMarkerIndex(0), m_histogramMarkerIndex(0),
m_waterfallMarkerIndex(0), m_waterfallMarkerIndex(0),
m_centerFrequency(0), m_centerFrequency(0),
@ -44,6 +46,7 @@ SpectrumMarkersDialog::SpectrumMarkersDialog(
ui->wMarkerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->wMarkerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->wMarkerFrequency->setValueRange(false, 10, -9999999999L, 9999999999L); ui->wMarkerFrequency->setValueRange(false, 10, -9999999999L, 9999999999L);
ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1); ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1);
ui->showSelect->setCurrentIndex((int) m_markersDisplay);
displayHistogramMarker(); displayHistogramMarker();
displayWaterfallMarker(); displayWaterfallMarker();
} }
@ -59,6 +62,7 @@ void SpectrumMarkersDialog::displayHistogramMarker()
ui->markerFrequency->setEnabled(false); ui->markerFrequency->setEnabled(false);
ui->powerMode->setEnabled(false); ui->powerMode->setEnabled(false);
ui->fixedPower->setEnabled(false); ui->fixedPower->setEnabled(false);
ui->showMarker->setEnabled(false);
ui->markerText->setText("-"); ui->markerText->setText("-");
ui->fixedPower->setValue(0); ui->fixedPower->setValue(0);
ui->fixedPowerText->setText(tr("0.0")); ui->fixedPowerText->setText(tr("0.0"));
@ -69,6 +73,7 @@ void SpectrumMarkersDialog::displayHistogramMarker()
ui->markerFrequency->setEnabled(true); ui->markerFrequency->setEnabled(true);
ui->powerMode->setEnabled(true); ui->powerMode->setEnabled(true);
ui->fixedPower->setEnabled(true); ui->fixedPower->setEnabled(true);
ui->showMarker->setEnabled(true);
ui->markerText->setText(tr("%1").arg(m_histogramMarkerIndex)); ui->markerText->setText(tr("%1").arg(m_histogramMarkerIndex));
ui->markerFrequency->setValue(m_histogramMarkers[m_histogramMarkerIndex].m_frequency); ui->markerFrequency->setValue(m_histogramMarkers[m_histogramMarkerIndex].m_frequency);
ui->powerMode->setCurrentIndex((int) m_histogramMarkers[m_histogramMarkerIndex].m_markerType); ui->powerMode->setCurrentIndex((int) m_histogramMarkers[m_histogramMarkerIndex].m_markerType);
@ -78,6 +83,7 @@ void SpectrumMarkersDialog::displayHistogramMarker()
int r,g,b,a; int r,g,b,a;
m_histogramMarkers[m_histogramMarkerIndex].m_markerColor.getRgb(&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)); ui->markerColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b));
ui->showMarker->setChecked(m_histogramMarkers[m_histogramMarkerIndex].m_show);
} }
} }
@ -90,6 +96,7 @@ void SpectrumMarkersDialog::displayWaterfallMarker()
ui->timeCoarse->setEnabled(false); ui->timeCoarse->setEnabled(false);
ui->timeFine->setEnabled(false); ui->timeFine->setEnabled(false);
ui->timeExp->setEnabled(false); ui->timeExp->setEnabled(false);
ui->wShowMarker->setEnabled(false);
ui->wMarkerText->setText("-"); ui->wMarkerText->setText("-");
ui->timeCoarse->setValue(0); ui->timeCoarse->setValue(0);
ui->timeFine->setValue(0); ui->timeFine->setValue(0);
@ -104,6 +111,7 @@ void SpectrumMarkersDialog::displayWaterfallMarker()
ui->timeCoarse->setEnabled(true); ui->timeCoarse->setEnabled(true);
ui->timeFine->setEnabled(true); ui->timeFine->setEnabled(true);
ui->timeExp->setEnabled(true); ui->timeExp->setEnabled(true);
ui->wShowMarker->setEnabled(true);
ui->wMarkerText->setText(tr("%1").arg(m_waterfallMarkerIndex)); ui->wMarkerText->setText(tr("%1").arg(m_waterfallMarkerIndex));
ui->wMarkerFrequency->setValue(m_waterfallMarkers[m_waterfallMarkerIndex].m_frequency); ui->wMarkerFrequency->setValue(m_waterfallMarkers[m_waterfallMarkerIndex].m_frequency);
int r,g,b,a; int r,g,b,a;
@ -175,6 +183,15 @@ void SpectrumMarkersDialog::on_markerColor_clicked()
} }
} }
void SpectrumMarkersDialog::on_showMarker_clicked(bool clicked)
{
if (m_histogramMarkers.size() == 0) {
return;
}
m_histogramMarkers[m_histogramMarkerIndex].m_show = clicked;
}
void SpectrumMarkersDialog::on_fixedPower_valueChanged(int value) void SpectrumMarkersDialog::on_fixedPower_valueChanged(int value)
{ {
if (m_histogramMarkers.size() == 0) { if (m_histogramMarkers.size() == 0) {
@ -247,7 +264,15 @@ void SpectrumMarkersDialog::on_powerMode_currentIndexChanged(int index)
return; return;
} }
m_histogramMarkers[m_histogramMarkerIndex].m_markerType = (SpectrumHistogramMarkerType) index; SpectrumHistogramMarkerType newType = (SpectrumHistogramMarkerType) index;
if ((m_histogramMarkers[m_histogramMarkerIndex].m_markerType != newType)
&& (newType == SpectrumHistogramMarkerTypePowerMax))
{
m_histogramMarkers[m_histogramMarkerIndex].m_holdReset = true;
}
m_histogramMarkers[m_histogramMarkerIndex].m_markerType = newType;
} }
void SpectrumMarkersDialog::on_powerHoldReset_clicked() void SpectrumMarkersDialog::on_powerHoldReset_clicked()
@ -338,6 +363,15 @@ void SpectrumMarkersDialog::on_wMarkerColor_clicked()
} }
} }
void SpectrumMarkersDialog::on_wShowMarker_clicked(bool clicked)
{
if (m_waterfallMarkers.size() == 0) {
return;
}
m_waterfallMarkers[m_waterfallMarkerIndex].m_show = clicked;
}
void SpectrumMarkersDialog::on_wMarker_valueChanged(int value) void SpectrumMarkersDialog::on_wMarker_valueChanged(int value)
{ {
if (m_waterfallMarkers.size() == 0) { if (m_waterfallMarkers.size() == 0) {
@ -391,3 +425,8 @@ void SpectrumMarkersDialog::on_wMarkerDel_clicked()
ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1); ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1);
displayWaterfallMarker(); displayWaterfallMarker();
} }
void SpectrumMarkersDialog::on_showSelect_currentIndexChanged(int index)
{
m_markersDisplay = (SpectrumSettings::MarkersDisplay) index;
}

View File

@ -22,6 +22,7 @@
#include <QDialog> #include <QDialog>
#include <QList> #include <QList>
#include "dsp/spectrumsettings.h"
#include "gui/spectrummarkers.h" #include "gui/spectrummarkers.h"
#include "export.h" #include "export.h"
@ -36,6 +37,7 @@ public:
explicit SpectrumMarkersDialog( explicit SpectrumMarkersDialog(
QList<SpectrumHistogramMarker>& histogramMarkers, QList<SpectrumHistogramMarker>& histogramMarkers,
QList<SpectrumWaterfallMarker>& waterfallMarkers, QList<SpectrumWaterfallMarker>& waterfallMarkers,
SpectrumSettings::MarkersDisplay& markersDisplay,
QWidget* parent = nullptr QWidget* parent = nullptr
); );
~SpectrumMarkersDialog(); ~SpectrumMarkersDialog();
@ -47,6 +49,7 @@ private:
Ui::SpectrumMarkersDialog* ui; Ui::SpectrumMarkersDialog* ui;
QList<SpectrumHistogramMarker>& m_histogramMarkers; QList<SpectrumHistogramMarker>& m_histogramMarkers;
QList<SpectrumWaterfallMarker>& m_waterfallMarkers; QList<SpectrumWaterfallMarker>& m_waterfallMarkers;
SpectrumSettings::MarkersDisplay& m_markersDisplay;
int m_histogramMarkerIndex; int m_histogramMarkerIndex;
int m_waterfallMarkerIndex; int m_waterfallMarkerIndex;
qint64 m_centerFrequency; qint64 m_centerFrequency;
@ -62,6 +65,7 @@ private slots:
void on_markerFrequency_changed(qint64 value); void on_markerFrequency_changed(qint64 value);
void on_centerFrequency_clicked(); void on_centerFrequency_clicked();
void on_markerColor_clicked(); void on_markerColor_clicked();
void on_showMarker_clicked(bool clicked);
void on_fixedPower_valueChanged(int value); void on_fixedPower_valueChanged(int value);
void on_marker_valueChanged(int value); void on_marker_valueChanged(int value);
void on_setReference_clicked(); void on_setReference_clicked();
@ -75,10 +79,12 @@ private slots:
void on_timeExp_valueChanged(int value); void on_timeExp_valueChanged(int value);
void on_wCenterFrequency_clicked(); void on_wCenterFrequency_clicked();
void on_wMarkerColor_clicked(); void on_wMarkerColor_clicked();
void on_wShowMarker_clicked(bool clicked);
void on_wMarker_valueChanged(int value); void on_wMarker_valueChanged(int value);
void on_wSetReference_clicked(); void on_wSetReference_clicked();
void on_wMarkerAdd_clicked(); void on_wMarkerAdd_clicked();
void on_wMarkerDel_clicked(); void on_wMarkerDel_clicked();
void on_showSelect_currentIndexChanged(int index);
signals: signals:
void updateHistogram(); void updateHistogram();

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>418</width> <width>418</width>
<height>201</height> <height>237</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
@ -158,6 +158,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="showMarker">
<property name="toolTip">
<string>Show this marker</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -594,6 +607,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="wShowMarker">
<property name="toolTip">
<string>Show this marker</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -963,6 +989,50 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="commonLayout">
<property name="topMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="showLabel">
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="showSelect">
<property name="toolTip">
<string>Select which set of markers to show</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>Spec</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">