From 06fc6faffc8b76503f84944378fcc7094a7d28c1 Mon Sep 17 00:00:00 2001 From: nanovna <54525305+nanovna@users.noreply.github.com> Date: Fri, 24 Jan 2020 08:46:48 +0000 Subject: [PATCH] show frequency range info in cal kit settings dialog --- vna_qt/calkitsettingsdialog.C | 51 +++++++++++++++++++++++++--------- vna_qt/calkitsettingsdialog.H | 2 ++ vna_qt/calkitsettingsdialog.ui | 6 ++-- vna_qt/calkitsettingswidget.ui | 19 +++++++++++-- 4 files changed, 60 insertions(+), 18 deletions(-) diff --git a/vna_qt/calkitsettingsdialog.C b/vna_qt/calkitsettingsdialog.C index b41b3f0..77c9e9b 100644 --- a/vna_qt/calkitsettingsdialog.C +++ b/vna_qt/calkitsettingsdialog.C @@ -42,10 +42,11 @@ void CalKitSettingsDialog::fromSettings(const CalKitSettings &settings) { for(auto& item:idealCalStds) { string name = item.first; string desc = name; + auto& inf = info[name]; if(calStdDesc.find(name) != calStdDesc.end()) desc = calStdDesc[name]; - Ui::CalKitSettingsWidget& ui1 = info[name].ui; + Ui::CalKitSettingsWidget& ui1 = inf.ui; QWidget* w = new QWidget(); ui1.setupUi(w); layout->addWidget(w); @@ -53,21 +54,28 @@ void CalKitSettingsDialog::fromSettings(const CalKitSettings &settings) { ui1.l_desc->setText(qs(desc)); auto it = settings.calKitModels.find(name); - if(it != settings.calKitModels.end()) { + if(it != settings.calKitModels.end() && (*it).second.values.size() != 0) { ui1.r_s_param->setChecked(true); - info[name].data = (*it).second; - info[name].useIdeal = false; + const SParamSeries& series = (*it).second; + inf.data = series; + inf.useIdeal = false; auto it2 = settings.calKitNames.find(name); if(it2 != settings.calKitNames.end()) - ui1.l_status->setText(qs((*it2).second)); - } else info[name].useIdeal = true; + inf.fileName = (*it2).second; + ui1.l_status->setText(generateLabel(inf)); + } else { + inf.useIdeal = true; + ui1.l_status->setText(""); + } connect(ui1.r_ideal, &QRadioButton::clicked, [this, name](){ - info[name].useIdeal = true; - info[name].ui.l_status->setText(""); + auto& inf = info[name]; + inf.useIdeal = true; + inf.ui.l_status->setText(""); }); connect(ui1.r_s_param, &QRadioButton::clicked, [this, name](){ + auto& inf = info[name]; QString fileName = QFileDialog::getOpenFileName(this, tr("Open S parameters file"), "", tr("S parameters (*.s1p *.s2p);;All Files (*)")); @@ -87,9 +95,10 @@ void CalKitSettingsDialog::fromSettings(const CalKitSettings &settings) { try { QFileInfo fileInfo(fileName); parseTouchstone(data,nPorts,series.values); - info[name].useIdeal = false; - info[name].data = series; - info[name].ui.l_status->setText(fileInfo.fileName()); + inf.useIdeal = false; + inf.data = series; + inf.fileName = fileName.toStdString(); + inf.ui.l_status->setText(generateLabel(inf)); } catch(exception& ex) { QMessageBox::warning(this, tr("Error parsing S parameter file"), ex.what()); goto fail; @@ -99,7 +108,7 @@ void CalKitSettingsDialog::fromSettings(const CalKitSettings &settings) { return; fail: // revert radiobutton state - info[name].ui.r_ideal->setChecked(info[name].useIdeal); + inf.ui.r_ideal->setChecked(inf.useIdeal); }); } } @@ -113,7 +122,23 @@ void CalKitSettingsDialog::toSettings(CalKitSettings &settings) { if(it == info.end()) continue; if(!(*it).second.useIdeal) { settings.calKitModels[name] = (*it).second.data; - settings.calKitNames[name] = (*it).second.ui.l_status->text().toStdString(); + settings.calKitNames[name] = (*it).second.fileName; } } } + +QString CalKitSettingsDialog::generateLabel(const CalKitSettingsDialog::calKitInfo &inf) { + QString status; + status = qs(inf.fileName); + if(status == "") + status = ""; + + status = status.toHtmlEscaped(); + + double startFreqHz = inf.data.values.begin()->first; + double stopFreqHz = inf.data.values.rbegin()->first; + status = "
" + status
+            + qs(ssprintf(256, "\n   %8.3f MHz - %8.3f MHz, %d points
", + startFreqHz*1e-6, stopFreqHz*1e-6, (int)inf.data.values.size())); + return status; +} diff --git a/vna_qt/calkitsettingsdialog.H b/vna_qt/calkitsettingsdialog.H index cdfb452..68d3edf 100644 --- a/vna_qt/calkitsettingsdialog.H +++ b/vna_qt/calkitsettingsdialog.H @@ -14,6 +14,7 @@ class CalKitSettingsDialog : public QDialog struct calKitInfo { Ui::CalKitSettingsWidget ui; + string fileName; SParamSeries data; bool useIdeal; }; @@ -24,6 +25,7 @@ public: void fromSettings(const CalKitSettings& settings); void toSettings(CalKitSettings& settings); + QString generateLabel(const calKitInfo& inf); map info; private: Ui::CalKitSettingsDialog *ui; diff --git a/vna_qt/calkitsettingsdialog.ui b/vna_qt/calkitsettingsdialog.ui index 2d90986..eaafa20 100644 --- a/vna_qt/calkitsettingsdialog.ui +++ b/vna_qt/calkitsettingsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 555 - 389 + 772 + 511 @@ -45,7 +45,7 @@ 0 0 - 535 + 752 16 diff --git a/vna_qt/calkitsettingswidget.ui b/vna_qt/calkitsettingswidget.ui index c532df2..c0c70de 100644 --- a/vna_qt/calkitsettingswidget.ui +++ b/vna_qt/calkitsettingswidget.ui @@ -7,7 +7,7 @@ 0 0 611 - 44 + 45 @@ -16,6 +16,12 @@ 0 + + + 0 + 45 + + Form @@ -85,8 +91,17 @@ + + color: #0066aa; font-family: Monospace + - + aaaaa<br />sssss + + + Qt::RichText + + + 8