mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-27 15:26:33 -04:00
Merge pull request #1309 from srcejon/goto_marker
SpectrumGUI: Add combo box to allow center frequency to be set to marker
This commit is contained in:
commit
a3dfc3850e
@ -222,6 +222,7 @@ void GLSpectrumGUI::displaySettings()
|
|||||||
ui->linscale->setChecked(m_settings.m_linear);
|
ui->linscale->setChecked(m_settings.m_linear);
|
||||||
setAveragingToolitp();
|
setAveragingToolitp();
|
||||||
ui->calibration->setChecked(m_settings.m_useCalibration);
|
ui->calibration->setChecked(m_settings.m_useCalibration);
|
||||||
|
displayGotoMarkers();
|
||||||
|
|
||||||
ui->fftWindow->blockSignals(false);
|
ui->fftWindow->blockSignals(false);
|
||||||
ui->averaging->blockSignals(false);
|
ui->averaging->blockSignals(false);
|
||||||
@ -230,6 +231,38 @@ void GLSpectrumGUI::displaySettings()
|
|||||||
blockApplySettings(false);
|
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)
|
void GLSpectrumGUI::blockApplySettings(bool block)
|
||||||
{
|
{
|
||||||
m_doApplySettings = !block;
|
m_doApplySettings = !block;
|
||||||
@ -611,6 +644,27 @@ void GLSpectrumGUI::on_calibration_toggled(bool checked)
|
|||||||
applySettings();
|
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()
|
void GLSpectrumGUI::setAveragingCombo()
|
||||||
{
|
{
|
||||||
int index = ui->averaging->currentIndex();
|
int index = ui->averaging->currentIndex();
|
||||||
|
@ -84,6 +84,8 @@ private:
|
|||||||
void setFFTSizeToolitp();
|
void setFFTSizeToolitp();
|
||||||
void setMaximumOverlap();
|
void setMaximumOverlap();
|
||||||
bool handleMessage(const Message& message);
|
bool handleMessage(const Message& message);
|
||||||
|
void displayGotoMarkers();
|
||||||
|
QString displayScaled(int64_t value, char type, int precision, bool showMult);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_fftWindow_currentIndexChanged(int index);
|
void on_fftWindow_currentIndexChanged(int index);
|
||||||
@ -118,6 +120,7 @@ private slots:
|
|||||||
void on_clearSpectrum_clicked(bool checked);
|
void on_clearSpectrum_clicked(bool checked);
|
||||||
void on_freeze_toggled(bool checked);
|
void on_freeze_toggled(bool checked);
|
||||||
void on_calibration_toggled(bool checked);
|
void on_calibration_toggled(bool checked);
|
||||||
|
void on_gotoMarker_currentIndexChanged(int index);
|
||||||
|
|
||||||
void handleInputMessages();
|
void handleInputMessages();
|
||||||
void openWebsocketSpectrumSettingsDialog(const QPoint& p);
|
void openWebsocketSpectrumSettingsDialog(const QPoint& p);
|
||||||
@ -128,6 +131,10 @@ private slots:
|
|||||||
void updateAnnotationMarkers();
|
void updateAnnotationMarkers();
|
||||||
void updateMarkersDisplay();
|
void updateMarkersDisplay();
|
||||||
void updateCalibrationPoints();
|
void updateCalibrationPoints();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
// Emitted when user selects an annotation marker
|
||||||
|
void requestCenterFrequency(qint64 frequency);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_GLSPECTRUMGUI_H
|
#endif // INCLUDE_GLSPECTRUMGUI_H
|
||||||
|
@ -1073,6 +1073,30 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QLabel" name="fillLabel4">
|
<widget class="QLabel" name="fillLabel4">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
@ -142,6 +142,7 @@ MainSpectrumGUI::MainSpectrumGUI(GLSpectrum *spectrum, GLSpectrumGUI *spectrumGU
|
|||||||
connect(m_hideButton, SIGNAL(clicked()), this, SLOT(hide()));
|
connect(m_hideButton, SIGNAL(clicked()), this, SLOT(hide()));
|
||||||
|
|
||||||
connect(spectrum, &GLSpectrum::requestCenterFrequency, this, &MainSpectrumGUI::onRequestCenterFrequency);
|
connect(spectrum, &GLSpectrum::requestCenterFrequency, this, &MainSpectrumGUI::onRequestCenterFrequency);
|
||||||
|
connect(spectrumGUI, &GLSpectrumGUI::requestCenterFrequency, this, &MainSpectrumGUI::onRequestCenterFrequency);
|
||||||
|
|
||||||
m_resizer.enableChildMouseTracking();
|
m_resizer.enableChildMouseTracking();
|
||||||
shrinkWindow();
|
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)
|
void MainSpectrumGUI::onRequestCenterFrequency(qint64 frequency)
|
||||||
{
|
{
|
||||||
emit requestCenterFrequency(m_deviceSetIndex, frequency);
|
emit requestCenterFrequency(m_deviceSetIndex, frequency);
|
||||||
|
Loading…
Reference in New Issue
Block a user