Commit 12ad922d authored by jcfr's avatar jcfr
Browse files

COMP: Add macro SlicerMacroBuildModuleMRML

The corresponding wrapped classes are imported into "slicer.modulemrml" python module

"slicer.modulemrml" is itself imported into slicer module.

git-svn-id: http://svn.slicer.org/Slicer4/trunk@16475 3bd1e089-480b-0410-8dfb-8563597acbee
parent 4beff992
...@@ -7,6 +7,7 @@ SET(Slicer_PYTHON_SCRIPTS ...@@ -7,6 +7,7 @@ SET(Slicer_PYTHON_SCRIPTS
slicer/slicerqt slicer/slicerqt
slicer/util slicer/util
slicer/modulelogic/__init__ slicer/modulelogic/__init__
slicer/modulemrml/__init__
mrml mrml
mrmlcli mrmlcli
mrmlLogic mrmlLogic
......
...@@ -14,7 +14,9 @@ __kits_to_load = [ ...@@ -14,7 +14,9 @@ __kits_to_load = [
'PythonQt.qSlicerBaseQTCore', 'PythonQt.qSlicerBaseQTCore',
'PythonQt.qSlicerBaseQTGUI', 'PythonQt.qSlicerBaseQTGUI',
# slicer module logic # slicer module logic
'modulelogic' 'modulelogic',
# slicer module mrml
'modulemrml'
#CLI logic #CLI logic
] ]
......
""" This module loads the Slicer Module MRML vtk classes into its namespace."""
import glob, os
# Retrieve list of modules
for fname in glob.glob(__path__[0] + "/vtkSlicer*ModuleMRML.py"):
# Extract module mrml name
module_mrml_name = os.path.splitext(os.path.basename(fname))[0]
# Import mrml library
try:
exec "import %s" % (module_mrml_name)
except ImportError as detail:
# TODO: this message should go in the application error log (how?)
print detail
continue
# ... and obtain a reference to the associated module
module_mrml = eval(module_mrml_name)
# Loop over content of the python module associated with the 'Module mrml library'
for item_name in dir(module_mrml):
# Obtain a reference associated with the current object
item = eval("%s.%s" % (module_mrml_name, item_name))
# Import the mrml vtk class if any
if type(item).__name__ == 'vtkclass':
exec("from %s import %s" % (module_mrml_name, item_name))
# Removing things the user shouldn't have to see.
del item, item_name
# Removing things the user shouldn't have to see.
exec("del %s" % (module_mrml_name))
del module_mrml, module_mrml_name
# Removing things the user shouldn't have to see.
del fname, glob, os
################################################################################
#
# Program: 3D Slicer
#
# Copyright (c) 2010 Kitware Inc.
#
# See Doc/copyright/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 Jean-Christophe Fillion-Robin, Kitware Inc.
# and was partially funded by NIH grant 3P41RR013218-12S1
#
################################################################################
#
# SlicerMacroBuildModuleMRML
#
MACRO(SlicerMacroBuildModuleMRML)
SLICER_PARSE_ARGUMENTS(MODULEMRML
"NAME;EXPORT_DIRECTIVE;SRCS;INCLUDE_DIRECTORIES;TARGET_LIBRARIES"
"DISABLE_WRAP_PYTHON"
${ARGN}
)
LIST(APPEND MODULEMRML_INCLUDE_DIRECTORIES
${Slicer_Libs_INCLUDE_DIRS}
${Slicer_ModuleMRML_INCLUDE_DIRS}
)
LIST(APPEND MODULEMRML_TARGET_LIBRARIES
${Slicer_Libs_LIBRARIES}
${Slicer_ModuleMRML_LIBRARIES}
)
SlicerMacroBuildModuleLibrary(
NAME ${MODULEMRML_NAME}
EXPORT_DIRECTIVE ${MODULEMRML_EXPORT_DIRECTIVE}
SRCS ${MODULEMRML_SRCS}
INCLUDE_DIRECTORIES ${MODULEMRML_INCLUDE_DIRECTORIES}
TARGET_LIBRARIES ${MODULEMRML_TARGET_LIBRARIES}
)
#-----------------------------------------------------------------------------
# Update Slicer_ModuleMRML_INCLUDE_DIRS and Slicer_ModuleMRML_LIBRARIES
#-----------------------------------------------------------------------------
SET(Slicer_ModuleMRML_INCLUDE_DIRS
${Slicer_ModuleMRML_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
CACHE INTERNAL "Slicer Module MRML includes" FORCE)
SET(Slicer_ModuleMRML_LIBRARIES
${Slicer_ModuleMRML_LIBRARIES}
${ModuleMRML_NAME}
CACHE INTERNAL "Slicer Module MRML libraries" FORCE)
# --------------------------------------------------------------------------
# Python wrapping
# --------------------------------------------------------------------------
IF(NOT ${MODULEMRML_DISABLE_WRAP_PYTHON} AND VTK_WRAP_PYTHON)
SET(Slicer_Wrapped_LIBRARIES
)
SlicerMacroPythonWrapModuleLibrary(
NAME ${MODULEMRML_NAME}
SRCS ${MODULEMRML_SRCS}
WRAPPED_TARGET_LIBRARIES ${Slicer_Wrapped_LIBRARIES}
RELATIVE_PYTHON_DIR "slicer/modulemrml"
)
ENDIF()
ENDMACRO()
...@@ -550,12 +550,17 @@ ADD_SUBDIRECTORY(Base) ...@@ -550,12 +550,17 @@ ADD_SUBDIRECTORY(Base)
ADD_SUBDIRECTORY(Resources) ADD_SUBDIRECTORY(Resources)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Module Logic # Macro useful to build ModuleLogic and ModuleMRML libraries
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
INCLUDE(SlicerMacroBuildModuleLibrary) INCLUDE(SlicerMacroBuildModuleLibrary)
INCLUDE(SlicerMacroPythonWrapModuleLibrary) INCLUDE(SlicerMacroPythonWrapModuleLibrary)
INCLUDE(SlicerMacroBuildModuleLogic) INCLUDE(SlicerMacroBuildModuleLogic)
INCLUDE(SlicerMacroBuildModuleMRML)
#-----------------------------------------------------------------------------
# Module Logic
#-----------------------------------------------------------------------------
# KWWidgets and Qt modules share the same logics typically located in the # KWWidgets and Qt modules share the same logics typically located in the
# kwwdigets modules. When KWWidgets is not build, the logic are missing for Qt # kwwdigets modules. When KWWidgets is not build, the logic are missing for Qt
......
...@@ -69,5 +69,6 @@ include(SlicerMacroParseArguments) ...@@ -69,5 +69,6 @@ include(SlicerMacroParseArguments)
include(SlicerMacroBuildModuleLibrary) include(SlicerMacroBuildModuleLibrary)
#include(SlicerMacroPythonWrapModuleLibrary) #include(SlicerMacroPythonWrapModuleLibrary)
include(SlicerMacroBuildModuleLogic) include(SlicerMacroBuildModuleLogic)
include(SlicerMacroBuildModuleMRML)
include(SlicerMacroBuildQtModule) include(SlicerMacroBuildQtModule)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment