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 " 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."); "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, [=](){ connect(saveCal, &QAction::triggered, [=](){
@ -330,6 +335,14 @@ VNA::VNA(AppWindow *window, QString name)
connect(bZero, &QPushButton::clicked, this, &VNA::SetZeroSpan); connect(bZero, &QPushButton::clicked, this, &VNA::SetZeroSpan);
frequencySweepActions.push_back(tb_sweep->addWidget(bZero)); 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 = new QCheckBox("Log");
cbLogSweep->setToolTip("Logarithmic sweep"); cbLogSweep->setToolTip("Logarithmic sweep");
connect(cbLogSweep, &QCheckBox::toggled, this, &VNA::SetLogSweep); connect(cbLogSweep, &QCheckBox::toggled, this, &VNA::SetLogSweep);
@ -479,6 +492,7 @@ VNA::VNA(AppWindow *window, QString name)
calImportTerms->setEnabled(false); calImportTerms->setEnabled(false);
calImportMeas->setEnabled(false); calImportMeas->setEnabled(false);
calApplyToTraces->setEnabled(false); calApplyToTraces->setEnabled(false);
bMatchCal->setEnabled(false);
// saveCal->setEnabled(false); // saveCal->setEnabled(false);
}); });
connect(&cal, &Calibration::activated, [=](Calibration::CalType applied){ connect(&cal, &Calibration::activated, [=](Calibration::CalType applied){
@ -494,6 +508,7 @@ VNA::VNA(AppWindow *window, QString name)
calImportTerms->setEnabled(true); calImportTerms->setEnabled(true);
calImportMeas->setEnabled(true); calImportMeas->setEnabled(true);
calApplyToTraces->setEnabled(true); calApplyToTraces->setEnabled(true);
bMatchCal->setEnabled(true);
saveCal->setEnabled(true); saveCal->setEnabled(true);
}); });
@ -1101,6 +1116,18 @@ void VNA::SpanZoomOut()
ConstrainAndUpdateFrequencies(); 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) void VNA::SetLogSweep(bool log)
{ {
if(settings.Freq.logSweep != log) { if(settings.Freq.logSweep != log) {

View File

@ -93,6 +93,7 @@ private slots:
void SetZeroSpan(); void SetZeroSpan();
void SpanZoomIn(); void SpanZoomIn();
void SpanZoomOut(); void SpanZoomOut();
bool SpanMatchCal();
void SetLogSweep(bool log); void SetLogSweep(bool log);
// Acquisition control // Acquisition control
@ -158,7 +159,7 @@ private:
QComboBox *cbSweepType; QComboBox *cbSweepType;
QCheckBox *cbLogSweep; QCheckBox *cbLogSweep;
QPushButton *bZero; QPushButton *bZero, *bMatchCal;
QMenu *defaultCalMenu; QMenu *defaultCalMenu;
QAction *assignDefaultCal, *removeDefaultCal; QAction *assignDefaultCal, *removeDefaultCal;