From e93e364079dcc7dd8f651015871f74b191f99840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 1 Mar 2024 09:25:47 +0100 Subject: [PATCH] update smith chart reference impedance when trace impedance changes but keep smith lines in place --- .../PC_Application/LibreVNA-GUI/Traces/trace.cpp | 12 ++++++++---- Software/PC_Application/LibreVNA-GUI/Traces/trace.h | 2 +- .../PC_Application/LibreVNA-GUI/Traces/traceplot.cpp | 2 ++ .../LibreVNA-GUI/Traces/tracesmithchart.cpp | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp index 9215011..40a16b0 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/trace.cpp @@ -179,12 +179,17 @@ void Trace::addDeembeddingData(const Trace::Data &d, double reference_impedance, deembeddingData.insert(lower, d); } } - deembedded_reference_impedance = reference_impedance; + if(deembedded_reference_impedance != reference_impedance) { + deembedded_reference_impedance = reference_impedance; + if(deembeddingActive) { + emit typeChanged(this); + } + } if(deembeddingActive) { emit outputSamplesChanged(index, index + 1); } if(!wasAvailable) { - emit deembeddingChanged(); + emit deembeddingChanged(this); } } @@ -1333,14 +1338,13 @@ void Trace::setDeembeddingActive(bool active) emit outputSamplesChanged(0, data.size()); } } - emit deembeddingChanged(); + emit deembeddingChanged(this); } void Trace::clearDeembedding() { deembeddingData.clear(); setDeembeddingActive(false); - deembeddingChanged(); } double Trace::minX() diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/trace.h b/Software/PC_Application/LibreVNA-GUI/Traces/trace.h index 3ef220a..8582c55 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/trace.h +++ b/Software/PC_Application/LibreVNA-GUI/Traces/trace.h @@ -207,7 +207,7 @@ signals: void dataChanged(unsigned int begin, unsigned int end); void nameChanged(); void pauseChanged(); - void deembeddingChanged(); + void deembeddingChanged(Trace *t); void colorChanged(Trace *t); void markerAdded(Marker *m); void markerRemoved(Marker *m); diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp index f657af8..282c9b7 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp @@ -79,6 +79,7 @@ void TracePlot::enableTrace(Trace *t, bool enabled) connect(t, &Trace::markerAdded, this, &TracePlot::markerAdded); connect(t, &Trace::markerRemoved, this, &TracePlot::markerRemoved); connect(t, &Trace::typeChanged, this, &TracePlot::checkIfStillSupported); + connect(t, &Trace::deembeddingChanged, this, &TracePlot::checkIfStillSupported); connect(t, &Trace::colorChanged, this, &TracePlot::triggerReplot); } else { // disconnect from notifications @@ -88,6 +89,7 @@ void TracePlot::enableTrace(Trace *t, bool enabled) disconnect(t, &Trace::markerAdded, this, &TracePlot::markerAdded); disconnect(t, &Trace::markerRemoved, this, &TracePlot::markerRemoved); disconnect(t, &Trace::typeChanged, this, &TracePlot::checkIfStillSupported); + disconnect(t, &Trace::deembeddingChanged, this, &TracePlot::checkIfStillSupported); disconnect(t, &Trace::colorChanged, this, &TracePlot::triggerReplot); } updateContextMenu(); diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp index 73f0058..5a85d1e 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracesmithchart.cpp @@ -279,7 +279,7 @@ void TraceSmithChart::draw(QPainter &p) { // center line visible p.drawLine(dataToPixel(p1),dataToPixel(p2)); } - constexpr std::array impedanceLines = {10, 25, 50, 100, 250}; + const std::array impedanceLines = {Z0*0.2, Z0*0.5, Z0, Z0*2, Z0*5}; for(auto z : impedanceLines) { z /= Z0; auto radius = 1.0/z;