Using Unit::ToString for descriptive calibration name
This commit is contained in:
parent
d5aca3d5e1
commit
323fb88c8f
@ -717,13 +717,7 @@ bool Calibration::openFromFile(QString filename)
|
|||||||
bool Calibration::saveToFile(QString filename)
|
bool Calibration::saveToFile(QString filename)
|
||||||
{
|
{
|
||||||
if(filename.isEmpty()) {
|
if(filename.isEmpty()) {
|
||||||
// Suggest descriptive name ie. "SOLT 40M-700M 1000pt"
|
QString fn = descriptiveCalName();
|
||||||
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);
|
filename = QFileDialog::getSaveFileName(nullptr, "Save calibration data", fn, "Calibration files (*.cal)", nullptr, QFileDialog::DontUseNativeDialog);
|
||||||
if(filename.isEmpty()) {
|
if(filename.isEmpty()) {
|
||||||
// aborted selection
|
// aborted selection
|
||||||
@ -750,26 +744,27 @@ bool Calibration::saveToFile(QString filename)
|
|||||||
/**
|
/**
|
||||||
* @brief Calibration::hzToString
|
* @brief Calibration::hzToString
|
||||||
* @param freqHz - input frequency in Hz
|
* @param freqHz - input frequency in Hz
|
||||||
* @return frequency in human-friendly form such as 145k 2M, 2.1M, 3.45G
|
* @return descriptive name ie. "SOLT 40M-700M 1000pt"
|
||||||
*/
|
*/
|
||||||
QString Calibration::hzToString(double freqHz){
|
QString Calibration::descriptiveCalName(){
|
||||||
int dgt = 3; // how many significant digits
|
int precision = 3;
|
||||||
QString res = ""; // initialize
|
QString lo = Unit::ToString(this->minFreq, "", " kMG", precision); // seems to work, but what are 2nd and 3rd parameters???
|
||||||
|
QString hi = Unit::ToString(this->maxFreq, "", " kMG", precision);
|
||||||
if (freqHz <= 999) {
|
// due to rounding up 123.66M and 123.99M -> we get lo="124M" and hi="124M"
|
||||||
// 0-999Hz
|
// so let's add some precision
|
||||||
res = QString::number(freqHz / 1, 'g', dgt) + "Hz"; // 1.23Hz, 45Hz, 88.5Hz
|
if (lo == hi) {
|
||||||
} else if (freqHz <= 999999) {
|
// Only in case of 123.66M and 123.69M we would need 5 digits, but that kind of narrow cal. is very unlikely.
|
||||||
// 1k-999kHz
|
precision = 4;
|
||||||
res = QString::number(freqHz / 1000, 'g', dgt) + "k";
|
lo = Unit::ToString(this->minFreq, "", " kMG", precision);
|
||||||
} else if (freqHz <= 999999999) {
|
hi = Unit::ToString(this->maxFreq, "", " kMG", precision);
|
||||||
// 1M-999M
|
|
||||||
res = QString::number(freqHz / 1000000, 'g', dgt) + "M";
|
|
||||||
} else {
|
|
||||||
// 1G-...
|
|
||||||
res = QString::number(freqHz / 1000000000, 'g', dgt) + "G";
|
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
|
QString tmp = Calibration::TypeToString(this->getType())
|
||||||
|
+ " "
|
||||||
|
+ lo + "-" + hi
|
||||||
|
+ " "
|
||||||
|
+ QString::number(this->points.size()) + "pt";
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Calibration::getCurrentCalibrationFile(){
|
QString Calibration::getCurrentCalibrationFile(){
|
||||||
|
@ -137,7 +137,7 @@ private:
|
|||||||
std::vector<Point> points;
|
std::vector<Point> points;
|
||||||
|
|
||||||
Calkit kit;
|
Calkit kit;
|
||||||
QString hzToString(double freqHz);
|
QString descriptiveCalName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString currentCalFile;
|
QString currentCalFile;
|
||||||
|
@ -287,7 +287,7 @@ VNA::VNA(AppWindow *window)
|
|||||||
|
|
||||||
// Calibration toolbar (and populate calibration menu)
|
// Calibration toolbar (and populate calibration menu)
|
||||||
auto tb_cal = new QToolBar("Calibration");
|
auto tb_cal = new QToolBar("Calibration");
|
||||||
QLabel *cbEnableCal_label = new QLabel("Calibration:"); // correct object type
|
QLabel *cbEnableCal_label = new QLabel("Calibration:");
|
||||||
tb_cal->addWidget(cbEnableCal_label);
|
tb_cal->addWidget(cbEnableCal_label);
|
||||||
auto cbEnableCal = new QCheckBox;
|
auto cbEnableCal = new QCheckBox;
|
||||||
tb_cal->addWidget(cbEnableCal);
|
tb_cal->addWidget(cbEnableCal);
|
||||||
@ -412,6 +412,7 @@ VNA::VNA(AppWindow *window)
|
|||||||
finalize(central);
|
finalize(central);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void VNA::deactivate()
|
void VNA::deactivate()
|
||||||
{
|
{
|
||||||
StoreSweepSettings();
|
StoreSweepSettings();
|
||||||
|
@ -71,6 +71,7 @@ private:
|
|||||||
bool calWaitFirst;
|
bool calWaitFirst;
|
||||||
QProgressDialog calDialog;
|
QProgressDialog calDialog;
|
||||||
|
|
||||||
|
|
||||||
QMenu *defaultCalMenu;
|
QMenu *defaultCalMenu;
|
||||||
QAction *assignDefaultCal, *removeDefaultCal;
|
QAction *assignDefaultCal, *removeDefaultCal;
|
||||||
QAction *saveCal;
|
QAction *saveCal;
|
||||||
|
Loading…
Reference in New Issue
Block a user