Calibration - highlight state; save/load cosmetics
This commit is contained in:
parent
49f9b5442d
commit
cde385935d
@ -679,7 +679,7 @@ bool Calibration::openFromFile(QString filename)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
qDebug() << "Attempting to open calibration from file" << filename;
|
||||
qDebug() << "Attempting to open calibration from file" << filename;
|
||||
|
||||
// reset all data before loading new calibration
|
||||
clearMeasurements();
|
||||
@ -716,7 +716,14 @@ qDebug() << "Attempting to open calibration from file" << filename;
|
||||
bool Calibration::saveToFile(QString filename)
|
||||
{
|
||||
if(filename.isEmpty()) {
|
||||
filename = QFileDialog::getSaveFileName(nullptr, "Save calibration data", "", "Calibration files (*.cal)", nullptr, QFileDialog::DontUseNativeDialog);
|
||||
// suggest descriptive name
|
||||
QString fn = Calibration::TypeToString(this->getType())
|
||||
+ " "
|
||||
+ hzToString(minFreq) + "-" + hzToString(maxFreq)
|
||||
+ " "
|
||||
+ QString::number(points.size()) + "pt";
|
||||
//
|
||||
filename = QFileDialog::getSaveFileName(nullptr, "Save calibration data", fn, "Calibration files (*.cal)", nullptr, QFileDialog::DontUseNativeDialog);
|
||||
if(filename.isEmpty()) {
|
||||
// aborted selection
|
||||
return false;
|
||||
@ -738,6 +745,31 @@ bool Calibration::saveToFile(QString filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calibration::hzToString
|
||||
* @param freqHz - input frequency in Hz
|
||||
* @return frequency in human-readable form such as 145k 2M, 2.1M, 3.45G
|
||||
*/
|
||||
QString Calibration::hzToString(double freqHz){
|
||||
int dgt = 3; // how many significant digits
|
||||
QString res = ""; // initialize
|
||||
|
||||
if (freqHz <= 999) {
|
||||
// 0-999Hz
|
||||
res = QString::number(freqHz / 1, 'g', dgt) + "Hz"; // 1.23Hz, 45Hz, 88.5Hz
|
||||
} else if (freqHz <= 999999) {
|
||||
// 1k-999kHz
|
||||
res = QString::number(freqHz / 1000, 'g', dgt) + "k";
|
||||
} else if (freqHz <= 999999999) {
|
||||
// 1M-999M
|
||||
res = QString::number(freqHz / 1000000, 'g', dgt) + "M";
|
||||
} else {
|
||||
// 1G-...
|
||||
res = QString::number(freqHz / 1000000000, 'g', dgt) + "G";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream &os, const Calibration &c)
|
||||
{
|
||||
for(auto m : c.measurements) {
|
||||
|
@ -137,6 +137,7 @@ private:
|
||||
std::vector<Point> points;
|
||||
|
||||
Calkit kit;
|
||||
QString hzToString(double freqHz);
|
||||
};
|
||||
|
||||
#endif // CALIBRATION_H
|
||||
|
@ -287,7 +287,8 @@ VNA::VNA(AppWindow *window)
|
||||
|
||||
// Calibration toolbar (and populate calibration menu)
|
||||
auto tb_cal = new QToolBar("Calibration");
|
||||
tb_cal->addWidget(new QLabel("Calibration:"));
|
||||
auto cbEnableCal_label = new QLabel("Calibration:");
|
||||
tb_cal->addWidget(cbEnableCal_label);
|
||||
auto cbEnableCal = new QCheckBox;
|
||||
tb_cal->addWidget(cbEnableCal);
|
||||
auto cbType = new QComboBox();
|
||||
@ -326,6 +327,7 @@ VNA::VNA(AppWindow *window)
|
||||
cbEnableCal->blockSignals(true);
|
||||
calDisable->setChecked(true);
|
||||
cbEnableCal->setCheckState(Qt::CheckState::Unchecked);
|
||||
cbEnableCal_label->setStyleSheet("background-color: yellow");
|
||||
cbType->blockSignals(false);
|
||||
cbEnableCal->blockSignals(false);
|
||||
calImportTerms->setEnabled(false);
|
||||
@ -343,6 +345,7 @@ VNA::VNA(AppWindow *window)
|
||||
}
|
||||
}
|
||||
cbEnableCal->setCheckState(Qt::CheckState::Checked);
|
||||
cbEnableCal_label->setStyleSheet("");
|
||||
cbType->blockSignals(false);
|
||||
cbEnableCal->blockSignals(false);
|
||||
calImportTerms->setEnabled(true);
|
||||
@ -427,7 +430,12 @@ void VNA::initializeDevice()
|
||||
if(cal.openFromFile(filename)) {
|
||||
ApplyCalibration(cal.getType());
|
||||
portExtension.setCalkit(&cal.getCalibrationKit());
|
||||
qDebug() << "Calibration successful from " << filename;
|
||||
} else {
|
||||
qDebug() << "Calibration not successfull from: " << filename;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Calibration file not found: " << filename;
|
||||
}
|
||||
removeDefaultCal->setEnabled(true);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user