From 7cfcbc25df36d8f58b10366ea4a3067e96bab2bf Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Mon, 19 Aug 2024 13:15:24 -0500 Subject: [PATCH 1/3] Added missing break --- src/mvc/FitSpectraWidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mvc/FitSpectraWidget.cpp b/src/mvc/FitSpectraWidget.cpp index 45b5f84..1a20e57 100644 --- a/src/mvc/FitSpectraWidget.cpp +++ b/src/mvc/FitSpectraWidget.cpp @@ -1340,6 +1340,7 @@ void FitSpectraWidget::optimizer_preset_changed(int val) _fit_params_table_model->setOptimizerPreset(fitting::models::Fit_Params_Preset::BATCH_FIT_NO_TAILS_E_QUAD); break; default: + break; } _fit_params_table->resizeColumnToContents(0); } From d2073d1239846b7f087fddf231aaaf69cbcd195f Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Tue, 20 Aug 2024 13:41:46 -0500 Subject: [PATCH 2/3] Added periodic table widget. Change preferences to combobox for fit params layout. --- src/mvc/FitSpectraWidget.cpp | 32 +++- src/mvc/FitSpectraWidget.h | 9 + src/mvc/PeriodicTableWidget.cpp | 217 +++++++++++++++++++++++++ src/mvc/PeriodicTableWidget.h | 166 +++++++++++++++++++ src/mvc/SpectraWidget.cpp | 2 +- src/preferences/PreferencesDisplay.cpp | 10 +- src/preferences/PreferencesDisplay.h | 2 +- 7 files changed, 429 insertions(+), 9 deletions(-) create mode 100644 src/mvc/PeriodicTableWidget.cpp create mode 100644 src/mvc/PeriodicTableWidget.h diff --git a/src/mvc/FitSpectraWidget.cpp b/src/mvc/FitSpectraWidget.cpp index 1a20e57..4c0b63e 100644 --- a/src/mvc/FitSpectraWidget.cpp +++ b/src/mvc/FitSpectraWidget.cpp @@ -108,6 +108,11 @@ FitSpectraWidget::FitSpectraWidget(QWidget* parent) : QWidget(parent) FitSpectraWidget::~FitSpectraWidget() { + if(_periodic_table_widget != nullptr) + { + delete _periodic_table_widget; + } + if (_fitting_dialog != nullptr) { delete _fitting_dialog; @@ -137,6 +142,8 @@ void FitSpectraWidget::createLayout() ComboBoxDelegate *cbDelegate = new ComboBoxDelegate(bound_types); NumericPrecDelegate* npDelegate = new NumericPrecDelegate(); + _periodic_table_widget = new PeriodicTableWidget(); + connect(_periodic_table_widget, &PeriodicTableWidget::onSelect, this, &FitSpectraWidget::update_selected_element_to_add); _fit_params_table = new QTableView(); _fit_params_table->setModel(_fit_params_table_model); @@ -194,10 +201,16 @@ void FitSpectraWidget::createLayout() _btn_del_element = new QPushButton("Delete Element"); connect(_btn_del_element, &QPushButton::released, this, &FitSpectraWidget::del_element); + _btn_periodic_table = new QPushButton(); + _btn_periodic_table->setIcon(QIcon(":/images/grid.png")); + _btn_periodic_table->setFixedSize(32,32); + connect(_btn_periodic_table, &QPushButton::released, this, &FitSpectraWidget::display_periodic_table); + QGridLayout* add_element_grid_layout = new QGridLayout(); add_element_grid_layout->setAlignment(Qt::AlignTop); add_element_grid_layout->addWidget(new QLabel("Element"), 0, 0); add_element_grid_layout->addWidget(_cb_add_elements, 0, 1); + add_element_grid_layout->addWidget(_btn_periodic_table, 0, 2); add_element_grid_layout->addWidget(new QLabel("Shell"), 1, 0); add_element_grid_layout->addWidget(_cb_add_shell, 1, 1); //add_element_grid_layout->addWidget(new QLabel("Detector Element"), 2, 0); @@ -208,7 +221,7 @@ void FitSpectraWidget::createLayout() add_element_grid_layout->addWidget(_btn_del_element, 3, 1); QLayout* elements_layout; - if(Preferences::inst()->getValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION).toBool()) + if(Preferences::inst()->getValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION).toInt() == 1) { elements_layout = new QVBoxLayout(); } @@ -253,7 +266,7 @@ void FitSpectraWidget::createLayout() QLayout * orient_layout; //QSplitter* splitter = new QSplitter(); - if(Preferences::inst()->getValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION).toBool()) + if(Preferences::inst()->getValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION).toInt() == 1) { orient_layout = new QHBoxLayout(); //splitter->setOrientation(Qt::Horizontal); @@ -331,6 +344,13 @@ void FitSpectraWidget::displayROIs(bool val) //--------------------------------------------------------------------------- +void FitSpectraWidget::update_selected_element_to_add(QString val) +{ + _cb_add_elements->setCurrentText(val); +} + +//--------------------------------------------------------------------------- + void FitSpectraWidget::setParamOverride(data_struct::Params_Override* po) { _param_override = po; @@ -737,9 +757,15 @@ void FitSpectraWidget::clearROISpectra() //--------------------------------------------------------------------------- -void FitSpectraWidget::add_element() +void FitSpectraWidget::display_periodic_table() { + _periodic_table_widget->show(); +} +//--------------------------------------------------------------------------- + +void FitSpectraWidget::add_element() +{ if(_elements_to_fit == nullptr) { _elements_to_fit = new data_struct::Fit_Element_Map_Dict(); diff --git a/src/mvc/FitSpectraWidget.h b/src/mvc/FitSpectraWidget.h index d34300e..7ee7e12 100644 --- a/src/mvc/FitSpectraWidget.h +++ b/src/mvc/FitSpectraWidget.h @@ -27,6 +27,7 @@ #include "data_struct/fit_element_map.h" #include "data_struct/params_override.h" #include "mvc/SpectraWidgetSettingsDialog.h" +#include "mvc/PeriodicTableWidget.h" //--------------------------------------------------------------------------- @@ -182,6 +183,10 @@ private slots: void on_export_fit_paramters(); + void display_periodic_table(); + + void update_selected_element_to_add(QString); + private: //std::mutex _mutex; @@ -255,6 +260,10 @@ private slots: std::unordered_map _labeled_spectras; QDir _dataset_dir; + + QPushButton* _btn_periodic_table; + + PeriodicTableWidget* _periodic_table_widget; }; diff --git a/src/mvc/PeriodicTableWidget.cpp b/src/mvc/PeriodicTableWidget.cpp new file mode 100644 index 0000000..c5fbaaf --- /dev/null +++ b/src/mvc/PeriodicTableWidget.cpp @@ -0,0 +1,217 @@ +/*----------------------------------------------------------------------------- + * Copyright (c) 2024, UChicago Argonne, LLC + * See LICENSE file. + *---------------------------------------------------------------------------*/ + +#include +#include + +//--------------------------------------------------------------------------- + +PeriodicTableWidget::PeriodicTableWidget(QWidget *parent) : QWidget(parent) +{ + _layout = new QGridLayout(); + _layout->setHorizontalSpacing(0); + + + _layout->addWidget(_gen_el_btn("H"), 0,0); + _layout->addWidget(_gen_el_btn("He"), 0,17); + + _layout->addWidget(_gen_el_btn("Li"), 1,0); + _layout->addWidget(_gen_el_btn("Be"), 1,1); + _layout->addWidget(_gen_el_btn("B"), 1,12); + _layout->addWidget(_gen_el_btn("C"), 1,13); + _layout->addWidget(_gen_el_btn("N"), 1,14); + _layout->addWidget(_gen_el_btn("O"), 1,15); + _layout->addWidget(_gen_el_btn("F"), 1,16); + _layout->addWidget(_gen_el_btn("Ne"), 1,17); + + _layout->addWidget(_gen_el_btn("Na"), 2,0); + _layout->addWidget(_gen_el_btn("Mg"), 2,1); + _layout->addWidget(_gen_el_btn("Al"), 2,12); + _layout->addWidget(_gen_el_btn("Si"), 2,13); + _layout->addWidget(_gen_el_btn("P"), 2,14); + _layout->addWidget(_gen_el_btn("S"), 2,15); + _layout->addWidget(_gen_el_btn("Cl"), 2,16); + _layout->addWidget(_gen_el_btn("Ar"), 2,17); + + _layout->addWidget(_gen_el_btn("K"), 3,0); + _layout->addWidget(_gen_el_btn("Ca"), 3,1); + _layout->addWidget(_gen_el_btn("Sc"), 3,2); + _layout->addWidget(_gen_el_btn("Ti"), 3,3); + _layout->addWidget(_gen_el_btn("V"), 3,4); + _layout->addWidget(_gen_el_btn("Cr"), 3,5); + _layout->addWidget(_gen_el_btn("Mn"), 3,6); + _layout->addWidget(_gen_el_btn("Fe"), 3,7); + _layout->addWidget(_gen_el_btn("Co"), 3,8); + _layout->addWidget(_gen_el_btn("Ni"), 3,9); + _layout->addWidget(_gen_el_btn("Cu"), 3,10); + _layout->addWidget(_gen_el_btn("Zn"), 3,11); + _layout->addWidget(_gen_el_btn("Ga"), 3,12); + _layout->addWidget(_gen_el_btn("Ge"), 3,13); + _layout->addWidget(_gen_el_btn("As"), 3,14); + _layout->addWidget(_gen_el_btn("Se"), 3,15); + _layout->addWidget(_gen_el_btn("Br"), 3,16); + _layout->addWidget(_gen_el_btn("Kr"), 3,17); + + _layout->addWidget(_gen_el_btn("Rb"), 4,0); + _layout->addWidget(_gen_el_btn("Sr"), 4,1); + _layout->addWidget(_gen_el_btn("Y"), 4,2); + _layout->addWidget(_gen_el_btn("Zr"), 4,3); + _layout->addWidget(_gen_el_btn("Nb"), 4,4); + _layout->addWidget(_gen_el_btn("Mo"), 4,5); + _layout->addWidget(_gen_el_btn("Tc"), 4,6); + _layout->addWidget(_gen_el_btn("Ru"), 4,7); + _layout->addWidget(_gen_el_btn("Rh"), 4,8); + _layout->addWidget(_gen_el_btn("Pd"), 4,9); + _layout->addWidget(_gen_el_btn("Ag"), 4,10); + _layout->addWidget(_gen_el_btn("Cd"), 4,11); + _layout->addWidget(_gen_el_btn("In"), 4,12); + _layout->addWidget(_gen_el_btn("Sn"), 4,13); + _layout->addWidget(_gen_el_btn("Sb"), 4,14); + _layout->addWidget(_gen_el_btn("Te"), 4,15); + _layout->addWidget(_gen_el_btn("I"), 4,16); + _layout->addWidget(_gen_el_btn("Xe"), 4,17); + + _layout->addWidget(_gen_el_btn("Cs"), 5,0); + _layout->addWidget(_gen_el_btn("Ba"), 5,1); + _layout->addWidget(_gen_el_btn("La"), 5,2); + _layout->addWidget(_gen_el_btn("Hf"), 5,3); + _layout->addWidget(_gen_el_btn("Ta"), 5,4); + _layout->addWidget(_gen_el_btn("W"), 5,5); + _layout->addWidget(_gen_el_btn("Re"), 5,6); + _layout->addWidget(_gen_el_btn("Os"), 5,7); + _layout->addWidget(_gen_el_btn("Ir"), 5,8); + _layout->addWidget(_gen_el_btn("Pt"), 5,9); + _layout->addWidget(_gen_el_btn("Au"), 5,10); + _layout->addWidget(_gen_el_btn("Hg"), 5,11); + _layout->addWidget(_gen_el_btn("Tl"), 5,12); + _layout->addWidget(_gen_el_btn("Pb"), 5,13); + _layout->addWidget(_gen_el_btn("Bi"), 5,14); + _layout->addWidget(_gen_el_btn("Po"), 5,15); + _layout->addWidget(_gen_el_btn("At"), 5,16); + _layout->addWidget(_gen_el_btn("Rn"), 5,17); + + _layout->addWidget(_gen_el_btn("Fr"), 6,0); + _layout->addWidget(_gen_el_btn("Ra"), 6,1); + _layout->addWidget(_gen_el_btn("Ac"), 6,2); + _layout->addWidget(_gen_el_btn("Rf"), 6,3); + _layout->addWidget(_gen_el_btn("Db"), 6,4); + _layout->addWidget(_gen_el_btn("Sg"), 6,5); + _layout->addWidget(_gen_el_btn("Bh"), 6,6); + _layout->addWidget(_gen_el_btn("Hs"), 6,7); + _layout->addWidget(_gen_el_btn("Mt"), 6,8); + _layout->addWidget(_gen_el_btn("Ds"), 6,9); + _layout->addWidget(_gen_el_btn("Rg"), 6,10); + _layout->addWidget(_gen_el_btn("Cn"), 6,11); + _layout->addWidget(_gen_el_btn("Nh"), 6,12); + _layout->addWidget(_gen_el_btn("Fl"), 6,13); + _layout->addWidget(_gen_el_btn("Mc"), 6,14); + _layout->addWidget(_gen_el_btn("Lv"), 6,15); + _layout->addWidget(_gen_el_btn("Ts"), 6,16); + _layout->addWidget(_gen_el_btn("Og"), 6,17); + + _layout->addWidget(new QLabel(" "), 7,3); + + _layout->addWidget(_gen_el_btn("Ce"), 8,3); + _layout->addWidget(_gen_el_btn("Pr"), 8,4); + _layout->addWidget(_gen_el_btn("Nd"), 8,5); + _layout->addWidget(_gen_el_btn("Pm"), 8,6); + _layout->addWidget(_gen_el_btn("Sm"), 8,7); + _layout->addWidget(_gen_el_btn("Eu"), 8,8); + _layout->addWidget(_gen_el_btn("Gd"), 8,9); + _layout->addWidget(_gen_el_btn("Tb"), 8,10); + _layout->addWidget(_gen_el_btn("Dy"), 8,11); + _layout->addWidget(_gen_el_btn("Ho"), 8,12); + _layout->addWidget(_gen_el_btn("Er"), 8,13); + _layout->addWidget(_gen_el_btn("Tm"), 8,14); + _layout->addWidget(_gen_el_btn("Yb"), 8,15); + _layout->addWidget(_gen_el_btn("Lu"), 8,16); + + _layout->addWidget(_gen_el_btn("Th"), 9,3); + _layout->addWidget(_gen_el_btn("Pa"), 9,4); + _layout->addWidget(_gen_el_btn("U"), 9,5); + _layout->addWidget(_gen_el_btn("Np"), 9,6); + _layout->addWidget(_gen_el_btn("Pu"), 9,7); + _layout->addWidget(_gen_el_btn("Am"), 9,8); + _layout->addWidget(_gen_el_btn("Cm"), 9,9); + _layout->addWidget(_gen_el_btn("Bk"), 9,10); + _layout->addWidget(_gen_el_btn("Cf"), 9,11); + _layout->addWidget(_gen_el_btn("Es"), 9,12); + _layout->addWidget(_gen_el_btn("Fm"), 9,13); + _layout->addWidget(_gen_el_btn("Md"), 9,14); + _layout->addWidget(_gen_el_btn("No"), 9,15); + _layout->addWidget(_gen_el_btn("Lr"), 9,16); + + this->setLayout(_layout); +} + +//--------------------------------------------------------------------------- + +PeriodicTableWidget::~PeriodicTableWidget() +{ + +} + +//--------------------------------------------------------------------------- + +void PeriodicTableWidget::button_pressed() +{ + QPushButton* btn = qobject_cast(sender()); + emit onSelect(btn->text()); + this->hide(); +} + +//--------------------------------------------------------------------------- + +QPushButton* PeriodicTableWidget::_gen_el_btn(QString symbol) +{ + enum Element_Class ec = Element_Class_Map.at(symbol); + QPushButton *btn; + btn = new QPushButton(); + btn->setText(symbol); + btn->setFixedWidth(36); + switch(ec) + { + case Element_Class::Hydrogen: + btn->setStyleSheet("QPushButton {background-color: #8ab4f8; color: white;}"); + break; + case Element_Class::Alkaline_Metal: + btn->setStyleSheet("QPushButton {background-color: #244d57; color: white;}"); + break; + case Element_Class::Alkaline_Earth_Metal: + btn->setStyleSheet("QPushButton {background-color: #622e39; color: white;}"); + break; + case Element_Class::Transition_metals: + btn->setStyleSheet("QPushButton {background-color: #433c65; color: white;}"); + break; + case Element_Class::Post_Transition_Metals: + btn->setStyleSheet("QPushButton {background-color: #2f4d47; color: white;}"); + break; + case Element_Class::Metalloids: + btn->setStyleSheet("QPushButton {background-color: #523e1b; color: white;}"); + break; + case Element_Class::Reactive_nonmetals: + btn->setStyleSheet("QPushButton {background-color: #2a4165; color: white;}"); + break; + case Element_Class::Noble_gases: + btn->setStyleSheet("QPushButton {background-color: #623842; color: white;}"); + break; + case Element_Class::Lanthanides: + btn->setStyleSheet("QPushButton {background-color: #004a77; color: white;}"); + break; + case Element_Class::Actinides: + btn->setStyleSheet("QPushButton {background-color: #613b28; color: white;}"); + break; + case Element_Class::Unknown_properties: + default: + btn->setStyleSheet("QPushButton {background-color: #46474c; color: white;}"); + break; + } + + connect(btn, &QPushButton::released, this, &PeriodicTableWidget::button_pressed); + return btn; +} + +//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------- \ No newline at end of file diff --git a/src/mvc/PeriodicTableWidget.h b/src/mvc/PeriodicTableWidget.h new file mode 100644 index 0000000..3c85a7c --- /dev/null +++ b/src/mvc/PeriodicTableWidget.h @@ -0,0 +1,166 @@ +/*----------------------------------------------------------------------------- + * Copyright (c) 2024, UChicago Argonne, LLC + * See LICENSE file. + *---------------------------------------------------------------------------*/ + +#ifndef PERIODIC_TABLE_WIDGET_H +#define PERIODIC_TABLE_WIDGET_H + +//--------------------------------------------------------------------------- + +#include +#include +#include +#include + +enum class Element_Class { Hydrogen, Alkaline_Metal, Alkaline_Earth_Metal, Transition_metals, Post_Transition_Metals, Metalloids, Reactive_nonmetals, Noble_gases, Lanthanides, Actinides, Unknown_properties }; + +class PeriodicTableWidget : public QWidget +{ + + Q_OBJECT + +public: + PeriodicTableWidget(QWidget *parent = nullptr); + + ~PeriodicTableWidget(); + +signals: + + void onSelect(QString); + +public slots: + + void button_pressed(); + +private: + + QPushButton* _gen_el_btn(QString symbol); + + QGridLayout* _layout; + + const std::unordered_map Element_Class_Map = { + {"H", Element_Class::Hydrogen}, + {"He", Element_Class::Noble_gases}, + {"Li", Element_Class::Alkaline_Metal}, + {"Be", Element_Class::Alkaline_Earth_Metal}, + {"B", Element_Class::Metalloids}, + {"C", Element_Class::Reactive_nonmetals}, + {"N", Element_Class::Reactive_nonmetals}, + {"O", Element_Class::Reactive_nonmetals}, + {"F", Element_Class::Reactive_nonmetals}, + {"Ne", Element_Class::Noble_gases}, + {"Na", Element_Class::Alkaline_Metal}, + {"Mg", Element_Class::Alkaline_Earth_Metal}, + {"Al", Element_Class::Post_Transition_Metals}, + {"Si", Element_Class::Metalloids}, + {"P", Element_Class::Reactive_nonmetals}, + {"S", Element_Class::Reactive_nonmetals}, + {"Cl", Element_Class::Reactive_nonmetals}, + {"Ar", Element_Class::Noble_gases}, + {"K", Element_Class::Alkaline_Metal}, + {"Ca", Element_Class::Alkaline_Earth_Metal}, + {"Sc", Element_Class::Transition_metals}, + {"Ti", Element_Class::Transition_metals}, + {"V", Element_Class::Transition_metals}, + {"Cr", Element_Class::Transition_metals}, + {"Mn", Element_Class::Transition_metals}, + {"Fe", Element_Class::Transition_metals}, + {"Co", Element_Class::Transition_metals}, + {"Ni", Element_Class::Transition_metals}, + {"Cu", Element_Class::Transition_metals}, + {"Zn", Element_Class::Transition_metals}, + {"Ga", Element_Class::Post_Transition_Metals}, + {"Ge", Element_Class::Metalloids}, + {"As", Element_Class::Metalloids}, + {"Se", Element_Class::Reactive_nonmetals}, + {"Br", Element_Class::Reactive_nonmetals}, + {"Kr", Element_Class::Noble_gases}, + {"Rb", Element_Class::Alkaline_Metal}, + {"Sr", Element_Class::Alkaline_Earth_Metal}, + {"Y", Element_Class::Transition_metals}, + {"Zr", Element_Class::Transition_metals}, + {"Nb", Element_Class::Transition_metals}, + {"Mo", Element_Class::Transition_metals}, + {"Tc", Element_Class::Transition_metals}, + {"Ru", Element_Class::Transition_metals}, + {"Rh", Element_Class::Transition_metals}, + {"Pd", Element_Class::Transition_metals}, + {"Ag", Element_Class::Transition_metals}, + {"Cd", Element_Class::Transition_metals}, + {"In", Element_Class::Post_Transition_Metals}, + {"Sn", Element_Class::Post_Transition_Metals}, + {"Sb", Element_Class::Metalloids}, + {"Te", Element_Class::Metalloids}, + {"I", Element_Class::Reactive_nonmetals}, + {"Xe", Element_Class::Noble_gases}, + {"Cs", Element_Class::Alkaline_Metal}, + {"Ba", Element_Class::Alkaline_Earth_Metal}, + {"La", Element_Class::Lanthanides}, + {"Ce", Element_Class::Lanthanides}, + {"Pr", Element_Class::Lanthanides}, + {"Nd", Element_Class::Lanthanides}, + {"Pm", Element_Class::Lanthanides}, + {"Sm", Element_Class::Lanthanides}, + {"Eu", Element_Class::Lanthanides}, + {"Gd", Element_Class::Lanthanides}, + {"Tb", Element_Class::Lanthanides}, + {"Dy", Element_Class::Lanthanides}, + {"Ho", Element_Class::Lanthanides}, + {"Er", Element_Class::Lanthanides}, + {"Tm", Element_Class::Lanthanides}, + {"Yb", Element_Class::Lanthanides}, + {"Lu", Element_Class::Lanthanides}, + {"Hf", Element_Class::Transition_metals}, + {"Ta", Element_Class::Transition_metals}, + {"W", Element_Class::Transition_metals}, + {"Re", Element_Class::Transition_metals}, + {"Os", Element_Class::Transition_metals}, + {"Ir", Element_Class::Transition_metals}, + {"Pt", Element_Class::Transition_metals}, + {"Au", Element_Class::Transition_metals}, + {"Hg", Element_Class::Transition_metals}, + {"Tl", Element_Class::Post_Transition_Metals}, + {"Pb", Element_Class::Post_Transition_Metals}, + {"Bi", Element_Class::Post_Transition_Metals}, + {"Po", Element_Class::Post_Transition_Metals}, + {"At", Element_Class::Post_Transition_Metals}, + {"Rn", Element_Class::Noble_gases}, + {"Fr", Element_Class::Alkaline_Metal}, + {"Ra", Element_Class::Alkaline_Earth_Metal}, + {"Ac", Element_Class::Actinides}, + {"Th", Element_Class::Actinides}, + {"Pa", Element_Class::Actinides}, + {"U", Element_Class::Actinides}, + {"Np", Element_Class::Actinides}, + {"Pu", Element_Class::Actinides}, + {"Am", Element_Class::Actinides}, + {"Cm", Element_Class::Actinides}, + {"Bk", Element_Class::Actinides}, + {"Cf", Element_Class::Actinides}, + {"Es", Element_Class::Actinides}, + {"Fm", Element_Class::Actinides}, + {"Md", Element_Class::Actinides}, + {"No", Element_Class::Actinides}, + {"Lr", Element_Class::Actinides}, + {"Rf", Element_Class::Transition_metals}, + {"Db", Element_Class::Transition_metals}, + {"Sg", Element_Class::Transition_metals}, + {"Bh", Element_Class::Transition_metals}, + {"Hs", Element_Class::Transition_metals}, + {"Mt", Element_Class::Unknown_properties}, + {"Ds", Element_Class::Unknown_properties}, + {"Rg", Element_Class::Unknown_properties}, + {"Cn", Element_Class::Unknown_properties}, + {"Nh", Element_Class::Unknown_properties}, + {"Fl", Element_Class::Unknown_properties}, + {"Mc", Element_Class::Unknown_properties}, + {"Lv", Element_Class::Unknown_properties}, + {"Ts", Element_Class::Unknown_properties}, + {"Og", Element_Class::Unknown_properties}, + + }; + +}; + +#endif \ No newline at end of file diff --git a/src/mvc/SpectraWidget.cpp b/src/mvc/SpectraWidget.cpp index 22bb6e3..0b13303 100644 --- a/src/mvc/SpectraWidget.cpp +++ b/src/mvc/SpectraWidget.cpp @@ -67,7 +67,7 @@ void SpectraWidget::createLayout() _axisX = new QValueAxis(); _axisX->setTitleText("Energy (keV)"); - _axisX->setLabelFormat("%.2f"); + _axisX->setLabelFormat("%.1f"); _axisX->setTruncateLabels(false); _axisX->setTickAnchor(0.0); _axisX->setTickInterval(0.5); diff --git a/src/preferences/PreferencesDisplay.cpp b/src/preferences/PreferencesDisplay.cpp index fa315ad..7efa0f6 100644 --- a/src/preferences/PreferencesDisplay.cpp +++ b/src/preferences/PreferencesDisplay.cpp @@ -64,10 +64,12 @@ PreferencesDisplay::PreferencesDisplay(QWidget* parent) : QWidget(parent) _ck_show_dataset_on_load = new QCheckBox(); _ck_show_dataset_on_load->setChecked(Preferences::inst()->getValue(STR_PRF_SHOW_DATASET_ON_LOAD).toBool()); - QLabel* lblIntSpecControlLoc = new QLabel("Integreated Spectra Controls On the Right of spectra? (Unchecked = Below)"); + QLabel* lblIntSpecControlLoc = new QLabel("Integreated Spectra: Fit Params Location"); lblIntSpecControlLoc->setFont(font); - _ck_int_spec_horiz = new QCheckBox(); - _ck_int_spec_horiz->setChecked(Preferences::inst()->getValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION).toBool()); + _ck_int_spec_horiz = new QComboBox(); + _ck_int_spec_horiz->addItem("Below"); + _ck_int_spec_horiz->addItem("Right Side"); + _ck_int_spec_horiz->setCurrentIndex(Preferences::inst()->getValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION).toInt()); QLabel* lblSearchDatasets = new QLabel("Search sub folders for datasets (ESRF datasets)."); @@ -162,7 +164,7 @@ void PreferencesDisplay::acceptChanges() Preferences::inst()->setValue(STR_PRF_DecimalPrecision, getDecimalPrecision()); Preferences::inst()->setValue(STR_PRF_SHOW_DATASET_ON_FILE_SELECT, _ck_show_dataset_on_select->isChecked()); Preferences::inst()->setValue(STR_PRF_SHOW_DATASET_ON_LOAD, _ck_show_dataset_on_load->isChecked()); - Preferences::inst()->setValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION, _ck_int_spec_horiz->isChecked()); + Preferences::inst()->setValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION, _ck_int_spec_horiz->currentIndex()); Preferences::inst()->setValue(STR_SEARCH_SUB_DIR_FOR_DATASETS, _ck_search_datasets->isChecked()); Preferences::inst()->setValue(STR_PRF_STRICT_REGEX, _ck_strict_regex->isChecked()); Preferences::inst()->setValue(STR_PRF_FILE_SIZE, _cb_file_size->currentIndex()); diff --git a/src/preferences/PreferencesDisplay.h b/src/preferences/PreferencesDisplay.h index c69c0fd..39eee16 100644 --- a/src/preferences/PreferencesDisplay.h +++ b/src/preferences/PreferencesDisplay.h @@ -113,7 +113,7 @@ public slots: QComboBox* _cb_file_size; - QCheckBox* _ck_int_spec_horiz; + QComboBox* _ck_int_spec_horiz; }; //--------------------------------------------------------------------------- From 55149bdfb0b9e23bb45655ede503e4186f426068 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Thu, 22 Aug 2024 10:41:22 -0500 Subject: [PATCH 3/3] Fixed warning if you enter 0 for counts it just sets a default -11 in log 10. Fixed At as metaloid --- src/mvc/FitElementsTableModel.cpp | 9 ++++----- src/mvc/PeriodicTableWidget.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mvc/FitElementsTableModel.cpp b/src/mvc/FitElementsTableModel.cpp index 38bd35d..43ea06c 100644 --- a/src/mvc/FitElementsTableModel.cpp +++ b/src/mvc/FitElementsTableModel.cpp @@ -552,6 +552,7 @@ bool FitElementsTableModel::setData(const QModelIndex &index, { bool ok = false; double dval = value.toDouble(&ok); + QVariant new_value = value; if (false == ok) { QMessageBox::warning(nullptr, "Could not convert to double", "Could not convert your value to a double."); @@ -566,8 +567,7 @@ bool FitElementsTableModel::setData(const QModelIndex &index, } else if (dval < -10) { - QMessageBox::warning(nullptr, "Value too small", "Value is too small and will create NaN/Inf. Use range -10 : 20 ."); - return false; + new_value = QVariant(-11); } } else @@ -579,11 +579,10 @@ bool FitElementsTableModel::setData(const QModelIndex &index, } else if (dval < 1.0e-10) { - QMessageBox::warning(nullptr, "Value too small", "Value is too small and will create NaN/Inf. Use range 1.0e-10 : 1.0e20 ."); - return false; + new_value = QVariant(0); } } - node->itemData[1] = value; + node->itemData[1] = new_value; } } else diff --git a/src/mvc/PeriodicTableWidget.h b/src/mvc/PeriodicTableWidget.h index 3c85a7c..627cf0a 100644 --- a/src/mvc/PeriodicTableWidget.h +++ b/src/mvc/PeriodicTableWidget.h @@ -124,7 +124,7 @@ public slots: {"Pb", Element_Class::Post_Transition_Metals}, {"Bi", Element_Class::Post_Transition_Metals}, {"Po", Element_Class::Post_Transition_Metals}, - {"At", Element_Class::Post_Transition_Metals}, + {"At", Element_Class::Metalloids}, {"Rn", Element_Class::Noble_gases}, {"Fr", Element_Class::Alkaline_Metal}, {"Ra", Element_Class::Alkaline_Earth_Metal},