-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: Add Pluggable Markups testing loadable module
- Loading branch information
Showing
21 changed files
with
1,722 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Modules/Loadable/Markups/Testing/Cxx/PluggableMarkupsTestModule/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
28 changes: 28 additions & 0 deletions
28
Modules/Loadable/Markups/Testing/Cxx/PluggableMarkupsTestModule/Logic/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
) |
126 changes: 126 additions & 0 deletions
126
...rkups/Testing/Cxx/PluggableMarkupsTestModule/Logic/vtkSlicerPluggableMarkupsTestLogic.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
50 changes: 50 additions & 0 deletions
50
...Markups/Testing/Cxx/PluggableMarkupsTestModule/Logic/vtkSlicerPluggableMarkupsTestLogic.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_ |
27 changes: 27 additions & 0 deletions
27
Modules/Loadable/Markups/Testing/Cxx/PluggableMarkupsTestModule/MRML/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
) |
42 changes: 42 additions & 0 deletions
42
...adable/Markups/Testing/Cxx/PluggableMarkupsTestModule/MRML/vtkMRMLMarkupsTestLineNode.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.