From d99b1101c46e8577213573e32e05526bc664757e Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Wed, 14 Aug 2024 11:45:47 -0500 Subject: [PATCH 1/3] Changed scan name to be in meta since md breaks things --- .../Annotation/ScanRegionGraphicsItem.cpp | 5 -- src/mvc/BlueskyComm.h | 66 ++++++++++++++++--- src/mvc/BlueskyPlan.h | 6 +- src/mvc/ScanQueueWidget.cpp | 2 + 4 files changed, 64 insertions(+), 15 deletions(-) diff --git a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp index 9813d90..5ee53b7 100644 --- a/src/gstar/Annotation/ScanRegionGraphicsItem.cpp +++ b/src/gstar/Annotation/ScanRegionGraphicsItem.cpp @@ -149,11 +149,6 @@ void ScanRegionGraphicsItem::onScanUpdated(const BlueskyPlan& plan) setPropertyValue(DEF_STR_DISPLAY_NAME, _scan_dialog.getScanName()); BlueskyPlan nplan = plan; nplan.name = _scan_dialog.getScanName(); - BlueskyParam meta_data; - meta_data.name = "md"; - meta_data.default_val = nplan.name; - meta_data.description = "Link to scan name"; - nplan.parameters["md"] = meta_data; emit scanUpdated(nplan); } diff --git a/src/mvc/BlueskyComm.h b/src/mvc/BlueskyComm.h index 637f69d..9fbb015 100644 --- a/src/mvc/BlueskyComm.h +++ b/src/mvc/BlueskyComm.h @@ -120,14 +120,34 @@ class BlueskyComm : public QThread item["name"] = plan.type; item["item_type"] = "plan"; - + QJsonObject meta; + meta["name"] = plan.name; + item["meta"] = meta; + QJsonArray args; QJsonObject kwargs; for(auto itr: plan.parameters) { - kwargs[itr.first] = itr.second.default_val; + if(itr.second.name == "detectors") + { + QJsonArray inner_args; // need this for bluesky or it doesn't work + QStringList sarr = itr.second.default_val.split(","); + for(auto sitr : sarr) + { + inner_args.append(QJsonValue::fromVariant(sitr)); + } + args.append(inner_args); + } + else if(itr.second.kind == BlueskyParamType::String && itr.second.default_val.length() > 0) + { + kwargs[itr.first] = itr.second.default_val; + } + else if(itr.second.kind == BlueskyParamType::Numeral && itr.second.default_val.length() > 0) + { + kwargs[itr.first] = QJsonValue::fromVariant(itr.second.default_val.toDouble()); + } } item["kwargs"] = kwargs; - + item["args"] = args; return item; } @@ -349,13 +369,35 @@ class BlueskyComm : public QThread plans[pobj["name"].toString()].parameters[param["name"].toString()].name = param["name"].toString(); if(param.contains("default")) { - plans[pobj["name"].toString()].parameters[param["name"].toString()].default_val = param["default"].toString(); + if(param["default"].toString() != "None") + { + plans[pobj["name"].toString()].parameters[param["name"].toString()].default_val = param["default"].toString(); + } } if(param.contains("description")) { plans[pobj["name"].toString()].parameters[param["name"].toString()].description = param["description"].toString(); } } + if(param.contains("kind")) + { + QJsonObject kind = param["kind"].toObject(); + if(kind.contains("value")) + { + int tval = kind["value"].toInt(); + switch (tval) + { + case 1: + plans[pobj["name"].toString()].parameters[param["name"].toString()].kind = BlueskyParamType::Numeral; + break; + case 3: + plans[pobj["name"].toString()].parameters[param["name"].toString()].kind = BlueskyParamType::String; + break; + default: + break; + } + } + } } } } @@ -437,16 +479,20 @@ class BlueskyComm : public QThread bsp.name = pitr; bsp.default_val = kwargs[pitr].toString(); plan.parameters[pitr] = bsp; - if(pitr == "md") // use meta data to link to scan name - { - plan.name = bsp.default_val; - } } } if(param.contains("user")) { plan.user = param["user"].toString(); } + if(param.contains("meta")) + { + QJsonObject meta = param["meta"].toObject(); + if(meta.contains("name")) + { + plan.name = meta["name"].toString(); + } + } if(param.contains("item_uid")) { plan.uuid = param["item_uid"].toString(); @@ -533,7 +579,9 @@ public slots: QJsonObject rootJson = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); if(rootJson.contains("msg")) { - emit newData(rootJson["msg"].toString()); + QString msg = rootJson["msg"].toString(); + msg.chop(1); + emit newData(msg); } else { diff --git a/src/mvc/BlueskyPlan.h b/src/mvc/BlueskyPlan.h index ca97ad3..e367aa9 100644 --- a/src/mvc/BlueskyPlan.h +++ b/src/mvc/BlueskyPlan.h @@ -10,16 +10,20 @@ #include +enum class BlueskyParamType { Numeral = 1, String = 3 }; + + //--------------------------------------------------------------------------- struct BlueskyParam { BlueskyParam() { - default_val = "0.0"; + default_val = ""; } QString name; QString description; QString default_val; + BlueskyParamType kind; }; //--------------------------------------------------------------------------- diff --git a/src/mvc/ScanQueueWidget.cpp b/src/mvc/ScanQueueWidget.cpp index 10c6e12..80566d5 100644 --- a/src/mvc/ScanQueueWidget.cpp +++ b/src/mvc/ScanQueueWidget.cpp @@ -89,6 +89,7 @@ void ScanQueueWidget::_createLayout() _te_qs_console = new QTextEdit(this); _te_qs_console->scrollBarWidgets(Qt::AlignRight); + _te_qs_console->setReadOnly(true); QDockWidget *dock_running = new QDockWidget("Running Scan", this); dock_running->setWidget(_scan_running_table_view); @@ -125,6 +126,7 @@ void ScanQueueWidget::updateQueuedItems( std::vector &queued_plans, void ScanQueueWidget::newDataArrived(const QString& data) { + //_te_qs_console->insertPlainText(data); _te_qs_console->append(data); if (data.count("Item added: success=True item_type='plan'") > 0 || data.count("Plan failed:") > 0 From d7c963f71d365eca50541fe6d00afd12c425c3d5 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Wed, 14 Aug 2024 14:26:38 -0500 Subject: [PATCH 2/3] Added fit parameter presets as a combobox --- src/mvc/FitParamsTableModel.cpp | 19 +++++++++--- src/mvc/FitParamsTableModel.h | 7 +++-- src/mvc/FitSpectraWidget.cpp | 55 ++++++++++++++++++++++++++++----- src/mvc/FitSpectraWidget.h | 6 ++-- src/mvc/FittingDialog.cpp | 5 +-- src/mvc/MapsElementsWidget.cpp | 1 - src/mvc/SpectraWidget.cpp | 6 +++- src/mvc/SpectraWidget.h | 3 ++ 8 files changed, 83 insertions(+), 19 deletions(-) diff --git a/src/mvc/FitParamsTableModel.cpp b/src/mvc/FitParamsTableModel.cpp index d2abeb1..94dbdb6 100644 --- a/src/mvc/FitParamsTableModel.cpp +++ b/src/mvc/FitParamsTableModel.cpp @@ -4,7 +4,6 @@ *---------------------------------------------------------------------------*/ #include "FitParamsTableModel.h" -#include "fitting/models/gaussian_model.h" #include //--------------------------------------------------------------------------- @@ -18,7 +17,7 @@ FitParamsTableModel::FitParamsTableModel(QObject* parent) : QAbstractTableModel( m_headers[BOUND_TYPE] = tr("Is Fixed"); m_headers[MIN_VAL] = tr("Min Value"); m_headers[MAX_VAL] = tr("Max Value"); - m_headers[STEP_SIZE] = tr("Step Size"); + //m_headers[STEP_SIZE] = tr("Step Size"); _editable = true; _optimizer_supports_min_max = false; @@ -54,6 +53,16 @@ int FitParamsTableModel::columnCount(const QModelIndex &parent) const //--------------------------------------------------------------------------- +void FitParamsTableModel::setOptimizerPreset(fitting::models::Fit_Params_Preset preset) +{ + fitting::models::Gaussian_Model gmodel; + gmodel.update_fit_params_values(&_fit_parameters); + gmodel.set_fit_params_preset(preset); + updateFitParams(&gmodel.fit_parameters()); +} + +//--------------------------------------------------------------------------- + void FitParamsTableModel::setOptimizerSupportsMinMax(bool val) { _optimizer_supports_min_max = val; @@ -65,7 +74,7 @@ void FitParamsTableModel::setOptimizerSupportsMinMax(bool val) //--------------------------------------------------------------------------- -void FitParamsTableModel::updateFitParams(data_struct::Fit_Parameters* fit_params) +void FitParamsTableModel::updateFitParams(const data_struct::Fit_Parameters* fit_params) { if(fit_params != nullptr) { @@ -157,7 +166,7 @@ QVariant FitParamsTableModel::data(const QModelIndex &index, int role) const else if (index.column() == VALUE) return fitp.value; else if (index.column() == MIN_VAL) return fitp.min_val; else if (index.column() == MAX_VAL) return fitp.max_val; - else if (index.column() == STEP_SIZE) return fitp.step_size; + // else if (index.column() == STEP_SIZE) return fitp.step_size; else if (index.column() == BOUND_TYPE) { if (_optimizer_supports_min_max) @@ -403,6 +412,7 @@ bool FitParamsTableModel::setData(const QModelIndex &index, else return false; } + /* else if (column == STEP_SIZE) { if(ok) @@ -410,6 +420,7 @@ bool FitParamsTableModel::setData(const QModelIndex &index, else return false; } + */ else if (column == BOUND_TYPE) { _fit_parameters[fitp_name].bound_type = (data_struct::E_Bound_Type)value.toInt(); diff --git a/src/mvc/FitParamsTableModel.h b/src/mvc/FitParamsTableModel.h index 698d347..ccc2271 100644 --- a/src/mvc/FitParamsTableModel.h +++ b/src/mvc/FitParamsTableModel.h @@ -12,6 +12,7 @@ #include #include #include "data_struct/fit_parameters.h" +#include "fitting/models/gaussian_model.h" //--------------------------------------------------------------------------- @@ -36,7 +37,7 @@ class FitParamsTableModel BOUND_TYPE, MIN_VAL, MAX_VAL, - STEP_SIZE, + //STEP_SIZE, NUM_PROPS }; @@ -49,9 +50,11 @@ class FitParamsTableModel void setOptimizerSupportsMinMax(bool val); + void setOptimizerPreset(fitting::models::Fit_Params_Preset preset); + void setFitParams(data_struct::Fit_Parameters fit_params); - void updateFitParams(data_struct::Fit_Parameters* fit_params); + void updateFitParams(const data_struct::Fit_Parameters* fit_params); void only_keep_these_keys(data_struct::Fit_Parameters fit_params); diff --git a/src/mvc/FitSpectraWidget.cpp b/src/mvc/FitSpectraWidget.cpp index 882adb2..d749aa5 100644 --- a/src/mvc/FitSpectraWidget.cpp +++ b/src/mvc/FitSpectraWidget.cpp @@ -144,7 +144,6 @@ void FitSpectraWidget::createLayout() _fit_params_table->setItemDelegateForColumn(4, npDelegate); _fit_params_table->setItemDelegateForColumn(5, npDelegate); _fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); - //_fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); _fit_params_table->setContextMenuPolicy(Qt::CustomContextMenu); connect(_fit_params_table, SIGNAL(customContextMenuRequested(QPoint)), @@ -160,7 +159,7 @@ void FitSpectraWidget::createLayout() _fit_elements_table->setModel(_fit_elements_table_model); _fit_elements_table->setItemDelegateForColumn(1, npDelegate); _fit_elements_table->sortByColumn(0, Qt::AscendingOrder); - //_fit_elements_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + //_fit_elements_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); QItemSelectionModel* mod = _fit_elements_table->selectionModel(); connect(mod, @@ -168,9 +167,7 @@ void FitSpectraWidget::createLayout() this, SLOT(element_selection_changed(QModelIndex,QModelIndex))); - _btnSsettings = new QPushButton(QIcon(":/images/gear.png"), "", this); - _btnSsettings->setMaximumWidth(64); - connect(_btnSsettings, &QPushButton::released, this, &FitSpectraWidget::onSettingsDialog); + connect(_spectra_widget, &SpectraWidget::onSettingsDialog, this, &FitSpectraWidget::onSettingsDialog); _btn_fit_spectra = new QPushButton("Fit Spectra"); connect(_btn_fit_spectra, &QPushButton::released, this, &FitSpectraWidget::Fit_Spectra_Click); @@ -226,6 +223,16 @@ void FitSpectraWidget::createLayout() _fit_params_tab_widget->addTab(_fit_params_table, "Fit Parameters"); _fit_params_tab_widget->addTab(element_widget, "Fit Elements"); + _cb_fitting_preset = new QComboBox(); + _cb_fitting_preset->addItem("User Defined"); + _cb_fitting_preset->addItem("Fit Amplitutes Only"); + _cb_fitting_preset->addItem("Fit No Tails"); + _cb_fitting_preset->addItem("Fit With Tails"); + _cb_fitting_preset->addItem("Fit With Free Energy"); + _cb_fitting_preset->addItem("Fit No Tails Energy Quadratic"); + connect(_cb_fitting_preset, &QComboBox::currentIndexChanged, this, &FitSpectraWidget::optimizer_preset_changed); + + _cb_opttimizer = new QComboBox(); _cb_opttimizer->addItem(STR_HYBRID_MP_FIT); _cb_opttimizer->addItem(STR_MP_FIT); @@ -247,7 +254,7 @@ void FitSpectraWidget::createLayout() { orient_layout = new QHBoxLayout(); //splitter->setOrientation(Qt::Horizontal); - grid_layout->addWidget(_btnSsettings, 0, 0); + grid_layout->addWidget(_cb_fitting_preset, 0, 0); grid_layout->addWidget(_cb_opttimizer, 0, 1); grid_layout->addWidget(_btn_fit_spectra, 1, 0); @@ -263,7 +270,7 @@ void FitSpectraWidget::createLayout() { orient_layout = new QVBoxLayout(); //splitter->setOrientation(Qt::Vertical); - grid_layout->addWidget(_btnSsettings, 0, 0); + grid_layout->addWidget(_cb_fitting_preset, 0, 0); grid_layout->addWidget(_cb_opttimizer, 0, 1); grid_layout->addWidget(_chk_auto_model, 0, 2); grid_layout->addWidget(_btn_export_csv, 0, 3); @@ -290,6 +297,8 @@ void FitSpectraWidget::createLayout() // splitter->setStretchFactor(0, 1); // splitter->addWidget(tab_and_buttons_widget); + _cb_fitting_preset->setCurrentIndex(2); + //optimizer_preset_changed(2); // batch with no tails optimizer_changed(STR_HYBRID_MP_FIT); QLayout* layout = new QVBoxLayout(); @@ -386,6 +395,8 @@ void FitSpectraWidget::onSettingsDialog() else { QString name = "Fitted_Int_" + QString(STR_FIT_GAUSS_MATRIX.c_str()); + _spectra_widget->remove_spectra(name); + name = "Fitted_Int_" + QString(STR_FIT_INT_BACKGROUND.c_str()); _spectra_widget->remove_spectra(name); } @@ -1237,6 +1248,36 @@ void FitSpectraWidget::element_selection_changed(int index) //--------------------------------------------------------------------------- +void FitSpectraWidget::optimizer_preset_changed(int val) +{ + switch (val) + { + case 0: + //_fit_params_table_model->setOptimizerPreset(fitting::models::Fit_Params_Preset::NOT_SET); + break; + case 1: + _fit_params_table_model->setOptimizerPreset(fitting::models::Fit_Params_Preset::MATRIX_BATCH_FIT); + break; + case 2: + _fit_params_table_model->setOptimizerPreset(fitting::models::Fit_Params_Preset::BATCH_FIT_NO_TAILS); + break; + case 3: + _fit_params_table_model->setOptimizerPreset(fitting::models::Fit_Params_Preset::BATCH_FIT_WITH_TAILS); + break; + case 4: + _fit_params_table_model->setOptimizerPreset(fitting::models::Fit_Params_Preset::BATCH_FIT_WITH_FREE_ENERGY); + break; + case 5: + _fit_params_table_model->setOptimizerPreset(fitting::models::Fit_Params_Preset::BATCH_FIT_NO_TAILS_E_QUAD); + break; + default: + } + _fit_params_table->resizeColumnToContents(0); +} + +//--------------------------------------------------------------------------- + + void FitSpectraWidget::optimizer_changed(QString val) { if(val == STR_LM_FIT) diff --git a/src/mvc/FitSpectraWidget.h b/src/mvc/FitSpectraWidget.h index 9de29ca..d4fa471 100644 --- a/src/mvc/FitSpectraWidget.h +++ b/src/mvc/FitSpectraWidget.h @@ -109,6 +109,8 @@ public slots: void optimizer_changed(QString val); + void optimizer_preset_changed(int idx); + // void element_clicked(QModelIndex index); void Model_Spectra_Val_Change(QModelIndex,QModelIndex,QVector); @@ -186,6 +188,8 @@ private slots: QComboBox *_cb_opttimizer; + QComboBox *_cb_fitting_preset; + QTabWidget *_fit_params_tab_widget; QPushButton* _btn_fit_spectra; @@ -236,8 +240,6 @@ private slots: QComboBox* _cb_detector_element; - QPushButton* _btnSsettings; - bool _showDetailedFitSpec; bool _showFitIntMatrix; diff --git a/src/mvc/FittingDialog.cpp b/src/mvc/FittingDialog.cpp index 5599683..ba70459 100644 --- a/src/mvc/FittingDialog.cpp +++ b/src/mvc/FittingDialog.cpp @@ -75,13 +75,14 @@ void FittingDialog::_createLayout() _fit_params_table->setItemDelegateForColumn(3, npDelegate); _fit_params_table->setItemDelegateForColumn(4, npDelegate); _fit_params_table->setItemDelegateForColumn(5, npDelegate); - _fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + _fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); + _fit_params_table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); _new_fit_params_table = new QTableView(); _new_fit_params_table->setModel(_new_fit_params_table_model); _new_fit_params_table->sortByColumn(0, Qt::AscendingOrder); _new_fit_params_table->setItemDelegateForColumn(2, cbDelegate); - _new_fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + _new_fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); connect(_new_fit_params_table->verticalScrollBar(), &QAbstractSlider::valueChanged, _fit_params_table->verticalScrollBar(), &QAbstractSlider::setValue); diff --git a/src/mvc/MapsElementsWidget.cpp b/src/mvc/MapsElementsWidget.cpp index ca797b2..747fb33 100644 --- a/src/mvc/MapsElementsWidget.cpp +++ b/src/mvc/MapsElementsWidget.cpp @@ -66,7 +66,6 @@ MapsElementsWidget::MapsElementsWidget(int rows, int cols, bool create_image_nav connect(&_img_seg_diag, &ImageSegRoiDialog::onNewROIs, this, &MapsElementsWidget::on_add_new_ROIs); setAttribute(Qt::WA_DeleteOnClose, true); - connect(this, SIGNAL(destroyed()), this, SLOT(closeEvent())); _createLayout(create_image_nav, restore_floating); } diff --git a/src/mvc/SpectraWidget.cpp b/src/mvc/SpectraWidget.cpp index ea336df..22bb6e3 100644 --- a/src/mvc/SpectraWidget.cpp +++ b/src/mvc/SpectraWidget.cpp @@ -137,6 +137,10 @@ void SpectraWidget::createLayout() _btn_reset_chart_view = new QPushButton("Reset"); connect(_btn_reset_chart_view, &QPushButton::released, this, &SpectraWidget::onResetChartView); + _btnSsettings = new QPushButton(QIcon(":/images/gear.png"), "", this); + _btnSsettings->setMaximumWidth(64); + connect(_btnSsettings, &QPushButton::released, this, &SpectraWidget::onSettingsDialog); + QHBoxLayout* spectra_layout = new QHBoxLayout(); spectra_layout->addWidget(_chartView); @@ -159,7 +163,7 @@ void SpectraWidget::createLayout() options_layout->addWidget(new QLabel("Counts | ")); */ options_layout->addWidget(_btn_reset_chart_view); - + options_layout->addWidget(_btnSsettings); options_layout->addItem(new QSpacerItem(9999, 40, QSizePolicy::Maximum)); QVBoxLayout* vlayout = new QVBoxLayout(); diff --git a/src/mvc/SpectraWidget.h b/src/mvc/SpectraWidget.h index 3e6724f..e31a001 100644 --- a/src/mvc/SpectraWidget.h +++ b/src/mvc/SpectraWidget.h @@ -112,6 +112,7 @@ class SpectraWidget : public QWidget void setBackgroundBlack(bool val); signals: + void onSettingsDialog(); void trigger_connect_markers(); @@ -170,6 +171,8 @@ private slots: private: + QPushButton* _btnSsettings; + QLineEdit *_display_eneergy_max; QLineEdit *_display_eneergy_min; From aad4b8406323b66c266a14adb9710830e5641235 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Fri, 16 Aug 2024 11:05:13 -0500 Subject: [PATCH 3/3] Added function in fit parameters context menu to be able to load output/fit_params/*.cav params --- src/mvc/FitSpectraWidget.cpp | 69 ++++++++++++++++++++++++++++++++++++ src/mvc/FitSpectraWidget.h | 2 ++ src/mvc/FittingDialog.cpp | 6 ++-- 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/src/mvc/FitSpectraWidget.cpp b/src/mvc/FitSpectraWidget.cpp index d749aa5..45b5f84 100644 --- a/src/mvc/FitSpectraWidget.cpp +++ b/src/mvc/FitSpectraWidget.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "data_struct/element_info.h" @@ -98,6 +99,8 @@ FitSpectraWidget::FitSpectraWidget(QWidget* parent) : QWidget(parent) //FIXED=1, LIMITED_LO_HI=2, LIMITED_LO=3, LIMITED_HI=4, FIT=5}; _fit_param_contextMenu = new QMenu(("Context menu"), this); _fit_param_contextMenu->addMenu(_set_fit_params_bounds_menu); + action_bounds = _fit_param_contextMenu->addAction("Load from CSV"); + connect(action_bounds, SIGNAL(triggered(bool)), this, SLOT(show_load_fit_params_dialog(bool))); } @@ -435,6 +438,72 @@ void FitSpectraWidget::onSettingsDialog() //--------------------------------------------------------------------------- +void FitSpectraWidget::show_load_fit_params_dialog(bool val) +{ + QString fileName = QFileDialog::getOpenFileName(this, + "Open Fit Parameters", _dataset_dir.absolutePath(), + "Fit Parameters (*.csv);;All Files (*.*)"); + + // Dialog returns a nullptr string if user press cancel. + if (fileName.isNull() || fileName.isEmpty()) return; + + QString filePath = QFileInfo(fileName).canonicalFilePath(); + + QFile file(filePath); + if (!file.open(QIODevice::ReadOnly)) + { + logE<< file.errorString().toStdString(); + return; + } + bool conv_log10 = Preferences::inst()->getValue(STR_PFR_LOG_10).toBool(); + data_struct::Fit_Parameters fit_params = _fit_params_table_model->getFitParams(); + data_struct::Fit_Parameters fit_elements = _fit_elements_table_model->getAsFitParams(); + QStringList wordList; + while (!file.atEnd()) + { + QByteArray line = file.readLine(); + QString sline = QString(line).trimmed(); + wordList = sline.split(','); + if( wordList.size() == 2 ) + { + std::string sfirst = wordList[0].toStdString(); + if( fit_params.contains(sfirst) ) + { + bool ok = false; + double val = wordList[1].toDouble(&ok); + if(ok) + { + if( sfirst == STR_COMPTON_AMPLITUDE || sfirst == STR_COHERENT_SCT_AMPLITUDE) + { + if(conv_log10) + { + val = log10(val); + } + } + fit_params[sfirst].value = val; + } + } + else if( fit_elements.contains(sfirst) ) + { + bool ok = false; + double val = wordList[1].toDouble(&ok); + if(ok) + { + if(conv_log10) + { + val = log10(val); + } + fit_elements[sfirst].value = val; + } + } + } + } + _fit_params_table_model->setFitParams(fit_params); + _fit_elements_table_model->updateElementValues(&fit_elements); +} + +//--------------------------------------------------------------------------- + void FitSpectraWidget::on_export_fit_paramters() { data_struct::Fit_Parameters fit_params; diff --git a/src/mvc/FitSpectraWidget.h b/src/mvc/FitSpectraWidget.h index d4fa471..d34300e 100644 --- a/src/mvc/FitSpectraWidget.h +++ b/src/mvc/FitSpectraWidget.h @@ -174,6 +174,8 @@ private slots: void set_fit_params_bounds_limited_hi(bool v) { set_fit_params_bounds(data_struct::E_Bound_Type::LIMITED_HI); } + void show_load_fit_params_dialog(bool); + void set_fit_params_bounds(data_struct::E_Bound_Type e_type); void pileup_chk_changed(int state); diff --git a/src/mvc/FittingDialog.cpp b/src/mvc/FittingDialog.cpp index ba70459..23d1599 100644 --- a/src/mvc/FittingDialog.cpp +++ b/src/mvc/FittingDialog.cpp @@ -77,13 +77,15 @@ void FittingDialog::_createLayout() _fit_params_table->setItemDelegateForColumn(5, npDelegate); _fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); _fit_params_table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); - + _fit_params_table->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); + _new_fit_params_table = new QTableView(); _new_fit_params_table->setModel(_new_fit_params_table_model); _new_fit_params_table->sortByColumn(0, Qt::AscendingOrder); _new_fit_params_table->setItemDelegateForColumn(2, cbDelegate); _new_fit_params_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); - + _new_fit_params_table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); + connect(_new_fit_params_table->verticalScrollBar(), &QAbstractSlider::valueChanged, _fit_params_table->verticalScrollBar(), &QAbstractSlider::setValue); _btn_run = new QPushButton("Run");