vna/mode/app/sa: refactor plot update colors

This commit is contained in:
Kiara Navarro 2022-06-23 21:46:12 -05:00
parent 794f55f1fb
commit 423585845e
No known key found for this signature in database
GPG Key ID: CBA9F2172CE33FBA
7 changed files with 11 additions and 31 deletions

View File

@ -73,12 +73,6 @@ SpectrumAnalyzer::SpectrumAnalyzer(AppWindow *window, QString name)
traceXY->setYAxis(0, YAxis::Type::Magnitude, false, false, -120,0,10); traceXY->setYAxis(0, YAxis::Type::Magnitude, false, false, -120,0,10);
traceXY->setYAxis(1, YAxis::Type::Disabled, false, true, 0,0,1); traceXY->setYAxis(1, YAxis::Type::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
@ -1127,11 +1121,6 @@ void SpectrumAnalyzer::StoreSweepSettings()
s.setValue("SASignalID", static_cast<bool>(settings.SignalID)); s.setValue("SASignalID", static_cast<bool>(settings.SignalID));
} }
void SpectrumAnalyzer::updateGraphColors()
{
emit graphColorsChanged();
}
void SpectrumAnalyzer::setAveragingMode(Averaging::Mode mode) void SpectrumAnalyzer::setAveragingMode(Averaging::Mode mode)
{ {
average.setMode(mode); average.setMode(mode);

View File

@ -134,7 +134,6 @@ 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

@ -95,12 +95,6 @@ VNA::VNA(AppWindow *window, QString name)
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();
@ -1644,11 +1638,6 @@ void VNA::EnableDeembedding(bool enable)
enableDeembeddingAction->blockSignals(false); enableDeembeddingAction->blockSignals(false);
} }
void VNA::updateGraphColors()
{
emit graphColorsChanged();
}
void VNA::setAveragingMode(Averaging::Mode mode) void VNA::setAveragingMode(Averaging::Mode mode)
{ {
average.setMode(mode); average.setMode(mode);

View File

@ -110,7 +110,6 @@ private slots:
signals: signals:
void CalibrationMeasurementsComplete(std::set<Calibration::Measurement> m); void CalibrationMeasurementsComplete(std::set<Calibration::Measurement> m);
void graphColorsChanged();
private: private:
bool CalibrationMeasurementActive() { return calWaitFirst || calMeasuring; } bool CalibrationMeasurementActive() { return calWaitFirst || calMeasuring; }

View File

@ -184,14 +184,9 @@ AppWindow::AppWindow(QWidget *parent)
StartTCPServer(p.SCPIServer.port); StartTCPServer(p.SCPIServer.port);
} }
} }
auto active = Mode::getActiveMode();
if(active == spectrumAnalyzer) { auto active = Mode::getActiveMode();
spectrumAnalyzer->updateGraphColors(); active->updateGraphColors();
}
else if (active == vna) {
vna->updateGraphColors();
}
// averaging mode may have changed, update for all relevant modes // averaging mode may have changed, update for all relevant modes
if(p.Acquisition.useMedianAveraging) { if(p.Acquisition.useMedianAveraging) {

View File

@ -338,3 +338,11 @@ void Mode::setName(const QString &value)
tabbar->setTabText(findTabIndex(), name); tabbar->setTabText(findTabIndex(), name);
} }
void Mode::updateGraphColors()
{
if ((getType() == Type::SA) || getType() == Type::VNA) {
for (auto p : TracePlot::getPlots()) {
p->updateGraphColors();
}
}
}

View File

@ -32,6 +32,7 @@ public:
virtual void shutdown(){}; // called when the application is about to exit virtual void shutdown(){}; // called when the application is about to exit
QString getName() const; QString getName() const;
void setName(const QString &value); void setName(const QString &value);
void updateGraphColors();
static Mode *getActiveMode(); static Mode *getActiveMode();
static QString TypeToName(Type t); static QString TypeToName(Type t);
static Type TypeFromName(QString s); static Type TypeFromName(QString s);