Skip to content

Commit

Permalink
Save roi fit params along with maps_fit_param_override.txt file for t…
Browse files Browse the repository at this point in the history
…he roi
  • Loading branch information
Arthur Glowacki committed Jun 28, 2024
1 parent d2bd465 commit 98ab325
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 33 deletions.
14 changes: 9 additions & 5 deletions src/gstar/ImageViewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,16 @@ void ImageViewWidget::createLayout()
_image_view_grid_layout->addItem(_sub_windows[idx].layout, i, j);
}
}

_main_layout->addItem(_image_view_grid_layout);
_main_layout->addWidget(m_coordWidget);

// Set widget's layout
setLayout(_main_layout);
_main_layout->addItem(_image_view_grid_layout);
_main_layout->addWidget(m_coordWidget);


_main_layout->setSpacing(0);
_main_layout->setContentsMargins(0, 0, 0, 0);

// Set widget's layout
setLayout(_main_layout);

}

Expand Down
3 changes: 3 additions & 0 deletions src/mvc/AnnimateSlideWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ void AnnimateSlideWidget::setAnimWidget(QWidget* w, QString btn_name)
if(_btn_hover == nullptr)
{
_btn_hover = new QPushButton(btn_name);
_btn_hover->setVisible(false);
}
_anim_widget = w;
}

QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget(_btn_hover);
layout->addWidget(_anim_widget);
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);

setLayout(layout);
}
Expand Down
2 changes: 2 additions & 0 deletions src/mvc/FileTabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ FileTabWidget::FileTabWidget(QWidget* parent) : QWidget(parent)
vlayout->addItem(hlayout2);
vlayout->addItem(_custom_btn_box);
vlayout->addWidget(_file_list_view);
vlayout->setSpacing(0);
vlayout->setContentsMargins(0, 0, 0, 0);
setLayout(vlayout);

}
Expand Down
16 changes: 14 additions & 2 deletions src/mvc/FitSpectraWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "fitting//optimizers/lmfit_optimizer.h"
#include <mvc/NumericPrecDelegate.h>
#include <preferences/Preferences.h>
#include "io/file/aps/aps_roi.h"

using namespace data_struct;

Expand Down Expand Up @@ -240,10 +241,14 @@ void FitSpectraWidget::createLayout()
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);

Expand All @@ -257,6 +262,8 @@ void FitSpectraWidget::createLayout()

QLayout* layout = new QVBoxLayout();
layout->addWidget(splitter);
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout);
}

Expand Down Expand Up @@ -978,15 +985,20 @@ void FitSpectraWidget::Fit_ROI_Spectra_Click()
data_struct::Fit_Element_Map_Dict<double> elements_to_fit = _fitting_dialog->get_elements_to_fit();
data_struct::Fit_Parameters<double>* new_fit_params = _fitting_dialog->get_new_fit_params();

int detector_num = -1;
//int detector_num = -1;
QDir tmp_dir = _dataset_dir;
tmp_dir.cdUp();
tmp_dir.cdUp();
QFileInfo finfo(_dataset_dir.absolutePath());

QString roi_file_name = finfo.fileName() + "_roi_" + roi_name;
int detector_num = finfo.completeSuffix().toInt();

