From d6cecf260345bcd6a96c73977bb190864964cf37 Mon Sep 17 00:00:00 2001 From: Kiara Navarro Date: Mon, 28 Jun 2021 23:47:02 -0300 Subject: [PATCH] gui: replot active mode when settings plot are updated --- .../SpectrumAnalyzer/spectrumanalyzer.cpp | 11 +++++++++++ .../SpectrumAnalyzer/spectrumanalyzer.h | 4 ++++ Software/PC_Application/Traces/traceplot.cpp | 5 +++++ Software/PC_Application/Traces/traceplot.h | 3 +++ Software/PC_Application/Traces/tracesmithchart.h | 1 + Software/PC_Application/VNA/vna.cpp | 12 ++++++++++++ Software/PC_Application/VNA/vna.h | 5 +++++ Software/PC_Application/appwindow.cpp | 11 +++++++++-- 8 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp index 488fef8..031bee5 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -69,6 +69,12 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window) traceXY->setYAxis(0, TraceXYPlot::YAxisType::Magnitude, false, false, -120,0,10); traceXY->setYAxis(1, TraceXYPlot::YAxisType::Disabled, false, true, 0,0,1); + connect(this, &SpectrumAnalyzer::graphColorsChanged, [=](){ + for (auto p : TracePlot::getPlots()) { + p->updateGraphColors(); + } + }); + central->setPlot(traceXY); // Create menu entries and connections @@ -960,3 +966,8 @@ void SpectrumAnalyzer::StoreSweepSettings() s.setValue("SAAveraging", averages); s.setValue("SASignalID", static_cast(settings.SignalID)); } + +void SpectrumAnalyzer::updateGraphColors() +{ + emit graphColorsChanged(); +} diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h index 1f8e7ac..48bfff1 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.h @@ -24,6 +24,9 @@ public: virtual nlohmann::json toJSON() override; virtual void fromJSON(nlohmann::json j) override; + void updateGraphColors(); + + private: enum class Window { None = 0, @@ -117,6 +120,7 @@ signals: void NormalizationLevelChanged(double level); void averagingChanged(unsigned int averages); + void graphColorsChanged(); }; #endif // VNA_H diff --git a/Software/PC_Application/Traces/traceplot.cpp b/Software/PC_Application/Traces/traceplot.cpp index c07ae90..4d31318 100644 --- a/Software/PC_Application/Traces/traceplot.cpp +++ b/Software/PC_Application/Traces/traceplot.cpp @@ -391,3 +391,8 @@ void TracePlot::markerRemoved(Marker *m) disconnect(m, &Marker::symbolChanged, this, &TracePlot::triggerReplot); triggerReplot(); } + +void TracePlot::updateGraphColors() +{ + replot(); +} diff --git a/Software/PC_Application/Traces/traceplot.h b/Software/PC_Application/Traces/traceplot.h index 081d76e..831e04a 100644 --- a/Software/PC_Application/Traces/traceplot.h +++ b/Software/PC_Application/Traces/traceplot.h @@ -28,6 +28,9 @@ public: static std::set getPlots(); +public slots: + void updateGraphColors(); + signals: void doubleClicked(QWidget *w); void deleted(TracePlot*); diff --git a/Software/PC_Application/Traces/tracesmithchart.h b/Software/PC_Application/Traces/tracesmithchart.h index c14faa3..5a9924e 100644 --- a/Software/PC_Application/Traces/tracesmithchart.h +++ b/Software/PC_Application/Traces/tracesmithchart.h @@ -18,6 +18,7 @@ public: virtual void fromJSON(nlohmann::json j) override; public slots: void axisSetupDialog(); + protected: static constexpr double ReferenceImpedance = 50.0; static constexpr double screenUsage = 0.9; diff --git a/Software/PC_Application/VNA/vna.cpp b/Software/PC_Application/VNA/vna.cpp index 1999e3a..1b797d8 100644 --- a/Software/PC_Application/VNA/vna.cpp +++ b/Software/PC_Application/VNA/vna.cpp @@ -75,6 +75,7 @@ VNA::VNA(AppWindow *window) auto tracesmith1 = new TraceSmithChart(traceModel); tracesmith1->enableTrace(tS11, true); + auto tracesmith2 = new TraceSmithChart(traceModel); tracesmith2->enableTrace(tS22, true); @@ -83,6 +84,12 @@ VNA::VNA(AppWindow *window) auto traceXY2 = new TraceXYPlot(traceModel); traceXY2->enableTrace(tS21, true); + connect(this, &VNA::graphColorsChanged, [=](){ + for (auto p : TracePlot::getPlots()) { + p->updateGraphColors(); + } + }); + connect(&traceModel, &TraceModel::requiredExcitation, this, &VNA::ExcitationRequired); central->splitVertically(); @@ -1117,3 +1124,8 @@ void VNA::EnableDeembedding(bool enable) enableDeembeddingAction->setChecked(enable); enableDeembeddingAction->blockSignals(false); } + +void VNA::updateGraphColors() +{ + emit graphColorsChanged(); +} diff --git a/Software/PC_Application/VNA/vna.h b/Software/PC_Application/VNA/vna.h index 7f15a48..31a3c35 100644 --- a/Software/PC_Application/VNA/vna.h +++ b/Software/PC_Application/VNA/vna.h @@ -26,6 +26,9 @@ public: // Only save/load user changeable stuff, no need to save the widgets/mode name etc. virtual nlohmann::json toJSON() override; virtual void fromJSON(nlohmann::json j) override; + + void updateGraphColors(); + private slots: void NewDatapoint(Protocol::Datapoint d); void StartImpedanceMatching(); @@ -48,8 +51,10 @@ private slots: void ApplyCalibration(Calibration::Type type); void StartCalibrationMeasurement(Calibration::Measurement m); + signals: void CalibrationMeasurementComplete(Calibration::Measurement m); + void graphColorsChanged(); private: bool CalibrationMeasurementActive() { return calWaitFirst || calMeasuring; } diff --git a/Software/PC_Application/appwindow.cpp b/Software/PC_Application/appwindow.cpp index c86f267..411fa8c 100644 --- a/Software/PC_Application/appwindow.cpp +++ b/Software/PC_Application/appwindow.cpp @@ -202,8 +202,15 @@ AppWindow::AppWindow(QWidget *parent) StartTCPServer(p.General.SCPI.port); } } - // settings might have changed, update necessary stuff -// TraceXYPlot::updateGraphColors(); + auto active = Mode::getActiveMode(); + + if(active == spectrumAnalyzer) { + spectrumAnalyzer->updateGraphColors(); + } + else if (active == vna) { + vna->updateGraphColors(); + } + }); connect(ui->actionAbout, &QAction::triggered, [=](){