Cal widget with coloured tooltip

This commit is contained in:
Zoran Kostic 2020-12-07 16:04:59 +01:00
parent 059eaafb40
commit 9ed73cfa13
4 changed files with 31 additions and 7 deletions

View File

@ -759,7 +759,8 @@ QString Calibration::descriptiveCalName(){
hi = Unit::ToString(this->maxFreq, "", " kMG", precision); hi = Unit::ToString(this->maxFreq, "", " kMG", precision);
} }
QString tmp = Calibration::TypeToString(this->getType()) QString tmp =
Calibration::TypeToString(this->getType())
+ " " + " "
+ lo + "-" + hi + lo + "-" + hi
+ " " + " "
@ -767,6 +768,15 @@ QString Calibration::descriptiveCalName(){
return tmp; return tmp;
} }
double Calibration::getMinFreq(){
return this->minFreq;
}
double Calibration::getMaxFreq(){
return this->maxFreq;
}
int Calibration::getNumPoints(){
return this->points.size();
}
QString Calibration::getCurrentCalibrationFile(){ QString Calibration::getCurrentCalibrationFile(){
return this->currentCalFile; return this->currentCalFile;
} }

View File

@ -143,6 +143,9 @@ private:
QString currentCalFile; QString currentCalFile;
public: public:
QString getCurrentCalibrationFile(); QString getCurrentCalibrationFile();
double getMinFreq();
double getMaxFreq();
int getNumPoints();
}; };
#endif // CALIBRATION_H #endif // CALIBRATION_H

View File

@ -288,7 +288,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:"); QLabel *cbEnableCal_label = new QLabel("Calibration:");
cbEnableCal_label->setStyleSheet(getCalStyleStr()); // on app start cbEnableCal_label->setStyleSheet(getCalStyle()); // on app start
cbEnableCal_label->setToolTip(getCalToolTip()); // no cal. file loaded cbEnableCal_label->setToolTip(getCalToolTip()); // no cal. file loaded
tb_cal->addWidget(cbEnableCal_label); tb_cal->addWidget(cbEnableCal_label);
auto cbEnableCal = new QCheckBox; auto cbEnableCal = new QCheckBox;
@ -329,7 +329,7 @@ VNA::VNA(AppWindow *window)
cbEnableCal->blockSignals(true); cbEnableCal->blockSignals(true);
calDisable->setChecked(true); calDisable->setChecked(true);
cbEnableCal->setCheckState(Qt::CheckState::Unchecked); cbEnableCal->setCheckState(Qt::CheckState::Unchecked);
cbEnableCal_label->setStyleSheet(getCalStyleStr()); // visually indicate loss of calibration cbEnableCal_label->setStyleSheet(getCalStyle()); // visually indicate loss of calibration
cbEnableCal_label->setToolTip(getCalToolTip()); // cal. file unknown at this moment cbEnableCal_label->setToolTip(getCalToolTip()); // cal. file unknown at this moment
cbType->blockSignals(false); cbType->blockSignals(false);
cbEnableCal->blockSignals(false); cbEnableCal->blockSignals(false);
@ -348,7 +348,7 @@ VNA::VNA(AppWindow *window)
} }
} }
cbEnableCal->setCheckState(Qt::CheckState::Checked); cbEnableCal->setCheckState(Qt::CheckState::Checked);
cbEnableCal_label->setStyleSheet(getCalStyleStr()); // restore default look of widget cbEnableCal_label->setStyleSheet(getCalStyle()); // restore default look of widget
cbEnableCal_label->setToolTip(getCalToolTip()); // on hover, show name of active cal. file cbEnableCal_label->setToolTip(getCalToolTip()); // on hover, show name of active cal. file
cbType->blockSignals(false); cbType->blockSignals(false);
cbEnableCal->blockSignals(false); cbEnableCal->blockSignals(false);
@ -414,7 +414,7 @@ VNA::VNA(AppWindow *window)
finalize(central); finalize(central);
} }
QString VNA::getCalStyleStr() QString VNA::getCalStyle()
{ {
Calibration::InterpolationType interpol = cal.getInterpolation(settings); Calibration::InterpolationType interpol = cal.getInterpolation(settings);
QString style = ""; QString style = "";
@ -446,8 +446,19 @@ QString VNA::getCalToolTip()
case Calibration::InterpolationType::Exact: case Calibration::InterpolationType::Exact:
case Calibration::InterpolationType::Interpolate: case Calibration::InterpolationType::Interpolate:
case Calibration::InterpolationType::Extrapolate: case Calibration::InterpolationType::Extrapolate:
txt = cal.getCurrentCalibrationFile(); {
QString lo = Unit::ToString(cal.getMinFreq(), "", " kMG", 5);
QString hi = Unit::ToString(cal.getMaxFreq(), "", " kMG", 5);
if (settings.f_start < cal.getMinFreq() ) { lo = "<font color=\"red\">" + lo + "</font>";}
if (settings.f_stop > cal.getMaxFreq() ) { hi = "<font color=\"red\">" + hi + "</font>";}
txt =
"limits: " + lo + " - " + hi
+ "<br>"
+ "points: " + QString::number(cal.getNumPoints())
+ "<br>"
"file: " + cal.getCurrentCalibrationFile();
break; break;
}
case Calibration::InterpolationType::NoCalibration: case Calibration::InterpolationType::NoCalibration:
txt = "none"; txt = "none";
break; break;

View File

@ -70,7 +70,7 @@ private:
bool calMeasuring; bool calMeasuring;
bool calWaitFirst; bool calWaitFirst;
QProgressDialog calDialog; QProgressDialog calDialog;
QString getCalStyleStr(); QString getCalStyle();
QString getCalToolTip(); QString getCalToolTip();