mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 10:05:46 -05:00
Spectrum markers: add dialog for waterfall markers
This commit is contained in:
parent
133f6caa60
commit
111c8d4a99
@ -443,6 +443,11 @@ float GLSpectrum::getPowerMax() const
|
||||
return m_linear ? m_powerScale.getRangeMax() : CalcDb::powerFromdB(m_powerScale.getRangeMax());
|
||||
}
|
||||
|
||||
float GLSpectrum::getTimeMax() const
|
||||
{
|
||||
return m_timeScale.getRangeMax();
|
||||
}
|
||||
|
||||
void GLSpectrum::newSpectrum(const Real *spectrum, int nbBins, int fftSize)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
@ -115,6 +115,7 @@ public:
|
||||
void setCenterFrequency(qint64 frequency);
|
||||
qint64 getCenterFrequency() const { return m_centerFrequency; }
|
||||
float getPowerMax() const;
|
||||
float getTimeMax() const;
|
||||
void setSampleRate(qint32 sampleRate);
|
||||
void setTimingRate(qint32 timingRate);
|
||||
void setFFTOverlap(int overlap);
|
||||
|
@ -348,6 +348,7 @@ void GLSpectrumGUI::on_markers_clicked(bool checked)
|
||||
|
||||
markersDialog.setCenterFrequency(m_glSpectrum->getCenterFrequency());
|
||||
markersDialog.setPower(m_glSpectrum->getPowerMax() / 2.0f);
|
||||
markersDialog.setTime(m_glSpectrum->getTimeMax() / 2.0f);
|
||||
|
||||
connect(&markersDialog, SIGNAL(updateHistogram()), this, SLOT(updateHistogramMarkers()));
|
||||
connect(&markersDialog, SIGNAL(updateWaterfall()), this, SLOT(updateWaterfallMarkers()));
|
||||
|
@ -33,6 +33,7 @@ SpectrumMarkersDialog::SpectrumMarkersDialog(
|
||||
m_histogramMarkers(histogramMarkers),
|
||||
m_waterfallMarkers(waterfallMarkers),
|
||||
m_histogramMarkerIndex(0),
|
||||
m_waterfallMarkerIndex(0),
|
||||
m_centerFrequency(0),
|
||||
m_power(0.5f)
|
||||
{
|
||||
@ -40,7 +41,11 @@ SpectrumMarkersDialog::SpectrumMarkersDialog(
|
||||
ui->markerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||
ui->markerFrequency->setValueRange(false, 10, -9999999999L, 9999999999L);
|
||||
ui->marker->setMaximum(m_histogramMarkers.size() - 1);
|
||||
ui->wMarkerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||
ui->wMarkerFrequency->setValueRange(false, 10, -9999999999L, 9999999999L);
|
||||
ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1);
|
||||
displayHistogramMarker();
|
||||
displayWaterfallMarker();
|
||||
}
|
||||
|
||||
SpectrumMarkersDialog::~SpectrumMarkersDialog()
|
||||
@ -76,6 +81,59 @@ void SpectrumMarkersDialog::displayHistogramMarker()
|
||||
}
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::displayWaterfallMarker()
|
||||
{
|
||||
if (m_waterfallMarkers.size() == 0)
|
||||
{
|
||||
ui->wMarker->setEnabled(false);
|
||||
ui->wMarkerFrequency->setEnabled(false);
|
||||
ui->timeCoarse->setEnabled(false);
|
||||
ui->timeFine->setEnabled(false);
|
||||
ui->timeExp->setEnabled(false);
|
||||
ui->wMarkerText->setText("-");
|
||||
ui->timeCoarse->setValue(0);
|
||||
ui->timeFine->setValue(0);
|
||||
ui->timeText->setText("0.000");
|
||||
ui->timeExp->setValue(0);
|
||||
ui->timeExpText->setText("e+0");
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->wMarker->setEnabled(true);
|
||||
ui->wMarkerFrequency->setEnabled(true);
|
||||
ui->timeCoarse->setEnabled(true);
|
||||
ui->timeFine->setEnabled(true);
|
||||
ui->timeExp->setEnabled(true);
|
||||
ui->wMarkerText->setText(tr("%1").arg(m_waterfallMarkerIndex));
|
||||
ui->wMarkerFrequency->setValue(m_waterfallMarkers[m_waterfallMarkerIndex].m_frequency);
|
||||
int r,g,b,a;
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_markerColor.getRgb(&r, &g, &b, &a);
|
||||
ui->wMarkerColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b));
|
||||
displayTime(m_waterfallMarkers[m_waterfallMarkerIndex].m_time);
|
||||
}
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::displayTime(float time)
|
||||
{
|
||||
int timeExp;
|
||||
double timeMant = CalcDb::frexp10(time, &timeExp) * 10.0;
|
||||
int timeCoarse = (int) timeMant;
|
||||
int timeFine = round((timeMant - timeCoarse) * 1000.0);
|
||||
timeExp -= timeMant == 0 ? 0 : 1;
|
||||
qDebug("SpectrumMarkersDialog::displayTime: time: %e fine: %d coarse: %d exp: %d",
|
||||
time, timeFine, timeCoarse, timeExp);
|
||||
ui->timeFine->setValue(timeFine);
|
||||
ui->timeCoarse->setValue(timeCoarse);
|
||||
ui->timeExp->setValue(timeExp);
|
||||
ui->timeText->setText(tr("%1").arg(timeMant, 0, 'f', 3));
|
||||
ui->timeExpText->setText(tr("e%1%2").arg(timeExp < 0 ? "" : "+").arg(timeExp));
|
||||
}
|
||||
|
||||
float SpectrumMarkersDialog::getTime() const
|
||||
{
|
||||
return ((ui->timeFine->value() / 1000.0) + ui->timeCoarse->value()) * pow(10.0, ui->timeExp->value());
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_markerFrequency_changed(qint64 value)
|
||||
{
|
||||
if (m_histogramMarkers.size() == 0) {
|
||||
@ -191,3 +249,136 @@ void SpectrumMarkersDialog::on_powerMode_currentIndexChanged(int index)
|
||||
|
||||
m_histogramMarkers[m_histogramMarkerIndex].m_markerType = (SpectrumHistogramMarkerType) index;
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_wMarkerFrequency_changed(qint64 value)
|
||||
{
|
||||
if (m_waterfallMarkers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_frequency = value;
|
||||
emit updateWaterfall();
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_timeCoarse_valueChanged(int value)
|
||||
{
|
||||
double timeMant = value + (ui->timeFine->value() / 1000.0);
|
||||
ui->timeText->setText(tr("%1").arg(timeMant, 0, 'f', 3));
|
||||
|
||||
if (m_waterfallMarkers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_time = getTime();
|
||||
emit updateWaterfall();
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_timeFine_valueChanged(int value)
|
||||
{
|
||||
double timeMant = ui->timeCoarse->value() + (value / 1000.0);
|
||||
ui->timeText->setText(tr("%1").arg(timeMant, 0, 'f', 3));
|
||||
|
||||
if (m_waterfallMarkers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_time = getTime();
|
||||
emit updateWaterfall();
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_timeExp_valueChanged(int value)
|
||||
{
|
||||
ui->timeExpText->setText(tr("e%1%2").arg(value < 0 ? "" : "+").arg(value));
|
||||
|
||||
if (m_waterfallMarkers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_time = getTime();
|
||||
emit updateWaterfall();
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_wCenterFrequency_clicked()
|
||||
{
|
||||
if (m_waterfallMarkers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_frequency = m_centerFrequency;
|
||||
displayWaterfallMarker();
|
||||
emit updateWaterfall();
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_wMarkerColor_clicked()
|
||||
{
|
||||
if (m_waterfallMarkers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
QColor newColor = QColorDialog::getColor(
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_markerColor,
|
||||
this,
|
||||
tr("Select Color for marker"),
|
||||
QColorDialog::DontUseNativeDialog
|
||||
);
|
||||
|
||||
if (newColor.isValid()) // user clicked OK and selected a color
|
||||
{
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_markerColor = newColor;
|
||||
displayWaterfallMarker();
|
||||
}
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_wMarker_valueChanged(int value)
|
||||
{
|
||||
if (m_waterfallMarkers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waterfallMarkerIndex = value;
|
||||
displayWaterfallMarker();
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_wSetReference_clicked()
|
||||
{
|
||||
if ((m_waterfallMarkerIndex == 0) || (m_waterfallMarkers.size() < 2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SpectrumWaterfallMarker marker0 = m_waterfallMarkers.at(0);
|
||||
QColor color0 = marker0.m_markerColor; // do not exchange colors
|
||||
QColor colorI = m_waterfallMarkers[m_waterfallMarkerIndex].m_markerColor;
|
||||
m_waterfallMarkers[0] = m_waterfallMarkers[m_waterfallMarkerIndex];
|
||||
m_waterfallMarkers[0].m_markerColor = color0;
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex] = marker0;
|
||||
m_waterfallMarkers[m_waterfallMarkerIndex].m_markerColor = colorI;
|
||||
displayWaterfallMarker();
|
||||
emit updateWaterfall();
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_wMarkerAdd_clicked()
|
||||
{
|
||||
if (m_waterfallMarkers.size() == SpectrumWaterfallMarker::m_maxNbOfMarkers) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waterfallMarkers.append(SpectrumWaterfallMarker());
|
||||
m_waterfallMarkers.back().m_frequency = m_centerFrequency;
|
||||
m_waterfallMarkers.back().m_time = m_time;
|
||||
m_waterfallMarkerIndex = m_waterfallMarkers.size() - 1;
|
||||
ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1);
|
||||
displayWaterfallMarker();
|
||||
}
|
||||
|
||||
void SpectrumMarkersDialog::on_wMarkerDel_clicked()
|
||||
{
|
||||
if (m_waterfallMarkers.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waterfallMarkers.removeAt(m_waterfallMarkerIndex);
|
||||
m_waterfallMarkerIndex = m_waterfallMarkerIndex < m_waterfallMarkers.size() ?
|
||||
m_waterfallMarkerIndex : m_waterfallMarkerIndex - 1;
|
||||
ui->wMarker->setMaximum(m_waterfallMarkers.size() - 1);
|
||||
displayWaterfallMarker();
|
||||
}
|
||||
|
@ -41,16 +41,22 @@ public:
|
||||
~SpectrumMarkersDialog();
|
||||
void setCenterFrequency(qint64 centerFrequency) { m_centerFrequency = centerFrequency; }
|
||||
void setPower(float power) { m_power = power; }
|
||||
void setTime(float time) { m_time = time; }
|
||||
|
||||
private:
|
||||
Ui::SpectrumMarkersDialog* ui;
|
||||
QList<SpectrumHistogramMarker>& m_histogramMarkers;
|
||||
QList<SpectrumWaterfallMarker>& m_waterfallMarkers;
|
||||
int m_histogramMarkerIndex;
|
||||
int m_waterfallMarkerIndex;
|
||||
qint64 m_centerFrequency;
|
||||
float m_power;
|
||||
float m_time;
|
||||
|
||||
void displayHistogramMarker();
|
||||
void displayWaterfallMarker();
|
||||
void displayTime(float time);
|
||||
float getTime() const;
|
||||
|
||||
private slots:
|
||||
void on_markerFrequency_changed(qint64 value);
|
||||
@ -62,6 +68,16 @@ private slots:
|
||||
void on_markerAdd_clicked();
|
||||
void on_markerDel_clicked();
|
||||
void on_powerMode_currentIndexChanged(int index);
|
||||
void on_wMarkerFrequency_changed(qint64 value);
|
||||
void on_timeCoarse_valueChanged(int value);
|
||||
void on_timeFine_valueChanged(int value);
|
||||
void on_timeExp_valueChanged(int value);
|
||||
void on_wCenterFrequency_clicked();
|
||||
void on_wMarkerColor_clicked();
|
||||
void on_wMarker_valueChanged(int value);
|
||||
void on_wSetReference_clicked();
|
||||
void on_wMarkerAdd_clicked();
|
||||
void on_wMarkerDel_clicked();
|
||||
|
||||
signals:
|
||||
void updateHistogram();
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user