Skip to content

Commit

Permalink
Merge pull request #81 from aglowacki/master
Browse files Browse the repository at this point in the history
Added dockable parts
  • Loading branch information
aglowacki authored May 3, 2024
2 parents 053db44 + fbcd447 commit 652bf3a
Show file tree
Hide file tree
Showing 19 changed files with 309 additions and 49 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]")
Expand Down
28 changes: 6 additions & 22 deletions src/core/uProbeX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,14 @@ 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();

initialize();

_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);

Expand All @@ -78,22 +74,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<double>(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();

Expand All @@ -104,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();
}

Expand Down Expand Up @@ -187,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();

Expand Down
44 changes: 44 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,50 @@ 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);
}
else // windows
{
int prog_idx = exe_loc.find("bin\\uProbeX.exe");
if (prog_idx > 0)
{
exe_loc = exe_loc.substr(0, prog_idx);
}
else
{
exe_loc = ".";
}
}

//////// 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<float>(element_henke_filename, element_csv_filename))
{
logE << "loading element information: " << "\n";
return -1;
}
if (false == io::file::load_element_info<double>(element_henke_filename, element_csv_filename))
{
logE << "loading element information: " << "\n";
return -1;
}

#if defined _WIN32 || defined __CYGWIN__
FreeConsole();
#endif
Expand Down
7 changes: 6 additions & 1 deletion src/mvc/FitSpectraWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double> g_model;
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions src/mvc/FitSpectraWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <QTreeView>
#include <QPushButton>
#include <mutex>
#include <QDockWidget>
#include <mvc/MapsH5Model.h>
#include <mvc/SpectraWidget.h>
#include "mvc/FitParamsTableModel.h"
Expand Down Expand Up @@ -133,6 +134,8 @@ public slots:

SpectraWidget* _spectra_widget;

QDockWidget* _spectra_dock;

FitParamsTableModel* _fit_params_table_model;

FitElementsTableModel* _fit_elements_table_model;
Expand Down
22 changes: 20 additions & 2 deletions src/mvc/ImageStackControlWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ ImageStackControlWidget::~ImageStackControlWidget()

}

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

void ImageStackControlWidget::savePref()
{
_imageGrid->savePref();
}

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

void ImageStackControlWidget::createLayout()
Expand Down Expand Up @@ -79,12 +86,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);
Expand Down
5 changes: 5 additions & 0 deletions src/mvc/ImageStackControlWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class ImageStackControlWidget : public QWidget

void update_file_list();

void savePref();

signals:

void widgetClosed();
Expand Down Expand Up @@ -100,6 +102,9 @@ public slots:

QProgressBar* _load_progress;

QDockWidget* _files_dock;

QDockWidget* _nav_dock;
//QDialog _raw_file_dialog;

};
Expand Down
120 changes: 113 additions & 7 deletions src/mvc/MapsElementsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -89,6 +90,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);
Expand Down Expand Up @@ -240,12 +244,72 @@ 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);
_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();
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);
Expand Down Expand Up @@ -284,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());
}
}

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

0 comments on commit 652bf3a

Please sign in to comment.