From 3bc9070eeaef9c0f6e78e03eaff0ad077803f575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Sat, 27 Jan 2024 18:18:04 +0100 Subject: [PATCH] option to match span to active calibration --- .../PC_Application/LibreVNA-GUI/VNA/vna.cpp | 27 +++++++++++++++++++ .../PC_Application/LibreVNA-GUI/VNA/vna.h | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp index b77dcbe9..50cae509 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp @@ -98,6 +98,11 @@ VNA::VNA(AppWindow *window, QString name) InformationBox::ShowMessage("Invalid calibration", "The selected calibration was created for a different device. You can still load it but the resulting " "data likely isn't useful."); } + if(cal.getCaltype().type != Calibration::Type::None) { + if(InformationBox::AskQuestion("Adjust span?", "Do you want to adjust the span to match the loaded calibration file?", false)) { + SpanMatchCal(); + } + } }); connect(saveCal, &QAction::triggered, [=](){ @@ -330,6 +335,14 @@ VNA::VNA(AppWindow *window, QString name) connect(bZero, &QPushButton::clicked, this, &VNA::SetZeroSpan); frequencySweepActions.push_back(tb_sweep->addWidget(bZero)); + bMatchCal = new QPushButton("Cal"); + bMatchCal->setToolTip("Match span of calibration"); + bMatchCal->setMaximumWidth(28); + bMatchCal->setMaximumHeight(24); + bMatchCal->setEnabled(false); + connect(bMatchCal, &QPushButton::clicked, this, &VNA::SpanMatchCal); + frequencySweepActions.push_back(tb_sweep->addWidget(bMatchCal)); + cbLogSweep = new QCheckBox("Log"); cbLogSweep->setToolTip("Logarithmic sweep"); connect(cbLogSweep, &QCheckBox::toggled, this, &VNA::SetLogSweep); @@ -479,6 +492,7 @@ VNA::VNA(AppWindow *window, QString name) calImportTerms->setEnabled(false); calImportMeas->setEnabled(false); calApplyToTraces->setEnabled(false); + bMatchCal->setEnabled(false); // saveCal->setEnabled(false); }); connect(&cal, &Calibration::activated, [=](Calibration::CalType applied){ @@ -494,6 +508,7 @@ VNA::VNA(AppWindow *window, QString name) calImportTerms->setEnabled(true); calImportMeas->setEnabled(true); calApplyToTraces->setEnabled(true); + bMatchCal->setEnabled(true); saveCal->setEnabled(true); }); @@ -1101,6 +1116,18 @@ void VNA::SpanZoomOut() ConstrainAndUpdateFrequencies(); } +bool VNA::SpanMatchCal() +{ + if(cal.getCaltype().type == Calibration::Type::None) { + // no cal, nothing to adjust + return false; + } + SetStartFreq(cal.getMinFreq()); + SetStopFreq(cal.getMaxFreq()); + SetPoints(cal.getNumPoints()); + return true; +} + void VNA::SetLogSweep(bool log) { if(settings.Freq.logSweep != log) { diff --git a/Software/PC_Application/LibreVNA-GUI/VNA/vna.h b/Software/PC_Application/LibreVNA-GUI/VNA/vna.h index d0e77019..aa2f2aa8 100644 --- a/Software/PC_Application/LibreVNA-GUI/VNA/vna.h +++ b/Software/PC_Application/LibreVNA-GUI/VNA/vna.h @@ -93,6 +93,7 @@ private slots: void SetZeroSpan(); void SpanZoomIn(); void SpanZoomOut(); + bool SpanMatchCal(); void SetLogSweep(bool log); // Acquisition control @@ -158,7 +159,7 @@ private slots: QComboBox *cbSweepType; QCheckBox *cbLogSweep; - QPushButton *bZero; + QPushButton *bZero, *bMatchCal; QMenu *defaultCalMenu; QAction *assignDefaultCal, *removeDefaultCal;