Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Update build system introducing Slicer_BUILD_SEGMENTATION_SUPPORT option #849

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ option(Slicer_USE_QtTesting "Integrate QtTesting framework into Slicer." ON)
mark_as_advanced(Slicer_USE_QtTesting)
mark_as_superbuild(Slicer_USE_QtTesting)

option(Slicer_BUILD_SEGMENTATION_SUPPORT "Build Slicer with Segmentation support." ON)
mark_as_advanced(Slicer_BUILD_SEGMENTATION_SUPPORT)
mark_as_superbuild(Slicer_BUILD_SEGMENTATION_SUPPORT)

option(Slicer_USE_SimpleITK "Build Slicer with SimpleITK support" ON)
mark_as_superbuild(Slicer_USE_SimpleITK)

Expand Down
15 changes: 13 additions & 2 deletions Libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ list(APPEND dirs
vtkAddon
vtkTeem
vtkITK
vtkSegmentationCore
)
if(Slicer_BUILD_SEGMENTATION_SUPPORT)
list(APPEND dirs
vtkSegmentationCore
)
endif()
list(APPEND dirs
FreeSurfer
MRML/Core
)
Expand Down Expand Up @@ -62,6 +68,9 @@ endif()
# Qt designer plugins
set(MRML_BUILD_QT_DESIGNER_PLUGINS ${Slicer_BUILD_QT_DESIGNER_PLUGINS})

# Segmentation support
set(MRML_BUILD_SEGMENTATION_SUPPORT ${Slicer_BUILD_SEGMENTATION_SUPPORT})

# ITKFactories directories
set(MRMLIDImageIO_ITKFACTORIES_DIR ${Slicer_ITKFACTORIES_DIR})
set(MRMLIDImageIO_INSTALL_ITKFACTORIES_DIR ${Slicer_INSTALL_ITKFACTORIES_DIR})
Expand Down Expand Up @@ -127,13 +136,15 @@ set(MRML_LIBRARIES ${_mrml_libraries} CACHE INTERNAL "MRML libraries" FORCE)
#-----------------------------------------------------------------------------
set(_vtk_wrapped_libraries
vtkAddon
vtkSegmentationCore
vtkTeem
vtkITK
FreeSurfer
MRMLCore
MRMLLogic
)
if(Slicer_BUILD_SEGMENTATION_SUPPORT)
list(APPEND _vtk_wrapped_libraries vtkSegmentationCore)
endif()
if(Slicer_USE_PYTHONQT AND VTK_WRAP_PYTHON)
list(APPEND _vtk_wrapped_libraries MRMLDisplayableManager)
endif()
Expand Down
40 changes: 28 additions & 12 deletions Libs/MRML/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ mark_as_advanced(MRML_SUPPORT_VERSION)
option(MRML_USE_vtkTeem "Build MRML with vtkTeem support." ON)
mark_as_advanced(MRML_USE_vtkTeem)

if(NOT DEFINED MRML_BUILD_SEGMENTATION_SUPPORT)
option(MRML_BUILD_SEGMENTATION_SUPPORT "Build MRML with Segmentation support" ON)
mark_as_advanced(MRML_BUILD_SEGMENTATION_SUPPORT)
endif()