QString roi_file_name = finfo.fileName() + "_roi_" + roi_name;
QString roi_override_name = tmp_dir.absolutePath() + QDir::separator() +"maps_fit_parameters_override_"+roi_file_name+".txt"+QString::number(detector_num);
io::file::save_optimized_fit_params(tmp_dir.absolutePath().toStdString(), roi_file_name.toStdString(), detector_num, result, new_fit_params, (Spectra<double>*)roi_spec, &elements_to_fit);
//io::file::aps::create_detector_fit_params_from_avg(roi_override_name.toStdString(), *new_fit_params, detector_num);
_param_override->fit_params.update_and_add_values(new_fit_params);
io::file::aps::save_parameters_override(roi_override_name.toStdString(), _param_override);
// open file location
tmp_dir.cd("output");
if (false == QDesktopServices::openUrl(QUrl::fromLocalFile(tmp_dir.absolutePath())))
Expand Down
14 changes: 11 additions & 3 deletions src/mvc/ImageStackControlWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void ImageStackControlWidget::createLayout()
{
QVBoxLayout* vlayout = new QVBoxLayout();
QHBoxLayout* hlayout1 = new QHBoxLayout();
QHBoxLayout* hlayout2 = new QHBoxLayout();
//QHBoxLayout* hlayout2 = new QHBoxLayout();
_imageGrid = new MapsElementsWidget(1,1);
_vlm_widget = new VLM_Widget();
connect(_vlm_widget, &VLM_Widget::onLinkRegionToDataset, this, &ImageStackControlWidget::onLinkRegionToDataset);
Expand Down Expand Up @@ -83,6 +83,8 @@ void ImageStackControlWidget::createLayout()
hlayout1->addWidget(_left_btn);
hlayout1->addWidget(_image_name_cb);
hlayout1->addWidget(_right_btn);
hlayout1->setSpacing(0);
hlayout1->setContentsMargins(0, 0, 0, 0);

connect(_image_name_cb, &QComboBox::currentTextChanged, this, &ImageStackControlWidget::model_IndexChanged);

Expand All @@ -100,6 +102,8 @@ void ImageStackControlWidget::createLayout()
vlayout->addWidget(_imageGrid);
vlayout->addWidget(_vlm_widget);
vlayout->addWidget(_mda_widget);
vlayout->setSpacing(0);
vlayout->setContentsMargins(0, 0, 0, 0);

_files_dock = new QDockWidget("Files", this);
_files_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
Expand Down Expand Up @@ -129,14 +133,18 @@ void ImageStackControlWidget::createLayout()
_load_progress = new QProgressBar();

QTabWidget* data_tab = new QTabWidget();

data_tab->addTab(single_data_splitter, "Single Dataset");
//data_tab->setProperty("padding", QVariant("1px"));
//data_tab->setSpacing(0);
data_tab->setContentsMargins(0, 0, 0, 0);
//data_tab->addTab(single_data_splitter, "Multiple Datasets");

QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->addWidget(data_tab);
mainLayout->addWidget(_load_progress);

mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0, 0, 0, 0);

