Skip to content

Commit

Permalink
Merge pull request #97 from aglowacki/master
Browse files Browse the repository at this point in the history
bug fixes and enhancments
  • Loading branch information
aglowacki authored Jan 10, 2025
2 parents 51e8dc9 + 28253c4 commit 4cbde07
Show file tree
Hide file tree
Showing 42 changed files with 662 additions and 1,582 deletions.
44 changes: 42 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ 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)
option(BUILD_WITH_OPENCV_SUPPORT "Compule with opencv support for image segmentation" ON)

IF (UNIX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/linux)
Expand All @@ -85,9 +86,13 @@ find_package(yaml-cpp CONFIG REQUIRED)
find_package(cppzmq CONFIG REQUIRED)
find_package(TIFF REQUIRED)
find_package(XRF_Maps CONFIG REQUIRED COMPONENTS libxrf_io libxrf_fit)
find_package(OpenCV CONFIG REQUIRED)
find_package(NLopt CONFIG REQUIRED)

IF (BUILD_WITH_OPENCV_SUPPORT)
add_definitions(-D_BUILD_WITH_OPENCV)
find_package(OpenCV CONFIG REQUIRED)
ENDIF()

if (libxrf_fit_FOUND)
message("Found libxrf_fit")
endif()
Expand Down Expand Up @@ -213,6 +218,7 @@ IF (MSVC)
set_target_properties(uProbeX PROPERTIES COMPILE_FLAGS "/D_WINSOCKAPI_")
set_target_properties(uProbeX PROPERTIES COMPILE_FLAGS_RELEASE "/O2 /Qvec-report:2 /GL /MP /bigobj /Qansi-alias")
set_target_properties(uProbeX PROPERTIES LINK_FLAGS "/LTCG")
IF (BUILD_WITH_OPENCV_SUPPORT)
target_link_libraries (uProbeX PRIVATE
yaml-cpp::yaml-cpp
libzmq-static
Expand All @@ -235,12 +241,32 @@ IF (MSVC)
libxrf_io
${CMAKE_THREAD_LIBS_INIT}
ws2_32.lib )
ELSE()
target_link_libraries (uProbeX PRIVATE
yaml-cpp::yaml-cpp
libzmq-static
ws2_32.lib
rpcrt4.lib
iphlpapi.lib
${TIFF_LIBRARIES}
${Qt6Core_LIBRARIES}
${Qt6Charts_LIBRARIES}
netCDF::netcdf
hdf5::hdf5-shared
cppzmq cppzmq-static
NLopt::nlopt
libxrf_fit
libxrf_io
${CMAKE_THREAD_LIBS_INIT}
ws2_32.lib )
ENDIF()

ELSEIF (UNIX)
#IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# set_target_properties(uProbeX PROPERTIES MACOSX_BUNDLE TRUE)
#ENDIF()
set_target_properties(uProbeX PROPERTIES COMPILE_FLAGS "-O2")

IF (BUILD_WITH_OPENCV_SUPPORT)
target_link_libraries (uProbeX PRIVATE
libzmq
yaml-cpp::yaml-cpp
Expand All @@ -258,4 +284,18 @@ ELSEIF (UNIX)
libxrf_fit
libxrf_io
${CMAKE_THREAD_LIBS_INIT} )
ELSE()
target_link_libraries (uProbeX PRIVATE
libzmq
yaml-cpp::yaml-cpp
${TIFF_LIBRARIES}
${Qt6Core_LIBRARIES}
${Qt6Charts_LIBRARIES}
netCDF::netcdf
cppzmq cppzmq-static
NLopt::nlopt
libxrf_fit
libxrf_io
${CMAKE_THREAD_LIBS_INIT} )
ENDIF()
ENDIF()
77 changes: 10 additions & 67 deletions src/core/uProbeX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,28 +442,9 @@ void uProbeX::make_VLM_Window(VLM_Model* model)
VLM_Widget* widget = new VLM_Widget();
widget->resize(1027, 768);
widget->setModel(model);

