diff --git a/src/client/suprafit_cli.h b/src/client/suprafit_cli.h index 0b2ec1df..e9a4adad 100644 --- a/src/client/suprafit_cli.h +++ b/src/client/suprafit_cli.h @@ -20,6 +20,7 @@ #include #include +#include class SupraFitCli : public QObject { Q_OBJECT diff --git a/src/global.h b/src/global.h index cad48bc9..b435ba58 100644 --- a/src/global.h +++ b/src/global.h @@ -160,6 +160,7 @@ inline QString aboutHtml() info += "

Created by Conrad Hübler

"; info += "

Special thanks to Prof. M. Mazik, TU Bergakademie Freiberg for her support.

"; info += "

Special thanks to Dr. Sebastian Förster and Dr. Stefan Kaiser for finding bugs and constructive feedback.

"; + info += "

Special thanks to all with constructive feedback and bug hunting: Felix Amrhein.

"; info += "

Special thanks to Alexander König for testing the Quickstart, helpful comments and feedback.

"; info += "

Thanks to all encouraged me writing the application.

"; info += "

Built-in Icon Theme taken from Oxygens Icon : http://www.oxygen-icons.org

"; @@ -182,6 +183,7 @@ inline QString about() info += "\t*********************************************************************************************************\n\n"; info += "\tSpecial thanks to Prof. M. Mazik, TU Bergakademie Freiberg for her support.\n\n"; info += "\tSpecial thanks to \t Dr. Sebastian Förster \t and \t Dr. Stefan Kaiser \t for finding bugs and constructive feedback.\n"; + info += "\tSpecial thanks to all with constructive feedback and bug hunting: Felix Amrhein.\n"; info += "\tSpecial thanks to Alexander König for testing the Quickstart, helpful comments and feedback.\n\n\n"; info += "\tThanks to all encouraged me writing the application.\n\n"; info += "\tSupraFit website on GitHub: https://github.com/conradhuebler/SupraFit\n\n"; diff --git a/src/ui/dialogs/configdialog.cpp b/src/ui/dialogs/configdialog.cpp index f7476217..971b35d6 100644 --- a/src/ui/dialogs/configdialog.cpp +++ b/src/ui/dialogs/configdialog.cpp @@ -132,6 +132,16 @@ void ConfigDialog::createGeneralTab() h_layout->addWidget(m_threads); layout->addLayout(h_layout); + m_model_element_cols = new QSpinBox; + m_model_element_cols->setMaximum(1e6); + m_model_element_cols->setValue(qApp->instance()->property("ModelParameterColums").toInt()); + m_model_element_cols->setMinimum(1); + + h_layout = new QHBoxLayout; + h_layout->addWidget(new QLabel(tr("Columns for Model Parameter:"))); + h_layout->addWidget(m_model_element_cols); + layout->addLayout(h_layout); + layout->addWidget(new QLabel(tr("Set directory behavior to:"))); m_current_dir = new QRadioButton(tr("Current Directory, where Application was started"), generalTab); @@ -438,6 +448,8 @@ void ConfigDialog::accept() m_dirlevel = 2; qApp->instance()->setProperty("threads", m_threads->value()); + qApp->instance()->setProperty("ModelParameterColums", m_model_element_cols->value()); + qApp->instance()->setProperty("workingdir", m_working->text()); qApp->instance()->setProperty("dirlevel", m_dirlevel); qApp->instance()->setProperty("auto_confidence", m_auto_confidence->isChecked()); diff --git a/src/ui/dialogs/configdialog.h b/src/ui/dialogs/configdialog.h index d28df776..8893c2cb 100644 --- a/src/ui/dialogs/configdialog.h +++ b/src/ui/dialogs/configdialog.h @@ -60,7 +60,7 @@ class ConfigDialog : public QDialog { private: QRadioButton *m_current_dir, *m_last_dir, *m_working_dir; - QSpinBox *m_threads, *m_XScale, *m_YScale, *m_FontSize, *m_FastConfidenceScaling, *m_FastConfidenceSteps, *m_HistBins; + QSpinBox *m_threads, *m_model_element_cols, *m_XScale, *m_YScale, *m_FontSize, *m_FastConfidenceScaling, *m_FastConfidenceSteps, *m_HistBins; QDoubleSpinBox *m_p_value, *m_markerSize, *m_lineWidth, *m_chartScaling; QCheckBox *m_transparentChart, *m_cropedChart, *m_ColorFullSearch, *m_advanced_ui, *m_unsafe_copy, *m_overwrite_bins, *m_initialise_random; QLineEdit* m_working; diff --git a/src/ui/guitools/chartwrapper.cpp b/src/ui/guitools/chartwrapper.cpp index 2017fe14..6be1a94e 100644 --- a/src/ui/guitools/chartwrapper.cpp +++ b/src/ui/guitools/chartwrapper.cpp @@ -133,11 +133,8 @@ void ChartWrapper::InitaliseSeries() void ChartWrapper::UpdateModel() { - if (!m_working) { - m_working = m_stored_data; - m_transformed = false; - } + CheckWorking(); MakeSeries(); emit ModelChanged(); } @@ -277,4 +274,13 @@ void ChartWrapper::showSeries(int i) } emit ShowSeries(i); } + +void ChartWrapper::CheckWorking() +{ + if (!m_working) { + m_working = m_stored_data; + m_transformed = false; + } +} + #include "chartwrapper.moc" diff --git a/src/ui/guitools/chartwrapper.h b/src/ui/guitools/chartwrapper.h index 31283ff0..b59087c4 100644 --- a/src/ui/guitools/chartwrapper.h +++ b/src/ui/guitools/chartwrapper.h @@ -64,9 +64,17 @@ class ChartWrapper : public QObject { static QColor ColorCode(int i); - inline QString XLabel() const { return m_working.data()->XLabel(); } - - inline QString YLabel() const { return m_working.data()->YLabel(); } + inline QString XLabel() + { + CheckWorking(); + return m_working.data()->XLabel(); + } + + inline QString YLabel() + { + CheckWorking(); + return m_working.data()->YLabel(); + } public slots: void UpdateModel(); @@ -83,6 +91,7 @@ public slots: bool m_blocked, m_transformed, m_flipable; void InitaliseSeries(); + void CheckWorking(); signals: void ModelChanged(); diff --git a/src/ui/mainwindow/suprafitgui.cpp b/src/ui/mainwindow/suprafitgui.cpp index b64bacee..a4335f25 100644 --- a/src/ui/mainwindow/suprafitgui.cpp +++ b/src/ui/mainwindow/suprafitgui.cpp @@ -1409,6 +1409,9 @@ void SupraFitGui::ReadSettings() QTimer::singleShot(10, this, SLOT(FirstStart())); } + if (qApp->instance()->property("ModelParameterColums") == QVariant()) + qApp->instance()->setProperty("ModelParameterColums", 2); + if (qApp->instance()->property("xSize") == QVariant()) qApp->instance()->setProperty("xSize", 600); diff --git a/src/ui/mainwindow/suprafitgui.h b/src/ui/mainwindow/suprafitgui.h index b2db991f..42672c17 100644 --- a/src/ui/mainwindow/suprafitgui.h +++ b/src/ui/mainwindow/suprafitgui.h @@ -291,7 +291,8 @@ public slots: << "StoreFileName" << "StoreAbsolutePath" << "StoreFileHash" - << "FindFileRecursive"; + << "FindFileRecursive" + << "ModelParameterColums"; QDockWidget* m_message_dock; MessageDock* m_messages_widget; diff --git a/src/ui/widgets/parameterwidget.cpp b/src/ui/widgets/parameterwidget.cpp index 0865b7aa..9ffb5fab 100644 --- a/src/ui/widgets/parameterwidget.cpp +++ b/src/ui/widgets/parameterwidget.cpp @@ -36,7 +36,8 @@ LocalParameterWidget::LocalParameterWidget(QSharedPointer model) : m_model(model) { - QVBoxLayout* layout = new QVBoxLayout; + int columns = qApp->instance()->property("ModelParameterColums").toInt(); + QGridLayout* layout = new QGridLayout; for (int i = 0; i < m_model.data()->LocalParameterSize(); i++) { QWidget* widget = new QWidget; QHBoxLayout* hlayout = new QHBoxLayout; @@ -89,7 +90,7 @@ LocalParameterWidget::LocalParameterWidget(QSharedPointer model) m_parameter << box; hlayout->addWidget(check); check->setHidden(m_model.data()->isSimulation()); - layout->addWidget(widget); + layout->addWidget(widget, i / columns, i % columns); } setLayout(layout); diff --git a/src/ui/widgets/thermogramwidget.cpp b/src/ui/widgets/thermogramwidget.cpp index 70e707fc..f8e0d2be 100644 --- a/src/ui/widgets/thermogramwidget.cpp +++ b/src/ui/widgets/thermogramwidget.cpp @@ -120,6 +120,8 @@ void ThermogramWidget::setUi() m_table->setToolTip(tr("This table hold all peaks, consisting of the integral, start time and end time. Double click on a peak will toggle the Peak Integration mode. Double click of within the thermogram selects the appropriate peak in this table (if any peaks already exists")); m_peak_rule_list = new QTableWidget; + PeakRule* prototype = new PeakRule; + m_peak_rule_list->setItemPrototype(prototype); m_peak_rule_list->setRowCount(1); m_peak_rule_list->setColumnCount(2); m_peak_rule_list->setContextMenuPolicy(Qt::ActionsContextMenu); @@ -435,9 +437,9 @@ void ThermogramWidget::setUi() m_splitter->restoreState(settings.value("splitterSizes").toByteArray()); m_iterations->setValue(settings.value("iterations", 15).toInt()); // m_integration_range->setCurrentText(settings.value("integration_range", m_Peak_Cut_Options[0]).toString()); - QTableWidgetItem* item = new QTableWidgetItem(QString::number(m_peaks_start->value())); + PeakRule* item = new PeakRule(QString::number(m_peaks_start->value())); m_peak_rule_list->setItem(m_current_peaks_rule, 0, item); - item = new QTableWidgetItem(QString::number(m_peaks_time->value())); + item = new PeakRule(QString::number(m_peaks_time->value())); m_peak_rule_list->setItem(m_current_peaks_rule, 1, item); connect(m_integration_range, &QComboBox::currentTextChanged, this, &ThermogramWidget::CutAllLimits); @@ -508,6 +510,9 @@ void ThermogramWidget::setThermogram(PeakPick::spectrum* spec, qreal offset) void ThermogramWidget::setPeakList(const std::vector& peak_list) { + if (peak_list.size() == 0) + return; + const QSignalBlocker blocker_a(m_peaks_time); const QSignalBlocker blocker_b(m_peaks_start); @@ -515,7 +520,7 @@ void ThermogramWidget::setPeakList(const std::vector& peak_list) m_peak_list = peak_list; m_peak_rule_list->clear(); int row = 0; - for (int i = 0; i < m_peak_list.size(); ++i) { + for (std::size_t i = 0; i < m_peak_list.size(); ++i) { double time = m_peak_list[i].end * m_spec.Step() - m_peak_list[i].start * m_spec.Step() + m_spec.Step(); double start = m_peak_list[i].start * m_spec.Step() - m_spec.Step(); if (!qFuzzyCompare(time_pred, time)) { @@ -873,21 +878,22 @@ void ThermogramWidget::setFit(const QJsonObject& fit) QList points = ToolSet::String2Points(fit["rules_list"].toString()); m_peak_rule_list->setRowCount(points.size()); for (int i = 0; i < m_peak_rule_list->rowCount(); ++i) { - QTableWidgetItem* item = new QTableWidgetItem(QString::number(points[i].x())); + PeakRule* item = new PeakRule(QString::number(points[i].x())); m_peak_rule_list->setItem(i, 0, item); - item = new QTableWidgetItem(QString::number(points[i].y())); + item = new PeakRule(QString::number(points[i].y())); m_peak_rule_list->setItem(i, 1, item); } UpdatePeaks(); points = ToolSet::String2Points(fit["peak_int_ranges"].toString()); - for (int i = 0; i < m_peak_list.size(); ++i) { + for (std::size_t i = 0; i < m_peak_list.size(); ++i) { m_peak_list[i].int_start = points[i].x(); m_peak_list[i].int_end = points[i].y(); } FitBaseLine(); Update(); m_block = false; + setEnabled(true); } QJsonObject ThermogramWidget::Fit() const @@ -962,11 +968,11 @@ void ThermogramWidget::UpdatePeaks() m_peak_list.clear(); PeakPick::Peak peak; - for (int j = 0; j < rules_size; ++j) { - QTableWidgetItem* item = (m_peak_rule_list->item(j, 0)); + PeakRule* item = dynamic_cast(m_peak_rule_list->item(j, 0)); double index_start = m_spec.XtoIndex(item->data(Qt::DisplayRole).toDouble()); - item = m_peak_rule_list->item(j, 1); + item = dynamic_cast(m_peak_rule_list->item(j, 1)); + double timestep = item->data(Qt::DisplayRole).toDouble() / m_spec.Step(); if (timestep <= 0) { m_guide_label->setText(QString("Sorry, but Peak rule %1 contains a zero as peak time. That means, if I did not stop right here, you would be waiting for Godot").arg(j + 1)); diff --git a/src/ui/widgets/thermogramwidget.h b/src/ui/widgets/thermogramwidget.h index ab010a27..35ea3327 100644 --- a/src/ui/widgets/thermogramwidget.h +++ b/src/ui/widgets/thermogramwidget.h @@ -44,12 +44,14 @@ class ScatterSeries; class PeakRule : public QTableWidgetItem { public: + PeakRule() = default; + PeakRule(const QString& str) : QTableWidgetItem(str) { } - bool operator<(const QTableWidgetItem& other) const + bool operator<(const QTableWidgetItem& other) const override { return (this->text().toDouble() < other.text().toDouble()); }