diff --git a/sdrbase/dsp/spectrumsettings.cpp b/sdrbase/dsp/spectrumsettings.cpp
index b1a4045d2..93564e925 100644
--- a/sdrbase/dsp/spectrumsettings.cpp
+++ b/sdrbase/dsp/spectrumsettings.cpp
@@ -68,14 +68,16 @@ void SpectrumSettings::resetToDefaults()
m_3DSpectrogramStyle = Outline;
m_colorMap = "Angel";
m_spectrumStyle = Line;
- m_measure = false;
- m_measurement = MeasurementPeaks;
+ m_measurement = MeasurementNone;
+ m_measurementCenterFrequencyOffset = 0;
m_measurementBandwidth = 10000;
m_measurementChSpacing = 10000;
m_measurementAdjChBandwidth = 10000;
m_measurementHarmonics = 5;
- m_measurementHighlight = true;
m_measurementPeaks = 5;
+ m_measurementHighlight = true;
+ m_measurementsPosition = PositionBelow;
+ m_measurementPrecision = 1;
}
QByteArray SpectrumSettings::serialize() const
@@ -123,7 +125,9 @@ QByteArray SpectrumSettings::serialize() const
// 41, 42 used below
s.writeBool(42, m_measurementHighlight);
s.writeS32(43, m_measurementPeaks);
- s.writeBool(44, m_measure);
+ s.writeS32(44, (int)m_measurementsPosition);
+ s.writeS32(45, m_measurementPrecision);
+ s.writeS32(46, m_measurementCenterFrequencyOffset);
s.writeS32(100, m_histogramMarkers.size());
for (int i = 0; i < m_histogramMarkers.size(); i++) {
@@ -225,14 +229,16 @@ bool SpectrumSettings::deserialize(const QByteArray& data)
d.readS32(32, (int*)&m_3DSpectrogramStyle, (int)Outline);
d.readString(33, &m_colorMap, "Angel");
d.readS32(34, (int*)&m_spectrumStyle, (int)Line);
- d.readS32(35, (int*)&m_measurement, (int)MeasurementPeaks);
+ d.readS32(35, (int*)&m_measurement, (int)MeasurementNone);
d.readS32(36, &m_measurementBandwidth, 10000);
d.readS32(37, &m_measurementChSpacing, 10000);
d.readS32(38, &m_measurementAdjChBandwidth, 10000);
d.readS32(39, &m_measurementHarmonics, 5);
d.readBool(42, &m_measurementHighlight, true);
d.readS32(43, &m_measurementPeaks, 5);
- d.readBool(44, &m_measure, false);
+ d.readS32(44, (int*)&m_measurementsPosition, (int)PositionBelow);
+ d.readS32(45, &m_measurementPrecision, 1);
+ d.readS32(46, &m_measurementCenterFrequencyOffset, 0);
int histogramMarkersSize;
d.readS32(100, &histogramMarkersSize, 0);
diff --git a/sdrbase/dsp/spectrumsettings.h b/sdrbase/dsp/spectrumsettings.h
index c9262cf8d..71bd6bfe5 100644
--- a/sdrbase/dsp/spectrumsettings.h
+++ b/sdrbase/dsp/spectrumsettings.h
@@ -72,12 +72,20 @@ public:
enum Measurement
{
+ MeasurementNone,
MeasurementPeaks,
MeasurementChannelPower,
MeasurementAdjacentChannelPower,
MeasurementSNR
};
+ enum MeasurementsPosition {
+ PositionAbove,
+ PositionBelow,
+ PositionLeft,
+ PositionRight
+ };
+
int m_fftSize;
int m_fftOverlap;
FFTWindow::Function m_fftWindow;
@@ -116,14 +124,17 @@ public:
SpectrogramStyle m_3DSpectrogramStyle;
QString m_colorMap;
SpectrumStyle m_spectrumStyle;
- bool m_measure;
Measurement m_measurement;
+ int m_measurementCenterFrequencyOffset;
int m_measurementBandwidth;
int m_measurementChSpacing;
int m_measurementAdjChBandwidth;
int m_measurementHarmonics;
int m_measurementPeaks;
bool m_measurementHighlight;
+ MeasurementsPosition m_measurementsPosition;
+ int m_measurementPrecision;
+
static const int m_log2FFTSizeMin = 6; // 64
static const int m_log2FFTSizeMax = 15; // 32k
diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt
index 7540249e3..9c533f1a5 100644
--- a/sdrgui/CMakeLists.txt
+++ b/sdrgui/CMakeLists.txt
@@ -70,6 +70,7 @@ set(sdrgui_SOURCES
gui/sdrangelsplash.cpp
gui/spectrumcalibrationpointsdialog.cpp
gui/spectrummarkersdialog.cpp
+ gui/spectrummeasurementsdialog.cpp
gui/spectrummeasurements.cpp
gui/tickedslider.cpp
gui/timedelegate.cpp
@@ -176,6 +177,7 @@ set(sdrgui_HEADERS
gui/sdrangelsplash.h
gui/spectrumcalibrationpointsdialog.h
gui/spectrummarkersdialog.h
+ gui/spectrummeasurementsdialog.h
gui/spectrummeasurements.h
gui/tickedslider.h
gui/timedelegate.h
@@ -243,6 +245,7 @@ set(sdrgui_FORMS
gui/samplingdevicecontrol.ui
gui/samplingdevicedialog.ui
gui/spectrummarkersdialog.ui
+ gui/spectrummeasurementsdialog.ui
gui/spectrumcalibrationpointsdialog.ui
gui/myposdialog.ui
gui/transverterdialog.ui
diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp
index 2e7c512ab..6f2bdc07b 100644
--- a/sdrgui/gui/glspectrum.cpp
+++ b/sdrgui/gui/glspectrum.cpp
@@ -111,14 +111,15 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_openGLLogger(nullptr),
m_isDeviceSpectrum(false),
m_measurements(nullptr),
- m_measure(false),
- m_measurement(SpectrumSettings::MeasurementPeaks),
+ m_measurement(SpectrumSettings::MeasurementNone),
+ m_measurementCenterFrequencyOffset(0),
m_measurementBandwidth(10000),
m_measurementChSpacing(10000),
m_measurementAdjChBandwidth(10000),
m_measurementHarmonics(5),
m_measurementPeaks(5),
- m_measurementHighlight(true)
+ m_measurementHighlight(true),
+ m_measurementPrecision(1)
{
// Enable multisampling anti-aliasing (MSAA)
int multisamples = MainCore::instance()->getSettings().getMultisampling();
@@ -495,22 +496,23 @@ void GLSpectrum::setUseCalibration(bool useCalibration)
update();
}
-void GLSpectrum::setMeasurementParams(bool measure, SpectrumSettings::Measurement measurement,
- int bandwidth, int chSpacing, int adjChBandwidth,
- int harmonics, int peaks, bool highlight)
+void GLSpectrum::setMeasurementParams(SpectrumSettings::Measurement measurement,
+ int centerFrequencyOffset, int bandwidth, int chSpacing, int adjChBandwidth,
+ int harmonics, int peaks, bool highlight, int precision)
{
m_mutex.lock();
- m_measure = measure;
m_measurement = measurement;
+ m_measurementCenterFrequencyOffset = centerFrequencyOffset;
m_measurementBandwidth = bandwidth;
m_measurementChSpacing = chSpacing;
m_measurementAdjChBandwidth = adjChBandwidth;
m_measurementHarmonics = harmonics;
m_measurementPeaks = peaks;
m_measurementHighlight = highlight;
+ m_measurementPrecision = precision;
m_changesPending = true;
if (m_measurements) {
- m_measurements->setMeasurementParams(measurement, peaks);
+ m_measurements->setMeasurementParams(measurement, peaks, precision);
}
m_mutex.unlock();
update();
@@ -1681,7 +1683,7 @@ void GLSpectrum::paintGL()
m_glShaderInfo.drawSurface(m_glInfoBoxMatrix, tex1, vtx1, 4);
}
- if (m_currentSpectrum && m_measure)
+ if (m_currentSpectrum)
{
switch (m_measurement)
{
@@ -2133,12 +2135,12 @@ void GLSpectrum::measureChannelPower()
{
float power;
- power = calcChannelPower(m_centerFrequency, m_measurementBandwidth);
+ power = calcChannelPower(m_centerFrequency + m_measurementCenterFrequencyOffset, m_measurementBandwidth);
if (m_measurements) {
m_measurements->setChannelPower(power);
}
if (m_measurementHighlight) {
- drawBandwidthMarkers(m_centerFrequency, m_measurementBandwidth, m_measurementLightMarkerColor);
+ drawBandwidthMarkers(m_centerFrequency + m_measurementCenterFrequencyOffset, m_measurementBandwidth, m_measurementLightMarkerColor);
}
}
@@ -2147,9 +2149,9 @@ void GLSpectrum::measureAdjacentChannelPower()
{
float power, powerLeft, powerRight;
- power = calcChannelPower(m_centerFrequency, m_measurementBandwidth);
- powerLeft = calcChannelPower(m_centerFrequency - m_measurementChSpacing, m_measurementAdjChBandwidth);
- powerRight = calcChannelPower(m_centerFrequency + m_measurementChSpacing, m_measurementAdjChBandwidth);
+ power = calcChannelPower(m_centerFrequency + m_measurementCenterFrequencyOffset, m_measurementBandwidth);
+ powerLeft = calcChannelPower(m_centerFrequency + m_measurementCenterFrequencyOffset - m_measurementChSpacing, m_measurementAdjChBandwidth);
+ powerRight = calcChannelPower(m_centerFrequency + m_measurementCenterFrequencyOffset + m_measurementChSpacing, m_measurementAdjChBandwidth);
float leftDiff = powerLeft - power;
float rightDiff = powerRight - power;
@@ -2160,9 +2162,9 @@ void GLSpectrum::measureAdjacentChannelPower()
if (m_measurementHighlight)
{
- drawBandwidthMarkers(m_centerFrequency, m_measurementBandwidth, m_measurementLightMarkerColor);
- drawBandwidthMarkers(m_centerFrequency - m_measurementChSpacing, m_measurementAdjChBandwidth, m_measurementDarkMarkerColor);
- drawBandwidthMarkers(m_centerFrequency + m_measurementChSpacing, m_measurementAdjChBandwidth, m_measurementDarkMarkerColor);
+ drawBandwidthMarkers(m_centerFrequency + m_measurementCenterFrequencyOffset, m_measurementBandwidth, m_measurementLightMarkerColor);
+ drawBandwidthMarkers(m_centerFrequency + m_measurementCenterFrequencyOffset - m_measurementChSpacing, m_measurementAdjChBandwidth, m_measurementDarkMarkerColor);
+ drawBandwidthMarkers(m_centerFrequency + m_measurementCenterFrequencyOffset + m_measurementChSpacing, m_measurementAdjChBandwidth, m_measurementDarkMarkerColor);
}
}
diff --git a/sdrgui/gui/glspectrum.h b/sdrgui/gui/glspectrum.h
index 0df10de7a..db397b3f8 100644
--- a/sdrgui/gui/glspectrum.h
+++ b/sdrgui/gui/glspectrum.h
@@ -163,9 +163,9 @@ public:
void setLinear(bool linear);
void setUseCalibration(bool useCalibration);
void setMeasurements(SpectrumMeasurements *measurements) { m_measurements = measurements; }
- void setMeasurementParams(bool measure, SpectrumSettings::Measurement measurement,
- int bandwidth, int chSpacing, int adjChBandwidth,
- int harmonics, int peaks, bool highlight);
+ void setMeasurementParams(SpectrumSettings::Measurement measurement,
+ int centerFrequencyOffset, int bandwidth, int chSpacing, int adjChBandwidth,
+ int harmonics, int peaks, bool highlight, int precision);
qint32 getSampleRate() const { return m_sampleRate; }
void addChannelMarker(ChannelMarker* channelMarker);
@@ -378,14 +378,15 @@ private:
bool m_isDeviceSpectrum;
SpectrumMeasurements *m_measurements;
- bool m_measure;
SpectrumSettings::Measurement m_measurement;
+ int m_measurementCenterFrequencyOffset;
int m_measurementBandwidth;
int m_measurementChSpacing;
int m_measurementAdjChBandwidth;
int m_measurementHarmonics;
int m_measurementPeaks;
bool m_measurementHighlight;
+ int m_measurementPrecision;
static const QVector4D m_measurementLightMarkerColor;
static const QVector4D m_measurementDarkMarkerColor;
diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp
index bbb299bf3..6f8901ec8 100644
--- a/sdrgui/gui/glspectrumgui.cpp
+++ b/sdrgui/gui/glspectrumgui.cpp
@@ -33,6 +33,7 @@
#include "gui/wsspectrumsettingsdialog.h"
#include "gui/spectrummarkersdialog.h"
#include "gui/spectrumcalibrationpointsdialog.h"
+#include "gui/spectrummeasurementsdialog.h"
#include "gui/spectrummeasurements.h"
#include "gui/flowlayout.h"
#include "util/colormap.h"
@@ -54,7 +55,6 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
ui->setupUi(this);
// Use the custom flow layout for the 3 main horizontal layouts (lines)
- ui->verticalLayout->removeItem(ui->Line7Layout);
ui->verticalLayout->removeItem(ui->Line6Layout);
ui->verticalLayout->removeItem(ui->Line5Layout);
ui->verticalLayout->removeItem(ui->Line4Layout);
@@ -68,11 +68,10 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) :
flowLayout->addItem(ui->Line4Layout);
flowLayout->addItem(ui->Line5Layout);
flowLayout->addItem(ui->Line6Layout);
- flowLayout->addItem(ui->Line7Layout);
ui->verticalLayout->addItem(flowLayout);
on_linscale_toggled(false);
- displayMeasurementGUI();
+ //displayMeasurementGUI();
QString levelStyle = QString(
"QSpinBox {background-color: rgb(79, 79, 79);}"
@@ -233,21 +232,13 @@ void GLSpectrumGUI::displaySettings()
ui->calibration->setChecked(m_settings.m_useCalibration);
displayGotoMarkers();
- ui->measure->setChecked(m_settings.m_measure);
- ui->measurement->setCurrentIndex((int) m_settings.m_measurement);
- ui->highlight->setChecked(m_settings.m_measurementHighlight);
- ui->bandwidth->setValue(m_settings.m_measurementBandwidth);
- ui->chSpacing->setValue(m_settings.m_measurementChSpacing);
- ui->adjChBandwidth->setValue(m_settings.m_measurementAdjChBandwidth);
- ui->harmonics->setValue(m_settings.m_measurementHarmonics);
- ui->peaks->setValue(m_settings.m_measurementPeaks);
- displayMeasurementGUI();
-
ui->fftWindow->blockSignals(false);
ui->averaging->blockSignals(false);
ui->averagingMode->blockSignals(false);
ui->linscale->blockSignals(false);
blockApplySettings(false);
+
+ updateMeasurements();
}
void GLSpectrumGUI::displayGotoMarkers()
@@ -349,17 +340,6 @@ void GLSpectrumGUI::applySpectrumSettings()
m_glSpectrum->setMarkersDisplay(m_settings.m_markersDisplay);
m_glSpectrum->setCalibrationPoints(m_settings.m_calibrationPoints);
m_glSpectrum->setCalibrationInterpMode(m_settings.m_calibrationInterpMode);
-
- m_glSpectrum->setMeasurementParams(
- m_settings.m_measure,
- m_settings.m_measurement,
- m_settings.m_measurementBandwidth,
- m_settings.m_measurementChSpacing,
- m_settings.m_measurementAdjChBandwidth,
- m_settings.m_measurementHarmonics,
- m_settings.m_measurementPeaks,
- m_settings.m_measurementHighlight
- );
}
void GLSpectrumGUI::on_fftWindow_currentIndexChanged(int index)
@@ -1036,95 +1016,39 @@ void GLSpectrumGUI::updateCalibrationPoints()
}
}
-void GLSpectrumGUI::displayMeasurementGUI()
-{
- bool show = m_settings.m_measure;
-
- if (m_glSpectrumTop) {
- m_glSpectrumTop->setMeasurementsVisible(show);
- }
-
- ui->measurement->setVisible(show);
- ui->highlight->setVisible(show);
-
- bool reset = (m_settings.m_measurement >= SpectrumSettings::MeasurementChannelPower);
- ui->resetMeasurements->setVisible(reset && show);
-
- bool bw = (m_settings.m_measurement == SpectrumSettings::MeasurementChannelPower)
- || (m_settings.m_measurement == SpectrumSettings::MeasurementAdjacentChannelPower);
- ui->bandwidthLabel->setVisible(bw && show);
- ui->bandwidth->setVisible(bw && show);
-
- bool adj = m_settings.m_measurement == SpectrumSettings::MeasurementAdjacentChannelPower;
- ui->chSpacingLabel->setVisible(adj && show);
- ui->chSpacing->setVisible(adj && show);
- ui->adjChBandwidthLabel->setVisible(adj && show);
- ui->adjChBandwidth->setVisible(adj && show);
-
- bool harmonics = (m_settings.m_measurement == SpectrumSettings::MeasurementSNR);
- ui->harmonicsLabel->setVisible(harmonics && show);
- ui->harmonics->setVisible(harmonics && show);
-
- bool peaks = (m_settings.m_measurement == SpectrumSettings::MeasurementPeaks);
- ui->peaksLabel->setVisible(peaks && show);
- ui->peaks->setVisible(peaks && show);
-}
-
void GLSpectrumGUI::on_measure_clicked(bool checked)
{
- m_settings.m_measure = checked;
- displayMeasurementGUI();
- applySettings();
+ SpectrumMeasurementsDialog measurementsDialog(
+ m_glSpectrumTop,
+ &m_settings,
+ this
+ );
+
+ connect(&measurementsDialog, &SpectrumMeasurementsDialog::updateMeasurements, this, &GLSpectrumGUI::updateMeasurements);
+
+ measurementsDialog.exec();
}
-void GLSpectrumGUI::on_measurement_currentIndexChanged(int index)
+void GLSpectrumGUI::updateMeasurements()
{
- m_settings.m_measurement = (SpectrumSettings::Measurement)index;
- displayMeasurementGUI();
- applySettings();
-}
+ if (m_glSpectrumTop)
+ {
+ m_glSpectrumTop->setMeasurementsVisible(m_settings.m_measurement != SpectrumSettings::MeasurementNone);
+ m_glSpectrumTop->setMeasurementsPosition(m_settings.m_measurementsPosition);
+ }
-void GLSpectrumGUI::on_highlight_toggled(bool checked)
-{
- m_settings.m_measurementHighlight = checked;
- applySettings();
-}
-
-void GLSpectrumGUI::on_resetMeasurements_clicked(bool checked)
-{
- (void) checked;
-
- if (m_glSpectrumTop) {
- m_glSpectrumTop->getMeasurements()->reset();
+ if (m_glSpectrum)
+ {
+ m_glSpectrum->setMeasurementParams(
+ m_settings.m_measurement,
+ m_settings.m_measurementCenterFrequencyOffset,
+ m_settings.m_measurementBandwidth,
+ m_settings.m_measurementChSpacing,
+ m_settings.m_measurementAdjChBandwidth,
+ m_settings.m_measurementHarmonics,
+ m_settings.m_measurementPeaks,
+ m_settings.m_measurementHighlight,
+ m_settings.m_measurementPrecision
+ );
}
}
-
-void GLSpectrumGUI::on_bandwidth_valueChanged(int value)
-{
- m_settings.m_measurementBandwidth = value;
- applySettings();
-}
-
-void GLSpectrumGUI::on_chSpacing_valueChanged(int value)
-{
- m_settings.m_measurementChSpacing = value;
- applySettings();
-}
-
-void GLSpectrumGUI::on_adjChBandwidth_valueChanged(int value)
-{
- m_settings.m_measurementAdjChBandwidth = value;
- applySettings();
-}
-
-void GLSpectrumGUI::on_harmonics_valueChanged(int value)
-{
- m_settings.m_measurementHarmonics = value;
- applySettings();
-}
-
-void GLSpectrumGUI::on_peaks_valueChanged(int value)
-{
- m_settings.m_measurementPeaks = value;
- applySettings();
-}
diff --git a/sdrgui/gui/glspectrumgui.h b/sdrgui/gui/glspectrumgui.h
index 1455d273a..041c737df 100644
--- a/sdrgui/gui/glspectrumgui.h
+++ b/sdrgui/gui/glspectrumgui.h
@@ -88,7 +88,6 @@ private:
bool handleMessage(const Message& message);
void displayGotoMarkers();
QString displayScaled(int64_t value, char type, int precision, bool showMult);
- void displayMeasurementGUI();
private slots:
void on_fftWindow_currentIndexChanged(int index);
@@ -127,14 +126,6 @@ private slots:
void on_gotoMarker_currentIndexChanged(int index);
void on_measure_clicked(bool checked);
- void on_measurement_currentIndexChanged(int index);
- void on_highlight_toggled(bool checked);
- void on_resetMeasurements_clicked(bool checked);
- void on_bandwidth_valueChanged(int value);
- void on_chSpacing_valueChanged(int value);
- void on_adjChBandwidth_valueChanged(int value);
- void on_harmonics_valueChanged(int value);
- void on_peaks_valueChanged(int value);
void handleInputMessages();
void openWebsocketSpectrumSettingsDialog(const QPoint& p);
@@ -145,6 +136,7 @@ private slots:
void updateAnnotationMarkers();
void updateMarkersDisplay();
void updateCalibrationPoints();
+ void updateMeasurements();
signals:
// Emitted when user selects an annotation marker
diff --git a/sdrgui/gui/glspectrumgui.ui b/sdrgui/gui/glspectrumgui.ui
index 998408784..afa1bf3cd 100644
--- a/sdrgui/gui/glspectrumgui.ui
+++ b/sdrgui/gui/glspectrumgui.ui
@@ -7,7 +7,7 @@
0
0
630
- 274
+ 228
@@ -1074,16 +1074,22 @@
-
-
+
+
+
+ 0
+ 0
+
+
- Display measurements
+ Open spectrum measurements dialog
:/ruler.png:/ruler.png
- true
+ false
@@ -1146,192 +1152,6 @@
- -
-
-
-
-
-
- Measurement
-
-
- -1
-
-
-
-
- Peaks
-
-
- -
-
- Ch Power
-
-
- -
-
- Adj Ch
-
-
- -
-
- SNR
-
-
-
-
- -
-
-
- Highlight measurement
-
-
- Max Hold
-
-
-
- :/carrier.png:/carrier.png
-
-
-
- 16
- 16
-
-
-
- true
-
-
-
- -
-
-
- Reset measurements
-
-
-
-
-
-
- :/bin.png:/bin.png
-
-
-
- -
-
-
- B/W
-
-
- 2
-
-
-
- -
-
-
- Measurement bandwidth (Hz)
-
-
- 1
-
-
- 100000000
-
-
- 1000
-
-
-
- -
-
-
- Spacing
-
-
- 2
-
-
-
- -
-
-
- Channel spacing (Hz)
-
-
- 100000000
-
-
- 1000
-
-
-
- -
-
-
- Adj. Ch. B/W
-
-
- 2
-
-
-
- -
-
-
- Adjacent channel bandwidth (Hz)
-
-
- 1
-
-
- 100000000
-
-
- 1000
-
-
-
- -
-
-
- Harmonics
-
-
- 2
-
-
-
- -
-
-
- Number of harmonics
-
-
- 20
-
-
-
- -
-
-
- Peaks
-
-
-
- -
-
-
- Number of peaks to display
-
-
- 1
-
-
- 20
-
-
-
-
-
diff --git a/sdrgui/gui/glspectrumtop.cpp b/sdrgui/gui/glspectrumtop.cpp
index 8b8799173..08f1453b3 100644
--- a/sdrgui/gui/glspectrumtop.cpp
+++ b/sdrgui/gui/glspectrumtop.cpp
@@ -44,3 +44,27 @@ void GLSpectrumTop::setMeasurementsVisible(bool visible)
{
m_measurements->setVisible(visible);
}
+
+void GLSpectrumTop::setMeasurementsPosition(SpectrumSettings::MeasurementsPosition position)
+{
+ switch (position)
+ {
+ case SpectrumSettings::PositionAbove:
+ m_splitter->setOrientation(Qt::Vertical);
+ m_splitter->insertWidget(0, m_measurements);
+ break;
+ case SpectrumSettings::PositionBelow:
+ m_splitter->setOrientation(Qt::Vertical);
+ m_splitter->insertWidget(0, m_spectrum);
+ break;
+ case SpectrumSettings::PositionLeft:
+ m_splitter->setOrientation(Qt::Horizontal);
+ m_splitter->insertWidget(0, m_measurements);
+ break;
+ case SpectrumSettings::PositionRight:
+ m_splitter->setOrientation(Qt::Horizontal);
+ m_splitter->insertWidget(0, m_spectrum);
+ break;
+ }
+}
+
diff --git a/sdrgui/gui/glspectrumtop.h b/sdrgui/gui/glspectrumtop.h
index eca7a214f..10848553d 100644
--- a/sdrgui/gui/glspectrumtop.h
+++ b/sdrgui/gui/glspectrumtop.h
@@ -35,6 +35,7 @@ public:
GLSpectrum *getSpectrum() const { return m_spectrum; }
SpectrumMeasurements *getMeasurements() const { return m_measurements; }
void setMeasurementsVisible(bool visible);
+ void setMeasurementsPosition(SpectrumSettings::MeasurementsPosition position);
private:
QSplitter *m_splitter;
diff --git a/sdrgui/gui/spectrummeasurements.cpp b/sdrgui/gui/spectrummeasurements.cpp
index 4e6f4f1df..f7bd9be33 100644
--- a/sdrgui/gui/spectrummeasurements.cpp
+++ b/sdrgui/gui/spectrummeasurements.cpp
@@ -168,6 +168,7 @@ const QStringList SpectrumMeasurements::m_tooltips = {
SpectrumMeasurements::SpectrumMeasurements(QWidget *parent) :
QWidget(parent),
m_measurement(SpectrumSettings::MeasurementPeaks),
+ m_precision(1),
m_table(nullptr),
m_peakTable(nullptr)
{
@@ -218,7 +219,7 @@ void SpectrumMeasurements::createMeasurementsTable(const QStringList &rows, cons
if (j < COL_COUNT)
{
item->setData(UnitsDelegate::UNITS_ROLE, units[i]);
- item->setData(UnitsDelegate::PRECISION_ROLE, 1);
+ item->setData(UnitsDelegate::PRECISION_ROLE, m_precision);
}
else if (j == COL_SPEC)
{
@@ -261,7 +262,7 @@ void SpectrumMeasurements::createPeakTable(int peaks)
item->setData(UnitsDelegate::UNITS_ROLE, "Hz");
} else if (j == COL_POWER) {
item->setData(UnitsDelegate::UNITS_ROLE, " dB");
- item->setData(UnitsDelegate::PRECISION_ROLE, 1);
+ item->setData(UnitsDelegate::PRECISION_ROLE, m_precision);
}
m_peakTable->setItem(i, j, item);
}
@@ -453,9 +454,10 @@ void SpectrumMeasurements::resizePeakTable()
m_peakTable->removeRow(row);
}
-void SpectrumMeasurements::setMeasurementParams(SpectrumSettings::Measurement measurement, int peaks)
+void SpectrumMeasurements::setMeasurementParams(SpectrumSettings::Measurement measurement, int peaks, int precision)
{
- if ( (measurement != m_measurement)
+ if ( (measurement != m_measurement)
+ || (m_precision != precision)
|| ((m_peakTable == nullptr) && (m_table == nullptr))
|| ((m_peakTable != nullptr) && (peaks != m_peakTable->rowCount()))
)
@@ -467,6 +469,7 @@ void SpectrumMeasurements::setMeasurementParams(SpectrumSettings::Measurement me
m_table = nullptr;
m_measurement = measurement;
+ m_precision = precision;
switch (measurement)
{
diff --git a/sdrgui/gui/spectrummeasurements.h b/sdrgui/gui/spectrummeasurements.h
index bab178384..41fa5aeab 100644
--- a/sdrgui/gui/spectrummeasurements.h
+++ b/sdrgui/gui/spectrummeasurements.h
@@ -83,7 +83,7 @@ class SDRGUI_API SpectrumMeasurements : public QWidget {
public:
SpectrumMeasurements(QWidget *parent = nullptr);
- void setMeasurementParams(SpectrumSettings::Measurement measurement, int peaks);
+ void setMeasurementParams(SpectrumSettings::Measurement measurement, int peaks, int precision);
void setSNR(float snr, float snfr, float thd, float thdpn, float sinad);
void setSFDR(float sfdr);
void setChannelPower(float power);
@@ -111,6 +111,7 @@ private:
bool checkSpec(const QString &spec, double value) const;
SpectrumSettings::Measurement m_measurement;
+ int m_precision;
QTableWidget *m_table;
QMenu *m_rowMenu;
diff --git a/sdrgui/gui/spectrummeasurementsdialog.cpp b/sdrgui/gui/spectrummeasurementsdialog.cpp
new file mode 100644
index 000000000..5775c168d
--- /dev/null
+++ b/sdrgui/gui/spectrummeasurementsdialog.cpp
@@ -0,0 +1,173 @@
+///////////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 2022 Jon Beniston, M7RCE //
+// //
+// 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 //
+// (at your option) any later version. //
+// //
+// 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
+#include
+#include
+
+#include "util/db.h"
+#include "util/csv.h"
+#include "spectrummeasurementsdialog.h"
+#include "spectrummeasurements.h"
+#include "glspectrumtop.h"
+
+#include "ui_spectrummeasurementsdialog.h"
+
+SpectrumMeasurementsDialog::SpectrumMeasurementsDialog(GLSpectrumTop *glSpectrumTop, SpectrumSettings *settings, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::SpectrumMeasurementsDialog),
+ m_glSpectrumTop(glSpectrumTop),
+ m_settings(settings)
+{
+ ui->setupUi(this);
+
+ ui->measurement->setCurrentIndex((int)m_settings->m_measurement);
+ ui->position->setCurrentIndex((int)m_settings->m_measurementsPosition);
+ ui->precision->setValue(m_settings->m_measurementPrecision);
+ ui->highlight->setChecked(m_settings->m_measurementHighlight);
+
+ ui->centerFrequencyOffset->setColorMapper(ColorMapper(ColorMapper::GrayGold));
+ ui->centerFrequencyOffset->setValueRange(false, 8, -99999999L, 99999999L);
+ ui->centerFrequencyOffset->setValue(m_settings->m_measurementCenterFrequencyOffset);
+
+ ui->bandwidth->setColorMapper(ColorMapper(ColorMapper::GrayGold));
+ ui->bandwidth->setValueRange(true, 8, 0L, 99999999L);
+ ui->bandwidth->setValue(m_settings->m_measurementBandwidth);
+
+ ui->chSpacing->setColorMapper(ColorMapper(ColorMapper::GrayGold));
+ ui->chSpacing->setValueRange(true, 8, 0L, 99999999L);
+ ui->chSpacing->setValue(m_settings->m_measurementChSpacing);
+
+ ui->adjChBandwidth->setColorMapper(ColorMapper(ColorMapper::GrayGold));
+ ui->adjChBandwidth->setValueRange(true, 8, 0L, 99999999L);
+ ui->adjChBandwidth->setValue(m_settings->m_measurementAdjChBandwidth);
+
+ ui->harmonics->setValue(m_settings->m_measurementHarmonics);
+ ui->peaks->setValue(m_settings->m_measurementPeaks);
+
+ displaySettings();
+}
+
+SpectrumMeasurementsDialog::~SpectrumMeasurementsDialog()
+{}
+
+void SpectrumMeasurementsDialog::displaySettings()
+{
+ bool show = m_settings->m_measurement != SpectrumSettings::MeasurementNone;
+
+ ui->positionLabel->setVisible(show);
+ ui->position->setVisible(show);
+ ui->precisionLabel->setVisible(show);
+ ui->precision->setVisible(show);
+ ui->highlightLabel->setVisible(show);
+ ui->highlight->setVisible(show);
+
+ bool reset = (m_settings->m_measurement >= SpectrumSettings::MeasurementChannelPower);
+ ui->resetMeasurements->setVisible(reset && show);
+
+ bool bw = (m_settings->m_measurement == SpectrumSettings::MeasurementChannelPower)
+ || (m_settings->m_measurement == SpectrumSettings::MeasurementAdjacentChannelPower);
+ ui->centerFrequencyOffsetLabel->setVisible(bw && show);
+ ui->centerFrequencyOffset->setVisible(bw && show);
+ ui->bandwidthLabel->setVisible(bw && show);
+ ui->bandwidth->setVisible(bw && show);
+
+ bool adj = m_settings->m_measurement == SpectrumSettings::MeasurementAdjacentChannelPower;
+ ui->chSpacingLabel->setVisible(adj && show);
+ ui->chSpacing->setVisible(adj && show);
+ ui->adjChBandwidthLabel->setVisible(adj && show);
+ ui->adjChBandwidth->setVisible(adj && show);
+
+ bool harmonics = (m_settings->m_measurement == SpectrumSettings::MeasurementSNR);
+ ui->harmonicsLabel->setVisible(harmonics && show);
+ ui->harmonics->setVisible(harmonics && show);
+
+ bool peaks = (m_settings->m_measurement == SpectrumSettings::MeasurementPeaks);
+ ui->peaksLabel->setVisible(peaks && show);
+ ui->peaks->setVisible(peaks && show);
+}
+
+
+void SpectrumMeasurementsDialog::on_measurement_currentIndexChanged(int index)
+{
+ m_settings->m_measurement = (SpectrumSettings::Measurement)index;
+ displaySettings();
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_precision_valueChanged(int value)
+{
+ m_settings->m_measurementPrecision = value;
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_position_currentIndexChanged(int index)
+{
+ m_settings->m_measurementsPosition = (SpectrumSettings::MeasurementsPosition)index;
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_highlight_toggled(bool checked)
+{
+ m_settings->m_measurementHighlight = checked;
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_resetMeasurements_clicked(bool checked)
+{
+ (void) checked;
+
+ if (m_glSpectrumTop) {
+ m_glSpectrumTop->getMeasurements()->reset();
+ }
+}
+
+void SpectrumMeasurementsDialog::on_centerFrequencyOffset_changed(qint64 value)
+{
+ m_settings->m_measurementCenterFrequencyOffset = value;
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_bandwidth_changed(qint64 value)
+{
+ m_settings->m_measurementBandwidth = value;
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_chSpacing_changed(qint64 value)
+{
+ m_settings->m_measurementChSpacing = value;
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_adjChBandwidth_changed(qint64 value)
+{
+ m_settings->m_measurementAdjChBandwidth = value;
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_harmonics_valueChanged(int value)
+{
+ m_settings->m_measurementHarmonics = value;
+ emit updateMeasurements();
+}
+
+void SpectrumMeasurementsDialog::on_peaks_valueChanged(int value)
+{
+ m_settings->m_measurementPeaks = value;
+ emit updateMeasurements();
+}
diff --git a/sdrgui/gui/spectrummeasurementsdialog.h b/sdrgui/gui/spectrummeasurementsdialog.h
new file mode 100644
index 000000000..ce640d6ae
--- /dev/null
+++ b/sdrgui/gui/spectrummeasurementsdialog.h
@@ -0,0 +1,63 @@
+///////////////////////////////////////////////////////////////////////////////////
+// Copyright (C) 2022 Jon Beniston, M7RCE //
+// //
+// 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 //
+// (at your option) any later version. //
+// //
+// 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_SPECTRUMMEASUREMENTSDIALOG_H_
+#define SDRBASE_GUI_SPECTRUMMEASUREMENTSDIALOG_H_
+
+#include
+
+#include "dsp/spectrumsettings.h"
+#include "export.h"
+
+namespace Ui {
+ class SpectrumMeasurementsDialog;
+}
+
+class GLSpectrumTop;
+
+class SDRGUI_API SpectrumMeasurementsDialog : public QDialog {
+ Q_OBJECT
+
+public:
+ explicit SpectrumMeasurementsDialog(GLSpectrumTop *glSpectrumTop, SpectrumSettings *settings, QWidget *parent = nullptr);
+ ~SpectrumMeasurementsDialog();
+
+private:
+ void displaySettings();
+
+ Ui::SpectrumMeasurementsDialog *ui;
+ GLSpectrumTop *m_glSpectrumTop;
+ SpectrumSettings *m_settings;
+
+private slots:
+ void on_measurement_currentIndexChanged(int index);
+ void on_precision_valueChanged(int value);
+ void on_position_currentIndexChanged(int index);
+ void on_highlight_toggled(bool checked);
+ void on_resetMeasurements_clicked(bool checked);
+ void on_centerFrequencyOffset_changed(qint64 value);
+ void on_bandwidth_changed(qint64 value);
+ void on_chSpacing_changed(qint64 value);
+ void on_adjChBandwidth_changed(qint64 value);
+ void on_harmonics_valueChanged(int value);
+ void on_peaks_valueChanged(int value);
+
+signals:
+ void updateMeasurements();
+};
+
+#endif // SDRBASE_GUI_SPECTRUMMEASUREMENTSDIALOG_H_
diff --git a/sdrgui/gui/spectrummeasurementsdialog.ui b/sdrgui/gui/spectrummeasurementsdialog.ui
new file mode 100644
index 000000000..2fc2d24f2
--- /dev/null
+++ b/sdrgui/gui/spectrummeasurementsdialog.ui
@@ -0,0 +1,435 @@
+
+
+ SpectrumMeasurementsDialog
+
+
+
+ 0
+ 0
+ 400
+ 302
+
+
+
+
+ 400
+ 250
+
+
+
+
+ Liberation Sans
+ 9
+
+
+
+ Spectrum Measurements
+
+
+ -
+
+
-
+
+
+ Highlight on spectrum
+
+
+
+ -
+
+
+ Number of harmonics
+
+
+ 20
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 32
+ 16
+
+
+
+
+ DejaVu Sans Mono
+ 12
+
+
+
+ PointingHandCursor
+
+
+ Qt::StrongFocus
+
+
+ Center frequency offset (Hz)
+
+
+
+ -
+
+
+ Channel spacing
+
+
+ 2
+
+
+
+ -
+
+
+ Where to display the measurements result table
+
+
-
+
+ Above spectrum
+
+
+ -
+
+ Below spectrum
+
+
+ -
+
+ Left of spectrum
+
+
+ -
+
+ Right of spectrum
+
+
+
+
+ -
+
+
+ Peaks
+
+
+
+ -
+
+
+ Center frequency offset
+
+
+
+ -
+
+
+ Type of measurement
+
+
+ 0
+
+
-
+
+ None
+
+
+ -
+
+ Peaks
+
+
+ -
+
+ Channel power
+
+
+ -
+
+ Adjacent channel power
+
+
+ -
+
+ SNR
+
+
+
+
+ -
+
+
+ Display results table
+
+
+
+ -
+
+
+ Channel bandwidth
+
+
+ 2
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 32
+ 16
+
+
+
+
+ DejaVu Sans Mono
+ 12
+
+
+
+ PointingHandCursor
+
+
+ Qt::StrongFocus
+
+
+ Channel spacing (Hz)
+
+
+
+ -
+
+
+ Results precision
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 32
+ 16
+
+
+
+
+ DejaVu Sans Mono
+ 12
+
+
+
+ PointingHandCursor
+
+
+ Qt::StrongFocus
+
+
+ Channel bandwidth (Hz)
+
+
+
+ -
+
+
+ Measurement
+
+
+
+ -
+
+
+ Whether to highlight the measurements in the spectrum
+
+
+
+
+
+
+ -
+
+
+ Harmonics
+
+
+ 2
+
+
+
+ -
+
+
+ Number of peaks to display
+
+
+ 1
+
+
+ 20
+
+
+
+ -
+
+
+ Adjacent channel bandwidth
+
+
+ 2
+
+
+
+ -
+
+
+ Precision of results (number of decimal places)
+
+
+ 9
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 32
+ 16
+
+
+
+
+ DejaVu Sans Mono
+ 12
+
+
+
+ PointingHandCursor
+
+
+ Qt::StrongFocus
+
+
+ Adjacent channel bandwidth (Hz)
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+ -
+
+
-
+
+
+ Reset measurement results
+
+
+ Reset
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Close
+
+
+
+
+
+
+
+
+
+ ValueDialZ
+ QWidget
+
+ 1
+
+
+
+ measurement
+ position
+ peaks
+ harmonics
+ resetMeasurements
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ SpectrumMeasurementsDialog
+ accept()
+
+
+ 257
+ 194
+
+
+ 157
+ 203
+
+
+
+
+ buttonBox
+ rejected()
+ SpectrumMeasurementsDialog
+ reject()
+
+
+ 314
+ 194
+
+
+ 286
+ 203
+
+
+
+
+