connect(widget,
SIGNAL(solverStart()),
this,
SLOT(solverStart()));

connect(widget,
SIGNAL(solverVariableUpdate(double, double)),
this,
SLOT(solverVariableUpdate(double, double)));

connect(widget,
SIGNAL(cancelSolverVariableUpdate()),
this,
SLOT(cancelSolverVariableUpdate()));



SubWindow* w = new SubWindow(m_mdiArea);
connect(w,
SIGNAL(windowClosing(SubWindow*)),
this,
SLOT(subWindowClosed(SubWindow*)));
connect(w, &SubWindow::windowClosing, this, &uProbeX::subWindowClosed);


m_mdiArea->addSubWindow(w);
Expand All @@ -474,10 +455,7 @@ void uProbeX::make_VLM_Window(VLM_Model* model)

m_subWindows[w->getUuid()] = w;

connect(w,
SIGNAL(windowStateChanged(Qt::WindowStates, Qt::WindowStates )),
widget,
SLOT(windowChanged(Qt::WindowStates, Qt::WindowStates)));
connect(w, &SubWindow::windowStateChanged, widget, &VLM_Widget::windowChanged);
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -538,31 +516,11 @@ void uProbeX::make_VLM_Window(QString path, bool newWindow)
return;
}

connect(widget,
SIGNAL(solverStart()),
this,
SLOT(solverStart()));

connect(widget,
SIGNAL(solverVariableUpdate(double, double)),
this,
SLOT(solverVariableUpdate(double, double)));

connect(widget,
SIGNAL(cancelSolverVariableUpdate()),
this,
SLOT(cancelSolverVariableUpdate()));


SubWindow* w = nullptr;
if (newWindow == true)
{
w = new SubWindow(m_mdiArea);
connect(w,
SIGNAL(windowClosing(SubWindow*)),
this,
SLOT(subWindowClosed(SubWindow*)));

connect(w, &SubWindow::windowClosing, this, &uProbeX::subWindowClosed);
}

m_mdiArea->addSubWindow(w);
Expand All @@ -573,10 +531,7 @@ void uProbeX::make_VLM_Window(QString path, bool newWindow)

m_subWindows[w->getUuid()] = w;

connect(w,
SIGNAL(windowStateChanged(Qt::WindowStates, Qt::WindowStates)),
widget,
SLOT(windowChanged(Qt::WindowStates, Qt::WindowStates)));
connect(w, &SubWindow::windowStateChanged, widget, &VLM_Widget::windowChanged);
}
else
{
Expand Down Expand Up @@ -712,10 +667,7 @@ void uProbeX::make_HDF_Window(MapsH5Model* model)

SubWindow* w = nullptr;
w = new SubWindow(m_mdiArea);
connect(w,
SIGNAL(windowClosing(SubWindow*)),
this,
SLOT(subWindowClosed(SubWindow*)));
connect(w, &SubWindow::windowClosing, this, &uProbeX::subWindowClosed);


m_mdiArea->addSubWindow(w);
Expand All @@ -727,10 +679,7 @@ void uProbeX::make_HDF_Window(MapsH5Model* model)

m_subWindows[w->getUuid()] = w;

connect(w,
SIGNAL(windowStateChanged(Qt::WindowStates, Qt::WindowStates )),
widget,
SLOT(windowChanged(Qt::WindowStates, Qt::WindowStates)));
connect(w, &SubWindow::windowStateChanged, widget, &MapsElementsWidget::windowChanged);


}
Expand All @@ -744,10 +693,7 @@ void uProbeX::make_MDA_Window(RAW_Model* model)

SubWindow* w = nullptr;
w = new SubWindow(m_mdiArea);
connect(w,
SIGNAL(windowClosing(SubWindow*)),
this,
SLOT(subWindowClosed(SubWindow*)));
connect(w, &SubWindow::windowClosing, this, &uProbeX::subWindowClosed);


