From d81b8168ad9ac2981cb4937b058fcad56f575053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 27 Nov 2020 16:36:21 +0100 Subject: [PATCH 1/3] Disable initially invalid options on dialog creation --- Software/PC_Application/Traces/xyplotaxisdialog.cpp | 5 +++-- Software/PC_Application/Traces/xyplotaxisdialog.ui | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Software/PC_Application/Traces/xyplotaxisdialog.cpp b/Software/PC_Application/Traces/xyplotaxisdialog.cpp index f454c07..8bfddcd 100644 --- a/Software/PC_Application/Traces/xyplotaxisdialog.cpp +++ b/Software/PC_Application/Traces/xyplotaxisdialog.cpp @@ -47,8 +47,6 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) : ui->Y2divs->setUnit(unit); }); - connect(ui->XType, qOverload(&QComboBox::currentIndexChanged), this, &XYplotAxisDialog::XAxisTypeChanged); - connect(ui->Y2auto, &QCheckBox::toggled, [this](bool checked) { ui->Y2min->setEnabled(!checked); ui->Y2max->setEnabled(!checked); @@ -67,6 +65,9 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) : ui->Xmax->setPrefixes("pnum kMG"); ui->Xdivs->setPrefixes("pnum kMG"); + XAxisTypeChanged((int) plot->XAxis.type); + connect(ui->XType, qOverload(&QComboBox::currentIndexChanged), this, &XYplotAxisDialog::XAxisTypeChanged); + // Fill initial values // assume same order in YAxisType enum as in ComboBox items ui->Y1type->setCurrentIndex((int) plot->YAxis[0].type); diff --git a/Software/PC_Application/Traces/xyplotaxisdialog.ui b/Software/PC_Application/Traces/xyplotaxisdialog.ui index be949d6..8141a23 100644 --- a/Software/PC_Application/Traces/xyplotaxisdialog.ui +++ b/Software/PC_Application/Traces/xyplotaxisdialog.ui @@ -445,6 +445,9 @@ + + false + Use Span From 6893af138644cba975a90295994e210b031fa616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 27 Nov 2020 16:53:41 +0100 Subject: [PATCH 2/3] Prevent crash on Y-axis autoscale when all trace values are identical --- .../PC_Application/Traces/tracexyplot.cpp | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Software/PC_Application/Traces/tracexyplot.cpp b/Software/PC_Application/Traces/tracexyplot.cpp index fd9eb65..a62772c 100644 --- a/Software/PC_Application/Traces/tracexyplot.cpp +++ b/Software/PC_Application/Traces/tracexyplot.cpp @@ -462,6 +462,7 @@ void TraceXYPlot::updateAxisTicks() }; auto createAutomaticTicks = [](vector& ticks, double start, double stop, int minDivisions) -> double { + Q_ASSERT(stop > start); ticks.clear(); double max_div_step = (stop - start) / minDivisions; int zeros = floor(log10(max_div_step)); @@ -561,13 +562,28 @@ void TraceXYPlot::updateAxisTicks() } } } - // add 5% overrange - auto range = max - min; - min -= range * 0.05; - max += range * 0.05; - YAxis[i].rangeMin = min; - YAxis[i].rangeMax = max; - YAxis[i].rangeDiv = createAutomaticTicks(YAxis[i].ticks, min, max, 8); + if(max >= min) { + auto range = max - min; + if(range == 0.0) { + // this could happen if all values in a trace are identical (e.g. imported ideal touchstone files) + if(max == 0.0) { + // simply use +/-1 range + max = 1.0; + min = -1.0; + } else { + // +/-5% around value + max += abs(max * 0.05); + min -= abs(max * 0.05); + } + } else { + // add 5% of range at both ends + min -= range * 0.05; + max += range * 0.05; + } + YAxis[i].rangeMin = min; + YAxis[i].rangeMax = max; + YAxis[i].rangeDiv = createAutomaticTicks(YAxis[i].ticks, min, max, 8); + } } } } From 0837db05adab346ea7280accbc442d9f901720bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 27 Nov 2020 18:18:31 +0100 Subject: [PATCH 3/3] Option to view raw calibration measurements + calkit typos fixed --- .../Calibration/calibration.cpp | 49 +++++++++++++++++++ .../PC_Application/Calibration/calibration.h | 1 + .../Calibration/calkitdialog.ui | 26 +++++----- Software/PC_Application/Traces/tracemodel.cpp | 2 +- Software/PC_Application/VNA/vna.cpp | 29 +++++++---- 5 files changed, 84 insertions(+), 23 deletions(-) diff --git a/Software/PC_Application/Calibration/calibration.cpp b/Software/PC_Application/Calibration/calibration.cpp index 875af02..a68667c 100644 --- a/Software/PC_Application/Calibration/calibration.cpp +++ b/Software/PC_Application/Calibration/calibration.cpp @@ -621,6 +621,55 @@ std::vector Calibration::getErrorTermTraces() return traces; } +std::vector Calibration::getMeasurementTraces() +{ + std::vector traces; + for(auto m : measurements) { + auto info = getMeasurementInfo(m.first); + if(info.points > 0) { + vector usedPrefixes; + switch(m.first) { + case Measurement::Port1Load: + case Measurement::Port1Open: + case Measurement::Port1Short: + usedPrefixes = {"S11"}; + break; + case Measurement::Port2Load: + case Measurement::Port2Open: + case Measurement::Port2Short: + usedPrefixes = {"S22"}; + break; + case Measurement::Through: + case Measurement::Line: + case Measurement::Isolation: + usedPrefixes = {"S11", "S12", "S21", "S22"}; + break; + } + for(auto prefix : usedPrefixes) { + auto t = new Trace(prefix + " " + info.name); + t->setCalibration(true); + t->setReflection(prefix == "S11" || prefix == "S22"); + for(auto p : m.second.datapoints) { + Trace::Data d; + d.frequency = p.frequency; + if(prefix == "S11") { + d.S = complex(p.real_S11, p.imag_S11); + } else if(prefix == "S12") { + d.S = complex(p.real_S12, p.imag_S12); + } else if(prefix == "S21") { + d.S = complex(p.real_S21, p.imag_S21); + } else { + d.S = complex(p.real_S22, p.imag_S22); + } + t->addData(d); + } + traces.push_back(t); + } + } + } + return traces; +} + bool Calibration::openFromFile(QString filename) { if(filename.isEmpty()) { diff --git a/Software/PC_Application/Calibration/calibration.h b/Software/PC_Application/Calibration/calibration.h index 87d68a1..47b496d 100644 --- a/Software/PC_Application/Calibration/calibration.h +++ b/Software/PC_Application/Calibration/calibration.h @@ -80,6 +80,7 @@ public: } std::vector getErrorTermTraces(); + std::vector getMeasurementTraces(); bool openFromFile(QString filename = QString()); bool saveToFile(QString filename = QString()); diff --git a/Software/PC_Application/Calibration/calkitdialog.ui b/Software/PC_Application/Calibration/calkitdialog.ui index a457b25..4048d94 100644 --- a/Software/PC_Application/Calibration/calkitdialog.ui +++ b/Software/PC_Application/Calibration/calkitdialog.ui @@ -32,7 +32,7 @@ - 1 + 0 @@ -112,7 +112,7 @@ - <html><head/><body><p>L0 [10<span style=" vertical-align:super;">-12</span>F]:</p></body></html> + <html><head/><body><p>L0 [10<span style=" vertical-align:super;">-12</span>H]:</p></body></html> @@ -122,7 +122,7 @@ - <html><head/><body><p>L1 [10<span style=" vertical-align:super;">-24</span>F/Hz]:</p></body></html> + <html><head/><body><p>L1 [10<span style=" vertical-align:super;">-24</span>H/Hz]:</p></body></html> @@ -132,7 +132,7 @@ - <html><head/><body><p>L2 [10<span style=" vertical-align:super;">-33</span>F/Hz<span style=" vertical-align:super;">2</span>]:</p></body></html> + <html><head/><body><p>L2 [10<span style=" vertical-align:super;">-33</span>H/Hz<span style=" vertical-align:super;">2</span>]:</p></body></html> @@ -142,7 +142,7 @@ - <html><head/><body><p>L3 [10<span style=" vertical-align:super;">-42</span>F/Hz<span style=" vertical-align:super;">3</span>]:</p></body></html> + <html><head/><body><p>L3 [10<span style=" vertical-align:super;">-42</span>H/Hz<span style=" vertical-align:super;">3</span>]:</p></body></html> @@ -288,7 +288,7 @@ - C0 [10<sup>-45</sup>F/Hz<sup>3</sup>]: + <html><head/><body><p>C3 [10<span style=" vertical-align:super;">-45</span>F/Hz<span style=" vertical-align:super;">3</span>]:</p></body></html> @@ -845,17 +845,17 @@ + + SIUnitEdit + QLineEdit +
CustomWidgets/siunitedit.h
+
TouchstoneImport QWidget
CustomWidgets/touchstoneimport.h
1
- - SIUnitEdit - QLineEdit -
CustomWidgets/siunitedit.h
-
open_Z0 @@ -933,10 +933,10 @@ - + + - diff --git a/Software/PC_Application/Traces/tracemodel.cpp b/Software/PC_Application/Traces/tracemodel.cpp index e90eab7..e30d663 100644 --- a/Software/PC_Application/Traces/tracemodel.cpp +++ b/Software/PC_Application/Traces/tracemodel.cpp @@ -97,7 +97,7 @@ QVariant TraceModel::data(const QModelIndex &index, int role) const return QVariant(); } } else if (index.column() == 1) { - if (role == Qt::DecorationRole && !traces[index.row()]->isTouchstone()) { + if (role == Qt::DecorationRole && traces[index.row()]->isLive()) { if (traces[index.row()]->isPaused()) { return QIcon(":/icons/pause.svg"); } else { diff --git a/Software/PC_Application/VNA/vna.cpp b/Software/PC_Application/VNA/vna.cpp index 132fa97..96ab4fb 100644 --- a/Software/PC_Application/VNA/vna.cpp +++ b/Software/PC_Application/VNA/vna.cpp @@ -119,13 +119,6 @@ VNA::VNA(AppWindow *window) StartCalibrationDialog(); }); - auto calImport = calMenu->addAction("Import error terms as traces"); - calImport->setEnabled(false); - connect(calImport, &QAction::triggered, [=](){ - auto import = new TraceImportDialog(traceModel, cal.getErrorTermTraces()); - import->show(); - }); - auto calEditKit = calMenu->addAction("Edit Calibration Kit"); connect(calEditKit, &QAction::triggered, [=](){ cal.getCalibrationKit().edit([=](){ @@ -134,6 +127,22 @@ VNA::VNA(AppWindow *window) } }); }); + + calMenu->addSeparator(); + + auto calImportTerms = calMenu->addAction("Import error terms as traces"); + calImportTerms->setEnabled(false); + connect(calImportTerms, &QAction::triggered, [=](){ + auto import = new TraceImportDialog(traceModel, cal.getErrorTermTraces()); + import->show(); + }); + auto calImportMeas = calMenu->addAction("Import measurements as traces"); + calImportMeas->setEnabled(false); + connect(calImportMeas, &QAction::triggered, [=](){ + auto import = new TraceImportDialog(traceModel, cal.getMeasurementTraces()); + import->show(); + }); + portExtension.setCalkit(&cal.getCalibrationKit()); // Tools menu @@ -319,7 +328,8 @@ VNA::VNA(AppWindow *window) cbEnableCal->setCheckState(Qt::CheckState::Unchecked); cbType->blockSignals(false); cbEnableCal->blockSignals(false); - calImport->setEnabled(false); + calImportTerms->setEnabled(false); + calImportMeas->setEnabled(false); saveCal->setEnabled(false); }); connect(calDisable, &QAction::triggered, this, &VNA::DisableCalibration); @@ -335,7 +345,8 @@ VNA::VNA(AppWindow *window) cbEnableCal->setCheckState(Qt::CheckState::Checked); cbType->blockSignals(false); cbEnableCal->blockSignals(false); - calImport->setEnabled(true); + calImportTerms->setEnabled(true); + calImportMeas->setEnabled(true); saveCal->setEnabled(true); });