//_imageGrid->hide();
_vlm_widget->hide();
_mda_widget->hide();
Expand Down
29 changes: 28 additions & 1 deletion src/mvc/MapsElementsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ void MapsElementsWidget::_createLayout(bool create_image_nav, bool restore_float
counts_layout->addWidget(scrollArea);
counts_layout->addWidget(splitter);

counts_layout->setSpacing(0);
counts_layout->setContentsMargins(0, 0, 0, 0);

_counts_window = new QWidget();
_counts_window->setLayout(counts_layout);

Expand All @@ -273,66 +276,83 @@ void MapsElementsWidget::_createLayout(bool create_image_nav, bool restore_float
_counts_dock = new QDockWidget("Analyzed Counts", this);
_counts_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
_counts_dock->setWidget(_counts_window);
_counts_dock->setProperty("padding", QVariant("1px"));
_counts_dock->setContentsMargins(0, 0, 0, 0);
_dockMap[STR_COUNTS_DOCK] = _counts_dock;

_intspectra_dock = new QDockWidget(DEF_STR_INT_SPECTRA, this);
_intspectra_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
_intspectra_dock->setWidget(_spectra_widget);
_intspectra_dock->setContentsMargins(0, 0, 0, 0);
_dockMap[STR_INTSPEC_DOCK] = _intspectra_dock;

_quant_dock = new QDockWidget("Quantification", this);
_quant_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
_quant_dock->setWidget(_quant_widget);
_quant_dock->setContentsMargins(0, 0, 0, 0);
_dockMap[STR_QUANT_DOCK] = _quant_dock;

_coloc_dock = new QDockWidget("CoLocalization", this);
_coloc_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
_coloc_dock->setWidget(_co_loc_widget);
_coloc_dock->setContentsMargins(0, 0, 0, 0);
_dockMap[STR_COLOR_DOCK] = _coloc_dock;

_scatter_dock = new QDockWidget("Scatter Plot", this);
_scatter_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
_scatter_dock->setWidget(_scatter_plot_widget);
_scatter_dock->setContentsMargins(0, 0, 0, 0);
_dockMap[STR_SCATTER_DOCK] = _scatter_dock;

_extra_dock = new QDockWidget("Extra PV's", this);
_extra_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable);
_extra_dock->setWidget(_extra_pvs_table_widget);
_extra_dock->setContentsMargins(0, 0, 0, 0);
_dockMap[STR_EXTRA_DOCK] = _extra_dock;

// This is done this way so that you can undock a widget and change tabs without hiding it.
tmp_layout = new QHBoxLayout();
tmp_layout->setSpacing(0);
tmp_layout->setContentsMargins(0, 0, 0, 0);
tmp_layout->addWidget(_counts_dock);
tmp_widget = new QWidget();
tmp_widget->setLayout(tmp_layout);
_tab_widget->addTab(tmp_widget, "Analyzed Counts");

tmp_layout = new QHBoxLayout();
tmp_layout->setSpacing(0);
tmp_layout->setContentsMargins(0, 0, 0, 0);
tmp_layout->addWidget(_intspectra_dock);
tmp_widget = new QWidget();
tmp_widget->setLayout(tmp_layout);
_tab_widget->addTab(tmp_widget, DEF_STR_INT_SPECTRA);

tmp_layout = new QHBoxLayout();
tmp_layout->setSpacing(0);
tmp_layout->setContentsMargins(0, 0, 0, 0);
tmp_layout->addWidget(_quant_dock);
tmp_widget = new QWidget();
tmp_widget->setLayout(tmp_layout);
_tab_widget->addTab(tmp_widget, "Quantification");

tmp_layout = new QHBoxLayout();
tmp_layout->setSpacing(0);
tmp_layout->setContentsMargins(0, 0, 0, 0);
tmp_layout->addWidget(_coloc_dock);
tmp_widget = new QWidget();
tmp_widget->setLayout(tmp_layout);
_tab_widget->addTab(tmp_widget, "CoLocalization");

tmp_layout = new QHBoxLayout();
tmp_layout->setSpacing(0);
tmp_layout->setContentsMargins(0, 0, 0, 0);
tmp_layout->addWidget(_scatter_dock);
tmp_widget = new QWidget();
tmp_widget->setLayout(tmp_layout);
_tab_widget->addTab(tmp_widget, "Scatter Plot");

tmp_layout = new QHBoxLayout();
tmp_layout->setSpacing(0);
tmp_layout->setContentsMargins(0, 0, 0, 0);
tmp_layout->addWidget(_extra_dock);
tmp_widget = new QWidget();
tmp_widget->setLayout(tmp_layout);
Expand Down Expand Up @@ -382,6 +402,13 @@ void MapsElementsWidget::_createLayout(bool create_image_nav, bool restore_float

setCoordinateModel(new gstar::CoordinateModel(&_motor_trans));

hbox->setSpacing(0);
hbox->setContentsMargins(0, 0, 0, 0);
hbox2->setSpacing(0);
hbox2->setContentsMargins(0, 0, 0, 0);

layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout);

if(restore_floating)
Expand Down
4 changes: 3 additions & 1 deletion src/mvc/MapsWorkspaceFilesWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ MapsWorkspaceFilesWidget::~MapsWorkspaceFilesWidget()
void MapsWorkspaceFilesWidget::createLayout()
{

std::vector<std::string> bound_types {"Not Initialized", "Fixed", "Limited Low High", "Limited Low", "Limited High", "Fit"};
//std::vector<std::string> bound_types {"Not Initialized", "Fixed", "Limited Low High", "Limited Low", "Limited High", "Fit"};
_lbl_workspace = new QLabel();
_tab_widget = new QTabWidget();

Expand Down Expand Up @@ -108,6 +108,8 @@ void MapsWorkspaceFilesWidget::createLayout()
_tab_widget->insertTab(2, _vlm_tab_widget, "Light Microscope");

vlayout->addWidget(_tab_widget);
vlayout->setSpacing(0);
vlayout->setContentsMargins(0, 0, 0, 0);
setLayout(vlayout);
}

Expand Down
39 changes: 22 additions & 17 deletions src/mvc/SpectraWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,22 +117,22 @@ void SpectraWidget::createLayout()

// Toolbar zoom out action
_display_eneergy_min = new QLineEdit(QString::number(_axisX->min(), 'f', 2));
// _display_eneergy_min->setMinimumWidth(100);
_display_eneergy_min->setMinimumWidth(50);
connect(_display_eneergy_min, SIGNAL(textEdited(const QString &)), this, SLOT(onSpectraDisplayChanged(const QString &)));


_display_eneergy_max = new QLineEdit(QString::number(_axisX->max(), 'f', 2));
// _display_eneergy_max->setMinimumWidth(100);
_display_eneergy_max->setMinimumWidth(50);
connect(_display_eneergy_max, SIGNAL(textEdited(const QString &)), this, SLOT(onSpectraDisplayChanged(const QString &)));


_display_height_min = new QLineEdit(QString::number(ymin));
// _display_height_min->setMinimumWidth(100);
connect(_display_height_min, SIGNAL(textEdited(const QString&)), this, SLOT(onSpectraDisplayHeightChanged(const QString&)));
//_display_height_min = new QLineEdit(QString::number(ymin));
//_display_height_min->setMinimumWidth(100);
//connect(_display_height_min, SIGNAL(textEdited(const QString&)), this, SLOT(onSpectraDisplayHeightChanged(const QString&)));

_display_height_max = new QLineEdit(QString::number(ymax, 'g', 0));
// _display_height_max->setMinimumWidth(100);
connect(_display_height_max, SIGNAL(textEdited(const QString&)), this, SLOT(onSpectraDisplayHeightChanged(const QString&)));
//_display_height_max = new QLineEdit(QString::number(ymax, 'g', 0));
//_display_height_max->setMinimumWidth(100);
//connect(_display_height_max, SIGNAL(textEdited(const QString&)), this, SLOT(onSpectraDisplayHeightChanged(const QString&)));

_btn_reset_chart_view = new QPushButton("Reset");
connect(_btn_reset_chart_view, &QPushButton::released, this, &SpectraWidget::onResetChartView);
Expand Down Expand Up @@ -171,6 +171,9 @@ void SpectraWidget::createLayout()
_chart->setBackgroundBrush(QBrush(QColor("black")));
}

