diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp
index 225fa2bf..ebe6a0c6 100644
--- a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp
+++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp
@@ -571,6 +571,19 @@ void TraceXYPlot::draw(QPainter &p)
auto last = traceToCoordinate(t, j-1, yAxis[i]);
auto now = traceToCoordinate(t, j, yAxis[i]);
+ // checking limits
+ for(auto limit : constantLines) {
+ if(i == 0 && limit->getAxis() != XYPlotConstantLine::Axis::Primary) {
+ continue;
+ }
+ if(i == 1 && limit->getAxis() != XYPlotConstantLine::Axis::Secondary) {
+ continue;
+ }
+ if(!limit->pass(now)) {
+ limitPassing = false;
+ }
+ }
+
if(isnan(last.y()) || isnan(now.y()) || isinf(last.y()) || isinf(now.y())) {
continue;
}
@@ -595,19 +608,6 @@ void TraceXYPlot::draw(QPainter &p)
}
// draw line
p.drawLine(p1, p2);
-
- // checking limits
- for(auto limit : constantLines) {
- if(i == 0 && limit->getAxis() != XYPlotConstantLine::Axis::Primary) {
- continue;
- }
- if(i == 1 && limit->getAxis() != XYPlotConstantLine::Axis::Secondary) {
- continue;
- }
- if(!limit->pass(now)) {
- limitPassing = false;
- }
- }
}
if(i == 0 && nPoints > 0) {
// only draw markers on primary YAxis and if the trace has at least one point
@@ -1352,6 +1352,13 @@ bool XYPlotConstantLine::pass(QPointF testPoint)
// out of range, always passes
return true;
}
+
+ // check for inf/nan on Y value
+ if(isnan(testPoint.y()) || isinf(testPoint.y())) {
+ // can not actually evaluate the limits, use pass/fail from preferences for this case
+ return Preferences::getInstance().Graphs.limitNaNpasses;
+ }
+
auto p = lower_bound(points.begin(), points.end(), testPoint.x(), [](QPointF p, double x) -> bool {
return p.x() < x;
});
diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.cpp b/Software/PC_Application/LibreVNA-GUI/preferences.cpp
index 5807dad3..26561941 100644
--- a/Software/PC_Application/LibreVNA-GUI/preferences.cpp
+++ b/Software/PC_Application/LibreVNA-GUI/preferences.cpp
@@ -274,6 +274,7 @@ void PreferencesDialog::setInitialGUIState()
ui->GraphsColorTicksBackground->setColor(p->Graphs.Color.Ticks.Background.background);
ui->GraphsDomainChangeBehavior->setCurrentIndex((int) p->Graphs.domainChangeBehavior);
ui->GraphsLimitIndication->setCurrentIndex((int) p->Graphs.limitIndication);
+ ui->GraphsLimitNaNpasses->setCurrentIndex(p->Graphs.limitNaNpasses ? 1 : 0);
ui->GraphsLineWidth->setValue(p->Graphs.lineWidth);
ui->GraphsFontSizeAxis->setValue(p->Graphs.fontSizeAxis);
ui->GraphsFontSizeCursorOverlay->setValue(p->Graphs.fontSizeCursorOverlay);
@@ -388,6 +389,7 @@ void PreferencesDialog::updateFromGUI()
p->Graphs.Color.Ticks.divisions = ui->GraphsColorTicksDivisions->getColor();
p->Graphs.domainChangeBehavior = (GraphDomainChangeBehavior) ui->GraphsDomainChangeBehavior->currentIndex();
p->Graphs.limitIndication = (GraphLimitIndication) ui->GraphsLimitIndication->currentIndex();
+ p->Graphs.limitNaNpasses = ui->GraphsLimitNaNpasses->currentIndex() == 1;
p->Graphs.lineWidth = ui->GraphsLineWidth->value();
p->Graphs.fontSizeAxis = ui->GraphsFontSizeAxis->value();
p->Graphs.fontSizeCursorOverlay = ui->GraphsFontSizeCursorOverlay->value();
diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.h b/Software/PC_Application/LibreVNA-GUI/preferences.h
index 08334c8d..b02042d3 100644
--- a/Software/PC_Application/LibreVNA-GUI/preferences.h
+++ b/Software/PC_Application/LibreVNA-GUI/preferences.h
@@ -129,6 +129,7 @@ class Preferences : public Savable {
} Color;
GraphDomainChangeBehavior domainChangeBehavior;
GraphLimitIndication limitIndication;
+ bool limitNaNpasses;
double lineWidth;
int fontSizeAxis;
@@ -257,6 +258,7 @@ class Preferences : public Savable {
{&Graphs.Color.Ticks.divisions, "Graphs.Color.Ticks.divisions", QColor(Qt::gray)},
{&Graphs.domainChangeBehavior, "Graphs.domainChangeBehavior", GraphDomainChangeBehavior::AdjustGraphs},
{&Graphs.limitIndication, "Graphs.limitIndication", GraphLimitIndication::PassFailText},
+ {&Graphs.limitNaNpasses, "Graphs.limitNaNpasses", false},
{&Graphs.lineWidth, "Graphs.lineWidth", 1.0},
{&Graphs.fontSizeAxis, "Graphs.fontSizeAxis", 10},
{&Graphs.fontSizeCursorOverlay, "Graphs.fontSizeCursorOverlay", 12},
diff --git a/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui b/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui
index 3b5d3a22..30e0876b 100644
--- a/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui
+++ b/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui
@@ -98,7 +98,7 @@
- 6
+ 2
@@ -111,7 +111,7 @@
0
- 0
+ -206
679
836
@@ -945,7 +945,7 @@
0
-400
679
- 964
+ 992
@@ -1378,7 +1378,7 @@
-
-
+
Limit checking
@@ -1409,6 +1409,27 @@
+ -
+
+
+ NaN/Inf values:
+
+
+
+ -
+
+
-
+
+ Fail
+
+
+ -
+
+ Pass
+
+
+
+
@@ -1445,8 +1466,8 @@
0
0
- 696
- 564
+ 402
+ 540
@@ -1791,8 +1812,8 @@
0
0
- 696
- 564
+ 138
+ 112