# --------------------------------------------------------------------------
# Dependencies
# --------------------------------------------------------------------------
Expand Down Expand Up @@ -67,9 +72,11 @@ set(include_dirs
${CMAKE_CURRENT_BINARY_DIR}
${vtkAddon_INCLUDE_DIRS}
${vtkITK_INCLUDE_DIRS}
${vtkSegmentationCore_INCLUDE_DIRS}
${FreeSurfer_INCLUDE_DIRS}
)
if(MRML_BUILD_SEGMENTATION_SUPPORT)
list(APPEND include_dirs ${vtkSegmentationCore_INCLUDE_DIRS})
endif()
if(MRML_USE_vtkTeem)
list(APPEND include_dirs ${vtkTeem_INCLUDE_DIRS})
endif()
Expand Down Expand Up @@ -156,12 +163,6 @@ set(MRMLCore_SRCS
vtkMRMLSceneViewStorageNode.cxx
vtkMRMLScriptedModuleNode.cxx
vtkMRMLScriptedModuleNode.h
vtkMRMLSegmentationNode.cxx
vtkMRMLSegmentationNode.h
vtkMRMLSegmentationDisplayNode.cxx
vtkMRMLSegmentationDisplayNode.h
vtkMRMLSegmentationStorageNode.cxx
vtkMRMLSegmentationStorageNode.h
vtkMRMLSelectionNode.cxx
vtkMRMLSliceCompositeNode.cxx
vtkMRMLSliceNode.cxx
Expand Down Expand Up @@ -212,9 +213,19 @@ set(MRMLCore_SRCS
# register code to the vtkMRMLScene constructor
)

if(MRML_BUILD_SEGMENTATION_SUPPORT)
list(APPEND MRMLCore_SRCS
vtkMRMLSegmentationNode.cxx
vtkMRMLSegmentationNode.h
vtkMRMLSegmentationDisplayNode.cxx
vtkMRMLSegmentationDisplayNode.h
vtkMRMLSegmentationStorageNode.cxx
vtkMRMLSegmentationStorageNode.h
)
endif()

if(MRML_USE_vtkTeem)
set(MRMLCore_SRCS
${MRMLCore_SRCS}
list(APPEND MRMLCore_SRCS
vtkMRMLDiffusionImageVolumeNode.cxx
vtkMRMLDiffusionTensorVolumeDisplayNode.cxx
vtkMRMLDiffusionTensorVolumeNode.cxx
Expand Down Expand Up @@ -260,12 +271,14 @@ add_library(${lib_name} ${srcs})
set(libs
vtkAddon
vtkITK
vtkSegmentationCore
${ITK_LIBRARIES}
${VTK_LIBRARIES}
vtkIOInfovis
FreeSurfer
)
if(MRML_BUILD_SEGMENTATION_SUPPORT)
list(APPEND libs vtkSegmentationCore)
endif()
if(MRML_USE_vtkTeem)
list(APPEND libs vtkTeem)
endif()
Expand Down Expand Up @@ -381,5 +394,8 @@ endif()
# --------------------------------------------------------------------------
# Set INCLUDE_DIRS variable
# --------------------------------------------------------------------------
set(${PROJECT_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${vtkAddon_INCLUDE_DIRS} ${vtkSegmentationCore_INCLUDE_DIRS}
CACHE INTERNAL "${PROJECT_NAME} include dirs" FORCE)
set(_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${vtkAddon_INCLUDE_DIRS})
if(MRML_BUILD_SEGMENTATION_SUPPORT)
list(APPEND _include_dirs ${vtkSegmentationCore_INCLUDE_DIRS})
endif()
set(${PROJECT_NAME}_INCLUDE_DIRS ${_include_dirs} CACHE INTERNAL "${PROJECT_NAME} include dirs" FORCE)
1 change: 1 addition & 0 deletions Libs/MRML/Core/vtkMRMLConfigure.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define VTKMRML_STATIC
#endif

#cmakedefine MRML_BUILD_SEGMENTATION_SUPPORT
#cmakedefine MRML_USE_TEEM
#cmakedefine MRML_USE_vtkTeem

Expand Down
11 changes: 8 additions & 3 deletions Libs/MRML/Core/vtkMRMLScene.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ Version: $Revision: 1.18 $
#include "vtkMRMLROINode.h"
#include "vtkMRMLROIListNode.h"
#include "vtkMRMLScriptedModuleNode.h"
#include "vtkMRMLSegmentationDisplayNode.h"
#include "vtkMRMLSegmentationNode.h"
#include "vtkMRMLSegmentationStorageNode.h"
#include "vtkMRMLSelectionNode.h"
#include "vtkMRMLSliceCompositeNode.h"
#include "vtkMRMLSliceNode.h"
Expand All @@ -71,6 +68,12 @@ Version: $Revision: 1.18 $
#include "vtkMRMLCrosshairNode.h"
#include "vtkMRMLInteractionNode.h"

#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
#include "vtkMRMLSegmentationDisplayNode.h"
#include "vtkMRMLSegmentationNode.h"
#include "vtkMRMLSegmentationStorageNode.h"
#endif

#ifdef MRML_USE_vtkTeem
#include "vtkMRMLNRRDStorageNode.h"
#include "vtkMRMLDiffusionTensorVolumeDisplayNode.h"
Expand Down Expand Up @@ -171,9 +174,11 @@ vtkMRMLScene::vtkMRMLScene()
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLROIListNode >::New() );
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLSliceCompositeNode >::New() );
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLScriptedModuleNode >::New() );
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLSegmentationDisplayNode >::New() );
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLSegmentationNode >::New() );
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLSegmentationStorageNode >::New() );
#endif
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLSelectionNode >::New() );
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLSliceNode >::New() );
this->RegisterNodeClass( vtkSmartPointer< vtkMRMLVolumeArchetypeStorageNode >::New() );
Expand Down
28 changes: 27 additions & 1 deletion Libs/MRML/Widgets/qMRMLSegmentSelectorWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,25 @@

#include "ui_qMRMLSegmentSelectorWidget.h"

#include <vtkMRMLConfigure.h> // For MRML_BUILD_SEGMENTATION_SUPPORT

