Skip to content

Commit

Permalink
Merge pull request #72 from aglowacki/master
Browse files Browse the repository at this point in the history
GUI updates
  • Loading branch information
aglowacki authored Dec 5, 2023
2 parents f6b1d50 + 794f515 commit 557b2c5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 11 deletions.
14 changes: 11 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,22 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
else
{
QString h_msg(msg);
switch (type)
int cnt = 0;
switch (type)
{
case QtDebugMsg:
//h_msg = "<span style=\"color : green; \">" + msg + "</span>\r";
cnt += h_msg.count("Info: ");
cnt += h_msg.count("Warning: ");
cnt += h_msg.count("Error: ");
h_msg.replace("Info: ", "<span style=\" font-weight: bold; \">Info: </span>");
h_msg.replace("\033[1;31mError: \033[0;m", "<span style=\"color : red; font-weight: bold; \">Error: </span>");
h_msg.replace("\033[1;33mWarning: \033[0;m", "<span style=\"color : yellow; font-weight: bold; \">Warning: </span>");
h_msg.replace("\n", "<br />");
if (cnt > 0)
{
h_msg.replace("\n", "<br>");
}
uProbeX::log_textedit->append(h_msg);
//uProbeX::log_textedit->ensureCursorVisible();
break;
case QtWarningMsg:
h_msg = "<span style=\"color : yellow; \">" + msg + "</span><br />";
Expand Down
28 changes: 28 additions & 0 deletions src/mvc/FitParamsTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "FitParamsTableModel.h"
#include "fitting/models/gaussian_model.h"
#include <QColor>

/*---------------------------------------------------------------------------*/

Expand Down Expand Up @@ -170,6 +171,33 @@ QVariant FitParamsTableModel::data(const QModelIndex &index, int role) const
return (int)data_struct::E_Bound_Type::FIT;
}
}
else if (role == Qt::BackgroundRole)
{
if (_optimizer_supports_min_max)
{
data_struct::Fit_Param<double> fitp = _fit_parameters.at(_row_indicies[row]);
if (index.column() == VALUE || index.column() == MIN_VAL)
{
if (fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO || fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO_HI)
{
if (fitp.value <= fitp.min_val)
{
return QColor(Qt::red);
}
}
}
if (index.column() == VALUE || index.column() == MAX_VAL)
{
if (fitp.bound_type == data_struct::E_Bound_Type::LIMITED_HI || fitp.bound_type == data_struct::E_Bound_Type::LIMITED_LO_HI)
{
if (fitp.value >= fitp.max_val)
{
return QColor(Qt::red);
}
}
}
}
}


// Return empty data
Expand Down
27 changes: 20 additions & 7 deletions src/mvc/OptimizerOptionsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const QString tip_step = "Used in determining the initial step bound. This bound
const QString tip_maxitr = "Used to set the maximum number of function evaluations to maxiter*(number_of_parameters+1).";
const QString tip_scale = "If 1, the variables will be rescaled internally. Recommended value is 1.";
const QString tip_covtol = "Range tolerance for covariance calculation Default: 1e-14";
const QString tip_verbose = "OR'ed: 1: print some messages; 2: print Jacobian.";


/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -81,17 +82,21 @@ void OptimizerOptionsWidget::_createLayout()

_opt_lm_scale_diag = new QSpinBox();
_opt_lm_scale_diag->setToolTip(tip_scale);
//_opt_lm_scale_diag->setDecimals(1);
_opt_lm_scale_diag->setRange(0, 1);
_opt_lm_scale_diag->setSingleStep(1.0);
QLabel* lbl_scale = new QLabel("Scale Diag: ");
lbl_scale->setToolTip(tip_scale);

_opt_mp_covtol = new QDoubleSpinBox();
_opt_lm_verbose = new QSpinBox();
_opt_lm_verbose->setToolTip(tip_scale);
_opt_lm_verbose->setRange(0, 3);
_opt_lm_verbose->setSingleStep(1.0);
QLabel* lbl_verbose = new QLabel("Verbose Level: ");
lbl_verbose->setToolTip(tip_verbose);

_opt_mp_covtol = new QLineEdit();
_opt_mp_covtol->setToolTip(tip_covtol);
_opt_mp_covtol->setDecimals(30);
_opt_mp_covtol->setRange(0.0, 1.0);
_opt_mp_covtol->setSingleStep(1.0e-15);

QLabel* lbl_covtol = new QLabel("CovTol: ");
lbl_covtol->setToolTip(tip_covtol);

Expand All @@ -117,6 +122,8 @@ void OptimizerOptionsWidget::_createLayout()
QHBoxLayout* hbox_lm = new QHBoxLayout();
hbox_lm->addWidget(lbl_scale);
hbox_lm->addWidget(_opt_lm_scale_diag);
hbox_lm->addWidget(lbl_verbose);
hbox_lm->addWidget(_opt_lm_verbose);
_lm_fit_ctrl_grp = new QGroupBox();
_lm_fit_ctrl_grp->setLayout(hbox_lm);
optimizerLayout->addWidget(_lm_fit_ctrl_grp, 0, 7, Qt::AlignLeft);
Expand Down Expand Up @@ -207,8 +214,13 @@ void OptimizerOptionsWidget::updateGUIOptimizerOptions(fitting::optimizers::Opt
}
if (opt.count(STR_OPT_COVTOL) > 0)
{
_opt_mp_covtol->setValue(opt.at(STR_OPT_COVTOL));
_opt_mp_covtol->setText(QString::number(opt.at(STR_OPT_COVTOL), 'e', 0));
}
if (opt.count(STR_OPT_VERBOSE_LEVEL) > 0)
{
_opt_lm_verbose->setValue(opt.at(STR_OPT_VERBOSE_LEVEL));
}

}

/*---------------------------------------------------------------------------*/
Expand All @@ -223,7 +235,8 @@ void OptimizerOptionsWidget::updateOptimizerOptions(fitting::optimizers::Optimi
opt[STR_OPT_STEP] = _opt_stepbound->value();
opt[STR_OPT_MAXITER] = _opt_maxiter->value();
opt[STR_OPT_SCALE_DIAG] = _opt_lm_scale_diag->value();
opt[STR_OPT_COVTOL] = _opt_mp_covtol->value();
opt[STR_OPT_COVTOL] = _opt_mp_covtol->text().toDouble();
opt[STR_OPT_VERBOSE_LEVEL] = _opt_lm_verbose->value();
optimizer.set_options(opt);
}

Expand Down
4 changes: 3 additions & 1 deletion src/mvc/OptimizerOptionsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ class OptimizerOptionsWidget : public QWidget

QSpinBox* _opt_lm_scale_diag;

QDoubleSpinBox* _opt_mp_covtol;
QSpinBox* _opt_lm_verbose;

QLineEdit* _opt_mp_covtol;

};

Expand Down

0 comments on commit 557b2c5

Please sign in to comment.