Merge pull request #36 from sophiekovalevsky/update-plots

gui: replot active mode when settings plot are updated
This commit is contained in:
jankae 2021-06-29 20:48:44 +02:00 committed by GitHub
commit d7ae23bdda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 50 additions and 2 deletions

View File

@ -69,6 +69,12 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window)
traceXY->setYAxis(0, TraceXYPlot::YAxisType::Magnitude, false, false, -120,0,10); traceXY->setYAxis(0, TraceXYPlot::YAxisType::Magnitude, false, false, -120,0,10);
traceXY->setYAxis(1, TraceXYPlot::YAxisType::Disabled, false, true, 0,0,1); 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); central->setPlot(traceXY);
// Create menu entries and connections // Create menu entries and connections
@ -960,3 +966,8 @@ void SpectrumAnalyzer::StoreSweepSettings()
s.setValue("SAAveraging", averages); s.setValue("SAAveraging", averages);
s.setValue("SASignalID", static_cast<bool>(settings.SignalID)); s.setValue("SASignalID", static_cast<bool>(settings.SignalID));
} }
void SpectrumAnalyzer::updateGraphColors()
{
emit graphColorsChanged();
}

View File

@ -24,6 +24,9 @@ public:
virtual nlohmann::json toJSON() override; virtual nlohmann::json toJSON() override;
virtual void fromJSON(nlohmann::json j) override; virtual void fromJSON(nlohmann::json j) override;
void updateGraphColors();
private: private:
enum class Window { enum class Window {
None = 0, None = 0,
@ -117,6 +120,7 @@ signals:
void NormalizationLevelChanged(double level); void NormalizationLevelChanged(double level);
void averagingChanged(unsigned int averages); void averagingChanged(unsigned int averages);
void graphColorsChanged();
}; };
#endif // VNA_H #endif // VNA_H

View File

@ -391,3 +391,8 @@ void TracePlot::markerRemoved(Marker *m)
disconnect(m, &Marker::symbolChanged, this, &TracePlot::triggerReplot); disconnect(m, &Marker::symbolChanged, this, &TracePlot::triggerReplot);
triggerReplot(); triggerReplot();
} }
void TracePlot::updateGraphColors()
{
replot();
}

View File

@ -28,6 +28,9 @@ public:
static std::set<TracePlot *> getPlots(); static std::set<TracePlot *> getPlots();
public slots:
void updateGraphColors();
signals: signals:
void doubleClicked(QWidget *w); void doubleClicked(QWidget *w);
void deleted(TracePlot*); void deleted(TracePlot*);

View File

@ -18,6 +18,7 @@ public:
virtual void fromJSON(nlohmann::json j) override; virtual void fromJSON(nlohmann::json j) override;
public slots: public slots:
void axisSetupDialog(); void axisSetupDialog();
protected: protected:
static constexpr double ReferenceImpedance = 50.0; static constexpr double ReferenceImpedance = 50.0;
static constexpr double screenUsage = 0.9; static constexpr double screenUsage = 0.9;

View File

@ -75,6 +75,7 @@ VNA::VNA(AppWindow *window)
auto tracesmith1 = new TraceSmithChart(traceModel); auto tracesmith1 = new TraceSmithChart(traceModel);
tracesmith1->enableTrace(tS11, true); tracesmith1->enableTrace(tS11, true);
auto tracesmith2 = new TraceSmithChart(traceModel); auto tracesmith2 = new TraceSmithChart(traceModel);
tracesmith2->enableTrace(tS22, true); tracesmith2->enableTrace(tS22, true);
@ -83,6 +84,12 @@ VNA::VNA(AppWindow *window)
auto traceXY2 = new TraceXYPlot(traceModel); auto traceXY2 = new TraceXYPlot(traceModel);
traceXY2->enableTrace(tS21, true); traceXY2->enableTrace(tS21, true);
connect(this, &VNA::graphColorsChanged, [=](){
for (auto p : TracePlot::getPlots()) {
p->updateGraphColors();
}
});
connect(&traceModel, &TraceModel::requiredExcitation, this, &VNA::ExcitationRequired); connect(&traceModel, &TraceModel::requiredExcitation, this, &VNA::ExcitationRequired);
central->splitVertically(); central->splitVertically();
@ -1117,3 +1124,8 @@ void VNA::EnableDeembedding(bool enable)
enableDeembeddingAction->setChecked(enable); enableDeembeddingAction->setChecked(enable);
enableDeembeddingAction->blockSignals(false); enableDeembeddingAction->blockSignals(false);
} }
void VNA::updateGraphColors()
{
emit graphColorsChanged();
}

View File

@ -26,6 +26,9 @@ public:
// Only save/load user changeable stuff, no need to save the widgets/mode name etc. // Only save/load user changeable stuff, no need to save the widgets/mode name etc.
virtual nlohmann::json toJSON() override; virtual nlohmann::json toJSON() override;
virtual void fromJSON(nlohmann::json j) override; virtual void fromJSON(nlohmann::json j) override;
void updateGraphColors();
private slots: private slots:
void NewDatapoint(Protocol::Datapoint d); void NewDatapoint(Protocol::Datapoint d);
void StartImpedanceMatching(); void StartImpedanceMatching();
@ -48,8 +51,10 @@ private slots:
void ApplyCalibration(Calibration::Type type); void ApplyCalibration(Calibration::Type type);
void StartCalibrationMeasurement(Calibration::Measurement m); void StartCalibrationMeasurement(Calibration::Measurement m);
signals: signals:
void CalibrationMeasurementComplete(Calibration::Measurement m); void CalibrationMeasurementComplete(Calibration::Measurement m);
void graphColorsChanged();
private: private:
bool CalibrationMeasurementActive() { return calWaitFirst || calMeasuring; } bool CalibrationMeasurementActive() { return calWaitFirst || calMeasuring; }

View File

@ -202,8 +202,15 @@ AppWindow::AppWindow(QWidget *parent)
StartTCPServer(p.General.SCPI.port); StartTCPServer(p.General.SCPI.port);
} }
} }
// settings might have changed, update necessary stuff auto active = Mode::getActiveMode();
// TraceXYPlot::updateGraphColors();
if(active == spectrumAnalyzer) {
spectrumAnalyzer->updateGraphColors();
}
else if (active == vna) {
vna->updateGraphColors();
}
}); });
connect(ui->actionAbout, &QAction::triggered, [=](){ connect(ui->actionAbout, &QAction::triggered, [=](){