#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
#include "vtkMRMLSegmentationNode.h"
#include "vtkMRMLSegmentationDisplayNode.h"
#include "vtkSegmentation.h"
#include "vtkSegment.h"
#endif

// VYK includes
// VTK includes
#include <vtkWeakPointer.h>

// Qt includes
#include <QDebug>

//-----------------------------------------------------------------------------
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
static const char* NONE_DISPLAY = "None";
#endif

//-----------------------------------------------------------------------------
class qMRMLSegmentSelectorWidgetPrivate: public Ui_qMRMLSegmentSelectorWidget
Expand All @@ -54,8 +60,10 @@ class qMRMLSegmentSelectorWidgetPrivate: public Ui_qMRMLSegmentSelectorWidget
void setMessage(QString message);

public:
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
/// Segmentation MRML node containing shown segments
vtkWeakPointer<vtkMRMLSegmentationNode> SegmentationNode;
#endif

/// Current segment ID in case of single selection
QString CurrentSegmentID;
Expand All @@ -71,7 +79,9 @@ class qMRMLSegmentSelectorWidgetPrivate: public Ui_qMRMLSegmentSelectorWidget
//-----------------------------------------------------------------------------
qMRMLSegmentSelectorWidgetPrivate::qMRMLSegmentSelectorWidgetPrivate(qMRMLSegmentSelectorWidget& object)
: q_ptr(&object)
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
, SegmentationNode(NULL)
#endif
, MultiSelection(false)
{
}
Expand Down Expand Up @@ -133,6 +143,7 @@ qMRMLSegmentSelectorWidget::~qMRMLSegmentSelectorWidget()
//-----------------------------------------------------------------------------
void qMRMLSegmentSelectorWidget::onCurrentNodeChanged(vtkMRMLNode* node)
{
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
Q_D(qMRMLSegmentSelectorWidget);

vtkMRMLSegmentationNode* segmentationNode = vtkMRMLSegmentationNode::SafeDownCast(node);
Expand All @@ -149,6 +160,9 @@ void qMRMLSegmentSelectorWidget::onCurrentNodeChanged(vtkMRMLNode* node)
d->SegmentationNode = segmentationNode;
this->populateSegmentCombobox();
}
#else
Q_UNUSED(node);
#endif
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -182,6 +196,7 @@ QString qMRMLSegmentSelectorWidget::currentNodeID()
//-----------------------------------------------------------------------------
void qMRMLSegmentSelectorWidget::populateSegmentCombobox()
{
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
Q_D(qMRMLSegmentSelectorWidget);

d->comboBox_Segment->clear();
Expand Down Expand Up @@ -263,11 +278,13 @@ void qMRMLSegmentSelectorWidget::populateSegmentCombobox()
// Make sure fist segment is selected (we checked before that there is at least one segment)
d->comboBox_Segment->setCurrentIndex(this->noneEnabled() ? 1 : 0);
}
#endif
}

//-----------------------------------------------------------------------------
void qMRMLSegmentSelectorWidget::onCurrentSegmentChanged(int index)
{
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
Q_D(qMRMLSegmentSelectorWidget);

d->setMessage(QString());
Expand All @@ -289,11 +306,15 @@ void qMRMLSegmentSelectorWidget::onCurrentSegmentChanged(int index)
}

emit currentSegmentChanged(d->CurrentSegmentID);
#else
Q_UNUSED(index);
#endif
}

//-----------------------------------------------------------------------------
void qMRMLSegmentSelectorWidget::onSegmentMultiSelectionChanged()
{
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
Q_D(qMRMLSegmentSelectorWidget);

d->setMessage(QString());
Expand All @@ -310,6 +331,7 @@ void qMRMLSegmentSelectorWidget::onSegmentMultiSelectionChanged()
}

emit segmentSelectionChanged(d->SelectedSegmentIDs);
#endif
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -367,6 +389,7 @@ void qMRMLSegmentSelectorWidget::setCurrentSegmentID(QString segmentID)
//-----------------------------------------------------------------------------
void qMRMLSegmentSelectorWidget::setSelectedSegmentIDs(QStringList segmentIDList)
{
#ifdef MRML_BUILD_SEGMENTATION_SUPPORT
Q_D(qMRMLSegmentSelectorWidget);

if (!d->MultiSelection)
Expand Down Expand Up @@ -413,6 +436,9 @@ void qMRMLSegmentSelectorWidget::setSelectedSegmentIDs(QStringList segmentIDList
}
d->CheckableComboBox_Segment->blockSignals(wasBlocked);
d->CheckableComboBox_Segment->repaint();
#else
Q_UNUSED(segmentIDList);
#endif
}

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