From 628d3f9deb7b1cb181411f3fc9e6d7a2552adcaa Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Thu, 25 Apr 2024 09:59:36 -0500 Subject: [PATCH 1/9] Update to be able to double click executable to launch in osx --- src/core/uProbeX.cpp | 21 --------------------- src/main.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/core/uProbeX.cpp b/src/core/uProbeX.cpp index 1b74dfe..30df5f1 100644 --- a/src/core/uProbeX.cpp +++ b/src/core/uProbeX.cpp @@ -44,11 +44,6 @@ uProbeX::uProbeX(QWidget* parent, Qt::WindowFlags flags) : QMainWindow(parent, f log_textedit = new QTextEdit(); //m_autosaveTimer = nullptr; _liveMapsViewer = nullptr; - - //////// HENKE and ELEMENT INFO ///////////// - const std::string element_csv_filename = "../reference/xrf_library.csv"; - const std::string element_henke_filename = "../reference/henke.xdr"; - const std::string scaler_lookup_yaml = "../reference/Scaler_to_PV_map.yaml"; PythonLoader::inst()->safeCheck(); @@ -78,22 +73,6 @@ uProbeX::uProbeX(QWidget* parent, Qt::WindowFlags flags) : QMainWindow(parent, f // Update preferences; also creates solver processPreferencesUpdate(); - if (false == io::file::load_scalers_lookup(scaler_lookup_yaml)) - { - logE << " Could not load " << scaler_lookup_yaml << ". Won't be able to translate from PV to Label for scalers!\n"; - } - - - if (false == io::file::load_element_info(element_henke_filename, element_csv_filename ) ) - { - QString msg = QString("Error loading "); - msg += QString(element_henke_filename.c_str()); - msg += QString(" and "); - msg += QString(element_csv_filename.c_str()); - - QMessageBox::critical(this, "Warning", msg); - } - // Creat MDI window m_mdiArea = new QMdiArea(); diff --git a/src/main.cpp b/src/main.cpp index 40455ac..5c3d408 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -137,6 +137,38 @@ int main(int argc, char** argv) return app.exec(); } } + + + // get location of where we are running from and use it to find ref files + std::string exe_loc = std::string(argv[0]); + int prog_idx = exe_loc.find("bin/uProbeX"); + if (prog_idx > 0) + { + exe_loc = exe_loc.substr(0, prog_idx); + } + + //////// HENKE and ELEMENT INFO ///////////// + const std::string element_csv_filename = exe_loc + "./reference/xrf_library.csv"; + const std::string element_henke_filename = exe_loc + "./reference/henke.xdr"; + const std::string scaler_lookup_yaml = exe_loc + "./reference/Scaler_to_PV_map.yaml"; + + if (false == io::file::load_scalers_lookup(scaler_lookup_yaml)) + { + logE << " Could not load " << scaler_lookup_yaml << ". Won't be able to translate from PV to Label for scalers!\n"; + } + + //load element information + if (false == io::file::load_element_info(element_henke_filename, element_csv_filename)) + { + logE << "loading element information: " << "\n"; + return -1; + } + if (false == io::file::load_element_info(element_henke_filename, element_csv_filename)) + { + logE << "loading element information: " << "\n"; + return -1; + } + #if defined _WIN32 || defined __CYGWIN__ FreeConsole(); #endif From fb27286a002b21eddc5320015521a25d70d53038 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Thu, 25 Apr 2024 15:57:36 -0500 Subject: [PATCH 2/9] Added docks for most widgets --- src/core/uProbeX.cpp | 1 + src/mvc/FitSpectraWidget.cpp | 7 +++++- src/mvc/FitSpectraWidget.h | 3 +++ src/mvc/ImageStackControlWidget.cpp | 15 ++++++++++-- src/mvc/ImageStackControlWidget.h | 3 +++ src/mvc/MapsElementsWidget.cpp | 36 ++++++++++++++++++++++++----- src/mvc/MapsElementsWidget.h | 11 +++++++++ src/mvc/MapsWorkspaceController.h | 4 ++-- 8 files changed, 69 insertions(+), 11 deletions(-) diff --git a/src/core/uProbeX.cpp b/src/core/uProbeX.cpp index 30df5f1..e4c3fe7 100644 --- a/src/core/uProbeX.cpp +++ b/src/core/uProbeX.cpp @@ -51,6 +51,7 @@ uProbeX::uProbeX(QWidget* parent, Qt::WindowFlags flags) : QMainWindow(parent, f _log_dock = new QDockWidget("Log", this); _log_dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + _log_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); _log_dock->setWidget(log_textedit); this->addDockWidget(Qt::BottomDockWidgetArea, _log_dock); diff --git a/src/mvc/FitSpectraWidget.cpp b/src/mvc/FitSpectraWidget.cpp index 87eea95..4f65874 100644 --- a/src/mvc/FitSpectraWidget.cpp +++ b/src/mvc/FitSpectraWidget.cpp @@ -119,6 +119,11 @@ void FitSpectraWidget::createLayout() _spectra_widget = new SpectraWidget(); + _spectra_dock = new QDockWidget("Spectra", this); + //_spectra_dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + _spectra_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _spectra_dock->setWidget(_spectra_widget); + _fit_params_tab_widget = new QTabWidget(); fitting::models::Gaussian_Model g_model; @@ -244,7 +249,7 @@ void FitSpectraWidget::createLayout() QSplitter* splitter = new QSplitter(); splitter->setOrientation(Qt::Vertical); - splitter->addWidget(_spectra_widget); + splitter->addWidget(_spectra_dock); splitter->setStretchFactor(0, 1); splitter->addWidget(tab_and_buttons_widget); diff --git a/src/mvc/FitSpectraWidget.h b/src/mvc/FitSpectraWidget.h index bfb6698..703e383 100644 --- a/src/mvc/FitSpectraWidget.h +++ b/src/mvc/FitSpectraWidget.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include "mvc/FitParamsTableModel.h" @@ -133,6 +134,8 @@ public slots: SpectraWidget* _spectra_widget; + QDockWidget* _spectra_dock; + FitParamsTableModel* _fit_params_table_model; FitElementsTableModel* _fit_elements_table_model; diff --git a/src/mvc/ImageStackControlWidget.cpp b/src/mvc/ImageStackControlWidget.cpp index c41349e..8cb9396 100644 --- a/src/mvc/ImageStackControlWidget.cpp +++ b/src/mvc/ImageStackControlWidget.cpp @@ -79,12 +79,23 @@ void ImageStackControlWidget::createLayout() connect(_imageGrid, &MapsElementsWidget::loaded_perc, this, &ImageStackControlWidget::update_progress_bar); connect(_mapsFilsWidget, &MapsWorkspaceFilesWidget::loaded_perc, this, &ImageStackControlWidget::update_progress_bar); - vlayout->addItem(hlayout1); + QWidget *navWidget = new QWidget(); + navWidget->setLayout(hlayout1); + + _nav_dock = new QDockWidget("Files", this); + _nav_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _nav_dock->setWidget(navWidget); + + vlayout->addWidget(_nav_dock); vlayout->addWidget(_imageGrid); vlayout->addWidget(_vlm_widget); vlayout->addWidget(_mda_widget); - hlayout2->addWidget(_mapsFilsWidget); + _files_dock = new QDockWidget("Files", this); + _files_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _files_dock->setWidget(_mapsFilsWidget); + + hlayout2->addWidget(_files_dock); QWidget *leftWidget = new QWidget(); leftWidget->setLayout(hlayout2); diff --git a/src/mvc/ImageStackControlWidget.h b/src/mvc/ImageStackControlWidget.h index cc1d3b9..0994bdf 100644 --- a/src/mvc/ImageStackControlWidget.h +++ b/src/mvc/ImageStackControlWidget.h @@ -100,6 +100,9 @@ public slots: QProgressBar* _load_progress; + QDockWidget* _files_dock; + + QDockWidget* _nav_dock; //QDialog _raw_file_dialog; }; diff --git a/src/mvc/MapsElementsWidget.cpp b/src/mvc/MapsElementsWidget.cpp index 57476a4..9fb40a6 100644 --- a/src/mvc/MapsElementsWidget.cpp +++ b/src/mvc/MapsElementsWidget.cpp @@ -240,12 +240,36 @@ void MapsElementsWidget::_createLayout(bool create_image_nav) _scatter_plot_widget = new ScatterPlotWidget(); connect(_scatter_plot_widget, &ScatterPlotWidget::updateProgressBar, this, &MapsElementsWidget::loaded_perc); - _tab_widget->addTab(_counts_window, "Analyzed Counts"); - _tab_widget->addTab(_spectra_widget, DEF_STR_INT_SPECTRA); - _tab_widget->addTab(_quant_widget, "Quantification"); - _tab_widget->addTab(_co_loc_widget, "CoLocalization"); - _tab_widget->addTab(_scatter_plot_widget, "Scatter Plot"); - _tab_widget->addTab(_extra_pvs_table_widget, "Extra PV's"); + _counts_dock = new QDockWidget("Analyzed Counts", this); + _counts_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _counts_dock->setWidget(_counts_window); + + _intspectra_dock = new QDockWidget(DEF_STR_INT_SPECTRA, this); + _intspectra_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _intspectra_dock->setWidget(_spectra_widget); + + _quant_dock = new QDockWidget("Quantification", this); + _quant_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _quant_dock->setWidget(_quant_widget); + + _coloc_dock = new QDockWidget("CoLocalization", this); + _coloc_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _coloc_dock->setWidget(_co_loc_widget); + + _scatter_dock = new QDockWidget("Scatter Plot", this); + _scatter_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _scatter_dock->setWidget(_scatter_plot_widget); + + _extra_dock = new QDockWidget("Extra PV's", this); + _extra_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + _extra_dock->setWidget(_extra_pvs_table_widget); + + _tab_widget->addTab(_counts_dock, "Analyzed Counts"); + _tab_widget->addTab(_intspectra_dock, DEF_STR_INT_SPECTRA); + _tab_widget->addTab(_quant_dock, "Quantification"); + _tab_widget->addTab(_coloc_dock, "CoLocalization"); + _tab_widget->addTab(_scatter_dock, "Scatter Plot"); + _tab_widget->addTab(_extra_dock, "Extra PV's"); layout->addItem(hbox2); diff --git a/src/mvc/MapsElementsWidget.h b/src/mvc/MapsElementsWidget.h index c1eb3a9..58fd08e 100644 --- a/src/mvc/MapsElementsWidget.h +++ b/src/mvc/MapsElementsWidget.h @@ -217,6 +217,17 @@ public slots: QPushButton* _btn_roi_img_seg; + QDockWidget* _counts_dock; + + QDockWidget* _intspectra_dock; + + QDockWidget* _quant_dock; + + QDockWidget* _coloc_dock; + + QDockWidget* _scatter_dock; + + QDockWidget* _extra_dock; }; diff --git a/src/mvc/MapsWorkspaceController.h b/src/mvc/MapsWorkspaceController.h index 815e060..f13da11 100644 --- a/src/mvc/MapsWorkspaceController.h +++ b/src/mvc/MapsWorkspaceController.h @@ -50,9 +50,9 @@ public slots: MapsWorkspaceModel* _mapsWorkspaceModel; - QDockWidget *_maps_workspace_dock; + //QDockWidget *_maps_workspace_dock; - QDockWidget *_image_stack_control_dock; + //QDockWidget *_image_stack_control_dock; }; From f80f7742d2737e1cfc97c14129bfd95f7e6f50f4 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Thu, 25 Apr 2024 16:10:46 -0500 Subject: [PATCH 3/9] Updated it so that docks do not hide when changing tabs --- src/mvc/MapsElementsWidget.cpp | 45 +++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/mvc/MapsElementsWidget.cpp b/src/mvc/MapsElementsWidget.cpp index 9fb40a6..4d994e3 100644 --- a/src/mvc/MapsElementsWidget.cpp +++ b/src/mvc/MapsElementsWidget.cpp @@ -89,6 +89,9 @@ MapsElementsWidget::~MapsElementsWidget() void MapsElementsWidget::_createLayout(bool create_image_nav) { + QHBoxLayout *tmp_layout; + QWidget *tmp_widget; + _tab_widget = new QTabWidget(); _spectra_widget = new FitSpectraWidget(); connect(_spectra_widget, &FitSpectraWidget::export_fit_paramters, this, &MapsElementsWidget::on_export_fit_params); @@ -264,12 +267,42 @@ void MapsElementsWidget::_createLayout(bool create_image_nav) _extra_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); _extra_dock->setWidget(_extra_pvs_table_widget); - _tab_widget->addTab(_counts_dock, "Analyzed Counts"); - _tab_widget->addTab(_intspectra_dock, DEF_STR_INT_SPECTRA); - _tab_widget->addTab(_quant_dock, "Quantification"); - _tab_widget->addTab(_coloc_dock, "CoLocalization"); - _tab_widget->addTab(_scatter_dock, "Scatter Plot"); - _tab_widget->addTab(_extra_dock, "Extra PV's"); + // This is done this way so that you can undock a widget and change tabs without hiding it. + tmp_layout = new QHBoxLayout(); + 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->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->addWidget(_quant_dock); + tmp_widget = new QWidget(); + tmp_widget->setLayout(tmp_layout); + _tab_widget->addTab(tmp_widget, "Quantification"); + + tmp_layout = new QHBoxLayout(); + 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->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->addWidget(_extra_dock); + tmp_widget = new QWidget(); + tmp_widget->setLayout(tmp_layout); + _tab_widget->addTab(tmp_widget, "Extra PV's"); layout->addItem(hbox2); From dba305357602fa6adf87933979245fe0b50bf5f4 Mon Sep 17 00:00:00 2001 From: aglowacki Date: Fri, 26 Apr 2024 08:04:15 -0500 Subject: [PATCH 4/9] update to windows to look for executable folder for references --- src/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 5c3d408..14f542b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -146,6 +146,19 @@ int main(int argc, char** argv) { exe_loc = exe_loc.substr(0, prog_idx); } + else // windows + { + int prog_idx = exe_loc.find("bin\\uProbeX.exe"); + if (prog_idx > 0) + { + exe_loc = exe_loc.substr(0, prog_idx); + } + else + { + logE << "Could not parse executable location to load reference files. Exiting.\n"; + return -1; + } + } //////// HENKE and ELEMENT INFO ///////////// const std::string element_csv_filename = exe_loc + "./reference/xrf_library.csv"; From 1c7e804a13590ca87b10bc6cf12bf958e929d605 Mon Sep 17 00:00:00 2001 From: aglowacki Date: Mon, 29 Apr 2024 13:45:03 -0500 Subject: [PATCH 5/9] Have it save and restore dockable widget --- src/core/uProbeX.cpp | 6 +++- src/mvc/ImageStackControlWidget.cpp | 7 ++++ src/mvc/ImageStackControlWidget.h | 2 ++ src/mvc/MapsElementsWidget.cpp | 55 +++++++++++++++++++++++++++-- src/mvc/MapsElementsWidget.h | 6 ++++ src/mvc/MapsWorkspaceController.cpp | 5 +++ src/preferences/Preferences.cpp | 4 ++- src/preferences/Preferences.h | 9 +++++ 8 files changed, 89 insertions(+), 5 deletions(-) diff --git a/src/core/uProbeX.cpp b/src/core/uProbeX.cpp index e4c3fe7..fc5d5e7 100644 --- a/src/core/uProbeX.cpp +++ b/src/core/uProbeX.cpp @@ -84,6 +84,9 @@ uProbeX::uProbeX(QWidget* parent, Qt::WindowFlags flags) : QMainWindow(parent, f ColorMap::inst()->reload_color_maps(); + restoreGeometry(Preferences::inst()->getValue(STR_GEOMETRY).toByteArray()); + restoreState(Preferences::inst()->getValue(STR_WINDOWSTATE).toByteArray()); + show(); } @@ -167,7 +170,8 @@ void uProbeX::closeEvent(QCloseEvent* event) saveAllXML(!saveWithoutPrompt); cleanUpAutoSafeData(); - + Preferences::inst()->setValue(STR_GEOMETRY, saveGeometry()); + Preferences::inst()->setValue(STR_WINDOWSTATE, saveState()); // Quit exitApplication(); diff --git a/src/mvc/ImageStackControlWidget.cpp b/src/mvc/ImageStackControlWidget.cpp index 8cb9396..37a07ef 100644 --- a/src/mvc/ImageStackControlWidget.cpp +++ b/src/mvc/ImageStackControlWidget.cpp @@ -39,6 +39,13 @@ ImageStackControlWidget::~ImageStackControlWidget() } +//--------------------------------------------------------------------------- + +void ImageStackControlWidget::savePref() +{ + _imageGrid->savePref(); +} + /*---------------------------------------------------------------------------*/ void ImageStackControlWidget::createLayout() diff --git a/src/mvc/ImageStackControlWidget.h b/src/mvc/ImageStackControlWidget.h index 0994bdf..a859501 100644 --- a/src/mvc/ImageStackControlWidget.h +++ b/src/mvc/ImageStackControlWidget.h @@ -48,6 +48,8 @@ class ImageStackControlWidget : public QWidget void update_file_list(); + void savePref(); + signals: void widgetClosed(); diff --git a/src/mvc/MapsElementsWidget.cpp b/src/mvc/MapsElementsWidget.cpp index 4d994e3..e99af84 100644 --- a/src/mvc/MapsElementsWidget.cpp +++ b/src/mvc/MapsElementsWidget.cpp @@ -64,7 +64,8 @@ MapsElementsWidget::MapsElementsWidget(int rows, int cols, bool create_image_nav _selected_colormap = &_gray_colormap; connect(&_img_seg_diag, &ImageSegRoiDialog::onNewROIs, this, &MapsElementsWidget::on_add_new_ROIs); - + setAttribute(Qt::WA_DeleteOnClose, true); + connect(this, SIGNAL(destroyed()), this, SLOT(closeEvent())); _createLayout(create_image_nav); } @@ -91,7 +92,7 @@ void MapsElementsWidget::_createLayout(bool create_image_nav) QHBoxLayout *tmp_layout; QWidget *tmp_widget; - + _tab_widget = new QTabWidget(); _spectra_widget = new FitSpectraWidget(); connect(_spectra_widget, &FitSpectraWidget::export_fit_paramters, this, &MapsElementsWidget::on_export_fit_params); @@ -246,26 +247,32 @@ void MapsElementsWidget::_createLayout(bool create_image_nav) _counts_dock = new QDockWidget("Analyzed Counts", this); _counts_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); _counts_dock->setWidget(_counts_window); - + _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); + _dockMap[STR_INTSPEC_DOCK] = _intspectra_dock; _quant_dock = new QDockWidget("Quantification", this); _quant_dock->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); _quant_dock->setWidget(_quant_widget); + _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); + _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); + _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); + _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(); @@ -341,8 +348,50 @@ void MapsElementsWidget::_createLayout(bool create_image_nav) connect(m_tabWidget, &QTabWidget::currentChanged, this, &MapsElementsWidget::annoTabChanged); + restoreGeometry(Preferences::inst()->getValue(STR_MAPS_WIDGET_GEOMETRY).toByteArray()); + //restoreState(Preferences::inst()->getValue(STR_MAPS_WIDGET_WINDOWSTATE).toByteArray()); + setLayout(layout); + + for (auto& mItr : _dockMap) + { + QVariant variant = Preferences::inst()->getValue(mItr.first+"_floating"); + if (variant.isValid()) + { + mItr.second->setFloating(variant.toBool()); + } + variant = Preferences::inst()->getValue(mItr.first + "_geometry"); + if (variant.isValid()) + { + mItr.second->restoreGeometry(variant.toByteArray()); + } + + connect(mItr.second, &QDockWidget::topLevelChanged, this, &MapsElementsWidget::onDockFloatChanged); + } + +} + +//--------------------------------------------------------------------------- + +void MapsElementsWidget::onDockFloatChanged(bool floating) +{ + for (auto& mItr : _dockMap) + { + Preferences::inst()->setValue(mItr.first + "_floating", mItr.second->isFloating()); + //Preferences::inst()->setValue(mItr.first + "_geometry", mItr.second->saveGeometry()); + } +} + +//--------------------------------------------------------------------------- + +void MapsElementsWidget::savePref() +{ + for (auto& mItr : _dockMap) + { + Preferences::inst()->setValue(mItr.first+"_floating", mItr.second->isFloating()); + Preferences::inst()->setValue(mItr.first + "_geometry", mItr.second->saveGeometry()); + } } //--------------------------------------------------------------------------- diff --git a/src/mvc/MapsElementsWidget.h b/src/mvc/MapsElementsWidget.h index 58fd08e..e419550 100644 --- a/src/mvc/MapsElementsWidget.h +++ b/src/mvc/MapsElementsWidget.h @@ -119,6 +119,10 @@ public slots: void annoTabChanged(int); + void savePref(); + + void onDockFloatChanged(bool floating); + protected: /** @@ -228,6 +232,8 @@ public slots: QDockWidget* _scatter_dock; QDockWidget* _extra_dock; + + std::map< QString, QDockWidget*> _dockMap; }; diff --git a/src/mvc/MapsWorkspaceController.cpp b/src/mvc/MapsWorkspaceController.cpp index 1265a7d..98d168e 100644 --- a/src/mvc/MapsWorkspaceController.cpp +++ b/src/mvc/MapsWorkspaceController.cpp @@ -49,6 +49,11 @@ MapsWorkspaceController::~MapsWorkspaceController() void MapsWorkspaceController::imgWidgetClosed() { + if (_imgStackControllWidget != nullptr) + { + _imgStackControllWidget->savePref(); + delete _imgStackControllWidget; + } _imgStackControllWidget = nullptr; emit controllerClosed(this); diff --git a/src/preferences/Preferences.cpp b/src/preferences/Preferences.cpp index c444f76..2172b7c 100644 --- a/src/preferences/Preferences.cpp +++ b/src/preferences/Preferences.cpp @@ -59,7 +59,9 @@ Preferences::Preferences() {STR_GRID_ROWS, QVariant()}, {STR_GRID_COLS, QVariant()}, {STR_PRF_SHOW_DATASET_ON_FILE_SELECT, QVariant()}, - {STR_SEARCH_SUB_DIR_FOR_DATASETS, QVariant()} + {STR_SEARCH_SUB_DIR_FOR_DATASETS, QVariant()}, + {STR_GEOMETRY, QVariant()}, + {STR_WINDOWSTATE, QVariant()} }; load(); } diff --git a/src/preferences/Preferences.h b/src/preferences/Preferences.h index 9204591..adcdca4 100644 --- a/src/preferences/Preferences.h +++ b/src/preferences/Preferences.h @@ -71,6 +71,15 @@ #define STR_DEFAULT "Default" #define STR_PRF_SHOW_DATASET_ON_FILE_SELECT "ShowDatasetOnFileSelect" // if you select file name on left side, it will change the current viewed dataset to that if it is loaded #define STR_SEARCH_SUB_DIR_FOR_DATASETS "SearchSubDirForDatasets" +#define STR_GEOMETRY "Geometry" +#define STR_WINDOWSTATE "WindowState" +#define STR_MAPS_WIDGET_GEOMETRY "MapsWidgetGeometry" +#define STR_COUNTS_DOCK "CountsDock" +#define STR_INTSPEC_DOCK "IntSpecDock" +#define STR_QUANT_DOCK "QuantDock" +#define STR_COLOR_DOCK "ColorDock" +#define STR_SCATTER_DOCK "ScatterDock" +#define STR_EXTRA_DOCK "ExtraDock" /** * @brief Read and save preferences between application restarts, the vaule key From 4def929b8384d99c1e328109864f315c86f41a5d Mon Sep 17 00:00:00 2001 From: aglowacki Date: Thu, 2 May 2024 14:44:35 -0500 Subject: [PATCH 6/9] Added an option to compile release with debug symbols for windows --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fbe3bf..ed44d69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) option(AVX2 "Compule with arch AVX2 on MSVC" OFF) option(AVX "Compule with arch AVX on MSVC" OFF) option(SSE2 "Compule with arch SSE2 on MSVC" OFF) +option(MSVC_DEBUG_INFO_REL "Compule with debug info in Release build for MSVC" OFF) IF (UNIX) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/linux) @@ -156,6 +157,11 @@ ENDIF() ENDIF() ENDIF() + IF(MSVC_DEBUG_INFO_REL) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi ") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /ASSEMBLYDEBUG /DEBUG:FULL") + ENDIF() + # Compile with compiler warnings turned on IF(MSVC) IF(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") From 883acea8e2f4d1e0b9e7e173ded72682a03e44ec Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Thu, 2 May 2024 14:58:44 -0500 Subject: [PATCH 7/9] update to work by calling exec from bin dir --- src/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 14f542b..dea4480 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -155,8 +155,7 @@ int main(int argc, char** argv) } else { - logE << "Could not parse executable location to load reference files. Exiting.\n"; - return -1; + exe_loc = "."; } } From 36f1c31a14841fe81f6a84e2ab44a40c4f3b17ea Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Fri, 3 May 2024 07:36:54 -0500 Subject: [PATCH 8/9] Changed it so if you reprocess analyzed datasets then it will rename to raw dataset name. Before it was processing the analyzed h5 files with each detector fit parrms --- src/mvc/MapsWorkspaceFilesWidget.cpp | 51 +++++++++++++++++++++++----- src/mvc/MapsWorkspaceFilesWidget.h | 2 ++ src/mvc/MapsWorkspaceModel.cpp | 2 ++ 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/mvc/MapsWorkspaceFilesWidget.cpp b/src/mvc/MapsWorkspaceFilesWidget.cpp index afc32d1..c362b36 100644 --- a/src/mvc/MapsWorkspaceFilesWidget.cpp +++ b/src/mvc/MapsWorkspaceFilesWidget.cpp @@ -16,6 +16,7 @@ #include "core/GlobalThreadPool.h" const QString STR_PROCESS("process"); +const QString STR_PROCESS_ANALYZED("process_analyzed"); const QString STR_BATCH_ROI("batch_roi"); const QString STR_H5_EXPORT("hdf5_export"); @@ -54,14 +55,14 @@ void MapsWorkspaceFilesWidget::createLayout() _h5_tab_widget->appendFilterHelpAction(h5avg_file); _h5_tab_widget->appendFilterHelpAction(h5det_file); - _h5_tab_widget->addCustomContext(STR_PROCESS, "Per Pixel Process"); + _h5_tab_widget->addCustomContext(STR_PROCESS_ANALYZED, "Per Pixel Process"); _h5_tab_widget->addCustomContext(STR_BATCH_ROI, "Process ROI's"); // TODO: need to implement //_h5_tab_widget->addCustomContext(STR_H5_EXPORT, "Export Images"); connect(_h5_tab_widget, &FileTabWidget::loadList, [this](const QStringList& sl) { this->onOpenModel(sl, MODEL_TYPE::MAPS_H5); }); connect(_h5_tab_widget, &FileTabWidget::unloadList, [this](const QStringList& sl) { this->onCloseModel(sl, MODEL_TYPE::MAPS_H5); }); - connect(_h5_tab_widget, &FileTabWidget::processList, this, &MapsWorkspaceFilesWidget::onPerPixelProcessList); + connect(_h5_tab_widget, &FileTabWidget::processList, this, &MapsWorkspaceFilesWidget::onPerPixelProcessListAnalyzed); connect(_h5_tab_widget, &FileTabWidget::batchRoiList, this, &MapsWorkspaceFilesWidget::onBatchRoiList); connect(_h5_tab_widget, &FileTabWidget::customContext, this, &MapsWorkspaceFilesWidget::onCustomContext); connect(_h5_tab_widget, &FileTabWidget::selectNewRow, this, &MapsWorkspaceFilesWidget::onDatasetSelected); @@ -127,6 +128,13 @@ void MapsWorkspaceFilesWidget::setModel(MapsWorkspaceModel *model) _model = model; if (_model != nullptr) { + //create per pixel process widget and pass workspace + if(_per_pixel_fit_widget == nullptr) + { + _per_pixel_fit_widget = new PerPixelFitWidget(_model->get_directory_name().toStdString()); + connect(_per_pixel_fit_widget, &PerPixelFitWidget::processed_list_update, this, &MapsWorkspaceFilesWidget::onProcessed_list_update); + } + QString path = _model->get_directory_name(); if (path.length() > 0) { @@ -415,6 +423,10 @@ void MapsWorkspaceFilesWidget::onCustomContext(const QString& context_label, con { onPerPixelProcessList(file_list); } + if (context_label == STR_PROCESS_ANALYZED) + { + onPerPixelProcessListAnalyzed(file_list); + } else if (context_label == STR_BATCH_ROI) { onBatchRoiList(file_list); @@ -430,15 +442,38 @@ void MapsWorkspaceFilesWidget::onCustomContext(const QString& context_label, con void MapsWorkspaceFilesWidget::onPerPixelProcessList(const QStringList& file_list) { + onCloseModel(file_list, MODEL_TYPE::MAPS_H5); + _per_pixel_fit_widget->updateFileList(file_list); + _per_pixel_fit_widget->show(); +} - //create per pixel process widget and pass workspace - if(_per_pixel_fit_widget == nullptr) +/*---------------------------------------------------------------------------*/ + +void MapsWorkspaceFilesWidget::onPerPixelProcessListAnalyzed(const QStringList& file_list) +{ + onCloseModel(file_list, MODEL_TYPE::MAPS_H5); + QStringList nfile_list = file_list; + // for each files replace .mda.h5[0-n] to .mda and remove duplicates + for(QString &str : nfile_list) { - _per_pixel_fit_widget = new PerPixelFitWidget(_model->get_directory_name().toStdString()); - connect(_per_pixel_fit_widget, &PerPixelFitWidget::processed_list_update, this, &MapsWorkspaceFilesWidget::onProcessed_list_update); + if(str.endsWith(".h5")) + { + str = str.replace(".h5", ".mda"); + } + else + { + for(int i =0; i<30; i++) + { + QString cmp = ".h5"+QString::number(i); + if(str.endsWith(cmp)) + { + str = str.replace(cmp, ""); + } + } + } } - onCloseModel(file_list, MODEL_TYPE::MAPS_H5); - _per_pixel_fit_widget->updateFileList(file_list); + nfile_list.removeDuplicates(); + _per_pixel_fit_widget->updateFileList(nfile_list); _per_pixel_fit_widget->show(); } diff --git a/src/mvc/MapsWorkspaceFilesWidget.h b/src/mvc/MapsWorkspaceFilesWidget.h index dc16a9f..469ff3e 100644 --- a/src/mvc/MapsWorkspaceFilesWidget.h +++ b/src/mvc/MapsWorkspaceFilesWidget.h @@ -85,6 +85,8 @@ public slots: void onPerPixelProcessList(const QStringList& file_list); + void onPerPixelProcessListAnalyzed(const QStringList& file_list); + void onBatchRoiList(const QStringList& file_list); void onProcessed_list_update(QStringList file_list); diff --git a/src/mvc/MapsWorkspaceModel.cpp b/src/mvc/MapsWorkspaceModel.cpp index f83c8a9..477d681 100644 --- a/src/mvc/MapsWorkspaceModel.cpp +++ b/src/mvc/MapsWorkspaceModel.cpp @@ -550,7 +550,9 @@ void MapsWorkspaceModel::unload_VLM_Model(QString name) QString MapsWorkspaceModel::get_directory_name() { if( _dir != nullptr) + { return _dir->path(); + } return ""; } From fbcd447e600603c84d5af9d438314b190b4b745e Mon Sep 17 00:00:00 2001 From: aglowacki Date: Fri, 3 May 2024 10:26:52 -0500 Subject: [PATCH 9/9] Change default per pixel optimizer to mpfit --- src/mvc/MapsWorkspaceFilesWidget.cpp | 10 +++++++++- src/mvc/PerPixelFitWidget.cpp | 18 ++++++++++++------ src/mvc/PerPixelFitWidget.h | 4 +++- src/mvc/PerPixelOptionsWidget.h | 1 + 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/mvc/MapsWorkspaceFilesWidget.cpp b/src/mvc/MapsWorkspaceFilesWidget.cpp index c362b36..5c332f3 100644 --- a/src/mvc/MapsWorkspaceFilesWidget.cpp +++ b/src/mvc/MapsWorkspaceFilesWidget.cpp @@ -131,7 +131,7 @@ void MapsWorkspaceFilesWidget::setModel(MapsWorkspaceModel *model) //create per pixel process widget and pass workspace if(_per_pixel_fit_widget == nullptr) { - _per_pixel_fit_widget = new PerPixelFitWidget(_model->get_directory_name().toStdString()); + _per_pixel_fit_widget = new PerPixelFitWidget(); connect(_per_pixel_fit_widget, &PerPixelFitWidget::processed_list_update, this, &MapsWorkspaceFilesWidget::onProcessed_list_update); } @@ -442,6 +442,10 @@ void MapsWorkspaceFilesWidget::onCustomContext(const QString& context_label, con void MapsWorkspaceFilesWidget::onPerPixelProcessList(const QStringList& file_list) { + if (_model != nullptr) + { + _per_pixel_fit_widget->setDir(_model->get_directory_name().toStdString()); + } onCloseModel(file_list, MODEL_TYPE::MAPS_H5); _per_pixel_fit_widget->updateFileList(file_list); _per_pixel_fit_widget->show(); @@ -451,6 +455,10 @@ void MapsWorkspaceFilesWidget::onPerPixelProcessList(const QStringList& file_lis void MapsWorkspaceFilesWidget::onPerPixelProcessListAnalyzed(const QStringList& file_list) { + if (_model != nullptr) + { + _per_pixel_fit_widget->setDir(_model->get_directory_name().toStdString()); + } onCloseModel(file_list, MODEL_TYPE::MAPS_H5); QStringList nfile_list = file_list; // for each files replace .mda.h5[0-n] to .mda and remove duplicates diff --git a/src/mvc/PerPixelFitWidget.cpp b/src/mvc/PerPixelFitWidget.cpp index a6a2072..3e2be68 100644 --- a/src/mvc/PerPixelFitWidget.cpp +++ b/src/mvc/PerPixelFitWidget.cpp @@ -8,14 +8,9 @@ /*---------------------------------------------------------------------------*/ -PerPixelFitWidget::PerPixelFitWidget(std::string directory, QWidget *parent) : QWidget(parent) +PerPixelFitWidget::PerPixelFitWidget(QWidget *parent) : QWidget(parent) { - _directory = directory; - if (_directory[directory.length() - 1] != DIR_END_CHAR) - { - _directory += DIR_END_CHAR; - } createLayout(); } @@ -44,6 +39,17 @@ void PerPixelFitWidget::createLayout() setLayout(layout); } +//--------------------------------------------------------------------------- + +void PerPixelFitWidget::setDir(std::string directory) +{ + _directory = directory; + if (_directory[directory.length() - 1] != DIR_END_CHAR) + { + _directory += DIR_END_CHAR; + } +} + /*---------------------------------------------------------------------------*/ void PerPixelFitWidget::runProcessing() diff --git a/src/mvc/PerPixelFitWidget.h b/src/mvc/PerPixelFitWidget.h index 56f031a..cb7ad33 100644 --- a/src/mvc/PerPixelFitWidget.h +++ b/src/mvc/PerPixelFitWidget.h @@ -40,7 +40,7 @@ class PerPixelFitWidget : public QWidget /** * Constructor. */ - PerPixelFitWidget(std::string directory, QWidget *parent = nullptr); + PerPixelFitWidget(QWidget *parent = nullptr); /** * Destructor. @@ -49,6 +49,8 @@ class PerPixelFitWidget : public QWidget void updateFileList(QStringList file_list) { _optionsWidget->updateFileList(file_list); } + void setDir(std::string directory); + signals: void processed_list_update(QStringList); diff --git a/src/mvc/PerPixelOptionsWidget.h b/src/mvc/PerPixelOptionsWidget.h index 29ddc83..c913407 100644 --- a/src/mvc/PerPixelOptionsWidget.h +++ b/src/mvc/PerPixelOptionsWidget.h @@ -76,6 +76,7 @@ class PerPixelOptionsWidget : public QWidget if (_proc_matrix->isChecked()) { analysis_job.fitting_routines.push_back(data_struct::Fitting_Routines::GAUSS_MATRIX); + analysis_job.set_optimizer("mpfit"); } if (_save_avg->isChecked())