SpectrumGUI: Add combo box to allow center frequency to be set to annotation marker

pull/1309/head
Jon Beniston 2022-06-24 23:37:22 +01:00
rodzic e881bc892c
commit 50127b4003
4 zmienionych plików z 87 dodań i 1 usunięć

Wyświetl plik

@ -222,6 +222,7 @@ void GLSpectrumGUI::displaySettings()
ui->linscale->setChecked(m_settings.m_linear);
setAveragingToolitp();
ui->calibration->setChecked(m_settings.m_useCalibration);
displayGotoMarkers();
ui->fftWindow->blockSignals(false);
ui->averaging->blockSignals(false);
@ -230,6 +231,38 @@ void GLSpectrumGUI::displaySettings()
blockApplySettings(false);
}
void GLSpectrumGUI::displayGotoMarkers()
{
ui->gotoMarker->clear();
ui->gotoMarker->addItem("Go to...");
for (auto marker : m_settings.m_annoationMarkers)
{
if (marker.m_show != SpectrumAnnotationMarker::Hidden)
{
qint64 freq = marker.m_startFrequency + marker.m_bandwidth/2;
QString freqString = displayScaled(freq, 'f', 3, true);
ui->gotoMarker->addItem(QString("%1 - %2").arg(marker.m_text).arg(freqString));
}
}
ui->gotoMarker->setVisible(ui->gotoMarker->count() > 1);
}
QString GLSpectrumGUI::displayScaled(int64_t value, char type, int precision, bool showMult)
{
int64_t posValue = (value < 0) ? -value : value;
if (posValue < 1000) {
return tr("%1").arg(QString::number(value, type, precision));
} else if (posValue < 1000000) {
return tr("%1%2").arg(QString::number(value / 1000.0, type, precision)).arg(showMult ? "k" : "");
} else if (posValue < 1000000000) {
return tr("%1%2").arg(QString::number(value / 1000000.0, type, precision)).arg(showMult ? "M" : "");
} else if (posValue < 1000000000000) {
return tr("%1%2").arg(QString::number(value / 1000000000.0, type, precision)).arg(showMult ? "G" : "");
} else {
return tr("%1").arg(QString::number(value, 'e', precision));
}
}
void GLSpectrumGUI::blockApplySettings(bool block)
{
m_doApplySettings = !block;
@ -611,6 +644,27 @@ void GLSpectrumGUI::on_calibration_toggled(bool checked)
applySettings();
}
void GLSpectrumGUI::on_gotoMarker_currentIndexChanged(int index)
{
if (index == 0) {
return;
}
int i = 1;
for (auto marker : m_settings.m_annoationMarkers)
{
if (marker.m_show != SpectrumAnnotationMarker::Hidden)
{
if (i == index)
{
emit requestCenterFrequency(marker.m_startFrequency + marker.m_bandwidth/2);
break;
}
i++;
}
}
ui->gotoMarker->setCurrentIndex(0); // Redisplay "Goto..."
}
void GLSpectrumGUI::setAveragingCombo()
{
int index = ui->averaging->currentIndex();

Wyświetl plik

@ -84,6 +84,8 @@ private:
void setFFTSizeToolitp();
void setMaximumOverlap();
bool handleMessage(const Message& message);
void displayGotoMarkers();
QString displayScaled(int64_t value, char type, int precision, bool showMult);
private slots:
void on_fftWindow_currentIndexChanged(int index);
@ -118,6 +120,7 @@ private slots:
void on_clearSpectrum_clicked(bool checked);
void on_freeze_toggled(bool checked);
void on_calibration_toggled(bool checked);
void on_gotoMarker_currentIndexChanged(int index);
void handleInputMessages();
void openWebsocketSpectrumSettingsDialog(const QPoint& p);
@ -128,6 +131,10 @@ private slots:
void updateAnnotationMarkers();
void updateMarkersDisplay();
void updateCalibrationPoints();
signals:
// Emitted when user selects an annotation marker
void requestCenterFrequency(qint64 frequency);
};
#endif // INCLUDE_GLSPECTRUMGUI_H

Wyświetl plik

@ -1073,6 +1073,30 @@
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="gotoMarker">
<property name="minimumSize">
<size>
<width>65</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>65</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Set frequency to marker</string>
</property>
<item>
<property name="text">
<string>Go to...</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="fillLabel4">
<property name="sizePolicy">

Wyświetl plik

@ -142,6 +142,7 @@ MainSpectrumGUI::MainSpectrumGUI(GLSpectrum *spectrum, GLSpectrumGUI *spectrumGU
connect(m_hideButton, SIGNAL(clicked()), this, SLOT(hide()));
connect(spectrum, &GLSpectrum::requestCenterFrequency, this, &MainSpectrumGUI::onRequestCenterFrequency);
connect(spectrumGUI, &GLSpectrumGUI::requestCenterFrequency, this, &MainSpectrumGUI::onRequestCenterFrequency);
m_resizer.enableChildMouseTracking();
shrinkWindow();
@ -320,7 +321,7 @@ QString MainSpectrumGUI::getDeviceTypeTag()
}
}
// Handle request from GLSpectrum to adjust center frequency
// Handle request from GLSpectrum/GLSpectrumGUI to adjust center frequency
void MainSpectrumGUI::onRequestCenterFrequency(qint64 frequency)
{
emit requestCenterFrequency(m_deviceSetIndex, frequency);