diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp index fe31d9f..b6eb437 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calibration.cpp @@ -1358,8 +1358,37 @@ void Calibration::fromJSON(nlohmann::json j) // unknown measurement name throw runtime_error("Measurement name unknown: "+std::string(j_m["name"])); } - // no standard selection in this format, just use the first suitable one - m->setFirstSupportedStandard(); + // attempt to select the correct standard + bool p1male = j.value("port1StandardMale", true); + bool p2male = j.value("port2StandardMale", true); + bool throughZeroLength = j.value("throughZeroLength", true); + + auto onePort = dynamic_cast(m); + if(onePort) { + bool male = onePort->getPort() == 1 ? p1male : p2male; + QString name = male ? "Default male standard" : "Default female standard"; + for(auto s : m->supportedStandards()) { + if(s->getName() == name) { + m->setStandard(s); + break; + } + } + } + auto through = dynamic_cast(m); + if(through) { + if(throughZeroLength) { + // needs to create a zero length through standard in the calkit in addition to the already existing through standard + auto zerolength = new CalStandard::Through(); + zerolength->setName("Zero length"); + kit.addStandard(zerolength); + // use this standard + m->setStandard(zerolength); + } + } + if(!m->getStandard()) { + // failed to find specific standard, use the first available + m->setFirstSupportedStandard(); + } // extract points if(!j_m.contains("points")) { throw runtime_error("Measurement "+name.toStdString()+" does not contain any points"); diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calkit.cpp b/Software/PC_Application/LibreVNA-GUI/Calibration/calkit.cpp index 3c1ad91..ac8dc51 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calkit.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calkit.cpp @@ -354,6 +354,11 @@ std::vector Calkit::getStandards() const return standards; } +void Calkit::addStandard(CalStandard::Virtual *s) +{ + standards.push_back(s); +} + nlohmann::json Calkit::toJSON() { json j = Savable::createJSON(descr); diff --git a/Software/PC_Application/LibreVNA-GUI/Calibration/calkit.h b/Software/PC_Application/LibreVNA-GUI/Calibration/calkit.h index 41becb7..6f52588 100644 --- a/Software/PC_Application/LibreVNA-GUI/Calibration/calkit.h +++ b/Software/PC_Application/LibreVNA-GUI/Calibration/calkit.h @@ -47,6 +47,7 @@ public: void edit(std::function updateCal = nullptr); std::vector getStandards() const; + void addStandard(CalStandard::Virtual* s); virtual nlohmann::json toJSON() override; virtual void fromJSON(nlohmann::json j) override; diff --git a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp index da2eede..250dc94 100644 --- a/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Traces/traceplot.cpp @@ -326,9 +326,10 @@ void TracePlot::finishContextMenu() void TracePlot::mousePressEvent(QMouseEvent *event) { + auto &pref = Preferences::getInstance(); if(event->buttons() == Qt::LeftButton) { selectedMarker = markerAtPosition(event->pos(), true); - if(!selectedMarker && positionWithinGraphArea(event->pos())) { + if(!selectedMarker && pref.Graphs.enablePanAndZoom && positionWithinGraphArea(event->pos())) { // no marker at the position, enter trace moving mode movingGraph = true; lastMousePoint = event->pos(); @@ -337,7 +338,7 @@ void TracePlot::mousePressEvent(QMouseEvent *event) } else { selectedMarker = nullptr; } - if(event->button() == Qt::MiddleButton) { + if(pref.Graphs.enablePanAndZoom && event->button() == Qt::MiddleButton) { bool horizontally = !(QApplication::keyboardModifiers() & Qt::ShiftModifier); bool vertically = !(QApplication::keyboardModifiers() & Qt::ControlModifier); setAuto(horizontally, vertically); @@ -392,10 +393,10 @@ void TracePlot::leaveEvent(QEvent *event) void TracePlot::wheelEvent(QWheelEvent *event) { auto &pref = Preferences::getInstance(); - if(positionWithinGraphArea(event->pos())) { + if(pref.Graphs.enablePanAndZoom && positionWithinGraphArea(event->pos())) { bool horizontally = !(QApplication::keyboardModifiers() & Qt::ShiftModifier); bool vertically = !(QApplication::keyboardModifiers() & Qt::ControlModifier); - double factor = pow((1.0-pref.Graphs.zoomFactor), (double) event->angleDelta().y() / 120.0); + double factor = pow(pref.Graphs.zoomFactor, (double) event->angleDelta().y() / 120.0); zoom(event->pos(), factor, horizontally, vertically); } } diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.cpp b/Software/PC_Application/LibreVNA-GUI/preferences.cpp index 04f20c3..bcd34e7 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferences.cpp +++ b/Software/PC_Application/LibreVNA-GUI/preferences.cpp @@ -115,6 +115,9 @@ PreferencesDialog::PreferencesDialog(Preferences *pref, QWidget *parent) : connect(ui->AcquisitionADCpresc, qOverload(&QSpinBox::valueChanged), updateIF2); connect(ui->AcquisitionADCphaseInc, qOverload(&QSpinBox::valueChanged), updateIF2); + // Graph page + ui->GraphsZoomFactor->setPrecision(3); + // General page if(p->TCPoverride) { ui->SCPIServerPort->setEnabled(false); @@ -305,6 +308,8 @@ void PreferencesDialog::setInitialGUIState() ui->GraphsFontSizeCursorOverlay->setValue(p->Graphs.fontSizeCursorOverlay); ui->GraphsFontSizeMarkerData->setValue(p->Graphs.fontSizeMarkerData); ui->GraphsFontSizeTraceNames->setValue(p->Graphs.fontSizeTraceNames); + ui->GraphsEnablePanZoom->setChecked(p->Graphs.enablePanAndZoom); + ui->GraphsZoomFactor->setValue(p->Graphs.zoomFactor); ui->MarkerShowMarkerData->setChecked(p->Marker.defaultBehavior.showDataOnGraphs); ui->MarkerShowAllMarkerData->setChecked(p->Marker.defaultBehavior.showAllData); @@ -376,6 +381,8 @@ void PreferencesDialog::updateFromGUI() p->Graphs.fontSizeCursorOverlay = ui->GraphsFontSizeCursorOverlay->value(); p->Graphs.fontSizeMarkerData = ui->GraphsFontSizeMarkerData->value(); p->Graphs.fontSizeTraceNames = ui->GraphsFontSizeTraceNames->value(); + p->Graphs.enablePanAndZoom = ui->GraphsEnablePanZoom->isChecked(); + p->Graphs.zoomFactor = ui->GraphsZoomFactor->value(); p->Marker.defaultBehavior.showDataOnGraphs = ui->MarkerShowMarkerData->isChecked(); p->Marker.defaultBehavior.showAllData = ui->MarkerShowAllMarkerData->isChecked(); diff --git a/Software/PC_Application/LibreVNA-GUI/preferences.h b/Software/PC_Application/LibreVNA-GUI/preferences.h index 2a1de84..e311657 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferences.h +++ b/Software/PC_Application/LibreVNA-GUI/preferences.h @@ -129,6 +129,7 @@ public: int fontSizeTraceNames; int fontSizeCursorOverlay; + bool enablePanAndZoom; double zoomFactor; } Graphs; struct { @@ -213,7 +214,8 @@ private: {&Graphs.fontSizeCursorOverlay, "Graphs.fontSizeCursorOverlay", 12}, {&Graphs.fontSizeMarkerData, "Graphs.fontSizeMarkerData", 12}, {&Graphs.fontSizeTraceNames, "Graphs.fontSizeTraceNames", 12}, - {&Graphs.zoomFactor, "Graphs.zoomFactor", 0.2}, + {&Graphs.enablePanAndZoom, "Graphs.enablePanAndZoom", true}, + {&Graphs.zoomFactor, "Graphs.zoomFactor", 0.9}, {&Marker.defaultBehavior.showDataOnGraphs, "Marker.defaultBehavior.ShowDataOnGraphs", true}, {&Marker.defaultBehavior.showAllData, "Marker.defaultBehavior.ShowAllData", false}, {&Marker.interpolatePoints, "Marker.interpolatePoints", false}, diff --git a/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui b/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui index 76da164..48649c6 100644 --- a/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui +++ b/Software/PC_Application/LibreVNA-GUI/preferencesdialog.ui @@ -83,8 +83,8 @@ 0 0 - 687 - 884 + 684 + 854 @@ -103,7 +103,7 @@ - 0 + 2 @@ -1117,6 +1117,39 @@ + + + + Pan and Zoom + + + + + + Enable: + + + + + + + + + + + + + + Zoom factor: + + + + + + + + + diff --git a/Software/PC_Application/LibreVNA-GUI/usersjanappdatalocaltemptmp8qcgdn b/Software/PC_Application/LibreVNA-GUI/usersjanappdatalocaltemptmp8qcgdn deleted file mode 100644 index e69de29..0000000