vlayout->setSpacing(0);
vlayout->setContentsMargins(0, 0, 0, 0);

setLayout(vlayout);
}

Expand All @@ -192,8 +195,8 @@ void SpectraWidget::setDisplayRange(QString wmin, QString wmax, QString hmin, QS
{
_display_eneergy_min->setText(wmin);
_display_eneergy_max->setText(wmax);
_display_height_min->setText(hmin);
_display_height_max->setText(hmax);
//_display_height_min->setText(hmin);
//_display_height_max->setText(hmax);
onSpectraDisplayChanged(wmin);
onSpectraDisplayHeightChanged(hmin);
}
Expand All @@ -212,17 +215,17 @@ void SpectraWidget::onSpectraDisplayChanged(const QString &)

void SpectraWidget::onSpectraDisplayHeightChanged(const QString&)
{
qreal maxRange = _display_height_max->text().toDouble();
qreal minRange = _display_height_min->text().toDouble();
_currentYAxis->setRange(minRange, maxRange);
//qreal maxRange = _display_height_max->text().toDouble();
//qreal minRange = _display_height_min->text().toDouble();
//_currentYAxis->setRange(minRange, maxRange);
}

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

void SpectraWidget::onResetChartViewOnlyY()
{
_display_height_min->setText(QString::number(1));
_display_height_max->setText(QString::number(_int_spec_max_y, 'g', 0));
//_display_height_min->setText(QString::number(1));
//_display_height_max->setText(QString::number(_int_spec_max_y, 'g', 0));
_currentYAxis->setRange(1, _int_spec_max_y);
}

Expand All @@ -233,8 +236,8 @@ void SpectraWidget::onResetChartView()
_display_eneergy_min->setText(QString::number(0, 'f', 2));
_display_eneergy_max->setText(QString::number(_int_spec_max_x, 'f', 2));

_display_height_min->setText(QString::number(1));
_display_height_max->setText(QString::number(_int_spec_max_y, 'g', 0));
//_display_height_min->setText(QString::number(1));
//_display_height_max->setText(QString::number(_int_spec_max_y, 'g', 0));

_currentYAxis->setRange(1, _int_spec_max_y);
_axisX->setRange(0, _int_spec_max_x);
Expand All @@ -249,6 +252,7 @@ void SpectraWidget::onUpdateChartLineEdits()
{
_display_eneergy_min->setText(QString::number(_axisX->min(), 'f', 2));
_display_eneergy_max->setText(QString::number(_axisX->max(), 'f', 2));
/*
if (_display_log10)
{
_display_height_min->setText(QString::number(_axisYLog10->min()));
Expand All @@ -259,6 +263,7 @@ void SpectraWidget::onUpdateChartLineEdits()
_display_height_min->setText(QString::number(_axisY->min()));
_display_height_max->setText(QString::number(_axisY->max()));
}
*/
}

//---------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 98ab325

Please sign in to comment.