Skip to content

Commit

Permalink
Added linear solver and update fitspectra widget layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Jul 9, 2024
1 parent f8ca7b3 commit 09112e6
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 20 deletions.
52 changes: 33 additions & 19 deletions src/mvc/FitSpectraWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,35 +232,48 @@ void FitSpectraWidget::createLayout()
SLOT(check_auto_model(int)));

QGridLayout *grid_layout = new QGridLayout();
grid_layout->addWidget(_cb_opttimizer, 0, 0);
grid_layout->addWidget(_btn_fit_spectra, 0, 1);
grid_layout->addWidget(_chk_auto_model, 0, 2);
grid_layout->addWidget(_btn_export_parameters, 0, 3);
grid_layout->addWidget(_btnSsettings, 1, 0);
grid_layout->addWidget(_btn_fit_roi_spectra, 1, 1);
grid_layout->addWidget(_btn_model_spectra, 1, 2);
grid_layout->addWidget(_btn_export_csv, 1, 3);
grid_layout->addItem(new QSpacerItem(9999, 10, QSizePolicy::Maximum), 0, 77);
//grid_layout->setSpacing(0);
//grid_layout->setContentsMargins(0, 0, 0, 0);

QVBoxLayout* vlayout_tab = new QVBoxLayout();
vlayout_tab->addWidget(_fit_params_tab_widget);
vlayout_tab->addItem(grid_layout);
vlayout_tab->setSpacing(0);
vlayout_tab->setContentsMargins(0, 0, 0, 0);
QWidget* tab_and_buttons_widget = new QWidget();
tab_and_buttons_widget->setLayout(vlayout_tab);

QSplitter* splitter = new QSplitter();
if(Preferences::inst()->getValue(STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION).toBool())
{
splitter->setOrientation(Qt::Horizontal);
grid_layout->addWidget(_btnSsettings, 0, 0);
grid_layout->addWidget(_cb_opttimizer, 0, 1);

grid_layout->addWidget(_btn_fit_spectra, 1, 0);
grid_layout->addWidget(_btn_fit_roi_spectra, 1, 1);

grid_layout->addWidget(_chk_auto_model, 2, 0);
grid_layout->addWidget(_btn_model_spectra, 2, 1);

grid_layout->addWidget(_btn_export_csv, 3, 0);
grid_layout->addWidget(_btn_export_parameters, 3, 1);
}
else
{
splitter->setOrientation(Qt::Vertical);

grid_layout->addWidget(_btnSsettings, 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);

grid_layout->addWidget(_btn_fit_spectra, 1, 0);
grid_layout->addWidget(_btn_fit_roi_spectra, 1, 1);
grid_layout->addWidget(_btn_model_spectra, 1, 2);
grid_layout->addWidget(_btn_export_parameters, 1, 3);

grid_layout->addItem(new QSpacerItem(9999, 10, QSizePolicy::Maximum), 0, 77);

}
QVBoxLayout* vlayout_tab = new QVBoxLayout();
vlayout_tab->addWidget(_fit_params_tab_widget);
vlayout_tab->addItem(grid_layout);
vlayout_tab->setSpacing(0);
vlayout_tab->setContentsMargins(0, 0, 0, 0);
QWidget* tab_and_buttons_widget = new QWidget();
tab_and_buttons_widget->setLayout(vlayout_tab);

