diff --git a/Software/PC_Application/Traces/polarchartdialog.ui b/Software/PC_Application/Traces/polarchartdialog.ui index 56fc831..97fcf2c 100644 --- a/Software/PC_Application/Traces/polarchartdialog.ui +++ b/Software/PC_Application/Traces/polarchartdialog.ui @@ -6,8 +6,8 @@ 0 0 - 389 - 275 + 381 + 385 @@ -26,48 +26,83 @@ Display mode - - - + + + + + + + Frequency: + + + + + + + + Show complete traces + + + + + Limit to current span + + + + + + + + - Frequency: + Override visible frequency range - - - - - Show complete traces - + + + + + + Start: + + - - - Limit to current span - + + - - - - - - Γ - - - - - - - - Show complete traces - + + + + Stop: + + - - - Limit to visible area - + + - + + + + Γ + + + + + + + + Show complete traces + + + + + Limit to visible area + + + + + diff --git a/Software/PC_Application/Traces/smithchartdialog.ui b/Software/PC_Application/Traces/smithchartdialog.ui index 1adddc7..88c5a31 100644 --- a/Software/PC_Application/Traces/smithchartdialog.ui +++ b/Software/PC_Application/Traces/smithchartdialog.ui @@ -6,8 +6,8 @@ 0 0 - 881 - 334 + 976 + 460 @@ -26,48 +26,83 @@ Display mode - - - + + + + + + + Frequency: + + + + + + + + Show complete traces + + + + + Limit to current span + + + + + + + + - Frequency: + Override visible frequency range - - - - - Show complete traces - + + + + + + Start: + + - - - Limit to current span - + + + + Stop: + + - - - - - - Impedance: - - - - - - - - Show complete traces - + + + + Impedance: + + - - - Limit to visible area - + + + + + Show complete traces + + + + + Limit to visible area + + + - + + + + + + + diff --git a/Software/PC_Application/Traces/tracepolar.cpp b/Software/PC_Application/Traces/tracepolar.cpp index 942e643..66f45cf 100644 --- a/Software/PC_Application/Traces/tracepolar.cpp +++ b/Software/PC_Application/Traces/tracepolar.cpp @@ -12,6 +12,9 @@ TracePolar::TracePolar(TraceModel &model, QWidget *parent) { limitToSpan = true; limitToEdge = true; + manualFrequencyRange = false; + fmin = 0; + fmax = 6000000000; edgeReflection = 1.0; dx = 0; initializeTraceInfo(); @@ -24,6 +27,9 @@ nlohmann::json TracePolar::toJSON() j["limit_to_edge"] = limitToEdge; j["edge_reflection"] = edgeReflection; j["offset_axis_x"] = dx; + j["frequency_override"] = manualFrequencyRange; + j["override_min"] = fmin; + j["override_max"] = fmax; nlohmann::json jtraces; for(auto t : traces) { if(t.second) { @@ -39,6 +45,9 @@ void TracePolar::fromJSON(nlohmann::json j) limitToSpan = j.value("limit_to_span", true); limitToEdge = j.value("limit_to_edge", false); edgeReflection = j.value("edge_reflection", 1.0); + manualFrequencyRange = j.value("frequency_override", false); + fmin = j.value("override_min", 0.0); + fmax = j.value("override_max", 6000000000.0); dx = j.value("offset_axis_x", 0.0); for(unsigned int hash : j["traces"]) { // attempt to find the traces with this hash diff --git a/Software/PC_Application/Traces/tracepolar.h b/Software/PC_Application/Traces/tracepolar.h index 2d878a4..377ccdc 100644 --- a/Software/PC_Application/Traces/tracepolar.h +++ b/Software/PC_Application/Traces/tracepolar.h @@ -50,6 +50,9 @@ protected: bool limitToSpan; bool limitToEdge; + bool manualFrequencyRange; + double fmin, fmax; // frequency range when manual range is selected + double edgeReflection; // magnitude of reflection coefficient at the edge of the polar chart (zoom factor) double dx; QTransform transform; diff --git a/Software/PC_Application/Traces/tracepolarchart.cpp b/Software/PC_Application/Traces/tracepolarchart.cpp index 7fd0c97..7bc0f4a 100644 --- a/Software/PC_Application/Traces/tracepolarchart.cpp +++ b/Software/PC_Application/Traces/tracepolarchart.cpp @@ -30,6 +30,24 @@ void TracePolarChart::axisSetupDialog() } else { ui->displayModeRefl->setCurrentIndex(0); } + + ui->displayStartFreq->setUnit("Hz"); + ui->displayStartFreq->setPrefixes(" kMG"); + ui->displayStartFreq->setPrecision(6); + ui->displayStartFreq->setValue(fmin); + ui->displayStopFreq->setUnit("Hz"); + ui->displayStopFreq->setPrefixes(" kMG"); + ui->displayStopFreq->setPrecision(6); + ui->displayStopFreq->setValue(fmax); + + connect(ui->displayFreqOverride, &QCheckBox::toggled, [=](bool active){ + ui->displayModeFreq->setEnabled(!active); + ui->displayStartFreq->setEnabled(active); + ui->displayStopFreq->setEnabled(active); + }); + ui->displayFreqOverride->setChecked(manualFrequencyRange); + emit ui->displayFreqOverride->toggled(manualFrequencyRange); + ui->zoomReflection->setPrecision(3); ui->zoomFactor->setPrecision(3); ui->offsetRealAxis->setPrecision(3); @@ -40,6 +58,9 @@ void TracePolarChart::axisSetupDialog() connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){ limitToSpan = ui->displayModeFreq->currentIndex() == 1; limitToEdge = ui->displayModeRefl->currentIndex() == 1; + manualFrequencyRange = ui->displayFreqOverride->isChecked(); + fmin = ui->displayStartFreq->value(); + fmax = ui->displayStopFreq->value(); triggerReplot(); }); connect(ui->zoomFactor, &SIUnitEdit::valueChanged, [=](){ @@ -71,6 +92,16 @@ void TracePolarChart::draw(QPainter &p) { transform = p.transform(); p.restore(); + auto minimumVisibleFrequency = std::numeric_limits::lowest(); + auto maximumVisibleFrequency = std::numeric_limits::max(); + if(manualFrequencyRange) { + minimumVisibleFrequency = fmin; + maximumVisibleFrequency = fmax; + } else if(limitToSpan) { + minimumVisibleFrequency = sweep_fmin; + maximumVisibleFrequency = sweep_fmax; + } + auto drawArc = [&](PolarArc a) { a.constrainToCircle(QPointF(0,0), edgeReflection); auto topleft = dataToPixel(complex(a.center.x() - a.radius, a.center.y() - a.radius)); @@ -147,7 +178,7 @@ void TracePolarChart::draw(QPainter &p) { for(int i=1;isample(i-1); auto now = trace->sample(i); - if (limitToSpan && (trace->getDataType() == Trace::DataType::Frequency) && (last.x < sweep_fmin || now.x > sweep_fmax)) { + if ((trace->getDataType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency || now.x > maximumVisibleFrequency)) { continue; } if(isnan(now.y.real())) { @@ -179,7 +210,7 @@ void TracePolarChart::draw(QPainter &p) { if(!m->isVisible()) { continue; } - if (limitToSpan && (m->getPosition() < sweep_fmin || m->getPosition() > sweep_fmax)) { + if (m->getPosition() < minimumVisibleFrequency || m->getPosition() > maximumVisibleFrequency) { continue; } if(m->getPosition() < trace->minX() || m->getPosition() > trace->maxX()) { diff --git a/Software/PC_Application/Traces/tracesmithchart.cpp b/Software/PC_Application/Traces/tracesmithchart.cpp index d24701b..9f5dd9f 100644 --- a/Software/PC_Application/Traces/tracesmithchart.cpp +++ b/Software/PC_Application/Traces/tracesmithchart.cpp @@ -62,6 +62,24 @@ void TraceSmithChart::axisSetupDialog() } else { ui->displayModeImp->setCurrentIndex(0); } + + ui->displayStartFreq->setUnit("Hz"); + ui->displayStartFreq->setPrefixes(" kMG"); + ui->displayStartFreq->setPrecision(6); + ui->displayStartFreq->setValue(fmin); + ui->displayStopFreq->setUnit("Hz"); + ui->displayStopFreq->setPrefixes(" kMG"); + ui->displayStopFreq->setPrecision(6); + ui->displayStopFreq->setValue(fmax); + + connect(ui->displayFreqOverride, &QCheckBox::toggled, [=](bool active){ + ui->displayModeFreq->setEnabled(!active); + ui->displayStartFreq->setEnabled(active); + ui->displayStopFreq->setEnabled(active); + }); + ui->displayFreqOverride->setChecked(manualFrequencyRange); + emit ui->displayFreqOverride->toggled(manualFrequencyRange); + ui->zoomReflection->setPrecision(3); ui->zoomFactor->setPrecision(3); ui->zoomReflection->setValue(edgeReflection); @@ -80,6 +98,9 @@ void TraceSmithChart::axisSetupDialog() connect(ui->buttonBox, &QDialogButtonBox::accepted, [=](){ limitToSpan = ui->displayModeFreq->currentIndex() == 1; limitToEdge = ui->displayModeImp->currentIndex() == 1; + manualFrequencyRange = ui->displayFreqOverride->isChecked(); + fmin = ui->displayStartFreq->value(); + fmax = ui->displayStopFreq->value(); updateContextMenu(); triggerReplot(); }); @@ -180,6 +201,16 @@ void TraceSmithChart::draw(QPainter &p) { transform = p.transform(); p.restore(); + auto minimumVisibleFrequency = std::numeric_limits::lowest(); + auto maximumVisibleFrequency = std::numeric_limits::max(); + if(manualFrequencyRange) { + minimumVisibleFrequency = fmin; + maximumVisibleFrequency = fmax; + } else if(limitToSpan) { + minimumVisibleFrequency = sweep_fmin; + maximumVisibleFrequency = sweep_fmax; + } + auto drawArc = [&](SmithChartArc a) { a.constrainToCircle(QPointF(0,0), edgeReflection); auto topleft = dataToPixel(complex(a.center.x() - a.radius, a.center.y() - a.radius)); @@ -241,7 +272,7 @@ void TraceSmithChart::draw(QPainter &p) { for(int i=1;isample(i-1); auto now = trace->sample(i); - if (limitToSpan && (trace->getDataType() == Trace::DataType::Frequency) && (last.x < sweep_fmin || now.x > sweep_fmax)) { + if ((trace->getDataType() == Trace::DataType::Frequency) && (last.x < minimumVisibleFrequency || now.x > maximumVisibleFrequency)) { continue; } if(isnan(now.y.real())) { @@ -276,7 +307,7 @@ void TraceSmithChart::draw(QPainter &p) { // if (m->isTimeDomain()) { // continue; // } - if (limitToSpan && (m->getPosition() < sweep_fmin || m->getPosition() > sweep_fmax)) { + if (m->getPosition() < minimumVisibleFrequency || m->getPosition() > maximumVisibleFrequency) { continue; } if(m->getPosition() < trace->minX() || m->getPosition() > trace->maxX()) {