diff --git a/GUI/Model/Job/MinimizerItem.cpp b/GUI/Model/Job/MinimizerItem.cpp index 7cfcbb4d1e0ee3573a168f20bf1f009049792457..e847d1127d5a6203730e8b3dc2fecc44e8d2b16d 100644 --- a/GUI/Model/Job/MinimizerItem.cpp +++ b/GUI/Model/Job/MinimizerItem.cpp @@ -51,40 +51,40 @@ MinimizerContainerItem::MinimizerContainerItem() addProperty<SimAnMinimizerItem>(SimAnMinimizerItem::M_TYPE); addProperty<GSLLMAMinimizerItem>(GSLLMAMinimizerItem::M_TYPE); - ComboProperty minimizer_combo = ComboProperty::fromList( - minimizer_names_map.keys(), default_minimizer); + ComboProperty minimizer_combo = + ComboProperty::fromList(minimizer_names_map.keys(), default_minimizer); addProperty(P_MINIMIZERS, minimizer_combo.variant()); ComboProperty metric_combo = ComboProperty::fromStdVec( - ObjectiveMetricUtils::metricNames(), ObjectiveMetricUtils::defaultMetricName()); + ObjectiveMetricUtils::metricNames(), ObjectiveMetricUtils::defaultMetricName()); addProperty(P_METRIC, metric_combo.variant()); - ComboProperty norm_combo = ComboProperty::fromStdVec( - ObjectiveMetricUtils::normNames(), ObjectiveMetricUtils::defaultNormName()); + ComboProperty norm_combo = ComboProperty::fromStdVec(ObjectiveMetricUtils::normNames(), + ObjectiveMetricUtils::defaultNormName()); addProperty(P_NORM, norm_combo.variant()); } -MinuitMinimizerItem *MinimizerContainerItem::minimizerItemMinuit() const +MinuitMinimizerItem* MinimizerContainerItem::minimizerItemMinuit() const { return item<MinuitMinimizerItem>(MinuitMinimizerItem::M_TYPE); } -GSLMultiMinimizerItem *MinimizerContainerItem::minimizerItemGSLMulti() const +GSLMultiMinimizerItem* MinimizerContainerItem::minimizerItemGSLMulti() const { return item<GSLMultiMinimizerItem>(GSLMultiMinimizerItem::M_TYPE); } -GeneticMinimizerItem *MinimizerContainerItem::minimizerItemGenetic() const +GeneticMinimizerItem* MinimizerContainerItem::minimizerItemGenetic() const { return item<GeneticMinimizerItem>(GeneticMinimizerItem::M_TYPE); } -SimAnMinimizerItem *MinimizerContainerItem::minimizerItemSimAn() const +SimAnMinimizerItem* MinimizerContainerItem::minimizerItemSimAn() const { return item<SimAnMinimizerItem>(SimAnMinimizerItem::M_TYPE); } -GSLLMAMinimizerItem *MinimizerContainerItem::minimizerItemGSLLMA() const +GSLLMAMinimizerItem* MinimizerContainerItem::minimizerItemGSLLMA() const { return item<GSLLMAMinimizerItem>(GSLLMAMinimizerItem::M_TYPE); } @@ -122,7 +122,7 @@ QString MinimizerContainerItem::currentObjectiveMetric() const return objectiveMetricCombo().currentValue(); } -void MinimizerContainerItem::setCurrentObjectiveMetric(const QString &name) +void MinimizerContainerItem::setCurrentObjectiveMetric(const QString& name) { ComboProperty combo = objectiveMetricCombo(); combo.setCurrentValue(name); @@ -139,7 +139,7 @@ QString MinimizerContainerItem::currentNormFunction() const return normFunctionCombo().currentValue(); } -void MinimizerContainerItem::setCurrentNormFunction(const QString &name) +void MinimizerContainerItem::setCurrentNormFunction(const QString& name) { ComboProperty combo = normFunctionCombo(); combo.setCurrentValue(name); @@ -186,7 +186,7 @@ QString MinuitMinimizerItem::currentAlgorithm() const return algorithmCombo().currentValue(); } -void MinuitMinimizerItem::setCurrentAlgorithm(const QString &name) +void MinuitMinimizerItem::setCurrentAlgorithm(const QString& name) { ComboProperty combo = algorithmCombo(); combo.setCurrentValue(name); @@ -276,7 +276,7 @@ QString GSLMultiMinimizerItem::currentAlgorithm() const return algorithmCombo().currentValue(); } -void GSLMultiMinimizerItem::setCurrentAlgorithm(const QString &name) +void GSLMultiMinimizerItem::setCurrentAlgorithm(const QString& name) { ComboProperty combo = algorithmCombo(); combo.setCurrentValue(name); diff --git a/GUI/Util/ComboProperty.cpp b/GUI/Util/ComboProperty.cpp index 6c9dd6d411a80caebe719b1115b6b4daff90263b..c1860d8ea0faf20f8f9ef722c6fea6948feef545 100644 --- a/GUI/Util/ComboProperty.cpp +++ b/GUI/Util/ComboProperty.cpp @@ -40,11 +40,12 @@ ComboProperty ComboProperty::fromList(const QStringList& values, const QString& return result; } -ComboProperty ComboProperty::fromStdVec(const std::vector<std::string>& values, const std::string& current_value) +ComboProperty ComboProperty::fromStdVec(const std::vector<std::string>& values, + const std::string& current_value) { QStringList q_list; - for(std::string val : values) + for (std::string val : values) q_list << QString::fromStdString(val); QString q_value = QString::fromStdString(current_value); diff --git a/GUI/Util/ComboProperty.h b/GUI/Util/ComboProperty.h index 699005eef2c2df4a5e92aef628e70bd8637535db..29e9b982afd4217f2286ea47dcadb809d8ae95e2 100644 --- a/GUI/Util/ComboProperty.h +++ b/GUI/Util/ComboProperty.h @@ -27,7 +27,8 @@ public: ComboProperty(); static ComboProperty fromList(const QStringList& values, const QString& current_value = ""); - static ComboProperty fromStdVec(const std::vector<std::string>& values, const std::string& current_value = ""); + static ComboProperty fromStdVec(const std::vector<std::string>& values, + const std::string& current_value = ""); QString currentValue() const; void setCurrentValue(const QString& name); @@ -67,7 +68,7 @@ private: ComboProperty(QStringList values); QStringList m_values; - QStringList m_tooltips; // without saving + QStringList m_tooltips; // without saving QVector<int> m_selected_indices; }; diff --git a/GUI/View/Fit/MinimizerSettingsWidget.cpp b/GUI/View/Fit/MinimizerSettingsWidget.cpp index efdb426edbd8a0b4484b25001667746d1534910b..d3189ff3eeebbba11cabd05d704fe55df5da93c9 100644 --- a/GUI/View/Fit/MinimizerSettingsWidget.cpp +++ b/GUI/View/Fit/MinimizerSettingsWidget.cpp @@ -55,26 +55,33 @@ void MinimizerSettingsWidget::setMinItem(MinimizerContainerItem* minimizerItem) if (!m_currentItem) return; - m_mainLayout->addRow("Minimizer:", GUI::Util::createComboBox( - [=] { return m_currentItem->minimizerCombo(); }, - [=](const QString& t) { - m_currentItem->setCurrentMinimizer(t); - createMimimizerEdits(); - }, &m_updaters)); + m_mainLayout->addRow("Minimizer:", + GUI::Util::createComboBox([=] { return m_currentItem->minimizerCombo(); }, + [=](const QString& t) { + m_currentItem->setCurrentMinimizer(t); + createMimimizerEdits(); + }, + &m_updaters)); auto* w = new QWidget(this); m_minimizerLayout = new QFormLayout(w); m_minimizerLayout->setContentsMargins(10, 8, 0, 8); m_mainLayout->addRow(w); - m_mainLayout->addRow("Objective metric:", GUI::Util::createComboBox( + m_mainLayout->addRow("Objective metric:", + GUI::Util::createComboBox( [=] { return m_currentItem->objectiveMetricCombo(); }, [=](const QString& t) { m_currentItem->setCurrentObjectiveMetric(t); }, - &m_updaters, "Objective metric to use for estimating distance between simulated and experimental data")); - m_mainLayout->addRow("Norm function:", GUI::Util::createComboBox( + &m_updaters, + "Objective metric to use for estimating distance between simulated " + "and experimental data")); + m_mainLayout->addRow("Norm function:", + GUI::Util::createComboBox( [=] { return m_currentItem->normFunctionCombo(); }, [=](const QString& t) { m_currentItem->setCurrentNormFunction(t); }, - &m_updaters, "Normalization to use for estimating distance between simulated and experimental data")); + &m_updaters, + "Normalization to use for estimating distance between simulated and " + "experimental data")); createMimimizerEdits(); updateUIValues(); @@ -84,174 +91,179 @@ void MinimizerSettingsWidget::createMimimizerEdits() GUI::Util::Layout::clearLayout(m_minimizerLayout); // Minuit2 - if(m_currentItem->currentMinimizerM_TYPE() == MinuitMinimizerItem::M_TYPE) + if (m_currentItem->currentMinimizerM_TYPE() == MinuitMinimizerItem::M_TYPE) createMinuitEdits(); else - // GSL MultiMin - if(m_currentItem->currentMinimizerM_TYPE() == GSLMultiMinimizerItem::M_TYPE) - createGSLMultiMinEdits(); - else - // TMVA Genetic - if(m_currentItem->currentMinimizerM_TYPE() == GeneticMinimizerItem::M_TYPE) - createTMVAGeneticEdits(); - else - // GSL Simulated Annealing - if(m_currentItem->currentMinimizerM_TYPE() == SimAnMinimizerItem::M_TYPE) - createGSLSimulatedAnnealingEdits(); - else - // GSL Levenberg-Marquardt - if(m_currentItem->currentMinimizerM_TYPE() == GSLLMAMinimizerItem::M_TYPE) - createGSLLevMarEdits(); - else - ASSERT(0); + // GSL MultiMin + if (m_currentItem->currentMinimizerM_TYPE() == GSLMultiMinimizerItem::M_TYPE) + createGSLMultiMinEdits(); + else + // TMVA Genetic + if (m_currentItem->currentMinimizerM_TYPE() == GeneticMinimizerItem::M_TYPE) + createTMVAGeneticEdits(); + else + // GSL Simulated Annealing + if (m_currentItem->currentMinimizerM_TYPE() == SimAnMinimizerItem::M_TYPE) + createGSLSimulatedAnnealingEdits(); + else + // GSL Levenberg-Marquardt + if (m_currentItem->currentMinimizerM_TYPE() == GSLLMAMinimizerItem::M_TYPE) + createGSLLevMarEdits(); + else + ASSERT(0); } void MinimizerSettingsWidget::createMinuitEdits() { MinuitMinimizerItem* minItem = m_currentItem->minimizerItemMinuit(); - m_minimizerLayout->addRow("Algorithm:", GUI::Util::createComboBox( - [=] { return minItem->algorithmCombo(); }, - [=](const QString& t) { minItem->setCurrentAlgorithm(t); }, - &m_updaters)); - - m_minimizerLayout->addRow("Strategy:", GUI::Util::createIntSpinbox( - [=] { return minItem->strategy(); }, - [=](int v) { minItem->setStrategy(v); }, - &m_updaters, "Minimization strategy (0-low, 1-medium, 2-high quality)", - RealLimits::limited(0, 2))); - - m_minimizerLayout->addRow("ErrorDef factor:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->errorDefinition(); }, - [=](double v) { minItem->setErrorDefinition(v); }, - &m_updaters, "Error definition factor for parameter error calculation", - RealLimits::positive())); - - m_minimizerLayout->addRow("Tolerance:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->tolerance(); }, - [=](double v) { minItem->setTolerance(v); }, - &m_updaters, "Tolerance on the function value at the minimum", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("Precision:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->precision(); }, - [=](double v) { minItem->setPrecision(v); }, - &m_updaters, "Relative floating point arithmetic precision", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("Max func calls:", GUI::Util::createIntSpinbox( - [=] { return minItem->maxFuncCalls(); }, - [=](int v) { minItem->setMaxFuncCalls(v); }, - &m_updaters, "Maximum number of function calls", - RealLimits::nonnegative())); + m_minimizerLayout->addRow( + "Algorithm:", GUI::Util::createComboBox( + [=] { return minItem->algorithmCombo(); }, + [=](const QString& t) { minItem->setCurrentAlgorithm(t); }, &m_updaters)); + + m_minimizerLayout->addRow( + "Strategy:", + GUI::Util::createIntSpinbox([=] { return minItem->strategy(); }, + [=](int v) { minItem->setStrategy(v); }, &m_updaters, + "Minimization strategy (0-low, 1-medium, 2-high quality)", + RealLimits::limited(0, 2))); + + m_minimizerLayout->addRow("ErrorDef factor:", + GUI::Util::createDoubleSpinbox( + [=] { return minItem->errorDefinition(); }, + [=](double v) { minItem->setErrorDefinition(v); }, &m_updaters, + "Error definition factor for parameter error calculation", + RealLimits::positive())); + + m_minimizerLayout->addRow( + "Tolerance:", + GUI::Util::createDoubleSpinbox([=] { return minItem->tolerance(); }, + [=](double v) { minItem->setTolerance(v); }, &m_updaters, + "Tolerance on the function value at the minimum", + RealLimits::nonnegative())); + + m_minimizerLayout->addRow( + "Precision:", + GUI::Util::createDoubleSpinbox([=] { return minItem->precision(); }, + [=](double v) { minItem->setPrecision(v); }, &m_updaters, + "Relative floating point arithmetic precision", + RealLimits::nonnegative())); + + m_minimizerLayout->addRow( + "Max func calls:", + GUI::Util::createIntSpinbox([=] { return minItem->maxFuncCalls(); }, + [=](int v) { minItem->setMaxFuncCalls(v); }, &m_updaters, + "Maximum number of function calls", RealLimits::nonnegative())); } void MinimizerSettingsWidget::createGSLMultiMinEdits() { GSLMultiMinimizerItem* minItem = m_currentItem->minimizerItemGSLMulti(); - m_minimizerLayout->addRow("Algorithm:", GUI::Util::createComboBox( - [=] { return minItem->algorithmCombo(); }, - [=](const QString& t) { minItem->setCurrentAlgorithm(t); }, - &m_updaters)); + m_minimizerLayout->addRow( + "Algorithm:", GUI::Util::createComboBox( + [=] { return minItem->algorithmCombo(); }, + [=](const QString& t) { minItem->setCurrentAlgorithm(t); }, &m_updaters)); - m_minimizerLayout->addRow("Max iterations:", GUI::Util::createIntSpinbox( - [=] { return minItem->maxIterations(); }, - [=](int v) { minItem->setMaxIterations(v); }, - &m_updaters, "Maximum number of iterations", - RealLimits::nonnegative())); + m_minimizerLayout->addRow( + "Max iterations:", + GUI::Util::createIntSpinbox([=] { return minItem->maxIterations(); }, + [=](int v) { minItem->setMaxIterations(v); }, &m_updaters, + "Maximum number of iterations", RealLimits::nonnegative())); } void MinimizerSettingsWidget::createTMVAGeneticEdits() { GeneticMinimizerItem* minItem = m_currentItem->minimizerItemGenetic(); - m_minimizerLayout->addRow("Tolerance:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->tolerance(); }, - [=](double v) { minItem->setTolerance(v); }, - &m_updaters, "Tolerance on the function value at the minimum", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("Max iterations:", GUI::Util::createIntSpinbox( - [=] { return minItem->maxIterations(); }, - [=](int v) { minItem->setMaxIterations(v); }, - &m_updaters, "Maximum number of iterations", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("Population:", GUI::Util::createIntSpinbox( - [=] { return minItem->populationSize(); }, - [=](int v) { minItem->setPopulationSize(v); }, - &m_updaters, "Population size", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("Random seed:", GUI::Util::createIntSpinbox( - [=] { return minItem->randomSeed(); }, - [=](int v) { minItem->setRandomSeed(v); }, - &m_updaters)); + m_minimizerLayout->addRow( + "Tolerance:", + GUI::Util::createDoubleSpinbox([=] { return minItem->tolerance(); }, + [=](double v) { minItem->setTolerance(v); }, &m_updaters, + "Tolerance on the function value at the minimum", + RealLimits::nonnegative())); + + m_minimizerLayout->addRow( + "Max iterations:", + GUI::Util::createIntSpinbox([=] { return minItem->maxIterations(); }, + [=](int v) { minItem->setMaxIterations(v); }, &m_updaters, + "Maximum number of iterations", RealLimits::nonnegative())); + + m_minimizerLayout->addRow( + "Population:", + GUI::Util::createIntSpinbox([=] { return minItem->populationSize(); }, + [=](int v) { minItem->setPopulationSize(v); }, &m_updaters, + "Population size", RealLimits::nonnegative())); + + m_minimizerLayout->addRow("Random seed:", + GUI::Util::createIntSpinbox([=] { return minItem->randomSeed(); }, + [=](int v) { minItem->setRandomSeed(v); }, + &m_updaters)); } void MinimizerSettingsWidget::createGSLSimulatedAnnealingEdits() { SimAnMinimizerItem* minItem = m_currentItem->minimizerItemSimAn(); - m_minimizerLayout->addRow("Max iterations:", GUI::Util::createIntSpinbox( - [=] { return minItem->maxIterations(); }, - [=](int v) { minItem->setMaxIterations(v); }, - &m_updaters, "Number of points to try for each step", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("Iterations at T:", GUI::Util::createIntSpinbox( - [=] { return minItem->iterationsAtEachTemp(); }, - [=](int v) { minItem->setIterationsAtEachTemp(v); }, - &m_updaters, "Number of iterations at each temperature", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("Step size:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->stepSize(); }, - [=](double v) { minItem->setStepSize(v); }, - &m_updaters, "Max step size used in random walk", - RealLimits::nonnegative())); + m_minimizerLayout->addRow( + "Max iterations:", + GUI::Util::createIntSpinbox( + [=] { return minItem->maxIterations(); }, [=](int v) { minItem->setMaxIterations(v); }, + &m_updaters, "Number of points to try for each step", RealLimits::nonnegative())); + + m_minimizerLayout->addRow( + "Iterations at T:", + GUI::Util::createIntSpinbox([=] { return minItem->iterationsAtEachTemp(); }, + [=](int v) { minItem->setIterationsAtEachTemp(v); }, + &m_updaters, "Number of iterations at each temperature", + RealLimits::nonnegative())); + + m_minimizerLayout->addRow("Step size:", + GUI::Util::createDoubleSpinbox( + [=] { return minItem->stepSize(); }, + [=](double v) { minItem->setStepSize(v); }, &m_updaters, + "Max step size used in random walk", RealLimits::nonnegative())); m_minimizerLayout->addRow("k:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->boltzmanK(); }, - [=](double v) { minItem->setBoltzmanK(v); }, - &m_updaters, "Boltzmann k", - RealLimits::nonnegative())); + [=] { return minItem->boltzmanK(); }, + [=](double v) { minItem->setBoltzmanK(v); }, &m_updaters, + "Boltzmann k", RealLimits::nonnegative())); - m_minimizerLayout->addRow("T init:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->boltzmanInitT(); }, - [=](double v) { minItem->setBoltzmanInitT(v); }, - &m_updaters, "Boltzmann initial temperature", - RealLimits::nonnegative())); + m_minimizerLayout->addRow( + "T init:", + GUI::Util::createDoubleSpinbox([=] { return minItem->boltzmanInitT(); }, + [=](double v) { minItem->setBoltzmanInitT(v); }, &m_updaters, + "Boltzmann initial temperature", RealLimits::nonnegative())); m_minimizerLayout->addRow("mu:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->boltzmanMu(); }, - [=](double v) { minItem->setBoltzmanMu(v); }, - &m_updaters, "Boltzmann mu", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("T min:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->boltzmanMinT(); }, - [=](double v) { minItem->setBoltzmanMinT(v); }, - &m_updaters, "Boltzmann minimal temperature", - RealLimits::nonnegative())); + [=] { return minItem->boltzmanMu(); }, + [=](double v) { minItem->setBoltzmanMu(v); }, &m_updaters, + "Boltzmann mu", RealLimits::nonnegative())); + + m_minimizerLayout->addRow( + "T min:", + GUI::Util::createDoubleSpinbox([=] { return minItem->boltzmanMinT(); }, + [=](double v) { minItem->setBoltzmanMinT(v); }, &m_updaters, + "Boltzmann minimal temperature", RealLimits::nonnegative())); } void MinimizerSettingsWidget::createGSLLevMarEdits() { GSLLMAMinimizerItem* minItem = m_currentItem->minimizerItemGSLLMA(); - m_minimizerLayout->addRow("Tolerance:", GUI::Util::createDoubleSpinbox( - [=] { return minItem->tolerance(); }, - [=](double v) { minItem->setTolerance(v); }, - &m_updaters, "Tolerance on the function value at the minimum", - RealLimits::nonnegative())); - - m_minimizerLayout->addRow("Max iterations:", GUI::Util::createIntSpinbox( - [=] { return minItem->maxIterations(); }, - [=](int v) { minItem->setMaxIterations(v); }, - &m_updaters, "Maximum number of iterations", - RealLimits::nonnegative())); + m_minimizerLayout->addRow( + "Tolerance:", + GUI::Util::createDoubleSpinbox([=] { return minItem->tolerance(); }, + [=](double v) { minItem->setTolerance(v); }, &m_updaters, + "Tolerance on the function value at the minimum", + RealLimits::nonnegative())); + + m_minimizerLayout->addRow( + "Max iterations:", + GUI::Util::createIntSpinbox([=] { return minItem->maxIterations(); }, + [=](int v) { minItem->setMaxIterations(v); }, &m_updaters, + "Maximum number of iterations", RealLimits::nonnegative())); } void MinimizerSettingsWidget::updateUIValues() diff --git a/GUI/View/Job/JobView.cpp b/GUI/View/Job/JobView.cpp index 33792bedab4d20d98a5d60c61f71c24909a4eecc..d2a2e5a5ab5ac970e941267b4f178bbe1699ced8 100644 --- a/GUI/View/Job/JobView.cpp +++ b/GUI/View/Job/JobView.cpp @@ -172,7 +172,7 @@ void JobView::setAppropriateActivityForJob(JobItem* jobItem) if (jobItem->isValidForFitting()) { // fitting presentation -// m_jobResultsPresenter->setPresentation(JobViewActivity::Fitting); + // m_jobResultsPresenter->setPresentation(JobViewActivity::Fitting); // ALTERNATIVE: // fitting activity setActivity(JobViewActivity::Fitting); diff --git a/GUI/View/Plot2D/IntensityDataPropertyWidget.cpp b/GUI/View/Plot2D/IntensityDataPropertyWidget.cpp index ff92ef91590c5be2e5d9c199cfa71050980e7216..4fb6587c13045e596b7256aeae3c717cf07a143d 100644 --- a/GUI/View/Plot2D/IntensityDataPropertyWidget.cpp +++ b/GUI/View/Plot2D/IntensityDataPropertyWidget.cpp @@ -51,23 +51,23 @@ void IntensityDataPropertyWidget::createPanelElements() GUI::Util::Layout::clearLayout(m_mainLayout); m_updaters.clear(); - m_mainLayout->addRow("Axes units:", - GUI::Util::createComboBox( - [=] { return currentIntensityDataItem()->axesUnitsCombo(); }, - [=](const QString& newVal) { - for (auto item : allIntensityDataItems()) - item->setCurrentAxesUnits(newVal); - }, - &m_updaters)); - - m_mainLayout->addRow("Color scheme:", - GUI::Util::createComboBox( - [=] { return currentIntensityDataItem()->gradientCombo(); }, - [=](const QString& newVal) { - for (auto item : allIntensityDataItems()) - item->setCurrentGradient(newVal); - }, - &m_updaters)); + m_mainLayout->addRow( + "Axes units:", + GUI::Util::createComboBox([=] { return currentIntensityDataItem()->axesUnitsCombo(); }, + [=](const QString& newVal) { + for (auto item : allIntensityDataItems()) + item->setCurrentAxesUnits(newVal); + }, + &m_updaters)); + + m_mainLayout->addRow( + "Color scheme:", + GUI::Util::createComboBox([=] { return currentIntensityDataItem()->gradientCombo(); }, + [=](const QString& newVal) { + for (auto item : allIntensityDataItems()) + item->setCurrentGradient(newVal); + }, + &m_updaters)); m_mainLayout->addRow(GUI::Util::createCheckBox( "Interpolate", [=] { return currentIntensityDataItem()->isInterpolated(); }, diff --git a/GUI/View/PlotSpecular/SpecularDataPropertyWidget.cpp b/GUI/View/PlotSpecular/SpecularDataPropertyWidget.cpp index 6334bf1d7c8cd71e1df37f46bdd32f18538512ef..e3fb926af330871149ae55abe016d9b50b584382 100644 --- a/GUI/View/PlotSpecular/SpecularDataPropertyWidget.cpp +++ b/GUI/View/PlotSpecular/SpecularDataPropertyWidget.cpp @@ -43,14 +43,14 @@ void SpecularDataPropertyWidget::createPanelElements() GUI::Util::Layout::clearLayout(m_mainLayout); m_updaters.clear(); - m_mainLayout->addRow("Axes units:", - GUI::Util::createComboBox( - [=] { return currentSpecularDataItem()->axesUnitsCombo(); }, - [=](const QString& newVal) { - for (auto item : allSpecularDataItems()) - item->setCurrentAxesUnits(newVal); - }, - &m_updaters)); + m_mainLayout->addRow( + "Axes units:", + GUI::Util::createComboBox([=] { return currentSpecularDataItem()->axesUnitsCombo(); }, + [=](const QString& newVal) { + for (auto item : allSpecularDataItems()) + item->setCurrentAxesUnits(newVal); + }, + &m_updaters)); // -- x-axis auto* xGroup = new QGroupBox("X axis", this); diff --git a/GUI/View/Tool/WidgetUtils.cpp b/GUI/View/Tool/WidgetUtils.cpp index 9ef90e3459c7f02794ebdfe7c87cf71938773b10..0a965917ebd000c39c614d8e394f919c8896a107 100644 --- a/GUI/View/Tool/WidgetUtils.cpp +++ b/GUI/View/Tool/WidgetUtils.cpp @@ -29,8 +29,8 @@ using std::variant; QComboBox* GUI::Util::createComboBox(function<ComboProperty()> comboFunction, function<void(const QString&)> slot, - QList<function<void()>>* updaters, - QString tooltip, bool isScrollable) + QList<function<void()>>* updaters, QString tooltip, + bool isScrollable) { QComboBox* combo = new QComboBox; combo->addItems(comboFunction().values()); @@ -174,25 +174,23 @@ QLineEdit* GUI::Util::createTextEdit(function<QString()> getter, function<void(Q return edit; } -QSpinBox *GUI::Util::createIntSpinbox(std::function<int ()> getter, - std::function<void (int)> slot, - QList<std::function<void ()> > *updaters, - QString tooltip, - const RealLimits &limits, - bool easyScrollable) +QSpinBox* GUI::Util::createIntSpinbox(std::function<int()> getter, std::function<void(int)> slot, + QList<std::function<void()>>* updaters, QString tooltip, + const RealLimits& limits, bool easyScrollable) { QSpinBox* spin = new QSpinBox; spin->setFocusPolicy(Qt::StrongFocus); - spin->setMinimum(limits.hasLowerLimit() ? limits.lowerLimit() : -std::numeric_limits<int>::max()); - spin->setMaximum(limits.hasUpperLimit() ? limits.upperLimit() : std::numeric_limits<int>::max()); + spin->setMinimum(limits.hasLowerLimit() ? limits.lowerLimit() + : -std::numeric_limits<int>::max()); + spin->setMaximum(limits.hasUpperLimit() ? limits.upperLimit() + : std::numeric_limits<int>::max()); spin->setValue(getter()); spin->setToolTip(tooltip); if (!easyScrollable) WheelEventEater::install(spin); - QObject::connect(spin, qOverload<int>(&QSpinBox::valueChanged), - [=] { slot(spin->value()); }); + QObject::connect(spin, qOverload<int>(&QSpinBox::valueChanged), [=] { slot(spin->value()); }); if (updaters) (*updaters) << [=]() { @@ -205,15 +203,15 @@ QSpinBox *GUI::Util::createIntSpinbox(std::function<int ()> getter, QDoubleSpinBox* GUI::Util::createDoubleSpinbox(function<double()> getter, function<void(double)> slot, - QList<function<void()>>* updaters, - QString tooltip, - const RealLimits &limits, - bool easyScrollable) + QList<function<void()>>* updaters, QString tooltip, + const RealLimits& limits, bool easyScrollable) { QDoubleSpinBox* spin = new QDoubleSpinBox; spin->setFocusPolicy(Qt::StrongFocus); - spin->setMinimum(limits.hasLowerLimit() ? limits.lowerLimit() : -std::numeric_limits<int>::max()); - spin->setMaximum(limits.hasUpperLimit() ? limits.upperLimit() : std::numeric_limits<int>::max()); + spin->setMinimum(limits.hasLowerLimit() ? limits.lowerLimit() + : -std::numeric_limits<int>::max()); + spin->setMaximum(limits.hasUpperLimit() ? limits.upperLimit() + : std::numeric_limits<int>::max()); spin->setDecimals(3); spin->setSingleStep(0.01); spin->setValue(getter()); diff --git a/GUI/View/Tool/WidgetUtils.h b/GUI/View/Tool/WidgetUtils.h index da0679290583a7ed90531f786862ca6dfe7633c4..89885510329efcd1834e7ec6f1d92eeea1252197 100644 --- a/GUI/View/Tool/WidgetUtils.h +++ b/GUI/View/Tool/WidgetUtils.h @@ -45,8 +45,8 @@ namespace GUI::Util { //! QComboBox* createComboBox(std::function<ComboProperty()> comboFunction, std::function<void(const QString&)> slot, - QList<std::function<void()>>* updaters = nullptr, - QString tooltip = "", bool isScrollable = true); + QList<std::function<void()>>* updaters = nullptr, QString tooltip = "", + bool isScrollable = true); //! Create a combo box with the information found in a selection descriptor. //! @@ -160,18 +160,14 @@ QLineEdit* createTextEdit(std::function<QString()> getter, std::function<void(QS QList<std::function<void()>>* updaters); //! Creates a scrollable updatable spinBox -QSpinBox *createIntSpinbox(std::function<int ()> getter, - std::function<void (int)> slot, - QList<std::function<void()>>* updaters, - QString tooltip = "", - const RealLimits& limits = RealLimits(), - bool easyScrollable = true); +QSpinBox* createIntSpinbox(std::function<int()> getter, std::function<void(int)> slot, + QList<std::function<void()>>* updaters, QString tooltip = "", + const RealLimits& limits = RealLimits(), bool easyScrollable = true); //! Creates a scrollable updatable doublespinBox QDoubleSpinBox* createDoubleSpinbox(std::function<double()> getter, std::function<void(double)> slot, - QList<std::function<void()>>* updaters, - QString tooltip = "", + QList<std::function<void()>>* updaters, QString tooltip = "", const RealLimits& limits = RealLimits(), bool easyScrollable = true); } // namespace GUI::Util