m_mdiArea->addSubWindow(w);
Expand All @@ -759,10 +705,7 @@ void uProbeX::make_MDA_Window(RAW_Model* model)

m_subWindows[w->getUuid()] = w;

connect(w,
SIGNAL(windowStateChanged(Qt::WindowStates, Qt::WindowStates )),
widget,
SLOT(windowChanged(Qt::WindowStates, Qt::WindowStates)));
//connect(w, &SubWindow::windowStateChanged, widget, &MDA_Widget::windowChanged);
}

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -876,7 +819,7 @@ void uProbeX::openMapsWorkspace(QString dirName)
updateRecentMapsWorkspaces();

MapsWorkspaceController* mapsWorkspaceController = new MapsWorkspaceController(this);
connect(mapsWorkspaceController, SIGNAL(controllerClosed(MapsWorkspaceController*)), this, SLOT(mapsControllerClosed(MapsWorkspaceController*)));
connect(mapsWorkspaceController, &MapsWorkspaceController::controllerClosed, this, &uProbeX::mapsControllerClosed);
_mapsWorkspaceControllers.append(mapsWorkspaceController);

mapsWorkspaceController->setWorkingDir(dirName);
Expand Down
67 changes: 16 additions & 51 deletions src/gstar/AbstractImageWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ AbstractImageWidget::AbstractImageWidget(int rows, int cols, QWidget* parent)

createActions();


//Setup a QTreeView and AnnotationTreeModel for Annotations

m_treeModel = new AnnotationTreeModel();
connect(m_treeModel,
SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
this,
SLOT(modelDataChanged(const QModelIndex &, const QModelIndex &)));
connect(m_treeModel, &AnnotationTreeModel::dataChanged, this, &AbstractImageWidget::modelDataChanged);

m_selectionModel = new QItemSelectionModel(m_treeModel);

Expand All @@ -66,23 +62,14 @@ AbstractImageWidget::AbstractImageWidget(int rows, int cols, QWidget* parent)
m_annoTreeView->setHeaderHidden(true);
m_annoTreeView->setSelectionModel(m_selectionModel);
m_annoTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_annoTreeView,
SIGNAL(customContextMenuRequested(const QPoint &)),
this,
SLOT(treeContextMenu(const QPoint &)));
connect(m_annoTreeView,
SIGNAL(doubleClicked(const QModelIndex &)),
this,
SLOT(treeDoubleClicked(const QModelIndex &)));
connect(m_annoTreeView, &QTreeView::customContextMenuRequested, this, &AbstractImageWidget::treeContextMenu);
connect(m_annoTreeView, &QTreeView::doubleClicked, this, &AbstractImageWidget::treeDoubleClicked);

m_imageViewWidget = new ImageViewWidget(rows, cols);
m_imageViewWidget->setSceneModel(m_treeModel);
m_imageViewWidget->setSceneSelectionModel(m_selectionModel);
m_imageViewWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_imageViewWidget,
SIGNAL(customContextMenuRequested(const QPoint &)),
this,
SLOT(viewContextMenu(const QPoint &)));
connect(m_imageViewWidget, &ImageViewWidget::customContextMenuRequested, this, &AbstractImageWidget::viewContextMenu);

createAnnotationToolBar();

Expand Down Expand Up @@ -177,27 +164,12 @@ void AbstractImageWidget::createActions()
m_deleteAction = new QAction("Delete", this);
m_showRulerDialogAction = new QAction("Ruler Units", this);

connect(m_addRulerAction,
SIGNAL(triggered()),
this,
SLOT(addRuler()));
connect(m_addMarkerAction,
SIGNAL(triggered()),
this,
SLOT(addMarker()));
connect(m_addRulerAction, &QAction::triggered, this, &AbstractImageWidget::addRuler);
connect(m_addMarkerAction, &QAction::triggered, this, &AbstractImageWidget::addMarker);

