From ab9605cb8586f07fbf7252623c4c1e0b8694e3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Wed, 8 Jan 2025 08:59:04 +0100 Subject: [PATCH] use trace model source and correct units for graph axes and edit dialogs --- .../LibreVNA-GUI/Traces/eyediagramplot.cpp | 2 +- .../LibreVNA-GUI/Traces/tracewaterfall.cpp | 6 +++--- .../PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp | 6 +++--- .../LibreVNA-GUI/Traces/waterfallaxisdialog.cpp | 2 +- .../LibreVNA-GUI/Traces/xyplotaxisdialog.cpp | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp index 193395d..4f0a90c 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/eyediagramplot.cpp @@ -715,7 +715,7 @@ QString EyeDiagramPlot::mouseText(QPoint pos) auto max = qMax(abs(yAxis.getRangeMax()), abs(yAxis.getRangeMin())); auto step = abs(yAxis.getRangeMax() - yAxis.getRangeMin()) / 1000.0; significantDigits = floor(log10(max)) - floor(log10(step)) + 1; - ret += Unit::ToString(coords.y(), "V", yAxis.Prefixes(), significantDigits) + "\n"; + ret += Unit::ToString(coords.y(), "V", yAxis.Prefixes(getModel().getSource()), significantDigits) + "\n"; } return ret; } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracewaterfall.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracewaterfall.cpp index 1d46c31..75767af 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracewaterfall.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracewaterfall.cpp @@ -284,10 +284,10 @@ void TraceWaterfall::draw(QPainter &p) } QString unit = ""; if(pref.Graphs.showUnits) { - unit = yAxis.Unit(); + unit = yAxis.Unit(getModel().getSource()); } - QString labelMin = Unit::ToString(yAxis.getRangeMin(), unit, yAxis.Prefixes(), 4); - QString labelMax = Unit::ToString(yAxis.getRangeMax(), unit, yAxis.Prefixes(), 4); + QString labelMin = Unit::ToString(yAxis.getRangeMin(), unit, yAxis.Prefixes(getModel().getSource()), 4); + QString labelMax = Unit::ToString(yAxis.getRangeMax(), unit, yAxis.Prefixes(getModel().getSource()), 4); p.setPen(QPen(pref.Graphs.Color.axis, 1)); p.save(); p.translate(legendRect.x(), w.height()); diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp index ebe6a0c..09aa7c4 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp @@ -510,8 +510,8 @@ void TraceXYPlot::draw(QPainter &p) QString unit = ""; QString prefix = " "; if(pref.Graphs.showUnits) { - unit = yAxis[i].Unit(); - prefix = yAxis[i].Prefixes(); + unit = yAxis[i].Unit(getModel().getSource()); + prefix = yAxis[i].Prefixes(getModel().getSource()); } auto tickValue = Unit::ToString(yAxis[i].getTicks()[j], unit, prefix, significantDigits); QRect bounding; @@ -1270,7 +1270,7 @@ QString TraceXYPlot::mouseText(QPoint pos) auto max = qMax(abs(yAxis[i].getRangeMax()), abs(yAxis[i].getRangeMin())); auto step = abs(yAxis[i].getRangeMax() - yAxis[i].getRangeMin()) / 1000.0; significantDigits = floor(log10(max)) - floor(log10(step)) + 1; - ret += Unit::ToString(coords[i].y(), yAxis[i].Unit(), yAxis[i].Prefixes(), significantDigits) + "\n"; + ret += Unit::ToString(coords[i].y(), yAxis[i].Unit(getModel().getSource()), yAxis[i].Prefixes(getModel().getSource()), significantDigits) + "\n"; } } } diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/waterfallaxisdialog.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/waterfallaxisdialog.cpp index 133ac81..a68b340 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/waterfallaxisdialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/waterfallaxisdialog.cpp @@ -53,7 +53,7 @@ WaterfallAxisDialog::WaterfallAxisDialog(TraceWaterfall *plot) : ui->Wmin->setEnabled(index != 0 && !autoRange); ui->Wmax->setEnabled(index != 0 && !autoRange); auto type = (YAxis::Type) index; - QString unit = YAxis::Unit(type); + QString unit = YAxis::Unit(type, plot->getModel().getSource()); QString prefixes = YAxis::Prefixes(type); ui->Wmin->setUnit(unit); ui->Wmin->setPrefixes(prefixes); diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/xyplotaxisdialog.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/xyplotaxisdialog.cpp index b61e333..f039104 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/xyplotaxisdialog.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/xyplotaxisdialog.cpp @@ -50,7 +50,7 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) : } // Setup GUI connections - auto updateYenableState = [](QComboBox *type, QRadioButton *linear, QRadioButton *log, QCheckBox *CBauto, SIUnitEdit *min, SIUnitEdit *max, QSpinBox *divs, QCheckBox *autoDivs) { + auto updateYenableState = [plot](QComboBox *type, QRadioButton *linear, QRadioButton *log, QCheckBox *CBauto, SIUnitEdit *min, SIUnitEdit *max, QSpinBox *divs, QCheckBox *autoDivs) { if(type->currentIndex() == 0) { // axis disabled log->setEnabled(false); @@ -80,7 +80,7 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) : } } auto t = (YAxis::Type) type->currentIndex(); - QString unit = YAxis::Unit(t); + QString unit = YAxis::Unit(t, plot->getModel().getSource()); QString prefixes = YAxis::Prefixes(t); min->setUnit(unit); min->setPrefixes(prefixes); @@ -202,10 +202,10 @@ XYplotAxisDialog::XYplotAxisDialog(TraceXYPlot *plot) : ui->XautoDivs->setChecked(plot->xAxis.getAutoDivs()); // Constant line list handling - auto editLine = [&](XYPlotConstantLine *line) { + auto editLine = [plot, this](XYPlotConstantLine *line) { line->editDialog(XAxis::Unit((XAxis::Type) ui->XType->currentIndex()), - YAxis::Unit((YAxis::Type) ui->Y1type->currentIndex()), - YAxis::Unit((YAxis::Type) ui->Y2type->currentIndex())); + YAxis::Unit((YAxis::Type) ui->Y1type->currentIndex(), plot->getModel().getSource()), + YAxis::Unit((YAxis::Type) ui->Y2type->currentIndex(), plot->getModel().getSource())); }; for(auto l : plot->constantLines) {