Skip to content

Commit

Permalink
ENH: Add Pluggable Markups testing loadable module
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafael Palomar authored and jcfr committed Apr 13, 2021
1 parent 0242927 commit bdd6b28
Show file tree
Hide file tree
Showing 21 changed files with 1,722 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Modules/Loadable/Markups/Testing/Cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ SIMPLE_TEST( vtkSlicerMarkupsLogicTest4 )
# test Slicer4 annotation fiducials in a mrml file
# TODO: remove this after annotation fiducials have been removed
SIMPLE_TEST( vtkMarkupsAnnotationSceneTest ${INPUT}/AnnotationTest/AnnotationFiducialsTest.mrml )

add_subdirectory(PluggableMarkupsTestModule)
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#-----------------------------------------------------------------------------
set(MODULE_NAME "PluggableMarkupsTest")
set(MODULE_TITLE ${MODULE_NAME})

string(TOUPPER ${MODULE_NAME} MODULE_NAME_UPPER)

#-----------------------------------------------------------------------------
add_subdirectory(MRML)
add_subdirectory(VTKWidgets)
add_subdirectory(Logic)
add_subdirectory(Widgets)

#-----------------------------------------------------------------------------
set(MODULE_EXPORT_DIRECTIVE "Q_SLICER_QTMODULES_${MODULE_NAME_UPPER}_EXPORT")

# Current_{source,binary} and Slicer_{Libs,Base} already included
set(MODULE_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/Logic
${CMAKE_CURRENT_BINARY_DIR}/Logic
${CMAKE_CURRENT_SOURCE_DIR}/MRML
${CMAKE_CURRENT_BINARY_DIR}/MRML
${CMAKE_CURRENT_SOURCE_DIR}/Widgets
${CMAKE_CURRENT_BINARY_DIR}/Widgets
)

set(MODULE_SRCS
qSlicer${MODULE_NAME}Module.cxx
qSlicer${MODULE_NAME}Module.h
)

set(MODULE_MOC_SRCS
qSlicer${MODULE_NAME}Module.h
)

set(MODULE_TARGET_LIBRARIES
vtkSlicer${MODULE_NAME}ModuleMRML
vtkSlicer${MODULE_NAME}ModuleLogic
vtkSlicer${MODULE_NAME}ModuleVTKWidgets
vtkSlicerMarkupsModuleVTKWidgets
vtkSlicerMarkupsModuleLogic
qSlicer${MODULE_NAME}ModuleWidgets
qSlicerMarkupsModuleWidgets
)

#-----------------------------------------------------------------------------
slicerMacroBuildLoadableModule(
NAME ${MODULE_NAME}
TITLE ${MODULE_TITLE}
EXPORT_DIRECTIVE ${MODULE_EXPORT_DIRECTIVE}
INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES}
SRCS ${MODULE_SRCS}
MOC_SRCS ${MODULE_MOC_SRCS}
TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES}
NO_INSTALL
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
project(vtkSlicer${MODULE_NAME}ModuleLogic)

set(KIT ${PROJECT_NAME})

set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_MODULE_LOGIC_EXPORT")

set(${KIT}_INCLUDE_DIRECTORIES
${CMAKE_CURRENT_BINARY_DIR}
)

set(${KIT}_SRCS
vtkSlicer${MODULE_NAME}Logic.cxx
vtkSlicer${MODULE_NAME}Logic.h
)

set(${KIT}_TARGET_LIBRARIES
vtkSlicer${MODULE_NAME}ModuleMRML
vtkSlicerMarkupsModuleLogic
)

#-----------------------------------------------------------------------------
SlicerMacroBuildModuleLogic(
NAME ${KIT}
EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE}
INCLUDE_DIRECTORIES ${${KIT}_INCLUDE_DIRECTORIES}
SRCS ${${KIT}_SRCS}
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*==============================================================================
Copyright (c) The Intervention Centre
Oslo University Hospital, Oslo, Norway. All Rights Reserved.
See COPYRIGHT.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file was originally developed by Rafael Palomar (The Intervention Centre,
Oslo University Hospital) and was supported by The Research Council of Norway
through the ALive project (grant nr. 311393).
==============================================================================*/

#include "vtkSlicerPluggableMarkupsTestLogic.h"

// Liver Markups MRML includes
#include "vtkMRMLMarkupsTestLineNode.h"

// QTGUI includes
#include <qSlicerApplication.h>

// MRML includes
#include <vtkMRMLScene.h>
#include <vtkMRMLSelectionNode.h>

// Markups logic includes
#include <vtkSlicerMarkupsLogic.h>

// Markups MRML includes
#include <vtkMRMLMarkupsDisplayNode.h>

// VTK includes
#include <vtkObjectFactory.h>

//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkSlicerPluggableMarkupsTestLogic);

//---------------------------------------------------------------------------
vtkSlicerPluggableMarkupsTestLogic::vtkSlicerPluggableMarkupsTestLogic()
{

}

//---------------------------------------------------------------------------
vtkSlicerPluggableMarkupsTestLogic::~vtkSlicerPluggableMarkupsTestLogic() = default;

//---------------------------------------------------------------------------
void vtkSlicerPluggableMarkupsTestLogic::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}

//-----------------------------------------------------------------------------
void vtkSlicerPluggableMarkupsTestLogic::RegisterNodes()
{
assert(this->GetMRMLScene() != nullptr);

vtkMRMLScene *scene = this->GetMRMLScene();

// Nodes
scene->RegisterNodeClass(vtkSmartPointer<vtkMRMLMarkupsTestLineNode>::New());
}