connect(m_duplicateAction,
SIGNAL(triggered()),
this,
SLOT(duplicateItem()));
connect(m_deleteAction,
SIGNAL(triggered()),
this,
SLOT(deleteItem()));
connect(m_showRulerDialogAction,
SIGNAL(triggered()),
this,
SLOT(showRulerUnitsDialog()));
connect(m_duplicateAction, &QAction::triggered, this, &AbstractImageWidget::duplicateItem);
connect(m_deleteAction, &QAction::triggered, this, &AbstractImageWidget::deleteItem);
connect(m_showRulerDialogAction, &QAction::triggered, this, &AbstractImageWidget::showRulerUnitsDialog);

}

Expand Down Expand Up @@ -235,19 +207,10 @@ void AbstractImageWidget::createAnnotationToolBar()

m_annotationToolbar = new AnnotationToolBarWidget();

connect(m_annotationToolbar,
SIGNAL(clickRuler()),
this,
SLOT(addRuler()));
connect(m_annotationToolbar,
SIGNAL(clickMarker()),
this,
SLOT(addMarker()));
connect(m_annotationToolbar, &AnnotationToolBarWidget::clickRuler, this, &AbstractImageWidget::addRuler);
connect(m_annotationToolbar, &AnnotationToolBarWidget::clickMarker, this, &AbstractImageWidget::addMarker);

connect(m_annotationToolbar,
SIGNAL(enabledStateChanged(bool)),
this,
SLOT(setAnnotationsEnabled(bool)));
connect(m_annotationToolbar, &AnnotationToolBarWidget::enabledStateChanged, this, &AbstractImageWidget::setAnnotationsEnabled);

}

Expand Down Expand Up @@ -574,9 +537,11 @@ void AbstractImageWidget::setHeightDims(int h)
{
if (h > (m_imageHeightDim->count() - 1)) return;

disconnect(m_imageHeightDim,SIGNAL(activated(int)),this,SLOT(imageHeightDimChanged(int)));
disconnect(m_imageHeightDim, &QComboBox::activated, this, &AbstractImageWidget::imageHeightDimChanged);

m_imageHeightDim->setCurrentIndex(h);
connect(m_imageHeightDim,SIGNAL(activated(int)),this,SIGNAL(imageHeightDimChanged(int)));

connect(m_imageHeightDim, &QComboBox::activated, this, &AbstractImageWidget::imageHeightDimChanged);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/gstar/Annotation/RoiMaskGraphicsItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ using namespace gstar;

static const QString CONST_STATIC_ROI_NAME = QString("ROI");

#ifdef _BUILD_WITH_OPENCV
RoiMaskGraphicsItem::RoiMaskGraphicsItem(cv::Mat& mat, int idx, QColor col, AbstractGraphicsItem* parent)
: AbstractGraphicsItem(parent)
{
Expand All @@ -41,7 +42,7 @@ RoiMaskGraphicsItem::RoiMaskGraphicsItem(cv::Mat& mat, int idx, QColor col, Abst
_init(col, 70);

}

#endif

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

Expand Down
6 changes: 4 additions & 2 deletions src/gstar/Annotation/RoiMaskGraphicsItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

#include "gstar/Annotation/AbstractGraphicsItem.h"
#include "gstar/RectItem.h"
#ifdef _BUILD_WITH_OPENCV
#include <opencv2/opencv.hpp>

#endif
//---------------------------------------------------------------------------

namespace gstar
Expand All @@ -34,8 +35,9 @@ class RoiMaskGraphicsItem : public AbstractGraphicsItem
* @param parent
*/
// blank constructor for classid
#ifdef _BUILD_WITH_OPENCV
RoiMaskGraphicsItem(cv::Mat& mat, int idx, QColor col, AbstractGraphicsItem* parent = 0);

#endif
RoiMaskGraphicsItem(int rows, int cols, QColor col, AbstractGraphicsItem* parent = 0);

RoiMaskGraphicsItem(QImage mask, QColor color, int alpha, AbstractGraphicsItem* parent = 0);
Expand Down
Loading

0 comments on commit 4cbde07

Please sign in to comment.