diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceaxis.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceaxis.cpp index d4b07d1..aafdb50 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceaxis.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceaxis.cpp @@ -97,6 +97,7 @@ static void createLogarithmicTicks(vector& ticks, double start, double s YAxis::YAxis() { type = Type::Magnitude; + tickMaster = nullptr; } double YAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample) @@ -391,6 +392,17 @@ std::complex YAxis::reconstructValueFromYAxisType(std::mapgetTicks()) { + ticks.push_back(Util::Scale(masterTick, tickMaster->rangeMin, tickMaster->rangeMax, rangeMin, rangeMax)); + } + } +} + bool XAxis::isSupported(XAxis::Type type, TraceModel::DataSource source) { if(source == TraceModel::DataSource::VNA) { diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceaxis.h b/Software/PC_Application/LibreVNA-GUI/Traces/traceaxis.h index 8f67c08..d8935cb 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceaxis.h +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceaxis.h @@ -22,7 +22,7 @@ public: const std::vector &getTicks() const; protected: - void updateTicks(); + virtual void updateTicks(); bool log; bool autorange; double rangeMin; @@ -99,14 +99,22 @@ public: QString Unit(TraceModel::DataSource source = TraceModel::DataSource::VNA); QString Prefixes(TraceModel::DataSource source = TraceModel::DataSource::VNA); + void setTickMaster(YAxis &master) { + tickMaster = &master; + } + Type getType() const; bool isSupported(XAxis::Type type, TraceModel::DataSource source); static std::set getSupported(XAxis::Type type, TraceModel::DataSource source); static std::complex reconstructValueFromYAxisType(std::map yaxistypes); +protected: + virtual void updateTicks() override; + private: Type type; + YAxis *tickMaster; // if set, the tick positions will be set to match if this option is enabled in the preferences and ticks are set to auto }; #endif // TRACEAXIS_H diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp index 1656946..468d148 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/tracexyplot.cpp @@ -24,6 +24,8 @@ TraceXYPlot::TraceXYPlot(TraceModel &model, QWidget *parent) { xAxisMode = XAxisMode::UseSpan; + yAxis[1].setTickMaster(yAxis[0]); + // Setup default axis setYAxis(0, YAxis::Type::Magnitude, false, false, -120, 20, 14, true); setYAxis(1, YAxis::Type::Phase, false, false, -180, 180, 12, true); diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.cpp b/Software/PC_Application/LibreVNA-GUI/preferences.cpp index 8e671b6..6006a78 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferences.cpp +++ b/Software/PC_Application/LibreVNA-GUI/preferences.cpp @@ -286,6 +286,7 @@ void PreferencesDialog::setInitialGUIState() ui->GraphsSweepLine->setChecked(p->Graphs.SweepIndicator.line); ui->GraphsSweepHide->setChecked(p->Graphs.SweepIndicator.hide); ui->GraphsSweepHidePercent->setValue(p->Graphs.SweepIndicator.hidePercent); + ui->graphsEnableMasterTicksForYAxis->setChecked(p->Graphs.enableMasterTicksForYAxis); ui->MarkerShowMarkerData->setChecked(p->Marker.defaultBehavior.showDataOnGraphs); @@ -398,6 +399,7 @@ void PreferencesDialog::updateFromGUI() p->Graphs.SweepIndicator.line = ui->GraphsSweepLine->isChecked(); p->Graphs.SweepIndicator.hide = ui->GraphsSweepHide->isChecked(); p->Graphs.SweepIndicator.hidePercent = ui->GraphsSweepHidePercent->value(); + p->Graphs.enableMasterTicksForYAxis = ui->graphsEnableMasterTicksForYAxis->isChecked(); p->Marker.defaultBehavior.showDataOnGraphs = ui->MarkerShowMarkerData->isChecked(); p->Marker.defaultBehavior.showdB = ui->MarkerShowdB->isChecked(); diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.h b/Software/PC_Application/LibreVNA-GUI/preferences.h index 38024ac..cd592ee 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferences.h +++ b/Software/PC_Application/LibreVNA-GUI/preferences.h @@ -136,6 +136,8 @@ public: bool enablePanAndZoom; double zoomFactor; + bool enableMasterTicksForYAxis; + struct { bool triangle; int triangleSize; @@ -258,6 +260,7 @@ private: {&Graphs.fontSizeTraceNames, "Graphs.fontSizeTraceNames", 12}, {&Graphs.enablePanAndZoom, "Graphs.enablePanAndZoom", true}, {&Graphs.zoomFactor, "Graphs.zoomFactor", 0.9}, + {&Graphs.enableMasterTicksForYAxis, "Graphs.enableMasterTicksForYAxis", false}, {&Graphs.SweepIndicator.triangle, "Graphs.SweepIndicator.triangle", true}, {&Graphs.SweepIndicator.triangleSize, "Graphs.SweepIndicator.triangleSize", 5}, {&Graphs.SweepIndicator.line, "Graphs.SweepIndicator.line", false}, diff --git a/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui b/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui index f446262..27e245c 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui +++ b/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui @@ -98,7 +98,7 @@ - 5 + 2 @@ -112,8 +112,8 @@ 0 0 - 522 - 914 + 424 + 852 @@ -703,8 +703,8 @@ 0 0 - 565 - 477 + 450 + 416 @@ -944,8 +944,8 @@ 0 0 - 553 - 1075 + 679 + 964 @@ -1029,6 +1029,13 @@ + + + + Use left Y-axis ticks for right Y-axis ticks in auto mode + + + @@ -1438,8 +1445,8 @@ 0 0 - 683 - 605 + 696 + 564 @@ -1784,8 +1791,8 @@ 0 0 - 697 - 563 + 696 + 564 @@ -2067,8 +2074,8 @@ 0 0 - 697 - 563 + 194 + 146