option to match span to active calibration

This commit is contained in:
Jan Käberich 2024-01-27 18:18:04 +01:00
parent 8a900600f5
commit 3bc9070eea
2 changed files with 29 additions and 1 deletions

View File

@ -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) {

View File

@ -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:
QComboBox *cbSweepType;
QCheckBox *cbLogSweep;
QPushButton *bZero;
QPushButton *bZero, *bMatchCal;
QMenu *defaultCalMenu;
QAction *assignDefaultCal, *removeDefaultCal;