//---------------------------------------------------------------------------
void vtkSlicerPluggableMarkupsTestLogic::ObserveMRMLScene()
{
if (!this->GetMRMLScene())
{
return;
}

vtkMRMLApplicationLogic *mrmlAppLogic = this->GetMRMLApplicationLogic();
if (!mrmlAppLogic)
{
vtkErrorMacro("ObserveMRMLScene: invalid MRML Application Logic.") ;
return;
}

vtkMRMLNode* node =
this->GetMRMLScene()->GetNodeByID(this->GetSelectionNodeID().c_str());
if (!node)
{
vtkErrorMacro("Observe MRMLScene: invalid Selection Node");
return;
}

// If testing is enabled then we register the new markup
bool isTestingEnabled = qSlicerApplication::testAttribute(qSlicerCoreApplication::AA_EnableTesting);
if (isTestingEnabled)
{

// add known markup types to the selection node
vtkMRMLSelectionNode *selectionNode =
vtkMRMLSelectionNode::SafeDownCast(node);
if (selectionNode)
{
// got into batch process mode so that an update on the mouse mode tool
// bar is triggered when leave it
this->GetMRMLScene()->StartState(vtkMRMLScene::BatchProcessState);

auto testLineNode = vtkSmartPointer<vtkMRMLMarkupsTestLineNode>::New();

selectionNode->AddNewPlaceNodeClassNameToList(testLineNode->GetClassName(),
testLineNode->GetAddIcon(),
testLineNode->GetMarkupType());

// trigger an update on the mouse mode toolbar
this->GetMRMLScene()->EndState(vtkMRMLScene::BatchProcessState);
}
}

this->Superclass::ObserveMRMLScene();
}

//---------------------------------------------------------------------------
void vtkSlicerPluggableMarkupsTestLogic::OnMRMLSceneNodeAdded(vtkMRMLNode* node)
{
Superclass::OnMRMLSceneNodeAdded(node);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*==============================================================================
Copyright (c) The Intervention Centre
Oslo University Hospital, Oslo, Norway. All Rights Reserved.
See COPYRIGHT.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file was originally developed by Rafael Palomar (The Intervention Centre,
Oslo University Hospital) and was supported by The Research Council of Norway
through the ALive project (grant nr. 311393).
==============================================================================*/

#ifndef __vtkslicerlivermarkupslogic_h_
#define __vtkslicerlivermarkupslogic_h_

#include <vtkSlicerMarkupsLogic.h>

#include "vtkSlicerPluggableMarkupsTestModuleLogicExport.h"

class VTK_SLICER_PLUGGABLEMARKUPSTEST_MODULE_LOGIC_EXPORT vtkSlicerPluggableMarkupsTestLogic:
public vtkSlicerMarkupsLogic
{
public:
static vtkSlicerPluggableMarkupsTestLogic* New();
vtkTypeMacro(vtkSlicerPluggableMarkupsTestLogic, vtkSlicerMarkupsLogic);
void PrintSelf(ostream& os, vtkIndent indent) override;

protected:
vtkSlicerPluggableMarkupsTestLogic();
~vtkSlicerPluggableMarkupsTestLogic() override;

void ObserveMRMLScene() override;
void RegisterNodes() override;

void OnMRMLSceneNodeAdded(vtkMRMLNode* node) override;

private:
vtkSlicerPluggableMarkupsTestLogic(const vtkSlicerPluggableMarkupsTestLogic&) = delete;
void operator=(const vtkSlicerPluggableMarkupsTestLogic&) = delete;
};

#endif // __vtkslicerlivermarkupslogic_h_
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
project(vtkSlicer${MODULE_NAME}ModuleMRML)

set(KIT ${PROJECT_NAME})

set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_MODULE_MRML_EXPORT")

set(${KIT}_INCLUDE_DIRECTORIES
)

set(${KIT}_SRCS
vtkMRMLMarkupsTestLineNode.h
vtkMRMLMarkupsTestLineNode.cxx
)

set(${KIT}_TARGET_LIBRARIES
${MRML_LIBRARIES}
vtkSlicerMarkupsModuleMRML
)

#-----------------------------------------------------------------------------
SlicerMacroBuildModuleMRML(
NAME ${KIT}
EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE}
INCLUDE_DIRECTORIES ${${KIT}_INCLUDE_DIRECTORIES}
SRCS ${${KIT}_SRCS}
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*==============================================================================
Copyright (c) The Intervention Centre
Oslo University Hospital, Oslo, Norway. All Rights Reserved.
See COPYRIGHT.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file was originally developed by Rafael Palomar (The Intervention Centre,
Oslo University Hospital) and was supported by The Research Council of Norway
through the ALive project (grant nr. 311393).
==============================================================================*/

#include "vtkMRMLMarkupsTestLineNode.h"

// VTK includes
#include <vtkNew.h>
#include <vtkObjectFactory.h>

//--------------------------------------------------------------------------------
vtkMRMLNodeNewMacro(vtkMRMLMarkupsTestLineNode);

//--------------------------------------------------------------------------------
vtkMRMLMarkupsTestLineNode::vtkMRMLMarkupsTestLineNode()
{
}

//--------------------------------------------------------------------------------
vtkMRMLMarkupsTestLineNode::~vtkMRMLMarkupsTestLineNode()=default;

//----------------------------------------------------------------------------
void vtkMRMLMarkupsTestLineNode::PrintSelf(ostream& os, vtkIndent indent)
{
Superclass::PrintSelf(os,indent);
}
Loading

0 comments on commit bdd6b28

Please sign in to comment.