Frequency range override for smith/polar chart
This commit is contained in:
parent
33726a815a
commit
71239842f6
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>389</width>
|
||||
<height>275</height>
|
||||
<width>381</width>
|
||||
<height>385</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -26,48 +26,83 @@
|
||||
<property name="title">
|
||||
<string>Display mode</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Frequency:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="displayModeFreq">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Show complete traces</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Limit to current span</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="displayFreqOverride">
|
||||
<property name="text">
|
||||
<string>Frequency:</string>
|
||||
<string>Override visible frequency range</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="displayModeFreq">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Show complete traces</string>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Limit to current span</string>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="SIUnitEdit" name="displayStartFreq"/>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Γ</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="displayModeRefl">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Show complete traces</string>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Stop:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Limit to visible area</string>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="SIUnitEdit" name="displayStopFreq"/>
|
||||
</item>
|
||||
</widget>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Γ</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="displayModeRefl">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Show complete traces</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Limit to visible area</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>881</width>
|
||||
<height>334</height>
|
||||
<width>976</width>
|
||||
<height>460</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -26,48 +26,83 @@
|
||||
<property name="title">
|
||||
<string>Display mode</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Frequency:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="displayModeFreq">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Show complete traces</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Limit to current span</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="displayFreqOverride">
|
||||
<property name="text">
|
||||
<string>Frequency:</string>
|
||||
<string>Override visible frequency range</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="displayModeFreq">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Show complete traces</string>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Start:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Limit to current span</string>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Stop:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Impedance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="displayModeImp">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Show complete traces</string>
|
||||
</property>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Impedance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Limit to visible area</string>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="displayModeImp">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Show complete traces</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Limit to visible area</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</widget>
|
||||
<item row="0" column="1">
|
||||
<widget class="SIUnitEdit" name="displayStartFreq"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="SIUnitEdit" name="displayStopFreq"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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<double>::lowest();
|
||||
auto maximumVisibleFrequency = std::numeric_limits<double>::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<double>(a.center.x() - a.radius, a.center.y() - a.radius));
|
||||
@ -147,7 +178,7 @@ void TracePolarChart::draw(QPainter &p) {
|
||||
for(int i=1;i<nPoints;i++) {
|
||||
auto last = trace->sample(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()) {
|
||||
|
@ -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<double>::lowest();
|
||||
auto maximumVisibleFrequency = std::numeric_limits<double>::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<double>(a.center.x() - a.radius, a.center.y() - a.radius));
|
||||
@ -241,7 +272,7 @@ void TraceSmithChart::draw(QPainter &p) {
|
||||
for(int i=1;i<nPoints;i++) {
|
||||
auto last = trace->sample(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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user