From 4b28f9eca5698aec8ef22e5a01bd8c4202f76eab Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Sun, 9 Sep 2018 17:18:07 -0400 Subject: [PATCH] Added QSY function to waterfall controls for centering a signal in the bandpass --- mainwindow.cpp | 7 + mainwindow.h | 1 + plotter.cpp | 18 +- plotter.h | 2 + widegraph.cpp | 12 ++ widegraph.h | 2 + widegraph.ui | 548 ++++++++++++++++++++++++++----------------------- 7 files changed, 313 insertions(+), 277 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 8f212d5..cdc81f1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -868,6 +868,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, connect(m_wideGraph.data (), SIGNAL(setFreq3(int,int)),this, SLOT(setFreq4(int,int))); + connect(m_wideGraph.data(), &WideGraph::qsy, this, &MainWindow::qsy); + decodeBusy(false); QString t1[28]={"1 uW","2 uW","5 uW","10 uW","20 uW","50 uW","100 uW","200 uW","500 uW", "1 mW","2 mW","5 mW","10 mW","20 mW","50 mW","100 mW","200 mW","500 mW", @@ -8170,6 +8172,11 @@ void MainWindow::setXIT(int n, Frequency base) Q_EMIT transmitFrequency (ui->TxFreqSpinBox->value () - m_XIT); } +void MainWindow::qsy(int hzDelta){ + setRig(m_freqNominal + hzDelta); + setFreqOffsetForRestore(1500, false); +} + void MainWindow::setFreqOffsetForRestore(int freq, bool shouldRestore){ setFreq4(freq, freq); if(shouldRestore){ diff --git a/mainwindow.h b/mainwindow.h index ab92655..a01a534 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -125,6 +125,7 @@ public slots: void readFromStdout(); void p1ReadFromStdout(); void setXIT(int n, Frequency base = 0u); + void qsy(int hzDelta); void setFreqOffsetForRestore(int freq, bool shouldRestore); bool tryRestoreFreqOffset(); void setFreq4(int rxFreq, int txFreq); diff --git a/plotter.cpp b/plotter.cpp index 57ba074..abce7c0 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -41,7 +41,8 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor m_rxFreq {1020}, m_txFreq {0}, m_startFreq {0}, - m_lastMouseX {-1} + m_lastMouseX {-1}, + m_menuOpen {false} { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setFocusPolicy(Qt::StrongFocus); @@ -52,21 +53,6 @@ CPlotter::CPlotter(QWidget *parent) : //CPlotter Constructor m_bReplot=false; setMouseTracking(true); - -#if 0 - // contextual pop up menu - setContextMenuPolicy (Qt::CustomContextMenu); - connect (this, &QWidget::customContextMenuRequested, [this] (QPoint const& pos) { - QMenu menu {this}; - menu.addAction (m_set_freq_action); - auto const& connection = connect (m_set_freq_action, &QAction::triggered, [this, pos] () { - int newFreq = FreqfromX (pos.x ()) + .5; - emit setFreq1 (newFreq, newFreq); - }); - menu.exec (mapToGlobal (pos)); - disconnect (connection); - }); -#endif } CPlotter::~CPlotter() { } // Destructor diff --git a/plotter.h b/plotter.h index 5cb1df8..1557186 100644 --- a/plotter.h +++ b/plotter.h @@ -90,6 +90,7 @@ public: signals: void freezeDecode1(int n); void setFreq1(int rxFreq, int txFreq); + void qsy(int hzDelta); protected: //re-implemented widget event handlers @@ -179,6 +180,7 @@ private: qint32 m_tol; qint32 m_j; qint32 m_lastMouseX; + bool m_menuOpen; char m_sutc[6]; }; diff --git a/widegraph.cpp b/widegraph.cpp index f4ca4f5..95e1bb1 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -42,7 +42,12 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) : connect(ui->widePlot, SIGNAL(setFreq1(int,int)),this, SLOT(setFreq2(int,int))); + connect(ui->widePlot, &CPlotter::qsy, this, [this](int hzDelta){ + emit qsy(hzDelta); + }); + { + //Restore user's settings SettingsGroup g {m_settings, "WideGraph"}; restoreGeometry (m_settings->value ("geometry", saveGeometry ()).toByteArray ()); @@ -81,6 +86,7 @@ WideGraph::WideGraph(QSettings * settings, QWidget *parent) : ui->sbPercent2dPlot->setValue(m_Percent2DScreen); ui->widePlot->SetPercent2DScreen(m_Percent2DScreen); ui->widePlot->setStartFreq(m_settings->value("StartFreq", 500).toInt()); + ui->centerSpinBox->setValue(m_settings->value("CenterOffset", 1500).toInt()); ui->fStartSpinBox->setValue(ui->widePlot->startFreq()); m_waterfallPalette=m_settings->value("WaterfallPalette","Default").toString(); m_userPalette = WFPalette {m_settings->value("UserPalette").value ()}; @@ -141,6 +147,7 @@ void WideGraph::saveSettings() //saveS m_settings->setValue("UseRef",m_bRef); m_settings->setValue ("HideControls", ui->controls_widget->isHidden ()); m_settings->setValue ("FminPerBand", m_fMinPerBand); + m_settings->setValue ("CenterOffset", ui->centerSpinBox->value()); } void WideGraph::drawRed(int ia, int ib) @@ -207,6 +214,11 @@ void WideGraph::on_bppSpinBox_valueChanged(int n) //b ui->widePlot->setBinsPerPixel(n); } +void WideGraph::on_qsyPushButton_clicked(){ + int hzDelta = rxFreq() - ui->centerSpinBox->value(); + emit qsy(hzDelta); +} + void WideGraph::on_offsetSpinBox_valueChanged(int n){ if(n == rxFreq()){ return; diff --git a/widegraph.h b/widegraph.h index 9701257..5e5f49e 100644 --- a/widegraph.h +++ b/widegraph.h @@ -55,6 +55,7 @@ signals: void f11f12(int n); void setXIT2(int n); void setFreq3(int rxFreq, int txFreq); + void qsy(int hzDelta); public slots: void wideFreezeDecode(int n); @@ -68,6 +69,7 @@ protected: void closeEvent (QCloseEvent *) override; private slots: + void on_qsyPushButton_clicked(); void on_offsetSpinBox_valueChanged(int n); void on_waterfallAvgSpinBox_valueChanged(int arg1); void on_bppSpinBox_valueChanged(int arg1); diff --git a/widegraph.ui b/widegraph.ui index 62b9410..23d09a0 100644 --- a/widegraph.ui +++ b/widegraph.ui @@ -56,9 +56,6 @@ 1 - - false - 5 @@ -67,6 +64,9 @@ 17 + + false + Controls @@ -103,127 +103,7 @@ 0 - - - - <html><head/><body><p>Select data for spectral display</p></body></html> - - - 0 - - - - Current - - - - - Cumulative - - - - - Linear Avg - - - - - Reference - - - - - - - - Number of FFTs averaged (controls waterfall scrolling rate) - - - N Avg - - - 1 - - - 50 - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - <html><head/><body><p>Frequency at left edge of waterfall</p></body></html> - - - Hz - - - Start - - - 5000 - - - 100 - - - 500 - - - - - - - false - - - Smoothing of Linear Average spectrum - - - Qt::AlignCenter - - - - - - Smooth - - - 1 - - - 7 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + @@ -260,14 +140,62 @@ - - + + - Select waterfall palette + <html><head/><body><p>Set fractional size of spectrum in this window.</p></body></html> + + + Qt::AlignCenter + + + % + + + Spec + + + 100 + + + 5 + + + 0 - + + + + <html><head/><body><p>Select data for spectral display</p></body></html> + + + 0 + + + + Current + + + + + Cumulative + + + + + Linear Avg + + + + + Reference + + + + + @@ -291,81 +219,32 @@ - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 200 - 16777215 - - + + - Spectrum gain + Compression factor for frequency scale + + + + + + Bins/Pixel - -50 + 1 - 50 + 1000 - - Qt::Horizontal + + 1 - - QSlider::TicksAbove + + 5 - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 200 - 16777215 - - - - Waterfall gain - - - -50 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksAbove - - - - + @@ -402,8 +281,111 @@ - - + + + + <html><head/><body><p>Frequency at left edge of waterfall</p></body></html> + + + Hz + + + Start + + + 5000 + + + 100 + + + 500 + + + + + + + Select waterfall palette + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 200 + 16777215 + + + + Waterfall gain + + + -50 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 200 + 16777215 + + + + Spectrum gain + + + -50 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + + + Qt::Horizontal @@ -415,56 +397,81 @@ - - + + - <html><head/><body><p>Set fractional size of spectrum in this window.</p></body></html> + Number of FFTs averaged (controls waterfall scrolling rate) + + + N Avg + + + 1 + + + 50 + + + + + + + false + + + Smoothing of Linear Average spectrum Qt::AlignCenter - % + - Spec + Smooth + + + 1 - 100 - - - 5 - - - 0 + 7 - - - - - - Palette - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - <html><head/><body><p>Enter definition for a new color palette.</p></body></html> - - - Adjust... - - - - - + + + Hz + + + Offset + + + 5000 + + + 1 + + + 1500 + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + false @@ -492,50 +499,69 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Palette + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + <html><head/><body><p>Enter definition for a new color palette.</p></body></html> + + + Adjust... + + + + + + + + + QSY + + + - + Hz - Offset + Center + + + 500 5000 - - 1 - 1500 - - - - Compression factor for frequency scale - - - - - - Bins/Pixel - - - 1 - - - 1000 - - - 1 - - - 5 - - -