splitter->addWidget(_spectra_dock);
splitter->setStretchFactor(0, 1);
splitter->addWidget(tab_and_buttons_widget);
Expand Down Expand Up @@ -1107,6 +1120,7 @@ void FitSpectraWidget::check_auto_model(int state)
if(state == Qt::Checked)
{
_btn_model_spectra->setEnabled(false);
Model_Spectra_Click();
connect(_fit_params_table_model,
SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
this,
Expand Down
3 changes: 2 additions & 1 deletion src/mvc/VLM_Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ void VLM_Widget::_createSolver()

if (id == ID_LINEAR)
{

LinearSolver* ls = new LinearSolver();
m_solver->setImpl(ls);
}
else if (id == ID_NELDER_MEAD)
{
Expand Down
1 change: 1 addition & 0 deletions src/mvc/VLM_Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <solver/SV_CoordTransformer.h>
#include <solver/LinearCoordTransformer.h>
#include <solver/PythonTransformer.h>
#include <solver/LinearSolver.h>


class Solver;
Expand Down
99 changes: 99 additions & 0 deletions src/solver/LinearSolver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*-----------------------------------------------------------------------------
* Copyright (c) 2024, UChicago Argonne, LLC
* See LICENSE file.
*---------------------------------------------------------------------------*/

#include <solver/LinearSolver.h>

//---------------------------------------------------------------------------

LinearSolver::LinearSolver() : AbstractSolver()
{

}

//---------------------------------------------------------------------------

LinearSolver::~LinearSolver()
{

}

//--------------------------------------------------------------------------

QMap<QString, double> LinearSolver::getAllCoef()
{
return _dict_min_coef;
}

//--------------------------------------------------------------------------

QString LinearSolver::getLastErrorMessage()
{
return "N/A";
}

//--------------------------------------------------------------------------

QMap<QString, double> LinearSolver::getMinCoef()
{
return _dict_min_coef;
}

//--------------------------------------------------------------------------

QMap<QString, double> LinearSolver::getOptions()
{
return _dict_options;
}

//--------------------------------------------------------------------------

gstar::ITransformer* LinearSolver::getTransformer()
{
return _transformer;
}

//--------------------------------------------------------------------------

void LinearSolver::setAllCoef(QMap<QString, double> vars)
{

}

//--------------------------------------------------------------------------

void LinearSolver::setCoordPoints(QList < QMap<QString,double> > vars)
{

}

//--------------------------------------------------------------------------

void LinearSolver::setMinCoef(QMap<QString, double> vars)
{

}

//--------------------------------------------------------------------------

void LinearSolver::setOptions(QMap<QString, double> vars)
{

}

//--------------------------------------------------------------------------

void LinearSolver::setTransformer(gstar::ITransformer* transformer)
{

}

//--------------------------------------------------------------------------

bool LinearSolver::run()
{

}

//--------------------------------------------------------------------------
117 changes: 117 additions & 0 deletions src/solver/LinearSolver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*-----------------------------------------------------------------------------
* Copyright (c) 2024, UChicago Argonne, LLC
* See LICENSE file.
*---------------------------------------------------------------------------*/

#ifndef LinearSolver_H
#define LinearSolver_H

#include <solver/AbstractSolver.h>
//---------------------------------------------------------------------------

/**
* @brief Transformation Interface
*
*/
class LinearSolver : public AbstractSolver
{

public:

/**
* Constructor.
*/
LinearSolver();

/**
* Destructor.
*/
virtual ~LinearSolver();

/**
* @brief getAllCoef
* @return
*/
virtual QMap<QString, double> getAllCoef();

/**
* @brief getLastErrorMessage
* @return
*/
QString getLastErrorMessage();

/**
* @brief getMinCoef
* @return
*/
virtual QMap<QString, double> getMinCoef();

/**
* @brief getOptions
* @return
*/
virtual QMap<QString, double> getOptions();

/**
* @brief getTransformer
* @return
*/
virtual gstar::ITransformer* getTransformer();

/**
* @brief setAllCoef
* @param vars
*/
virtual void setAllCoef(QMap<QString, double> vars);

/**
* @brief setCoordPoints
* @param vars
*/
virtual void setCoordPoints(QList < QMap<QString,double> > vars);

/**
* @brief setMinCoef
* @param vars
*/
virtual void setMinCoef(QMap<QString, double> vars);

/**
* @brief setOptions
* @param vars
*/
virtual void setOptions(QMap<QString, double> vars);

/**
* @brief setTransformer
* @param transformer
*/
virtual void setTransformer(gstar::ITransformer* transformer);

/**
* @brief run
* @return
*/
virtual bool run();

protected:

/**
* m_dict_min_coef.
*/
QMap<QString, double> _dict_min_coef;

/**
* m_dict_options.
*/
QMap<QString, double> _dict_options;

gstar::ITransformer *_transformer;

};

//---------------------------------------------------------------------------

#endif //LinearSolver_H

//---------------------------------------------------------------------------

0 comments on commit 09112e6

Please sign in to comment.