From afc6122bf273faea2910ac40778fb7d779644435 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 22 Feb 2019 14:58:45 +0100 Subject: [PATCH 01/24] NEW first version of python for Qt5/PySide2 --- CMakeLists.txt | 2 +- python_sdk/CMakeLists.txt | 143 ------ python_sdk/actions/CMakeLists.txt | 24 - python_sdk/actions/application/CMakeLists.txt | 9 - .../global_sdk_actions_application.h | 23 - .../typesystem_sdk_actions_application.xml | 27 -- python_sdk/actions/global_sdk_actions.h | 5 - python_sdk/actions/image/CMakeLists.txt | 16 - .../image/arbitraryslice/CMakeLists.txt | 9 - .../global_sdk_actions_image_arbitraryslice.h | 6 - ...ystem_sdk_actions_image_arbitraryslice.xml | 8 - .../actions/image/cropvolume/CMakeLists.txt | 9 - .../global_sdk_actions_image_cropvolume.h | 5 - ...ypesystem_sdk_actions_image_cropvolume.xml | 8 - .../actions/image/global_sdk_actions_image.h | 8 - .../actions/image/imagelut/CMakeLists.txt | 9 - .../global_sdk_actions_image_imagelut.h | 4 - .../typesystem_sdk_actions_image_imagelut.xml | 8 - .../actions/image/multipicking/CMakeLists.txt | 9 - .../global_sdk_actions_image_multipicking.h | 7 - ...esystem_sdk_actions_image_multipicking.xml | 9 - .../image/reconstruction/CMakeLists.txt | 9 - .../global_sdk_actions_image_reconstruction.h | 4 - ...ystem_sdk_actions_image_reconstruction.xml | 7 - .../actions/image/showin3d/CMakeLists.txt | 9 - .../global_sdk_actions_image_showin3d.h | 7 - .../typesystem_sdk_actions_image_showin3d.xml | 11 - .../image/typesystem_sdk_actions_image.xml | 13 - .../image/volumerendering/CMakeLists.txt | 9 - ...global_sdk_actions_image_volumerendering.h | 8 - ...stem_sdk_actions_image_volumerendering.xml | 12 - python_sdk/actions/mesh/CMakeLists.txt | 16 - .../actions/mesh/basicmesh/CMakeLists.txt | 9 - .../global_sdk_actions_mesh_basicmesh.h | 10 - .../typesystem_sdk_actions_mesh_basicmesh.xml | 13 - .../actions/mesh/basictopology/CMakeLists.txt | 9 - .../global_sdk_actions_mesh_basictopology.h | 4 - ...esystem_sdk_actions_mesh_basictopology.xml | 8 - .../actions/mesh/global_sdk_actions_mesh.h | 7 - .../mesh/meshprocessing/CMakeLists.txt | 9 - .../global_sdk_actions_mesh_meshprocessing.h | 10 - ...system_sdk_actions_mesh_meshprocessing.xml | 15 - .../mesh/typesystem_sdk_actions_mesh.xml | 10 - python_sdk/actions/typesystem_sdk_actions.xml | 9 - python_sdk/applications/CMakeLists.txt | 24 - .../actionstatemachine/CMakeLists.txt | 8 - ...obal_sdk_applications_actionstatemachine.h | 3 - ...em_sdk_applications_actionstatemachine.xml | 5 - python_sdk/applications/config/CMakeLists.txt | 9 - .../config/global_sdk_applications_config.h | 3 - .../typesystem_sdk_applications_config.xml | 5 - .../applications/global_sdk_applications.h | 5 - python_sdk/applications/imp/CMakeLists.txt | 8 - .../imp/global_sdk_applications_imp.h | 3 - .../imp/typesystem_sdk_applications_imp.xml | 6 - .../typesystem_sdk_applications.xml | 10 - python_sdk/applications/wizard/CMakeLists.txt | 8 - .../wizard/global_sdk_applications_wizard.h | 3 - .../typesystem_sdk_applications_wizard.xml | 5 - python_sdk/components/CMakeLists.txt | 23 - python_sdk/components/global_sdk_components.h | 8 - python_sdk/components/msh/CMakeLists.txt | 8 - .../msh/global_sdk_components_msh.h | 4 - .../msh/typesystem_sdk_components_msh.xml | 5 - python_sdk/components/obj/CMakeLists.txt | 8 - .../obj/global_sdk_components_obj.h | 4 - .../obj/typesystem_sdk_components_obj.xml | 5 - python_sdk/components/off/CMakeLists.txt | 8 - .../off/global_sdk_components_off.h | 4 - .../off/typesystem_sdk_components_off.xml | 5 - .../components/typesystem_sdk_components.xml | 12 - python_sdk/components/vrml/CMakeLists.txt | 8 - .../vrml/global_sdk_components_vrml.h | 4 - .../vrml/typesystem_sdk_components_vrml.xml | 5 - python_sdk/components/vtkimage/CMakeLists.txt | 8 - .../vtkimage/global_sdk_components_vtkimage.h | 4 - .../typesystem_sdk_components_vtkimage.xml | 5 - python_sdk/components/vtkmesh/CMakeLists.txt | 8 - .../vtkmesh/global_sdk_components_vtkmesh.h | 4 - .../typesystem_sdk_components_vtkmesh.xml | 5 - python_sdk/global_sdk.h | 17 - python_sdk/libraries/CMakeLists.txt | 25 -- python_sdk/libraries/core/CMakeLists.txt | 16 - .../libraries/core/action/CMakeLists.txt | 8 - .../action/global_sdk_libraries_core_action.h | 7 - .../typesystem_sdk_libraries_core_action.xml | 10 - .../libraries/core/application/CMakeLists.txt | 8 - .../global_sdk_libraries_core_application.h | 9 - ...esystem_sdk_libraries_core_application.xml | 40 -- .../libraries/core/component/CMakeLists.txt | 16 - .../global_sdk_libraries_core_component.h | 12 - .../core/component/image/CMakeLists.txt | 8 - ...lobal_sdk_libraries_core_component_image.h | 6 - ...tem_sdk_libraries_core_component_image.xml | 10 - .../core/component/mesh/CMakeLists.txt | 8 - ...global_sdk_libraries_core_component_mesh.h | 6 - ...stem_sdk_libraries_core_component_mesh.xml | 9 - ...ypesystem_sdk_libraries_core_component.xml | 78 ---- .../core/global_sdk_libraries_core.h | 13 - .../core/typesystem_sdk_libraries_core.xml | 19 - .../libraries/core/utils/CMakeLists.txt | 8 - .../utils/global_sdk_libraries_core_utils.h | 11 - .../typesystem_sdk_libraries_core_utils.xml | 14 - .../libraries/core/viewer/CMakeLists.txt | 8 - .../viewer/global_sdk_libraries_core_viewer.h | 9 - .../typesystem_sdk_libraries_core_viewer.xml | 12 - .../libraries/coreschema/CMakeLists.txt | 8 - .../global_sdk_libraries_coreschema.h | 5 - .../typesystem_sdk_libraries_coreschema.xml | 6 - python_sdk/libraries/global_sdk_libraries.h | 7 - .../qtpropertybrowser/CMakeLists.txt | 8 - .../global_sdk_libraries_qtpropertybrowser.h | 5 - ...system_sdk_libraries_qtpropertybrowser.xml | 6 - .../libraries/typesystem_sdk_libraries.xml | 9 - python_sdk/pyside_global.h | 417 ------------------ python_sdk/typesystem_sdk.xml | 45 -- sdk/libraries/core/CMakeLists.txt | 4 +- 117 files changed, 3 insertions(+), 1720 deletions(-) delete mode 100644 python_sdk/CMakeLists.txt delete mode 100644 python_sdk/actions/CMakeLists.txt delete mode 100644 python_sdk/actions/application/CMakeLists.txt delete mode 100644 python_sdk/actions/application/global_sdk_actions_application.h delete mode 100644 python_sdk/actions/application/typesystem_sdk_actions_application.xml delete mode 100644 python_sdk/actions/global_sdk_actions.h delete mode 100644 python_sdk/actions/image/CMakeLists.txt delete mode 100644 python_sdk/actions/image/arbitraryslice/CMakeLists.txt delete mode 100644 python_sdk/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h delete mode 100644 python_sdk/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml delete mode 100644 python_sdk/actions/image/cropvolume/CMakeLists.txt delete mode 100644 python_sdk/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h delete mode 100644 python_sdk/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml delete mode 100644 python_sdk/actions/image/global_sdk_actions_image.h delete mode 100644 python_sdk/actions/image/imagelut/CMakeLists.txt delete mode 100644 python_sdk/actions/image/imagelut/global_sdk_actions_image_imagelut.h delete mode 100644 python_sdk/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml delete mode 100644 python_sdk/actions/image/multipicking/CMakeLists.txt delete mode 100644 python_sdk/actions/image/multipicking/global_sdk_actions_image_multipicking.h delete mode 100644 python_sdk/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml delete mode 100644 python_sdk/actions/image/reconstruction/CMakeLists.txt delete mode 100644 python_sdk/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h delete mode 100644 python_sdk/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml delete mode 100644 python_sdk/actions/image/showin3d/CMakeLists.txt delete mode 100644 python_sdk/actions/image/showin3d/global_sdk_actions_image_showin3d.h delete mode 100644 python_sdk/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml delete mode 100644 python_sdk/actions/image/typesystem_sdk_actions_image.xml delete mode 100644 python_sdk/actions/image/volumerendering/CMakeLists.txt delete mode 100644 python_sdk/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h delete mode 100644 python_sdk/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml delete mode 100644 python_sdk/actions/mesh/CMakeLists.txt delete mode 100644 python_sdk/actions/mesh/basicmesh/CMakeLists.txt delete mode 100644 python_sdk/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h delete mode 100644 python_sdk/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml delete mode 100644 python_sdk/actions/mesh/basictopology/CMakeLists.txt delete mode 100644 python_sdk/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h delete mode 100644 python_sdk/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml delete mode 100644 python_sdk/actions/mesh/global_sdk_actions_mesh.h delete mode 100644 python_sdk/actions/mesh/meshprocessing/CMakeLists.txt delete mode 100644 python_sdk/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h delete mode 100644 python_sdk/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml delete mode 100644 python_sdk/actions/mesh/typesystem_sdk_actions_mesh.xml delete mode 100644 python_sdk/actions/typesystem_sdk_actions.xml delete mode 100644 python_sdk/applications/CMakeLists.txt delete mode 100644 python_sdk/applications/actionstatemachine/CMakeLists.txt delete mode 100644 python_sdk/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h delete mode 100644 python_sdk/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml delete mode 100644 python_sdk/applications/config/CMakeLists.txt delete mode 100644 python_sdk/applications/config/global_sdk_applications_config.h delete mode 100644 python_sdk/applications/config/typesystem_sdk_applications_config.xml delete mode 100644 python_sdk/applications/global_sdk_applications.h delete mode 100644 python_sdk/applications/imp/CMakeLists.txt delete mode 100644 python_sdk/applications/imp/global_sdk_applications_imp.h delete mode 100644 python_sdk/applications/imp/typesystem_sdk_applications_imp.xml delete mode 100644 python_sdk/applications/typesystem_sdk_applications.xml delete mode 100644 python_sdk/applications/wizard/CMakeLists.txt delete mode 100644 python_sdk/applications/wizard/global_sdk_applications_wizard.h delete mode 100644 python_sdk/applications/wizard/typesystem_sdk_applications_wizard.xml delete mode 100644 python_sdk/components/CMakeLists.txt delete mode 100644 python_sdk/components/global_sdk_components.h delete mode 100644 python_sdk/components/msh/CMakeLists.txt delete mode 100644 python_sdk/components/msh/global_sdk_components_msh.h delete mode 100644 python_sdk/components/msh/typesystem_sdk_components_msh.xml delete mode 100644 python_sdk/components/obj/CMakeLists.txt delete mode 100644 python_sdk/components/obj/global_sdk_components_obj.h delete mode 100644 python_sdk/components/obj/typesystem_sdk_components_obj.xml delete mode 100644 python_sdk/components/off/CMakeLists.txt delete mode 100644 python_sdk/components/off/global_sdk_components_off.h delete mode 100644 python_sdk/components/off/typesystem_sdk_components_off.xml delete mode 100644 python_sdk/components/typesystem_sdk_components.xml delete mode 100644 python_sdk/components/vrml/CMakeLists.txt delete mode 100644 python_sdk/components/vrml/global_sdk_components_vrml.h delete mode 100644 python_sdk/components/vrml/typesystem_sdk_components_vrml.xml delete mode 100644 python_sdk/components/vtkimage/CMakeLists.txt delete mode 100644 python_sdk/components/vtkimage/global_sdk_components_vtkimage.h delete mode 100644 python_sdk/components/vtkimage/typesystem_sdk_components_vtkimage.xml delete mode 100644 python_sdk/components/vtkmesh/CMakeLists.txt delete mode 100644 python_sdk/components/vtkmesh/global_sdk_components_vtkmesh.h delete mode 100644 python_sdk/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml delete mode 100644 python_sdk/global_sdk.h delete mode 100644 python_sdk/libraries/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/action/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/action/global_sdk_libraries_core_action.h delete mode 100644 python_sdk/libraries/core/action/typesystem_sdk_libraries_core_action.xml delete mode 100644 python_sdk/libraries/core/application/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/application/global_sdk_libraries_core_application.h delete mode 100644 python_sdk/libraries/core/application/typesystem_sdk_libraries_core_application.xml delete mode 100644 python_sdk/libraries/core/component/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/component/global_sdk_libraries_core_component.h delete mode 100644 python_sdk/libraries/core/component/image/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/component/image/global_sdk_libraries_core_component_image.h delete mode 100644 python_sdk/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml delete mode 100644 python_sdk/libraries/core/component/mesh/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h delete mode 100644 python_sdk/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml delete mode 100644 python_sdk/libraries/core/component/typesystem_sdk_libraries_core_component.xml delete mode 100644 python_sdk/libraries/core/global_sdk_libraries_core.h delete mode 100644 python_sdk/libraries/core/typesystem_sdk_libraries_core.xml delete mode 100644 python_sdk/libraries/core/utils/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/utils/global_sdk_libraries_core_utils.h delete mode 100644 python_sdk/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml delete mode 100644 python_sdk/libraries/core/viewer/CMakeLists.txt delete mode 100644 python_sdk/libraries/core/viewer/global_sdk_libraries_core_viewer.h delete mode 100644 python_sdk/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml delete mode 100644 python_sdk/libraries/coreschema/CMakeLists.txt delete mode 100644 python_sdk/libraries/coreschema/global_sdk_libraries_coreschema.h delete mode 100644 python_sdk/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml delete mode 100644 python_sdk/libraries/global_sdk_libraries.h delete mode 100644 python_sdk/libraries/qtpropertybrowser/CMakeLists.txt delete mode 100644 python_sdk/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h delete mode 100644 python_sdk/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml delete mode 100644 python_sdk/libraries/typesystem_sdk_libraries.xml delete mode 100644 python_sdk/pyside_global.h delete mode 100644 python_sdk/typesystem_sdk.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 772a3924..a62b13ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ set(CAMITK_BINDING_PYTHON CACHE BOOL FALSE) # Consider python binding only if the CMake variable is checked if(CAMITK_BINDING_PYTHON) - add_subdirectory(python_sdk) + add_subdirectory(python) endif() diff --git a/python_sdk/CMakeLists.txt b/python_sdk/CMakeLists.txt deleted file mode 100644 index daa3666f..00000000 --- a/python_sdk/CMakeLists.txt +++ /dev/null @@ -1,143 +0,0 @@ -#-------------------------------------------- -# -# CamiTK SDK Python binding -# -# Do not edit this file, unless -# you really (really!) know -# what you're doing -# -#-------------------------------------------- - - -#-------------------------------------------- -# -# Python binding requirements -# -#-------------------------------------------- -# First of all needs : Python -find_package(PythonLibs REQUIRED) -# Then the Shiboken tool, the PySide team C++ to Python wrapper -find_package(Shiboken REQUIRED) -find_program(CAMITK_BINDING_PYTHON_GENERATOR shiboken REQUIRED) -if (NOT CAMITK_BINDING_PYTHON_GENERATOR) - message(FATAL_ERROR "Please add Shiboken binary in your PATH or manually point to it using the CAMITK_BINDING_PYTHON_GENERATOR variable") -endif() - -# And of course Qt and PySide, the Python binding of Qt (4.8) using Shiboken. -find_package(Qt4 REQUIRED) -find_package(PySide REQUIRED) - -# TEST Using VTK dependency -find_package(VTK REQUIRED) - -#-------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#-------------------------------------------- -# Shiboken PATH to look for typesystem.xml and global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# include subdirectories -add_subdirectory(actions) -add_subdirectory(applications) -add_subdirectory(components) -add_subdirectory(libraries) - -# TODO : Remove once debugged -# message(WARNING "PYSIDE_INCLUDE_DIR = ${PYSIDE_INCLUDE_DIR}") -# message(WARNING "SHIBOKEN_TYPESYSTEM_PATH = ${SHIBOKEN_TYPESYSTEM_PATH}") -# message(WARNING "SHIBOKEN_GLOBAL_H_PATH = ${SHIBOKEN_GLOBAL_H_PATH}") -# message(WARNING "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}") -# message(WARNING "QT_QTCORE_INCLUDE_DIR = ${QT_QTCORE_INCLUDE_DIR}") -# message(WARNING "SHIBOKEN_CAMITK_SDK_PATH = ${SHIBOKEN_CAMITK_SDK_PATH}") -# message(WARNING "VTK_INCLUDE_DIRS = ${VTK_INCLUDE_DIRS}") - -#-------------------------------------------- -# -# Custom CMake Python binding targets -# -#-------------------------------------------- -# Shiboken specific paths -set(PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN - ${PYSIDE_INCLUDE_DIR}:${PYSIDE_INCLUDE_DIR}/QtCore:${PYSIDE_INCLUDE_DIR}/QtGui - #:${PYSIDE_INCLUDE_DIR}/QtHelp:${PYSIDE_INCLUDE_DIR}/QtNetwork:${PYSIDE_INCLUDE_DIR}/QtOpenGL:${PYSIDE_INCLUDE_DIR}/QtScript:${PYSIDE_INCLUDE_DIR}/QtScriptTools:${PYSIDE_INCLUDE_DIR}/QtSql:${PYSIDE_INCLUDE_DIR}/QtSvg:${PYSIDE_INCLUDE_DIR}/QtTest:${PYSIDE_INCLUDE_DIR}/QtUiTools:${PYSIDE_INCLUDE_DIR}/QtWebKit:${PYSIDE_INCLUDE_DIR}/QtXml:${PYSIDE_INCLUDE_DIR}/QtXmlPatterns:${PYSIDE_INCLUDE_DIR}/QtDeclarative -) - -# TODO : Remove once debugged -# message(WARNING "PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN = ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}") - -# Wrap the CamiTK SDK. Wrapping uses Shiboken (PySide binding tool) -# It means it decorates the specified C++ classes to Python by adding -# information in order to convert it into a CPython extension -# Shiboken parses the typesystem.xml files to detect which C++ classes to expose to Python -# For each of them, it create a CPython C++ decorated class in the build directory -add_custom_target( camitk-sdk-wrap-to-python -# OUTPUT ${lib_python_SRC} - COMMAND ${CMAKE_COMMAND} -E echo "Cleaning C++ classes generated from previous wrapping." - COMMAND ${CMAKE_COMMAND} -E remove_directory camitk_sdk - COMMAND ${CMAKE_COMMAND} -E echo "Wrapping CamiTK SDK for Python exposure." - COMMAND ${CAMITK_BINDING_PYTHON_GENERATOR} --enable-parent-ctor-heuristic --enable-return-value-heuristic --enable-pyside-extensions #--debug-level=full - ${CMAKE_CURRENT_SOURCE_DIR}/global_sdk.h - --include-paths=${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}:${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}:${SHIBOKEN_GLOBAL_H_PATH}:${SHIBOKEN_CAMITK_SDK_PATH}:${VTK_INCLUDE_DIRS} - --typesystem-paths=${PYSIDE_TYPESYSTEMS}:${SHIBOKEN_TYPESYSTEM_PATH} - --output-directory=${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_sdk.xml -# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -# COMMENT "Running generator for ${PROJECT_NAME}:" - COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK wrapped." - ) - -# The resulting C++ wrapped classes will be listed in the following CMake variable: -file(GLOB_RECURSE SDK_WRAPPED_CLASSES ${CMAKE_BINARY_DIR}/python_sdk/camitk_sdk/*.cpp ) - -# We list the CamiTK SDK generated dynamic libraries for linking the python package -# TODO do not manually list those libraries, but dynamically create this list at configuration -# step, using CamiTK CMake macros -file(GLOB_RECURSE CAMITK_SDK_LIBRARIES ${CMAKE_BINARY_DIR}/*.so) -# message(WARNING "CAMITK_SDK_LIBRARIES = ${CAMITK_SDK_LIBRARIES}") - -# This CMake target aims at compiling the C++ Python-wrapped classes of CamiTK and link them against -# the original CamiTK SDK libraries. -# WARNING Do not manually run this target, it requires another configure step wich is run by the camitk-sdk-package-to-python -# CMake target. -if(NOT SDK_WRAPPED_CLASSES STREQUAL "") # only create camitk_sdk target if camitk sdk has been wrapped - set(PROJECT_NAME camitk_sdk) # the name of the camitk sdk package once compiled - string(REPLACE ":" ";" CAMITK_SDK_INCLUDE_DIR ${SHIBOKEN_CAMITK_SDK_PATH}) # deduce the list of include directories of CamiTK SDK - string(REPLACE ":" ";" PYSIDE_INCLUDE_ALL_DIR ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}) #deduce the list of include directories provided from PySide / Shiboken - # Qt libraries dependencies - set(QT_LIBRARIES "${QT_QTCORE_LIBRARY};${QT_QTGUI_LIBRARY}") -# message(WARNING "QT_LIBRARIES = ${QT_LIBRARIES}") - set(CAMITK_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../sdk/libraries/core - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/mesh/basicmesh - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/arbitraryslice ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/cropvolume - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/imagelut - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/multipicking ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/reconstruction - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/volumerendering - ) #build directories required for ui wrapping includes ! - - include_directories(${PROJECT_NAME} ${CAMITK_SDK_INCLUDE_DIR} ${PYSIDE_INCLUDE_ALL_DIR} ${SHIBOKEN_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${VTK_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CAMITK_BUILD_DIR}) - add_library(${PROJECT_NAME} SHARED ${SDK_WRAPPED_CLASSES}) - # # set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") - set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") - target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${VTK_LIBRARIES} ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${CAMITK_SDK_LIBRARIES}) - # WARNING check VTK dependency -# message(WARNING "SHIBOKEN_PYTHON_LIBRARIES = ${SHIBOKEN_PYTHON_LIBRARIES}") -# message(WARNING "SHIBOKEN_LIBRARY = ${SHIBOKEN_LIBRARY}") - # add_dependencies(${PROJECT_NAME} camitkcore) -endif() - - -# Create the Python package of CamiTK SDK -# This package is compiled from the generated C++ classes of the camitk-sdk-wrap-to-python target -# and link against the CamiTK SDK libraries. -# Build the custom camitk-sdk-package-to-python target in order to compile the wrapped C++ classes and link against -# CamiTK SDK dynamic libraries. -add_custom_target( camitk-sdk-package-to-python - COMMAND ${CMAKE_COMMAND} -E echo "Creating Python package of CamiTK SDK." - COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target camitk_sdk - COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK Python package created." - ) -add_dependencies(camitk-sdk-package-to-python camitk-sdk-wrap-to-python) # need to wrapp before creating the package diff --git a/python_sdk/actions/CMakeLists.txt b/python_sdk/actions/CMakeLists.txt deleted file mode 100644 index 489c8057..00000000 --- a/python_sdk/actions/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# -# DO NOT EDIT THIS FILE (unless you REALLY know what you are doing) -# -# To add a component, just add a subdirectory (the component name is the -# directory name). Add all your code there and a text file called -# CMakeLists.txt -# In your CMakeLists.txt, use the camitk_extension(ACTION_EXTENSION ...) macro appropriately -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# find components -get_subdirectories(ACTIONS_MESH_LIST) - -# Add subdirectories in CMake project -foreach(ACTION_NAME ${ACTIONS_MESH_LIST}) - add_subdirectory(${ACTION_NAME}) -endforeach() - diff --git a/python_sdk/actions/application/CMakeLists.txt b/python_sdk/actions/application/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/application/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/application/global_sdk_actions_application.h b/python_sdk/actions/application/global_sdk_actions_application.h deleted file mode 100644 index e2ac564c..00000000 --- a/python_sdk/actions/application/global_sdk_actions_application.h +++ /dev/null @@ -1,23 +0,0 @@ -// local header files -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - diff --git a/python_sdk/actions/application/typesystem_sdk_actions_application.xml b/python_sdk/actions/application/typesystem_sdk_actions_application.xml deleted file mode 100644 index 78563dee..00000000 --- a/python_sdk/actions/application/typesystem_sdk_actions_application.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/python_sdk/actions/global_sdk_actions.h b/python_sdk/actions/global_sdk_actions.h deleted file mode 100644 index 0123593c..00000000 --- a/python_sdk/actions/global_sdk_actions.h +++ /dev/null @@ -1,5 +0,0 @@ -// subdirectories header files -#include "./application/global_sdk_actions_application.h" -#include "./image/global_sdk_actions_image.h" -#include "./mesh/global_sdk_actions_mesh.h" - diff --git a/python_sdk/actions/image/CMakeLists.txt b/python_sdk/actions/image/CMakeLists.txt deleted file mode 100644 index 31f261cf..00000000 --- a/python_sdk/actions/image/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# find actions -get_subdirectories(ACTIONS_IMAGE_LIST) - -# Add subdirectories in CMake project -foreach(ACTION_NAME ${ACTIONS_IMAGE_LIST}) - add_subdirectory(${ACTION_NAME}) -endforeach() \ No newline at end of file diff --git a/python_sdk/actions/image/arbitraryslice/CMakeLists.txt b/python_sdk/actions/image/arbitraryslice/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/image/arbitraryslice/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h b/python_sdk/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h deleted file mode 100644 index 271f06a9..00000000 --- a/python_sdk/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h +++ /dev/null @@ -1,6 +0,0 @@ -// local header files -#include -#include -#include - - diff --git a/python_sdk/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml b/python_sdk/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml deleted file mode 100644 index 59a8d9fe..00000000 --- a/python_sdk/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/python_sdk/actions/image/cropvolume/CMakeLists.txt b/python_sdk/actions/image/cropvolume/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/image/cropvolume/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h b/python_sdk/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h deleted file mode 100644 index a188dcb7..00000000 --- a/python_sdk/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h +++ /dev/null @@ -1,5 +0,0 @@ -// local header files -#include -#include -#include - diff --git a/python_sdk/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml b/python_sdk/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml deleted file mode 100644 index 18d49759..00000000 --- a/python_sdk/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/python_sdk/actions/image/global_sdk_actions_image.h b/python_sdk/actions/image/global_sdk_actions_image.h deleted file mode 100644 index eeabce11..00000000 --- a/python_sdk/actions/image/global_sdk_actions_image.h +++ /dev/null @@ -1,8 +0,0 @@ -// local header files -#include "./arbitraryslice/global_sdk_actions_image_arbitraryslice.h" -#include "./cropvolume/global_sdk_actions_image_cropvolume.h" -#include "./imagelut/global_sdk_actions_image_imagelut.h" -#include "./multipicking/global_sdk_actions_image_multipicking.h" -#include "./reconstruction/global_sdk_actions_image_reconstruction.h" -#include "./showin3d/global_sdk_actions_image_showin3d.h" -#include "./volumerendering/global_sdk_actions_image_volumerendering.h" \ No newline at end of file diff --git a/python_sdk/actions/image/imagelut/CMakeLists.txt b/python_sdk/actions/image/imagelut/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/image/imagelut/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/image/imagelut/global_sdk_actions_image_imagelut.h b/python_sdk/actions/image/imagelut/global_sdk_actions_image_imagelut.h deleted file mode 100644 index fcf92947..00000000 --- a/python_sdk/actions/image/imagelut/global_sdk_actions_image_imagelut.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files -#include -#include -#include diff --git a/python_sdk/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml b/python_sdk/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml deleted file mode 100644 index 6a4ded74..00000000 --- a/python_sdk/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/python_sdk/actions/image/multipicking/CMakeLists.txt b/python_sdk/actions/image/multipicking/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/image/multipicking/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/image/multipicking/global_sdk_actions_image_multipicking.h b/python_sdk/actions/image/multipicking/global_sdk_actions_image_multipicking.h deleted file mode 100644 index 1e43cdbc..00000000 --- a/python_sdk/actions/image/multipicking/global_sdk_actions_image_multipicking.h +++ /dev/null @@ -1,7 +0,0 @@ -// local header files -#include -#include -#include -#include -#include - diff --git a/python_sdk/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml b/python_sdk/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml deleted file mode 100644 index 5f510995..00000000 --- a/python_sdk/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/python_sdk/actions/image/reconstruction/CMakeLists.txt b/python_sdk/actions/image/reconstruction/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/image/reconstruction/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h b/python_sdk/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h deleted file mode 100644 index 2d06b1be..00000000 --- a/python_sdk/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files -#include -#include - diff --git a/python_sdk/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml b/python_sdk/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml deleted file mode 100644 index 4b1ef49e..00000000 --- a/python_sdk/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/python_sdk/actions/image/showin3d/CMakeLists.txt b/python_sdk/actions/image/showin3d/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/image/showin3d/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/image/showin3d/global_sdk_actions_image_showin3d.h b/python_sdk/actions/image/showin3d/global_sdk_actions_image_showin3d.h deleted file mode 100644 index 909de37a..00000000 --- a/python_sdk/actions/image/showin3d/global_sdk_actions_image_showin3d.h +++ /dev/null @@ -1,7 +0,0 @@ -// local header files -#include -#include -#include -#include -#include -#include diff --git a/python_sdk/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml b/python_sdk/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml deleted file mode 100644 index 386fbcb0..00000000 --- a/python_sdk/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/python_sdk/actions/image/typesystem_sdk_actions_image.xml b/python_sdk/actions/image/typesystem_sdk_actions_image.xml deleted file mode 100644 index 35abd1ef..00000000 --- a/python_sdk/actions/image/typesystem_sdk_actions_image.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/python_sdk/actions/image/volumerendering/CMakeLists.txt b/python_sdk/actions/image/volumerendering/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/image/volumerendering/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h b/python_sdk/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h deleted file mode 100644 index b06c8387..00000000 --- a/python_sdk/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h +++ /dev/null @@ -1,8 +0,0 @@ -// local header files -#include -#include -#include -#include -#include -#include - diff --git a/python_sdk/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml b/python_sdk/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml deleted file mode 100644 index 8e4a4ada..00000000 --- a/python_sdk/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/python_sdk/actions/mesh/CMakeLists.txt b/python_sdk/actions/mesh/CMakeLists.txt deleted file mode 100644 index a5c25355..00000000 --- a/python_sdk/actions/mesh/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# find mesh component -get_subdirectories(MESHCOMP_LIST) - -# Add subdirectories in CMake project -foreach(MESHCOMP_NAME ${MESHCOMP_LIST}) - add_subdirectory(${MESHCOMP_NAME}) -endforeach() diff --git a/python_sdk/actions/mesh/basicmesh/CMakeLists.txt b/python_sdk/actions/mesh/basicmesh/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/mesh/basicmesh/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h b/python_sdk/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h deleted file mode 100644 index f142d0df..00000000 --- a/python_sdk/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h +++ /dev/null @@ -1,10 +0,0 @@ -// local header files -#include -#include -#include -#include -#include -#include -#include -#include - diff --git a/python_sdk/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml b/python_sdk/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml deleted file mode 100644 index 67c59fbc..00000000 --- a/python_sdk/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/python_sdk/actions/mesh/basictopology/CMakeLists.txt b/python_sdk/actions/mesh/basictopology/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/mesh/basictopology/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h b/python_sdk/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h deleted file mode 100644 index 406f374d..00000000 --- a/python_sdk/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files -#include -#include -#include diff --git a/python_sdk/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml b/python_sdk/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml deleted file mode 100644 index f835eaa7..00000000 --- a/python_sdk/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/python_sdk/actions/mesh/global_sdk_actions_mesh.h b/python_sdk/actions/mesh/global_sdk_actions_mesh.h deleted file mode 100644 index dc0a39f0..00000000 --- a/python_sdk/actions/mesh/global_sdk_actions_mesh.h +++ /dev/null @@ -1,7 +0,0 @@ -// subdirectories header files -#include "./basicmesh/global_sdk_actions_mesh_basicmesh.h" -#include "./basictopology/global_sdk_actions_mesh_basictopology.h" -#include "./meshprocessing/global_sdk_actions_mesh_meshprocessing.h" - -// local header files - diff --git a/python_sdk/actions/mesh/meshprocessing/CMakeLists.txt b/python_sdk/actions/mesh/meshprocessing/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/actions/mesh/meshprocessing/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h b/python_sdk/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h deleted file mode 100644 index 112902cd..00000000 --- a/python_sdk/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h +++ /dev/null @@ -1,10 +0,0 @@ -// local header files -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/python_sdk/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml b/python_sdk/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml deleted file mode 100644 index ee3cf831..00000000 --- a/python_sdk/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/python_sdk/actions/mesh/typesystem_sdk_actions_mesh.xml b/python_sdk/actions/mesh/typesystem_sdk_actions_mesh.xml deleted file mode 100644 index a060c404..00000000 --- a/python_sdk/actions/mesh/typesystem_sdk_actions_mesh.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/python_sdk/actions/typesystem_sdk_actions.xml b/python_sdk/actions/typesystem_sdk_actions.xml deleted file mode 100644 index 0da9df76..00000000 --- a/python_sdk/actions/typesystem_sdk_actions.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/python_sdk/applications/CMakeLists.txt b/python_sdk/applications/CMakeLists.txt deleted file mode 100644 index f46746a4..00000000 --- a/python_sdk/applications/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# -# DO NOT EDIT THIS FILE (unless you REALLY know what you are doing) -# -# To add an application, just add a subdirectory (the application name is the -# directory name). Add all your code there and a text file called -# CMakeLists.txt -# In your CMakeLists.txt, use the camitk_application() macro appropriately - -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# Find applications -get_subdirectories(APPLICATIONS_LIST) - -# --- add every given application -foreach(APPLICATION_NAME ${APPLICATIONS_LIST}) - add_subdirectory(${APPLICATION_NAME}) -endforeach() diff --git a/python_sdk/applications/actionstatemachine/CMakeLists.txt b/python_sdk/applications/actionstatemachine/CMakeLists.txt deleted file mode 100644 index 6074ca53..00000000 --- a/python_sdk/applications/actionstatemachine/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h b/python_sdk/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h deleted file mode 100644 index 043409e3..00000000 --- a/python_sdk/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h +++ /dev/null @@ -1,3 +0,0 @@ -// local header files - - diff --git a/python_sdk/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml b/python_sdk/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml deleted file mode 100644 index a6d50676..00000000 --- a/python_sdk/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/python_sdk/applications/config/CMakeLists.txt b/python_sdk/applications/config/CMakeLists.txt deleted file mode 100644 index 653139d0..00000000 --- a/python_sdk/applications/config/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - diff --git a/python_sdk/applications/config/global_sdk_applications_config.h b/python_sdk/applications/config/global_sdk_applications_config.h deleted file mode 100644 index 043409e3..00000000 --- a/python_sdk/applications/config/global_sdk_applications_config.h +++ /dev/null @@ -1,3 +0,0 @@ -// local header files - - diff --git a/python_sdk/applications/config/typesystem_sdk_applications_config.xml b/python_sdk/applications/config/typesystem_sdk_applications_config.xml deleted file mode 100644 index a584aed0..00000000 --- a/python_sdk/applications/config/typesystem_sdk_applications_config.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/python_sdk/applications/global_sdk_applications.h b/python_sdk/applications/global_sdk_applications.h deleted file mode 100644 index 850b3b5f..00000000 --- a/python_sdk/applications/global_sdk_applications.h +++ /dev/null @@ -1,5 +0,0 @@ -// subdirectories header files -#include "./actionstatemachine/global_sdk_applications_actionstatemachine.h" -#include "./config/global_sdk_applications_config.h" -#include "./imp/global_sdk_applications_imp.h" -#include "./wizard/global_sdk_applications_wizard.h" diff --git a/python_sdk/applications/imp/CMakeLists.txt b/python_sdk/applications/imp/CMakeLists.txt deleted file mode 100644 index 6074ca53..00000000 --- a/python_sdk/applications/imp/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/applications/imp/global_sdk_applications_imp.h b/python_sdk/applications/imp/global_sdk_applications_imp.h deleted file mode 100644 index 3b5ea92c..00000000 --- a/python_sdk/applications/imp/global_sdk_applications_imp.h +++ /dev/null @@ -1,3 +0,0 @@ -// local header files -#include - diff --git a/python_sdk/applications/imp/typesystem_sdk_applications_imp.xml b/python_sdk/applications/imp/typesystem_sdk_applications_imp.xml deleted file mode 100644 index 9673db75..00000000 --- a/python_sdk/applications/imp/typesystem_sdk_applications_imp.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/python_sdk/applications/typesystem_sdk_applications.xml b/python_sdk/applications/typesystem_sdk_applications.xml deleted file mode 100644 index 8e224c14..00000000 --- a/python_sdk/applications/typesystem_sdk_applications.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/python_sdk/applications/wizard/CMakeLists.txt b/python_sdk/applications/wizard/CMakeLists.txt deleted file mode 100644 index 6074ca53..00000000 --- a/python_sdk/applications/wizard/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/applications/wizard/global_sdk_applications_wizard.h b/python_sdk/applications/wizard/global_sdk_applications_wizard.h deleted file mode 100644 index 043409e3..00000000 --- a/python_sdk/applications/wizard/global_sdk_applications_wizard.h +++ /dev/null @@ -1,3 +0,0 @@ -// local header files - - diff --git a/python_sdk/applications/wizard/typesystem_sdk_applications_wizard.xml b/python_sdk/applications/wizard/typesystem_sdk_applications_wizard.xml deleted file mode 100644 index a584aed0..00000000 --- a/python_sdk/applications/wizard/typesystem_sdk_applications_wizard.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/python_sdk/components/CMakeLists.txt b/python_sdk/components/CMakeLists.txt deleted file mode 100644 index 476aba6a..00000000 --- a/python_sdk/components/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# -# DO NOT EDIT THIS FILE (unless you REALLY know what you are doing) -# -# To add a component, just add a subdirectory (the component name is the -# directory name). Add all your code there and a text file called -# CMakeLists.txt -# In your CMakeLists.txt, use the camitk_extension(COMPONENT_EXTENSION ...) macro appropriately -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# find components -get_subdirectories(COMPONENTS_LIST) - -# Add subdirectories in CMake project -foreach(COMPONENT_NAME ${COMPONENTS_LIST}) - add_subdirectory(${COMPONENT_NAME}) -endforeach() \ No newline at end of file diff --git a/python_sdk/components/global_sdk_components.h b/python_sdk/components/global_sdk_components.h deleted file mode 100644 index e15e563a..00000000 --- a/python_sdk/components/global_sdk_components.h +++ /dev/null @@ -1,8 +0,0 @@ -// subdirectories header files -#include "./msh/global_sdk_components_msh.h" -#include "./obj/global_sdk_components_obj.h" -#include "./off/global_sdk_components_off.h" -#include "./vrml/global_sdk_components_vrml.h" -#include "./vtkimage/global_sdk_components_vtkimage.h" -#include "./vtkmesh/global_sdk_components_vtkmesh.h" - diff --git a/python_sdk/components/msh/CMakeLists.txt b/python_sdk/components/msh/CMakeLists.txt deleted file mode 100644 index 6074ca53..00000000 --- a/python_sdk/components/msh/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/components/msh/global_sdk_components_msh.h b/python_sdk/components/msh/global_sdk_components_msh.h deleted file mode 100644 index dd07d64b..00000000 --- a/python_sdk/components/msh/global_sdk_components_msh.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files - - - diff --git a/python_sdk/components/msh/typesystem_sdk_components_msh.xml b/python_sdk/components/msh/typesystem_sdk_components_msh.xml deleted file mode 100644 index 4bb90f32..00000000 --- a/python_sdk/components/msh/typesystem_sdk_components_msh.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/python_sdk/components/obj/CMakeLists.txt b/python_sdk/components/obj/CMakeLists.txt deleted file mode 100644 index 0e30981b..00000000 --- a/python_sdk/components/obj/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/components/obj/global_sdk_components_obj.h b/python_sdk/components/obj/global_sdk_components_obj.h deleted file mode 100644 index dd07d64b..00000000 --- a/python_sdk/components/obj/global_sdk_components_obj.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files - - - diff --git a/python_sdk/components/obj/typesystem_sdk_components_obj.xml b/python_sdk/components/obj/typesystem_sdk_components_obj.xml deleted file mode 100644 index 4bb90f32..00000000 --- a/python_sdk/components/obj/typesystem_sdk_components_obj.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/python_sdk/components/off/CMakeLists.txt b/python_sdk/components/off/CMakeLists.txt deleted file mode 100644 index 0e30981b..00000000 --- a/python_sdk/components/off/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/components/off/global_sdk_components_off.h b/python_sdk/components/off/global_sdk_components_off.h deleted file mode 100644 index dd07d64b..00000000 --- a/python_sdk/components/off/global_sdk_components_off.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files - - - diff --git a/python_sdk/components/off/typesystem_sdk_components_off.xml b/python_sdk/components/off/typesystem_sdk_components_off.xml deleted file mode 100644 index 4bb90f32..00000000 --- a/python_sdk/components/off/typesystem_sdk_components_off.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/python_sdk/components/typesystem_sdk_components.xml b/python_sdk/components/typesystem_sdk_components.xml deleted file mode 100644 index 28854575..00000000 --- a/python_sdk/components/typesystem_sdk_components.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/python_sdk/components/vrml/CMakeLists.txt b/python_sdk/components/vrml/CMakeLists.txt deleted file mode 100644 index 6074ca53..00000000 --- a/python_sdk/components/vrml/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/components/vrml/global_sdk_components_vrml.h b/python_sdk/components/vrml/global_sdk_components_vrml.h deleted file mode 100644 index dd07d64b..00000000 --- a/python_sdk/components/vrml/global_sdk_components_vrml.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files - - - diff --git a/python_sdk/components/vrml/typesystem_sdk_components_vrml.xml b/python_sdk/components/vrml/typesystem_sdk_components_vrml.xml deleted file mode 100644 index 4bb90f32..00000000 --- a/python_sdk/components/vrml/typesystem_sdk_components_vrml.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/python_sdk/components/vtkimage/CMakeLists.txt b/python_sdk/components/vtkimage/CMakeLists.txt deleted file mode 100644 index 0e30981b..00000000 --- a/python_sdk/components/vtkimage/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/components/vtkimage/global_sdk_components_vtkimage.h b/python_sdk/components/vtkimage/global_sdk_components_vtkimage.h deleted file mode 100644 index dd07d64b..00000000 --- a/python_sdk/components/vtkimage/global_sdk_components_vtkimage.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files - - - diff --git a/python_sdk/components/vtkimage/typesystem_sdk_components_vtkimage.xml b/python_sdk/components/vtkimage/typesystem_sdk_components_vtkimage.xml deleted file mode 100644 index 4bb90f32..00000000 --- a/python_sdk/components/vtkimage/typesystem_sdk_components_vtkimage.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/python_sdk/components/vtkmesh/CMakeLists.txt b/python_sdk/components/vtkmesh/CMakeLists.txt deleted file mode 100644 index 0e30981b..00000000 --- a/python_sdk/components/vtkmesh/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/components/vtkmesh/global_sdk_components_vtkmesh.h b/python_sdk/components/vtkmesh/global_sdk_components_vtkmesh.h deleted file mode 100644 index dd07d64b..00000000 --- a/python_sdk/components/vtkmesh/global_sdk_components_vtkmesh.h +++ /dev/null @@ -1,4 +0,0 @@ -// local header files - - - diff --git a/python_sdk/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml b/python_sdk/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml deleted file mode 100644 index 4bb90f32..00000000 --- a/python_sdk/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/python_sdk/global_sdk.h b/python_sdk/global_sdk.h deleted file mode 100644 index 0690477a..00000000 --- a/python_sdk/global_sdk.h +++ /dev/null @@ -1,17 +0,0 @@ -#undef QT_NO_STL -#undef QT_NO_STL_WCHAR - -#ifndef NULL -#define NULL 0 -#endif - -// the PySide global.h file, containing common Qt Python declaration -#include "pyside_global.h" - -// subdirectories header files -#include "./actions/global_sdk_actions.h" -#include "./applications/global_sdk_applications.h" -#include "./components/global_sdk_components.h" -#include "./libraries/global_sdk_libraries.h" - -// include here the classes you want to be exposed to Python diff --git a/python_sdk/libraries/CMakeLists.txt b/python_sdk/libraries/CMakeLists.txt deleted file mode 100644 index 2d0bbc1e..00000000 --- a/python_sdk/libraries/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# -# DO NOT EDIT THIS FILE (unless you REALLY know what you are doing) -# -# To add a library, just add a subdirectory (the application name is the -# directory name). Add all your code there and a text file called -# CMakeLists.txt -# In your CMakeLists.txt, use the camitk_library() macro appropriately - -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# Find libraries -get_subdirectories(LIBRARY_LIST) - -# --- add every given library -foreach(LIB_NAME ${LIBRARY_LIST}) - add_subdirectory(${LIB_NAME}) -endforeach() - diff --git a/python_sdk/libraries/core/CMakeLists.txt b/python_sdk/libraries/core/CMakeLists.txt deleted file mode 100644 index 65b80db4..00000000 --- a/python_sdk/libraries/core/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# Find core subdirectories -get_subdirectories(CORE_SUBDIR_LIST) - -# --- add every given library -foreach(LIB_NAME ${CORE_SUBDIR_LIST}) - add_subdirectory(${LIB_NAME}) -endforeach() \ No newline at end of file diff --git a/python_sdk/libraries/core/action/CMakeLists.txt b/python_sdk/libraries/core/action/CMakeLists.txt deleted file mode 100644 index 6074ca53..00000000 --- a/python_sdk/libraries/core/action/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/libraries/core/action/global_sdk_libraries_core_action.h b/python_sdk/libraries/core/action/global_sdk_libraries_core_action.h deleted file mode 100644 index d5455394..00000000 --- a/python_sdk/libraries/core/action/global_sdk_libraries_core_action.h +++ /dev/null @@ -1,7 +0,0 @@ -// local header files -#include -#include -#include - - - diff --git a/python_sdk/libraries/core/action/typesystem_sdk_libraries_core_action.xml b/python_sdk/libraries/core/action/typesystem_sdk_libraries_core_action.xml deleted file mode 100644 index 2451f8b4..00000000 --- a/python_sdk/libraries/core/action/typesystem_sdk_libraries_core_action.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/python_sdk/libraries/core/application/CMakeLists.txt b/python_sdk/libraries/core/application/CMakeLists.txt deleted file mode 100644 index 0e30981b..00000000 --- a/python_sdk/libraries/core/application/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/libraries/core/application/global_sdk_libraries_core_application.h b/python_sdk/libraries/core/application/global_sdk_libraries_core_application.h deleted file mode 100644 index 88abab79..00000000 --- a/python_sdk/libraries/core/application/global_sdk_libraries_core_application.h +++ /dev/null @@ -1,9 +0,0 @@ -// local header files -#include -#include -#include - - - - - diff --git a/python_sdk/libraries/core/application/typesystem_sdk_libraries_core_application.xml b/python_sdk/libraries/core/application/typesystem_sdk_libraries_core_application.xml deleted file mode 100644 index d7915118..00000000 --- a/python_sdk/libraries/core/application/typesystem_sdk_libraries_core_application.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - int argc; - char** argv; - if (!Shiboken::sequenceToArgcArgv(%PYARG_2, &argc, &argv, %1.toStdString().c_str())) { - PyErr_SetString(PyExc_TypeError, "error"); - return 0; - } - - // Shiboken asks to call %FUNCTION_NAME in the injected code - // here we don't need it ( %0 = (%CPPTYPEWrapper *)%CONVERTTOPYTHON[camitk::%CPPTYPE](app); doesn't work) - // simply delete it and directly call application wrapper - // TODO : understand how the conversion / wrapper handle objects - // If we comment the 2 above lines, the imp application (throught imp.py) will seg fault at runtime. - camitk::%CPPTYPE* app = new %FUNCTION_NAME(%1, argc, argv, %4, %5); - delete app; - - %0 = new %CPPTYPEWrapper(%1, argc, argv, %4, %5); - - delete[] argv; - - - - - - - diff --git a/python_sdk/libraries/core/component/CMakeLists.txt b/python_sdk/libraries/core/component/CMakeLists.txt deleted file mode 100644 index f20dbba8..00000000 --- a/python_sdk/libraries/core/component/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") - -# Find core subdirectories -get_subdirectories(CORE_COMPONENT_SUBDIR_LIST) - -# --- add every given library -foreach(COMP_NAME ${CORE_COMPONENT_SUBDIR_LIST}) - add_subdirectory(${COMP_NAME}) -endforeach() \ No newline at end of file diff --git a/python_sdk/libraries/core/component/global_sdk_libraries_core_component.h b/python_sdk/libraries/core/component/global_sdk_libraries_core_component.h deleted file mode 100644 index e7e04fe7..00000000 --- a/python_sdk/libraries/core/component/global_sdk_libraries_core_component.h +++ /dev/null @@ -1,12 +0,0 @@ -// subdirectories header files -#include "./component/image/global_sdk_libraries_core_component_image.h" -#include "./component/mesh/global_sdk_libraries_core_component_mesh.h" - -// local header files -#include -#include -#include -#include -#include - - diff --git a/python_sdk/libraries/core/component/image/CMakeLists.txt b/python_sdk/libraries/core/component/image/CMakeLists.txt deleted file mode 100644 index 0e30981b..00000000 --- a/python_sdk/libraries/core/component/image/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/libraries/core/component/image/global_sdk_libraries_core_component_image.h b/python_sdk/libraries/core/component/image/global_sdk_libraries_core_component_image.h deleted file mode 100644 index 163ae4dc..00000000 --- a/python_sdk/libraries/core/component/image/global_sdk_libraries_core_component_image.h +++ /dev/null @@ -1,6 +0,0 @@ -// local header files -#include -#include -#include -#include - diff --git a/python_sdk/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml b/python_sdk/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml deleted file mode 100644 index f6174094..00000000 --- a/python_sdk/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/python_sdk/libraries/core/component/mesh/CMakeLists.txt b/python_sdk/libraries/core/component/mesh/CMakeLists.txt deleted file mode 100644 index 0e30981b..00000000 --- a/python_sdk/libraries/core/component/mesh/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h b/python_sdk/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h deleted file mode 100644 index 8055fecc..00000000 --- a/python_sdk/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h +++ /dev/null @@ -1,6 +0,0 @@ -// local header files -#include -#include - - - diff --git a/python_sdk/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml b/python_sdk/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml deleted file mode 100644 index 0f78c75b..00000000 --- a/python_sdk/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/python_sdk/libraries/core/component/typesystem_sdk_libraries_core_component.xml b/python_sdk/libraries/core/component/typesystem_sdk_libraries_core_component.xml deleted file mode 100644 index dac8db6a..00000000 --- a/python_sdk/libraries/core/component/typesystem_sdk_libraries_core_component.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - // Force Shiboken not to instantiate Component (which is abstract) throught ComponentWrapper constructor - - // Let Shiboken believes we have called the constructor, which is not the case due to comments. - // cptr = new ComponentWrapper(); - - - - - // Force Shiboken not to instantiate Component (which is abstract) throught ComponentWrapper constructor - - // Let Shiboken believes we have called the constructor, which is not the case due to comments. - // cptr = new ComponentWrapper(); - - - - - - - - - - // Force Shiboken not to instantiate InterfaceNode (which is abstract) throught InterfaceNodeWrapper constructor - - // Let Shiboken believes we have called the constructor, which is not the case due to comments. - // cptr = new InterfaceNodeWrapper(); - - - - - - - - // Force Shiboken not to instantiate InterfaceBitMap (which is abstract) throught InterfaceBitMapWrapper constructor - - // Let Shiboken believes we have called the constructor, which is not the case due to comments. - // cptr = new InterfaceBitMapWrapper(); - - - - - - - - - // Force Shiboken not to instantiate InterfaceGeometry (which is abstract) throught InterfaceGeometryWrapper constructor - - // Let Shiboken believes we have called the constructor, which is not the case due to comments. - // cptr = new InterfaceGeometryWrapper(); - - - - - - - - - - - // Force Shiboken not to instantiate InterfaceProperty (which is abstract) throught InterfacePropertyWrapper constructor - - // Let Shiboken believes we have called the constructor, which is not the case due to comments. - // cptr = new InterfacePropertyWrapper(); - - - - - - diff --git a/python_sdk/libraries/core/global_sdk_libraries_core.h b/python_sdk/libraries/core/global_sdk_libraries_core.h deleted file mode 100644 index 324520da..00000000 --- a/python_sdk/libraries/core/global_sdk_libraries_core.h +++ /dev/null @@ -1,13 +0,0 @@ -// subdirectories header files -#include "./action/global_sdk_libraries_core_action.h" -#include "./application/global_sdk_libraries_core_application.h" -#include "./component/global_sdk_libraries_core_component.h" -#include "./utils/global_sdk_libraries_core_utils.h" -#include "./viewer/global_sdk_libraries_core_viewer.h" - -// include here the classes you want to be exposed to Python for sdk/library/core -#include -#include -#include -// #include - diff --git a/python_sdk/libraries/core/typesystem_sdk_libraries_core.xml b/python_sdk/libraries/core/typesystem_sdk_libraries_core.xml deleted file mode 100644 index 805ea25b..00000000 --- a/python_sdk/libraries/core/typesystem_sdk_libraries_core.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/python_sdk/libraries/core/utils/CMakeLists.txt b/python_sdk/libraries/core/utils/CMakeLists.txt deleted file mode 100644 index 0e30981b..00000000 --- a/python_sdk/libraries/core/utils/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/libraries/core/utils/global_sdk_libraries_core_utils.h b/python_sdk/libraries/core/utils/global_sdk_libraries_core_utils.h deleted file mode 100644 index 5a16f3a0..00000000 --- a/python_sdk/libraries/core/utils/global_sdk_libraries_core_utils.h +++ /dev/null @@ -1,11 +0,0 @@ -// local header files -// #include -#include -// #include -#include -#include -#include - - - - diff --git a/python_sdk/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml b/python_sdk/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml deleted file mode 100644 index 581e8591..00000000 --- a/python_sdk/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/python_sdk/libraries/core/viewer/CMakeLists.txt b/python_sdk/libraries/core/viewer/CMakeLists.txt deleted file mode 100644 index 6074ca53..00000000 --- a/python_sdk/libraries/core/viewer/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/libraries/core/viewer/global_sdk_libraries_core_viewer.h b/python_sdk/libraries/core/viewer/global_sdk_libraries_core_viewer.h deleted file mode 100644 index c1598f17..00000000 --- a/python_sdk/libraries/core/viewer/global_sdk_libraries_core_viewer.h +++ /dev/null @@ -1,9 +0,0 @@ -// local header files -#include -#include -#include -#include -#include - - - diff --git a/python_sdk/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml b/python_sdk/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml deleted file mode 100644 index 1d874b40..00000000 --- a/python_sdk/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/python_sdk/libraries/coreschema/CMakeLists.txt b/python_sdk/libraries/coreschema/CMakeLists.txt deleted file mode 100644 index 4a046d7b..00000000 --- a/python_sdk/libraries/coreschema/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/libraries/coreschema/global_sdk_libraries_coreschema.h b/python_sdk/libraries/coreschema/global_sdk_libraries_coreschema.h deleted file mode 100644 index 65a7ec2d..00000000 --- a/python_sdk/libraries/coreschema/global_sdk_libraries_coreschema.h +++ /dev/null @@ -1,5 +0,0 @@ -// local header files - - - - diff --git a/python_sdk/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml b/python_sdk/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml deleted file mode 100644 index 6c94ddf2..00000000 --- a/python_sdk/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/python_sdk/libraries/global_sdk_libraries.h b/python_sdk/libraries/global_sdk_libraries.h deleted file mode 100644 index dbc1905a..00000000 --- a/python_sdk/libraries/global_sdk_libraries.h +++ /dev/null @@ -1,7 +0,0 @@ -// subdirectories header files -#include "./core/global_sdk_libraries_core.h" -#include "./coreschema/global_sdk_libraries_coreschema.h" -#include "./qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h" - - - diff --git a/python_sdk/libraries/qtpropertybrowser/CMakeLists.txt b/python_sdk/libraries/qtpropertybrowser/CMakeLists.txt deleted file mode 100644 index fe126730..00000000 --- a/python_sdk/libraries/qtpropertybrowser/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -#--------------------------------------------------------------------------------- -# -# Recursively parse subdirectories for classes to expose -# -#--------------------------------------------------------------------------------- -# Shiboken PATH to look for typesystem.xml and global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python_sdk/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h b/python_sdk/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h deleted file mode 100644 index 65a7ec2d..00000000 --- a/python_sdk/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h +++ /dev/null @@ -1,5 +0,0 @@ -// local header files - - - - diff --git a/python_sdk/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml b/python_sdk/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml deleted file mode 100644 index 6c94ddf2..00000000 --- a/python_sdk/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/python_sdk/libraries/typesystem_sdk_libraries.xml b/python_sdk/libraries/typesystem_sdk_libraries.xml deleted file mode 100644 index f325903e..00000000 --- a/python_sdk/libraries/typesystem_sdk_libraries.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/python_sdk/pyside_global.h b/python_sdk/pyside_global.h deleted file mode 100644 index b4d6d9da..00000000 --- a/python_sdk/pyside_global.h +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). -** -** This file is part of the QtCore module of the Qt Toolkit, plus some -** modifications by PySide team. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - -#undef QT_NO_STL -#undef QT_NO_STL_WCHAR -#define Q_BYTE_ORDER // used to enable QSysInfo.Endian detection on MacOSX - -#include "/usr/include/qt4/QtCore/qnamespace.h" - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Core) - -class QByteArray; - -class QString; - -#ifndef Q_MOC_OUTPUT_REVISION -#define Q_MOC_OUTPUT_REVISION 61 -#endif - -// macro for onaming members -#ifdef METHOD -#undef METHOD -#endif -#ifdef SLOT -#undef SLOT -#endif -#ifdef SIGNAL -#undef SIGNAL -#endif - -Q_CORE_EXPORT const char* qFlagLocation(const char* method); - -#define QTOSTRING_HELPER(s) #s -#define QTOSTRING(s) QTOSTRING_HELPER(s) -#ifndef QT_NO_DEBUG -# define QLOCATION "\0"__FILE__":"QTOSTRING(__LINE__) -# define METHOD(a) qFlagLocation("0"#a QLOCATION) -# define SLOT(a) qFlagLocation("1"#a QLOCATION) -# define SIGNAL(a) qFlagLocation("2"#a QLOCATION) -#else -# define METHOD(a) "0"#a -# define SLOT(a) "1"#a -# define SIGNAL(a) "2"#a -#endif - -#ifdef QT3_SUPPORT -#define METHOD_CODE 0 // member type codes -#define SLOT_CODE 1 -#define SIGNAL_CODE 2 -#endif - -#define QMETHOD_CODE 0 // member type codes -#define QSLOT_CODE 1 -#define QSIGNAL_CODE 2 - -#define Q_ARG(type, data) QArgument(#type, data) -#define Q_RETURN_ARG(type, data) QReturnArgument(#type, data) - -class QObject; -class QMetaMethod; -class QMetaEnum; -class QMetaProperty; -class QMetaClassInfo; - - -class Q_CORE_EXPORT QGenericArgument { -public: - inline QGenericArgument(const char* aName = 0, const void* aData = 0) - : _data(aData), _name(aName) {} - inline void* data() const { - return const_cast(_data); - } - inline const char* name() const { - return _name; - } - -private: - const void* _data; - const char* _name; -}; - -class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument { -public: - inline QGenericReturnArgument(const char* aName = 0, void* aData = 0) - : QGenericArgument(aName, aData) { - } -}; - -template -class QArgument: public QGenericArgument { -public: - inline QArgument(const char* aName, const T& aData) - : QGenericArgument(aName, static_cast(&aData)) { - } -}; - - -template -class QReturnArgument: public QGenericReturnArgument { -public: - inline QReturnArgument(const char* aName, T& aData) - : QGenericReturnArgument(aName, static_cast(&aData)) { - } -}; - -struct Q_CORE_EXPORT QMetaObject { - const char* className() const; - const QMetaObject* superClass() const; - - QObject* cast(QObject* obj) const; - -#ifndef QT_NO_TRANSLATION - // ### Qt 4: Merge overloads - QString tr(const char* s, const char* c) const; - QString trUtf8(const char* s, const char* c) const; - QString tr(const char* s, const char* c, int n) const; - QString trUtf8(const char* s, const char* c, int n) const; -#endif // QT_NO_TRANSLATION - - int methodOffset() const; - int enumeratorOffset() const; - int propertyOffset() const; - int classInfoOffset() const; - - int constructorCount() const; - int methodCount() const; - int enumeratorCount() const; - int propertyCount() const; - int classInfoCount() const; - - int indexOfConstructor(const char* constructor) const; - int indexOfMethod(const char* method) const; - int indexOfSignal(const char* signal) const; - int indexOfSlot(const char* slot) const; - int indexOfEnumerator(const char* name) const; - int indexOfProperty(const char* name) const; - int indexOfClassInfo(const char* name) const; - - QMetaMethod constructor(int index) const; - QMetaMethod method(int index) const; - QMetaEnum enumerator(int index) const; - QMetaProperty property(int index) const; - QMetaClassInfo classInfo(int index) const; - QMetaProperty userProperty() const; - - static bool checkConnectArgs(const char* signal, const char* method); - static QByteArray normalizedSignature(const char* method); - static QByteArray normalizedType(const char* type); - - // internal index-based connect - static bool connect(const QObject* sender, int signal_index, - const QObject* receiver, int method_index, - int type = 0, int* types = 0); - // internal index-based disconnect - static bool disconnect(const QObject* sender, int signal_index, - const QObject* receiver, int method_index); - // internal slot-name based connect - static void connectSlotsByName(QObject* o); - - // internal index-based signal activation - static void activate(QObject* sender, int signal_index, void** argv); - static void activate(QObject* sender, int from_signal_index, int to_signal_index, void** argv); - static void activate(QObject* sender, const QMetaObject*, int local_signal_index, void** argv); - static void activate(QObject* sender, const QMetaObject*, int from_local_signal_index, int to_local_signal_index, void** argv); - // internal guarded pointers - static void addGuard(QObject** ptr); - static void removeGuard(QObject** ptr); - static void changeGuard(QObject** ptr, QObject* o); - - static bool invokeMethod(QObject* obj, const char* member, - Qt::ConnectionType, - QGenericReturnArgument ret, - QGenericArgument val0 = QGenericArgument(0), - QGenericArgument val1 = QGenericArgument(), - QGenericArgument val2 = QGenericArgument(), - QGenericArgument val3 = QGenericArgument(), - QGenericArgument val4 = QGenericArgument(), - QGenericArgument val5 = QGenericArgument(), - QGenericArgument val6 = QGenericArgument(), - QGenericArgument val7 = QGenericArgument(), - QGenericArgument val8 = QGenericArgument(), - QGenericArgument val9 = QGenericArgument()); - - static inline bool invokeMethod(QObject* obj, const char* member, - QGenericReturnArgument ret, - QGenericArgument val0 = QGenericArgument(0), - QGenericArgument val1 = QGenericArgument(), - QGenericArgument val2 = QGenericArgument(), - QGenericArgument val3 = QGenericArgument(), - QGenericArgument val4 = QGenericArgument(), - QGenericArgument val5 = QGenericArgument(), - QGenericArgument val6 = QGenericArgument(), - QGenericArgument val7 = QGenericArgument(), - QGenericArgument val8 = QGenericArgument(), - QGenericArgument val9 = QGenericArgument()) { - return invokeMethod(obj, member, Qt::AutoConnection, ret, val0, val1, val2, val3, - val4, val5, val6, val7, val8, val9); - } - - static inline bool invokeMethod(QObject* obj, const char* member, - Qt::ConnectionType type, - QGenericArgument val0 = QGenericArgument(0), - QGenericArgument val1 = QGenericArgument(), - QGenericArgument val2 = QGenericArgument(), - QGenericArgument val3 = QGenericArgument(), - QGenericArgument val4 = QGenericArgument(), - QGenericArgument val5 = QGenericArgument(), - QGenericArgument val6 = QGenericArgument(), - QGenericArgument val7 = QGenericArgument(), - QGenericArgument val8 = QGenericArgument(), - QGenericArgument val9 = QGenericArgument()) { - return invokeMethod(obj, member, type, QGenericReturnArgument(), val0, val1, val2, - val3, val4, val5, val6, val7, val8, val9); - } - - static inline bool invokeMethod(QObject* obj, const char* member, - QGenericArgument val0 = QGenericArgument(0), - QGenericArgument val1 = QGenericArgument(), - QGenericArgument val2 = QGenericArgument(), - QGenericArgument val3 = QGenericArgument(), - QGenericArgument val4 = QGenericArgument(), - QGenericArgument val5 = QGenericArgument(), - QGenericArgument val6 = QGenericArgument(), - QGenericArgument val7 = QGenericArgument(), - QGenericArgument val8 = QGenericArgument(), - QGenericArgument val9 = QGenericArgument()) { - return invokeMethod(obj, member, Qt::AutoConnection, QGenericReturnArgument(), val0, - val1, val2, val3, val4, val5, val6, val7, val8, val9); - } - - QObject* newInstance(QGenericArgument val0 = QGenericArgument(0), - QGenericArgument val1 = QGenericArgument(), - QGenericArgument val2 = QGenericArgument(), - QGenericArgument val3 = QGenericArgument(), - QGenericArgument val4 = QGenericArgument(), - QGenericArgument val5 = QGenericArgument(), - QGenericArgument val6 = QGenericArgument(), - QGenericArgument val7 = QGenericArgument(), - QGenericArgument val8 = QGenericArgument(), - QGenericArgument val9 = QGenericArgument()) const; - - enum Call { - InvokeMetaMethod, - ReadProperty, - WriteProperty, - ResetProperty, - QueryPropertyDesignable, - QueryPropertyScriptable, - QueryPropertyStored, - QueryPropertyEditable, - QueryPropertyUser, - CreateInstance - }; - - int static_metacall(Call, int, void**) const; - -#ifdef QT3_SUPPORT - QT3_SUPPORT const char* superClassName() const; -#endif - - struct { // private data - const QMetaObject* superdata; - const char* stringdata; - const uint* data; - const void* extradata; - } d; -}; - -struct QMetaObjectExtraData { - const QMetaObject** objects; - int (*static_metacall)(QMetaObject::Call, int, void**); -}; - -inline const char* QMetaObject::className() const { - return d.stringdata; -} - -inline const QMetaObject* QMetaObject::superClass() const { - return d.superdata; -} - -#ifdef QT3_SUPPORT -inline const char* QMetaObject::superClassName() const { - return d.superdata ? d.superdata->className() : 0; -} -#endif - -QT_END_NAMESPACE - -QT_END_HEADER - -#define qdoc - -#if 1 -#define Q_WS_X11 -#elif 0 -#define Q_WS_MAC -#elif 0 -#include "pysidewtypes.h" -#define Q_WS_WIN -#elif 0 -#define Q_WS_SIMULATOR -#endif - -// There are symbols in Qt that exist in Debug but -// not in release -#define QT_NO_DEBUG - -#include "/usr/include/qt4/QtCore/QtCore" -#if 0 || 0 -// Workaround to parse the QApplication header -#define Q_INTERNAL_QAPP_SRC -#undef qdoc -#endif -#include "/usr/include/qt4/QtGui/QtGui" -#include "qpytextobject.h" // PySide class -#if 1 -#include "/usr/include/qt4/QtGui/QX11Info" -#include "/usr/include/qt4/QtGui/QX11EmbedContainer" -#include "/usr/include/qt4/QtGui/QX11EmbedWidget" -#elif 0 -#include "/usr/include/qt4/QtGui/qmacstyle_mac.h" -#endif -#include "/usr/include/qt4/QtXml/QtXml" -#include "/usr/include/qt4/QtUiTools/QtUiTools" -#include "/usr/include/qt4/QtNetwork/QtNetwork" -#include "/usr/include/qt4/QtScript/QtScript" -#include "/usr/include/qt4/QtScriptTools/QtScriptTools" -#include "QT_QTMULTIMEDIA_INCLUDE_DIR-NOTFOUND/QtMultimedia" -#include -#include "/usr/include/qt4/QtDeclarative/QtDeclarative" - -// QT_GUI_LIB must be defined to QSqlRelationalDelegate become visible -#define QT_GUI_LIB -#undef Q_DECLARE_INTERFACE -#include "/usr/include/qt4/QtSql/QtSql" -#include "/usr/include/qt4/QtSvg/QtSvg" - -#if 1 -# include "/usr/include/qt4/QtXmlPatterns/QtXmlPatterns" -#endif - -#if 1 -# include "/usr/include/qt4/QtWebKit/QtWebKit" -#endif - -#if 1 -# include "/usr/include/qt4/QtTest/QtTest" -#if 8 > 5 -# include "pysideqtesttouch.h" -#endif -#endif - -// Phonon -#include "phonon/pyside_phonon.h" -#include "/usr/include/qt4/phonon/abstractaudiooutput.h" -#include "/usr/include/qt4/phonon/abstractmediastream.h" -#include "/usr/include/qt4/phonon/abstractvideooutput.h" -#include "/usr/include/qt4/phonon/addoninterface.h" -#include "/usr/include/qt4/phonon/audiooutput.h" -#include "/usr/include/qt4/phonon/audiooutputinterface.h" -#include "/usr/include/qt4/phonon/backendcapabilities.h" -#include "/usr/include/qt4/phonon/backendinterface.h" -#include "/usr/include/qt4/phonon/effect.h" -#include "/usr/include/qt4/phonon/effectinterface.h" -#include "/usr/include/qt4/phonon/effectparameter.h" -#include "/usr/include/qt4/phonon/effectwidget.h" -#include "/usr/include/qt4/phonon/mediacontroller.h" -#include "/usr/include/qt4/phonon/medianode.h" -#include "/usr/include/qt4/phonon/mediaobject.h" -#include "/usr/include/qt4/phonon/mediaobjectinterface.h" -#include "/usr/include/qt4/phonon/mediasource.h" -#include "/usr/include/qt4/phonon/objectdescription.h" -#include "/usr/include/qt4/phonon/objectdescriptionmodel.h" -#include "/usr/include/qt4/phonon/path.h" -#include "/usr/include/qt4/phonon/phonon_export.h" -#include "/usr/include/qt4/phonon/phonondefs.h" -#include "/usr/include/qt4/phonon/phononnamespace.h" -#include "/usr/include/qt4/phonon/platformplugin.h" -#include "/usr/include/qt4/phonon/seekslider.h" -#include "/usr/include/qt4/phonon/streaminterface.h" -#include "/usr/include/qt4/phonon/videoplayer.h" -#include "/usr/include/qt4/phonon/videowidget.h" -#include "/usr/include/qt4/phonon/videowidgetinterface.h" -#include "/usr/include/qt4/phonon/volumefadereffect.h" -#include "/usr/include/qt4/phonon/volumefaderinterface.h" -#include "/usr/include/qt4/phonon/volumeslider.h" - -//QtHelp need be included after QtSql -#include "/usr/include/qt4/QtHelp/QtHelp" - -#ifndef QT_NO_OPENGL -#include -#include -#endif // QT_NO_OPENGL - diff --git a/python_sdk/typesystem_sdk.xml b/python_sdk/typesystem_sdk.xml deleted file mode 100644 index 9649581c..00000000 --- a/python_sdk/typesystem_sdk.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdk/libraries/core/CMakeLists.txt b/sdk/libraries/core/CMakeLists.txt index 998afd67..b1b35c1e 100644 --- a/sdk/libraries/core/CMakeLists.txt +++ b/sdk/libraries/core/CMakeLists.txt @@ -62,7 +62,7 @@ set_target_properties(${CAMITK_CORE_LIB_TARGET_NAME} PROPERTIES ${CAMITKCORE_LIB if (WIN32 AND MSVC) # property required for camitk file association on windows platform compilation with Visual Studio set_target_properties(${CAMITK_CORE_LIB_TARGET_NAME} PROPERTIES COMPILE_FLAGS "/Zc:wchar_t-" - DEBUG_POSTFIX ${CAMITK_DEBUG_POSTFIX} + DEBUG_POSTFIX ${CAMITK_DEBUG_POSTFIX} ) endif() @@ -126,7 +126,7 @@ export_headers(${${CAMITK_CORE_LIB_TARGET_NAME}_INSTALL_H} # change the output library name (without the prefix 'library') set_target_properties(${CAMITK_CORE_LIB_TARGET_NAME} - PROPERTIES OUTPUT_NAME ${CAMITK_CORE_LIB_NAME} + PROPERTIES OUTPUT_NAME ${CAMITK_CORE_LIB_NAME} ) # lib installation -- GitLab From 20fa1a2774ad3c14ad3a801fcd406b0d11cfddf1 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 22 Feb 2019 15:10:18 +0100 Subject: [PATCH 02/24] NEW python binding directory (copy of previouslys called python_sdk) --- python/CMakeLists.txt | 268 +++++++++++ python/FindPySide2Tools.cmake | 98 ++++ python/PythonBindings.h | 38 ++ python/PythonBindings.xml | 10 + python/actions/CMakeLists.txt | 24 + python/actions/application/CMakeLists.txt | 9 + .../global_sdk_actions_application.h | 23 + .../typesystem_sdk_actions_application.xml | 27 ++ python/actions/global_sdk_actions.h | 5 + python/actions/image/CMakeLists.txt | 16 + .../image/arbitraryslice/CMakeLists.txt | 9 + .../global_sdk_actions_image_arbitraryslice.h | 6 + ...ystem_sdk_actions_image_arbitraryslice.xml | 8 + .../actions/image/cropvolume/CMakeLists.txt | 9 + .../global_sdk_actions_image_cropvolume.h | 5 + ...ypesystem_sdk_actions_image_cropvolume.xml | 8 + .../actions/image/global_sdk_actions_image.h | 8 + python/actions/image/imagelut/CMakeLists.txt | 9 + .../global_sdk_actions_image_imagelut.h | 4 + .../typesystem_sdk_actions_image_imagelut.xml | 8 + .../actions/image/multipicking/CMakeLists.txt | 9 + .../global_sdk_actions_image_multipicking.h | 7 + ...esystem_sdk_actions_image_multipicking.xml | 9 + .../image/reconstruction/CMakeLists.txt | 9 + .../global_sdk_actions_image_reconstruction.h | 4 + ...ystem_sdk_actions_image_reconstruction.xml | 7 + python/actions/image/showin3d/CMakeLists.txt | 9 + .../global_sdk_actions_image_showin3d.h | 7 + .../typesystem_sdk_actions_image_showin3d.xml | 11 + .../image/typesystem_sdk_actions_image.xml | 13 + .../image/volumerendering/CMakeLists.txt | 9 + ...global_sdk_actions_image_volumerendering.h | 8 + ...stem_sdk_actions_image_volumerendering.xml | 12 + python/actions/mesh/CMakeLists.txt | 16 + python/actions/mesh/basicmesh/CMakeLists.txt | 9 + .../global_sdk_actions_mesh_basicmesh.h | 10 + .../typesystem_sdk_actions_mesh_basicmesh.xml | 13 + .../actions/mesh/basictopology/CMakeLists.txt | 9 + .../global_sdk_actions_mesh_basictopology.h | 4 + ...esystem_sdk_actions_mesh_basictopology.xml | 8 + python/actions/mesh/global_sdk_actions_mesh.h | 7 + .../mesh/meshprocessing/CMakeLists.txt | 9 + .../global_sdk_actions_mesh_meshprocessing.h | 10 + ...system_sdk_actions_mesh_meshprocessing.xml | 15 + .../mesh/typesystem_sdk_actions_mesh.xml | 10 + python/actions/typesystem_sdk_actions.xml | 9 + python/applications/CMakeLists.txt | 24 + .../actionstatemachine/CMakeLists.txt | 8 + ...obal_sdk_applications_actionstatemachine.h | 3 + ...em_sdk_applications_actionstatemachine.xml | 5 + python/applications/config/CMakeLists.txt | 9 + .../config/global_sdk_applications_config.h | 3 + .../typesystem_sdk_applications_config.xml | 5 + python/applications/global_sdk_applications.h | 5 + python/applications/imp/CMakeLists.txt | 8 + .../imp/global_sdk_applications_imp.h | 3 + .../imp/typesystem_sdk_applications_imp.xml | 6 + .../typesystem_sdk_applications.xml | 10 + python/applications/wizard/CMakeLists.txt | 8 + .../wizard/global_sdk_applications_wizard.h | 3 + .../typesystem_sdk_applications_wizard.xml | 5 + python/components/CMakeLists.txt | 23 + python/components/global_sdk_components.h | 8 + python/components/msh/CMakeLists.txt | 8 + .../msh/global_sdk_components_msh.h | 4 + .../msh/typesystem_sdk_components_msh.xml | 5 + python/components/obj/CMakeLists.txt | 8 + .../obj/global_sdk_components_obj.h | 4 + .../obj/typesystem_sdk_components_obj.xml | 5 + python/components/off/CMakeLists.txt | 8 + .../off/global_sdk_components_off.h | 4 + .../off/typesystem_sdk_components_off.xml | 5 + .../components/typesystem_sdk_components.xml | 12 + python/components/vrml/CMakeLists.txt | 8 + .../vrml/global_sdk_components_vrml.h | 4 + .../vrml/typesystem_sdk_components_vrml.xml | 5 + python/components/vtkimage/CMakeLists.txt | 8 + .../vtkimage/global_sdk_components_vtkimage.h | 4 + .../typesystem_sdk_components_vtkimage.xml | 5 + python/components/vtkmesh/CMakeLists.txt | 8 + .../vtkmesh/global_sdk_components_vtkmesh.h | 4 + .../typesystem_sdk_components_vtkmesh.xml | 5 + python/global_sdk.h | 17 + python/libraries/CMakeLists.txt | 25 ++ python/libraries/core/CMakeLists.txt | 16 + python/libraries/core/action/CMakeLists.txt | 8 + .../action/global_sdk_libraries_core_action.h | 7 + .../typesystem_sdk_libraries_core_action.xml | 10 + .../libraries/core/application/CMakeLists.txt | 8 + .../global_sdk_libraries_core_application.h | 9 + ...esystem_sdk_libraries_core_application.xml | 40 ++ .../libraries/core/component/CMakeLists.txt | 16 + .../global_sdk_libraries_core_component.h | 12 + .../core/component/image/CMakeLists.txt | 8 + ...lobal_sdk_libraries_core_component_image.h | 6 + ...tem_sdk_libraries_core_component_image.xml | 10 + .../core/component/mesh/CMakeLists.txt | 8 + ...global_sdk_libraries_core_component_mesh.h | 6 + ...stem_sdk_libraries_core_component_mesh.xml | 9 + ...ypesystem_sdk_libraries_core_component.xml | 78 ++++ .../core/global_sdk_libraries_core.h | 13 + .../core/typesystem_sdk_libraries_core.xml | 19 + python/libraries/core/utils/CMakeLists.txt | 8 + .../utils/global_sdk_libraries_core_utils.h | 11 + .../typesystem_sdk_libraries_core_utils.xml | 14 + python/libraries/core/viewer/CMakeLists.txt | 8 + .../viewer/global_sdk_libraries_core_viewer.h | 9 + .../typesystem_sdk_libraries_core_viewer.xml | 12 + python/libraries/coreschema/CMakeLists.txt | 8 + .../global_sdk_libraries_coreschema.h | 5 + .../typesystem_sdk_libraries_coreschema.xml | 6 + python/libraries/global_sdk_libraries.h | 7 + .../qtpropertybrowser/CMakeLists.txt | 8 + .../global_sdk_libraries_qtpropertybrowser.h | 5 + ...system_sdk_libraries_qtpropertybrowser.xml | 6 + python/libraries/typesystem_sdk_libraries.xml | 9 + python/pyside2_config.py | 302 +++++++++++++ python/pyside_global.h | 417 ++++++++++++++++++ python/typesystem_sdk.xml | 46 ++ python/utils.py | 49 ++ 120 files changed, 2340 insertions(+) create mode 100644 python/CMakeLists.txt create mode 100644 python/FindPySide2Tools.cmake create mode 100644 python/PythonBindings.h create mode 100644 python/PythonBindings.xml create mode 100644 python/actions/CMakeLists.txt create mode 100644 python/actions/application/CMakeLists.txt create mode 100644 python/actions/application/global_sdk_actions_application.h create mode 100644 python/actions/application/typesystem_sdk_actions_application.xml create mode 100644 python/actions/global_sdk_actions.h create mode 100644 python/actions/image/CMakeLists.txt create mode 100644 python/actions/image/arbitraryslice/CMakeLists.txt create mode 100644 python/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h create mode 100644 python/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml create mode 100644 python/actions/image/cropvolume/CMakeLists.txt create mode 100644 python/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h create mode 100644 python/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml create mode 100644 python/actions/image/global_sdk_actions_image.h create mode 100644 python/actions/image/imagelut/CMakeLists.txt create mode 100644 python/actions/image/imagelut/global_sdk_actions_image_imagelut.h create mode 100644 python/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml create mode 100644 python/actions/image/multipicking/CMakeLists.txt create mode 100644 python/actions/image/multipicking/global_sdk_actions_image_multipicking.h create mode 100644 python/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml create mode 100644 python/actions/image/reconstruction/CMakeLists.txt create mode 100644 python/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h create mode 100644 python/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml create mode 100644 python/actions/image/showin3d/CMakeLists.txt create mode 100644 python/actions/image/showin3d/global_sdk_actions_image_showin3d.h create mode 100644 python/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml create mode 100644 python/actions/image/typesystem_sdk_actions_image.xml create mode 100644 python/actions/image/volumerendering/CMakeLists.txt create mode 100644 python/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h create mode 100644 python/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml create mode 100644 python/actions/mesh/CMakeLists.txt create mode 100644 python/actions/mesh/basicmesh/CMakeLists.txt create mode 100644 python/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h create mode 100644 python/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml create mode 100644 python/actions/mesh/basictopology/CMakeLists.txt create mode 100644 python/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h create mode 100644 python/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml create mode 100644 python/actions/mesh/global_sdk_actions_mesh.h create mode 100644 python/actions/mesh/meshprocessing/CMakeLists.txt create mode 100644 python/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h create mode 100644 python/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml create mode 100644 python/actions/mesh/typesystem_sdk_actions_mesh.xml create mode 100644 python/actions/typesystem_sdk_actions.xml create mode 100644 python/applications/CMakeLists.txt create mode 100644 python/applications/actionstatemachine/CMakeLists.txt create mode 100644 python/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h create mode 100644 python/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml create mode 100644 python/applications/config/CMakeLists.txt create mode 100644 python/applications/config/global_sdk_applications_config.h create mode 100644 python/applications/config/typesystem_sdk_applications_config.xml create mode 100644 python/applications/global_sdk_applications.h create mode 100644 python/applications/imp/CMakeLists.txt create mode 100644 python/applications/imp/global_sdk_applications_imp.h create mode 100644 python/applications/imp/typesystem_sdk_applications_imp.xml create mode 100644 python/applications/typesystem_sdk_applications.xml create mode 100644 python/applications/wizard/CMakeLists.txt create mode 100644 python/applications/wizard/global_sdk_applications_wizard.h create mode 100644 python/applications/wizard/typesystem_sdk_applications_wizard.xml create mode 100644 python/components/CMakeLists.txt create mode 100644 python/components/global_sdk_components.h create mode 100644 python/components/msh/CMakeLists.txt create mode 100644 python/components/msh/global_sdk_components_msh.h create mode 100644 python/components/msh/typesystem_sdk_components_msh.xml create mode 100644 python/components/obj/CMakeLists.txt create mode 100644 python/components/obj/global_sdk_components_obj.h create mode 100644 python/components/obj/typesystem_sdk_components_obj.xml create mode 100644 python/components/off/CMakeLists.txt create mode 100644 python/components/off/global_sdk_components_off.h create mode 100644 python/components/off/typesystem_sdk_components_off.xml create mode 100644 python/components/typesystem_sdk_components.xml create mode 100644 python/components/vrml/CMakeLists.txt create mode 100644 python/components/vrml/global_sdk_components_vrml.h create mode 100644 python/components/vrml/typesystem_sdk_components_vrml.xml create mode 100644 python/components/vtkimage/CMakeLists.txt create mode 100644 python/components/vtkimage/global_sdk_components_vtkimage.h create mode 100644 python/components/vtkimage/typesystem_sdk_components_vtkimage.xml create mode 100644 python/components/vtkmesh/CMakeLists.txt create mode 100644 python/components/vtkmesh/global_sdk_components_vtkmesh.h create mode 100644 python/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml create mode 100644 python/global_sdk.h create mode 100644 python/libraries/CMakeLists.txt create mode 100644 python/libraries/core/CMakeLists.txt create mode 100644 python/libraries/core/action/CMakeLists.txt create mode 100644 python/libraries/core/action/global_sdk_libraries_core_action.h create mode 100644 python/libraries/core/action/typesystem_sdk_libraries_core_action.xml create mode 100644 python/libraries/core/application/CMakeLists.txt create mode 100644 python/libraries/core/application/global_sdk_libraries_core_application.h create mode 100644 python/libraries/core/application/typesystem_sdk_libraries_core_application.xml create mode 100644 python/libraries/core/component/CMakeLists.txt create mode 100644 python/libraries/core/component/global_sdk_libraries_core_component.h create mode 100644 python/libraries/core/component/image/CMakeLists.txt create mode 100644 python/libraries/core/component/image/global_sdk_libraries_core_component_image.h create mode 100644 python/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml create mode 100644 python/libraries/core/component/mesh/CMakeLists.txt create mode 100644 python/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h create mode 100644 python/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml create mode 100644 python/libraries/core/component/typesystem_sdk_libraries_core_component.xml create mode 100644 python/libraries/core/global_sdk_libraries_core.h create mode 100644 python/libraries/core/typesystem_sdk_libraries_core.xml create mode 100644 python/libraries/core/utils/CMakeLists.txt create mode 100644 python/libraries/core/utils/global_sdk_libraries_core_utils.h create mode 100644 python/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml create mode 100644 python/libraries/core/viewer/CMakeLists.txt create mode 100644 python/libraries/core/viewer/global_sdk_libraries_core_viewer.h create mode 100644 python/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml create mode 100644 python/libraries/coreschema/CMakeLists.txt create mode 100644 python/libraries/coreschema/global_sdk_libraries_coreschema.h create mode 100644 python/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml create mode 100644 python/libraries/global_sdk_libraries.h create mode 100644 python/libraries/qtpropertybrowser/CMakeLists.txt create mode 100644 python/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h create mode 100644 python/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml create mode 100644 python/libraries/typesystem_sdk_libraries.xml create mode 100755 python/pyside2_config.py create mode 100644 python/pyside_global.h create mode 100644 python/typesystem_sdk.xml create mode 100755 python/utils.py diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 00000000..3223ba91 --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,268 @@ +#-------------------------------------------- +# +# CamiTK SDK Python binding +# +# Do not edit this file, unless +# you really (really!) know +# what you're doing +# +#-------------------------------------------- + +# Requires +# - libshiboken2-dev +# - libpyside2-dev +# - shiboken2 +# - clang +# - llvm + +# cmake ../../src/camitk -DCAMITK_BINDING_PYTHON=TRUE + +# check also https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples/samplebinding/CMakeLists.txt?h=5.9 +cmake_minimum_required(VERSION 3.1) +cmake_policy(VERSION 3.1) + +# Enable policy to not use RPATH settings for install_name on macOS. +if(POLICY CMP0068) + cmake_policy(SET CMP0068 NEW) +endif() + +# Set CPP standard to C++11 minimum. +set(CMAKE_CXX_STANDARD 11) + +#-------------------------------------------- +# +# Python binding requirements +# +#-------------------------------------------- + +# Greatly inspired by freecad CMakeLists.txt +# set(PYTHON_SUFFIX -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +# Below are two variables that can be left empty for standard python 3 version, +# but must be set by the user for different python versions such as 2.7, 3.5 ... +if (PYTHON_VERSION_MAJOR LESS 3) + SET(PYTHON_CONFIG_SUFFIX -python2.7 CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: ") + SET(PYTHON_BASENAME -python2.7 CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: ") +else() + #SET(PYTHON_CONFIG_SUFFIX "" CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: ") + #SET(PYTHON_BASENAME "" CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: ") +endif() + +# -- Python3 +# find_package(PythonLibs REQUIRED) +# find_package(PythonInterp 3.7 REQUIRED) +find_package(Python3 REQUIRED) +set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +if(NOT DEFINED PYTHON_VERSION_STRING) + find_package(PythonLibs REQUIRED) +else() + find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT) +endif() + + +if(NOT PYTHONLIBS_FOUND) + message(FATAL_ERROR "=================================\n" + "Python not found, install Python!\n" + "=================================\n") +else() + # prevent python3 lower than 3.3 (not enough utf8<->unicode tools) + if(PYTHON_VERSION_MAJOR EQUAL 3) + if(PYTHON_VERSION_MINOR LESS 7) + message(FATAL_ERROR "To build CamiTK Python, you need at least version python 3.47n") + endif() + endif() +endif() + +# -- Qt +# # List of Qt5 modules that are required in CamiTK +# set(CAMITK_QT_COMPONENTS Core Gui Xml XmlPatterns Widgets Help UiTools OpenGL OpenGLExtensions Test) +# # Find Qt5 +# find_package(Qt5 COMPONENTS ${CAMITK_QT_COMPONENTS} REQUIRED) + +# -- PySide, the Python binding of Qt using Shiboken. +find_package(PySide2 REQUIRED) +# find_package(PySide2 QUIET)# REQUIRED +if(NOT PYSIDE_INCLUDE_DIR) + message("==================\n" + "PySide2 not found.\n" + "==================\n") +endif() + +# -- Shiboken2, the PySide team C++ to Python wrapper +find_package(Shiboken2 REQUIRED) +if (Shiboken2_FOUND) + # Shiboken2 config file was found but it may use the wrong Python version + # Try to get the matching config suffix and repeat finding the package + if (PYTHON_VERSION_MAJOR LESS 3) + set(SHIBOKEN_PATTERN -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) + else() + set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + endif() + + file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake") + if (SHIBOKEN_CONFIG) + get_filename_component(SHIBOKEN_CONFIG_SUFFIX ${SHIBOKEN_CONFIG} NAME) + string(SUBSTRING ${SHIBOKEN_CONFIG_SUFFIX} 15 -1 SHIBOKEN_CONFIG_SUFFIX) + string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${SHIBOKEN_CONFIG_SUFFIX}) + message(STATUS "PYTHON_CONFIG_SUFFIX: ${PYTHON_CONFIG_SUFFIX}") + find_package(Shiboken2 QUIET) + endif() +endif() + +if(NOT SHIBOKEN_INCLUDE_DIR) + message(FATAL_ERROR + "====================\n" + "shiboken2 not found.\n" + "====================\n") +endif() + + +find_program(CAMITK_BINDING_PYTHON_GENERATOR shiboken2 REQUIRED) +if (NOT CAMITK_BINDING_PYTHON_GENERATOR) + message(FATAL_ERROR "Please add Shiboken2 binary in your PATH or manually point to it using the CAMITK_BINDING_PYTHON_GENERATOR variable") +endif() + + +find_package(PySide2Tools QUIET) #REQUIRED # PySide2 utilities (pyside2-uic & pyside2-rcc) +if(NOT PYSIDE2_TOOLS_FOUND) + message("=======================\n" + "PySide2Tools not found.\n" + "=======================\n") +endif() + +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide) +file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/__init__.py "# PySide wrapper\n" + "from PySide2 import __version__\n" + "from PySide2 import __version_info__\n") +file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtCore.py "from PySide2.QtCore import *\n\n" + "#QCoreApplication.CodecForTr=0\n" + "#QCoreApplication.UnicodeUTF8=1\n") +file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtGui.py "from PySide2.QtGui import *\n" + "from PySide2.QtWidgets import *\n" + "QHeaderView.setResizeMode = QHeaderView.setSectionResizeMode\n") +file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvg.py "from PySide2.QtSvg import *\n") + +if(APPLE AND NOT BUILD_WITH_CONDA) + install(DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide + DESTINATION MacOS) +else() + install(DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide + DESTINATION Ext) +endif() + +# TEST Using VTK dependency +# find_package(VTK REQUIRED) + +#-------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#-------------------------------------------- +# Shiboken PATH to look for typesystem.xml and global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# include subdirectories +add_subdirectory(actions) +add_subdirectory(applications) +add_subdirectory(components) +add_subdirectory(libraries) + +# TODO : Remove once debugged +message(WARNING "PYSIDE_INCLUDE_DIR = ${PYSIDE_INCLUDE_DIR}") +message(WARNING "SHIBOKEN_TYPESYSTEM_PATH = ${SHIBOKEN_TYPESYSTEM_PATH}") +message(WARNING "SHIBOKEN_GLOBAL_H_PATH = ${SHIBOKEN_GLOBAL_H_PATH}") +message(WARNING "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}") +message(WARNING "QT_QTCORE_INCLUDE_DIR = ${QT_QTCORE_INCLUDE_DIR}") +message(WARNING "SHIBOKEN_CAMITK_SDK_PATH = ${SHIBOKEN_CAMITK_SDK_PATH}") +message(WARNING "VTK_INCLUDE_DIRS = ${VTK_INCLUDE_DIRS}") + +#-------------------------------------------- +# +# Custom CMake Python binding targets +# +#-------------------------------------------- +# Shiboken specific paths +set(PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN + ${PYSIDE_INCLUDE_DIR}:${PYSIDE_INCLUDE_DIR}/QtCore:${PYSIDE_INCLUDE_DIR}/QtGui + #:${PYSIDE_INCLUDE_DIR}/QtHelp:${PYSIDE_INCLUDE_DIR}/QtNetwork:${PYSIDE_INCLUDE_DIR}/QtOpenGL:${PYSIDE_INCLUDE_DIR}/QtScript:${PYSIDE_INCLUDE_DIR}/QtScriptTools:${PYSIDE_INCLUDE_DIR}/QtSql:${PYSIDE_INCLUDE_DIR}/QtSvg:${PYSIDE_INCLUDE_DIR}/QtTest:${PYSIDE_INCLUDE_DIR}/QtUiTools:${PYSIDE_INCLUDE_DIR}/QtWebKit:${PYSIDE_INCLUDE_DIR}/QtXml:${PYSIDE_INCLUDE_DIR}/QtXmlPatterns:${PYSIDE_INCLUDE_DIR}/QtDeclarative +) + +# TODO : Remove once debugged +message(WARNING "PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN = ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}") + +set(SHIBOKEN_OPTIONS + --generator-set=shiboken --enable-parent-ctor-heuristic + --enable-return-value-heuristic --use-isnull-as-nb_nonzero + --avoid-protected-hack + --output-directory=${CMAKE_CURRENT_BINARY_DIR} + --include-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}:${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}:${SHIBOKEN_GLOBAL_H_PATH}:${SHIBOKEN_CAMITK_SDK_PATH}:${VTK_INCLUDE_DIRS} + --typesystem-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_TYPESYSTEMS}:${SHIBOKEN_TYPESYSTEM_PATH} +) + +# Wrap the CamiTK SDK. Wrapping uses Shiboken (PySide binding tool) +# It means it decorates the specified C++ classes to Python by adding +# information in order to convert it into a CPython extension +# Shiboken parses the typesystem.xml files to detect which C++ classes to expose to Python +# For each of them, it create a CPython C++ decorated class in the build directory +add_custom_target(camitk-ce-python-wrapping + COMMAND ${CMAKE_COMMAND} -E echo "Cleaning C++ classes generated from previous wrapping." + COMMAND ${CMAKE_COMMAND} -E remove_directory python + COMMAND ${CMAKE_COMMAND} -E echo "Wrapping CamiTK SDK for Python exposure." + COMMAND ${CAMITK_BINDING_PYTHON_GENERATOR} ${SHIBOKEN_OPTIONS} + ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.h # wrap header + ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.xml # type system + COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK wrapped." +) +add_dependencies(camitk-ce-python-wrapping action-application) # need a first build to wrap + +# The resulting C++ wrapped classes will be listed in the following CMake variable: +file(GLOB_RECURSE SDK_WRAPPED_CLASSES ${CMAKE_BINARY_DIR}/python/camitk/*.cpp ) + +# We list the CamiTK SDK generated dynamic libraries for linking the python package +# TODO do not manually list those libraries, but dynamically create this list at configuration +# step, using CamiTK CMake macros +file(GLOB_RECURSE CAMITK_SDK_LIBRARIES ${CMAKE_BINARY_DIR}/*.so) +# message(WARNING "CAMITK_SDK_LIBRARIES = ${CAMITK_SDK_LIBRARIES}") + +# This CMake target aims at compiling the C++ Python-wrapped classes of CamiTK and link them against +# the original CamiTK SDK libraries. +# WARNING Do not manually run this target, it requires another configure step wich is run by the camitk-sdk-package-to-python +# CMake target. +if(NOT SDK_WRAPPED_CLASSES STREQUAL "") # only create sdk_python target if camitk sdk has been wrapped + set(PROJECT_NAME sdk_python) # the name of the camitk sdk package once compiled + string(REPLACE ":" ";" CAMITK_SDK_INCLUDE_DIR ${SHIBOKEN_CAMITK_SDK_PATH}) # deduce the list of include directories of CamiTK SDK + string(REPLACE ":" ";" PYSIDE_INCLUDE_ALL_DIR ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}) #deduce the list of include directories provided from PySide / Shiboken + # Qt libraries dependencies + set(QT_LIBRARIES "${QT_QTCORE_LIBRARY};${QT_QTGUI_LIBRARY}") +# message(WARNING "QT_LIBRARIES = ${QT_LIBRARIES}") + set(CAMITK_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../sdk/libraries/core + ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/mesh/basicmesh + ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/arbitraryslice ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/cropvolume + ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/imagelut + ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/multipicking ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/reconstruction + ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/volumerendering + ) #build directories required for ui wrapping includes ! + + include_directories(${PROJECT_NAME} ${CAMITK_SDK_INCLUDE_DIR} ${PYSIDE_INCLUDE_ALL_DIR} ${SHIBOKEN_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${VTK_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CAMITK_BUILD_DIR}) + add_library(${PROJECT_NAME} SHARED ${SDK_WRAPPED_CLASSES}) + # # set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") + set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") + target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${VTK_LIBRARIES} ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${CAMITK_SDK_LIBRARIES}) + # WARNING check VTK dependency +# message(WARNING "SHIBOKEN_PYTHON_LIBRARIES = ${SHIBOKEN_PYTHON_LIBRARIES}") +# message(WARNING "SHIBOKEN_LIBRARY = ${SHIBOKEN_LIBRARY}") + # add_dependencies(${PROJECT_NAME} camitkcore) +endif() + +# Create the Python package of CamiTK SDK +# This package is compiled from the generated C++ classes of the camitk-ce-python-wrapping target +# and link against the CamiTK SDK libraries. +# Build the custom camitk-ce-python-package target in order to compile the wrapped C++ classes and link against +# CamiTK SDK dynamic libraries. +add_custom_target(camitk-ce-python-package + COMMAND ${CMAKE_COMMAND} -E echo "Creating Python package of CamiTK SDK." + COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target camitk_python + COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK Python package created." +) +add_dependencies(camitk-ce-python-package camitk-ce-python-wrapping) # need all to wrapped before creating the package diff --git a/python/FindPySide2Tools.cmake b/python/FindPySide2Tools.cmake new file mode 100644 index 00000000..a774756e --- /dev/null +++ b/python/FindPySide2Tools.cmake @@ -0,0 +1,98 @@ +# Originally from freecad +# +# Try to find PySide2 utilities, PYSIDE2UIC and PYSIDE2RCC: +# PYSIDE2UICBINARY - Location of PYSIDE2UIC executable +# PYSIDE2RCCBINARY - Location of PYSIDE2RCC executable +# PYSIDE2_TOOLS_FOUND - PySide2 utilities found. + +# Also provides macro similar to FindQt4.cmake's WRAP_UI and WRAP_RC, +# for the automatic generation of Python code from Qt4's user interface +# ('.ui') and resource ('.qrc') files. These macros are called: +# - PYSIDE_WRAP_UI +# - PYSIDE_WRAP_RC + +IF(PYSIDE2UICBINARY AND PYSIDE2RCCBINARY) + # Already in cache, be silent + set(PYSIDE2_TOOLS_FOUND_QUIETLY TRUE) +ENDIF(PYSIDE2UICBINARY AND PYSIDE2RCCBINARY) + +if(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + #pyside2 tools are often in same location as python interpreter + get_filename_component(PYTHON_BIN_DIR ${PYTHON_EXECUTABLE} PATH) + set(PYSIDE_BIN_DIR ${PYTHON_BIN_DIR}) +endif(WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + +FIND_PROGRAM(PYSIDE2UICBINARY NAMES python2-pyside2-uic pyside2-uic pyside2-uic-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR}) +FIND_PROGRAM(PYSIDE2RCCBINARY NAMES pyside2-rcc pyside2-rcc-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} HINTS ${PYSIDE_BIN_DIR}) + +MACRO(PYSIDE_WRAP_UI outfiles) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + SET(outfile ${CMAKE_CURRENT_BINARY_DIR}/ui_${outfile}.py) + #ADD_CUSTOM_TARGET(${it} ALL + # DEPENDS ${outfile} + #) + if(WIN32 OR APPLE) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${PYSIDE2UICBINARY} ${infile} -o ${outfile} + MAIN_DEPENDENCY ${infile} + ) + else() + # Especially on Open Build Service we don't want changing date like + # pyside2-uic generates in comments at beginning., which is why + # we follow the tool command with in-place sed. + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND "${PYSIDE2UICBINARY}" "${infile}" -o "${outfile}" + COMMAND sed -i "/^# /d" "${outfile}" + MAIN_DEPENDENCY "${infile}" + ) + endif() + list(APPEND ${outfiles} ${outfile}) + ENDFOREACH(it) +ENDMACRO (PYSIDE_WRAP_UI) + +MACRO(PYSIDE_WRAP_RC outfiles) + FOREACH(it ${ARGN}) + GET_FILENAME_COMPONENT(outfile ${it} NAME_WE) + GET_FILENAME_COMPONENT(infile ${it} ABSOLUTE) + SET(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}_rc.py") + #ADD_CUSTOM_TARGET(${it} ALL + # DEPENDS ${outfile} + #) + if(WIN32 OR APPLE) + ADD_CUSTOM_COMMAND(OUTPUT ${outfile} + COMMAND ${PYSIDE2RCCBINARY} ${infile} -o ${outfile} + MAIN_DEPENDENCY ${infile} + ) + else() + # Especially on Open Build Service we don't want changing date like + # pyside-rcc generates in comments at beginning, which is why + # we follow the tool command with in-place sed. + ADD_CUSTOM_COMMAND(OUTPUT "${outfile}" + COMMAND "${PYSIDE2RCCBINARY}" "${infile}" ${PY_ATTRIBUTE} -o "${outfile}" + COMMAND sed -i "/^# /d" "${outfile}" + MAIN_DEPENDENCY "${infile}" + ) + endif() + list(APPEND ${outfiles} ${outfile}) + ENDFOREACH(it) +ENDMACRO (PYSIDE_WRAP_RC) + +IF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY}) + set(PYSIDE2_TOOLS_FOUND TRUE) +ENDIF(EXISTS ${PYSIDE2UICBINARY} AND EXISTS ${PYSIDE2RCCBINARY}) + +if(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) + if (NOT PySide2Tools_FIND_QUIETLY) + message(STATUS "Found PySide2 tools: ${PYSIDE2UICBINARY}, ${PYSIDE2RCCBINARY}") + endif (NOT PySide2Tools_FIND_QUIETLY) +else(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) + if(PySide2Tools_FIND_REQUIRED) + message(FATAL_ERROR "PySide2 tools could not be found, but are required.") + else(PySide2Tools_FIND_REQUIRED) + if (NOT PySide2Tools_FIND_QUIETLY) + message(STATUS "PySide2 tools: not found.") + endif (NOT PySide2Tools_FIND_QUIETLY) + endif(PySide2Tools_FIND_REQUIRED) +endif(PYSIDE2RCCBINARY AND PYSIDE2UICBINARY) diff --git a/python/PythonBindings.h b/python/PythonBindings.h new file mode 100644 index 00000000..9f14c6d1 --- /dev/null +++ b/python/PythonBindings.h @@ -0,0 +1,38 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2019 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +#ifndef PYTHON_BINDINGS_H +#define PYTHON_BINDINGS_H + +// include here the classes you want to be exposed to Python +#include +#include +#include +#include +#include +#include + + +#endif // PYTHON_BINDINGS_H diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml new file mode 100644 index 00000000..5a8d2703 --- /dev/null +++ b/python/PythonBindings.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/python/actions/CMakeLists.txt b/python/actions/CMakeLists.txt new file mode 100644 index 00000000..489c8057 --- /dev/null +++ b/python/actions/CMakeLists.txt @@ -0,0 +1,24 @@ +# +# DO NOT EDIT THIS FILE (unless you REALLY know what you are doing) +# +# To add a component, just add a subdirectory (the component name is the +# directory name). Add all your code there and a text file called +# CMakeLists.txt +# In your CMakeLists.txt, use the camitk_extension(ACTION_EXTENSION ...) macro appropriately +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# find components +get_subdirectories(ACTIONS_MESH_LIST) + +# Add subdirectories in CMake project +foreach(ACTION_NAME ${ACTIONS_MESH_LIST}) + add_subdirectory(${ACTION_NAME}) +endforeach() + diff --git a/python/actions/application/CMakeLists.txt b/python/actions/application/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/application/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/application/global_sdk_actions_application.h b/python/actions/application/global_sdk_actions_application.h new file mode 100644 index 00000000..e2ac564c --- /dev/null +++ b/python/actions/application/global_sdk_actions_application.h @@ -0,0 +1,23 @@ +// local header files +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + diff --git a/python/actions/application/typesystem_sdk_actions_application.xml b/python/actions/application/typesystem_sdk_actions_application.xml new file mode 100644 index 00000000..78563dee --- /dev/null +++ b/python/actions/application/typesystem_sdk_actions_application.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/actions/global_sdk_actions.h b/python/actions/global_sdk_actions.h new file mode 100644 index 00000000..0123593c --- /dev/null +++ b/python/actions/global_sdk_actions.h @@ -0,0 +1,5 @@ +// subdirectories header files +#include "./application/global_sdk_actions_application.h" +#include "./image/global_sdk_actions_image.h" +#include "./mesh/global_sdk_actions_mesh.h" + diff --git a/python/actions/image/CMakeLists.txt b/python/actions/image/CMakeLists.txt new file mode 100644 index 00000000..31f261cf --- /dev/null +++ b/python/actions/image/CMakeLists.txt @@ -0,0 +1,16 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# find actions +get_subdirectories(ACTIONS_IMAGE_LIST) + +# Add subdirectories in CMake project +foreach(ACTION_NAME ${ACTIONS_IMAGE_LIST}) + add_subdirectory(${ACTION_NAME}) +endforeach() \ No newline at end of file diff --git a/python/actions/image/arbitraryslice/CMakeLists.txt b/python/actions/image/arbitraryslice/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/image/arbitraryslice/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h b/python/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h new file mode 100644 index 00000000..271f06a9 --- /dev/null +++ b/python/actions/image/arbitraryslice/global_sdk_actions_image_arbitraryslice.h @@ -0,0 +1,6 @@ +// local header files +#include +#include +#include + + diff --git a/python/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml b/python/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml new file mode 100644 index 00000000..59a8d9fe --- /dev/null +++ b/python/actions/image/arbitraryslice/typesystem_sdk_actions_image_arbitraryslice.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/python/actions/image/cropvolume/CMakeLists.txt b/python/actions/image/cropvolume/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/image/cropvolume/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h b/python/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h new file mode 100644 index 00000000..a188dcb7 --- /dev/null +++ b/python/actions/image/cropvolume/global_sdk_actions_image_cropvolume.h @@ -0,0 +1,5 @@ +// local header files +#include +#include +#include + diff --git a/python/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml b/python/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml new file mode 100644 index 00000000..18d49759 --- /dev/null +++ b/python/actions/image/cropvolume/typesystem_sdk_actions_image_cropvolume.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/python/actions/image/global_sdk_actions_image.h b/python/actions/image/global_sdk_actions_image.h new file mode 100644 index 00000000..eeabce11 --- /dev/null +++ b/python/actions/image/global_sdk_actions_image.h @@ -0,0 +1,8 @@ +// local header files +#include "./arbitraryslice/global_sdk_actions_image_arbitraryslice.h" +#include "./cropvolume/global_sdk_actions_image_cropvolume.h" +#include "./imagelut/global_sdk_actions_image_imagelut.h" +#include "./multipicking/global_sdk_actions_image_multipicking.h" +#include "./reconstruction/global_sdk_actions_image_reconstruction.h" +#include "./showin3d/global_sdk_actions_image_showin3d.h" +#include "./volumerendering/global_sdk_actions_image_volumerendering.h" \ No newline at end of file diff --git a/python/actions/image/imagelut/CMakeLists.txt b/python/actions/image/imagelut/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/image/imagelut/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/image/imagelut/global_sdk_actions_image_imagelut.h b/python/actions/image/imagelut/global_sdk_actions_image_imagelut.h new file mode 100644 index 00000000..fcf92947 --- /dev/null +++ b/python/actions/image/imagelut/global_sdk_actions_image_imagelut.h @@ -0,0 +1,4 @@ +// local header files +#include +#include +#include diff --git a/python/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml b/python/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml new file mode 100644 index 00000000..6a4ded74 --- /dev/null +++ b/python/actions/image/imagelut/typesystem_sdk_actions_image_imagelut.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/python/actions/image/multipicking/CMakeLists.txt b/python/actions/image/multipicking/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/image/multipicking/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/image/multipicking/global_sdk_actions_image_multipicking.h b/python/actions/image/multipicking/global_sdk_actions_image_multipicking.h new file mode 100644 index 00000000..1e43cdbc --- /dev/null +++ b/python/actions/image/multipicking/global_sdk_actions_image_multipicking.h @@ -0,0 +1,7 @@ +// local header files +#include +#include +#include +#include +#include + diff --git a/python/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml b/python/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml new file mode 100644 index 00000000..5f510995 --- /dev/null +++ b/python/actions/image/multipicking/typesystem_sdk_actions_image_multipicking.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/python/actions/image/reconstruction/CMakeLists.txt b/python/actions/image/reconstruction/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/image/reconstruction/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h b/python/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h new file mode 100644 index 00000000..2d06b1be --- /dev/null +++ b/python/actions/image/reconstruction/global_sdk_actions_image_reconstruction.h @@ -0,0 +1,4 @@ +// local header files +#include +#include + diff --git a/python/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml b/python/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml new file mode 100644 index 00000000..4b1ef49e --- /dev/null +++ b/python/actions/image/reconstruction/typesystem_sdk_actions_image_reconstruction.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/python/actions/image/showin3d/CMakeLists.txt b/python/actions/image/showin3d/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/image/showin3d/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/image/showin3d/global_sdk_actions_image_showin3d.h b/python/actions/image/showin3d/global_sdk_actions_image_showin3d.h new file mode 100644 index 00000000..909de37a --- /dev/null +++ b/python/actions/image/showin3d/global_sdk_actions_image_showin3d.h @@ -0,0 +1,7 @@ +// local header files +#include +#include +#include +#include +#include +#include diff --git a/python/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml b/python/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml new file mode 100644 index 00000000..386fbcb0 --- /dev/null +++ b/python/actions/image/showin3d/typesystem_sdk_actions_image_showin3d.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/python/actions/image/typesystem_sdk_actions_image.xml b/python/actions/image/typesystem_sdk_actions_image.xml new file mode 100644 index 00000000..35abd1ef --- /dev/null +++ b/python/actions/image/typesystem_sdk_actions_image.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/python/actions/image/volumerendering/CMakeLists.txt b/python/actions/image/volumerendering/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/image/volumerendering/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h b/python/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h new file mode 100644 index 00000000..b06c8387 --- /dev/null +++ b/python/actions/image/volumerendering/global_sdk_actions_image_volumerendering.h @@ -0,0 +1,8 @@ +// local header files +#include +#include +#include +#include +#include +#include + diff --git a/python/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml b/python/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml new file mode 100644 index 00000000..8e4a4ada --- /dev/null +++ b/python/actions/image/volumerendering/typesystem_sdk_actions_image_volumerendering.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/python/actions/mesh/CMakeLists.txt b/python/actions/mesh/CMakeLists.txt new file mode 100644 index 00000000..a5c25355 --- /dev/null +++ b/python/actions/mesh/CMakeLists.txt @@ -0,0 +1,16 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# find mesh component +get_subdirectories(MESHCOMP_LIST) + +# Add subdirectories in CMake project +foreach(MESHCOMP_NAME ${MESHCOMP_LIST}) + add_subdirectory(${MESHCOMP_NAME}) +endforeach() diff --git a/python/actions/mesh/basicmesh/CMakeLists.txt b/python/actions/mesh/basicmesh/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/mesh/basicmesh/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h b/python/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h new file mode 100644 index 00000000..f142d0df --- /dev/null +++ b/python/actions/mesh/basicmesh/global_sdk_actions_mesh_basicmesh.h @@ -0,0 +1,10 @@ +// local header files +#include +#include +#include +#include +#include +#include +#include +#include + diff --git a/python/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml b/python/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml new file mode 100644 index 00000000..67c59fbc --- /dev/null +++ b/python/actions/mesh/basicmesh/typesystem_sdk_actions_mesh_basicmesh.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/python/actions/mesh/basictopology/CMakeLists.txt b/python/actions/mesh/basictopology/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/mesh/basictopology/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h b/python/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h new file mode 100644 index 00000000..406f374d --- /dev/null +++ b/python/actions/mesh/basictopology/global_sdk_actions_mesh_basictopology.h @@ -0,0 +1,4 @@ +// local header files +#include +#include +#include diff --git a/python/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml b/python/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml new file mode 100644 index 00000000..f835eaa7 --- /dev/null +++ b/python/actions/mesh/basictopology/typesystem_sdk_actions_mesh_basictopology.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/python/actions/mesh/global_sdk_actions_mesh.h b/python/actions/mesh/global_sdk_actions_mesh.h new file mode 100644 index 00000000..dc0a39f0 --- /dev/null +++ b/python/actions/mesh/global_sdk_actions_mesh.h @@ -0,0 +1,7 @@ +// subdirectories header files +#include "./basicmesh/global_sdk_actions_mesh_basicmesh.h" +#include "./basictopology/global_sdk_actions_mesh_basictopology.h" +#include "./meshprocessing/global_sdk_actions_mesh_meshprocessing.h" + +// local header files + diff --git a/python/actions/mesh/meshprocessing/CMakeLists.txt b/python/actions/mesh/meshprocessing/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/actions/mesh/meshprocessing/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h b/python/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h new file mode 100644 index 00000000..112902cd --- /dev/null +++ b/python/actions/mesh/meshprocessing/global_sdk_actions_mesh_meshprocessing.h @@ -0,0 +1,10 @@ +// local header files +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/python/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml b/python/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml new file mode 100644 index 00000000..ee3cf831 --- /dev/null +++ b/python/actions/mesh/meshprocessing/typesystem_sdk_actions_mesh_meshprocessing.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/python/actions/mesh/typesystem_sdk_actions_mesh.xml b/python/actions/mesh/typesystem_sdk_actions_mesh.xml new file mode 100644 index 00000000..a060c404 --- /dev/null +++ b/python/actions/mesh/typesystem_sdk_actions_mesh.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/python/actions/typesystem_sdk_actions.xml b/python/actions/typesystem_sdk_actions.xml new file mode 100644 index 00000000..0da9df76 --- /dev/null +++ b/python/actions/typesystem_sdk_actions.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/python/applications/CMakeLists.txt b/python/applications/CMakeLists.txt new file mode 100644 index 00000000..f46746a4 --- /dev/null +++ b/python/applications/CMakeLists.txt @@ -0,0 +1,24 @@ +# +# DO NOT EDIT THIS FILE (unless you REALLY know what you are doing) +# +# To add an application, just add a subdirectory (the application name is the +# directory name). Add all your code there and a text file called +# CMakeLists.txt +# In your CMakeLists.txt, use the camitk_application() macro appropriately + +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# Find applications +get_subdirectories(APPLICATIONS_LIST) + +# --- add every given application +foreach(APPLICATION_NAME ${APPLICATIONS_LIST}) + add_subdirectory(${APPLICATION_NAME}) +endforeach() diff --git a/python/applications/actionstatemachine/CMakeLists.txt b/python/applications/actionstatemachine/CMakeLists.txt new file mode 100644 index 00000000..6074ca53 --- /dev/null +++ b/python/applications/actionstatemachine/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h b/python/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h new file mode 100644 index 00000000..043409e3 --- /dev/null +++ b/python/applications/actionstatemachine/global_sdk_applications_actionstatemachine.h @@ -0,0 +1,3 @@ +// local header files + + diff --git a/python/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml b/python/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml new file mode 100644 index 00000000..a6d50676 --- /dev/null +++ b/python/applications/actionstatemachine/typesystem_sdk_applications_actionstatemachine.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/python/applications/config/CMakeLists.txt b/python/applications/config/CMakeLists.txt new file mode 100644 index 00000000..653139d0 --- /dev/null +++ b/python/applications/config/CMakeLists.txt @@ -0,0 +1,9 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + diff --git a/python/applications/config/global_sdk_applications_config.h b/python/applications/config/global_sdk_applications_config.h new file mode 100644 index 00000000..043409e3 --- /dev/null +++ b/python/applications/config/global_sdk_applications_config.h @@ -0,0 +1,3 @@ +// local header files + + diff --git a/python/applications/config/typesystem_sdk_applications_config.xml b/python/applications/config/typesystem_sdk_applications_config.xml new file mode 100644 index 00000000..a584aed0 --- /dev/null +++ b/python/applications/config/typesystem_sdk_applications_config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/python/applications/global_sdk_applications.h b/python/applications/global_sdk_applications.h new file mode 100644 index 00000000..850b3b5f --- /dev/null +++ b/python/applications/global_sdk_applications.h @@ -0,0 +1,5 @@ +// subdirectories header files +#include "./actionstatemachine/global_sdk_applications_actionstatemachine.h" +#include "./config/global_sdk_applications_config.h" +#include "./imp/global_sdk_applications_imp.h" +#include "./wizard/global_sdk_applications_wizard.h" diff --git a/python/applications/imp/CMakeLists.txt b/python/applications/imp/CMakeLists.txt new file mode 100644 index 00000000..6074ca53 --- /dev/null +++ b/python/applications/imp/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/applications/imp/global_sdk_applications_imp.h b/python/applications/imp/global_sdk_applications_imp.h new file mode 100644 index 00000000..3b5ea92c --- /dev/null +++ b/python/applications/imp/global_sdk_applications_imp.h @@ -0,0 +1,3 @@ +// local header files +#include + diff --git a/python/applications/imp/typesystem_sdk_applications_imp.xml b/python/applications/imp/typesystem_sdk_applications_imp.xml new file mode 100644 index 00000000..9673db75 --- /dev/null +++ b/python/applications/imp/typesystem_sdk_applications_imp.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/python/applications/typesystem_sdk_applications.xml b/python/applications/typesystem_sdk_applications.xml new file mode 100644 index 00000000..8e224c14 --- /dev/null +++ b/python/applications/typesystem_sdk_applications.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/python/applications/wizard/CMakeLists.txt b/python/applications/wizard/CMakeLists.txt new file mode 100644 index 00000000..6074ca53 --- /dev/null +++ b/python/applications/wizard/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/applications/wizard/global_sdk_applications_wizard.h b/python/applications/wizard/global_sdk_applications_wizard.h new file mode 100644 index 00000000..043409e3 --- /dev/null +++ b/python/applications/wizard/global_sdk_applications_wizard.h @@ -0,0 +1,3 @@ +// local header files + + diff --git a/python/applications/wizard/typesystem_sdk_applications_wizard.xml b/python/applications/wizard/typesystem_sdk_applications_wizard.xml new file mode 100644 index 00000000..a584aed0 --- /dev/null +++ b/python/applications/wizard/typesystem_sdk_applications_wizard.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/python/components/CMakeLists.txt b/python/components/CMakeLists.txt new file mode 100644 index 00000000..476aba6a --- /dev/null +++ b/python/components/CMakeLists.txt @@ -0,0 +1,23 @@ +# +# DO NOT EDIT THIS FILE (unless you REALLY know what you are doing) +# +# To add a component, just add a subdirectory (the component name is the +# directory name). Add all your code there and a text file called +# CMakeLists.txt +# In your CMakeLists.txt, use the camitk_extension(COMPONENT_EXTENSION ...) macro appropriately +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# find components +get_subdirectories(COMPONENTS_LIST) + +# Add subdirectories in CMake project +foreach(COMPONENT_NAME ${COMPONENTS_LIST}) + add_subdirectory(${COMPONENT_NAME}) +endforeach() \ No newline at end of file diff --git a/python/components/global_sdk_components.h b/python/components/global_sdk_components.h new file mode 100644 index 00000000..e15e563a --- /dev/null +++ b/python/components/global_sdk_components.h @@ -0,0 +1,8 @@ +// subdirectories header files +#include "./msh/global_sdk_components_msh.h" +#include "./obj/global_sdk_components_obj.h" +#include "./off/global_sdk_components_off.h" +#include "./vrml/global_sdk_components_vrml.h" +#include "./vtkimage/global_sdk_components_vtkimage.h" +#include "./vtkmesh/global_sdk_components_vtkmesh.h" + diff --git a/python/components/msh/CMakeLists.txt b/python/components/msh/CMakeLists.txt new file mode 100644 index 00000000..6074ca53 --- /dev/null +++ b/python/components/msh/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/components/msh/global_sdk_components_msh.h b/python/components/msh/global_sdk_components_msh.h new file mode 100644 index 00000000..dd07d64b --- /dev/null +++ b/python/components/msh/global_sdk_components_msh.h @@ -0,0 +1,4 @@ +// local header files + + + diff --git a/python/components/msh/typesystem_sdk_components_msh.xml b/python/components/msh/typesystem_sdk_components_msh.xml new file mode 100644 index 00000000..4bb90f32 --- /dev/null +++ b/python/components/msh/typesystem_sdk_components_msh.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/python/components/obj/CMakeLists.txt b/python/components/obj/CMakeLists.txt new file mode 100644 index 00000000..0e30981b --- /dev/null +++ b/python/components/obj/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/components/obj/global_sdk_components_obj.h b/python/components/obj/global_sdk_components_obj.h new file mode 100644 index 00000000..dd07d64b --- /dev/null +++ b/python/components/obj/global_sdk_components_obj.h @@ -0,0 +1,4 @@ +// local header files + + + diff --git a/python/components/obj/typesystem_sdk_components_obj.xml b/python/components/obj/typesystem_sdk_components_obj.xml new file mode 100644 index 00000000..4bb90f32 --- /dev/null +++ b/python/components/obj/typesystem_sdk_components_obj.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/python/components/off/CMakeLists.txt b/python/components/off/CMakeLists.txt new file mode 100644 index 00000000..0e30981b --- /dev/null +++ b/python/components/off/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/components/off/global_sdk_components_off.h b/python/components/off/global_sdk_components_off.h new file mode 100644 index 00000000..dd07d64b --- /dev/null +++ b/python/components/off/global_sdk_components_off.h @@ -0,0 +1,4 @@ +// local header files + + + diff --git a/python/components/off/typesystem_sdk_components_off.xml b/python/components/off/typesystem_sdk_components_off.xml new file mode 100644 index 00000000..4bb90f32 --- /dev/null +++ b/python/components/off/typesystem_sdk_components_off.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/python/components/typesystem_sdk_components.xml b/python/components/typesystem_sdk_components.xml new file mode 100644 index 00000000..28854575 --- /dev/null +++ b/python/components/typesystem_sdk_components.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/python/components/vrml/CMakeLists.txt b/python/components/vrml/CMakeLists.txt new file mode 100644 index 00000000..6074ca53 --- /dev/null +++ b/python/components/vrml/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/components/vrml/global_sdk_components_vrml.h b/python/components/vrml/global_sdk_components_vrml.h new file mode 100644 index 00000000..dd07d64b --- /dev/null +++ b/python/components/vrml/global_sdk_components_vrml.h @@ -0,0 +1,4 @@ +// local header files + + + diff --git a/python/components/vrml/typesystem_sdk_components_vrml.xml b/python/components/vrml/typesystem_sdk_components_vrml.xml new file mode 100644 index 00000000..4bb90f32 --- /dev/null +++ b/python/components/vrml/typesystem_sdk_components_vrml.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/python/components/vtkimage/CMakeLists.txt b/python/components/vtkimage/CMakeLists.txt new file mode 100644 index 00000000..0e30981b --- /dev/null +++ b/python/components/vtkimage/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/components/vtkimage/global_sdk_components_vtkimage.h b/python/components/vtkimage/global_sdk_components_vtkimage.h new file mode 100644 index 00000000..dd07d64b --- /dev/null +++ b/python/components/vtkimage/global_sdk_components_vtkimage.h @@ -0,0 +1,4 @@ +// local header files + + + diff --git a/python/components/vtkimage/typesystem_sdk_components_vtkimage.xml b/python/components/vtkimage/typesystem_sdk_components_vtkimage.xml new file mode 100644 index 00000000..4bb90f32 --- /dev/null +++ b/python/components/vtkimage/typesystem_sdk_components_vtkimage.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/python/components/vtkmesh/CMakeLists.txt b/python/components/vtkmesh/CMakeLists.txt new file mode 100644 index 00000000..0e30981b --- /dev/null +++ b/python/components/vtkmesh/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/components/vtkmesh/global_sdk_components_vtkmesh.h b/python/components/vtkmesh/global_sdk_components_vtkmesh.h new file mode 100644 index 00000000..dd07d64b --- /dev/null +++ b/python/components/vtkmesh/global_sdk_components_vtkmesh.h @@ -0,0 +1,4 @@ +// local header files + + + diff --git a/python/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml b/python/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml new file mode 100644 index 00000000..4bb90f32 --- /dev/null +++ b/python/components/vtkmesh/typesystem_sdk_components_vtkmesh.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/python/global_sdk.h b/python/global_sdk.h new file mode 100644 index 00000000..0690477a --- /dev/null +++ b/python/global_sdk.h @@ -0,0 +1,17 @@ +#undef QT_NO_STL +#undef QT_NO_STL_WCHAR + +#ifndef NULL +#define NULL 0 +#endif + +// the PySide global.h file, containing common Qt Python declaration +#include "pyside_global.h" + +// subdirectories header files +#include "./actions/global_sdk_actions.h" +#include "./applications/global_sdk_applications.h" +#include "./components/global_sdk_components.h" +#include "./libraries/global_sdk_libraries.h" + +// include here the classes you want to be exposed to Python diff --git a/python/libraries/CMakeLists.txt b/python/libraries/CMakeLists.txt new file mode 100644 index 00000000..2d0bbc1e --- /dev/null +++ b/python/libraries/CMakeLists.txt @@ -0,0 +1,25 @@ +# +# DO NOT EDIT THIS FILE (unless you REALLY know what you are doing) +# +# To add a library, just add a subdirectory (the application name is the +# directory name). Add all your code there and a text file called +# CMakeLists.txt +# In your CMakeLists.txt, use the camitk_library() macro appropriately + +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# Find libraries +get_subdirectories(LIBRARY_LIST) + +# --- add every given library +foreach(LIB_NAME ${LIBRARY_LIST}) + add_subdirectory(${LIB_NAME}) +endforeach() + diff --git a/python/libraries/core/CMakeLists.txt b/python/libraries/core/CMakeLists.txt new file mode 100644 index 00000000..65b80db4 --- /dev/null +++ b/python/libraries/core/CMakeLists.txt @@ -0,0 +1,16 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# Find core subdirectories +get_subdirectories(CORE_SUBDIR_LIST) + +# --- add every given library +foreach(LIB_NAME ${CORE_SUBDIR_LIST}) + add_subdirectory(${LIB_NAME}) +endforeach() \ No newline at end of file diff --git a/python/libraries/core/action/CMakeLists.txt b/python/libraries/core/action/CMakeLists.txt new file mode 100644 index 00000000..6074ca53 --- /dev/null +++ b/python/libraries/core/action/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/libraries/core/action/global_sdk_libraries_core_action.h b/python/libraries/core/action/global_sdk_libraries_core_action.h new file mode 100644 index 00000000..d5455394 --- /dev/null +++ b/python/libraries/core/action/global_sdk_libraries_core_action.h @@ -0,0 +1,7 @@ +// local header files +#include +#include +#include + + + diff --git a/python/libraries/core/action/typesystem_sdk_libraries_core_action.xml b/python/libraries/core/action/typesystem_sdk_libraries_core_action.xml new file mode 100644 index 00000000..2451f8b4 --- /dev/null +++ b/python/libraries/core/action/typesystem_sdk_libraries_core_action.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/python/libraries/core/application/CMakeLists.txt b/python/libraries/core/application/CMakeLists.txt new file mode 100644 index 00000000..0e30981b --- /dev/null +++ b/python/libraries/core/application/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/libraries/core/application/global_sdk_libraries_core_application.h b/python/libraries/core/application/global_sdk_libraries_core_application.h new file mode 100644 index 00000000..88abab79 --- /dev/null +++ b/python/libraries/core/application/global_sdk_libraries_core_application.h @@ -0,0 +1,9 @@ +// local header files +#include +#include +#include + + + + + diff --git a/python/libraries/core/application/typesystem_sdk_libraries_core_application.xml b/python/libraries/core/application/typesystem_sdk_libraries_core_application.xml new file mode 100644 index 00000000..d7915118 --- /dev/null +++ b/python/libraries/core/application/typesystem_sdk_libraries_core_application.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + int argc; + char** argv; + if (!Shiboken::sequenceToArgcArgv(%PYARG_2, &argc, &argv, %1.toStdString().c_str())) { + PyErr_SetString(PyExc_TypeError, "error"); + return 0; + } + + // Shiboken asks to call %FUNCTION_NAME in the injected code + // here we don't need it ( %0 = (%CPPTYPEWrapper *)%CONVERTTOPYTHON[camitk::%CPPTYPE](app); doesn't work) + // simply delete it and directly call application wrapper + // TODO : understand how the conversion / wrapper handle objects + // If we comment the 2 above lines, the imp application (throught imp.py) will seg fault at runtime. + camitk::%CPPTYPE* app = new %FUNCTION_NAME(%1, argc, argv, %4, %5); + delete app; + + %0 = new %CPPTYPEWrapper(%1, argc, argv, %4, %5); + + delete[] argv; + + + + + + + diff --git a/python/libraries/core/component/CMakeLists.txt b/python/libraries/core/component/CMakeLists.txt new file mode 100644 index 00000000..f20dbba8 --- /dev/null +++ b/python/libraries/core/component/CMakeLists.txt @@ -0,0 +1,16 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# Find core subdirectories +get_subdirectories(CORE_COMPONENT_SUBDIR_LIST) + +# --- add every given library +foreach(COMP_NAME ${CORE_COMPONENT_SUBDIR_LIST}) + add_subdirectory(${COMP_NAME}) +endforeach() \ No newline at end of file diff --git a/python/libraries/core/component/global_sdk_libraries_core_component.h b/python/libraries/core/component/global_sdk_libraries_core_component.h new file mode 100644 index 00000000..e7e04fe7 --- /dev/null +++ b/python/libraries/core/component/global_sdk_libraries_core_component.h @@ -0,0 +1,12 @@ +// subdirectories header files +#include "./component/image/global_sdk_libraries_core_component_image.h" +#include "./component/mesh/global_sdk_libraries_core_component_mesh.h" + +// local header files +#include +#include +#include +#include +#include + + diff --git a/python/libraries/core/component/image/CMakeLists.txt b/python/libraries/core/component/image/CMakeLists.txt new file mode 100644 index 00000000..0e30981b --- /dev/null +++ b/python/libraries/core/component/image/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/libraries/core/component/image/global_sdk_libraries_core_component_image.h b/python/libraries/core/component/image/global_sdk_libraries_core_component_image.h new file mode 100644 index 00000000..163ae4dc --- /dev/null +++ b/python/libraries/core/component/image/global_sdk_libraries_core_component_image.h @@ -0,0 +1,6 @@ +// local header files +#include +#include +#include +#include + diff --git a/python/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml b/python/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml new file mode 100644 index 00000000..f6174094 --- /dev/null +++ b/python/libraries/core/component/image/typesystem_sdk_libraries_core_component_image.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/python/libraries/core/component/mesh/CMakeLists.txt b/python/libraries/core/component/mesh/CMakeLists.txt new file mode 100644 index 00000000..0e30981b --- /dev/null +++ b/python/libraries/core/component/mesh/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h b/python/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h new file mode 100644 index 00000000..8055fecc --- /dev/null +++ b/python/libraries/core/component/mesh/global_sdk_libraries_core_component_mesh.h @@ -0,0 +1,6 @@ +// local header files +#include +#include + + + diff --git a/python/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml b/python/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml new file mode 100644 index 00000000..0f78c75b --- /dev/null +++ b/python/libraries/core/component/mesh/typesystem_sdk_libraries_core_component_mesh.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/python/libraries/core/component/typesystem_sdk_libraries_core_component.xml b/python/libraries/core/component/typesystem_sdk_libraries_core_component.xml new file mode 100644 index 00000000..dac8db6a --- /dev/null +++ b/python/libraries/core/component/typesystem_sdk_libraries_core_component.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + // Force Shiboken not to instantiate Component (which is abstract) throught ComponentWrapper constructor + + // Let Shiboken believes we have called the constructor, which is not the case due to comments. + // cptr = new ComponentWrapper(); + + + + + // Force Shiboken not to instantiate Component (which is abstract) throught ComponentWrapper constructor + + // Let Shiboken believes we have called the constructor, which is not the case due to comments. + // cptr = new ComponentWrapper(); + + + + + + + + + + // Force Shiboken not to instantiate InterfaceNode (which is abstract) throught InterfaceNodeWrapper constructor + + // Let Shiboken believes we have called the constructor, which is not the case due to comments. + // cptr = new InterfaceNodeWrapper(); + + + + + + + + // Force Shiboken not to instantiate InterfaceBitMap (which is abstract) throught InterfaceBitMapWrapper constructor + + // Let Shiboken believes we have called the constructor, which is not the case due to comments. + // cptr = new InterfaceBitMapWrapper(); + + + + + + + + + // Force Shiboken not to instantiate InterfaceGeometry (which is abstract) throught InterfaceGeometryWrapper constructor + + // Let Shiboken believes we have called the constructor, which is not the case due to comments. + // cptr = new InterfaceGeometryWrapper(); + + + + + + + + + + + // Force Shiboken not to instantiate InterfaceProperty (which is abstract) throught InterfacePropertyWrapper constructor + + // Let Shiboken believes we have called the constructor, which is not the case due to comments. + // cptr = new InterfacePropertyWrapper(); + + + + + + diff --git a/python/libraries/core/global_sdk_libraries_core.h b/python/libraries/core/global_sdk_libraries_core.h new file mode 100644 index 00000000..324520da --- /dev/null +++ b/python/libraries/core/global_sdk_libraries_core.h @@ -0,0 +1,13 @@ +// subdirectories header files +#include "./action/global_sdk_libraries_core_action.h" +#include "./application/global_sdk_libraries_core_application.h" +#include "./component/global_sdk_libraries_core_component.h" +#include "./utils/global_sdk_libraries_core_utils.h" +#include "./viewer/global_sdk_libraries_core_viewer.h" + +// include here the classes you want to be exposed to Python for sdk/library/core +#include +#include +#include +// #include + diff --git a/python/libraries/core/typesystem_sdk_libraries_core.xml b/python/libraries/core/typesystem_sdk_libraries_core.xml new file mode 100644 index 00000000..805ea25b --- /dev/null +++ b/python/libraries/core/typesystem_sdk_libraries_core.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + diff --git a/python/libraries/core/utils/CMakeLists.txt b/python/libraries/core/utils/CMakeLists.txt new file mode 100644 index 00000000..0e30981b --- /dev/null +++ b/python/libraries/core/utils/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/libraries/core/utils/global_sdk_libraries_core_utils.h b/python/libraries/core/utils/global_sdk_libraries_core_utils.h new file mode 100644 index 00000000..5a16f3a0 --- /dev/null +++ b/python/libraries/core/utils/global_sdk_libraries_core_utils.h @@ -0,0 +1,11 @@ +// local header files +// #include +#include +// #include +#include +#include +#include + + + + diff --git a/python/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml b/python/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml new file mode 100644 index 00000000..581e8591 --- /dev/null +++ b/python/libraries/core/utils/typesystem_sdk_libraries_core_utils.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/python/libraries/core/viewer/CMakeLists.txt b/python/libraries/core/viewer/CMakeLists.txt new file mode 100644 index 00000000..6074ca53 --- /dev/null +++ b/python/libraries/core/viewer/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/libraries/core/viewer/global_sdk_libraries_core_viewer.h b/python/libraries/core/viewer/global_sdk_libraries_core_viewer.h new file mode 100644 index 00000000..c1598f17 --- /dev/null +++ b/python/libraries/core/viewer/global_sdk_libraries_core_viewer.h @@ -0,0 +1,9 @@ +// local header files +#include +#include +#include +#include +#include + + + diff --git a/python/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml b/python/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml new file mode 100644 index 00000000..1d874b40 --- /dev/null +++ b/python/libraries/core/viewer/typesystem_sdk_libraries_core_viewer.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/python/libraries/coreschema/CMakeLists.txt b/python/libraries/coreschema/CMakeLists.txt new file mode 100644 index 00000000..4a046d7b --- /dev/null +++ b/python/libraries/coreschema/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml adn global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/libraries/coreschema/global_sdk_libraries_coreschema.h b/python/libraries/coreschema/global_sdk_libraries_coreschema.h new file mode 100644 index 00000000..65a7ec2d --- /dev/null +++ b/python/libraries/coreschema/global_sdk_libraries_coreschema.h @@ -0,0 +1,5 @@ +// local header files + + + + diff --git a/python/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml b/python/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml new file mode 100644 index 00000000..6c94ddf2 --- /dev/null +++ b/python/libraries/coreschema/typesystem_sdk_libraries_coreschema.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/python/libraries/global_sdk_libraries.h b/python/libraries/global_sdk_libraries.h new file mode 100644 index 00000000..dbc1905a --- /dev/null +++ b/python/libraries/global_sdk_libraries.h @@ -0,0 +1,7 @@ +// subdirectories header files +#include "./core/global_sdk_libraries_core.h" +#include "./coreschema/global_sdk_libraries_coreschema.h" +#include "./qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h" + + + diff --git a/python/libraries/qtpropertybrowser/CMakeLists.txt b/python/libraries/qtpropertybrowser/CMakeLists.txt new file mode 100644 index 00000000..fe126730 --- /dev/null +++ b/python/libraries/qtpropertybrowser/CMakeLists.txt @@ -0,0 +1,8 @@ +#--------------------------------------------------------------------------------- +# +# Recursively parse subdirectories for classes to expose +# +#--------------------------------------------------------------------------------- +# Shiboken PATH to look for typesystem.xml and global.h files, recursively udapted +set(SHIBOKEN_TYPESYSTEM_PATH ${SHIBOKEN_TYPESYSTEM_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +set(SHIBOKEN_GLOBAL_H_PATH ${SHIBOKEN_GLOBAL_H_PATH}:${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") diff --git a/python/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h b/python/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h new file mode 100644 index 00000000..65a7ec2d --- /dev/null +++ b/python/libraries/qtpropertybrowser/global_sdk_libraries_qtpropertybrowser.h @@ -0,0 +1,5 @@ +// local header files + + + + diff --git a/python/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml b/python/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml new file mode 100644 index 00000000..6c94ddf2 --- /dev/null +++ b/python/libraries/qtpropertybrowser/typesystem_sdk_libraries_qtpropertybrowser.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/python/libraries/typesystem_sdk_libraries.xml b/python/libraries/typesystem_sdk_libraries.xml new file mode 100644 index 00000000..f325903e --- /dev/null +++ b/python/libraries/typesystem_sdk_libraries.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/python/pyside2_config.py b/python/pyside2_config.py new file mode 100755 index 00000000..298d40d5 --- /dev/null +++ b/python/pyside2_config.py @@ -0,0 +1,302 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: http://www.qt.io/licensing/ +## +## This file is part of the Qt for Python examples of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:BSD$ +## You may use this file under the terms of the BSD license as follows: +## +## "Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions are +## met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in +## the documentation and/or other materials provided with the +## distribution. +## * Neither the name of The Qt Company Ltd nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +## +## $QT_END_LICENSE$ +## +############################################################################# + +import os, glob, re, sys, imp +from distutils import sysconfig + +usage = """ +Utility to determine include/link options of PySide2 and Python for qmake + +Usage: pyside2_config.py [option] +Options: + --python-include Print Python include path + --python-link Print Python link flags + --pyside2 Print PySide2 location + --pyside2-include Print PySide2 include paths + --pyside2-link Print PySide2 link flags + --pyside2-shared-libraries Print paths of PySide2 shared libraries (.so's, .dylib's, .dll's) + -a Print all + --help/-h Print this help +""" + +def cleanPath(path): + return path if sys.platform != 'win32' else path.replace('\\', '/') + +def sharedLibrarySuffix(): + if sys.platform == 'win32': + return 'lib' + elif sys.platform == 'darwin': + return 'dylib' + # Linux + else: + return 'so.*' + +def sharedLibraryGlobPattern(): + glob = '*.' + sharedLibrarySuffix() + return glob if sys.platform == 'win32' else 'lib' + glob + +def filterPySide2SharedLibraries(list, only_shiboken=False): + def predicate(item): + basename = os.path.basename(item) + if 'shiboken' in basename or ('pyside2' in basename and not only_shiboken): + return True + return False + result = [item for item in list if predicate(item)] + return result + +# Return qmake link option for a library file name +def linkOption(lib): + # On Linux: + # Since we cannot include symlinks with wheel packages + # we are using an absolute path for the libpyside and libshiboken + # libraries when compiling the project + baseName = os.path.basename(lib) + link = ' -l' + if sys.platform in ['linux', 'linux2']: # Linux: 'libfoo.so' -> '/absolute/path/libfoo.so' + link = lib + elif sys.platform in ['darwin']: # Darwin: 'libfoo.so' -> '-lfoo' + link += os.path.splitext(baseName[3:])[0] + else: # Windows: 'libfoo.dll' -> 'libfoo.dll' + link += os.path.splitext(baseName)[0] + return link + +# Locate PySide2 via package path +def findPySide2(): + for p in sys.path: + if 'site-' in p: + pyside2 = os.path.join(p, 'PySide2') + if os.path.exists(pyside2): + return cleanPath(os.path.realpath(pyside2)) + return None + +# Return version as "3.5" +def pythonVersion(): + return str(sys.version_info[0]) + '.' + str(sys.version_info[1]) + +def pythonInclude(): + return sysconfig.get_python_inc() + +def pythonLinkQmake(): + flags = pythonLinkData() + if sys.platform == 'win32': + libdir = flags['libdir'] + # This will add the "~1" shortcut for directories that + # contain white spaces + # e.g.: "Program Files" to "Progra~1" + for d in libdir.split("\\"): + if " " in d: + libdir = libdir.replace(d, d.split(" ")[0][:-1]+"~1") + return '-L{} -l{}'.format(libdir, flags['lib']) + elif sys.platform == 'darwin': + return '-L{} -l{}'.format(flags['libdir'], flags['lib']) + + else: + # Linux and anything else + return '-L{} -l{}'.format(flags['libdir'], flags['lib']) + +def pythonLinkCmake(): + flags = pythonLinkData() + libdir = flags['libdir'] + lib = re.sub(r'.dll$', '.lib', flags['lib']) + return '{};{}'.format(libdir, lib) + +def pythonLinkData(): + # @TODO Fix to work with static builds of Python + libdir = sysconfig.get_config_var('LIBDIR') + if libdir is None: + libdir = os.path.abspath(os.path.join( + sysconfig.get_config_var('LIBDEST'), "..", "libs")) + version = pythonVersion() + version_no_dots = version.replace('.', '') + + flags = {} + flags['libdir'] = libdir + if sys.platform == 'win32': + suffix = '_d' if any([tup[0].endswith('_d.pyd') for tup in imp.get_suffixes()]) else '' + flags['lib'] = 'python{}{}'.format(version_no_dots, suffix) + + elif sys.platform == 'darwin': + flags['lib'] = 'python{}'.format(version) + + # Linux and anything else + else: + if sys.version_info[0] < 3: + suffix = '_d' if any([tup[0].endswith('_d.so') for tup in imp.get_suffixes()]) else '' + flags['lib'] = 'python{}{}'.format(version, suffix) + else: + flags['lib'] = 'python{}{}'.format(version, sys.abiflags) + + return flags + +def pyside2Include(only_shiboken=False): + pySide2 = findPySide2() + if pySide2 is None: + return None + + includes = "{0}/include/shiboken2".format(pySide2) + if not only_shiboken: + includes = includes + " {0}/include/PySide2".format(pySide2) + + return includes + +def pyside2Link(): + pySide2 = findPySide2() + if pySide2 is None: + return None + link = "-L{}".format(pySide2) + glob_result = glob.glob(os.path.join(pySide2, sharedLibraryGlobPattern())) + for lib in filterPySide2SharedLibraries(glob_result): + link += ' ' + link += linkOption(lib) + return link + +def pyside2SharedLibrariesData(only_shiboken=False): + pySide2 = findPySide2() + if pySide2 is None: + return None + + glob_result = glob.glob(os.path.join(pySide2, sharedLibraryGlobPattern())) + filtered_libs = filterPySide2SharedLibraries(glob_result, only_shiboken) + libs = [] + if sys.platform == 'win32': + for lib in filtered_libs: + libs.append(os.path.realpath(lib)) + else: + for lib in filtered_libs: + libs.append(lib) + return libs + +def pyside2SharedLibraries(): + libs = pyside2SharedLibrariesData() + if libs is None: + return None + + if sys.platform == 'win32': + if not libs: + return '' + dlls = '' + for lib in libs: + dll = os.path.splitext(lib)[0] + '.dll' + dlls += dll + ' ' + + return dlls + else: + libs_string = '' + for lib in libs: + libs_string += lib + ' ' + return libs_string + +def pyside2SharedLibrariesCmake(only_shiboken=False): + libs = pyside2SharedLibrariesData(only_shiboken) + result = ';'.join(libs) + return result + +option = sys.argv[1] if len(sys.argv) == 2 else '-a' +if option == '-h' or option == '--help': + print(usage) + sys.exit(0) + +generic_error = (' Did you forget to activate your virtualenv? Or perhaps' + ' you forgot to build / install PySide2 into your currently active Python' + ' environment?') +pyside2_error = 'Unable to locate PySide2.' + generic_error +pyside2_libs_error = 'Unable to locate the PySide2 shared libraries.' + generic_error +python_link_error = 'Unable to locate the Python library for linking.' + +if option == '--pyside2' or option == '-a': + pySide2 = findPySide2() + if pySide2 is None: + sys.exit(pyside2_error) + print(pySide2) + +if option == '--pyside2-link' or option == '-a': + l = pyside2Link() + if l is None: + sys.exit(pyside2_error) + + print(l) + +if option == '--shiboken-include' or option == '-a': + i = pyside2Include(only_shiboken=True) + if i is None: + sys.exit(pyside2_error) + print(i) + +if option == '--pyside2-include' or option == '-a': + i = pyside2Include() + if i is None: + sys.exit(pyside2_error) + print(i) + +if option == '--python-include' or option == '-a': + i = pythonInclude() + if i is None: + sys.exit('Unable to locate the Python include headers directory.') + print(i) + +if option == '--python-link' or option == '-a': + l = pythonLinkQmake() + if l is None: + sys.exit(python_link_error) + print(l) + +if option == '--python-link-cmake' or option == '-a': + l = pythonLinkCmake() + if l is None: + sys.exit(python_link_error) + print(l) + +if option == '--pyside2-shared-libraries' or option == '-a': + l = pyside2SharedLibraries() + if l is None: + sys.exit(pyside2_libs_error) + print(l) + +if option == '--pyside2-shared-libraries-cmake' or option == '-a': + l = pyside2SharedLibrariesCmake() + if l is None: + sys.exit(pyside2_libs_error) + print(l) + +if option == '--shiboken-shared-libraries-cmake' or option == '-a': + l = pyside2SharedLibrariesCmake(only_shiboken=True) + if l is None: + sys.exit(pyside2_libs_error) + print(l) diff --git a/python/pyside_global.h b/python/pyside_global.h new file mode 100644 index 00000000..b4d6d9da --- /dev/null +++ b/python/pyside_global.h @@ -0,0 +1,417 @@ +/**************************************************************************** +** +** Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). +** +** This file is part of the QtCore module of the Qt Toolkit, plus some +** modifications by PySide team. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#undef QT_NO_STL +#undef QT_NO_STL_WCHAR +#define Q_BYTE_ORDER // used to enable QSysInfo.Endian detection on MacOSX + +#include "/usr/include/qt4/QtCore/qnamespace.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Core) + +class QByteArray; + +class QString; + +#ifndef Q_MOC_OUTPUT_REVISION +#define Q_MOC_OUTPUT_REVISION 61 +#endif + +// macro for onaming members +#ifdef METHOD +#undef METHOD +#endif +#ifdef SLOT +#undef SLOT +#endif +#ifdef SIGNAL +#undef SIGNAL +#endif + +Q_CORE_EXPORT const char* qFlagLocation(const char* method); + +#define QTOSTRING_HELPER(s) #s +#define QTOSTRING(s) QTOSTRING_HELPER(s) +#ifndef QT_NO_DEBUG +# define QLOCATION "\0"__FILE__":"QTOSTRING(__LINE__) +# define METHOD(a) qFlagLocation("0"#a QLOCATION) +# define SLOT(a) qFlagLocation("1"#a QLOCATION) +# define SIGNAL(a) qFlagLocation("2"#a QLOCATION) +#else +# define METHOD(a) "0"#a +# define SLOT(a) "1"#a +# define SIGNAL(a) "2"#a +#endif + +#ifdef QT3_SUPPORT +#define METHOD_CODE 0 // member type codes +#define SLOT_CODE 1 +#define SIGNAL_CODE 2 +#endif + +#define QMETHOD_CODE 0 // member type codes +#define QSLOT_CODE 1 +#define QSIGNAL_CODE 2 + +#define Q_ARG(type, data) QArgument(#type, data) +#define Q_RETURN_ARG(type, data) QReturnArgument(#type, data) + +class QObject; +class QMetaMethod; +class QMetaEnum; +class QMetaProperty; +class QMetaClassInfo; + + +class Q_CORE_EXPORT QGenericArgument { +public: + inline QGenericArgument(const char* aName = 0, const void* aData = 0) + : _data(aData), _name(aName) {} + inline void* data() const { + return const_cast(_data); + } + inline const char* name() const { + return _name; + } + +private: + const void* _data; + const char* _name; +}; + +class Q_CORE_EXPORT QGenericReturnArgument: public QGenericArgument { +public: + inline QGenericReturnArgument(const char* aName = 0, void* aData = 0) + : QGenericArgument(aName, aData) { + } +}; + +template +class QArgument: public QGenericArgument { +public: + inline QArgument(const char* aName, const T& aData) + : QGenericArgument(aName, static_cast(&aData)) { + } +}; + + +template +class QReturnArgument: public QGenericReturnArgument { +public: + inline QReturnArgument(const char* aName, T& aData) + : QGenericReturnArgument(aName, static_cast(&aData)) { + } +}; + +struct Q_CORE_EXPORT QMetaObject { + const char* className() const; + const QMetaObject* superClass() const; + + QObject* cast(QObject* obj) const; + +#ifndef QT_NO_TRANSLATION + // ### Qt 4: Merge overloads + QString tr(const char* s, const char* c) const; + QString trUtf8(const char* s, const char* c) const; + QString tr(const char* s, const char* c, int n) const; + QString trUtf8(const char* s, const char* c, int n) const; +#endif // QT_NO_TRANSLATION + + int methodOffset() const; + int enumeratorOffset() const; + int propertyOffset() const; + int classInfoOffset() const; + + int constructorCount() const; + int methodCount() const; + int enumeratorCount() const; + int propertyCount() const; + int classInfoCount() const; + + int indexOfConstructor(const char* constructor) const; + int indexOfMethod(const char* method) const; + int indexOfSignal(const char* signal) const; + int indexOfSlot(const char* slot) const; + int indexOfEnumerator(const char* name) const; + int indexOfProperty(const char* name) const; + int indexOfClassInfo(const char* name) const; + + QMetaMethod constructor(int index) const; + QMetaMethod method(int index) const; + QMetaEnum enumerator(int index) const; + QMetaProperty property(int index) const; + QMetaClassInfo classInfo(int index) const; + QMetaProperty userProperty() const; + + static bool checkConnectArgs(const char* signal, const char* method); + static QByteArray normalizedSignature(const char* method); + static QByteArray normalizedType(const char* type); + + // internal index-based connect + static bool connect(const QObject* sender, int signal_index, + const QObject* receiver, int method_index, + int type = 0, int* types = 0); + // internal index-based disconnect + static bool disconnect(const QObject* sender, int signal_index, + const QObject* receiver, int method_index); + // internal slot-name based connect + static void connectSlotsByName(QObject* o); + + // internal index-based signal activation + static void activate(QObject* sender, int signal_index, void** argv); + static void activate(QObject* sender, int from_signal_index, int to_signal_index, void** argv); + static void activate(QObject* sender, const QMetaObject*, int local_signal_index, void** argv); + static void activate(QObject* sender, const QMetaObject*, int from_local_signal_index, int to_local_signal_index, void** argv); + // internal guarded pointers + static void addGuard(QObject** ptr); + static void removeGuard(QObject** ptr); + static void changeGuard(QObject** ptr, QObject* o); + + static bool invokeMethod(QObject* obj, const char* member, + Qt::ConnectionType, + QGenericReturnArgument ret, + QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()); + + static inline bool invokeMethod(QObject* obj, const char* member, + QGenericReturnArgument ret, + QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()) { + return invokeMethod(obj, member, Qt::AutoConnection, ret, val0, val1, val2, val3, + val4, val5, val6, val7, val8, val9); + } + + static inline bool invokeMethod(QObject* obj, const char* member, + Qt::ConnectionType type, + QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()) { + return invokeMethod(obj, member, type, QGenericReturnArgument(), val0, val1, val2, + val3, val4, val5, val6, val7, val8, val9); + } + + static inline bool invokeMethod(QObject* obj, const char* member, + QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()) { + return invokeMethod(obj, member, Qt::AutoConnection, QGenericReturnArgument(), val0, + val1, val2, val3, val4, val5, val6, val7, val8, val9); + } + + QObject* newInstance(QGenericArgument val0 = QGenericArgument(0), + QGenericArgument val1 = QGenericArgument(), + QGenericArgument val2 = QGenericArgument(), + QGenericArgument val3 = QGenericArgument(), + QGenericArgument val4 = QGenericArgument(), + QGenericArgument val5 = QGenericArgument(), + QGenericArgument val6 = QGenericArgument(), + QGenericArgument val7 = QGenericArgument(), + QGenericArgument val8 = QGenericArgument(), + QGenericArgument val9 = QGenericArgument()) const; + + enum Call { + InvokeMetaMethod, + ReadProperty, + WriteProperty, + ResetProperty, + QueryPropertyDesignable, + QueryPropertyScriptable, + QueryPropertyStored, + QueryPropertyEditable, + QueryPropertyUser, + CreateInstance + }; + + int static_metacall(Call, int, void**) const; + +#ifdef QT3_SUPPORT + QT3_SUPPORT const char* superClassName() const; +#endif + + struct { // private data + const QMetaObject* superdata; + const char* stringdata; + const uint* data; + const void* extradata; + } d; +}; + +struct QMetaObjectExtraData { + const QMetaObject** objects; + int (*static_metacall)(QMetaObject::Call, int, void**); +}; + +inline const char* QMetaObject::className() const { + return d.stringdata; +} + +inline const QMetaObject* QMetaObject::superClass() const { + return d.superdata; +} + +#ifdef QT3_SUPPORT +inline const char* QMetaObject::superClassName() const { + return d.superdata ? d.superdata->className() : 0; +} +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#define qdoc + +#if 1 +#define Q_WS_X11 +#elif 0 +#define Q_WS_MAC +#elif 0 +#include "pysidewtypes.h" +#define Q_WS_WIN +#elif 0 +#define Q_WS_SIMULATOR +#endif + +// There are symbols in Qt that exist in Debug but +// not in release +#define QT_NO_DEBUG + +#include "/usr/include/qt4/QtCore/QtCore" +#if 0 || 0 +// Workaround to parse the QApplication header +#define Q_INTERNAL_QAPP_SRC +#undef qdoc +#endif +#include "/usr/include/qt4/QtGui/QtGui" +#include "qpytextobject.h" // PySide class +#if 1 +#include "/usr/include/qt4/QtGui/QX11Info" +#include "/usr/include/qt4/QtGui/QX11EmbedContainer" +#include "/usr/include/qt4/QtGui/QX11EmbedWidget" +#elif 0 +#include "/usr/include/qt4/QtGui/qmacstyle_mac.h" +#endif +#include "/usr/include/qt4/QtXml/QtXml" +#include "/usr/include/qt4/QtUiTools/QtUiTools" +#include "/usr/include/qt4/QtNetwork/QtNetwork" +#include "/usr/include/qt4/QtScript/QtScript" +#include "/usr/include/qt4/QtScriptTools/QtScriptTools" +#include "QT_QTMULTIMEDIA_INCLUDE_DIR-NOTFOUND/QtMultimedia" +#include +#include "/usr/include/qt4/QtDeclarative/QtDeclarative" + +// QT_GUI_LIB must be defined to QSqlRelationalDelegate become visible +#define QT_GUI_LIB +#undef Q_DECLARE_INTERFACE +#include "/usr/include/qt4/QtSql/QtSql" +#include "/usr/include/qt4/QtSvg/QtSvg" + +#if 1 +# include "/usr/include/qt4/QtXmlPatterns/QtXmlPatterns" +#endif + +#if 1 +# include "/usr/include/qt4/QtWebKit/QtWebKit" +#endif + +#if 1 +# include "/usr/include/qt4/QtTest/QtTest" +#if 8 > 5 +# include "pysideqtesttouch.h" +#endif +#endif + +// Phonon +#include "phonon/pyside_phonon.h" +#include "/usr/include/qt4/phonon/abstractaudiooutput.h" +#include "/usr/include/qt4/phonon/abstractmediastream.h" +#include "/usr/include/qt4/phonon/abstractvideooutput.h" +#include "/usr/include/qt4/phonon/addoninterface.h" +#include "/usr/include/qt4/phonon/audiooutput.h" +#include "/usr/include/qt4/phonon/audiooutputinterface.h" +#include "/usr/include/qt4/phonon/backendcapabilities.h" +#include "/usr/include/qt4/phonon/backendinterface.h" +#include "/usr/include/qt4/phonon/effect.h" +#include "/usr/include/qt4/phonon/effectinterface.h" +#include "/usr/include/qt4/phonon/effectparameter.h" +#include "/usr/include/qt4/phonon/effectwidget.h" +#include "/usr/include/qt4/phonon/mediacontroller.h" +#include "/usr/include/qt4/phonon/medianode.h" +#include "/usr/include/qt4/phonon/mediaobject.h" +#include "/usr/include/qt4/phonon/mediaobjectinterface.h" +#include "/usr/include/qt4/phonon/mediasource.h" +#include "/usr/include/qt4/phonon/objectdescription.h" +#include "/usr/include/qt4/phonon/objectdescriptionmodel.h" +#include "/usr/include/qt4/phonon/path.h" +#include "/usr/include/qt4/phonon/phonon_export.h" +#include "/usr/include/qt4/phonon/phonondefs.h" +#include "/usr/include/qt4/phonon/phononnamespace.h" +#include "/usr/include/qt4/phonon/platformplugin.h" +#include "/usr/include/qt4/phonon/seekslider.h" +#include "/usr/include/qt4/phonon/streaminterface.h" +#include "/usr/include/qt4/phonon/videoplayer.h" +#include "/usr/include/qt4/phonon/videowidget.h" +#include "/usr/include/qt4/phonon/videowidgetinterface.h" +#include "/usr/include/qt4/phonon/volumefadereffect.h" +#include "/usr/include/qt4/phonon/volumefaderinterface.h" +#include "/usr/include/qt4/phonon/volumeslider.h" + +//QtHelp need be included after QtSql +#include "/usr/include/qt4/QtHelp/QtHelp" + +#ifndef QT_NO_OPENGL +#include +#include +#endif // QT_NO_OPENGL + diff --git a/python/typesystem_sdk.xml b/python/typesystem_sdk.xml new file mode 100644 index 00000000..74907496 --- /dev/null +++ b/python/typesystem_sdk.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/utils.py b/python/utils.py new file mode 100755 index 00000000..522f5356 --- /dev/null +++ b/python/utils.py @@ -0,0 +1,49 @@ +#!/usr/bin/python + +############################################################################# +## +## Copyright (C) 2016 The Qt Company Ltd. +## Contact: http://www.qt.io/licensing/ +## +## This file is part of the Qt for Python examples of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:BSD$ +## You may use this file under the terms of the BSD license as follows: +## +## "Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions are +## met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in +## the documentation and/or other materials provided with the +## distribution. +## * Neither the name of The Qt Company Ltd nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +## +## $QT_END_LICENSE$ +## +############################################################################# + +import sys +isPY3 = sys.version_info[0] == 3 + +if isPY3: + text_type = str +else: + text_type = unicode -- GitLab From e3709e20c49335a9cd7164ca3d520ac42a54c365 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 22 Feb 2019 17:37:26 +0100 Subject: [PATCH 03/24] FIXED required packages --- python/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 3223ba91..d17da0ff 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -11,9 +11,9 @@ # Requires # - libshiboken2-dev # - libpyside2-dev -# - shiboken2 -# - clang -# - llvm +# - shiboken2 (*) +# - clang (*) +# - llvm (*) # cmake ../../src/camitk -DCAMITK_BINDING_PYTHON=TRUE -- GitLab From f3bb3cc7fbb0045ab2cdd6f97dab48ebadb05ec1 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Mon, 4 Mar 2019 21:24:29 +0100 Subject: [PATCH 04/24] FIXED Core class should be more independent --- sdk/applications/wizard/main.cpp | 3 ++- sdk/libraries/core/Core.h | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/sdk/applications/wizard/main.cpp b/sdk/applications/wizard/main.cpp index 8e4980b6..c8942ae6 100644 --- a/sdk/applications/wizard/main.cpp +++ b/sdk/applications/wizard/main.cpp @@ -27,6 +27,7 @@ // CamiTK stuff #include +#include //Imports from Qt #include @@ -42,7 +43,7 @@ void usage(char* appName) { std::cerr << "Usage: " << appName << " [options]" << std::endl; std::cerr << "Build using " << camitk::Core::version << std::endl; std::cerr << std::endl; - std::cerr << "Options:" << endl; + std::cerr << "Options:" << std::endl; options::print_usage(std::cerr); } diff --git a/sdk/libraries/core/Core.h b/sdk/libraries/core/Core.h index 17f054c5..153db96f 100644 --- a/sdk/libraries/core/Core.h +++ b/sdk/libraries/core/Core.h @@ -26,16 +26,8 @@ #ifndef CAMITKCORE_H #define CAMITKCORE_H - - // -- Core stuff #include "CamiTKAPI.h" -#include "HistoryItem.h" - -// -- Qt stuff -#include - - namespace camitk { /** -- GitLab From 8b2b51156ae95d52833858e3c8bc4be75930b2c9 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Wed, 6 Mar 2019 13:33:07 +0100 Subject: [PATCH 05/24] NEW first version without "no QApplication" (still crashes though) --- python/CMakeLists.txt | 495 +++++++++++------- python/PythonBindings.h | 27 +- python/PythonBindings.xml | 296 ++++++++++- python/ShibokenHack1.cmake | 7 + python/test.py | 55 ++ python/typesystem_sdk.xml | 2 +- tutorials/applications/testlogger/main.cpp | 1 + .../applications/testloggercrash/main.cpp | 1 + 8 files changed, 693 insertions(+), 191 deletions(-) create mode 100644 python/ShibokenHack1.cmake create mode 100644 python/test.py diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d17da0ff..cb799904 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -8,14 +8,10 @@ # #-------------------------------------------- -# Requires -# - libshiboken2-dev -# - libpyside2-dev -# - shiboken2 (*) -# - clang (*) -# - llvm (*) - -# cmake ../../src/camitk -DCAMITK_BINDING_PYTHON=TRUE +# cmake ../src/camitk -DCMAKE_BUILD_TYPE=Debug -DCAMITK_BINDING_PYTHON=TRUE -DCEP_IMAGING=FALSE -DCEP_TUTORIALS=FALSE -DCEP_MODELING=FALSE +# make -j6 +# make camitk-ce-python-package +# python3 ../src/camitk/python/test.py # check also https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples/samplebinding/CMakeLists.txt?h=5.9 cmake_minimum_required(VERSION 3.1) @@ -35,42 +31,46 @@ set(CMAKE_CXX_STANDARD 11) # #-------------------------------------------- -# Greatly inspired by freecad CMakeLists.txt -# set(PYTHON_SUFFIX -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -# Below are two variables that can be left empty for standard python 3 version, -# but must be set by the user for different python versions such as 2.7, 3.5 ... -if (PYTHON_VERSION_MAJOR LESS 3) - SET(PYTHON_CONFIG_SUFFIX -python2.7 CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: ") - SET(PYTHON_BASENAME -python2.7 CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: ") -else() - #SET(PYTHON_CONFIG_SUFFIX "" CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: ") - #SET(PYTHON_BASENAME "" CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: ") -endif() +# # Greatly inspired by freecad CMakeLists.txt +# # set(PYTHON_SUFFIX -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +# # Below are two variables that can be left empty for standard python 3 version, +# # but must be set by the user for different python versions such as 2.7, 3.5 ... +# if (PYTHON_VERSION_MAJOR LESS 3) +# SET(PYTHON_CONFIG_SUFFIX -python2.7 CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: ") +# SET(PYTHON_BASENAME -python2.7 CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: ") +# else() +# #SET(PYTHON_CONFIG_SUFFIX "" CACHE STRING "Shiboken cmake file suffix. If left empty, system default will be used: ") +# #SET(PYTHON_BASENAME "" CACHE STRING "Same as PYTHON_SUFFIX but for PySide. If left empty, PYTHON_SUFFIX will be used: ") +# endif() # -- Python3 -# find_package(PythonLibs REQUIRED) -# find_package(PythonInterp 3.7 REQUIRED) -find_package(Python3 REQUIRED) -set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) -if(NOT DEFINED PYTHON_VERSION_STRING) - find_package(PythonLibs REQUIRED) -else() - find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT) +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +if(NOT Python3_FOUND) + message(SEND_ERROR "Failed to find Python 3 or greater. This is needed to build CamiTK Python binding.") endif() - - -if(NOT PYTHONLIBS_FOUND) - message(FATAL_ERROR "=================================\n" - "Python not found, install Python!\n" - "=================================\n") -else() - # prevent python3 lower than 3.3 (not enough utf8<->unicode tools) - if(PYTHON_VERSION_MAJOR EQUAL 3) - if(PYTHON_VERSION_MINOR LESS 7) - message(FATAL_ERROR "To build CamiTK Python, you need at least version python 3.47n") - endif() - endif() +if("${Python3_VERSION}" VERSION_LESS 3.7) + message(FATAL_ERROR "Found Python3 ${Python3_VERSION} version but at least 3.7 is required. Please update your version of Python3.") endif() +message(STATUS "Found suitable version of Python: ${Python3_VERSION} (required is at least 3.7)") + +# set(Python_ADDITIONAL_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) +# if(NOT DEFINED PYTHON_VERSION_STRING) +# find_package(PythonLibs REQUIRED) +# else() +#find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT) +# endif() +# +# +# if(NOT PYTHONLIBS_FOUND) +# message(FATAL_ERROR "=================================\n" +# "Python not found, install Python!\n" +# "=================================\n") +# else() +# # prevent python3 lower than 3.7 (not enough utf8<->unicode tools) +# if(PYTHON_VERSION VERSION_LESS 3.7) +# message(FATAL_ERROR "To build CamiTK Python binding, you need at least version python 3.7") +# endif() +# endif() # -- Qt # # List of Qt5 modules that are required in CamiTK @@ -80,74 +80,97 @@ endif() # -- PySide, the Python binding of Qt using Shiboken. find_package(PySide2 REQUIRED) -# find_package(PySide2 QUIET)# REQUIRED +if(PYSIDE_INCLUDE_DIR) + message(STATUS "Found PySide2 configuration in ${PySide2_DIR}") + # PySide2 config file was found but it may use the wrong Python version + # Try to get the matching config suffix and repeat finding the package + set(PYSIDE_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + + file(GLOB PYSIDE_CONFIG "${PySide2_DIR}/PySide2Config${PYSIDE_PATTERN}*.cmake") + if (PYSIDE_CONFIG) + get_filename_component(PYSIDE_CONFIG_SUFFIX ${PYSIDE_CONFIG} NAME) + string(SUBSTRING ${PYSIDE_CONFIG_SUFFIX} 13 -1 PYSIDE_CONFIG_SUFFIX) + string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${PYSIDE_CONFIG_SUFFIX}) + message(STATUS "PYTHON_CONFIG_SUFFIX for PySide2: ${PYTHON_CONFIG_SUFFIX}") + # find the package again but this time use the python 3 version (in quiet mode) + find_package(PySide2 QUIET) + endif() + set(PYSIDE_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}.${Python3_VERSION_PATCH}) +endif() +if (NOT PYSIDE_VERSION OR ${PYSIDE_VERSION} VERSION_LESS 3.7) + message(FATAL_ERROR "Failed to find PySide2 for Python3. Found version: ${PYSIDE_VERSION}. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found suitable version of PySide2: ${PYSIDE_VERSION}, path to binary is ${PYSIDE_VERSION}") + + if(NOT PYSIDE_INCLUDE_DIR) - message("==================\n" - "PySide2 not found.\n" - "==================\n") + message(FATAL_ERROR "Failed to find PySide2. This is needed to build CamiTK Python binding.") endif() +message(STATUS "Found PySide2") # -- Shiboken2, the PySide team C++ to Python wrapper find_package(Shiboken2 REQUIRED) if (Shiboken2_FOUND) # Shiboken2 config file was found but it may use the wrong Python version # Try to get the matching config suffix and repeat finding the package - if (PYTHON_VERSION_MAJOR LESS 3) - set(SHIBOKEN_PATTERN -python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - else() - set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) - endif() + set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake") if (SHIBOKEN_CONFIG) get_filename_component(SHIBOKEN_CONFIG_SUFFIX ${SHIBOKEN_CONFIG} NAME) string(SUBSTRING ${SHIBOKEN_CONFIG_SUFFIX} 15 -1 SHIBOKEN_CONFIG_SUFFIX) string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${SHIBOKEN_CONFIG_SUFFIX}) - message(STATUS "PYTHON_CONFIG_SUFFIX: ${PYTHON_CONFIG_SUFFIX}") + message(STATUS "PYTHON_CONFIG_SUFFIX for Shiboken2: ${PYTHON_CONFIG_SUFFIX}") + # find the package again but this time use the python 3 version (in quiet mode) find_package(Shiboken2 QUIET) endif() + set(SHIBOKEN_VERSION ${SHIBOKEN_PYTHON_VERSION_MAJOR}.${SHIBOKEN_PYTHON_VERSION_MINOR}.${SHIBOKEN_PYTHON_VERSION_PATCH}) endif() - -if(NOT SHIBOKEN_INCLUDE_DIR) - message(FATAL_ERROR - "====================\n" - "shiboken2 not found.\n" - "====================\n") -endif() - - -find_program(CAMITK_BINDING_PYTHON_GENERATOR shiboken2 REQUIRED) -if (NOT CAMITK_BINDING_PYTHON_GENERATOR) - message(FATAL_ERROR "Please add Shiboken2 binary in your PATH or manually point to it using the CAMITK_BINDING_PYTHON_GENERATOR variable") -endif() - - -find_package(PySide2Tools QUIET) #REQUIRED # PySide2 utilities (pyside2-uic & pyside2-rcc) -if(NOT PYSIDE2_TOOLS_FOUND) - message("=======================\n" - "PySide2Tools not found.\n" - "=======================\n") -endif() - -file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide) -file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/__init__.py "# PySide wrapper\n" - "from PySide2 import __version__\n" - "from PySide2 import __version_info__\n") -file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtCore.py "from PySide2.QtCore import *\n\n" - "#QCoreApplication.CodecForTr=0\n" - "#QCoreApplication.UnicodeUTF8=1\n") -file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtGui.py "from PySide2.QtGui import *\n" - "from PySide2.QtWidgets import *\n" - "QHeaderView.setResizeMode = QHeaderView.setSectionResizeMode\n") -file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvg.py "from PySide2.QtSvg import *\n") - -if(APPLE AND NOT BUILD_WITH_CONDA) - install(DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide - DESTINATION MacOS) -else() - install(DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide - DESTINATION Ext) +if (NOT SHIBOKEN_VERSION OR ${SHIBOKEN_VERSION} VERSION_LESS 3.7) + message(FATAL_ERROR "Failed to find Shiboken2 for Python3. Found version: ${SHIBOKEN_VERSION}. This is needed to build CamiTK Python binding.") endif() +message(STATUS "Found suitable version of Shiboken2: ${SHIBOKEN_VERSION}, path to binary is ${SHIBOKEN_BINARY}") + +# +# find_program(SHIBOKEN2 shiboken2 REQUIRED) +# if (NOT SHIBOKEN2) +# message(FATAL_ERROR "Please add Shiboken2 binary in your PATH or manually point to it using the SHIBOKEN2 variable") +# endif() +# +# +# +# find_package(PySide2Tools QUIET) #REQUIRED # PySide2 utilities (pyside2-uic & pyside2-rcc) +# if(NOT PYSIDE2_TOOLS_FOUND) +# message("=======================\n" +# "PySide2Tools not found.\n" +# "=======================\n") +# endif() + +# Mini find CamiTK inside SDK +set(CAMITK_DIR ${CMAKE_BINARY_DIR}) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CAMITK_DIR}/share/${CAMITK_SHORT_VERSION_STRING}/cmake) +include(CamiTKConfig) + + +# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide) +# file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/__init__.py "# PySide wrapper\n" +# "from PySide2 import __version__\n" +# "from PySide2 import __version_info__\n") +# file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtCore.py "from PySide2.QtCore import *\n\n" +# "#QCoreApplication.CodecForTr=0\n" +# "#QCoreApplication.UnicodeUTF8=1\n") +# file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtGui.py "from PySide2.QtGui import *\n" +# "from PySide2.QtWidgets import *\n" +# "QHeaderView.setResizeMode = QHeaderView.setSectionResizeMode\n") +# file(WRITE ${CMAKE_BINARY_DIR}/Ext/PySide/QtSvg.py "from PySide2.QtSvg import *\n") +# +# if(APPLE AND NOT BUILD_WITH_CONDA) +# install(DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide +# DESTINATION MacOS) +# else() +# install(DIRECTORY ${CMAKE_BINARY_DIR}/Ext/PySide +# DESTINATION Ext) +# endif() # TEST Using VTK dependency # find_package(VTK REQUIRED) @@ -158,111 +181,233 @@ endif() # #-------------------------------------------- # Shiboken PATH to look for typesystem.xml and global.h files, recursively udapted -set(SHIBOKEN_TYPESYSTEM_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") -set(SHIBOKEN_GLOBAL_H_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +# set(SHIBOKEN_TYPESYSTEM_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") +# set(SHIBOKEN_GLOBAL_H_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "") + +# Shiboken command need paths separated by ":" instead of ";" +string(REPLACE ";" ":" SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES "${CAMITK_INCLUDE_DIRECTORIES}") +string(REPLACE ";" ":" SHIBOKEN_VTK_INCLUDE_DIRS "${VTK_INCLUDE_DIRS}") # include subdirectories -add_subdirectory(actions) -add_subdirectory(applications) -add_subdirectory(components) -add_subdirectory(libraries) +# add_subdirectory(actions) +# add_subdirectory(applications) +# add_subdirectory(components) +# add_subdirectory(libraries) # TODO : Remove once debugged -message(WARNING "PYSIDE_INCLUDE_DIR = ${PYSIDE_INCLUDE_DIR}") -message(WARNING "SHIBOKEN_TYPESYSTEM_PATH = ${SHIBOKEN_TYPESYSTEM_PATH}") -message(WARNING "SHIBOKEN_GLOBAL_H_PATH = ${SHIBOKEN_GLOBAL_H_PATH}") -message(WARNING "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}") -message(WARNING "QT_QTCORE_INCLUDE_DIR = ${QT_QTCORE_INCLUDE_DIR}") -message(WARNING "SHIBOKEN_CAMITK_SDK_PATH = ${SHIBOKEN_CAMITK_SDK_PATH}") -message(WARNING "VTK_INCLUDE_DIRS = ${VTK_INCLUDE_DIRS}") +# message(WARNING "PYSIDE_INCLUDE_DIR = ${PYSIDE_INCLUDE_DIR}") +# message(WARNING "SHIBOKEN_TYPESYSTEM_PATH = ${SHIBOKEN_TYPESYSTEM_PATH}") +# message(WARNING "SHIBOKEN_GLOBAL_H_PATH = ${SHIBOKEN_GLOBAL_H_PATH}") +# message(WARNING "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}") +# message(WARNING "QT_QTCORE_INCLUDE_DIR = ${QT_QTCORE_INCLUDE_DIR}") +# message(FATAL_ERROR "SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES = ${SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES}") +# message(WARNING "SHIBOKEN_VTK_INCLUDE_DIRS = ${SHIBOKEN_VTK_INCLUDE_DIRS}") #-------------------------------------------- # # Custom CMake Python binding targets # #-------------------------------------------- -# Shiboken specific paths -set(PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN - ${PYSIDE_INCLUDE_DIR}:${PYSIDE_INCLUDE_DIR}/QtCore:${PYSIDE_INCLUDE_DIR}/QtGui - #:${PYSIDE_INCLUDE_DIR}/QtHelp:${PYSIDE_INCLUDE_DIR}/QtNetwork:${PYSIDE_INCLUDE_DIR}/QtOpenGL:${PYSIDE_INCLUDE_DIR}/QtScript:${PYSIDE_INCLUDE_DIR}/QtScriptTools:${PYSIDE_INCLUDE_DIR}/QtSql:${PYSIDE_INCLUDE_DIR}/QtSvg:${PYSIDE_INCLUDE_DIR}/QtTest:${PYSIDE_INCLUDE_DIR}/QtUiTools:${PYSIDE_INCLUDE_DIR}/QtWebKit:${PYSIDE_INCLUDE_DIR}/QtXml:${PYSIDE_INCLUDE_DIR}/QtXmlPatterns:${PYSIDE_INCLUDE_DIR}/QtDeclarative +# # Shiboken specific paths +# set(PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN +# ${PYSIDE_INCLUDE_DIR}:${PYSIDE_INCLUDE_DIR}/QtCore:${PYSIDE_INCLUDE_DIR}/QtGui +# #:${PYSIDE_INCLUDE_DIR}/QtHelp:${PYSIDE_INCLUDE_DIR}/QtNetwork:${PYSIDE_INCLUDE_DIR}/QtOpenGL:${PYSIDE_INCLUDE_DIR}/QtScript:${PYSIDE_INCLUDE_DIR}/QtScriptTools:${PYSIDE_INCLUDE_DIR}/QtSql:${PYSIDE_INCLUDE_DIR}/QtSvg:${PYSIDE_INCLUDE_DIR}/QtTest:${PYSIDE_INCLUDE_DIR}/QtUiTools:${PYSIDE_INCLUDE_DIR}/QtWebKit:${PYSIDE_INCLUDE_DIR}/QtXml:${PYSIDE_INCLUDE_DIR}/QtXmlPatterns:${PYSIDE_INCLUDE_DIR}/QtDeclarative +# ) +# +# # TODO : Remove once debugged +# message(WARNING "PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN = ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}") + +# The name of the generated bindings module (as imported in Python). You can change the name +# to something relevant for your project. +set(CAMITK_PYTHON_BIDINGS_MODULE_NAME "PyCamiTK") + +# The header file with all the types and functions for which bindings will be generated. +set(CAMITK_PYTHON_WRAPPED_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.h) + +# The typesystem xml file which defines the relationships between the C++ types / functions +# and the corresponding Python equivalents. +set(CAMITK_PYTHON_TYPESYSTEM_FILE ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.xml) + +# The resulting C++ wrapped classes will be listed in the following CMake variable: +# file(GLOB_RECURSE CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_BINARY_DIR}/python/camitk/*.cpp) +# message(FATAL_ERROR "CPGS=${CAMITK_PYTHON_GENERATED_SOURCES}") +# Specify which C++ files will be generated by shiboken. This includes the module wrapper +# and a '.cpp' file per C++ type. These are needed for generating the module shared +# library. +set(CAMITK_PYTHON_GENERATED_SOURCES + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/pycamitk_module_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_wrapper.cpp + # one file per sources + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_core_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_interfacelogger_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_log_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_application_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_consolestream_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_viewer_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_mainwindow_wrapper.cpp +# ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_impmainwindow_wrapper.cpp +# ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_PREFIX}/Core/ ) -# TODO : Remove once debugged -message(WARNING "PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN = ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}") +# set the dependencies so that if any of these files are modified, the python modules will be +# automatically regenerated +set(CAMITK_PYTHON_GENERATED_SOURCES_DEPENDENCIES ${CAMITK_PYTHON_WRAPPED_HEADER} ${CAMITK_PYTHON_TYPESYSTEM_FILE}) +# set up the options to pass to shiboken. set(SHIBOKEN_OPTIONS - --generator-set=shiboken --enable-parent-ctor-heuristic - --enable-return-value-heuristic --use-isnull-as-nb_nonzero + --generator-set=shiboken + --enable-parent-ctor-heuristic + --enable-return-value-heuristic + --use-isnull-as-nb_nonzero --avoid-protected-hack + --enable-pyside-extensions + --api-version=5.11 --output-directory=${CMAKE_CURRENT_BINARY_DIR} - --include-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}:${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}:${SHIBOKEN_GLOBAL_H_PATH}:${SHIBOKEN_CAMITK_SDK_PATH}:${VTK_INCLUDE_DIRS} + --include-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_INCLUDE_DIR}:${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}:${SHIBOKEN_GLOBAL_H_PATH}:${SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES}:${SHIBOKEN_VTK_INCLUDE_DIRS}:${SHIBOKEN_INCLUDE_DIR} --typesystem-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_TYPESYSTEMS}:${SHIBOKEN_TYPESYSTEM_PATH} ) - + +# Add custom target to run shiboken to generate the binding cpp files. +add_custom_command(OUTPUT ${CAMITK_PYTHON_GENERATED_SOURCES} + COMMAND ${SHIBOKEN_BINARY} + ${SHIBOKEN_OPTIONS} # all required options + ${CAMITK_PYTHON_WRAPPED_HEADER} # wrap header + ${CAMITK_PYTHON_TYPESYSTEM_FILE} # type system + # Hack Shiboken #1: change "unsigned int(0)" to "0" + COMMAND ${CMAKE_COMMAND} -DCAMITK_PYTHON_BIDINGS_MODULE_NAME=${CAMITK_PYTHON_BIDINGS_MODULE_NAME} -P ${CMAKE_CURRENT_SOURCE_DIR}/ShibokenHack1.cmake + DEPENDS ${CAMITK_PYTHON_GENERATED_SOURCES_DEPENDENCIES} + IMPLICIT_DEPENDS CXX ${CAMITK_PYTHON_WRAPPED_HEADER} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Wrapping CamiTK SDK for Python bindings." +) + +# =============================== CMake target for CamiTK Python binding ============================= + +# Set the cpp files which will be used for the bindings library. +set(${CAMITK_PYTHON_BIDINGS_MODULE_NAME}_SOURCES ${CAMITK_PYTHON_GENERATED_SOURCES}) + +# message(FATAL_ERROR "value=${CAMITK_CORE_LIBRARIES}") +link_directories(${CAMITK_LINK_DIRECTORIES}) + +# Define and build the bindings library. +add_library(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} MODULE ${${CAMITK_PYTHON_BIDINGS_MODULE_NAME}_SOURCES}) + +# Apply relevant include and link flags. +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYTHON3_INCLUDE_DIRS}) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}/QtCore) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}/QtGui) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}/QtWidgets) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${SHIBOKEN_INCLUDE_DIR}) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${CMAKE_SOURCE_DIR}) +target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${CAMITK_INCLUDE_DIRECTORIES}) + +# target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${QT_QTCORE_LIBRARY}) +# target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${QT_QTGUI_LIBRARY}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${VTK_LIBRARIES}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_LIBRARY}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${SHIBOKEN_PYTHON_LIBRARIES}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${SHIBOKEN_LIBRARY}) +target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${CAMITK_CORE_LIBRARIES}) + +# message(FATAL_ERROR "lib=${CAMITK_CORE_LIBRARIES}") +# message(WARNING "PYSIDE_LIBRARY = ${PYSIDE_LIBRARY}") +# message(WARNING "SHIBOKEN_PYTHON_LIBRARIES = ${SHIBOKEN_PYTHON_LIBRARIES}") +# message(WARNING "SHIBOKEN_LIBRARY = ${SHIBOKEN_LIBRARY}") +# message(WARNING "QT_INCLUDE_DIR = ${QT_INCLUDE_DIR}") +# message(WARNING "QT_QTCORE_INCLUDE_DIR = ${QT_QTCORE_INCLUDE_DIR}") +# message(WARNING "SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES = ${SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES}") +# message(WARNING "SHIBOKEN_VTK_INCLUDE_DIRS = ${SHIBOKEN_VTK_INCLUDE_DIRS}") + +# Adjust the name of generated module. +set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY PREFIX "") +set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY OUTPUT_NAME + "${CAMITK_PYTHON_BIDINGS_MODULE_NAME}${PYTHON_EXTENSION_SUFFIX}") + +if(WIN32) + set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY SUFFIX ".pyd") +endif() + +# Make sure the linker doesn't complain about not finding Python symbols on macOS. +if(APPLE) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") +endif() + +# Find and link to the python import library only on Windows. +# On Linux and macOS, the undefined symbols will get resolved by the dynamic linker +# (the symbols will be picked up in the Python executable). +if (WIN32) + list(GET python_linking_data 0 python_libdir) + list(GET python_linking_data 1 python_lib) + find_library(python_link_flags ${python_lib} PATHS ${python_libdir} HINTS ${python_libdir}) + target_link_libraries(${bindings_library} PRIVATE ${python_link_flags}) +endif() + + # Wrap the CamiTK SDK. Wrapping uses Shiboken (PySide binding tool) # It means it decorates the specified C++ classes to Python by adding # information in order to convert it into a CPython extension # Shiboken parses the typesystem.xml files to detect which C++ classes to expose to Python # For each of them, it create a CPython C++ decorated class in the build directory -add_custom_target(camitk-ce-python-wrapping - COMMAND ${CMAKE_COMMAND} -E echo "Cleaning C++ classes generated from previous wrapping." - COMMAND ${CMAKE_COMMAND} -E remove_directory python - COMMAND ${CMAKE_COMMAND} -E echo "Wrapping CamiTK SDK for Python exposure." - COMMAND ${CAMITK_BINDING_PYTHON_GENERATOR} ${SHIBOKEN_OPTIONS} - ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.h # wrap header - ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.xml # type system - COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK wrapped." -) -add_dependencies(camitk-ce-python-wrapping action-application) # need a first build to wrap - -# The resulting C++ wrapped classes will be listed in the following CMake variable: -file(GLOB_RECURSE SDK_WRAPPED_CLASSES ${CMAKE_BINARY_DIR}/python/camitk/*.cpp ) - -# We list the CamiTK SDK generated dynamic libraries for linking the python package -# TODO do not manually list those libraries, but dynamically create this list at configuration -# step, using CamiTK CMake macros -file(GLOB_RECURSE CAMITK_SDK_LIBRARIES ${CMAKE_BINARY_DIR}/*.so) -# message(WARNING "CAMITK_SDK_LIBRARIES = ${CAMITK_SDK_LIBRARIES}") - -# This CMake target aims at compiling the C++ Python-wrapped classes of CamiTK and link them against -# the original CamiTK SDK libraries. -# WARNING Do not manually run this target, it requires another configure step wich is run by the camitk-sdk-package-to-python -# CMake target. -if(NOT SDK_WRAPPED_CLASSES STREQUAL "") # only create sdk_python target if camitk sdk has been wrapped - set(PROJECT_NAME sdk_python) # the name of the camitk sdk package once compiled - string(REPLACE ":" ";" CAMITK_SDK_INCLUDE_DIR ${SHIBOKEN_CAMITK_SDK_PATH}) # deduce the list of include directories of CamiTK SDK - string(REPLACE ":" ";" PYSIDE_INCLUDE_ALL_DIR ${PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN}) #deduce the list of include directories provided from PySide / Shiboken - # Qt libraries dependencies - set(QT_LIBRARIES "${QT_QTCORE_LIBRARY};${QT_QTGUI_LIBRARY}") -# message(WARNING "QT_LIBRARIES = ${QT_LIBRARIES}") - set(CAMITK_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../sdk/libraries/core - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/mesh/basicmesh - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/arbitraryslice ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/cropvolume - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/imagelut - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/multipicking ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/reconstruction - ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/volumerendering - ) #build directories required for ui wrapping includes ! - - include_directories(${PROJECT_NAME} ${CAMITK_SDK_INCLUDE_DIR} ${PYSIDE_INCLUDE_ALL_DIR} ${SHIBOKEN_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${VTK_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CAMITK_BUILD_DIR}) - add_library(${PROJECT_NAME} SHARED ${SDK_WRAPPED_CLASSES}) - # # set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") - set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") - target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${VTK_LIBRARIES} ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${CAMITK_SDK_LIBRARIES}) - # WARNING check VTK dependency -# message(WARNING "SHIBOKEN_PYTHON_LIBRARIES = ${SHIBOKEN_PYTHON_LIBRARIES}") -# message(WARNING "SHIBOKEN_LIBRARY = ${SHIBOKEN_LIBRARY}") - # add_dependencies(${PROJECT_NAME} camitkcore) -endif() - -# Create the Python package of CamiTK SDK -# This package is compiled from the generated C++ classes of the camitk-ce-python-wrapping target -# and link against the CamiTK SDK libraries. -# Build the custom camitk-ce-python-package target in order to compile the wrapped C++ classes and link against -# CamiTK SDK dynamic libraries. -add_custom_target(camitk-ce-python-package - COMMAND ${CMAKE_COMMAND} -E echo "Creating Python package of CamiTK SDK." - COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target camitk_python - COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK Python package created." -) -add_dependencies(camitk-ce-python-package camitk-ce-python-wrapping) # need all to wrapped before creating the package +# add_custom_target(camitk-ce-python-wrapping +# # COMMAND ${CMAKE_COMMAND} -E echo "Cleaning C++ classes generated from previous wrapping." +# # COMMAND ${CMAKE_COMMAND} -E remove_directory python +# COMMAND ${CMAKE_COMMAND} -E echo "Wrapping CamiTK SDK for Python exposure." +# COMMAND ${SHIBOKEN2} ${SHIBOKEN_OPTIONS} +# ${CAMITK_PYTHON_WRAPPED_HEADER} # wrap header +# ${CAMITK_PYTHON_TYPESYSTEM_FILE} # type system +# COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK wrapped." +# ) +# add_dependencies(camitk-ce-python-wrapping action-application) # need a first build to wrap +# +# # The resulting C++ wrapped classes will be listed in the following CMake variable: +# file(GLOB_RECURSE SDK_WRAPPED_CLASSES ${CMAKE_BINARY_DIR}/python/camitk/*.cpp ) +# +# # We list the CamiTK SDK generated dynamic libraries for linking the python package +# # TODO do not manually list those libraries, but dynamically create this list at configuration +# # step, using CamiTK CMake macros +# file(GLOB_RECURSE CAMITK_SDK_LIBRARIES ${CMAKE_BINARY_DIR}/*.so) +# # message(WARNING "CAMITK_SDK_LIBRARIES = ${CAMITK_SDK_LIBRARIES}") +# +# # This CMake target aims at compiling the C++ Python-wrapped classes of CamiTK and link them against +# # the original CamiTK SDK libraries. +# # WARNING Do not manually run this target, it requires another configure step which is run by the camitk-sdk-package-to-python +# # CMake target. +# if(NOT SDK_WRAPPED_CLASSES STREQUAL "") # only create sdk_python target if camitk sdk has been wrapped +# set(PROJECT_NAME sdk_python) # the name of the camitk sdk package once compiled +# string(REPLACE ":" ";" CAMITK_SDK_INCLUDE_DIR ${SHIBOKEN_CAMITK_SDK_PATH}) # deduce the list of include directories of CamiTK SDK +# string(REPLACE ":" ";" PYSIDE_INCLUDE_ALL_DIR ${PYSIDE_INCLUDE_DIR}) #deduce the list of include directories provided from PySide / Shiboken +# # Qt libraries dependencies +# set(QT_LIBRARIES "${QT_QTCORE_LIBRARY};${QT_QTGUI_LIBRARY}") +# # message(WARNING "QT_LIBRARIES = ${QT_LIBRARIES}") +# set(CAMITK_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../sdk/libraries/core +# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/mesh/basicmesh +# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/arbitraryslice ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/cropvolume +# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/imagelut +# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/multipicking ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/reconstruction +# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/volumerendering +# ) #build directories required for ui wrapping includes ! +# +# include_directories(${PROJECT_NAME} ${CAMITK_SDK_INCLUDE_DIR} ${PYSIDE_INCLUDE_ALL_DIR} ${SHIBOKEN_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${VTK_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CAMITK_BUILD_DIR}) +# add_library(${PROJECT_NAME} SHARED ${SDK_WRAPPED_CLASSES}) +# # # set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") +# set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") +# target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${VTK_LIBRARIES} ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${CAMITK_SDK_LIBRARIES}) +# # WARNING check VTK dependency +# # message(WARNING "SHIBOKEN_PYTHON_LIBRARIES = ${SHIBOKEN_PYTHON_LIBRARIES}") +# # message(WARNING "SHIBOKEN_LIBRARY = ${SHIBOKEN_LIBRARY}") +# # add_dependencies(${PROJECT_NAME} camitkcore) +# endif() +# +# # Create the Python package of CamiTK SDK +# # This package is compiled from the generated C++ classes of the camitk-ce-python-wrapping target +# # and link against the CamiTK SDK libraries. +# # Build the custom camitk-ce-python-package target in order to compile the wrapped C++ classes and link against +# # CamiTK SDK dynamic libraries. +# add_custom_target(camitk-ce-python-package +# COMMAND ${CMAKE_COMMAND} -E echo "Creating Python package of CamiTK SDK." +# # COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} +# COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target sdk_python +# COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK Python package created." +# ) +# add_dependencies(camitk-ce-python-package camitk-ce-python-wrapping) # need all to wrapped before creating the package diff --git a/python/PythonBindings.h b/python/PythonBindings.h index 9f14c6d1..e0147fdf 100644 --- a/python/PythonBindings.h +++ b/python/PythonBindings.h @@ -26,13 +26,26 @@ #ifndef PYTHON_BINDINGS_H #define PYTHON_BINDINGS_H -// include here the classes you want to be exposed to Python -#include -#include -#include -#include -#include -#include +// Qt Bindings +// class to export to python +#include +#include +#include +#include +#include +#include +#include +// #include + +/* +#include + +#include +#include +#include +#include +#include +*/ #endif // PYTHON_BINDINGS_H diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index 5a8d2703..29d03583 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -1,10 +1,290 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + int argc; + char** argv; + if (!Shiboken::listToArgcArgv(%PYARG_2, &argc, &argv, %1.toStdString().c_str())) { + PyErr_SetString(PyExc_TypeError, "error"); + return 0; + } + else { + // Shiboken asks to call %FUNCTION_NAME in the injected code + // here we don't need it ( %0 = (%CPPTYPEWrapper *)%CONVERTTOPYTHON[camitk::%CPPTYPE](app); doesn't work) + // simply delete it and directly call application wrapper + // TODO : understand how the conversion / wrapper handle objects + // If we comment the 2 above lines, the application will seg fault at runtime. + //camitk::%CPPTYPE* app = new %FUNCTION_NAME(%1, argc, argv, false, false); + //delete app; + + %0 = new %CPPTYPEWrapper(%1, argc, argv, %4, %5); + Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self)); + PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); + + std::cout << "before" << std::endl; + std::cout << %0->applicationDirPath().toStdString() << std::endl; + std::cout << %0->getName().toStdString() << std::endl; + std::cout << "inst1=" << QCoreApplication::instance() << std::endl; + QCoreApplication *coreApp = QCoreApplication::instance(); + std::cout << "inst2=" << coreApp << std::endl; + std::cout << "objectName=" << coreApp->objectName().toStdString() << std::endl; + std::cout << "className=" << coreApp->metaObject()->className() << std::endl; + std::cout << "inherits(QCoreApplication)=" << coreApp->inherits("QCoreApplication") << std::endl; + std::cout << "inherits(QApplication)=" << coreApp->inherits("QApplication") << std::endl; + std::cout << "inst3=" << qobject_cast<QApplication *>(coreApp) << std::endl; + QApplication* appPtr = qobject_cast<QApplication *>(coreApp); + std::cout << "inst4=" << appPtr << std::endl; + + + // QWidget* a = new QWidget(); + std::cout << "===" << std::endl; + std::cout << dynamic_cast<Application*>(qApp)->getMainWindow() << std::endl; + std::cout << %0->getMainWindow() << std::endl; + std::cout << "after" << std::endl; + + /* + Application* cappPtr = qobject_cast<Application *>(appPtr); + std::cout << "instc=" << cappPtr << std::endl; + std::cout << "===2" << std::endl; + std::cout << cappPtr->getMainWindow() << std::endl; + */ + //delete[] argv; + } + + + + + + + + + + + + + // Force Shiboken not to instantiate InterfaceGeometry (which is abstract) throught InterfaceGeometryWrapper constructor + // Let Shiboken believes we have called the constructor, which is not the case due to comments. + // cptr = new InterfaceGeometryWrapper(); + + + + + + + + + + + + + + + + + + + diff --git a/python/ShibokenHack1.cmake b/python/ShibokenHack1.cmake new file mode 100644 index 00000000..4c4895ff --- /dev/null +++ b/python/ShibokenHack1.cmake @@ -0,0 +1,7 @@ +file(GLOB_RECURSE CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/*.cpp) +foreach(WRAPPER_FILE ${CAMITK_PYTHON_GENERATED_SOURCES}) + message(STATUS "Hacking#1: ${WRAPPER_FILE}") + file(READ ${WRAPPER_FILE} WRAPPER_CODE) + string(REPLACE "unsigned int(0)" "0" WRAPPER_CODE_HACKED "${WRAPPER_CODE}") + file(WRITE ${WRAPPER_FILE} "${WRAPPER_CODE_HACKED}") +endforeach() diff --git a/python/test.py b/python/test.py new file mode 100644 index 00000000..fae1508d --- /dev/null +++ b/python/test.py @@ -0,0 +1,55 @@ +#!/usr/bin/python3 +# +# In order to debug a core dump, use: +# gdb python3 core +# and then issue the "where" command +# +import traceback +import sys +sys.path.append('.') +sys.path.append('./python') +#print("Adding pwd to python path") + +# list CamiTK python bindings exported classes +import inspect + +from PyCamiTK import camitk +availableCamiTKClasses = inspect.getmembers(sys.modules[__name__], inspect.isclass) +print (availableCamiTKClasses) + +#app = camitk.Application(sys.argv) +#mw = camitk.MainWindow("Python MainWindow") + +#print("CamiTK path:\n" + camitk.Core.getPaths()) +#print("CamiTK config:\n" + camitk.Core.getConfig()) + +if __name__ == "__main__": + print("\nTry...\n") + try: + print("Setting log...") + camitk.Log.getLogger().setTimeStampInformation(True) + camitk.Log.getLogger().setMessageBoxLevel(camitk.InterfaceLogger.NONE) + camitk.Log.getLogger().setLogLevel(camitk.InterfaceLogger.TRACE) + print("CamiTK version: " + camitk.Core.version) + app = camitk.Application("python-testapp", sys.argv, True, False) + print(app) + print("Starting application: \"" + app.getName() + "\"") + print("Is there any modified components: " + str(app.hasModified())) + # CoreDump: print("Actions: " + app.getActions()) + # CoreDump: print("Main window is: " + app.getMainWindow()) + # CoreDump: print("Number of opened top level components: " + str(app.getTopLevelComponents().size())) + # CoreDump: mw = camitk.MainWindow("Python MainWindow") + # CoreDump: app.setMainWindow(mw) + sys.exit(app.exec_()) + except Exception: + print(traceback.format_exc()) + # or + print(sys.exc_info()[0]) + +#from PySide2.QtWidgets import QApplication, QLabel + +#if __name__ == "__main__": + #app = QApplication(sys.argv) + #label = QLabel("Hello World") + #label.show() + #sys.exit(app.exec_()) diff --git a/python/typesystem_sdk.xml b/python/typesystem_sdk.xml index 74907496..c79a8108 100644 --- a/python/typesystem_sdk.xml +++ b/python/typesystem_sdk.xml @@ -1,5 +1,5 @@ - + diff --git a/tutorials/applications/testlogger/main.cpp b/tutorials/applications/testlogger/main.cpp index 676534e6..45e843ed 100644 --- a/tutorials/applications/testlogger/main.cpp +++ b/tutorials/applications/testlogger/main.cpp @@ -26,6 +26,7 @@ // -- Core stuff #include #include +#include #include #include diff --git a/tutorials/applications/testloggercrash/main.cpp b/tutorials/applications/testloggercrash/main.cpp index ee79f3d2..6cb5ce94 100644 --- a/tutorials/applications/testloggercrash/main.cpp +++ b/tutorials/applications/testloggercrash/main.cpp @@ -26,6 +26,7 @@ // -- Core stuff #include #include +#include #include #include -- GitLab From e8b5717f92f787f2db50971b9233580475017d1c Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Wed, 6 Mar 2019 22:20:38 +0100 Subject: [PATCH 06/24] FIXED first version without crash Run test.py show a beautiful empty window, with the CamiTK icon Note: a right-click can show the CamiTK console! --- python/CMakeLists.txt | 38 +-- python/PythonBindings.h | 91 +++++-- python/PythonBindings.xml | 232 ++---------------- ...ShibokenHack1.cmake => ShibokenHack.cmake} | 2 +- python/test.py | 33 ++- 5 files changed, 136 insertions(+), 260 deletions(-) rename python/{ShibokenHack1.cmake => ShibokenHack.cmake} (86%) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cb799904..8e33f81c 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -230,30 +230,30 @@ set(CAMITK_PYTHON_TYPESYSTEM_FILE ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.xml # The resulting C++ wrapped classes will be listed in the following CMake variable: # file(GLOB_RECURSE CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_BINARY_DIR}/python/camitk/*.cpp) -# message(FATAL_ERROR "CPGS=${CAMITK_PYTHON_GENERATED_SOURCES}") -# Specify which C++ files will be generated by shiboken. This includes the module wrapper -# and a '.cpp' file per C++ type. These are needed for generating the module shared + +# Manually specifies the classes to bind +set(CAMITK_PYTHON_CLASS_NAMES Core + InterfaceLogger + Log + Application +) + +# Compute which C++ files will be generated by shiboken. This includes the module wrapper, the namespace wrapper +# and a '.cpp' file per C++ class. These are needed for generating the module shared # library. -set(CAMITK_PYTHON_GENERATED_SOURCES - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/pycamitk_module_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_wrapper.cpp - # one file per sources - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_core_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_interfacelogger_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_log_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_application_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_consolestream_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_viewer_wrapper.cpp - ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_mainwindow_wrapper.cpp -# ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_impmainwindow_wrapper.cpp -# ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_PREFIX}/Core/ +set(CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/pycamitk_module_wrapper.cpp + ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_wrapper.cpp ) +foreach(CAMITK_CLASS_NAME ${CAMITK_PYTHON_CLASS_NAMES}) + string(TOLOWER "${CAMITK_CLASS_NAME}" CAMITK_CLASS_NAME_LOWER) + set(CAMITK_PYTHON_GENERATED_SOURCES ${CAMITK_PYTHON_GENERATED_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/camitk_${CAMITK_CLASS_NAME_LOWER}_wrapper.cpp) +endforeach() # set the dependencies so that if any of these files are modified, the python modules will be # automatically regenerated set(CAMITK_PYTHON_GENERATED_SOURCES_DEPENDENCIES ${CAMITK_PYTHON_WRAPPED_HEADER} ${CAMITK_PYTHON_TYPESYSTEM_FILE}) -# set up the options to pass to shiboken. +# set up the options to pass to shiboken. Check https://doc.qt.io/qtforpython/shiboken2/commandlineoptions.html set(SHIBOKEN_OPTIONS --generator-set=shiboken --enable-parent-ctor-heuristic @@ -262,6 +262,8 @@ set(SHIBOKEN_OPTIONS --avoid-protected-hack --enable-pyside-extensions --api-version=5.11 +# --disable-verbose-error-messages # Disable verbose error messages. Turn the CPython code hard to debug but saves a few kilobytes in the generated binding. + --no-suppress-warnings # Show all warnings. --output-directory=${CMAKE_CURRENT_BINARY_DIR} --include-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_INCLUDE_DIR}:${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}:${SHIBOKEN_GLOBAL_H_PATH}:${SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES}:${SHIBOKEN_VTK_INCLUDE_DIRS}:${SHIBOKEN_INCLUDE_DIR} --typesystem-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_TYPESYSTEMS}:${SHIBOKEN_TYPESYSTEM_PATH} @@ -274,7 +276,7 @@ add_custom_command(OUTPUT ${CAMITK_PYTHON_GENERATED_SOURCES} ${CAMITK_PYTHON_WRAPPED_HEADER} # wrap header ${CAMITK_PYTHON_TYPESYSTEM_FILE} # type system # Hack Shiboken #1: change "unsigned int(0)" to "0" - COMMAND ${CMAKE_COMMAND} -DCAMITK_PYTHON_BIDINGS_MODULE_NAME=${CAMITK_PYTHON_BIDINGS_MODULE_NAME} -P ${CMAKE_CURRENT_SOURCE_DIR}/ShibokenHack1.cmake + COMMAND ${CMAKE_COMMAND} -DCAMITK_PYTHON_BIDINGS_MODULE_NAME=${CAMITK_PYTHON_BIDINGS_MODULE_NAME} -P ${CMAKE_CURRENT_SOURCE_DIR}/ShibokenHack.cmake DEPENDS ${CAMITK_PYTHON_GENERATED_SOURCES_DEPENDENCIES} IMPLICIT_DEPENDS CXX ${CAMITK_PYTHON_WRAPPED_HEADER} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} diff --git a/python/PythonBindings.h b/python/PythonBindings.h index e0147fdf..4d3fd4c8 100644 --- a/python/PythonBindings.h +++ b/python/PythonBindings.h @@ -26,26 +26,85 @@ #ifndef PYTHON_BINDINGS_H #define PYTHON_BINDINGS_H -// Qt Bindings +// Qt Bindings for CamiTK (PyCamiTK) -// class to export to python +// CamiTK core library + +// top dir #include +// not needed: +// ExtensionManager.h +// HistoryComponent.h +// HistoryItem.h +// CamiTKAPI.h + +// utils #include #include +// not needed: +// AbortException.h +// PropertyObject.h +// Property.h +// CamiTKLogger.h +// PlaneC.h +// ObjectController.h +// ConsoleStream.h +// SliderSpinBoxWidget.h +// SliderTextWidget.h + +// application #include -#include -#include -#include -// #include - -/* -#include - -#include -#include -#include -#include -#include -*/ +//#include +// SettingsDialog.h + +// viewer +// #include +// RendererWidget.h +// FrameExplorer.h +// Explorer.h +// Viewer.h +// PropertyExplorer.h +// ActionViewer.h +// MedicalImageViewer.h + +// Action.h +// ActionExtension.h +// ActionWidget.h +// Frame.h +// InterfaceNode.h +// InterfaceProperty.h +// SimplisticComponent.h +// InterfaceBitMap.h +// Geometry.h +// InterfaceGeometry.h +// ComponentExtension.h +// InterfaceFrame.h +// GeometricObject.h +// Component.h +// Slice.h + +// mesh subdir +// MeshComponent.h +// MeshDataModel.h +// MeshDataView.h +// MeshComponentExtension.h +// MeshSelectionModel.h +// MeshSelectionView.h + +// image subdir +// ItkProgressObserver.h +// SingleImageComponent.h +// itkVTKImageToImageFilter.h +// ImageComponentExtension.h +// ImageComponent.h +// ImageOrientationHelper.h +// itkImageToVTKImageFilter.h + +// imageacquisition subdir +// ImageAcquisitionComponent.h +// ImageAcquisitionComponentExtension.h + + + #endif // PYTHON_BINDINGS_H diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index 29d03583..39ad24fb 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -40,6 +40,7 @@ + @@ -51,25 +52,24 @@ see: pyside-setup/sources/pyside2/PySide2/glue/qtwidgets.cpp and: pyside-setup/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml --> - - - + + - - - - - - - - - - - - - - - - - - - int argc; - char** argv; - if (!Shiboken::listToArgcArgv(%PYARG_2, &argc, &argv, %1.toStdString().c_str())) { - PyErr_SetString(PyExc_TypeError, "error"); - return 0; - } - else { - // Shiboken asks to call %FUNCTION_NAME in the injected code - // here we don't need it ( %0 = (%CPPTYPEWrapper *)%CONVERTTOPYTHON[camitk::%CPPTYPE](app); doesn't work) - // simply delete it and directly call application wrapper - // TODO : understand how the conversion / wrapper handle objects - // If we comment the 2 above lines, the application will seg fault at runtime. - //camitk::%CPPTYPE* app = new %FUNCTION_NAME(%1, argc, argv, false, false); - //delete app; - - %0 = new %CPPTYPEWrapper(%1, argc, argv, %4, %5); - Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self)); - PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); - - std::cout << "before" << std::endl; - std::cout << %0->applicationDirPath().toStdString() << std::endl; - std::cout << %0->getName().toStdString() << std::endl; - std::cout << "inst1=" << QCoreApplication::instance() << std::endl; - QCoreApplication *coreApp = QCoreApplication::instance(); - std::cout << "inst2=" << coreApp << std::endl; - std::cout << "objectName=" << coreApp->objectName().toStdString() << std::endl; - std::cout << "className=" << coreApp->metaObject()->className() << std::endl; - std::cout << "inherits(QCoreApplication)=" << coreApp->inherits("QCoreApplication") << std::endl; - std::cout << "inherits(QApplication)=" << coreApp->inherits("QApplication") << std::endl; - std::cout << "inst3=" << qobject_cast<QApplication *>(coreApp) << std::endl; - QApplication* appPtr = qobject_cast<QApplication *>(coreApp); - std::cout << "inst4=" << appPtr << std::endl; - - - // QWidget* a = new QWidget(); - std::cout << "===" << std::endl; - std::cout << dynamic_cast<Application*>(qApp)->getMainWindow() << std::endl; - std::cout << %0->getMainWindow() << std::endl; - std::cout << "after" << std::endl; - - /* - Application* cappPtr = qobject_cast<Application *>(appPtr); - std::cout << "instc=" << cappPtr << std::endl; - std::cout << "===2" << std::endl; - std::cout << cappPtr->getMainWindow() << std::endl; - */ - //delete[] argv; - } - - - + - - - - - - - - // Force Shiboken not to instantiate InterfaceGeometry (which is abstract) throught InterfaceGeometryWrapper constructor - // Let Shiboken believes we have called the constructor, which is not the case due to comments. - // cptr = new InterfaceGeometryWrapper(); - - - - - - - - - - - - - - - - - diff --git a/python/ShibokenHack1.cmake b/python/ShibokenHack.cmake similarity index 86% rename from python/ShibokenHack1.cmake rename to python/ShibokenHack.cmake index 4c4895ff..4f0e0084 100644 --- a/python/ShibokenHack1.cmake +++ b/python/ShibokenHack.cmake @@ -1,6 +1,6 @@ file(GLOB_RECURSE CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/*.cpp) foreach(WRAPPER_FILE ${CAMITK_PYTHON_GENERATED_SOURCES}) - message(STATUS "Hacking#1: ${WRAPPER_FILE}") + message(STATUS "Shiboken Hacking: ${WRAPPER_FILE}") file(READ ${WRAPPER_FILE} WRAPPER_CODE) string(REPLACE "unsigned int(0)" "0" WRAPPER_CODE_HACKED "${WRAPPER_CODE}") file(WRITE ${WRAPPER_FILE} "${WRAPPER_CODE_HACKED}") diff --git a/python/test.py b/python/test.py index fae1508d..dde02348 100644 --- a/python/test.py +++ b/python/test.py @@ -5,14 +5,14 @@ # and then issue the "where" command # import traceback + +# Add the python subdir in order to be able to load PyCamiTK import sys sys.path.append('.') sys.path.append('./python') -#print("Adding pwd to python path") # list CamiTK python bindings exported classes import inspect - from PyCamiTK import camitk availableCamiTKClasses = inspect.getmembers(sys.modules[__name__], inspect.isclass) print (availableCamiTKClasses) @@ -23,6 +23,10 @@ print (availableCamiTKClasses) #print("CamiTK path:\n" + camitk.Core.getPaths()) #print("CamiTK config:\n" + camitk.Core.getConfig()) +#class MyApp(camitk.Application): + #def __init__(self): + #camitk.Application.__init__(self) + if __name__ == "__main__": print("\nTry...\n") try: @@ -31,15 +35,19 @@ if __name__ == "__main__": camitk.Log.getLogger().setMessageBoxLevel(camitk.InterfaceLogger.NONE) camitk.Log.getLogger().setLogLevel(camitk.InterfaceLogger.TRACE) print("CamiTK version: " + camitk.Core.version) - app = camitk.Application("python-testapp", sys.argv, True, False) - print(app) + app = camitk.Application(sys.argv) + print("Class name:" + app.metaObject().className()) print("Starting application: \"" + app.getName() + "\"") print("Is there any modified components: " + str(app.hasModified())) - # CoreDump: print("Actions: " + app.getActions()) - # CoreDump: print("Main window is: " + app.getMainWindow()) - # CoreDump: print("Number of opened top level components: " + str(app.getTopLevelComponents().size())) - # CoreDump: mw = camitk.MainWindow("Python MainWindow") - # CoreDump: app.setMainWindow(mw) + print("Arguments: " + str(app.arguments())) + print("Testdata dir:" + camitk.Core.getTestDataDir()) + print("Platform name: " + app.platformName()) + #camitk.Application.open(camitk.Core.getTestDataDir() + "/brain.mha") + #print("Font: " + str(app.font())) + #print("Main window is: " + app.getMainWindow()) + #print("Number of opened top level components: " + str(app.getTopLevelComponents().size())) + #mw = camitk.MainWindow("Python MainWindow") + #app.setMainWindow(mw) sys.exit(app.exec_()) except Exception: print(traceback.format_exc()) @@ -53,3 +61,10 @@ if __name__ == "__main__": #label = QLabel("Hello World") #label.show() #sys.exit(app.exec_()) + +# Minimal +# import sys +# sys.path.append('.') +# sys.path.append('./python') +# from PyCamiTK import camitk +# app = camitk.Application(sys.argv) -- GitLab From cee7572715520cef63a9e1e9eacc66b3ad00ec89 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 8 Mar 2019 11:47:46 +0100 Subject: [PATCH 07/24] NEW first demo (open a image component and visualize it in a medical viewer) --- python/CMakeLists.txt | 28 +++- python/PythonBindings.h | 75 +++++---- python/PythonBindings.xml | 338 ++++++++++++++++++++++++++++++++++++-- python/ShibokenHack.cmake | 7 +- python/test.py | 34 +++- 5 files changed, 430 insertions(+), 52 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 8e33f81c..da1d6141 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -233,9 +233,30 @@ set(CAMITK_PYTHON_TYPESYSTEM_FILE ${CMAKE_CURRENT_SOURCE_DIR}/PythonBindings.xml # Manually specifies the classes to bind set(CAMITK_PYTHON_CLASS_NAMES Core + ExtensionManager + HistoryComponent + HistoryItem InterfaceLogger Log + AbortException + PropertyObject + Property + CamiTKLogger + ObjectController Application + MainWindow + SettingsDialog + Viewer + InterfaceNode + InterfaceProperty + InterfaceBitMap + InterfaceGeometry + InterfaceFrame + Component + ImageComponent +# RendererWidget +# InteractiveViewer + MedicalImageViewer ) # Compute which C++ files will be generated by shiboken. This includes the module wrapper, the namespace wrapper @@ -253,6 +274,10 @@ endforeach() # automatically regenerated set(CAMITK_PYTHON_GENERATED_SOURCES_DEPENDENCIES ${CAMITK_PYTHON_WRAPPED_HEADER} ${CAMITK_PYTHON_TYPESYSTEM_FILE}) +# if (CMAKE_COMPILER_IS_GNUCC) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") +# endif() + # set up the options to pass to shiboken. Check https://doc.qt.io/qtforpython/shiboken2/commandlineoptions.html set(SHIBOKEN_OPTIONS --generator-set=shiboken @@ -264,6 +289,7 @@ set(SHIBOKEN_OPTIONS --api-version=5.11 # --disable-verbose-error-messages # Disable verbose error messages. Turn the CPython code hard to debug but saves a few kilobytes in the generated binding. --no-suppress-warnings # Show all warnings. + --debug-level=full --output-directory=${CMAKE_CURRENT_BINARY_DIR} --include-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_INCLUDE_DIR}:${QT_INCLUDE_DIR}:${QT_QTCORE_INCLUDE_DIR}:${SHIBOKEN_GLOBAL_H_PATH}:${SHIBOKEN_CAMITK_INCLUDE_DIRECTORIES}:${SHIBOKEN_VTK_INCLUDE_DIRS}:${SHIBOKEN_INCLUDE_DIR} --typesystem-paths=${CMAKE_SOURCE_DIR}:${PYSIDE_TYPESYSTEMS}:${SHIBOKEN_TYPESYSTEM_PATH} @@ -276,7 +302,7 @@ add_custom_command(OUTPUT ${CAMITK_PYTHON_GENERATED_SOURCES} ${CAMITK_PYTHON_WRAPPED_HEADER} # wrap header ${CAMITK_PYTHON_TYPESYSTEM_FILE} # type system # Hack Shiboken #1: change "unsigned int(0)" to "0" - COMMAND ${CMAKE_COMMAND} -DCAMITK_PYTHON_BIDINGS_MODULE_NAME=${CAMITK_PYTHON_BIDINGS_MODULE_NAME} -P ${CMAKE_CURRENT_SOURCE_DIR}/ShibokenHack.cmake +# COMMAND ${CMAKE_COMMAND} -DCAMITK_PYTHON_BIDINGS_MODULE_NAME=${CAMITK_PYTHON_BIDINGS_MODULE_NAME} -P ${CMAKE_CURRENT_SOURCE_DIR}/ShibokenHack.cmake DEPENDS ${CAMITK_PYTHON_GENERATED_SOURCES_DEPENDENCIES} IMPLICIT_DEPENDS CXX ${CAMITK_PYTHON_WRAPPED_HEADER} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} diff --git a/python/PythonBindings.h b/python/PythonBindings.h index 4d3fd4c8..2a8e590b 100644 --- a/python/PythonBindings.h +++ b/python/PythonBindings.h @@ -31,56 +31,67 @@ // CamiTK core library // top dir -#include -// not needed: -// ExtensionManager.h -// HistoryComponent.h -// HistoryItem.h -// CamiTKAPI.h +#include -// utils -#include -#include -// not needed: -// AbortException.h -// PropertyObject.h -// Property.h -// CamiTKLogger.h -// PlaneC.h -// ObjectController.h -// ConsoleStream.h -// SliderSpinBoxWidget.h -// SliderTextWidget.h +// force redefinition of type as Shiboken does not understand +// the C++11 type aliases +#define ComponentList QList +#define ActionSet QSet +#define ActionList QList + +// requires to be at the end due to Win/OpenGL confusion with ERROR macro +#include + +#include +#include +#include +#include // application #include -//#include -// SettingsDialog.h +#include +#include // viewer -// #include -// RendererWidget.h +#include +#include // FrameExplorer.h // Explorer.h -// Viewer.h // PropertyExplorer.h // ActionViewer.h -// MedicalImageViewer.h +#include +// utils +#include +#include +#include +#include +#include +#include +#include +// not needed: +// PlaneC.h +// ConsoleStream.h +// SliderSpinBoxWidget.h +// SliderTextWidget.h + +// action // Action.h // ActionExtension.h // ActionWidget.h + +// component +#include +#include +#include +#include +#include +#include // Frame.h -// InterfaceNode.h -// InterfaceProperty.h // SimplisticComponent.h -// InterfaceBitMap.h // Geometry.h -// InterfaceGeometry.h // ComponentExtension.h -// InterfaceFrame.h // GeometricObject.h -// Component.h // Slice.h // mesh subdir @@ -96,7 +107,7 @@ // SingleImageComponent.h // itkVTKImageToImageFilter.h // ImageComponentExtension.h -// ImageComponent.h +#include // ImageOrientationHelper.h // itkImageToVTKImageFilter.h diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index 39ad24fb..34417c31 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -29,28 +29,157 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + - @@ -65,26 +194,213 @@ ApplicationConstructor(%PYSELF, empty, &%0); - - - static void ApplicationConstructor(PyObject* self, PyObject* pyargv, ApplicationWrapper** cptr) { static int argc; static char** argv; PyObject* stringlist = PyTuple_GET_ITEM(pyargv, 0); if (Shiboken::listToArgcArgv(stringlist, &argc, &argv, "PyCamiTKApp")) { - *cptr = new ApplicationWrapper(argv[0], argc, argv, 0); + *cptr = new ApplicationWrapper(argv[0], argc, argv, true, false); Shiboken::Object::releaseOwnership(reinterpret_cast<SbkObject*>(self)); PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/ShibokenHack.cmake b/python/ShibokenHack.cmake index 4f0e0084..91096c1d 100644 --- a/python/ShibokenHack.cmake +++ b/python/ShibokenHack.cmake @@ -2,6 +2,9 @@ file(GLOB_RECURSE CAMITK_PYTHON_GENERATED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/${ foreach(WRAPPER_FILE ${CAMITK_PYTHON_GENERATED_SOURCES}) message(STATUS "Shiboken Hacking: ${WRAPPER_FILE}") file(READ ${WRAPPER_FILE} WRAPPER_CODE) - string(REPLACE "unsigned int(0)" "0" WRAPPER_CODE_HACKED "${WRAPPER_CODE}") - file(WRITE ${WRAPPER_FILE} "${WRAPPER_CODE_HACKED}") + # Hack #1: unsigned int returns are not translated properly +# string(REPLACE "unsigned int(0)" "0" WRAPPER_CODE_HACKED_1 "${WRAPPER_CODE}") + # Hack #2: bug with the return type of "const QVector & InterfaceFrameWrapper::getChildrenFrame() const" +# string(REPLACE "::QVector" "QVector" WRAPPER_CODE_HACKED_2 "${WRAPPER_CODE_HACKED_1}") +# file(WRITE ${WRAPPER_FILE} "${WRAPPER_CODE_HACKED_1}") endforeach() diff --git a/python/test.py b/python/test.py index dde02348..fae60aae 100644 --- a/python/test.py +++ b/python/test.py @@ -4,6 +4,8 @@ # gdb python3 core # and then issue the "where" command # +# see https://pyscience.wordpress.com/2014/09/06/numpy-to-vtk-converting-your-numpy-arrays-to-vtk-arrays-and-files/ +# import traceback # Add the python subdir in order to be able to load PyCamiTK @@ -26,6 +28,7 @@ print (availableCamiTKClasses) #class MyApp(camitk.Application): #def __init__(self): #camitk.Application.__init__(self) +import vtk if __name__ == "__main__": print("\nTry...\n") @@ -42,12 +45,31 @@ if __name__ == "__main__": print("Arguments: " + str(app.arguments())) print("Testdata dir:" + camitk.Core.getTestDataDir()) print("Platform name: " + app.platformName()) - #camitk.Application.open(camitk.Core.getTestDataDir() + "/brain.mha") - #print("Font: " + str(app.font())) - #print("Main window is: " + app.getMainWindow()) - #print("Number of opened top level components: " + str(app.getTopLevelComponents().size())) - #mw = camitk.MainWindow("Python MainWindow") - #app.setMainWindow(mw) + print("Main window is: " + str(app.getMainWindow())) + print("Font: " + str(app.font())) + + comp = camitk.Application.open(camitk.Core.getTestDataDir() + "/brain.mha") + + print("Name of component: " + comp.getName()) + + #imageData = vtk.vtkImageData() + #imageData.SetDimensions(3, 4, 5) + #imageData.AllocateScalars(vtk.VTK_DOUBLE, 1) + + #dims = imageData.GetDimensions() + + ## Fill every entry of the image data with '2.0' + #for z in range(dims[2]): + #for y in range(dims[1]): + #for x in range(dims[0]): + #imageData.SetScalarComponentFromDouble(x, y, z, 0, 2.0) + + ##comp.setImageData(imageData) + #imageData2 = comp.getImageData() + + print("Number of opened top level components: " + str(len(app.getTopLevelComponents()))) + miw = camitk.MedicalImageViewer("Medical Image Viewer") + app.getMainWindow().setCentralViewer(miw) sys.exit(app.exec_()) except Exception: print(traceback.format_exc()) -- GitLab From fce76cb2447cf54257dbcf1a0530586f86c3e99a Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Wed, 13 Mar 2019 21:41:03 +0100 Subject: [PATCH 08/24] NEW first version with Python <-> C++ interoperability Implemented for ImageComponent / vtkImageData --- python/CMakeLists.txt | 3 + python/PythonBindings.h | 6 +- python/PythonBindings.xml | 177 ++++++++++++++++++++++++++++++++++++-- python/test.py | 162 +++++++++++++++++++++++++++++++--- 4 files changed, 327 insertions(+), 21 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index da1d6141..c68a4017 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -247,6 +247,7 @@ set(CAMITK_PYTHON_CLASS_NAMES Core MainWindow SettingsDialog Viewer + Action InterfaceNode InterfaceProperty InterfaceBitMap @@ -257,6 +258,8 @@ set(CAMITK_PYTHON_CLASS_NAMES Core # RendererWidget # InteractiveViewer MedicalImageViewer + PropertyExplorer + Explorer ) # Compute which C++ files will be generated by shiboken. This includes the module wrapper, the namespace wrapper diff --git a/python/PythonBindings.h b/python/PythonBindings.h index 2a8e590b..8c774cb6 100644 --- a/python/PythonBindings.h +++ b/python/PythonBindings.h @@ -56,8 +56,8 @@ #include #include // FrameExplorer.h -// Explorer.h -// PropertyExplorer.h +#include +#include // ActionViewer.h #include @@ -76,7 +76,7 @@ // SliderTextWidget.h // action -// Action.h +#include // ActionExtension.h // ActionWidget.h diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index 34417c31..b3f0b518 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -35,7 +35,9 @@ - + + + @@ -254,6 +256,10 @@ static void ApplicationConstructor(PyObject* self, PyObject* pyargv, Application + + + + @@ -294,7 +300,8 @@ static void ApplicationConstructor(PyObject* self, PyObject* pyargv, Application ============================ --> - + + @@ -382,13 +389,169 @@ static void ApplicationConstructor(PyObject* self, PyObject* pyargv, Application + - + + + + + + + + vtkImageData* imageData = cppSelf->getImageData(); + + PyObject *module_name, *module, *dict, *python_class, *object; + module_name = PyUnicode_DecodeFSDefault("vtk"); + module = PyImport_Import(module_name); + + if (module == nullptr) { + PyErr_Print(); + qDebug() << "Fails to import the vtk module."; + return nullptr; + } + Py_DECREF(module_name); + + // dict is a borrowed reference. + dict = PyModule_GetDict(module); + if (dict == nullptr) { + PyErr_Print(); + qDebug() << "Fails to get the dictionary."; + return nullptr; + } + Py_DECREF(module); + + // Builds the name of a callable class + python_class = PyDict_GetItemString(dict, "vtkObjectBase"); + if (python_class == nullptr) { + PyErr_Print(); + qDebug() << "Fails to get the vtkObjectBase Python class."; + return nullptr; + } + Py_DECREF(dict); + + std::ostringstream oss; + oss << (vtkObjectBase*) imageData; // here don't get address + std::string address_str = oss.str(); + qDebug() << "image data at adress: " << QString::fromStdString(address_str); + + // Creates an instance of the class + if (PyCallable_Check(python_class)) { + Shiboken::AutoDecRef args(PyTuple_New(1)); + PyTuple_SET_ITEM(args, 0, Shiboken::Conversions::copyToPython(Shiboken::Conversions::PrimitiveTypeConverter<std::string>(), &address_str)); + + qDebug() << "Calling instanciation"; + object = PyObject_CallObject(python_class, args); + Py_DECREF(python_class); + } else { + qDebug() << "Cannot instantiate the vtkObjectBase Python class"; + Py_DECREF(python_class); + return nullptr; + } + qDebug() << "Calling instanciation done"; + return object; - --> + + + + + +vtkImageData* cppImageData = nullptr; +// +// Inspired by https://vtk.org/Wiki/Example_from_and_to_python_converters +// +// This python to C++ converter uses the fact that VTK Python objects have an +// attribute called __this__, which is a string containing the memory address +// of the VTK C++ object and its class name. +// E.g. for a vtkPoints object __this__ might be "_0000000105a64420_p_vtkPoints" +// +//qDebug() << "In setVtkImageData"; + +char thisStr[] = "__this__"; +//first we need to get the __this__ attribute from the Python Object +if (!PyObject_HasAttrString(%PYARG_1, thisStr)) { + qDebug() << "PyArg has not string __this__"; + return nullptr; +} + +PyObject* thisAttr = PyObject_GetAttrString(%PYARG_1, thisStr); +if (thisAttr == nullptr) { + qDebug() << "__this__ is null"; + return nullptr; +} +//qDebug() << "Found: " << thisAttr; + +PyObject* strUTF8 = PyUnicode_AsUTF8String(thisAttr); +Py_DECREF(thisAttr); +const char* str = PyBytes_AS_STRING(strUTF8); +qDebug() << "VTK __this string: \"" << str << "\""; + +char hex_address[32], *pEnd; +const char *_p_ = strstr(str, "_p_vtk"); +if(_p_ == nullptr) { + qDebug() << "Cannot find \"_p_vtk\" ending string"; + return nullptr; +} +const char *class_name = strstr(_p_, "vtk"); +if(class_name == nullptr) { + qDebug() << "Cannot find \"vtk\" ending string"; + return nullptr; +} +strcpy(hex_address, str+1); +hex_address[_p_-str-1] = '\0'; + +long address = strtol(hex_address, &pEnd, 16); + +//qDebug() << "Ptr address is \"" << hex_address << "\""; + +vtkObjectBase* vtk_object = (vtkObjectBase*)((void*)address); +Py_DECREF(strUTF8); + +if(vtk_object->IsA(class_name)) { + //qDebug() << "PyArg converted to vtkObjectBase"; + cppImageData = vtkImageData::SafeDownCast(vtk_object); + //qDebug() << "PyArg converted to vtkImageData"; +} + + + + + // convert the vtkImageData from Python to C++ + + + + + + + + + + + + + // Not %1 but %out + %CPPSELF->replaceImageData(cppImageData, false); + + diff --git a/python/test.py b/python/test.py index fae60aae..99e8ffbf 100644 --- a/python/test.py +++ b/python/test.py @@ -4,7 +4,13 @@ # gdb python3 core # and then issue the "where" command # +# debug +# python3 -m pdb ../src/camitk/python/test.py +# +# Another example is to transfer numpy to VTK # see https://pyscience.wordpress.com/2014/09/06/numpy-to-vtk-converting-your-numpy-arrays-to-vtk-arrays-and-files/ +# It points out to pyvtk, which is a example of numpy export to VTK +# https://bitbucket.org/somada141/pyevtk/src/08f37a46fadc?at=default # import traceback @@ -29,16 +35,82 @@ print (availableCamiTKClasses) #def __init__(self): #camitk.Application.__init__(self) import vtk +import math +from PySide2.QtCore import Qt # for Qt.LeftDockWidgetArea +from PySide2.QtWidgets import QMenu + +# Inspired by https://stackoverflow.com/a/46626448 +from vtk.util import vtkImageImportFromArray as vtkutil +import numpy as np + +def generateSphere(imageDimension): + # compute radius and center from imageDimension + radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + # 3D array + semisizes = (radius,) * 3 + + # generate the grid for the support points + # centered at the position indicated by center + grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + center = np.ogrid[grid] + # calculate the distance of all points from center + # scaled by the radius + arr = np.zeros(imageDimension, dtype=float) + for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) + # the inner part of the sphere will have distance below 1 + #return arr <= 1.0 + + # generate vtkImage from an array + f = vtkutil.vtkImageImportFromArray() + f.SetArray( arr ) + #f.SetDataOrigin( ... ) + #f.SetDataSpacing( ... ) + #f.SetDataExtent( ... ) + f.Update() + return f.GetOutput() + if __name__ == "__main__": print("\nTry...\n") try: + # TODO segmentation fault with Explorer + print("Setting log...") + camitk.Log.getLogger().setTimeStampInformation(True) camitk.Log.getLogger().setMessageBoxLevel(camitk.InterfaceLogger.NONE) camitk.Log.getLogger().setLogLevel(camitk.InterfaceLogger.TRACE) + print("CamiTK version: " + camitk.Core.version) + app = camitk.Application(sys.argv) + app.getMainWindow().setCentralViewer(camitk.MedicalImageViewer.getInstance()) + app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.Explorer.getInstance()) + app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.PropertyExplorer.getInstance()) + + fileMenu = QMenu("&File"); + action = camitk.Application.getAction("Open") + fileMenu.addAction(action.getQAction()) + action = camitk.Application.getAction("Close") + fileMenu.addAction(action.getQAction()) + action= camitk.Application.getAction("Quit") + fileMenu.addAction(action.getQAction()) + + # help + helpMenu = QMenu("&Help") + action = camitk.Application.getAction("About...") + helpMenu.addAction(action.getQAction()) + + # add everything in the menu bar + mainWindow = app.getMainWindow() + appMenuBar = mainWindow.menuBar() + appMenuBar.addMenu(fileMenu) + appMenuBar.addSeparator() + appMenuBar.addMenu(helpMenu) + print("Class name:" + app.metaObject().className()) print("Starting application: \"" + app.getName() + "\"") print("Is there any modified components: " + str(app.hasModified())) @@ -46,31 +118,99 @@ if __name__ == "__main__": print("Testdata dir:" + camitk.Core.getTestDataDir()) print("Platform name: " + app.platformName()) print("Main window is: " + str(app.getMainWindow())) - print("Font: " + str(app.font())) + #print("Font: " + str(app.font())) comp = camitk.Application.open(camitk.Core.getTestDataDir() + "/brain.mha") - + print("Name of component: " + comp.getName()) + + imageDimension = eval(comp.property("Image Dimensions")) # dim + print("Original image dimension: " + str(imageDimension)) + print("Voxel type: " + comp.property("Voxel Data Type")) #imageData = vtk.vtkImageData() - #imageData.SetDimensions(3, 4, 5) - #imageData.AllocateScalars(vtk.VTK_DOUBLE, 1) + #imageData.SetDimensions(dim[0], dim[1], dim[2]) + #imageData.AllocateScalars(vtk.VTK_UNSIGNED_CHAR, 1) #dims = imageData.GetDimensions() + #radius = math.sqrt(dims[2]*dims[2] + dims[1]*dims[1] + dims[0]*dims[0])/4.0 + #print("Image half size radius:" + str(radius)) + #halfDims = [x / 2 for x in dims] - ## Fill every entry of the image data with '2.0' + # Fill every entry of the image data with '2.0' + #inside = 0 + #outside = 1 + #i = 0 #for z in range(dims[2]): #for y in range(dims[1]): #for x in range(dims[0]): - #imageData.SetScalarComponentFromDouble(x, y, z, 0, 2.0) - - ##comp.setImageData(imageData) - #imageData2 = comp.getImageData() + #pos = [x-halfDims[0],y-halfDims[1],z-halfDims[2]] + #posSquare = math.sqrt(pos[2]*pos[2] + pos[1]*pos[1] + pos[0]*pos[0]) + #if (posSquare < radius): + #inside+=1 + #value = -127.0 + #else: + #outside+=1 + #value = 127.0 + #i+=1 + ##imageData.SetScalarComponentFromDouble(x, y, z, 0, value) + #imageData.GetPointData().GetScalars().SetTuple1(i, value) + ##imageData.SetScalarComponentFromDouble(x, y, z, 0, 42.0) + + + #imageData = generateSphere(imageDimension) + + # compute radius and center from imageDimension + radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + # 3D array + semisizes = (radius,) * 3 + + # generate the grid for the support points + # centered at the position indicated by center + grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + center = np.ogrid[grid] + # calculate the distance of all points from center + # scaled by the radius + arr = np.zeros(imageDimension, dtype=float) + for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) + # the inner part of the sphere will have distance below 1 + #return arr <= 1.0 + + # generate vtkImage from an array + f = vtkutil.vtkImageImportFromArray() + f.SetArray( arr ) + #f.SetDataOrigin( ... ) + #f.SetDataSpacing( ... ) + #f.SetDataExtent( ... ) + f.Update() + imageData = f.GetOutput() + + #print("inside=" + str(inside) + ", outside=" + str(outside) + ", inside/outside=" + str(inside/outside)) + #print("imageData=" + str(imageData)) + print("imageData.__this__=" + str(imageData.__this__)) + #print("comp=" + str(comp)) + + backupImageData = comp.getImageData() + print("backup image data =" + str(backupImageData)) + + comp.replaceImageData(imageData) #setVtkImageData + + + # add a new component + comp2 = camitk.ImageComponent("test from scratch") + #comp2.replaceImageData(backupImageData) + + comp.setSelected(True) print("Number of opened top level components: " + str(len(app.getTopLevelComponents()))) - miw = camitk.MedicalImageViewer("Medical Image Viewer") - app.getMainWindow().setCentralViewer(miw) + + #comp.setSelected(True) + app.refresh() sys.exit(app.exec_()) + except Exception: print(traceback.format_exc()) # or -- GitLab From 45ba8af08d98b9fd212cbe10059b115c0f3340f2 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Wed, 13 Mar 2019 22:16:14 +0100 Subject: [PATCH 09/24] FIXED Explorer refreshInterfaceNode + ImageComponent volume rendering crash Closes #84. Thanks to Matthias Tummers for his patience and bug fix. --- .../core/component/image/ImageComponent.cpp | 50 +++++++------- .../core/component/mesh/MeshComponent.cpp | 4 +- sdk/libraries/core/viewer/Explorer.cpp | 67 ++++++++++--------- sdk/libraries/core/viewer/Explorer.h | 8 +-- 4 files changed, 67 insertions(+), 62 deletions(-) diff --git a/sdk/libraries/core/component/image/ImageComponent.cpp b/sdk/libraries/core/component/image/ImageComponent.cpp index 7cbb8490..30486fb2 100644 --- a/sdk/libraries/core/component/image/ImageComponent.cpp +++ b/sdk/libraries/core/component/image/ImageComponent.cpp @@ -405,31 +405,31 @@ void ImageComponent::initLookupTable() { // -------------------- replaceImageData -------------------- void ImageComponent::replaceImageData(vtkSmartPointer anImageData, bool copy, ImageOrientationHelper::PossibleImageOrientations initialOrientation) { // Delete ImageComponents - if (axialSlices) { + if (axialSlices != nullptr) { removeChild(axialSlices); delete axialSlices; axialSlices = nullptr; } - if (coronalSlices) { + if (coronalSlices != nullptr) { removeChild(coronalSlices); delete coronalSlices; coronalSlices = nullptr; } - if (sagittalSlices) { + if (sagittalSlices != nullptr) { removeChild(sagittalSlices); delete sagittalSlices; sagittalSlices = nullptr; } - if (arbitrarySlices) { + if (arbitrarySlices != nullptr) { removeChild(arbitrarySlices); delete arbitrarySlices; arbitrarySlices = nullptr; } - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { removeChild(volumeRenderingChild); delete volumeRenderingChild; volumeRenderingChild = nullptr; @@ -510,45 +510,45 @@ void ImageComponent::update3DViewer() { bool viewIn3D = property("Display Image in 3D Viewer").toBool(); if (viewIn3D) { - if (axialSlices) { + if (axialSlices != nullptr) { axialSlices->setViewSliceIn3D(true); } - if (coronalSlices) { + if (coronalSlices != nullptr) { coronalSlices->setViewSliceIn3D(true); } - if (sagittalSlices) { + if (sagittalSlices != nullptr) { sagittalSlices->setViewSliceIn3D(true); } - if (arbitrarySlices) { + if (arbitrarySlices != nullptr) { // by default not visible in 3D arbitrarySlices->setViewSliceIn3D(false); } - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { volumeRenderingChild->setVisibility(InteractiveViewer::get3DViewer(), true); } } else { - if (axialSlices) { + if (axialSlices != nullptr) { axialSlices->setViewSliceIn3D(false); } - if (coronalSlices) { + if (coronalSlices != nullptr) { coronalSlices->setViewSliceIn3D(false); } - if (sagittalSlices) { + if (sagittalSlices != nullptr) { sagittalSlices->setViewSliceIn3D(false); } - if (arbitrarySlices) { + if (arbitrarySlices != nullptr) { arbitrarySlices->setViewSliceIn3D(false); } - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { volumeRenderingChild->setVisibility(InteractiveViewer::get3DViewer(), false); } } @@ -557,25 +557,25 @@ void ImageComponent::update3DViewer() { // -------------------- buildImageComponents -------------------- void ImageComponent::buildImageComponents() { - if (!axialSlices) { + if (axialSlices == nullptr) { axialSlices = new SingleImageComponent(this, Slice::AXIAL, "Axial view", lut); } if (this->originalImageData->GetDataDimension() == 3) { - if (!coronalSlices) { + if (coronalSlices == nullptr) { coronalSlices = new SingleImageComponent(this, Slice::CORONAL, "Coronal view", lut); } - if (!sagittalSlices) { + if (sagittalSlices == nullptr) { sagittalSlices = new SingleImageComponent(this, Slice::SAGITTAL, "Sagittal view", lut); } - if (!arbitrarySlices) { + if (arbitrarySlices == nullptr) { // TODO implement arbitrary slice orientation - arbitrarySlices = nullptr; // new SingleImageComponent(this, Slice::ARBITRARY, "Arbitrary view", lut); + //arbitrarySlices = new SingleImageComponent(this, Slice::ARBITRARY, "Arbitrary view", lut); } - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { delete volumeRenderingChild; } @@ -587,25 +587,25 @@ void ImageComponent::buildImageComponents() { } else { - if (coronalSlices) { + if (coronalSlices != nullptr) { delete coronalSlices; } coronalSlices = nullptr; - if (sagittalSlices) { + if (sagittalSlices != nullptr) { delete sagittalSlices; } sagittalSlices = nullptr; - if (arbitrarySlices) { + if (arbitrarySlices != nullptr) { delete arbitrarySlices; } arbitrarySlices = nullptr; - if (volumeRenderingChild) { + if (volumeRenderingChild != nullptr) { delete volumeRenderingChild; } diff --git a/sdk/libraries/core/component/mesh/MeshComponent.cpp b/sdk/libraries/core/component/mesh/MeshComponent.cpp index e696f79e..ac850e53 100644 --- a/sdk/libraries/core/component/mesh/MeshComponent.cpp +++ b/sdk/libraries/core/component/mesh/MeshComponent.cpp @@ -789,7 +789,6 @@ bool MeshComponent::getDataRepresentationVisibility(FieldType field, const QStri } } - // -------------------- setDataRepresentationOff -------------------- void MeshComponent::setDataRepresentationOff(int dataType) { @@ -842,7 +841,8 @@ void MeshComponent::setDataRepresentationOff(int dataType) { // refresh the property tab and 3D dataModel->refresh(); - refresh(); + if (dataRepresentationVisibility.size()>0) + refresh(); } diff --git a/sdk/libraries/core/viewer/Explorer.cpp b/sdk/libraries/core/viewer/Explorer.cpp index cffa07dc..96189b09 100644 --- a/sdk/libraries/core/viewer/Explorer.cpp +++ b/sdk/libraries/core/viewer/Explorer.cpp @@ -59,7 +59,7 @@ Explorer::~Explorer() { //----------------------- getInstance ------------------------ Explorer* Explorer::getInstance() { - // static instantiation, static method variable + // static instanciation, static method variable static Explorer* explorer = nullptr; if (!explorer) { explorer = new Explorer(); @@ -135,18 +135,18 @@ void Explorer::refresh(Viewer* whoIsAsking) { if (whoIsAsking != this) { //-- check the top-level component number ComponentList topLevelCpt = Application::getTopLevelComponents(); - ComponentList viewedcomp = itemCompMap.uniqueKeys(); + ComponentList viewedcomp = topLevelCompItemMap.uniqueKeys(); if (viewedcomp.size() != topLevelCpt.size()) { // remove the closed/deleted top-level component foreach (Component* comp, viewedcomp) { if (!topLevelCpt.contains(comp)) { - remove(comp); + removeTopLevel(comp); } } // add the new top-level component foreach (Component* comp, topLevelCpt) { if (!viewedcomp.contains(comp)) { - add(comp); + addTopLevel(comp); } } } @@ -217,6 +217,7 @@ QTreeWidgetItem* Explorer::getNewItem(QTreeWidgetItem* parent, Component* abstra // add the pixmap tw->setIcon(0, abstractNode->getIcon()); } + // check the italic property QFont f = tw->font(0); f.setItalic(abstractNode->inItalic()); @@ -227,6 +228,24 @@ QTreeWidgetItem* Explorer::getNewItem(QTreeWidgetItem* parent, Component* abstra return tw; } +//----------------------- addTopLevel ------------------------ +void Explorer::addTopLevel(Component* comp, int index) { + if (!comp->getParent()) { + // create the items + QTreeWidgetItem* compItem = add(nullptr, comp); + + // add to / insert in the tree + if (index < 0) { + explorerTree->addTopLevelItem(compItem); + } + else { + explorerTree->insertTopLevelItem(index, compItem); + } + + // insert top-level component in the map + topLevelCompItemMap.insert(comp, compItem); + } +} //----------------------- add ------------------------ QTreeWidgetItem* Explorer::add(QTreeWidgetItem* parent, Component* abstractNode) { @@ -247,18 +266,6 @@ QTreeWidgetItem* Explorer::add(QTreeWidgetItem* parent, Component* abstractNode) return tw; } -//----------------------- add ------------------------ -void Explorer::add(Component* comp) { - if (!comp->getParent()) { - // create the items - QTreeWidgetItem* compItem = add(nullptr, comp); - explorerTree->addTopLevelItem(compItem); - - // insert top-level component in the map - itemCompMap.insert(comp, compItem); - } -} - //----------------------- refreshInterfaceNode ------------------------ void Explorer::refreshInterfaceNode(Component* comp) { QTreeWidgetItem* toDelete = getItem(comp); @@ -267,30 +274,28 @@ void Explorer::refreshInterfaceNode(Component* comp) { // get the index in the parent list QTreeWidgetItem* parentTW = toDelete->parent(); int index = -1; - if (parentTW == nullptr) + if (parentTW == nullptr) { // if no parent, it means toDelete is at top level, get its index - { index = explorerTree->indexOfTopLevelItem(toDelete); } - else + else { // if the parent exists, then get the index of the child - { index = parentTW->indexOfChild(toDelete); } // remove from the list and from the explorer explorerTree->blockSignals(true); - remove(toDelete); // recreate and add at the same place - if (parentTW == nullptr) - // if there is no parent, then add at the correct index on the top level - { - explorerTree->insertTopLevelItem(index, add(nullptr, comp)); + if (parentTW == nullptr) { + // if there is no parent, first remove from the map + removeTopLevel(comp); + // and then add at the correct index on the top level + addTopLevel(comp, index); } - else + else { // add where it was deleted in the parent index - { + remove(toDelete); parentTW->insertChild(index, add(nullptr, comp)); } explorerTree->blockSignals(false); @@ -298,16 +303,16 @@ void Explorer::refreshInterfaceNode(Component* comp) { } -//----------------------- remove ------------------------ -void Explorer::remove(Component* comp) { - QTreeWidgetItem* toDelete = itemCompMap.value(comp); +//----------------------- removeTopLevel ------------------------ +void Explorer::removeTopLevel(Component* comp) { + QTreeWidgetItem* toDelete = topLevelCompItemMap.value(comp); if (toDelete != nullptr) { explorerTree->blockSignals(true); // remove from the explorer remove(toDelete); explorerTree->blockSignals(false); // remove from the map - itemCompMap.remove(comp); + topLevelCompItemMap.remove(comp); } } diff --git a/sdk/libraries/core/viewer/Explorer.h b/sdk/libraries/core/viewer/Explorer.h index aaf4935c..fcb73c34 100644 --- a/sdk/libraries/core/viewer/Explorer.h +++ b/sdk/libraries/core/viewer/Explorer.h @@ -124,7 +124,7 @@ private: QMap itemComponentMap; /// the map to get the QTreeWidgetItem corresponding to a parentComp - QMap itemCompMap; + QMap topLevelCompItemMap; /// Return the QTreeWidgetItem of a given Component (return NULL if not found) QTreeWidgetItem* getItem(Component*); @@ -132,7 +132,7 @@ private: /// @name QTreeWidget and QTreeWidgetItem management ///@{ - /// instantiate a new QTreeWidgetItem using names and properties from the InterfaceNode, and using parent + /// instanciate a new QTreeWidgetItem using names and properties from the InterfaceNode, and using parent QTreeWidgetItem* getNewItem(QTreeWidgetItem* parent, Component*); /// recursively add the Component in the tree explorer and return the QTreeWidgetItem of the InterfaceNode @@ -141,7 +141,7 @@ private: /** Add the given Component to the explorer (at top level) and automatically create children Component items. * @param comp The Component to add in the tree view. */ - void add(Component* comp); + void addTopLevel(Component* comp, int index = -1); /// remove a given item from the explorer (return its index in the parent item list) void remove(QTreeWidgetItem*); @@ -149,7 +149,7 @@ private: /** Remove the Component (its Component and its sub-item) from the explorer list (if present). * The Component itself is of course not deleted here. */ - void remove(Component* comp); + void removeTopLevel(Component* comp); /// the list view -- GitLab From a4d14e3f62cc5fc4225c69f2636476fb3b86e747 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Wed, 13 Mar 2019 22:21:29 +0100 Subject: [PATCH 10/24] FIXED test.py using an Explorer viewer --- python/test.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/test.py b/python/test.py index 99e8ffbf..1dbebbf5 100644 --- a/python/test.py +++ b/python/test.py @@ -197,11 +197,10 @@ if __name__ == "__main__": print("backup image data =" + str(backupImageData)) comp.replaceImageData(imageData) #setVtkImageData - - + # add a new component comp2 = camitk.ImageComponent("test from scratch") - #comp2.replaceImageData(backupImageData) + comp2.replaceImageData(backupImageData) comp.setSelected(True) -- GitLab From 61c9d3eaead937baf61b4cbf15b64fb31f97e30d Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Thu, 14 Mar 2019 07:32:16 +0100 Subject: [PATCH 11/24] NEW action viewer accessible from Python --- python/CMakeLists.txt | 7 ++++--- python/PythonBindings.h | 2 +- python/PythonBindings.xml | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index c68a4017..5a02a1e1 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -247,6 +247,10 @@ set(CAMITK_PYTHON_CLASS_NAMES Core MainWindow SettingsDialog Viewer + Explorer + PropertyExplorer + MedicalImageViewer + ActionViewer Action InterfaceNode InterfaceProperty @@ -257,9 +261,6 @@ set(CAMITK_PYTHON_CLASS_NAMES Core ImageComponent # RendererWidget # InteractiveViewer - MedicalImageViewer - PropertyExplorer - Explorer ) # Compute which C++ files will be generated by shiboken. This includes the module wrapper, the namespace wrapper diff --git a/python/PythonBindings.h b/python/PythonBindings.h index 8c774cb6..cd9a2eeb 100644 --- a/python/PythonBindings.h +++ b/python/PythonBindings.h @@ -58,7 +58,7 @@ // FrameExplorer.h #include #include -// ActionViewer.h +#include #include // utils diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index b3f0b518..e832f4b6 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -260,6 +260,8 @@ static void ApplicationConstructor(PyObject* self, PyObject* pyargv, Application + + -- GitLab From efe04be087fb81f4be5170c5a4a2f8b66431fdf4 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Thu, 14 Mar 2019 07:33:19 +0100 Subject: [PATCH 12/24] FIXED added the documentation about the current target name The current target name is generated by the CamiTK macros and can be reused after the macro if needed --- .../macros/camitk/CamiTKApplication.cmake | 19 +++++++++++++++++++ .../macros/camitk/CamiTKExtension.cmake | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/sdk/cmake/modules/macros/camitk/CamiTKApplication.cmake b/sdk/cmake/modules/macros/camitk/CamiTKApplication.cmake index c7628f0e..75a60d67 100644 --- a/sdk/cmake/modules/macros/camitk/CamiTKApplication.cmake +++ b/sdk/cmake/modules/macros/camitk/CamiTKApplication.cmake @@ -52,6 +52,25 @@ #! \param INCLUDE_DIRECTORIES additional include directories #! \param EXTERNAL_LIBRARIES external libraries to add to the link command #! \param EXTRA_TRANSLATE_LANGUAGE Additionnal extra language to translate the application +#! +#! \note If you need to add any extra/custom CMake command after this macro, you can use ${APPLICATION_TARGET_NAME} +#! to specify the current target. +#! +#! For example: +#! \code +#! camitk_application( +#! ... +#! ) +#! +#! message(STATUS "Adding tests for target ${APPLICATION_TARGET_NAME}") +#! camitk_init_test(${APPLICATION_TARGET_NAME}) +#! # testing the application with no arguments, should print a message and exit success +#! camitk_add_test(PROJECT_NAME ${APPLICATION_TARGET_NAME} TEST_SUFFIX "-") +#! \endcode +#! + + + macro(camitk_application) # Instruct CMake to run moc automatically when needed. diff --git a/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake b/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake index 49e32983..9dd23211 100644 --- a/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake +++ b/sdk/cmake/modules/macros/camitk/CamiTKExtension.cmake @@ -94,9 +94,21 @@ #! a file called "asm-input.scxml" and at least one file name "output-*.*") #! Check the wiki for more information about integration test #! +#! \note If you need to add any extra/custom CMake command after this macro, you can use the name of the extension +#! produced by the macro: #! +#! - ${ACTION_TARGET_NAME} is the name of the target for action +#! - ${COMPONENT_TARGET_NAME} is the name of the target for component #! +#! E.g., in a CMakeLists.txt of an action: +#! \code +#! camitk_extension(ACTION_EXTENSION +#! ... +#! ) #! +#! message(STATUS "The name of the current target is: ${ACTION_TARGET_NAME}") +#! \endcode +#! macro(camitk_extension) -- GitLab From 5fe00345faa379f1a3b2335644b23d5fbbacd635 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 15 Mar 2019 10:45:19 +0100 Subject: [PATCH 13/24] FIXED use Q_SLOTS, Q_SIGNALS and remove Qt's foreach macro slot is defined when using python biding. When using python bindings and shiboken2 you might need to add the QT_NO_KEYWORDS define flags at compile time. In this case to avoid syntax errors in Python object.h due to the usage of the word "slot" we need to use the Q_SLOTS and Q_SIGNALS macro instead. Q_SLOTS and Q_SIGNALS are always defined. foreach is going to be completely deprecated. They can be easily replaced by C++11 for each loop type. See https://www.kdab.com/goodbye-q_foreach/ --- .../itkfilters/AnisotropicDiffusion.cpp | 2 +- .../actions/itkfilters/CannyEdgeDetection.cpp | 2 +- .../itkfilters/ConnectedComponents.cpp | 2 +- imaging/actions/itkfilters/Derivative.cpp | 2 +- imaging/actions/itkfilters/GaussianFilter.cpp | 2 +- .../actions/itkfilters/GradientMagnitude.cpp | 2 +- .../GradientMagnitudeRecursiveGaussian.cpp | 2 +- imaging/actions/itkfilters/Laplacian.cpp | 2 +- .../itkfilters/LaplacianRecursiveGaussian.cpp | 2 +- .../itkfilters/LaplacianSharpening.cpp | 2 +- imaging/actions/itkfilters/MeanFilter.cpp | 2 +- imaging/actions/itkfilters/MedianFilter.cpp | 2 +- .../itkfilters/MorphologicalOperators.cpp | 2 +- .../actions/itkfilters/SobelEdgeDetection.cpp | 2 +- .../itksegmentation/ManualThreshold.cpp | 2 +- .../actions/itksegmentation/OtsuFilter.cpp | 2 +- imaging/components/dicom/DicomComponent.cpp | 2 +- .../dicom/DicomComponentExtension.cpp | 6 +-- imaging/components/dicom/DicomDialog.cpp | 2 +- imaging/components/dicom/DicomParser.cpp | 10 ++-- modeling/actions/pml/CamiTKPropertyList.cpp | 2 +- modeling/actions/pml/PMLExplorerWidget.cpp | 8 +-- .../mml/monitoring/Xmlhighlighter.cpp | 2 +- sdk/actions/application/CloseAction.cpp | 2 +- sdk/actions/application/OpenAction.cpp | 2 +- sdk/actions/application/OpenFile.cpp | 2 +- sdk/actions/application/SaveAction.cpp | 2 +- sdk/actions/application/SaveAsAction.cpp | 12 ++--- .../SelectLastInstantiatedAction.cpp | 1 + sdk/actions/frame/editframes/FrameEditor.cpp | 2 +- .../image/imageresampling/ResampleAction.cpp | 2 +- .../image/reorientimage/ReorientImage.h | 3 ++ .../image/showin3d/ShowArbitrarySliceIn3D.cpp | 2 +- .../image/showin3d/ShowAxialSliceIn3D.cpp | 2 +- .../image/showin3d/ShowCoronalSliceIn3D.cpp | 2 +- sdk/actions/image/showin3d/ShowImageIn3D.cpp | 2 +- .../image/showin3d/ShowSagittalSliceIn3D.cpp | 2 +- .../volumerendering/VolumeRenderingAction.cpp | 2 +- .../imageacquisition/InitImagerAction.cpp | 2 +- .../SingleAcquisition2DAction.cpp | 2 +- .../SingleAcquisition3DAction.cpp | 2 +- .../imageacquisition/StartImaging2DAction.cpp | 2 +- .../imageacquisition/StartImaging3DAction.cpp | 2 +- .../imageacquisition/StopImaging2DAction.cpp | 2 +- .../imageacquisition/StopImaging3DAction.cpp | 2 +- sdk/actions/mesh/basicmesh/ChangeColor.cpp | 2 +- .../mesh/basicmesh/MeshToImageStencil.cpp | 2 +- .../mesh/basicmesh/RenderingOption.cpp | 2 +- sdk/actions/mesh/basicmesh/RigidTransform.cpp | 6 +-- .../mesh/meshprocessing/ExportAsMDL.cpp | 2 +- .../mesh/meshprocessing/InvertMesh.cpp | 2 +- .../meshprocessing/LoadTextureFromBMP.cpp | 2 +- .../meshprocessing/LoadTransformation.cpp | 2 +- .../mesh/meshprocessing/MeshClipping.cpp | 12 ++--- .../SaveDisplacementFromTransformation.cpp | 2 +- .../mesh/meshprocessing/SmoothFilter.cpp | 2 +- sdk/actions/mesh/meshprocessing/WarpOut.cpp | 5 ++ .../actionstatemachine/ActionState.cpp | 2 +- .../actionstatemachine/ActionStateMachine.cpp | 4 +- sdk/applications/actionstatemachine/main.cpp | 4 +- sdk/applications/imp/ImpMainWindow.cpp | 10 ++-- .../wizard/ActionAddParameterState.cpp | 2 +- .../wizard/ActionAddParameterWidget.cpp | 2 +- .../wizard/ActionClassificationState.cpp | 2 +- .../wizard/ActionClassificationWidget.cpp | 2 +- .../wizard/ActionSummaryWidget.cpp | 4 +- .../wizard/ComponentAddPropertyState.cpp | 2 +- .../wizard/ComponentAddPropertyWidget.cpp | 2 +- .../wizard/ComponentSummaryWidget.cpp | 2 +- sdk/applications/wizard/DependenciesState.cpp | 14 +++--- .../wizard/DependenciesWidget.cpp | 24 ++++----- .../wizard/ExtensionSummaryWidget.cpp | 4 +- .../wizard/GeneratingCEPState.cpp | 2 +- .../wizard/LibraryCopyFilesState.cpp | 2 +- .../wizard/LibraryCopyFilesWidget.cpp | 2 +- .../cepgenerator/ClassNameHandler.cpp | 2 +- .../ComponentExtensionGenerator.cpp | 2 +- .../cepgenerator/ParameterGenerator.cpp | 2 +- .../cepgenerator/resources/Action.cpp.in | 2 +- sdk/libraries/core/Core.cpp | 6 +-- sdk/libraries/core/ExtensionManager.cpp | 14 +++--- sdk/libraries/core/HistoryComponent.h | 5 +- sdk/libraries/core/HistoryItem.h | 1 - sdk/libraries/core/action/Action.cpp | 14 +++--- sdk/libraries/core/action/Action.h | 2 +- sdk/libraries/core/action/ActionWidget.cpp | 2 +- .../core/application/Application.cpp | 26 +++++----- sdk/libraries/core/application/Application.h | 2 +- sdk/libraries/core/application/MainWindow.cpp | 6 +-- .../core/application/SettingsDialog.cpp | 4 +- sdk/libraries/core/component/Component.cpp | 18 +++---- sdk/libraries/core/component/Component.h | 49 ++++++++++--------- sdk/libraries/core/component/Frame.cpp | 6 +-- .../core/component/image/ImageComponent.cpp | 6 +-- .../core/component/image/ImageComponent.h | 2 +- .../ImageAcquisitionComponentExtension.cpp | 2 +- .../core/component/mesh/MeshComponent.cpp | 9 ++-- sdk/libraries/core/utils/ObjectController.cpp | 2 +- sdk/libraries/core/utils/Property.h | 2 +- sdk/libraries/core/utils/PropertyObject.cpp | 2 +- sdk/libraries/core/viewer/ActionViewer.cpp | 8 +-- sdk/libraries/core/viewer/Explorer.cpp | 8 +-- sdk/libraries/core/viewer/FrameExplorer.cpp | 10 ++-- .../core/viewer/InteractiveViewer.cpp | 28 +++++------ sdk/libraries/core/viewer/InteractiveViewer.h | 10 ++-- .../core/viewer/MedicalImageViewer.cpp | 6 +-- sdk/libraries/core/viewer/RendererWidget.cpp | 2 +- sdk/libraries/core/viewer/RendererWidget.h | 4 +- sdk/libraries/core/viewer/Viewer.cpp | 2 +- sdk/libraries/core/viewer/Viewer.h | 2 +- .../ComputeNeighborValueAction.cpp | 2 +- .../actions/meshpointdata/ShowPointData.cpp | 2 +- .../actions/properties/AddDynamicProperty.cpp | 2 +- tutorials/actions/properties/PropAction.cpp | 6 ++- .../WorkingWhenSleepingLinear.cpp | 2 +- .../WorkingWhenSleepingRandom.cpp | 2 +- 116 files changed, 270 insertions(+), 259 deletions(-) diff --git a/imaging/actions/itkfilters/AnisotropicDiffusion.cpp b/imaging/actions/itkfilters/AnisotropicDiffusion.cpp index b3b9c688..835db967 100644 --- a/imaging/actions/itkfilters/AnisotropicDiffusion.cpp +++ b/imaging/actions/itkfilters/AnisotropicDiffusion.cpp @@ -97,7 +97,7 @@ AnisotropicDiffusion::AnisoDiffType AnisotropicDiffusion::getDiffusionType() { // --------------- apply ------------------- Action::ApplyStatus AnisotropicDiffusion::apply() { - foreach (Component* comp, getTargets()) { + for(Component *child : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/CannyEdgeDetection.cpp b/imaging/actions/itkfilters/CannyEdgeDetection.cpp index 5c185a2f..e1818aec 100644 --- a/imaging/actions/itkfilters/CannyEdgeDetection.cpp +++ b/imaging/actions/itkfilters/CannyEdgeDetection.cpp @@ -80,7 +80,7 @@ CannyEdgeDetection::~CannyEdgeDetection() { // --------------- apply ------------------- Action::ApplyStatus CannyEdgeDetection::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/ConnectedComponents.cpp b/imaging/actions/itkfilters/ConnectedComponents.cpp index 08193555..4f2b5cc0 100644 --- a/imaging/actions/itkfilters/ConnectedComponents.cpp +++ b/imaging/actions/itkfilters/ConnectedComponents.cpp @@ -65,7 +65,7 @@ void ConnectedComponents::setNbConnectedComponents(const int nbConnectedComponen // --------------- apply ------------------- Action::ApplyStatus ConnectedComponents::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/Derivative.cpp b/imaging/actions/itkfilters/Derivative.cpp index d98ed3a7..09945586 100644 --- a/imaging/actions/itkfilters/Derivative.cpp +++ b/imaging/actions/itkfilters/Derivative.cpp @@ -91,7 +91,7 @@ Derivative::~Derivative() { // --------------- apply ------------------- Action::ApplyStatus Derivative::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); this->process(input); } diff --git a/imaging/actions/itkfilters/GaussianFilter.cpp b/imaging/actions/itkfilters/GaussianFilter.cpp index 2e74f50f..de0dc79f 100644 --- a/imaging/actions/itkfilters/GaussianFilter.cpp +++ b/imaging/actions/itkfilters/GaussianFilter.cpp @@ -87,7 +87,7 @@ GaussianFilter::GaussianType GaussianFilter::getType() { // --------------- apply ------------------- Action::ApplyStatus GaussianFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/GradientMagnitude.cpp b/imaging/actions/itkfilters/GradientMagnitude.cpp index a7db5634..9f30a331 100644 --- a/imaging/actions/itkfilters/GradientMagnitude.cpp +++ b/imaging/actions/itkfilters/GradientMagnitude.cpp @@ -52,7 +52,7 @@ GradientMagnitude::GradientMagnitude(ActionExtension* extension) : Action(extens // --------------- apply ------------------- Action::ApplyStatus GradientMagnitude::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/GradientMagnitudeRecursiveGaussian.cpp b/imaging/actions/itkfilters/GradientMagnitudeRecursiveGaussian.cpp index 5b918f59..5ae9f3c2 100644 --- a/imaging/actions/itkfilters/GradientMagnitudeRecursiveGaussian.cpp +++ b/imaging/actions/itkfilters/GradientMagnitudeRecursiveGaussian.cpp @@ -74,7 +74,7 @@ GradientMagnitudeRecursiveGaussian::~GradientMagnitudeRecursiveGaussian() { // --------------- apply ------------------- Action::ApplyStatus GradientMagnitudeRecursiveGaussian::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/Laplacian.cpp b/imaging/actions/itkfilters/Laplacian.cpp index 0efeebef..71d1aa91 100644 --- a/imaging/actions/itkfilters/Laplacian.cpp +++ b/imaging/actions/itkfilters/Laplacian.cpp @@ -68,7 +68,7 @@ Laplacian::~Laplacian() { // --------------- apply ------------------- Action::ApplyStatus Laplacian::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/LaplacianRecursiveGaussian.cpp b/imaging/actions/itkfilters/LaplacianRecursiveGaussian.cpp index 5dc9f8f1..74078249 100644 --- a/imaging/actions/itkfilters/LaplacianRecursiveGaussian.cpp +++ b/imaging/actions/itkfilters/LaplacianRecursiveGaussian.cpp @@ -72,7 +72,7 @@ LaplacianRecursiveGaussian::~LaplacianRecursiveGaussian() { // --------------- apply ------------------- Action::ApplyStatus LaplacianRecursiveGaussian::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/LaplacianSharpening.cpp b/imaging/actions/itkfilters/LaplacianSharpening.cpp index d2cee96c..f7be56e3 100644 --- a/imaging/actions/itkfilters/LaplacianSharpening.cpp +++ b/imaging/actions/itkfilters/LaplacianSharpening.cpp @@ -56,7 +56,7 @@ LaplacianSharpening::LaplacianSharpening(ActionExtension* extension) : Action(ex // --------------- apply ------------------- Action::ApplyStatus LaplacianSharpening::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/MeanFilter.cpp b/imaging/actions/itkfilters/MeanFilter.cpp index c0866b97..21ef1401 100644 --- a/imaging/actions/itkfilters/MeanFilter.cpp +++ b/imaging/actions/itkfilters/MeanFilter.cpp @@ -89,7 +89,7 @@ MeanFilter::~MeanFilter() { // --------------- apply ------------------- Action::ApplyStatus MeanFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/MedianFilter.cpp b/imaging/actions/itkfilters/MedianFilter.cpp index 05fc7890..381d67c8 100644 --- a/imaging/actions/itkfilters/MedianFilter.cpp +++ b/imaging/actions/itkfilters/MedianFilter.cpp @@ -89,7 +89,7 @@ MedianFilter::~MedianFilter() { // --------------- apply ------------------- Action::ApplyStatus MedianFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/MorphologicalOperators.cpp b/imaging/actions/itkfilters/MorphologicalOperators.cpp index 3ea1b65b..8fcfb935 100644 --- a/imaging/actions/itkfilters/MorphologicalOperators.cpp +++ b/imaging/actions/itkfilters/MorphologicalOperators.cpp @@ -86,7 +86,7 @@ MorphologicalOperators::MorphoOperation MorphologicalOperators::getMorphoOperati // --------------- apply ------------------- Action::ApplyStatus MorphologicalOperators::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itkfilters/SobelEdgeDetection.cpp b/imaging/actions/itkfilters/SobelEdgeDetection.cpp index c9c13a61..6b173e7e 100644 --- a/imaging/actions/itkfilters/SobelEdgeDetection.cpp +++ b/imaging/actions/itkfilters/SobelEdgeDetection.cpp @@ -60,7 +60,7 @@ SobelEdgeDetection::SobelEdgeDetection(ActionExtension* extension) : Action(exte // --------------- apply ------------------- Action::ApplyStatus SobelEdgeDetection::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itksegmentation/ManualThreshold.cpp b/imaging/actions/itksegmentation/ManualThreshold.cpp index f1e97a61..0fbe45c7 100644 --- a/imaging/actions/itksegmentation/ManualThreshold.cpp +++ b/imaging/actions/itksegmentation/ManualThreshold.cpp @@ -74,7 +74,7 @@ ManualThreshold::~ManualThreshold() { // --------------- apply ------------------- Action::ApplyStatus ManualThreshold::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/actions/itksegmentation/OtsuFilter.cpp b/imaging/actions/itksegmentation/OtsuFilter.cpp index 3917c3c3..0befe1d6 100644 --- a/imaging/actions/itksegmentation/OtsuFilter.cpp +++ b/imaging/actions/itksegmentation/OtsuFilter.cpp @@ -79,7 +79,7 @@ OtsuFilter::~OtsuFilter() { // --------------- apply ------------------- Action::ApplyStatus OtsuFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/imaging/components/dicom/DicomComponent.cpp b/imaging/components/dicom/DicomComponent.cpp index 180da9df..e2d57988 100644 --- a/imaging/components/dicom/DicomComponent.cpp +++ b/imaging/components/dicom/DicomComponent.cpp @@ -83,7 +83,7 @@ DicomComponent::DicomComponent(DicomSeries* dicomSeries) : ImageComponent("") { // convert this list as a vtkStringArray vtkSmartPointer fileNamesSorted = vtkSmartPointer::New(); - foreach (std::string file, files) { + for (std::string file : files) { fileNamesSorted->InsertNextValue(file.c_str()); } diff --git a/imaging/components/dicom/DicomComponentExtension.cpp b/imaging/components/dicom/DicomComponentExtension.cpp index 4c1a5e21..eaa24ad9 100644 --- a/imaging/components/dicom/DicomComponentExtension.cpp +++ b/imaging/components/dicom/DicomComponentExtension.cpp @@ -57,7 +57,7 @@ Component* DicomComponentExtension::open(const QString& path) { seriesParsed = DicomParser::parseDirectory(path); // create a Dialog entry for each series parsed - foreach (DicomSeries* dicomSeries, seriesParsed) { + for (DicomSeries* dicomSeries : seriesParsed) { DicomDialogEntry* entry = new DicomDialogEntry(); entry->setSelected(false); entry->setAcquisitionDate(dicomSeries->getAcquisitionDate()); @@ -77,9 +77,9 @@ Component* DicomComponentExtension::open(const QString& path) { // Open each selected Dicom as a component if (!seriesDialogEntries.isEmpty()) { - foreach (DicomDialogEntry* entry, seriesDialogEntries) { + for (DicomDialogEntry* entry : seriesDialogEntries) { // Find the corresponding Dicom Series in the List - foreach (DicomSeries* series, seriesParsed) { + for (DicomSeries* series : seriesParsed) { if ((series->getStudyName() == entry->getStudyName()) && (series->getSeriesName() == entry->getSeriesName())) { lastOpenedComponent = new DicomComponent(series); diff --git a/imaging/components/dicom/DicomDialog.cpp b/imaging/components/dicom/DicomDialog.cpp index 9b7f4cf4..3d5795bd 100644 --- a/imaging/components/dicom/DicomDialog.cpp +++ b/imaging/components/dicom/DicomDialog.cpp @@ -46,7 +46,7 @@ DicomDialog::DicomDialog(QList elements): QDialog() { int row = 0; int column = 0; - foreach (DicomDialogEntry* item, dicomDialogEntries) { + for (DicomDialogEntry* item : dicomDialogEntries) { column = 0; QTableWidgetItem* selectionItem = new QTableWidgetItem(""); selectionItem->setCheckState(Qt::Unchecked); diff --git a/imaging/components/dicom/DicomParser.cpp b/imaging/components/dicom/DicomParser.cpp index 17d55b28..4db6003b 100644 --- a/imaging/components/dicom/DicomParser.cpp +++ b/imaging/components/dicom/DicomParser.cpp @@ -53,7 +53,7 @@ QList DicomParser::parseDirectory(const QString& directory) { dicomImageScanner.Scan(fileNames); CAMITK_TRACE_ALT(tr("Parsing files for DICOM image files")) - foreach (std::string file, dicomImageScanner.GetFilenames()) { + for (std::string file : dicomImageScanner.GetFilenames()) { // 1st check the file is a valid DICOM file if (dicomImageScanner.IsKey(file.c_str())) { // 2nd check the dicom file is is an image file @@ -85,7 +85,7 @@ QList DicomParser::parseDirectory(const QString& directory) { const std::set< std::string > studyValues = studyScanner.GetValues(); // for each value, build a new DicomStudyComponent given the associated study filenames - foreach (std::string studyName, studyValues) { + for (std::string studyName : studyValues) { // get study associated filenames std::vector< std::string > studyFileNames = studyScanner.GetAllFilenamesFromTagToValue(studyUIDTag, studyName.c_str()); @@ -95,7 +95,7 @@ QList DicomParser::parseDirectory(const QString& directory) { seriesScanner.AddTag(seriesUIDTag); seriesScanner.Scan(studyFileNames); const std::set< std::string > seriesValues = seriesScanner.GetValues(); - foreach (std::string serieName, seriesValues) { + for (std::string serieName : seriesValues) { // get file associated with this series std::vector< std::string > seriesFileNames = seriesScanner.GetAllFilenamesFromTagToValue(seriesUIDTag, serieName.c_str()); @@ -198,7 +198,7 @@ QString DicomParser::getStudyName(const std::vector& seriesFileName // --------------- stdListOfStringToQt ------------------- QList DicomParser::stdListOfStringToQt(const std::vector& inputList) { QList outputFileNames; - foreach (std::string stdFile, inputList) { + for (std::string stdFile : inputList) { outputFileNames.append(QString::fromStdString(stdFile)); } @@ -208,7 +208,7 @@ QList DicomParser::stdListOfStringToQt(const std::vector& // --------------- qtListOfStringToStd ------------------- std::vector< std::string > DicomParser::qtListOfStringToStd(const QList& inputList) { std::vector< std::string > outputFileNames; - foreach (QString qtFile, inputList) { + for (QString qtFile : inputList) { outputFileNames.push_back(qtFile.toStdString()); } diff --git a/modeling/actions/pml/CamiTKPropertyList.cpp b/modeling/actions/pml/CamiTKPropertyList.cpp index 7cf84693..a46b1011 100644 --- a/modeling/actions/pml/CamiTKPropertyList.cpp +++ b/modeling/actions/pml/CamiTKPropertyList.cpp @@ -29,7 +29,7 @@ using namespace camitk; // ---------------------- Destructor ---------------------------- CamiTKPropertyList::~CamiTKPropertyList() { // delete all properties - foreach (Property* prop, propertyMap.values()) { + for (Property* prop : propertyMap.values()) { delete prop; } propertyMap.clear(); diff --git a/modeling/actions/pml/PMLExplorerWidget.cpp b/modeling/actions/pml/PMLExplorerWidget.cpp index 006302c3..388016ce 100644 --- a/modeling/actions/pml/PMLExplorerWidget.cpp +++ b/modeling/actions/pml/PMLExplorerWidget.cpp @@ -77,7 +77,7 @@ PMLExplorerWidget::~PMLExplorerWidget() { delete objectController; objectController = nullptr; - foreach (QObject* o, widgetPropertiesMap) { + for (QObject* o : widgetPropertiesMap) { delete o; } @@ -219,7 +219,7 @@ void PMLExplorerWidget::selectItems() { // let's find out the corresponding Atom, SC, MC or Cell selected and ask to select them in the 3D structure QList itemsSelected = ui->treeWidget->selectedItems(); - foreach (QTreeWidgetItem* item, itemsSelected) { + for (QTreeWidgetItem* item : itemsSelected) { if (widgetAtomMap.contains(item)) { // Is it an atom ? Atom* atomSelected = widgetAtomMap.value(item); @@ -262,10 +262,10 @@ void PMLExplorerWidget::updateTarget(PMLComponent* comp) { // constructing the tree content). disconnect(ui->treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(selectItems())); - foreach (QObject* o, widgetPropertiesMap) { + for (QObject* o : widgetPropertiesMap) { delete o; } - foreach (QObject* o, atomPropertiesMap) { + for (QObject* o : atomPropertiesMap) { delete o; } diff --git a/modeling/libraries/mml/monitoring/Xmlhighlighter.cpp b/modeling/libraries/mml/monitoring/Xmlhighlighter.cpp index 6043ecd9..6ba9a149 100644 --- a/modeling/libraries/mml/monitoring/Xmlhighlighter.cpp +++ b/modeling/libraries/mml/monitoring/Xmlhighlighter.cpp @@ -367,7 +367,7 @@ void XmlHighlighter::highlightBlock(const QString& text) { highlightSubBlock(text, 0, previousBlockState()); //Run the set of inline rules. - foreach (const HighlightingRule& rule, hlRules) { + for (const HighlightingRule& rule : hlRules) { QRegExp expression(rule.pattern); int index = expression.indexIn(text); while (index >= 0) { diff --git a/sdk/actions/application/CloseAction.cpp b/sdk/actions/application/CloseAction.cpp index 23142ee8..76abcdff 100644 --- a/sdk/actions/application/CloseAction.cpp +++ b/sdk/actions/application/CloseAction.cpp @@ -62,7 +62,7 @@ Action::ApplyStatus CloseAction::apply() { QSet allTopLevel; // fill the toplevel component set - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { allTopLevel.insert(comp->getTopLevelComponent()); } diff --git a/sdk/actions/application/OpenAction.cpp b/sdk/actions/application/OpenAction.cpp index db022c88..559c6602 100644 --- a/sdk/actions/application/OpenAction.cpp +++ b/sdk/actions/application/OpenAction.cpp @@ -73,7 +73,7 @@ Action::ApplyStatus OpenAction::apply() { filter += QString("All known files (*.") + ExtensionManager::getFileExtensions().join(" *.") + ");;"; // add the extension of loaded and valid plugins - foreach (ComponentExtension* ext, ExtensionManager::getComponentExtensionsList()) { + for (ComponentExtension* ext : ExtensionManager::getComponentExtensionsList()) { filter += ext->getName() + " (*." + ext->getFileExtensions().join(" *.") + ");;"; } diff --git a/sdk/actions/application/OpenFile.cpp b/sdk/actions/application/OpenFile.cpp index 8e50d66c..a8cd6eec 100644 --- a/sdk/actions/application/OpenFile.cpp +++ b/sdk/actions/application/OpenFile.cpp @@ -136,7 +136,7 @@ void OpenFile::selectFile() { filter += QString("All known files (*.") + ExtensionManager::getFileExtensions().join(" *.") + ");;"; // add the extension of loaded and valid plugins - foreach (ComponentExtension* ext, ExtensionManager::getComponentExtensionsList()) { + for (ComponentExtension* ext : ExtensionManager::getComponentExtensionsList()) { filter += ext->getName() + " (*." + ext->getFileExtensions().join(" *.") + ");;"; } diff --git a/sdk/actions/application/SaveAction.cpp b/sdk/actions/application/SaveAction.cpp index cf610bc3..ae1430ae 100644 --- a/sdk/actions/application/SaveAction.cpp +++ b/sdk/actions/application/SaveAction.cpp @@ -62,7 +62,7 @@ QWidget* SaveAction::getWidget() { Action::ApplyStatus SaveAction::apply() { QSet allTopLevel; // fill the toplevel component set - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { allTopLevel.insert(comp->getTopLevelComponent()); } diff --git a/sdk/actions/application/SaveAsAction.cpp b/sdk/actions/application/SaveAsAction.cpp index b3b754d1..1dbb6f03 100644 --- a/sdk/actions/application/SaveAsAction.cpp +++ b/sdk/actions/application/SaveAsAction.cpp @@ -82,7 +82,7 @@ Action::ApplyStatus SaveAsAction::apply() { // if no extension is found, look for the export of plugins which write directories if (!compfileName.isEmpty() && extension.isEmpty() && comp->isTopLevel()) { - foreach (QString cpName, ExtensionManager::getDataDirectoryExtNames()) { + for (QString cpName :ExtensionManager::getDataDirectoryExtNames()) { const ComponentExtension* cp = ExtensionManager::getComponentExtension(cpName); filter += cpName + cp->getFileExtensions().join(" "); } @@ -92,12 +92,12 @@ Action::ApplyStatus SaveAsAction::apply() { const ImageComponent* compAsImg = dynamic_cast(comp); if (compAsImg) { - foreach (ComponentExtension* pl, ExtensionManager::getComponentExtensionsList()) { + for (ComponentExtension* pl : ExtensionManager::getComponentExtensionsList()) { const ImageComponentExtension* imageExt = dynamic_cast(pl); if (imageExt) { QString imgFilter = imageExt->getName() + " ("; - foreach (QString ext, imageExt->getFileExtensions()) { + for (QString ext : imageExt->getFileExtensions()) { imgFilter += "*." + ext + " "; } imgFilter += ")"; @@ -110,12 +110,12 @@ Action::ApplyStatus SaveAsAction::apply() { const MeshComponent* compAsMesh = dynamic_cast(comp); if (compAsMesh) { - foreach (ComponentExtension* pl, ExtensionManager::getComponentExtensionsList()) { + for (ComponentExtension* pl : ExtensionManager::getComponentExtensionsList()) { const ComponentExtension* meshExt = dynamic_cast(pl); if (meshExt) { QString meshFilter = meshExt->getName() + " ("; - foreach (QString ext, meshExt->getFileExtensions()) { + for (QString ext : meshExt->getFileExtensions()) { meshFilter += "*." + ext + " "; } meshFilter += ")"; @@ -126,7 +126,7 @@ Action::ApplyStatus SaveAsAction::apply() { else { // the selected component is neither ImageComponent or MeshComponent, just // ask the component that instantiated it - foreach (QString ext, ExtensionManager::getComponentExtension(extension)->getFileExtensions()) { + for (QString ext : ExtensionManager::getComponentExtension(extension)->getFileExtensions()) { filter += ExtensionManager::getComponentExtension(ext)->getName() + " (*." + ext + ")"; } } diff --git a/sdk/actions/application/SelectLastInstantiatedAction.cpp b/sdk/actions/application/SelectLastInstantiatedAction.cpp index a7302f7a..e6be3779 100644 --- a/sdk/actions/application/SelectLastInstantiatedAction.cpp +++ b/sdk/actions/application/SelectLastInstantiatedAction.cpp @@ -27,6 +27,7 @@ // CamiTK #include #include +#include using namespace camitk; diff --git a/sdk/actions/frame/editframes/FrameEditor.cpp b/sdk/actions/frame/editframes/FrameEditor.cpp index c6b9de37..e8f115bc 100644 --- a/sdk/actions/frame/editframes/FrameEditor.cpp +++ b/sdk/actions/frame/editframes/FrameEditor.cpp @@ -169,7 +169,7 @@ void FrameEditor::initializeDialogWithCurrentComponent() { ui.parentFrameComboBox->clear(); ui.parentFrameComboBox->addItem("World"); ComponentList allComps = Application::getAllComponents(); - foreach (Component* comp, allComps) { + for (Component* comp : allComps) { if (comp != currentComponent) { ui.parentFrameComboBox->addItem(comp->getName()); } diff --git a/sdk/actions/image/imageresampling/ResampleAction.cpp b/sdk/actions/image/imageresampling/ResampleAction.cpp index 3b986b2a..92df4987 100644 --- a/sdk/actions/image/imageresampling/ResampleAction.cpp +++ b/sdk/actions/image/imageresampling/ResampleAction.cpp @@ -79,7 +79,7 @@ ResampleAction::~ResampleAction() { // --------------- apply ------------------- Action::ApplyStatus ResampleAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/image/reorientimage/ReorientImage.h b/sdk/actions/image/reorientimage/ReorientImage.h index 9ce4b3c2..e35b68d7 100644 --- a/sdk/actions/image/reorientimage/ReorientImage.h +++ b/sdk/actions/image/reorientimage/ReorientImage.h @@ -33,6 +33,9 @@ class vtkTransform; class vtkAnnotatedCubeActor; +class vtkAxesActor; +#include + namespace camitk { class Geometry; class ImageComponent; diff --git a/sdk/actions/image/showin3d/ShowArbitrarySliceIn3D.cpp b/sdk/actions/image/showin3d/ShowArbitrarySliceIn3D.cpp index 91345d5b..c187e14b 100644 --- a/sdk/actions/image/showin3d/ShowArbitrarySliceIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowArbitrarySliceIn3D.cpp @@ -56,7 +56,7 @@ QWidget* ShowArbitrarySliceIn3D::getWidget() { // --------------- apply ------------------- Action::ApplyStatus ShowArbitrarySliceIn3D::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { img->getArbitrarySlices()->setViewSliceIn3D(! img->getArbitrarySlices()->getViewSliceIn3D()); diff --git a/sdk/actions/image/showin3d/ShowAxialSliceIn3D.cpp b/sdk/actions/image/showin3d/ShowAxialSliceIn3D.cpp index 41bb3b32..d9ff8a0a 100644 --- a/sdk/actions/image/showin3d/ShowAxialSliceIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowAxialSliceIn3D.cpp @@ -56,7 +56,7 @@ QWidget* ShowAxialSliceIn3D::getWidget() { // --------------- apply ------------------- Action::ApplyStatus ShowAxialSliceIn3D::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { img->getAxialSlices()->setViewSliceIn3D(! img->getAxialSlices()->getViewSliceIn3D()); diff --git a/sdk/actions/image/showin3d/ShowCoronalSliceIn3D.cpp b/sdk/actions/image/showin3d/ShowCoronalSliceIn3D.cpp index 80912454..1ded382c 100644 --- a/sdk/actions/image/showin3d/ShowCoronalSliceIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowCoronalSliceIn3D.cpp @@ -56,7 +56,7 @@ QWidget* ShowCoronalSliceIn3D::getWidget() { // --------------- apply ------------------- Action::ApplyStatus ShowCoronalSliceIn3D::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { img->getCoronalSlices()->setViewSliceIn3D(! img->getCoronalSlices()->getViewSliceIn3D()); diff --git a/sdk/actions/image/showin3d/ShowImageIn3D.cpp b/sdk/actions/image/showin3d/ShowImageIn3D.cpp index b90a7b8f..8b432b03 100644 --- a/sdk/actions/image/showin3d/ShowImageIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowImageIn3D.cpp @@ -65,7 +65,7 @@ QWidget* ShowImageIn3D::getWidget() { Action::ApplyStatus ShowImageIn3D::apply() { // fill the toplevel component set - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { bool isDisplayedIn3D = img->property("Display Image in 3D Viewer").toBool(); diff --git a/sdk/actions/image/showin3d/ShowSagittalSliceIn3D.cpp b/sdk/actions/image/showin3d/ShowSagittalSliceIn3D.cpp index dc8d750d..d20d656a 100644 --- a/sdk/actions/image/showin3d/ShowSagittalSliceIn3D.cpp +++ b/sdk/actions/image/showin3d/ShowSagittalSliceIn3D.cpp @@ -55,7 +55,7 @@ QWidget* ShowSagittalSliceIn3D::getWidget() { // --------------- apply ------------------- Action::ApplyStatus ShowSagittalSliceIn3D::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* img = dynamic_cast(comp); if (img) { img->getSagittalSlices()->setViewSliceIn3D(! img->getSagittalSlices()->getViewSliceIn3D()); diff --git a/sdk/actions/image/volumerendering/VolumeRenderingAction.cpp b/sdk/actions/image/volumerendering/VolumeRenderingAction.cpp index 4d59d470..34c4a5f1 100644 --- a/sdk/actions/image/volumerendering/VolumeRenderingAction.cpp +++ b/sdk/actions/image/volumerendering/VolumeRenderingAction.cpp @@ -102,7 +102,7 @@ QWidget* VolumeRenderingAction::getWidget() { // --------------- apply ------------------- Action::ApplyStatus VolumeRenderingAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/InitImagerAction.cpp b/sdk/actions/imageacquisition/InitImagerAction.cpp index 6c48c630..fbaf8f29 100644 --- a/sdk/actions/imageacquisition/InitImagerAction.cpp +++ b/sdk/actions/imageacquisition/InitImagerAction.cpp @@ -59,7 +59,7 @@ InitImagerAction::~InitImagerAction() { // --------------- apply ------------------- Action::ApplyStatus InitImagerAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/SingleAcquisition2DAction.cpp b/sdk/actions/imageacquisition/SingleAcquisition2DAction.cpp index ea716a37..12ef20a6 100644 --- a/sdk/actions/imageacquisition/SingleAcquisition2DAction.cpp +++ b/sdk/actions/imageacquisition/SingleAcquisition2DAction.cpp @@ -59,7 +59,7 @@ SingleAcquisition2DAction::~SingleAcquisition2DAction() { // --------------- apply ------------------- Action::ApplyStatus SingleAcquisition2DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/SingleAcquisition3DAction.cpp b/sdk/actions/imageacquisition/SingleAcquisition3DAction.cpp index 768085bc..9a503336 100644 --- a/sdk/actions/imageacquisition/SingleAcquisition3DAction.cpp +++ b/sdk/actions/imageacquisition/SingleAcquisition3DAction.cpp @@ -59,7 +59,7 @@ SingleAcquisition3DAction::~SingleAcquisition3DAction() { // --------------- apply ------------------- Action::ApplyStatus SingleAcquisition3DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/StartImaging2DAction.cpp b/sdk/actions/imageacquisition/StartImaging2DAction.cpp index b2e1d498..1ebc2ab6 100644 --- a/sdk/actions/imageacquisition/StartImaging2DAction.cpp +++ b/sdk/actions/imageacquisition/StartImaging2DAction.cpp @@ -59,7 +59,7 @@ StartImaging2DAction::~StartImaging2DAction() { // --------------- apply ------------------- Action::ApplyStatus StartImaging2DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/StartImaging3DAction.cpp b/sdk/actions/imageacquisition/StartImaging3DAction.cpp index 1ae6a4ce..07a7d633 100644 --- a/sdk/actions/imageacquisition/StartImaging3DAction.cpp +++ b/sdk/actions/imageacquisition/StartImaging3DAction.cpp @@ -59,7 +59,7 @@ StartImaging3DAction::~StartImaging3DAction() { // --------------- apply ------------------- Action::ApplyStatus StartImaging3DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/StopImaging2DAction.cpp b/sdk/actions/imageacquisition/StopImaging2DAction.cpp index 63d98437..911d1d9d 100644 --- a/sdk/actions/imageacquisition/StopImaging2DAction.cpp +++ b/sdk/actions/imageacquisition/StopImaging2DAction.cpp @@ -59,7 +59,7 @@ StopImaging2DAction::~StopImaging2DAction() { // --------------- apply ------------------- Action::ApplyStatus StopImaging2DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/imageacquisition/StopImaging3DAction.cpp b/sdk/actions/imageacquisition/StopImaging3DAction.cpp index 85a8ac58..9a856838 100644 --- a/sdk/actions/imageacquisition/StopImaging3DAction.cpp +++ b/sdk/actions/imageacquisition/StopImaging3DAction.cpp @@ -59,7 +59,7 @@ StopImaging3DAction::~StopImaging3DAction() { // --------------- apply ------------------- Action::ApplyStatus StopImaging3DAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageAcquisitionComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/basicmesh/ChangeColor.cpp b/sdk/actions/mesh/basicmesh/ChangeColor.cpp index 2f72b489..b3dbecb7 100644 --- a/sdk/actions/mesh/basicmesh/ChangeColor.cpp +++ b/sdk/actions/mesh/basicmesh/ChangeColor.cpp @@ -61,7 +61,7 @@ Action::ApplyStatus ChangeColor::apply() { actorColor[3] = newColor.alphaF(); // change the color for the selected Component modes - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { comp->setActorColor(comp->getRenderingModes(), actorColor); } diff --git a/sdk/actions/mesh/basicmesh/MeshToImageStencil.cpp b/sdk/actions/mesh/basicmesh/MeshToImageStencil.cpp index 938c6e83..5dea4c65 100644 --- a/sdk/actions/mesh/basicmesh/MeshToImageStencil.cpp +++ b/sdk/actions/mesh/basicmesh/MeshToImageStencil.cpp @@ -81,7 +81,7 @@ MeshToImageStencil::~MeshToImageStencil() { // --------------- apply ------------------- Action::ApplyStatus MeshToImageStencil::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); ApplyStatus status = process(input); // abort if one of the selecteed component processing is not successful diff --git a/sdk/actions/mesh/basicmesh/RenderingOption.cpp b/sdk/actions/mesh/basicmesh/RenderingOption.cpp index 0fdea1ce..0c48c316 100644 --- a/sdk/actions/mesh/basicmesh/RenderingOption.cpp +++ b/sdk/actions/mesh/basicmesh/RenderingOption.cpp @@ -127,7 +127,7 @@ Action::ApplyStatus RenderingOption::apply() { } // update the rendering mode of selected - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { comp->setRenderingModes(m); // set the additional prop visibility comp->getProp("glyph")->SetVisibility(property("Glyph representation?").toBool()); diff --git a/sdk/actions/mesh/basicmesh/RigidTransform.cpp b/sdk/actions/mesh/basicmesh/RigidTransform.cpp index 972c9046..e2615789 100644 --- a/sdk/actions/mesh/basicmesh/RigidTransform.cpp +++ b/sdk/actions/mesh/basicmesh/RigidTransform.cpp @@ -114,7 +114,7 @@ QWidget* RigidTransform::getWidget() { //-- connect the custom pipeline to the selected Component filterList.clear(); - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { filterList.append(vtkSmartPointerTransformFilter::New()); filterList.last()->SetTransform(transformation); filterList.last()->SetInputConnection(comp->getDataPort()); @@ -194,7 +194,7 @@ Action::ApplyStatus RigidTransform::apply() { // apply the transformation unsigned int i = 0; - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { // get the result from the corresponding filter vtkSmartPointer result = vtkPointSet::SafeDownCast(filterList[i]->GetOutputDataObject(0)); if (result) { @@ -216,7 +216,7 @@ Action::ApplyStatus RigidTransform::apply() { //--------------- close ------------ void RigidTransform::close() { //--disconnect the selected Component - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { comp->setDataConnection(NULL); } // hide the dialog diff --git a/sdk/actions/mesh/meshprocessing/ExportAsMDL.cpp b/sdk/actions/mesh/meshprocessing/ExportAsMDL.cpp index 3c1f9bd7..b1540713 100644 --- a/sdk/actions/mesh/meshprocessing/ExportAsMDL.cpp +++ b/sdk/actions/mesh/meshprocessing/ExportAsMDL.cpp @@ -114,7 +114,7 @@ void ExportAsMDL::outputFileChanged(const QString& ofile) { Action::ApplyStatus ExportAsMDL::apply() { Action::ApplyStatus returnStatus = SUCCESS; - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); if (input != nullptr) { returnStatus = process(input); diff --git a/sdk/actions/mesh/meshprocessing/InvertMesh.cpp b/sdk/actions/mesh/meshprocessing/InvertMesh.cpp index be96d243..53475b84 100644 --- a/sdk/actions/mesh/meshprocessing/InvertMesh.cpp +++ b/sdk/actions/mesh/meshprocessing/InvertMesh.cpp @@ -56,7 +56,7 @@ InvertMesh::~InvertMesh() { // --------------- apply ------------------- Action::ApplyStatus InvertMesh::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/meshprocessing/LoadTextureFromBMP.cpp b/sdk/actions/mesh/meshprocessing/LoadTextureFromBMP.cpp index 8a6d29a4..badd063d 100644 --- a/sdk/actions/mesh/meshprocessing/LoadTextureFromBMP.cpp +++ b/sdk/actions/mesh/meshprocessing/LoadTextureFromBMP.cpp @@ -72,7 +72,7 @@ void LoadTextureFromBMP::loadBMP() { // --------------- apply ------------------- Action::ApplyStatus LoadTextureFromBMP::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/meshprocessing/LoadTransformation.cpp b/sdk/actions/mesh/meshprocessing/LoadTransformation.cpp index 74e4833e..f6a95fa1 100644 --- a/sdk/actions/mesh/meshprocessing/LoadTransformation.cpp +++ b/sdk/actions/mesh/meshprocessing/LoadTransformation.cpp @@ -77,7 +77,7 @@ void LoadTransformation::openTransformation() { // --------------- apply ------------------- Action::ApplyStatus LoadTransformation::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); loadTransformationFile(); } diff --git a/sdk/actions/mesh/meshprocessing/MeshClipping.cpp b/sdk/actions/mesh/meshprocessing/MeshClipping.cpp index 773a4ce4..8ef8d05e 100644 --- a/sdk/actions/mesh/meshprocessing/MeshClipping.cpp +++ b/sdk/actions/mesh/meshprocessing/MeshClipping.cpp @@ -145,8 +145,7 @@ Action::ApplyStatus MeshClipping::apply() { //-- Clipping the targeted components if (list.size() != 0) { //-- Clipping - Component* candidate; - foreach (candidate, list) { + for (Component* candidate : list) { if (candidate->isInstanceOf("MeshComponent")) { if (allComponents || candidate->isSelected()) { ApplyStatus clipStatus = clipMesh(dynamic_cast < MeshComponent* >(candidate), plane); @@ -239,8 +238,7 @@ void MeshClipping::updateBox(bool refreshViewer) { double currentBounds[6]; ComponentList list = Application::getTopLevelComponents(); (*list.begin())->getBounds(limBounds); - Component* currentComponent; - foreach (currentComponent, list) { + for (Component* currentComponent : list) { currentComponent->getBounds(currentBounds); if (currentBounds[0] < limBounds[0]) { limBounds[0] = currentBounds[0]; @@ -355,8 +353,7 @@ Action::ApplyStatus MeshClipping::clipMesh(MeshComponent* mesh, vtkSmartPointer // --------------- restoreMeshes ------------------- void MeshClipping::restoreMeshes() { - Component* candidate; - foreach (candidate, list) { + for (Component* candidate : list) { candidate->setDataConnection(candidate->getDataPort()); } list.clear(); @@ -406,8 +403,7 @@ void MeshClipping::changeAllComponents() { } else { button->setText(tr("Clip All Components")); - Component* candidate; - foreach (candidate, list) { + for (Component* candidate : list) { candidate->setDataConnection(candidate->getDataPort()); } } diff --git a/sdk/actions/mesh/meshprocessing/SaveDisplacementFromTransformation.cpp b/sdk/actions/mesh/meshprocessing/SaveDisplacementFromTransformation.cpp index 62553d15..ea000498 100644 --- a/sdk/actions/mesh/meshprocessing/SaveDisplacementFromTransformation.cpp +++ b/sdk/actions/mesh/meshprocessing/SaveDisplacementFromTransformation.cpp @@ -99,7 +99,7 @@ QWidget* SaveDisplacementFromTransformation::getWidget() { // --------------- apply ------------------- Action::ApplyStatus SaveDisplacementFromTransformation::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/meshprocessing/SmoothFilter.cpp b/sdk/actions/mesh/meshprocessing/SmoothFilter.cpp index 37905de1..962f3ed8 100644 --- a/sdk/actions/mesh/meshprocessing/SmoothFilter.cpp +++ b/sdk/actions/mesh/meshprocessing/SmoothFilter.cpp @@ -93,7 +93,7 @@ SmoothFilter::~SmoothFilter() { // --------------- apply ------------------- Action::ApplyStatus SmoothFilter::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); } diff --git a/sdk/actions/mesh/meshprocessing/WarpOut.cpp b/sdk/actions/mesh/meshprocessing/WarpOut.cpp index f2a14cd9..045e5359 100644 --- a/sdk/actions/mesh/meshprocessing/WarpOut.cpp +++ b/sdk/actions/mesh/meshprocessing/WarpOut.cpp @@ -189,7 +189,12 @@ Action::ApplyStatus WarpOut::apply() { for (vtkIdType i = 0; i < connectivityFilter->GetOutput()->GetNumberOfPoints(); i++) { // get the id of the point in the original point set +#if ( VTK_MAJOR_VERSION >= 7 && VTK_MINOR_VERSION >=1) || VTK_MAJOR_VERSION >= 8 + pointId->GetTypedTuple(i, &id); +#else pointId->GetTupleValue(i, &id); +#endif + // get the initial point position resultPointSet->GetPoint(id, pos); // get the normal diff --git a/sdk/applications/actionstatemachine/ActionState.cpp b/sdk/applications/actionstatemachine/ActionState.cpp index 71c9e913..0648d696 100644 --- a/sdk/applications/actionstatemachine/ActionState.cpp +++ b/sdk/applications/actionstatemachine/ActionState.cpp @@ -273,7 +273,7 @@ void ActionState::onEntry(QEvent* event) { myAction->setInputComponents(inputComps); //-- reset modification flags on input components to avoid mismatching output component - foreach (Component* inputComponent, inputComps) { + for (Component* inputComponent : inputComps) { inputComponent->setModified(false); } diff --git a/sdk/applications/actionstatemachine/ActionStateMachine.cpp b/sdk/applications/actionstatemachine/ActionStateMachine.cpp index 0009fdcb..bb7ce747 100644 --- a/sdk/applications/actionstatemachine/ActionStateMachine.cpp +++ b/sdk/applications/actionstatemachine/ActionStateMachine.cpp @@ -310,7 +310,7 @@ void ActionStateMachine::createAllActionStates(QDomNodeList nodeList) { QMap outputNames; QMap ::const_iterator it = statesMap->constBegin(); while (it != statesMap->constEnd()) { - foreach (QString inputCompName, it.value()->getInputComponents().keys()) { + for (QString inputCompName : it.value()->getInputComponents().keys()) { if (inputNames.values().contains(inputCompName)) { CAMITK_WARNING(tr("Warning: same input \"%1\" for more than one state. It might be wrong.\n").arg(inputCompName)) } @@ -318,7 +318,7 @@ void ActionStateMachine::createAllActionStates(QDomNodeList nodeList) { inputNames.insert(it.value(), inputCompName); } } - foreach (QString outputCompName, it.value()->getOutputComponents().keys()) { + for (QString outputCompName : it.value()->getOutputComponents().keys()) { if (outputNames.values().contains(outputCompName)) { QString msg = tr("Error: same output name \"%1\" for more than one state. Please rename the output of \"%2\"").arg(outputCompName, it.value()->getName()); CAMITK_ERROR(msg) diff --git a/sdk/applications/actionstatemachine/main.cpp b/sdk/applications/actionstatemachine/main.cpp index d7c89735..d4d34d08 100644 --- a/sdk/applications/actionstatemachine/main.cpp +++ b/sdk/applications/actionstatemachine/main.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "CommandLineOptions.hxx" using namespace camitk; @@ -76,7 +78,7 @@ int main(int argc, char** argv) { } } catch (const cli::exception& e) { - cerr << e << endl; + std::cerr << e << std::endl; usage(argv[0]); return EXIT_FAILURE; } diff --git a/sdk/applications/imp/ImpMainWindow.cpp b/sdk/applications/imp/ImpMainWindow.cpp index e48154e8..1d450222 100644 --- a/sdk/applications/imp/ImpMainWindow.cpp +++ b/sdk/applications/imp/ImpMainWindow.cpp @@ -244,7 +244,7 @@ void ImpMainWindow::initMenuBar() { fileMenu->addAction(saveHistory); fileMenu->addAction(recentDocumentSeparator); - foreach (QAction* recentAction, recentDocumentActions) { + for (QAction* recentAction : recentDocumentActions) { fileMenu->addAction(recentAction); } @@ -336,7 +336,7 @@ void ImpMainWindow::updateActionStates() { else { // add all generic actions ActionList allActions = Application::getActions(NULL); - foreach (Action* action, allActions) { + for (Action* action : allActions) { actionMenu->addAction(action->getQAction()); actionMenu->setEnabled(true); } @@ -428,7 +428,7 @@ void ImpMainWindow::updateOpenDirectoryMenu() { fileOpenDataDirectoryMenu->clear(); fileOpenDataDirectoryMenu->setEnabled(false); - foreach (QString name, ExtensionManager::getDataDirectoryExtNames()) { + for (QString name : ExtensionManager::getDataDirectoryExtNames()) { nrOfDataDirectoryManager++; QAction* openDirectory = new QAction(name, this); openDirectory->setStatusTip(tr(QString("Opens data directory for " + name).toStdString().c_str())); @@ -481,7 +481,7 @@ void ImpMainWindow::updateViewMenu() { viewMenu->clear(); // insert viewers menu - foreach (Viewer* v, viewers) { + for (Viewer* v : viewers) { QMenu* viewerMenu = v->getMenu(); if (viewerMenu) { @@ -516,7 +516,7 @@ void ImpMainWindow::editSettings() { settingsDialog.editSettings(dynamic_cast(qApp)->getPropertyObject()); // edit all viewers that have properties - foreach (Viewer* v, viewers) { + for (Viewer* v : viewers) { QObject* viewerProp = v->getPropertyObject(); if (viewerProp) { diff --git a/sdk/applications/wizard/ActionAddParameterState.cpp b/sdk/applications/wizard/ActionAddParameterState.cpp index e29e00fa..c3ff5c51 100644 --- a/sdk/applications/wizard/ActionAddParameterState.cpp +++ b/sdk/applications/wizard/ActionAddParameterState.cpp @@ -67,7 +67,7 @@ void ActionAddParameterState::addDomParameters() { if (parameterWidgets.size() > 0) { cepcoreschema::Parameters domParameters; - foreach (ActionParameterWidget* p, parameterWidgets) { + for (ActionParameterWidget* p : parameterWidgets) { QString name = p->getName(); QString type = p->getType(); QString defValue = p->getDefaultValue(); diff --git a/sdk/applications/wizard/ActionAddParameterWidget.cpp b/sdk/applications/wizard/ActionAddParameterWidget.cpp index 2049821e..48fd4db8 100644 --- a/sdk/applications/wizard/ActionAddParameterWidget.cpp +++ b/sdk/applications/wizard/ActionAddParameterWidget.cpp @@ -104,7 +104,7 @@ bool ActionAddParameterWidget::isOneNonAsciiParameter() { void ActionAddParameterWidget::setToDefault() { // Remove existing parameters - foreach (ActionParameterWidget* widget, list) { + for (ActionParameterWidget* widget : list) { ui.parametersLayout->removeWidget(widget); if (widget != NULL) { delete widget; diff --git a/sdk/applications/wizard/ActionClassificationState.cpp b/sdk/applications/wizard/ActionClassificationState.cpp index d61e53e9..9935472c 100644 --- a/sdk/applications/wizard/ActionClassificationState.cpp +++ b/sdk/applications/wizard/ActionClassificationState.cpp @@ -66,7 +66,7 @@ void ActionClassificationState::onExit(QEvent* event) { aClassification.itkFilter(domAction->classification().itkFilter()); } - foreach (ActionTagWidget* tagWidget, tagWidgets) { + for (ActionTagWidget* tagWidget : tagWidgets) { QString tag = tagWidget->getTag(); aClassification.tag().push_back(tag.toStdString().c_str()); } diff --git a/sdk/applications/wizard/ActionClassificationWidget.cpp b/sdk/applications/wizard/ActionClassificationWidget.cpp index a8eae608..76301467 100644 --- a/sdk/applications/wizard/ActionClassificationWidget.cpp +++ b/sdk/applications/wizard/ActionClassificationWidget.cpp @@ -43,7 +43,7 @@ void ActionClassificationWidget::setToDefault() { ui.requiredLabel->setStyleSheet(normalStyle); // Empty Tags - foreach (ActionTagWidget* tag, list) { + for (ActionTagWidget* tag : list) { ui.actionTagsLayout->removeWidget(tag); if (tag != NULL) { delete tag; diff --git a/sdk/applications/wizard/ActionSummaryWidget.cpp b/sdk/applications/wizard/ActionSummaryWidget.cpp index 55f43e1f..c34f7ebc 100644 --- a/sdk/applications/wizard/ActionSummaryWidget.cpp +++ b/sdk/applications/wizard/ActionSummaryWidget.cpp @@ -60,13 +60,13 @@ void ActionSummaryWidget::setSummary(QString name, QString description, QString text = text.replace(QRegExp("@FAMILY@"), family); QString parametersList = ""; - foreach (QString el, parameters) { + for (QString el : parameters) { parametersList += "
  • " + el + "
  • \n"; } text = text.replace(QRegExp("@PARAMETERS_LIST@"), parametersList); QString tagsList = ""; - foreach (QString dep, tags) { + for (QString dep : tags) { tagsList += "
  • " + dep + "
  • \n"; } text = text.replace(QRegExp("@TAGS_LIST@"), tagsList); diff --git a/sdk/applications/wizard/ComponentAddPropertyState.cpp b/sdk/applications/wizard/ComponentAddPropertyState.cpp index 607ee783..0c3461d1 100644 --- a/sdk/applications/wizard/ComponentAddPropertyState.cpp +++ b/sdk/applications/wizard/ComponentAddPropertyState.cpp @@ -67,7 +67,7 @@ void ComponentAddPropertyState::addDomParameters() { if (parameterWidgets.size() > 0) { cepcoreschema::Parameters domParameters; - foreach (ComponentPropertyWidget* p, parameterWidgets) { + for (ComponentPropertyWidget* p : parameterWidgets) { QString name = p->getName(); QString type = p->getType(); QString defValue = p->getDefaultValue(); diff --git a/sdk/applications/wizard/ComponentAddPropertyWidget.cpp b/sdk/applications/wizard/ComponentAddPropertyWidget.cpp index c502e6d2..bd7527e9 100644 --- a/sdk/applications/wizard/ComponentAddPropertyWidget.cpp +++ b/sdk/applications/wizard/ComponentAddPropertyWidget.cpp @@ -105,7 +105,7 @@ bool ComponentAddPropertyWidget::isOneNonAsciiParameter() { void ComponentAddPropertyWidget::setToDefault() { // Remove existing properties - foreach (ComponentPropertyWidget* widget, list) { + for (ComponentPropertyWidget* widget : list) { ui.propertiesLayout->removeWidget(widget); if (widget != NULL) { delete widget; diff --git a/sdk/applications/wizard/ComponentSummaryWidget.cpp b/sdk/applications/wizard/ComponentSummaryWidget.cpp index 4faf4a3a..45724d67 100644 --- a/sdk/applications/wizard/ComponentSummaryWidget.cpp +++ b/sdk/applications/wizard/ComponentSummaryWidget.cpp @@ -58,7 +58,7 @@ void ComponentSummaryWidget::setSummary(QString name, QString description, QStri text = text.replace(QRegExp("@REPRESENTATION@"), representation); QString parametersList = ""; - foreach (QString el, properties) { + for (QString el : properties) { parametersList += "
  • " + el + "
  • \n"; } text = text.replace(QRegExp("@PROPERTIES_LIST@"), parametersList); diff --git a/sdk/applications/wizard/DependenciesState.cpp b/sdk/applications/wizard/DependenciesState.cpp index 677f6d85..14f25cd4 100644 --- a/sdk/applications/wizard/DependenciesState.cpp +++ b/sdk/applications/wizard/DependenciesState.cpp @@ -111,19 +111,19 @@ cepcoreschema::Dependencies* DependenciesState::getDependencies() { if (dependenciesWidget != nullptr) { // Get Internal CEP dependencies QStringList cepLibraries = dependenciesWidget->getCEPLibrariesDependencies(); - foreach (QString lib, cepLibraries) { + for (QString lib : cepLibraries) { QString libName = ClassNameHandler::getDirectoryName(lib); cepcoreschema::Dependency dep("cepLibrary", libName.toStdString()); domDependencies->dependency().push_back(dep); } QStringList cepComponents = dependenciesWidget->getCEPComponentsDependencies(); - foreach (QString comp, cepComponents) { + for (QString comp : cepComponents) { QString compName = ClassNameHandler::getDirectoryName(comp); cepcoreschema::Dependency dep("component", compName.toStdString()); domDependencies->dependency().push_back(dep); } QStringList cepActions = dependenciesWidget->getCEPActionsDependencies(); - foreach (QString action, cepActions) { + for (QString action : cepActions) { QString actionName = ClassNameHandler::getDirectoryName(action); cepcoreschema::Dependency dep("action", actionName.toStdString()); domDependencies->dependency().push_back(dep); @@ -131,19 +131,19 @@ cepcoreschema::Dependencies* DependenciesState::getDependencies() { // Get CamiTK dependencies QStringList camitkLibraries = dependenciesWidget->getCamiTKLibrariesDependencies(); - foreach (QString lib, camitkLibraries) { + for (QString lib : camitkLibraries) { QString libName = ClassNameHandler::getDirectoryName(lib); cepcoreschema::Dependency dep("cepLibrary", libName.toStdString()); domDependencies->dependency().push_back(dep); } QStringList camitkComponents = dependenciesWidget->getCamiTKComponentsDependencies(); - foreach (QString comp, camitkComponents) { + for (QString comp : camitkComponents) { QString compName = ClassNameHandler::getDirectoryName(comp); cepcoreschema::Dependency dep("component", compName.toStdString()); domDependencies->dependency().push_back(dep); } QStringList camitkActions = dependenciesWidget->getCamiTKActionsDependencies(); - foreach (QString action, camitkActions) { + for (QString action : camitkActions) { QString actionName = ClassNameHandler::getDirectoryName(action); cepcoreschema::Dependency dep("action", actionName.toStdString()); domDependencies->dependency().push_back(dep); @@ -151,7 +151,7 @@ cepcoreschema::Dependencies* DependenciesState::getDependencies() { // Get Other libraries dependencies QStringList externalLibs = dependenciesWidget->getExternalLibsDependencies(); - foreach (QString lib, externalLibs) { + for (QString lib : externalLibs) { cepcoreschema::Dependency dep("library", lib.toStdString()); domDependencies->dependency().push_back(dep); } diff --git a/sdk/applications/wizard/DependenciesWidget.cpp b/sdk/applications/wizard/DependenciesWidget.cpp index f20da2fd..294ab43b 100644 --- a/sdk/applications/wizard/DependenciesWidget.cpp +++ b/sdk/applications/wizard/DependenciesWidget.cpp @@ -34,21 +34,21 @@ DependenciesWidget::DependenciesWidget(QWidget* parent) : QWidget(parent) { void DependenciesWidget::setToDefault() { // Remove exisiting Libraries Check Boxes - foreach (QCheckBox* cb, cepLibrariesCheckBox) { + for (QCheckBox* cb : cepLibrariesCheckBox) { ui.cepLibsLayout->removeWidget(cb); delete cb; } cepLibrariesCheckBox.clear(); // Remove exisiting Components Check Boxes - foreach (QCheckBox* cb, cepComponentsCheckBox) { + for (QCheckBox* cb : cepComponentsCheckBox) { ui.cepLibsLayout->removeWidget(cb); delete cb; } cepComponentsCheckBox.clear(); // Remove exisiting Actions Check Boxes - foreach (QCheckBox* cb, cepActionsCheckBox) { + for (QCheckBox* cb : cepActionsCheckBox) { ui.cepActionsLayout->removeWidget(cb); delete cb; } @@ -106,7 +106,7 @@ void DependenciesWidget::setElement(QString element) { questionMarks.append(ui.camitkComponentsQM); questionMarks.append(ui.camitkActionsQM); - foreach (QLabel* qm, questionMarks) { + for (QLabel* qm : questionMarks) { text = qm->toolTip(); text.replace(QRegExp("@ELEMENT@"), element); qm->setToolTip(text); @@ -116,7 +116,7 @@ void DependenciesWidget::setElement(QString element) { void DependenciesWidget::updateCEPLibraries(QStringList cepLibraries) { // Remove exisiting Check Boxes - foreach (QCheckBox* cb, cepLibrariesCheckBox) { + for (QCheckBox* cb : cepLibrariesCheckBox) { ui.cepLibsLayout->removeWidget(cb); delete cb; } @@ -129,7 +129,7 @@ void DependenciesWidget::updateCEPLibraries(QStringList cepLibraries) { else { int row = 0; int col = 0; - foreach (QString lib, cepLibraries) { + for (QString lib : cepLibraries) { QCheckBox* checkBox = new QCheckBox(); checkBox->setText(lib); checkBox->setChecked(false); @@ -148,7 +148,7 @@ void DependenciesWidget::updateCEPLibraries(QStringList cepLibraries) { void DependenciesWidget::updateCEPComponents(QMap cepComponents) { // Remove exisiting Check Boxes - foreach (QCheckBox* cb, cepComponentsCheckBox) { + for (QCheckBox* cb : cepComponentsCheckBox) { ui.cepLibsLayout->removeWidget(cb); delete cb; } @@ -186,7 +186,7 @@ void DependenciesWidget::updateCEPComponents(QMap cepComponents) void DependenciesWidget::updateCEPActions(QStringList cepActions) { // Remove exisiting Check Boxes - foreach (QCheckBox* cb, cepActionsCheckBox) { + for (QCheckBox* cb : cepActionsCheckBox) { ui.cepActionsLayout->removeWidget(cb); delete cb; } @@ -199,7 +199,7 @@ void DependenciesWidget::updateCEPActions(QStringList cepActions) { else { int row = 0; int col = 0; - foreach (QString action, cepActions) { + for (QString action : cepActions) { QCheckBox* checkBox = new QCheckBox(); checkBox->setText(action); checkBox->setChecked(false); @@ -218,7 +218,7 @@ void DependenciesWidget::updateCEPActions(QStringList cepActions) { QStringList DependenciesWidget::getCEPLibrariesDependencies() { QStringList cepLibs; - foreach (QCheckBox* cb, cepLibrariesCheckBox) { + for (QCheckBox* cb : cepLibrariesCheckBox) { if (cb->isChecked()) { cepLibs.append(cb->text()); } @@ -229,7 +229,7 @@ QStringList DependenciesWidget::getCEPLibrariesDependencies() { QStringList DependenciesWidget::getCEPComponentsDependencies() { QStringList cepComps; - foreach (QCheckBox* cb, cepComponentsCheckBox) { + for (QCheckBox* cb : cepComponentsCheckBox) { if (cb->isChecked()) { cepComps.append(cb->text()); } @@ -240,7 +240,7 @@ QStringList DependenciesWidget::getCEPComponentsDependencies() { QStringList DependenciesWidget::getCEPActionsDependencies() { QStringList cepActions; - foreach (QCheckBox* cb, cepActionsCheckBox) { + for (QCheckBox* cb : cepActionsCheckBox) { if (cb->isChecked()) { cepActions.append(cb->text()); } diff --git a/sdk/applications/wizard/ExtensionSummaryWidget.cpp b/sdk/applications/wizard/ExtensionSummaryWidget.cpp index b086f196..171ec673 100644 --- a/sdk/applications/wizard/ExtensionSummaryWidget.cpp +++ b/sdk/applications/wizard/ExtensionSummaryWidget.cpp @@ -72,13 +72,13 @@ void ExtensionSummaryWidget::setSummary(QString name, QString description, QStri text = text.replace(QRegExp("@DESCRIPTION@"), description); QString elementsList = ""; - foreach (QString el, elements) { + for (QString el : elements) { elementsList += "
  • " + el + "
  • \n"; } text = text.replace(QRegExp("@ELEMENTS_LIST@"), elementsList); QString dependenciesList = ""; - foreach (QString dep, dependencies) { + for (QString dep : dependencies) { dependenciesList += "
  • " + dep + "
  • \n"; } text = text.replace(QRegExp("@DEPENDENCIES_LIST@"), dependenciesList); diff --git a/sdk/applications/wizard/GeneratingCEPState.cpp b/sdk/applications/wizard/GeneratingCEPState.cpp index 53578b2a..0763f3f2 100644 --- a/sdk/applications/wizard/GeneratingCEPState.cpp +++ b/sdk/applications/wizard/GeneratingCEPState.cpp @@ -99,7 +99,7 @@ void GeneratingCEPState::onEntry(QEvent* event) { std::cout << "cpeDirName: " << cepDirName.toStdString() << ", libraryName: " << libraryName.toStdString() << std::endl; - foreach (QString totalFileName, totalFileNamesList) { + for (QString totalFileName : totalFileNamesList) { QFileInfo fileInfo(totalFileName); QString shortFileName = fileInfo.fileName(); diff --git a/sdk/applications/wizard/LibraryCopyFilesState.cpp b/sdk/applications/wizard/LibraryCopyFilesState.cpp index 81ff78ba..661276e6 100644 --- a/sdk/applications/wizard/LibraryCopyFilesState.cpp +++ b/sdk/applications/wizard/LibraryCopyFilesState.cpp @@ -55,7 +55,7 @@ void LibraryCopyFilesState::onEntry(QEvent* event) { if (domLibrary != nullptr) { QString libraryName = domLibrary->name().c_str(); QStringList files = libraryFilesMap->value(libraryName); - foreach (QString file, files) { + for (QString file : files) { libraryCopyFilesWidget->addFile(file); } } diff --git a/sdk/applications/wizard/LibraryCopyFilesWidget.cpp b/sdk/applications/wizard/LibraryCopyFilesWidget.cpp index 544d6079..51c15b86 100644 --- a/sdk/applications/wizard/LibraryCopyFilesWidget.cpp +++ b/sdk/applications/wizard/LibraryCopyFilesWidget.cpp @@ -65,7 +65,7 @@ void LibraryCopyFilesWidget::addFile(QString file) { void LibraryCopyFilesWidget::addFileClicked() { QStringList filesList = QFileDialog::getOpenFileNames(this, tr("Select one or more files"), "/home"); - foreach (QString fileName, filesList) { + for (QString fileName : filesList) { addLibraryName(fileName); } } diff --git a/sdk/libraries/cepgenerator/ClassNameHandler.cpp b/sdk/libraries/cepgenerator/ClassNameHandler.cpp index b5654b39..fe99748a 100644 --- a/sdk/libraries/cepgenerator/ClassNameHandler.cpp +++ b/sdk/libraries/cepgenerator/ClassNameHandler.cpp @@ -49,7 +49,7 @@ QString ClassNameHandler::getClassName(QString genericName) { } // uppercase the first letter of each word and concatenate - foreach (QString s, cppNameList) { + for (QString s : cppNameList) { className += s.left(1).toUpper() + s.mid(1).toLower(); } className = className.left(1).toUpper() + className.mid(1); diff --git a/sdk/libraries/cepgenerator/ComponentExtensionGenerator.cpp b/sdk/libraries/cepgenerator/ComponentExtensionGenerator.cpp index 6a33876c..6cf220bf 100644 --- a/sdk/libraries/cepgenerator/ComponentExtensionGenerator.cpp +++ b/sdk/libraries/cepgenerator/ComponentExtensionGenerator.cpp @@ -164,7 +164,7 @@ void ComponentExtensionGenerator::writeCFile(QString directory) { suffixesList << componentSuffixes; } - foreach (QString s, suffixesList) { + for (QString s : suffixesList) { std::cout << "Found suffix in XML: " << s.toStdString() << std::endl; } diff --git a/sdk/libraries/cepgenerator/ParameterGenerator.cpp b/sdk/libraries/cepgenerator/ParameterGenerator.cpp index ddc58fd8..6840ab05 100644 --- a/sdk/libraries/cepgenerator/ParameterGenerator.cpp +++ b/sdk/libraries/cepgenerator/ParameterGenerator.cpp @@ -158,7 +158,7 @@ QString ParameterGenerator::getCppName() const { } // uppercase the first letter of each word and concatenate - foreach (QString s, cppNameList) { + for (QString s : cppNameList) { cppName += s.left(1).toUpper() + s.mid(1).toLower(); } diff --git a/sdk/libraries/cepgenerator/resources/Action.cpp.in b/sdk/libraries/cepgenerator/resources/Action.cpp.in index 7e8809c3..51d7eef4 100644 --- a/sdk/libraries/cepgenerator/resources/Action.cpp.in +++ b/sdk/libraries/cepgenerator/resources/Action.cpp.in @@ -74,7 +74,7 @@ Action::ApplyStatus @ACTIONCLASSNAME@::apply() { @ELSEIF_NOCOMP@ - foreach (Component *comp, getTargets()) { + for (Component *comp : getTargets()) { @IF_DEFCOMPONENT@ @COMPONENTNAME@ * input = dynamic_cast<@COMPONENTNAME@ *> ( comp ); process(input); diff --git a/sdk/libraries/core/Core.cpp b/sdk/libraries/core/Core.cpp index 5be7431f..fdcdea63 100644 --- a/sdk/libraries/core/Core.cpp +++ b/sdk/libraries/core/Core.cpp @@ -147,7 +147,7 @@ const QString Core::getConfig() { // regular component extensions const QList< ComponentExtension* >& allCE = ExtensionManager::getComponentExtensionsList(); - foreach (ComponentExtension* ce, allCE) { + for (ComponentExtension* ce : allCE) { installationDirectory = ExtensionManager::getInstallationString(ce->getLocation(), globalDir, userDir, currentWorkingDir); components << " - " + installationDirectory + " " + ce->getName().leftJustified(35, '.') + " " + ce->getFileExtensions().join(", "); // to get more information, use ce->getDescription(); @@ -169,7 +169,7 @@ const QString Core::getConfig() { // directory extensions const QList< ComponentExtension* >& allDCE = ExtensionManager::getDataDirectoryComponentsList(); - foreach (ComponentExtension* ce, allDCE) { + for (ComponentExtension* ce : allDCE) { installationDirectory = ExtensionManager::getInstallationString(ce->getLocation(), globalDir, userDir, currentWorkingDir); components << " - " + installationDirectory + " " + ce->getName().leftJustified(35, '.') + " directory"; @@ -198,7 +198,7 @@ const QString Core::getConfig() { QStringList actions; const QList< ActionExtension* >& allActions = ExtensionManager::getActionExtensionsList(); - foreach (ActionExtension* ae, allActions) { + for (ActionExtension* ae : allActions) { QStringList actionNames; for (Action* a : ae->getActions()) { actionNames << a->getName(); diff --git a/sdk/libraries/core/ExtensionManager.cpp b/sdk/libraries/core/ExtensionManager.cpp index f76067df..ea60d073 100644 --- a/sdk/libraries/core/ExtensionManager.cpp +++ b/sdk/libraries/core/ExtensionManager.cpp @@ -64,10 +64,10 @@ void ExtensionManager::autoload(ExtensionManager::ExtensionType type) { QStringList extensionFileNames; QStringList extensionAbsoluteFileNames; QMap extensionUniqueDir; - foreach (QString dirName, extensionDir) { + for (QString dirName : extensionDir) { QDir dir(dirName); QStringList pluginFileNames = getPluginFileNames(dir); - foreach (QString pluginFile, pluginFileNames) { + for (QString pluginFile : pluginFileNames) { QString pluginAbsoluteFileName = dir.absoluteFilePath(pluginFile); if (!extensionFileNames.contains(pluginFile)) { extensionFileNames.append(pluginFile); @@ -110,7 +110,7 @@ void ExtensionManager::autoload(ExtensionManager::ExtensionType type) { if (extensionAbsoluteFileNames.size() > 0) { // get the messages from Qt QStringList errorStrings; - foreach (QString fileName, extensionAbsoluteFileNames) { + for (QString fileName : extensionAbsoluteFileNames) { QPluginLoader pluginLoader(fileName); QObject* plugin = pluginLoader.instance(); @@ -153,7 +153,7 @@ void ExtensionManager::autoload(ExtensionManager::ExtensionType type) { } settings.endGroup(); - foreach (QString userRegisteredExtensionFile, userRegisteredExtensions) { + for (QString userRegisteredExtensionFile : userRegisteredExtensions) { loadExtension(type, userRegisteredExtensionFile); } @@ -205,7 +205,7 @@ bool ExtensionManager::loadExtension(ExtensionManager::ExtensionType type, QStri } else { // (cannot do that in the constructor because the virtual symbol table seems to be confused!) - foreach (QString ext, cp->getFileExtensions()) { + for (QString ext : cp->getFileExtensions()) { ComponentExtension* existingComponentExtension = getComponentExtensionMap().value(ext); if (existingComponentExtension != nullptr) { CAMITK_INFO_ALT(tr("Extension Manager: duplicate extension management: component extension \"%1\" (in file \"%2\") declares management of \"%3\" file extension while \"%4\" extension (loaded from file \"%5\") is already managing \"%6\".\nUsing extension in \"%7\" instead (higher priority) as only one component extension can manage a give file extension.") @@ -440,7 +440,7 @@ QStringList ExtensionManager::getPluginFileNames(QDir extensionsDir) { } else { // remove debug dll one by one - foreach (QString debugDLL, pluginFileNamesDebugMSVC) { + for (QString debugDLL : pluginFileNamesDebugMSVC) { pluginFileNames.removeAll(debugDLL); } return pluginFileNames; @@ -456,7 +456,7 @@ bool ExtensionManager::unloadActionExtension(QString fileName) { if (getActionExtensionMap().contains(fileName)) { ActionExtension* ext = getActionExtensionMap().value(fileName); //-- unregister all actions - foreach (Action* action, ext->getActions()) { + for (Action* action : ext->getActions()) { getActionExtensionMap().remove(action->getName()); } //-- unregister extension diff --git a/sdk/libraries/core/HistoryComponent.h b/sdk/libraries/core/HistoryComponent.h index 2a398f61..a54a3b21 100644 --- a/sdk/libraries/core/HistoryComponent.h +++ b/sdk/libraries/core/HistoryComponent.h @@ -29,11 +29,12 @@ // Qt stuffs #include -// CamiTK stuffs -#include +// CamiTK stuff +#include "CamiTKAPI.h" namespace camitk { +class Component; /** * @ingroup group_sdk_libraries_core diff --git a/sdk/libraries/core/HistoryItem.h b/sdk/libraries/core/HistoryItem.h index 2865efcf..aae740b9 100644 --- a/sdk/libraries/core/HistoryItem.h +++ b/sdk/libraries/core/HistoryItem.h @@ -32,7 +32,6 @@ #include // CamiTK stuffs -#include #include "HistoryComponent.h" namespace camitk { diff --git a/sdk/libraries/core/action/Action.cpp b/sdk/libraries/core/action/Action.cpp index a3a5bc4e..5abf559f 100644 --- a/sdk/libraries/core/action/Action.cpp +++ b/sdk/libraries/core/action/Action.cpp @@ -49,7 +49,7 @@ Action::Action(ActionExtension* extension) : QObject() { // -------------------- destructor -------------------- Action::~Action() { // delete all properties - foreach (Property* prop, parameterMap.values()) { + for (Property* prop : parameterMap.values()) { delete prop; } parameterMap.clear(); @@ -176,7 +176,7 @@ Action::ApplyStatus Action::trigger(QWidget* parent) { targetComponents.clear(); ComponentList selComp = Application::getSelectedComponents(); - foreach (Component* comp, selComp) { + for (Component* comp : selComp) { // check compatibility if (comp->isInstanceOf(this->getComponent())) { targetComponents.append(comp); @@ -266,7 +266,7 @@ Action::ApplyStatus Action::applyInPipeline() { void Action::setInputComponents(ComponentList inputs) { //-- build the list of valid targets targetComponents.clear(); - foreach (Component* comp, inputs) { + for (Component* comp : inputs) { // check compatibility if (comp->isInstanceOf(this->getComponent())) { targetComponents.append(comp); @@ -314,7 +314,7 @@ void Action::preProcess() { // We will select the one selected as input of the current action this->topLevelSelectedComponents.clear(); QList topLevelSelectedHistoryComponents; - foreach (Component* comp, this->aliveBeforeComponents) { + for (Component* comp : this->aliveBeforeComponents) { if (comp->isSelected()) { this->topLevelSelectedComponents.append(comp); topLevelSelectedHistoryComponents.append(HistoryComponent(comp)); @@ -340,7 +340,7 @@ void Action::postProcess() { ComponentList topLevelComponentCreated; QList topLevelHistoryComponentCreated; topLevelHistoryComponentCreated.clear(); - foreach (Component* comp, Application::getTopLevelComponents()) { + for (Component* comp : Application::getTopLevelComponents()) { if (!this->aliveBeforeComponents.contains(comp)) { topLevelComponentCreated.append(comp); topLevelHistoryComponentCreated.append(HistoryComponent(comp)); @@ -352,7 +352,7 @@ void Action::postProcess() { // Add the action's parameters to the history item // get back all the properties dynamically added to the action using Qt meta object - foreach (QByteArray propertyName, dynamicPropertyNames()) { + for (QByteArray propertyName : dynamicPropertyNames()) { item->addProperty(propertyName, property(propertyName)); } @@ -365,7 +365,7 @@ void Action::postProcess() { void Action::postProcessInPipeline() { outputComponents.clear(); ComponentList allComp = Application::getAllComponents(); - foreach (Component* comp, allComp) { + for (Component* comp : allComp) { if (!aliveBeforeComponents.contains(comp) || comp->getModified()) { outputComponents.append(comp); } diff --git a/sdk/libraries/core/action/Action.h b/sdk/libraries/core/action/Action.h index e1953cb3..476246c3 100644 --- a/sdk/libraries/core/action/Action.h +++ b/sdk/libraries/core/action/Action.h @@ -235,7 +235,7 @@ public: ///@return the QString equivalement of the given status static QString getStatusAsString(ApplyStatus); -public slots: +public Q_SLOTS: /** * This method triggers the action. * The parent widget is used if the action is embedded, see class description for more information about the algorithm. diff --git a/sdk/libraries/core/action/ActionWidget.cpp b/sdk/libraries/core/action/ActionWidget.cpp index 357afd7c..5db4fde9 100644 --- a/sdk/libraries/core/action/ActionWidget.cpp +++ b/sdk/libraries/core/action/ActionWidget.cpp @@ -160,7 +160,7 @@ void ActionWidget::update() { QString ActionWidget::getTargetLabel() { QString targetNames = "
      "; - foreach (Component* comp, myAction->getTargets()) { + for (Component* comp : myAction->getTargets()) { targetNames += "
    • " + comp->getName() + " (" + comp->metaObject()->className() + ") " + "
    • "; } diff --git a/sdk/libraries/core/application/Application.cpp b/sdk/libraries/core/application/Application.cpp index d5fe1c9e..4e725c91 100644 --- a/sdk/libraries/core/application/Application.cpp +++ b/sdk/libraries/core/application/Application.cpp @@ -104,7 +104,7 @@ Application::Application(QString name, int& theArgc, char** theArgv, bool autolo QStringList recentDoc = settings.value("recentDocuments").toStringList(); recentDocuments.clear(); - foreach (QString fileName, recentDoc) { + for (QString fileName : recentDoc) { recentDocuments.append(fileName); } @@ -130,7 +130,7 @@ Application::Application(QString name, int& theArgc, char** theArgv, bool autolo fileExtensionForbidden.append("tif"); fileExtensionForbidden.append("tiff"); - foreach (QString extensionFile, ExtensionManager::getFileExtensions()) { + for (QString extensionFile : ExtensionManager::getFileExtensions()) { // check the application can handle new file type if (!fileExtensionsAlreadyRegistered.contains(extensionFile) && !fileExtensionForbidden.contains(extensionFile)) { newFileExtensions.append(extensionFile); @@ -153,7 +153,7 @@ Application::Application(QString name, int& theArgc, char** theArgv, bool autolo if (msgBox.exec() == QMessageBox::Yes) { // user agrees : register each new file type - foreach (QString fileExtensionToRegister, newFileExtensions) { + for (QString fileExtensionToRegister : newFileExtensions) { ExtensionManager::registerFileExtension(fileExtensionToRegister); } } @@ -711,7 +711,7 @@ const ActionList Application::getActions() { int Application::registerAllActions(ActionExtension* ext) { int registered = 0; - foreach (Action* action, ext->getActions()) { + for (Action* action : ext->getActions()) { // check if an action with same name was not already registered if (getActionMap().contains(action->getName())) { CAMITK_ERROR_ALT(tr("Cannot register action: %1 (extension: %2, family: %3, description: \"%4\")\n" @@ -735,7 +735,7 @@ int Application::registerAllActions(ActionExtension* ext) { int Application::unregisterAllActions(ActionExtension* ext) { int registered = 0; - foreach (Action* action, ext->getActions()) { + for (Action* action : ext->getActions()) { getActionMap().remove(action->getName()); registered++; } @@ -770,14 +770,14 @@ ActionList Application::getActions(Component* component) { if (component) { QStringList componentHierarchy = component->getHierarchy(); - foreach (Action* currentAct, Application::getActions()) { + for (Action* currentAct : Application::getActions()) { if (componentHierarchy.contains(currentAct->getComponent())) { actions.insert(currentAct); } } } else { - foreach (Action* currentAct, Application::getActions()) { + for (Action* currentAct : Application::getActions()) { if (currentAct->getComponent().isEmpty()) { actions.insert(currentAct); } @@ -796,7 +796,7 @@ ActionList Application::getActions(ComponentList cList) { else { ActionSet actions; - foreach (Component* currentComp, cList) { + for (Component* currentComp : cList) { actions += getActions(currentComp).toSet(); } @@ -812,7 +812,7 @@ ActionList Application::getActions(ComponentList selComp, QString tag) { // now check possibleActions considering the tag value ActionList actions; - foreach (Action* action, possibleActions) { + for (Action* action : possibleActions) { if (action->getTag().contains(tag)) { actions.append(action); } @@ -910,7 +910,7 @@ void Application::setSelected(Component* component, bool isSelected) { // -------------------- clearSelectedComponents -------------------- void Application::clearSelectedComponents() { - foreach (Component* comp, getSelectedComponentList()) { + for (Component* comp : getSelectedComponentList()) { comp->setSelected(false); } @@ -1016,7 +1016,7 @@ void Application::saveHistoryAsSXML() { actionElement.appendChild(parametersElement); if (!action->dynamicPropertyNames().isEmpty()) { - foreach (QByteArray actionParameter, action->dynamicPropertyNames()) { + for (QByteArray actionParameter : action->dynamicPropertyNames()) { QDomElement parameterElement = doc.createElement("camitk:parameter"); parameterElement.setAttribute("name", QString(actionParameter)); parameterElement.setAttribute("type", QVariant::typeToName(action->property(actionParameter).type())); @@ -1125,7 +1125,7 @@ void Application::saveHistoryAsSXML() { QDomElement closeElement = doc.createElement("camitk:close"); onTransitionElement.appendChild(closeElement); - foreach (HistoryComponent outputHistoryComponent, previousItem.getOutputHistoryComponents()) { + for (HistoryComponent outputHistoryComponent : previousItem.getOutputHistoryComponents()) { QDomElement backTransitionComponentElement = doc.createElement("camitk:component"); closeElement.appendChild(backTransitionComponentElement); @@ -1187,7 +1187,7 @@ void Application::saveHistoryAsSXML() { QDomElement finalEltTransition_close = doc.createElement("camitk:close"); finalEltTransition_onTransition.appendChild(finalEltTransition_close); - foreach (HistoryComponent createdComponent, allCreatedComponents) { + for (HistoryComponent createdComponent : allCreatedComponents) { QDomElement finalEltTransition_comp = doc.createElement("camitk:component"); finalEltTransition_close.appendChild(finalEltTransition_comp); diff --git a/sdk/libraries/core/application/Application.h b/sdk/libraries/core/application/Application.h index f051c480..71e71e89 100644 --- a/sdk/libraries/core/application/Application.h +++ b/sdk/libraries/core/application/Application.h @@ -355,7 +355,7 @@ public: static PropertyObject* getPropertyObject(); ///}@ -private slots: +private Q_SLOTS: void quitting(); private: diff --git a/sdk/libraries/core/application/MainWindow.cpp b/sdk/libraries/core/application/MainWindow.cpp index 82c6c52d..c87f525d 100644 --- a/sdk/libraries/core/application/MainWindow.cpp +++ b/sdk/libraries/core/application/MainWindow.cpp @@ -208,7 +208,7 @@ bool MainWindow::removeViewer(Viewer* viewer) { } // tell all component not to be visible anymore in this viewer - foreach (Component* comp, Application::getAllComponents()) { + for (Component* comp : Application::getAllComponents()) { comp->setVisibility(viewer, false); } @@ -229,7 +229,7 @@ void MainWindow::showViewer(Viewer* theViewer, bool visible) { // -------------------- refreshViewers -------------------- void MainWindow::refreshViewers() { - foreach (Viewer* v, viewers) { + for (Viewer* v : viewers) { v->refresh(); } } @@ -280,7 +280,7 @@ const Viewer& MainWindow::getCentralViewer() const { // ------------- refresh ----------------- void MainWindow::refresh() { Viewer* whoIsAsking = qobject_cast (sender()); - foreach (Viewer* v, viewers) { + for (Viewer* v : viewers) { if (v != whoIsAsking) { v->refresh(); } diff --git a/sdk/libraries/core/application/SettingsDialog.cpp b/sdk/libraries/core/application/SettingsDialog.cpp index 52069ab3..3007e920 100644 --- a/sdk/libraries/core/application/SettingsDialog.cpp +++ b/sdk/libraries/core/application/SettingsDialog.cpp @@ -181,7 +181,7 @@ void SettingsDialog::updateActionExtensionList() { // loop over all ActionExtensions unsigned int actionId = 0; - foreach (ActionExtension* ae, aeList) { + for (ActionExtension* ae : aeList) { // create table row for (int i = 0; i < ae->getActions().size(); i++) { Action* action = ae->getActions().at(i); @@ -340,7 +340,7 @@ void SettingsDialog::on_removeActionExtensionButton_released() { if (actions.size() > 1) { QString actionName = myUI->actionExtensionList->item(myUI->actionExtensionList->currentRow(), 0)->text(); QStringList actionNames; - foreach (Action* a, actions) { + for (Action* a : actions) { if (a->getName() != actionName) { actionNames << a->getName(); } diff --git a/sdk/libraries/core/component/Component.cpp b/sdk/libraries/core/component/Component.cpp index 44faba92..86d1e3a8 100644 --- a/sdk/libraries/core/component/Component.cpp +++ b/sdk/libraries/core/component/Component.cpp @@ -99,7 +99,7 @@ Component::~Component() { } // delete all properties - foreach (Property* prop, propertyMap.values()) { + for (Property* prop : propertyMap.values()) { delete prop; } propertyMap.clear(); @@ -348,7 +348,7 @@ QMenu* Component::getActionMenu() { //-- add all actions sorted by family ActionList allActions = Application::getActions(this); QMap familyMap; - foreach (Action* action, allActions) { + for (Action* action : allActions) { ActionSet* familySet = familyMap.value(action->getFamily().toLower()); if (!familySet) { familySet = new ActionSet; @@ -358,13 +358,13 @@ QMenu* Component::getActionMenu() { } //-- create one sub menu per family (unless there is only one action) - foreach (ActionSet* familySet, familyMap.values()) { + for (ActionSet* familySet : familyMap.values()) { // sort actions by name ActionList familyList = familySet->toList(); qSort(familyList.begin(), familyList.end(), actionLessThan); if (familyList.size() >= 1) { QMenu* familyMenu = actionsMenu->addMenu(familyList.first()->getFamily()); - foreach (Action* action, familyList) { + for (Action* action : familyList) { familyMenu->addAction(action->getQAction()); } } @@ -401,7 +401,7 @@ const InterfaceGeometry::RenderingModes Component::getRenderingModes() const { // else return the added rendering mode of all children if (childrenComponent.size() > 0) { InterfaceGeometry::RenderingModes m = InterfaceGeometry::None; - foreach (Component* childComponent, childrenComponent) { + for (Component* childComponent : childrenComponent) { m |= childComponent->getRenderingModes(); } return m; @@ -442,7 +442,7 @@ void Component::getBounds(double* bounds) { bounds[0] = bounds[2] = bounds[4] = 0.0; bounds[1] = bounds[3] = bounds[5] = 1.0; // compute bounds using the children's - foreach (Component* childComponent, childrenComponent) { + for (Component* childComponent : childrenComponent) { double childBounds[6]; //xmin,xmax, ymin,ymax, zmin,zmax // get child bounds childComponent->getBounds(childBounds); @@ -470,7 +470,7 @@ double Component::getBoundingRadius() { else { // compute bounding radius using the children's double radius = 0.0; - foreach (Component* childComponent, childrenComponent) { + for (Component* childComponent : childrenComponent) { double childRadius = childComponent->getBoundingRadius(); if (childRadius > radius) { radius = childRadius; @@ -536,7 +536,7 @@ void Component::setSelected(const bool b, const bool recursive) { isSelectedFlag = b; // maintain the children selection state as well if (recursive) { - foreach (Component* child, childrenComponent) { + for (Component* child : childrenComponent) { child->setSelected(b, recursive); } } @@ -568,7 +568,7 @@ void Component::removeChild(InterfaceNode* childNode) { void Component::deleteChildren() { // calling clear() on a QSet does not delete the instances // (the destuctor of points is not called, the Component are not deleted from the memory) - foreach (Component* childComp, childrenComponent) { + for (Component* childComp : childrenComponent) { if (Application::isAlive(childComp)) { delete childComp; } diff --git a/sdk/libraries/core/component/Component.h b/sdk/libraries/core/component/Component.h index 27467213..24cb05fa 100644 --- a/sdk/libraries/core/component/Component.h +++ b/sdk/libraries/core/component/Component.h @@ -118,27 +118,27 @@ if (HANDLER) \ * Call a given METHOD eventually with PARAM for all childrenComponent */ #define invokeChildren0(METHOD) \ -foreach (Component *child, childrenComponent) { \ +for(Component *child : childrenComponent) { \ child->METHOD(); \ } #define invokeChildren1(METHOD,PARAM) \ -foreach (Component *child, childrenComponent) { \ - child->METHOD(PARAM); \ - } +for(Component *child : childrenComponent) { \ + child->METHOD(PARAM); \ +} #define invokeChildren2(METHOD,PARAM1,PARAM2) \ -foreach (Component *child, childrenComponent) { \ +for(Component *child : childrenComponent) { \ child->METHOD(PARAM1,PARAM2); \ } #define invokeChildren3(METHOD,PARAM1,PARAM2,PARAM3) \ -foreach (Component *child, childrenComponent) { \ +for(Component *child : childrenComponent) { \ child->METHOD(PARAM1,PARAM2,PARAM3); \ } #define invokeChildren4(METHOD,PARAM1,PARAM2,PARAM3,PARAM4) \ -foreach (Component *child, childrenComponent) { \ +for(Component *child : childrenComponent) { \ child->METHOD(PARAM1,PARAM2,PARAM3,PARAM4); \ } @@ -558,9 +558,10 @@ public: if (myGeometry) { return myGeometry->getProp(param); } - else if (mySlice) { - return mySlice->getProp(param); - } + else + if (mySlice) { + return mySlice->getProp(param); + } return nullptr; } @@ -568,9 +569,10 @@ public: if (myGeometry) { return myGeometry->getNumberOfProp(); } - else if (mySlice) { - return mySlice->getNumberOfProp(); - } + else + if (mySlice) { + return mySlice->getNumberOfProp(); + } return 0; } @@ -578,9 +580,10 @@ public: if (myGeometry) { return myGeometry->getProp(index); } - else if (mySlice) { - return mySlice->getProp(index); - } + else + if (mySlice) { + return mySlice->getProp(index); + } return nullptr; } @@ -588,9 +591,10 @@ public: if (myGeometry) { return myGeometry->addProp(name, prop); } - else if (mySlice) { - return mySlice->addProp(name, prop); - } + else + if (mySlice) { + return mySlice->addProp(name, prop); + } return false; } @@ -599,9 +603,10 @@ public: if (myGeometry) { return myGeometry->removeProp(name); } - else if (mySlice) { - return mySlice->removeProp(name); - } + else + if (mySlice) { + return mySlice->removeProp(name); + } return false; } // END TODO diff --git a/sdk/libraries/core/component/Frame.cpp b/sdk/libraries/core/component/Frame.cpp index 58b993a6..8f0f15a4 100644 --- a/sdk/libraries/core/component/Frame.cpp +++ b/sdk/libraries/core/component/Frame.cpp @@ -84,7 +84,7 @@ Frame::~Frame() { } // Declare my children as orpheans - foreach (InterfaceFrame* f, childrenFrame) { + for (InterfaceFrame* f : childrenFrame) { f->setParentFrame(nullptr); } @@ -128,7 +128,7 @@ void Frame::setParentFrame(InterfaceFrame* parent, bool keepTransform) { // compute all the descendants of the current frame QVector descendants = computeDescendants(this); // check if one of the descendant if the checked parent - foreach (InterfaceFrame* descendant, descendants) { + for (InterfaceFrame* descendant : descendants) { if (descendant->getFrameName() == checkedParent->getFrameName()) { //remove the new parent in the list of children removeFrameChild(checkedParent); @@ -421,7 +421,7 @@ QVector Frame::computeDescendants(InterfaceFrame* frame) { QVector descendants; // recursively call to get all the descendants of 'frame' - foreach (InterfaceFrame* child, frame->getChildrenFrame()) { + for (InterfaceFrame* child : frame->getChildrenFrame()) { descendants.append(child); descendants += computeDescendants(child); } diff --git a/sdk/libraries/core/component/image/ImageComponent.cpp b/sdk/libraries/core/component/image/ImageComponent.cpp index 30486fb2..278b9117 100644 --- a/sdk/libraries/core/component/image/ImageComponent.cpp +++ b/sdk/libraries/core/component/image/ImageComponent.cpp @@ -652,7 +652,7 @@ void ImageComponent::pixelPicked(double x, double y, double z, SingleImageCompon getLastPointPickedWorldCoords(&wx, &wy, &wz); // Update each child even the one who is asking i order to display correctly the pixel pixed. - foreach (Component* dc, getChildren()) { + for (Component* dc : getChildren()) { SingleImageComponent* child = dynamic_cast(dc); if (child) { @@ -729,7 +729,7 @@ vtkSmartPointer ImageComponent::getLut() { // -------------------- setSelected -------------------- void ImageComponent::setSelected(const bool b, const bool) { - foreach (Component* dc, getChildren()) { + for (Component* dc : getChildren()) { SingleImageComponent* child = dynamic_cast(dc); if (child) { @@ -772,7 +772,7 @@ void ImageComponent::getLastPointPickedWorldCoords(double* x, double* y, double* // -------------------- refresh -------------------- void ImageComponent::refresh() const { - foreach (const Component* dc, childrenComponent) { + for (const Component* dc : childrenComponent) { dc->refresh(); } } diff --git a/sdk/libraries/core/component/image/ImageComponent.h b/sdk/libraries/core/component/image/ImageComponent.h index 549f2b7e..80843153 100644 --- a/sdk/libraries/core/component/image/ImageComponent.h +++ b/sdk/libraries/core/component/image/ImageComponent.h @@ -27,8 +27,8 @@ #define IMAGE_COMPONENT_H // -- Core image component stuff -#include "SingleImageComponent.h" #include "CamiTKAPI.h" +#include "SingleImageComponent.h" #include "ImageOrientationHelper.h" // -- vtk stuff diff --git a/sdk/libraries/core/component/imageacquisition/ImageAcquisitionComponentExtension.cpp b/sdk/libraries/core/component/imageacquisition/ImageAcquisitionComponentExtension.cpp index fa8af613..3d959eca 100644 --- a/sdk/libraries/core/component/imageacquisition/ImageAcquisitionComponentExtension.cpp +++ b/sdk/libraries/core/component/imageacquisition/ImageAcquisitionComponentExtension.cpp @@ -41,7 +41,7 @@ QStringList ImageAcquisitionComponentExtension::getImagerList() { //-- get componentextension list QList compExt = ExtensionManager::getComponentExtensionsList(); QStringList listImageAcqui; - foreach (ComponentExtension* ce, compExt) { + for (ComponentExtension* ce : compExt) { if (dynamic_cast(ce)) { // a new ImageAcquisitionComponentExtension:: we add to the list auto* im = dynamic_cast(ce); diff --git a/sdk/libraries/core/component/mesh/MeshComponent.cpp b/sdk/libraries/core/component/mesh/MeshComponent.cpp index ac850e53..7b8207bf 100644 --- a/sdk/libraries/core/component/mesh/MeshComponent.cpp +++ b/sdk/libraries/core/component/mesh/MeshComponent.cpp @@ -524,19 +524,16 @@ void MeshComponent::changeSelectedSelection(const QItemSelection& selected, cons // remove all the selection nodes from the selection currentSelection->RemoveAllNodes(); - // do not use selected since it contains only the new selected selections - // QModelIndexList items = selected.indexes(); - QModelIndex index; - QModelIndexList items = selectionView->selectionModel()->selectedRows(); - // Select the PropertyExplorer 'Selection' tab for the currently selected component if (!Application::getSelectedComponents().isEmpty()) { Component* currentComponent = Application::getSelectedComponents().last(); currentComponent->setIndexOfPropertyExplorerTab(1); } + // do not use selected since it contains only the new selected selections + // QModelIndexList items = selected.indexes(); // add each selected selection nodes to the current selection - foreach (index, items) { + for (QModelIndex index : selectionView->selectionModel()->selectedRows()) { currentSelection->Union(selectionList.at(index.row())); } diff --git a/sdk/libraries/core/utils/ObjectController.cpp b/sdk/libraries/core/utils/ObjectController.cpp index 9fd889e5..ac661d3d 100644 --- a/sdk/libraries/core/utils/ObjectController.cpp +++ b/sdk/libraries/core/utils/ObjectController.cpp @@ -409,7 +409,7 @@ void ObjectControllerPrivate::addDynamicProperties(QObject* edited) { } // loop on all property attributes and transfer the values to subProperty - foreach (QString attributeName, camitkProp->getAttributeList()) { + for (QString attributeName : camitkProp->getAttributeList()) { subProperty->setAttribute(attributeName, camitkProp->getAttribute(attributeName)); // if this is an enum, setting the enumNames will reset the value to 0 // in case there is not a direct match between names and enum diff --git a/sdk/libraries/core/utils/Property.h b/sdk/libraries/core/utils/Property.h index a2a27c83..82077cf4 100644 --- a/sdk/libraries/core/utils/Property.h +++ b/sdk/libraries/core/utils/Property.h @@ -347,7 +347,7 @@ public: * CAMITK_INFO(tr("myProp does not have an attribute 'bad' (or this attribute is still equals to the default value)")) * } * - * It is recommended to only use this method inside a foreach(QString s: getAttributeList()) + * It is recommended to only use this method inside a "for (QString s : getAttributeList())" loop */ QVariant getAttribute(QString attName); diff --git a/sdk/libraries/core/utils/PropertyObject.cpp b/sdk/libraries/core/utils/PropertyObject.cpp index ace58d75..b52364ff 100644 --- a/sdk/libraries/core/utils/PropertyObject.cpp +++ b/sdk/libraries/core/utils/PropertyObject.cpp @@ -43,7 +43,7 @@ PropertyObject::PropertyObject(QString name) : QObject() { // -------------------- Destructor -------------------- PropertyObject::~PropertyObject() { // delete all properties - foreach (Property* prop, propertiesMap.values()) { + for (Property* prop : propertiesMap.values()) { delete prop; } propertiesMap.clear(); diff --git a/sdk/libraries/core/viewer/ActionViewer.cpp b/sdk/libraries/core/viewer/ActionViewer.cpp index 35df1bb4..cadd6135 100644 --- a/sdk/libraries/core/viewer/ActionViewer.cpp +++ b/sdk/libraries/core/viewer/ActionViewer.cpp @@ -204,7 +204,7 @@ void ActionViewer::updateActionViewer(UpdateReason reason) { possibleActions = Application::getActions(nullptr); } - foreach (Action* action, possibleActions) { + for (Action* action : possibleActions) { if (action->getFamily() == familyComboBox->currentText() || familyComboBox->currentText() == QString("-- Select Family --")) { nameComboBox->addItem(action->getName()); } @@ -235,7 +235,7 @@ void ActionViewer::updateActionViewer(UpdateReason reason) { else { nameComboBox->clear(); nameComboBox->addItem("-- Select Action --"); - foreach (Action* action, actionset) { + for (Action* action : actionset) { nameComboBox->addItem(action->getName()); } } @@ -266,14 +266,14 @@ void ActionViewer::updateActionViewer(UpdateReason reason) { else { // no selection => select only empty component actions possibleActions = Application::getActions(nullptr); } // Complete family and action lists depending of the last selected component - foreach (Action* action, possibleActions) { + for (Action* action : possibleActions) { if (familyComboBox->findText(action->getFamily()) == -1) { familyComboBox->addItem(action->getFamily()); } if (nameComboBox->findText(action->getName()) == -1) { nameComboBox->addItem(action->getName()); } - foreach (QString tag, action->getTag()) { + for (QString tag : action->getTag()) { if (!wordList.contains(tag)) { wordList.append(tag); } diff --git a/sdk/libraries/core/viewer/Explorer.cpp b/sdk/libraries/core/viewer/Explorer.cpp index 96189b09..db5e7e66 100644 --- a/sdk/libraries/core/viewer/Explorer.cpp +++ b/sdk/libraries/core/viewer/Explorer.cpp @@ -138,13 +138,13 @@ void Explorer::refresh(Viewer* whoIsAsking) { ComponentList viewedcomp = topLevelCompItemMap.uniqueKeys(); if (viewedcomp.size() != topLevelCpt.size()) { // remove the closed/deleted top-level component - foreach (Component* comp, viewedcomp) { + for (Component* comp : viewedcomp) { if (!topLevelCpt.contains(comp)) { removeTopLevel(comp); } } // add the new top-level component - foreach (Component* comp, topLevelCpt) { + for (Component* comp : topLevelCpt) { if (!viewedcomp.contains(comp)) { addTopLevel(comp); } @@ -155,7 +155,7 @@ void Explorer::refresh(Viewer* whoIsAsking) { explorerTree->blockSignals(true); explorerTree->clearSelection(); if (!Application::getSelectedComponents().isEmpty()) { - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { if (comp->isSelected()) { QTreeWidgetItem* selected = getItem(comp); if (selected) { @@ -259,7 +259,7 @@ QTreeWidgetItem* Explorer::add(QTreeWidgetItem* parent, Component* abstractNode) abstractNode->setVisibility(this, true); //-- add children recursively - foreach (Component* comp, abstractNode->getChildren()) { + for (Component* comp : abstractNode->getChildren()) { add(tw, comp); } diff --git a/sdk/libraries/core/viewer/FrameExplorer.cpp b/sdk/libraries/core/viewer/FrameExplorer.cpp index 7548555d..eb407443 100644 --- a/sdk/libraries/core/viewer/FrameExplorer.cpp +++ b/sdk/libraries/core/viewer/FrameExplorer.cpp @@ -94,7 +94,7 @@ void FrameExplorer::refresh(Viewer* whoIsAsking) { remove(); // rebuild the explorer tree - foreach (Component* comp, cptList) { + for (Component* comp : cptList) { add(comp); } @@ -113,9 +113,9 @@ QTreeWidgetItem* FrameExplorer::getNewItem(QTreeWidgetItem* parent, Component* a tw->setText(1, abstractNode->getName()); //-- add children recursively - foreach (InterfaceFrame* intFrame, (abstractNode->getFrame()->getChildrenFrame())) { + for (InterfaceFrame* intFrame : (abstractNode->getFrame()->getChildrenFrame())) { ComponentList cptlst = Application::getAllComponents(); - foreach (Component* cp, cptlst) { + for (Component* cp : cptlst) { if (cp->getFrame()->getFrameName() == intFrame->getFrameName()) { getNewItem(tw, cp); } @@ -142,9 +142,9 @@ QTreeWidgetItem* FrameExplorer::add(QTreeWidgetItem* parent, Component* abstract abstractNode->setVisibility(this, true); //-- add children - foreach (InterfaceFrame* intFrame, abstractNode->getFrame()->getChildrenFrame()) { + for (InterfaceFrame* intFrame : abstractNode->getFrame()->getChildrenFrame()) { ComponentList cptlst = Application::getAllComponents(); - foreach (Component* cp, cptlst) { + for (Component* cp : cptlst) { if (cp->getFrame()->getFrameName() == intFrame->getFrameName()) { getNewItem(tw, cp); } diff --git a/sdk/libraries/core/viewer/InteractiveViewer.cpp b/sdk/libraries/core/viewer/InteractiveViewer.cpp index 791f1a92..0619d64a 100644 --- a/sdk/libraries/core/viewer/InteractiveViewer.cpp +++ b/sdk/libraries/core/viewer/InteractiveViewer.cpp @@ -512,7 +512,7 @@ void InteractiveViewer::refresh(Viewer* v) { if (v != this) { //-- check all present QList compRendered = actorMap.keys(); - foreach (Component* comp, compRendered) { + for (Component* comp : compRendered) { if (!Application::isAlive(comp)) { // remove from the renderer and map removeAllActors(comp); @@ -526,7 +526,7 @@ void InteractiveViewer::refresh(Viewer* v) { switch (myType) { case GEOMETRY_VIEWER: // check all Components - foreach (Component* comp, allComponents) { + for (Component* comp : allComponents) { // remove from the renderer and map removeAllActors(comp); @@ -572,7 +572,7 @@ void InteractiveViewer::refresh(Viewer* v) { case SLICE_VIEWER: // remove all from the renderer and map QList compRendered = actorMap.keys(); - foreach (Component* comp, compRendered) { + for (Component* comp : compRendered) { removeAllActors(comp); } @@ -671,7 +671,7 @@ void InteractiveViewer::refreshRenderer() { // ---------------------- removeAllActors ---------------------------- void InteractiveViewer::removeAllActors(Component* comp) { QList > actorRendered = actorMap.values(comp); - foreach (vtkSmartPointer a, actorRendered) { + for (vtkSmartPointer a : actorRendered) { rendererWidget->removeProp(a); } // remove from the list @@ -1132,7 +1132,7 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) { // addWhatsThisItem("Alt+P", "Toggle point rendering"); if (e->modifiers() == Qt::AltModifier) { - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { // check if the Component is to be displayed here if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->setRenderingModes(comp->getRenderingModes() ^ InterfaceGeometry::Points); //XOR @@ -1154,7 +1154,7 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) { // addWhatsThisItem("Alt+S", "Toggle surface rendering"); if (e->modifiers() == Qt::AltModifier) { - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { // check if the Component is to be displayed here if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->setRenderingModes(comp->getRenderingModes() ^ InterfaceGeometry::Surface); //XOR @@ -1183,7 +1183,7 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) { // addWhatsThisItem("Alt+W", "Toggle wireframe rendering"); if (e->modifiers() == Qt::AltModifier) { - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { // check if the Component is to be displayed here if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->setRenderingModes(comp->getRenderingModes() ^ InterfaceGeometry::Wireframe); //XOR @@ -1366,14 +1366,14 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) { debugStream << endl; debugStream << "== Component vtkProp ==" << endl; - foreach (Component* c, actorMap.keys().toSet()) { + for (Component* c : actorMap.keys().toSet()) { debugStream << "- Component: \"" << c->getName() << "\" of type \"" << c->metaObject()->className() << "\" has " << actorMap.values(c).size() << " vtkProp:" << endl; std::list > allActors = actorMap.values(c).toStdList(); allActors.sort(); allActors.unique(); - foreach (vtkSmartPointer p, allActors) { + for (vtkSmartPointer p : allActors) { // get more information by comparing with the getActor/getProp method of c bool found = false; switch (myType) { @@ -1609,7 +1609,7 @@ void InteractiveViewer::getBoundsOfSelected(double* bounds) { } // check the bound of all selected Component in the InteractiveViewer - foreach (Component* comp, actorMap.keys()) { + for (Component* comp : actorMap.keys()) { if (comp->isSelected()) { //if we are in this loop that is 1 element at least is selected then oneElementSelected = true; @@ -1649,7 +1649,7 @@ void InteractiveViewer::setSideFrameVisible(bool visibility) { //------------------------- toggleInterpolation ---------------------------- void InteractiveViewer::toggleInterpolation() { - foreach (Component* comp, actorMap.keys()) { + for (Component* comp : actorMap.keys()) { if (comp->getRepresentation() == Component::SLICE) { bool state = comp->get2DImageActor()->GetInterpolate(); comp->get2DImageActor()->SetInterpolate(!state); @@ -1929,7 +1929,7 @@ void InteractiveViewer::renderingActorsChanged() { } // update the rendering mode of selected - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { comp->setRenderingModes(m); } @@ -2043,7 +2043,7 @@ void InteractiveViewer::toggleCopyright(bool c) { // ------------- setLabel ----------------- void InteractiveViewer::setLabel(bool b) { // update the rendering mode of selected - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->getProp("label")->SetVisibility(b); } @@ -2055,7 +2055,7 @@ void InteractiveViewer::setLabel(bool b) { // ------------- setGlyph ----------------- void InteractiveViewer::setGlyph(bool b) { // update the rendering mode of selected - foreach (Component* comp, Application::getSelectedComponents()) { + for (Component* comp : Application::getSelectedComponents()) { if (comp->getVisibility(this) && comp->getRepresentation() == Component::GEOMETRY) { comp->getProp("glyph")->SetVisibility(b); } diff --git a/sdk/libraries/core/viewer/InteractiveViewer.h b/sdk/libraries/core/viewer/InteractiveViewer.h index c9a041da..09f0ad01 100644 --- a/sdk/libraries/core/viewer/InteractiveViewer.h +++ b/sdk/libraries/core/viewer/InteractiveViewer.h @@ -248,7 +248,7 @@ public: /// call this method to take a screenshot using the given filename (the extension must be a supported format extension, see class RendererWindow) void screenshot(QString); -public slots: +public Q_SLOTS: /// call this method to take a screenshot in various format and write the resulting image to a file void screenshot(); /// @} @@ -263,7 +263,7 @@ public: /** @name Viewing/Interaction Property */ ///@{ -public slots: +public Q_SLOTS: /// set the backface culling mode (default is true). void setBackfaceCulling(bool); @@ -274,7 +274,7 @@ public: /// get the backface current culling mode. // bool getBackfaceCulling() const; -public slots: +public Q_SLOTS: /** Update the visualization of lines (for all the InterfaceGeometry of the scene). * * \note it is only possible to transform lines to tubes if @@ -333,7 +333,7 @@ public: void setSideFrameVisible(bool); ///@} -public slots: +public Q_SLOTS: /** Slot called when the InteractiveViewer slider has been changed. If there is a InterfaceBitMap in the scene, * set the slice index with the new slider value. */ @@ -616,7 +616,7 @@ protected: ///@} -protected slots: +protected Q_SLOTS: /** * @name All the slots called by the menu actions */ diff --git a/sdk/libraries/core/viewer/MedicalImageViewer.cpp b/sdk/libraries/core/viewer/MedicalImageViewer.cpp index 2b776870..d6797a1a 100644 --- a/sdk/libraries/core/viewer/MedicalImageViewer.cpp +++ b/sdk/libraries/core/viewer/MedicalImageViewer.cpp @@ -85,7 +85,7 @@ unsigned int MedicalImageViewer::numberOfViewedComponent() { // -------------------- refresh -------------------- void MedicalImageViewer::refresh(Viewer* whoIsAsking) { // just tell everyone to update! - foreach (Viewer* v, viewers.values()) { + for (Viewer* v : viewers.values()) { v->refresh(this); } @@ -155,7 +155,7 @@ QWidget* MedicalImageViewer::getWidget(QWidget* parent) { //-- connect - foreach (LayoutVisibility v, viewerVisibility) { + for (LayoutVisibility v : viewerVisibility) { if (viewers.value(v)) { // prevent ALL connect(viewers.value(v), SIGNAL(selectionChanged()), this, SLOT(synchronizeSelection())); } @@ -257,7 +257,7 @@ void MedicalImageViewer::updateLayout() { void MedicalImageViewer::synchronizeSelection() { auto* whoIsAsking = qobject_cast(sender()); - foreach (Viewer* v, viewers.values()) { + for (Viewer* v : viewers.values()) { if (v != whoIsAsking) { v->refresh(whoIsAsking); } diff --git a/sdk/libraries/core/viewer/RendererWidget.cpp b/sdk/libraries/core/viewer/RendererWidget.cpp index b853e8c6..eb9fcb99 100644 --- a/sdk/libraries/core/viewer/RendererWidget.cpp +++ b/sdk/libraries/core/viewer/RendererWidget.cpp @@ -708,7 +708,7 @@ RendererWidget::RendererWidget(QWidget* parent, ControlMode mode) : QVTKWidget(p //---------------------- Destructor ------------------------ RendererWidget::~RendererWidget() { // delete all properties - foreach (ScreenshotFormatInfo* sfi, screenshotMap.values()) { + for (ScreenshotFormatInfo* sfi : screenshotMap.values()) { delete sfi; } screenshotMap.clear(); diff --git a/sdk/libraries/core/viewer/RendererWidget.h b/sdk/libraries/core/viewer/RendererWidget.h index aca75bf8..0de17f7b 100644 --- a/sdk/libraries/core/viewer/RendererWidget.h +++ b/sdk/libraries/core/viewer/RendererWidget.h @@ -417,7 +417,7 @@ public : -protected slots: +protected Q_SLOTS: ///@name picking and interaction ///@{ /// manage left mouse click interactions @@ -437,7 +437,7 @@ protected slots: ///@} -signals : +Q_SIGNALS : ///@name picking and interaction ///@{ diff --git a/sdk/libraries/core/viewer/Viewer.cpp b/sdk/libraries/core/viewer/Viewer.cpp index ef44e0f0..bd8d3143 100644 --- a/sdk/libraries/core/viewer/Viewer.cpp +++ b/sdk/libraries/core/viewer/Viewer.cpp @@ -36,7 +36,7 @@ Viewer::Viewer(QString name): QObject() { //---------------------- selectionChanged ------------------------ void Viewer::selectionChanged(camitk::ComponentList& compSet) { - foreach (Component* comp, compSet) { + for (Component* comp : compSet) { comp->setSelected(true); } emit selectionChanged(); diff --git a/sdk/libraries/core/viewer/Viewer.h b/sdk/libraries/core/viewer/Viewer.h index 9d68720e..ce5ac47f 100644 --- a/sdk/libraries/core/viewer/Viewer.h +++ b/sdk/libraries/core/viewer/Viewer.h @@ -90,7 +90,7 @@ public: /// Is actually useful (and defined) in Explorer. virtual void refreshInterfaceNode(Component* comp) {}; -signals: +Q_SIGNALS: /// this signal is emitted when the current selection was changed by the viewer void selectionChanged(); diff --git a/tutorials/actions/averagevoxelvalues/ComputeNeighborValueAction.cpp b/tutorials/actions/averagevoxelvalues/ComputeNeighborValueAction.cpp index e2edb8b7..7db40688 100644 --- a/tutorials/actions/averagevoxelvalues/ComputeNeighborValueAction.cpp +++ b/tutorials/actions/averagevoxelvalues/ComputeNeighborValueAction.cpp @@ -58,7 +58,7 @@ ComputeNeighborValueAction::~ComputeNeighborValueAction() { // --------------- apply ------------------- Action::ApplyStatus ComputeNeighborValueAction::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/tutorials/actions/meshpointdata/ShowPointData.cpp b/tutorials/actions/meshpointdata/ShowPointData.cpp index dc7bb39b..e250170b 100644 --- a/tutorials/actions/meshpointdata/ShowPointData.cpp +++ b/tutorials/actions/meshpointdata/ShowPointData.cpp @@ -69,7 +69,7 @@ ShowPointData::~ShowPointData() { // --------------- apply ------------------- Action::ApplyStatus ShowPointData::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { MeshComponent* input = dynamic_cast(comp); process(input); diff --git a/tutorials/actions/properties/AddDynamicProperty.cpp b/tutorials/actions/properties/AddDynamicProperty.cpp index 69c24caf..eeeebefa 100644 --- a/tutorials/actions/properties/AddDynamicProperty.cpp +++ b/tutorials/actions/properties/AddDynamicProperty.cpp @@ -73,7 +73,7 @@ Action::ApplyStatus AddDynamicProperty::apply() { QString description = property("Description").toString(); QString unit = property("Unit").toString(); QString name = property("Name").toByteArray().constData(); - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { if (comp->getProperty(name)) { // the property already exits, modify its value switch (currentType) { diff --git a/tutorials/actions/properties/PropAction.cpp b/tutorials/actions/properties/PropAction.cpp index 6932cc5b..4ff10291 100644 --- a/tutorials/actions/properties/PropAction.cpp +++ b/tutorials/actions/properties/PropAction.cpp @@ -30,6 +30,8 @@ #include #include +#include + using namespace camitk; @@ -122,7 +124,7 @@ Action::ApplyStatus PropAction::apply() { // loop on all dynamic properties of this action (i.e. the action parameters) and // add each of them as a property of the currently selected components - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { QList dynProp = dynamicPropertyNames(); // loop on all dynamic properties @@ -143,7 +145,7 @@ Action::ApplyStatus PropAction::apply() { // copy all attributes newProp->setReadOnly(actionParam->getReadOnly()); - foreach (QString attributeName, actionParam->getAttributeList()) { + for (QString attributeName : actionParam->getAttributeList()) { newProp->setAttribute(attributeName, actionParam->getAttribute(attributeName)); } newProp->setEnumTypeName(actionParam->getEnumTypeName(), this); diff --git a/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingLinear.cpp b/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingLinear.cpp index 14b1a191..16e3e09b 100644 --- a/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingLinear.cpp +++ b/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingLinear.cpp @@ -60,7 +60,7 @@ WorkingWhenSleepingLinear::~WorkingWhenSleepingLinear() { // --------------- apply ------------------- Action::ApplyStatus WorkingWhenSleepingLinear::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } diff --git a/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingRandom.cpp b/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingRandom.cpp index 03478382..67d40e51 100644 --- a/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingRandom.cpp +++ b/tutorials/actions/sleepingwhileworking/WorkingWhenSleepingRandom.cpp @@ -60,7 +60,7 @@ WorkingWhenSleepingRandom::~WorkingWhenSleepingRandom() { // --------------- apply ------------------- Action::ApplyStatus WorkingWhenSleepingRandom::apply() { - foreach (Component* comp, getTargets()) { + for (Component* comp : getTargets()) { ImageComponent* input = dynamic_cast(comp); process(input); } -- GitLab From 31e63dc959947b629ffb173d558d11efdce00ba9 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 15 Mar 2019 18:06:22 +0100 Subject: [PATCH 14/24] NEW more viewers and camitk pything bindings --- python/CMakeLists.txt | 83 +++++++++++++++++++++++++++++++-------- python/PythonBindings.xml | 8 +++- python/test.py | 10 +++++ 3 files changed, 82 insertions(+), 19 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5a02a1e1..1dad154e 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -8,6 +8,9 @@ # #-------------------------------------------- +# TODO add an install target to install the PyCamiTK python module in the right place for system wide installation +# as well as locally + # cmake ../src/camitk -DCMAKE_BUILD_TYPE=Debug -DCAMITK_BINDING_PYTHON=TRUE -DCEP_IMAGING=FALSE -DCEP_TUTORIALS=FALSE -DCEP_MODELING=FALSE # make -j6 # make camitk-ce-python-package @@ -313,8 +316,12 @@ add_custom_command(OUTPUT ${CAMITK_PYTHON_GENERATED_SOURCES} COMMENT "Wrapping CamiTK SDK for Python bindings." ) + # =============================== CMake target for CamiTK Python binding ============================= + + + # Set the cpp files which will be used for the bindings library. set(${CAMITK_PYTHON_BIDINGS_MODULE_NAME}_SOURCES ${CAMITK_PYTHON_GENERATED_SOURCES}) @@ -355,25 +362,58 @@ target_link_libraries(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${CAMITK_CORE set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY PREFIX "") set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY OUTPUT_NAME "${CAMITK_PYTHON_BIDINGS_MODULE_NAME}${PYTHON_EXTENSION_SUFFIX}") - -if(WIN32) - set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY SUFFIX ".pyd") -endif() - -# Make sure the linker doesn't complain about not finding Python symbols on macOS. -if(APPLE) - set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -endif() -# Find and link to the python import library only on Windows. -# On Linux and macOS, the undefined symbols will get resolved by the dynamic linker -# (the symbols will be picked up in the Python executable). -if (WIN32) - list(GET python_linking_data 0 python_libdir) - list(GET python_linking_data 1 python_lib) - find_library(python_link_flags ${python_lib} PATHS ${python_libdir} HINTS ${python_libdir}) - target_link_libraries(${bindings_library} PRIVATE ${python_link_flags}) +# Output directory (python is public for now) +if (MSVC) + # With Visual Studio, public libraries are built in build\bin directory, else it's in build\lib + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CAMITK_BUILD_BIN_DIR} + LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_BIN_DIR} + LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_BIN_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BUILD_BIN_DIR} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_BIN_DIR} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_BIN_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CAMITK_BUILD_BIN_DIR} + ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_BIN_DIR} + ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_BIN_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES DEBUG_POSTFIX ${CAMITK_DEBUG_POSTFIX}) +else() + # for xcode generation, the postfix should also be used, but "a la" UNIX (lib in /lib etc...) + # no need to check the generator with if(CMAKE_GENERATOR STREQUAL Xcode), as the postfix should + # not affect the other unix generators + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} + LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PUBLIC_LIB_DIR} + LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PUBLIC_LIB_DIR} + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ) + set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PUBLIC_LIB_DIR} + ) endif() +# if(WIN32) +# set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY SUFFIX ".pyd") +# endif() +# +# # Make sure the linker doesn't complain about not finding Python symbols on macOS. +# if(APPLE) +# set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") +# endif() +# +# # Find and link to the python import library only on Windows. +# # On Linux and macOS, the undefined symbols will get resolved by the dynamic linker +# # (the symbols will be picked up in the Python executable). +# if (WIN32) +# list(GET python_linking_data 0 python_libdir) +# list(GET python_linking_data 1 python_lib) +# find_library(python_link_flags ${python_lib} PATHS ${python_libdir} HINTS ${python_libdir}) +# target_link_libraries(${bindings_library} PRIVATE ${python_link_flags}) +# endif() # Wrap the CamiTK SDK. Wrapping uses Shiboken (PySide binding tool) @@ -443,3 +483,12 @@ endif() # COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK Python package created." # ) # add_dependencies(camitk-ce-python-package camitk-ce-python-wrapping) # need all to wrapped before creating the package + +# Indicate where to install the python library +install(TARGETS ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} + # TODO proper python lib installation + RUNTIME DESTINATION lib + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + COMPONENT ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} +) diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index e832f4b6..7d3bc769 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -488,12 +488,16 @@ if (thisAttr == nullptr) { qDebug() << "__this__ is null"; return nullptr; } -//qDebug() << "Found: " << thisAttr; PyObject* strUTF8 = PyUnicode_AsUTF8String(thisAttr); +if (strUTF8 == nullptr) { + qDebug() << "Cannot convert to UTF8 string"; + return nullptr; +} + Py_DECREF(thisAttr); const char* str = PyBytes_AS_STRING(strUTF8); -qDebug() << "VTK __this string: \"" << str << "\""; +qDebug() << "VTK __this__ string: \"" << str << "\""; char hex_address[32], *pEnd; const char *_p_ = strstr(str, "_p_vtk"); diff --git a/python/test.py b/python/test.py index 1dbebbf5..46483485 100644 --- a/python/test.py +++ b/python/test.py @@ -90,6 +90,8 @@ if __name__ == "__main__": app.getMainWindow().setCentralViewer(camitk.MedicalImageViewer.getInstance()) app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.Explorer.getInstance()) app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.PropertyExplorer.getInstance()) + app.getMainWindow().addDockViewer(Qt.RightDockWidgetArea, camitk.ActionViewer.getInstance()) + fileMenu = QMenu("&File"); action = camitk.Application.getAction("Open") @@ -229,3 +231,11 @@ if __name__ == "__main__": # sys.path.append('./python') # from PyCamiTK import camitk # app = camitk.Application(sys.argv) + +#fileMenu = QMenu("&Python"); +#action = camitk.Application.getAction("Open") +#fileMenu.addAction(action.getQAction()) +#mainWindow = app.getMainWindow() +#appMenuBar = mainWindow.menuBar() +#appMenuBar.addMenu(fileMenu) + -- GitLab From 9aa1e36dc70ebda50c3bb4a26e9339e60175984e Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 15 Mar 2019 18:08:01 +0100 Subject: [PATCH 15/24] NEW tutorial action for scripting inside imp! Everything you ever dreamed about... inside imp! Just run camitk-imp, open an image, launch the "Python Image Scripting" action and type whatever you like inside the text area... That's PyCamiTK ! --- .../actions/pythonscripting/CMakeLists.txt | 101 ++++++ .../pythonscripting/PythonScripting.cpp | 296 ++++++++++++++++++ .../actions/pythonscripting/PythonScripting.h | 67 ++++ .../PythonScriptingActionExtension.cpp | 32 ++ .../PythonScriptingActionExtension.h | 62 ++++ 5 files changed, 558 insertions(+) create mode 100644 tutorials/actions/pythonscripting/CMakeLists.txt create mode 100644 tutorials/actions/pythonscripting/PythonScripting.cpp create mode 100644 tutorials/actions/pythonscripting/PythonScripting.h create mode 100644 tutorials/actions/pythonscripting/PythonScriptingActionExtension.cpp create mode 100644 tutorials/actions/pythonscripting/PythonScriptingActionExtension.h diff --git a/tutorials/actions/pythonscripting/CMakeLists.txt b/tutorials/actions/pythonscripting/CMakeLists.txt new file mode 100644 index 00000000..32b6b36f --- /dev/null +++ b/tutorials/actions/pythonscripting/CMakeLists.txt @@ -0,0 +1,101 @@ +# Only available if CamiTK Python is available +# TODO add a "NEEDS_PYTHON" flag in camitk_extension CamiTK macros +if(CAMITK_BINDING_PYTHON) + +# -- Python3 +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +if(NOT Python3_FOUND) + message(SEND_ERROR "Failed to find Python 3 or greater. This is needed to build CamiTK Python binding.") +endif() +if("${Python3_VERSION}" VERSION_LESS 3.7) + message(FATAL_ERROR "Found Python3 ${Python3_VERSION} version but at least 3.7 is required. Please update your version of Python3.") +endif() +message(STATUS "Found suitable version of Python: ${Python3_VERSION} (required is at least 3.7)") + + + +# -- PySide, the Python binding of Qt using Shiboken. +find_package(PySide2 REQUIRED) +if(PYSIDE_INCLUDE_DIR) + message(STATUS "Found PySide2 configuration in ${PySide2_DIR}") + # PySide2 config file was found but it may use the wrong Python version + # Try to get the matching config suffix and repeat finding the package + set(PYSIDE_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + + file(GLOB PYSIDE_CONFIG "${PySide2_DIR}/PySide2Config${PYSIDE_PATTERN}*.cmake") + if (PYSIDE_CONFIG) + get_filename_component(PYSIDE_CONFIG_SUFFIX ${PYSIDE_CONFIG} NAME) + string(SUBSTRING ${PYSIDE_CONFIG_SUFFIX} 13 -1 PYSIDE_CONFIG_SUFFIX) + string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${PYSIDE_CONFIG_SUFFIX}) + message(STATUS "PYTHON_CONFIG_SUFFIX for PySide2: ${PYTHON_CONFIG_SUFFIX}") + # find the package again but this time use the python 3 version (in quiet mode) + find_package(PySide2 QUIET) + endif() + set(PYSIDE_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}.${Python3_VERSION_PATCH}) +endif() +if (NOT PYSIDE_VERSION OR ${PYSIDE_VERSION} VERSION_LESS 3.7) + message(FATAL_ERROR "Failed to find PySide2 for Python3. Found version: ${PYSIDE_VERSION}. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found suitable version of PySide2: ${PYSIDE_VERSION}, path to binary is ${PYSIDE_VERSION}") + + +if(NOT PYSIDE_INCLUDE_DIR) + message(FATAL_ERROR "Failed to find PySide2. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found PySide2") + +# -- Shiboken2, the PySide team C++ to Python wrapper +find_package(Shiboken2 REQUIRED) +if (Shiboken2_FOUND) + # Shiboken2 config file was found but it may use the wrong Python version + # Try to get the matching config suffix and repeat finding the package + set(SHIBOKEN_PATTERN .cpython-${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + + file(GLOB SHIBOKEN_CONFIG "${Shiboken2_DIR}/Shiboken2Config${SHIBOKEN_PATTERN}*.cmake") + if (SHIBOKEN_CONFIG) + get_filename_component(SHIBOKEN_CONFIG_SUFFIX ${SHIBOKEN_CONFIG} NAME) + string(SUBSTRING ${SHIBOKEN_CONFIG_SUFFIX} 15 -1 SHIBOKEN_CONFIG_SUFFIX) + string(REPLACE ".cmake" "" PYTHON_CONFIG_SUFFIX ${SHIBOKEN_CONFIG_SUFFIX}) + message(STATUS "PYTHON_CONFIG_SUFFIX for Shiboken2: ${PYTHON_CONFIG_SUFFIX}") + # find the package again but this time use the python 3 version (in quiet mode) + find_package(Shiboken2 QUIET) + endif() + set(SHIBOKEN_VERSION ${SHIBOKEN_PYTHON_VERSION_MAJOR}.${SHIBOKEN_PYTHON_VERSION_MINOR}.${SHIBOKEN_PYTHON_VERSION_PATCH}) +endif() +if (NOT SHIBOKEN_VERSION OR ${SHIBOKEN_VERSION} VERSION_LESS 3.7) + message(FATAL_ERROR "Failed to find Shiboken2 for Python3. Found version: ${SHIBOKEN_VERSION}. This is needed to build CamiTK Python binding.") +endif() +message(STATUS "Found suitable version of Shiboken2: ${SHIBOKEN_VERSION}, path to binary is ${SHIBOKEN_BINARY}") + +# Enable rpaths so that the example can be executed from the build dir. +# set(CMAKE_SKIP_BUILD_RPATH FALSE) +# set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +# set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ${PYSIDE_TYPESYSTEMS} ${SHIBOKEN_TYPESYSTEM_PATH}) +# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + + +camitk_extension(ACTION_EXTENSION + INCLUDE_DIRECTORIES ${PYTHON3_INCLUDE_DIRS} ${PYSIDE_INCLUDE_DIR} ${PYSIDE_INCLUDE_DIR}/QtCore ${SHIBOKEN_INCLUDE_DIR} + EXTERNAL_LIBRARIES ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} + # to avoid syntax errors in Python object.h due to the usage of the word "slot" (Same as CONFIG += no_keywords) + DEFINES QT_NO_KEYWORDS +# EXTERNAL_LIBRARIES +) + +# TODO add everything necessary to find this library +# link_directories(${CAMITK_BUILD_PRIVATE_LIB_DIR}) +# message(FATAL_ERROR "$$$ ${CAMITK_BUILD_PRIVATE_LIB_DIR}/python") +# if (MSVC) +# set(PYCAMITK_LIBRARY ${CAMITK_BUILD_BIN_DIR}/PyCamiTK.so) +# else() +# set(PYCAMITK_LIBRARY ${CAMITK_BUILD_PUBLIC_LIB_DIR}/PyCamiTK.so) +# endif() +# target_link_libraries(${ACTION_TARGET_NAME} ${PYCAMITK_LIBRARY}) + +# Find and link to the python library. +# list(GET PYTHON_LINKING_DATA 0 PYTHON_LIBDIR) +# list(GET PYTHON_LINKING_DATA 1 PYTHON_LIB) +# find_library(PYTHON_LINK_FLAGS ${PYTHON_LIB} PATHS ${PYTHON_LIBDIR} HINTS ${PYTHON_LIBDIR}) +# target_link_libraries(${ACTION_TARGET_NAME} ${PYTHON_LINK_FLAGS}) + +endif() # CAMITK_BINDING_PYTHON diff --git a/tutorials/actions/pythonscripting/PythonScripting.cpp b/tutorials/actions/pythonscripting/PythonScripting.cpp new file mode 100644 index 00000000..c01078a1 --- /dev/null +++ b/tutorials/actions/pythonscripting/PythonScripting.cpp @@ -0,0 +1,296 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3w + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +#include "PythonScripting.h" + +#include +#include +#include +#include +#include +using namespace camitk; + +// Qt +#include +#include // from QtWidgets +#include // from QtCore + +// Python binding (shiboken2) +#include +#include +#include + +// From PyCamiTK python module +// extern "C" PyObject *PyInit_PyCamiTK(); + + +// -------------------- PythonScripting -------------------- +PythonScripting::PythonScripting(ActionExtension* extension) : Action(extension) { + setName("Python Image Scripting"); + setDescription("Tutorial action to demonstrate the python scripting ability of CamiTK"); + setComponent("ImageComponent"); + + setFamily("Tutorial"); + addTag("Python"); + addTag("Scripting"); + addTag("Image Processing"); + + //-- widget lazy instantiation + scriptTextEdit = nullptr; + + //-- init Python module + pythonScriptingIsAvailable = false; +} + +// --------------- getWidget ------------------- +QWidget* PythonScripting::getWidget() { + + if (!scriptTextEdit) { + // customize existing widget + QWidget* defaultWidget = Action::getWidget(); + QLayout* informationFrameLayout = defaultWidget->layout(); + + //-- the frame +// QString defaultScript = "print(\"Name of component: \" + comp.getName())\n" +// "\n" +// "imageDimension = eval(comp.property(\"Image Dimensions\")) # dim\n" +// "print(\"Original image dimension: \" + str(imageDimension))\n" +// "print(\"Voxel type: \" + comp.property(\"Voxel Data Type\"))\n"; +// QString defaultScript = "print (\"Hello World\")"; + QString defaultScript = "print(\"PyCamiTK version: \" + camitk.Core.version)"; + + scriptTextEdit = new QPlainTextEdit(defaultScript); + + informationFrameLayout->addWidget(scriptTextEdit); + + defaultWidget->setLayout(informationFrameLayout); + } + + return Action::getWidget(); +} + +// --------------- destructor ------------------- +PythonScripting::~PythonScripting() { + // As we are not using qAddPostRoutine(cleanup) in initPython() + // just call this manually here + Py_Finalize(); + +} + +// --------------- apply ------------------- +Action::ApplyStatus PythonScripting::apply() { + + // get the last selected image component + ImageComponent* imageComponent = dynamic_cast(getTargets().last()); + + // update the information label + if (scriptTextEdit != nullptr) { + // set waiting cursor (not really needed here as the action is very fast, but after all this is a demo) + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + +/* + * + * Demo + * + from PySide2.QtWidgets import QMenu +from PySide2.QtGui import * +from PySide2.QtCore import Qt + +app = camitk.Application.instance() #QApplication.instance() + +print("PyCamiTK version: " + camitk.Core.version) +print(app) + +# comp = camitk.Application.open(camitk.Core.getTestDataDir() + "/brain.mha") + +#fileMenu = QMenu("&Python"); +#action = camitk.Application.getAction("Open") +#fileMenu.addAction(action.getQAction()) +#mainWindow = app.getMainWindow() +#appMenuBar = mainWindow.menuBar() +#appMenuBar.addMenu(fileMenu) + +#app.getMainWindow().addDockViewer(Qt.RightDockWidgetArea, camitk.PropertyExplorer.getInstance()) + +#app.getMainWindow().dockWidgetMap[camitk.PropertyExplorer.getInstance()].hide() + +app.getMainWindow().showViewer(camitk.PropertyExplorer.getInstance(), True) + +*/ + + // if (!PythonUtils::bindAppObject("camitk", "ImageComponent", PythonUtils::ImageComponentType, this)) { +// CAMITK_WARNING(tr("Error loading the Python module. Action Aborted.")) +// return ABORTED; +// // Application::showStatusBarMessage(tr("Error loading the Python module")); +// } + + const QStringList pythonScript = scriptTextEdit->toPlainText().trimmed().split(QLatin1Char('\n'), QString::SkipEmptyParts); + bool result = runScript(pythonScript); + + // restore the normal cursor + QApplication::restoreOverrideCursor(); + + return (result) ? SUCCESS : ERROR; + } + + return SUCCESS; +} + + +// --------------- initPython ------------------- +void PythonScripting::initPython() { + + if (!pythonScriptingIsAvailable) { + // If there is an active python virtual environment, use that environment's packages location. + QByteArray virtualEnvPath = qgetenv("VIRTUAL_ENV"); + if (!virtualEnvPath.isEmpty()) + qputenv("PYTHONHOME", virtualEnvPath); + + Py_Initialize(); + + const bool pythonInitialized = true; //PyInit_PyCamiTK() != nullptr; + + const bool pyErrorOccurred = PyErr_Occurred() != nullptr; + if (pythonInitialized && !pyErrorOccurred) { + pythonScriptingIsAvailable = true; + CAMITK_INFO(tr("Python environment initialized.")) + } + else { + if (pyErrorOccurred) { + PyErr_Print(); + } + pythonScriptingIsAvailable = false; + CAMITK_WARNING(tr("Failed to initialize the Python module. Python scripting not available.")) + } + } +} + +// --------------- runScript ------------------- +bool PythonScripting::runScript(const QStringList& script) { + + initPython(); + + if (!pythonScriptingIsAvailable) { + return false; + } + + CAMITK_INFO(tr("Script:\n=========\n%1\n=========").arg(script.join("\n"))) + + // Concatenating all the lines + QString content; + QTextStream ss(&content); + ss << "try:\n"; + for (const QString& line : script) + ss << " " << line << "\n"; + ss << "except Exception:\n"; + ss << " print(traceback.format_exc())\n"; + ss << " print(sys.exc_info()[0])\n"; + + //this is python code to redirect stdout/stderr, see extending FAQ https://docs.python.org/3/faq/extending.html and https://stackoverflow.com/q/46632488 + std::string stdOutErr = + "import sys\n" + "class PythonOutputCatcher:\n" + " def __init__(self):\n" + " self.value = ''\n" + " def write(self, text):\n" + " self.value += text\n" + "pythonOutput = PythonOutputCatcher()\n" + "sys.stdout = pythonOutput\n" + "sys.stderr = pythonOutput\n" + "import traceback\n" + "import sys\n" + "print(\"Adding Python library path: " + Core::getInstallDirectories("lib").at(0).toStdString() + "\")\n" + // "sys.path.append('.')\n" + "sys.path.append('" + Core::getInstallDirectories("lib").at(0).toStdString() + "')\n" + + "from PyCamiTK import camitk\n"; + + PyObject* pModule = PyImport_AddModule("__main__"); //create main module + PyRun_SimpleString(stdOutErr.c_str()); // invoke code to redirect + +// PyObject * hashlibModule = PyImport_ImportModule("PyCamiTK"); + + // Executing the whole script as one line + const QByteArray line = content.toUtf8(); + int runResult = PyRun_SimpleString(line.constData()); + + PyObject* pythonOutput = PyObject_GetAttrString(pModule, "pythonOutput"); + + if (pythonOutput == nullptr) { + CAMITK_WARNING("Cannot get pythonOutput object.") + return false; + } + + //PyErr_Print(); // make python print any errors + + PyObject* pythonOutputValue = PyObject_GetAttrString(pythonOutput, "value"); + if (pythonOutputValue == nullptr) { + CAMITK_WARNING("Cannot get pythonStdOuput data.") + return false; + } + + char* catcherData; + if (PyUnicode_Check(pythonOutputValue)) { + // Convert string to bytes. + // strdup() bytes into my_result. + PyObject* temp_bytes = PyUnicode_AsEncodedString(pythonOutputValue, "utf-8", "strict"); // Owned reference + if (temp_bytes != NULL) { + catcherData = PyBytes_AsString(temp_bytes); // Borrowed pointer + catcherData = strdup(catcherData); + Py_DECREF(temp_bytes); + } + else { + // TODO: Handle encoding error. + CAMITK_WARNING("Encoding error.") + return false; + } + } + else { + if (PyBytes_Check(pythonOutputValue)) { + // strdup() bytes into my_result. + catcherData = PyBytes_AS_STRING(pythonOutputValue); // Borrowed pointer + catcherData = strdup(catcherData); + } + else { + // Convert into your favorite string representation. + // Convert string to bytes if it is not already. + // strdup() bytes into my_result. + CAMITK_WARNING("Importing string error. Not implemented") + return false; + } + } + + /* + PyObject* strUTF8 = PyUnicode_AsUTF8String(output); + // Py_DECREF(thisAttr); + + const char* str = //PyUnicode_AsEncodedString(strUTF8); //PyBytes_AS_STRING(strUTF8); + + CAMITK_INFO(tr("Here's the output:%1").arg(QString(str))) + */ + + CAMITK_INFO(tr("Python Output:\n=========\n%1=========").arg(QString(catcherData))) + return true; + +} diff --git a/tutorials/actions/pythonscripting/PythonScripting.h b/tutorials/actions/pythonscripting/PythonScripting.h new file mode 100644 index 00000000..6e6b63a2 --- /dev/null +++ b/tutorials/actions/pythonscripting/PythonScripting.h @@ -0,0 +1,67 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + +#ifndef IMAGE_PICKING_H +#define IMAGE_PICKING_H + +#include +class QPlainTextEdit; + +/** + * Demonstrates how to get information from image picking. + * This is an embedded action (it is shown in the ActionViewer) + */ +class PythonScripting : public camitk::Action { + +public: + /// the constructor + PythonScripting(camitk::ActionExtension*); + + /// the destructor + virtual ~PythonScripting(); + + /// method called when the action when the action is triggered (i.e. started) + virtual QWidget* getWidget(); + +public Q_SLOTS: + /// method called when the action is applied + virtual ApplyStatus apply(); + +private: + /// the script editor + QPlainTextEdit* scriptTextEdit; + + /// initialize python environment, set the state of python scripting to true if everything + /// went well, otherwise set it to false + void initPython(); + + /// current state of python + bool pythonScriptingIsAvailable; + + /// run the script in python (each python line of code is an QString in the list) + bool runScript(const QStringList &); +}; + +#endif // IMAGE_PICKING_H diff --git a/tutorials/actions/pythonscripting/PythonScriptingActionExtension.cpp b/tutorials/actions/pythonscripting/PythonScriptingActionExtension.cpp new file mode 100644 index 00000000..f2d74692 --- /dev/null +++ b/tutorials/actions/pythonscripting/PythonScriptingActionExtension.cpp @@ -0,0 +1,32 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ +#include "PythonScriptingActionExtension.h" +#include "PythonScripting.h" + +// -------------------- init -------------------- +void PythonScriptingActionExtension::init() { + registerNewAction(PythonScripting); +} + diff --git a/tutorials/actions/pythonscripting/PythonScriptingActionExtension.h b/tutorials/actions/pythonscripting/PythonScriptingActionExtension.h new file mode 100644 index 00000000..69642003 --- /dev/null +++ b/tutorials/actions/pythonscripting/PythonScriptingActionExtension.h @@ -0,0 +1,62 @@ +/***************************************************************************** + * $CAMITK_LICENCE_BEGIN$ + * + * CamiTK - Computer Assisted Medical Intervention ToolKit + * (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO) + * + * Visit http://camitk.imag.fr for more information + * + * This file is part of CamiTK. + * + * CamiTK is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * CamiTK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with CamiTK. If not, see . + * + * $CAMITK_LICENCE_END$ + ****************************************************************************/ + + +#ifndef PYTHON_SCRIPTING_ACTION_EXTENSION_H +#define PYTHON_SCRIPTING_ACTION_EXTENSION_H + +#include +#include +#include + +/// a simple action extension containing two actions: one for mesh picking, one for image picking +class PythonScriptingActionExtension : public camitk::ActionExtension { + Q_OBJECT + Q_INTERFACES(camitk::ActionExtension) + Q_PLUGIN_METADATA(IID "fr.imag.camitk.tutorials.action.python") + +public: + /// the constructor + PythonScriptingActionExtension() : ActionExtension() {}; + + /// the destructor + virtual ~PythonScriptingActionExtension() = default; + + /// initialize all the actions + virtual void init(); + + /// Method that return the action extension name + virtual QString getName() { + return "Python Scripting Tutorial"; + }; + + /// Method that return the action extension descrption + virtual QString getDescription() { + return "This is a basic demo of python scripting in an action."; + }; + +}; + +#endif // PYTHON_SCRIPTING_ACTION_EXTENSION_H -- GitLab From 67230ee897a429574893dccda908fea9431e0108 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 22 Mar 2019 15:50:07 +0100 Subject: [PATCH 16/24] NEW Complete working example in tutorials (demo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CamiTK → VTK → numpy → ITKfilter → numpy → VTK → CamiTK --- python/CMakeLists.txt | 12 +- python/PythonBindings.h | 2 +- python/PythonBindings.xml | 2 + python/test.py | 14 +- .../actions/pythonscripting/CMakeLists.txt | 44 ++- .../pythonscripting/PythonScripting.cpp | 335 ++++++++++++++++-- .../actions/pythonscripting/PythonScripting.h | 6 +- 7 files changed, 347 insertions(+), 68 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 1dad154e..e62374af 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -15,16 +15,13 @@ # make -j6 # make camitk-ce-python-package # python3 ../src/camitk/python/test.py +# gdb bin/camitk-actionstatemachine +# (gdb) r -a -f camitk-history-20190315-132942.scxml -o /tmp # check also https://code.qt.io/cgit/pyside/pyside-setup.git/tree/examples/samplebinding/CMakeLists.txt?h=5.9 cmake_minimum_required(VERSION 3.1) cmake_policy(VERSION 3.1) -# Enable policy to not use RPATH settings for install_name on macOS. -if(POLICY CMP0068) - cmake_policy(SET CMP0068 NEW) -endif() - # Set CPP standard to C++11 minimum. set(CMAKE_CXX_STANDARD 11) @@ -260,6 +257,7 @@ set(CAMITK_PYTHON_CLASS_NAMES Core InterfaceBitMap InterfaceGeometry InterfaceFrame + ComponentExtension Component ImageComponent # RendererWidget @@ -316,12 +314,8 @@ add_custom_command(OUTPUT ${CAMITK_PYTHON_GENERATED_SOURCES} COMMENT "Wrapping CamiTK SDK for Python bindings." ) - # =============================== CMake target for CamiTK Python binding ============================= - - - # Set the cpp files which will be used for the bindings library. set(${CAMITK_PYTHON_BIDINGS_MODULE_NAME}_SOURCES ${CAMITK_PYTHON_GENERATED_SOURCES}) diff --git a/python/PythonBindings.h b/python/PythonBindings.h index cd9a2eeb..451f4afd 100644 --- a/python/PythonBindings.h +++ b/python/PythonBindings.h @@ -90,7 +90,7 @@ // Frame.h // SimplisticComponent.h // Geometry.h -// ComponentExtension.h +#include // GeometricObject.h // Slice.h diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index 7d3bc769..29eb8805 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -385,6 +385,8 @@ static void ApplicationConstructor(PyObject* self, PyObject* pyargv, Application + + diff --git a/python/test.py b/python/test.py index 46483485..82483e99 100644 --- a/python/test.py +++ b/python/test.py @@ -20,10 +20,8 @@ sys.path.append('.') sys.path.append('./python') # list CamiTK python bindings exported classes -import inspect from PyCamiTK import camitk -availableCamiTKClasses = inspect.getmembers(sys.modules[__name__], inspect.isclass) -print (availableCamiTKClasses) +dir(camitk) #app = camitk.Application(sys.argv) #mw = camitk.MainWindow("Python MainWindow") @@ -165,7 +163,7 @@ if __name__ == "__main__": # compute radius and center from imageDimension radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) - + # 3D array semisizes = (radius,) * 3 @@ -189,11 +187,11 @@ if __name__ == "__main__": #f.SetDataExtent( ... ) f.Update() imageData = f.GetOutput() - + #print("inside=" + str(inside) + ", outside=" + str(outside) + ", inside/outside=" + str(inside/outside)) #print("imageData=" + str(imageData)) print("imageData.__this__=" + str(imageData.__this__)) - #print("comp=" + str(comp)) +#print("comp=" + str(comp)) backupImageData = comp.getImageData() print("backup image data =" + str(backupImageData)) @@ -201,10 +199,8 @@ if __name__ == "__main__": comp.replaceImageData(imageData) #setVtkImageData # add a new component - comp2 = camitk.ImageComponent("test from scratch") - comp2.replaceImageData(backupImageData) - comp.setSelected(True) + print("Number of opened top level components: " + str(len(app.getTopLevelComponents()))) diff --git a/tutorials/actions/pythonscripting/CMakeLists.txt b/tutorials/actions/pythonscripting/CMakeLists.txt index 32b6b36f..7bd5342f 100644 --- a/tutorials/actions/pythonscripting/CMakeLists.txt +++ b/tutorials/actions/pythonscripting/CMakeLists.txt @@ -68,10 +68,10 @@ endif() message(STATUS "Found suitable version of Shiboken2: ${SHIBOKEN_VERSION}, path to binary is ${SHIBOKEN_BINARY}") # Enable rpaths so that the example can be executed from the build dir. -# set(CMAKE_SKIP_BUILD_RPATH FALSE) -# set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) -# set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ${PYSIDE_TYPESYSTEMS} ${SHIBOKEN_TYPESYSTEM_PATH}) -# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +set(CMAKE_SKIP_BUILD_RPATH FALSE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ${PYSIDE_TYPESYSTEMS} ${SHIBOKEN_TYPESYSTEM_PATH}) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) camitk_extension(ACTION_EXTENSION @@ -83,14 +83,36 @@ camitk_extension(ACTION_EXTENSION ) # TODO add everything necessary to find this library -# link_directories(${CAMITK_BUILD_PRIVATE_LIB_DIR}) +# link_directories(${CAMITK_BUILD_PUBLIC_LIB_DIR}) # message(FATAL_ERROR "$$$ ${CAMITK_BUILD_PRIVATE_LIB_DIR}/python") -# if (MSVC) -# set(PYCAMITK_LIBRARY ${CAMITK_BUILD_BIN_DIR}/PyCamiTK.so) -# else() -# set(PYCAMITK_LIBRARY ${CAMITK_BUILD_PUBLIC_LIB_DIR}/PyCamiTK.so) -# endif() -# target_link_libraries(${ACTION_TARGET_NAME} ${PYCAMITK_LIBRARY}) +set(PYCAMITK_LIBRARY_NAME "PyCamiTK") +# transform PyCamiTK.so to libPyCamiTK.so has to be present as well as PyCamiTK.so +find_library( + PYCAMITK_LIB + NAMES lib${PYCAMITK_LIBRARY_NAME}.so # what to look for + HINTS "${CAMITK_BUILD_PUBLIC_LIB_DIR}" # where to look + NO_DEFAULT_PATH # do not search system default paths +) + +# check if we found the library +message(STATUS "PYCAMITK_LIB: [${PYCAMITK_LIB}]") + +if (NOT PYCAMITK_LIB) + message(SEND_ERROR "Did not find lib PyCamiTK") +endif() +# +# add_library(PYCAMITK UNKNOWN IMPORTED) +# # if (MSVC) +# # # not CAMITK_BUILD_BIN_DIR / CAMITK_BUILD_PRIVATE_LIB_DIR +# # set(PYCAMITK_LIBRARY_PATH "${CAMITK_BUILD_PUBLIC_LIB_DIR}/${PYCAMITK_LIBRARY_NAME}.so") +# # else() +# # # not CAMITK_BUILD_PUBLIC_LIB_DIR / CAMITK_BUILD_PRIVATE_LIB_DIR +# # set(PYCAMITK_LIBRARY_PATH "${CAMITK_BUILD_PUBLIC_LIB_DIR}/${PYCAMITK_LIBRARY_NAME}.so") +# # endif() +# set_property(TARGET PYCAMITK PROPERTY IMPORTED_LOCATION "${PYCAMITK_LIB}") +# set_property(TARGET PYCAMITK PROPERTY IMPORTED_SONAME "${PYCAMITK_LIBRARY_NAME}.so") + +target_link_libraries(${ACTION_TARGET_NAME} ${PYCAMITK_LIB}) # Find and link to the python library. # list(GET PYTHON_LINKING_DATA 0 PYTHON_LIBDIR) diff --git a/tutorials/actions/pythonscripting/PythonScripting.cpp b/tutorials/actions/pythonscripting/PythonScripting.cpp index c01078a1..2c71db74 100644 --- a/tutorials/actions/pythonscripting/PythonScripting.cpp +++ b/tutorials/actions/pythonscripting/PythonScripting.cpp @@ -42,10 +42,6 @@ using namespace camitk; #include #include -// From PyCamiTK python module -// extern "C" PyObject *PyInit_PyCamiTK(); - - // -------------------- PythonScripting -------------------- PythonScripting::PythonScripting(ActionExtension* extension) : Action(extension) { setName("Python Image Scripting"); @@ -73,14 +69,7 @@ QWidget* PythonScripting::getWidget() { QLayout* informationFrameLayout = defaultWidget->layout(); //-- the frame -// QString defaultScript = "print(\"Name of component: \" + comp.getName())\n" -// "\n" -// "imageDimension = eval(comp.property(\"Image Dimensions\")) # dim\n" -// "print(\"Original image dimension: \" + str(imageDimension))\n" -// "print(\"Voxel type: \" + comp.property(\"Voxel Data Type\"))\n"; -// QString defaultScript = "print (\"Hello World\")"; - QString defaultScript = "print(\"PyCamiTK version: \" + camitk.Core.version)"; - + QString defaultScript = "print(target)\n"; scriptTextEdit = new QPlainTextEdit(defaultScript); informationFrameLayout->addWidget(scriptTextEdit); @@ -112,7 +101,7 @@ Action::ApplyStatus PythonScripting::apply() { /* * - * Demo + * Demo 1 * from PySide2.QtWidgets import QMenu from PySide2.QtGui import * @@ -130,7 +119,7 @@ print(app) #fileMenu.addAction(action.getQAction()) #mainWindow = app.getMainWindow() #appMenuBar = mainWindow.menuBar() -#appMenuBar.addMenu(fileMenu) +#appMenuBar.addMenu(fileMenu) #app.getMainWindow().addDockViewer(Qt.RightDockWidgetArea, camitk.PropertyExplorer.getInstance()) @@ -140,11 +129,271 @@ app.getMainWindow().showViewer(camitk.PropertyExplorer.getInstance(), True) */ - // if (!PythonUtils::bindAppObject("camitk", "ImageComponent", PythonUtils::ImageComponentType, this)) { -// CAMITK_WARNING(tr("Error loading the Python module. Action Aborted.")) -// return ABORTED; -// // Application::showStatusBarMessage(tr("Error loading the Python module")); -// } +/** + * Demo 2 + * + * CPP object is visible from python + * + +print("PyCamiTK version: " + camitk.Core.version) +print(target) +imageDimension = eval(target.property("Image Dimensions")) # dim +print("Original image dimension: " + str(imageDimension)) +print("Voxel type: " + target.property("Voxel Data Type")) +*/ + + +/** + * Demo 3 + * + * + +backupImageData = target.getImageData() +print("backup image data =" + str(backupImageData)) +comp2 = camitk.ImageComponent("test from scratch") +comp2.replaceImageData(backupImageData) +comp2.setSelected(True) +camitk.Application.refresh() + +*/ + +/* + * Demo 4 + * + * +import vtk +import math +from vtk.util import vtkImageImportFromArray as vtkutil +import numpy as np + +def generateSphere(imageDimension): + # compute radius and center from imageDimension + radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + # 3D array + semisizes = (radius,) * 3 + + # generate the grid for the support points + # centered at the position indicated by center + grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + center = np.ogrid[grid] + # calculate the distance of all points from center + # scaled by the radius + arr = np.zeros(imageDimension, dtype=float) + for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) + # the inner part of the sphere will have distance below 1 + #return arr <= 1.0 + + # generate vtkImage from an array + f = vtkutil.vtkImageImportFromArray() + f.SetArray( arr ) + #f.SetDataOrigin( ... ) + #f.SetDataSpacing( ... ) + #f.SetDataExtent( ... ) + f.Update() + return f.GetOutput() + + +imageDimension = eval(target.property("Image Dimensions")) +# compute radius and center from imageDimension +radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 +center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + +# 3D array +semisizes = (radius,) * 3 + +# generate the grid for the support points +# centered at the position indicated by center +grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] +center = np.ogrid[grid] +# calculate the distance of all points from center +# scaled by the radius +arr = np.zeros(imageDimension, dtype=float) +for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) +# the inner part of the sphere will have distance below 1 + +# generate vtkImage from an array +f = vtkutil.vtkImageImportFromArray() +f.SetArray( arr ) +f.Update() +imageData = f.GetOutput() + +print("imageData.__this__=" + str(imageData.__this__)) + +target.replaceImageData(imageData) +camitk.Application.refresh() +*/ + +/* Demo 5 + * + * +import vtk +import math +from vtk.util import vtkImageImportFromArray as vtkutil +import numpy as np + +def generateSphere(imageDimension): + # compute radius and center from imageDimension + radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + # 3D array + semisizes = (radius,) * 3 + + # generate the grid for the support points + # centered at the position indicated by center + grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + center = np.ogrid[grid] + # calculate the distance of all points from center + # scaled by the radius + arr = np.zeros(imageDimension, dtype=float) + for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) + # the inner part of the sphere will have distance below 1 + #return arr <= 1.0 + + # generate vtkImage from an array + f = vtkutil.vtkImageImportFromArray() + f.SetArray( arr ) + #f.SetDataOrigin( ... ) + #f.SetDataSpacing( ... ) + #f.SetDataExtent( ... ) + f.Update() + return f.GetOutput() + + +imageDimension = eval(target.property("Image Dimensions")) +# compute radius and center from imageDimension +radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 +center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + +# 3D array +semisizes = (radius,) * 3 + +# generate the grid for the support points +# centered at the position indicated by center +grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] +center = np.ogrid[grid] +# calculate the distance of all points from center +# scaled by the radius +arr = np.zeros(imageDimension, dtype=float) +for x_i, semisize in zip(center, semisizes): + arr += (np.abs(x_i / semisize) ** 2) +# the inner part of the sphere will have distance below 1 +#return arr <= 1.0 + +# generate vtkImage from an array +f = vtkutil.vtkImageImportFromArray() +f.SetArray( arr ) +#f.SetDataOrigin( ... ) +#f.SetDataSpacing( ... ) +#f.SetDataExtent( ... ) +f.Update() +imageData = f.GetOutput() + +print("imageData.__this__=" + str(imageData.__this__)) + +newComponent = camitk.ImageComponent("test from scratch") +newComponent.replaceImageData(imageData) +newComponent.setSelected(True) + +camitk.Application.refresh() +*/ + +/** + * Demo 6 + * + * + * +import itk +import numpy as np +itkImage = itk.imread(camitk.Core.getTestDataDir() + "/brain.mha") +print(itkImage) + +dimension = 3 +pixelType = itk.UC +imageType = itk.Image[pixelType, dimension] + +meanFilter = itk.MeanImageFilter[imageType, imageType].New() +meanFilter.SetInput(itkImage) +meanFilter.SetRadius(5) + +outputItkImage = meanFilter.GetOutput() + +print("---------------") +print(outputItkImage) + +numpyArray = itk.GetArrayFromImage(outputItkImage) + +# Back to vtk +import vtk +from vtk.util import vtkImageImportFromArray as vtkutil +f = vtkutil.vtkImageImportFromArray() +f.SetArray( numpyArray ) +f.Update() +imageData = f.GetOutput() + +print("imageData.__this__=" + str(imageData.__this__)) + +newComponent = camitk.ImageComponent("test from scratch") +newComponent.replaceImageData(imageData) +newComponent.setSelected(True) + +camitk.Application.refresh() + + +*/ + +/** + * Demo 7 + * + * +import numpy as np +import vtk +from vtk.util.numpy_support import vtk_to_numpy +vtkImage = target.getImageData() +dim1,dim2,dim3 = vtkImage.GetDimensions() +vtkArray = vtkImage.GetPointData().GetScalars() +components = vtkArray.GetNumberOfComponents() + +arr = vtk_to_numpy(vtkArray).reshape(dim3,dim2,dim1) + +# to itk +import itk +itkImage = itk.GetImageFromArray(arr) + +# filter +dimension = 3 +pixelType = itk.UC +imageType = itk.Image[pixelType, dimension] +meanFilter = itk.MeanImageFilter[imageType, imageType].New() +meanFilter.SetInput(itkImage) +meanFilter.SetRadius(5) + +outputItkImage = meanFilter.GetOutput() +numpyArray = itk.GetArrayFromImage(outputItkImage) + +# Back to vtk +import vtk +from vtk.util import vtkImageImportFromArray as vtkutil +f = vtkutil.vtkImageImportFromArray() +f.SetArray( numpyArray ) +f.Update() +imageData = f.GetOutput() + +print("imageData.__this__=" + str(imageData.__this__)) + +# Back to CamiTK +newComponent = camitk.ImageComponent("test from scratch") +newComponent.replaceImageData(imageData) +newComponent.setSelected(True) + +camitk.Application.refresh() + +*/ const QStringList pythonScript = scriptTextEdit->toPlainText().trimmed().split(QLatin1Char('\n'), QString::SkipEmptyParts); bool result = runScript(pythonScript); @@ -170,7 +419,7 @@ void PythonScripting::initPython() { Py_Initialize(); - const bool pythonInitialized = true; //PyInit_PyCamiTK() != nullptr; + const bool pythonInitialized = true; const bool pyErrorOccurred = PyErr_Occurred() != nullptr; if (pythonInitialized && !pyErrorOccurred) { @@ -201,13 +450,20 @@ bool PythonScripting::runScript(const QStringList& script) { // Concatenating all the lines QString content; QTextStream ss(&content); + ss << "import traceback\n"; ss << "try:\n"; for (const QString& line : script) ss << " " << line << "\n"; ss << "except Exception:\n"; + ss << " print(\"Exception in \" + sys.argv[0] + \":\")\n"; + ss << " print(sys.exc_info()[0])\n"; + ss << " print()\n"; ss << " print(traceback.format_exc())\n"; ss << " print(sys.exc_info()[0])\n"; + // import doc + // https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html + //this is python code to redirect stdout/stderr, see extending FAQ https://docs.python.org/3/faq/extending.html and https://stackoverflow.com/q/46632488 std::string stdOutErr = "import sys\n" @@ -225,25 +481,43 @@ bool PythonScripting::runScript(const QStringList& script) { // "sys.path.append('.')\n" "sys.path.append('" + Core::getInstallDirectories("lib").at(0).toStdString() + "')\n" + "from PyCamiTK import camitk\n"; - - PyObject* pModule = PyImport_AddModule("__main__"); //create main module + + PyObject* pythonModule = PyImport_AddModule("__main__"); //create main module + PyRun_SimpleString(stdOutErr.c_str()); // invoke code to redirect -// PyObject * hashlibModule = PyImport_ImportModule("PyCamiTK"); + static SbkConverter* converter = Shiboken::Conversions::getConverter("ImageComponent"); + if (!converter) { + CAMITK_WARNING("Failed to create converter for ImageComponent") + return false; + } + + PyObject *pythonImageComponent = Shiboken::Conversions::pointerToPython(converter, getTargets().last()); + + if (pythonImageComponent == nullptr) { + CAMITK_WARNING("Failed to create wrapper for ImageComponent") + return false; + } + Py_INCREF(pythonImageComponent); + + if (PyModule_AddObject(pythonModule, "target", pythonImageComponent) < 0) { + if (PyErr_Occurred()) + PyErr_Print(); + CAMITK_WARNING("Failed add object \"target\" to __main__") + return false; + } // Executing the whole script as one line const QByteArray line = content.toUtf8(); int runResult = PyRun_SimpleString(line.constData()); - PyObject* pythonOutput = PyObject_GetAttrString(pModule, "pythonOutput"); + PyObject* pythonOutput = PyObject_GetAttrString(pythonModule, "pythonOutput"); if (pythonOutput == nullptr) { CAMITK_WARNING("Cannot get pythonOutput object.") return false; } - //PyErr_Print(); // make python print any errors - PyObject* pythonOutputValue = PyObject_GetAttrString(pythonOutput, "value"); if (pythonOutputValue == nullptr) { CAMITK_WARNING("Cannot get pythonStdOuput data.") @@ -281,15 +555,6 @@ bool PythonScripting::runScript(const QStringList& script) { } } - /* - PyObject* strUTF8 = PyUnicode_AsUTF8String(output); - // Py_DECREF(thisAttr); - - const char* str = //PyUnicode_AsEncodedString(strUTF8); //PyBytes_AS_STRING(strUTF8); - - CAMITK_INFO(tr("Here's the output:%1").arg(QString(str))) - */ - CAMITK_INFO(tr("Python Output:\n=========\n%1=========").arg(QString(catcherData))) return true; diff --git a/tutorials/actions/pythonscripting/PythonScripting.h b/tutorials/actions/pythonscripting/PythonScripting.h index 6e6b63a2..c3576e96 100644 --- a/tutorials/actions/pythonscripting/PythonScripting.h +++ b/tutorials/actions/pythonscripting/PythonScripting.h @@ -23,8 +23,8 @@ * $CAMITK_LICENCE_END$ ****************************************************************************/ -#ifndef IMAGE_PICKING_H -#define IMAGE_PICKING_H +#ifndef PYTHON_SCRIPTING_H +#define PYTHON_SCRIPTING_H #include class QPlainTextEdit; @@ -64,4 +64,4 @@ private: bool runScript(const QStringList &); }; -#endif // IMAGE_PICKING_H +#endif // PYTHON_SCRIPTING_H -- GitLab From 61f89decd2f0d28af2cee4d8922d20722d9ecd50 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Mon, 25 Mar 2019 11:02:59 +0100 Subject: [PATCH 17/24] NEW PyCamiTK installation now install all required files and link --- python/CMakeLists.txt | 164 ++++++++---------- .../actions/pythonscripting/CMakeLists.txt | 44 +---- 2 files changed, 80 insertions(+), 128 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e62374af..41050ec6 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -11,7 +11,7 @@ # TODO add an install target to install the PyCamiTK python module in the right place for system wide installation # as well as locally -# cmake ../src/camitk -DCMAKE_BUILD_TYPE=Debug -DCAMITK_BINDING_PYTHON=TRUE -DCEP_IMAGING=FALSE -DCEP_TUTORIALS=FALSE -DCEP_MODELING=FALSE +# cmake ../../src/camitk -DCMAKE_BUILD_TYPE=Debug -DCAMITK_BINDING_PYTHON=TRUE -DCEP_IMAGING=FALSE -DCEP_TUTORIALS=TRUE -DCEP_MODELING=FALSE # make -j6 # make camitk-ce-python-package # python3 ../src/camitk/python/test.py @@ -325,6 +325,14 @@ link_directories(${CAMITK_LINK_DIRECTORIES}) # Define and build the bindings library. add_library(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} MODULE ${${CAMITK_PYTHON_BIDINGS_MODULE_NAME}_SOURCES}) +# add add_dependencies to CamiTK core +# Using target_link_libraries(..) is enough to link the extension to the CamiTK core library +if(CAMITK_COMMUNITY_EDITION_BUILD) + add_dependencies(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} ${CAMITK_CORE_TARGET_LIB_NAME}) + # add the dependency to the core automoc target only if inside a SDK build + set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} APPEND PROPERTY AUTOGEN_TARGET_DEPENDS ${CAMITK_CORE_TARGET_LIB_NAME}) +endif() + # Apply relevant include and link flags. target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYTHON3_INCLUDE_DIRS}) target_include_directories(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PRIVATE ${PYSIDE_INCLUDE_DIR}) @@ -390,99 +398,75 @@ else() ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CAMITK_BUILD_PUBLIC_LIB_DIR} ) endif() -# if(WIN32) -# set_property(TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTY SUFFIX ".pyd") -# endif() -# -# # Make sure the linker doesn't complain about not finding Python symbols on macOS. -# if(APPLE) -# set_target_properties(${CAMITK_PYTHON_BIDINGS_MODULE_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") -# endif() -# -# # Find and link to the python import library only on Windows. -# # On Linux and macOS, the undefined symbols will get resolved by the dynamic linker -# # (the symbols will be picked up in the Python executable). -# if (WIN32) -# list(GET python_linking_data 0 python_libdir) -# list(GET python_linking_data 1 python_lib) -# find_library(python_link_flags ${python_lib} PATHS ${python_libdir} HINTS ${python_libdir}) -# target_link_libraries(${bindings_library} PRIVATE ${python_link_flags}) -# endif() - - -# Wrap the CamiTK SDK. Wrapping uses Shiboken (PySide binding tool) -# It means it decorates the specified C++ classes to Python by adding -# information in order to convert it into a CPython extension -# Shiboken parses the typesystem.xml files to detect which C++ classes to expose to Python -# For each of them, it create a CPython C++ decorated class in the build directory -# add_custom_target(camitk-ce-python-wrapping -# # COMMAND ${CMAKE_COMMAND} -E echo "Cleaning C++ classes generated from previous wrapping." -# # COMMAND ${CMAKE_COMMAND} -E remove_directory python -# COMMAND ${CMAKE_COMMAND} -E echo "Wrapping CamiTK SDK for Python exposure." -# COMMAND ${SHIBOKEN2} ${SHIBOKEN_OPTIONS} -# ${CAMITK_PYTHON_WRAPPED_HEADER} # wrap header -# ${CAMITK_PYTHON_TYPESYSTEM_FILE} # type system -# COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK wrapped." -# ) -# add_dependencies(camitk-ce-python-wrapping action-application) # need a first build to wrap -# -# # The resulting C++ wrapped classes will be listed in the following CMake variable: -# file(GLOB_RECURSE SDK_WRAPPED_CLASSES ${CMAKE_BINARY_DIR}/python/camitk/*.cpp ) -# -# # We list the CamiTK SDK generated dynamic libraries for linking the python package -# # TODO do not manually list those libraries, but dynamically create this list at configuration -# # step, using CamiTK CMake macros -# file(GLOB_RECURSE CAMITK_SDK_LIBRARIES ${CMAKE_BINARY_DIR}/*.so) -# # message(WARNING "CAMITK_SDK_LIBRARIES = ${CAMITK_SDK_LIBRARIES}") -# -# # This CMake target aims at compiling the C++ Python-wrapped classes of CamiTK and link them against -# # the original CamiTK SDK libraries. -# # WARNING Do not manually run this target, it requires another configure step which is run by the camitk-sdk-package-to-python -# # CMake target. -# if(NOT SDK_WRAPPED_CLASSES STREQUAL "") # only create sdk_python target if camitk sdk has been wrapped -# set(PROJECT_NAME sdk_python) # the name of the camitk sdk package once compiled -# string(REPLACE ":" ";" CAMITK_SDK_INCLUDE_DIR ${SHIBOKEN_CAMITK_SDK_PATH}) # deduce the list of include directories of CamiTK SDK -# string(REPLACE ":" ";" PYSIDE_INCLUDE_ALL_DIR ${PYSIDE_INCLUDE_DIR}) #deduce the list of include directories provided from PySide / Shiboken -# # Qt libraries dependencies -# set(QT_LIBRARIES "${QT_QTCORE_LIBRARY};${QT_QTGUI_LIBRARY}") -# # message(WARNING "QT_LIBRARIES = ${QT_LIBRARIES}") -# set(CAMITK_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/../sdk/libraries/core -# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/mesh/basicmesh -# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/arbitraryslice ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/cropvolume -# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/imagelut -# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/multipicking ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/reconstruction -# ${CMAKE_CURRENT_BINARY_DIR}/../sdk/actions/image/volumerendering -# ) #build directories required for ui wrapping includes ! -# -# include_directories(${PROJECT_NAME} ${CAMITK_SDK_INCLUDE_DIR} ${PYSIDE_INCLUDE_ALL_DIR} ${SHIBOKEN_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${VTK_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ${CAMITK_BUILD_DIR}) -# add_library(${PROJECT_NAME} SHARED ${SDK_WRAPPED_CLASSES}) -# # # set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") -# set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "") -# target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${VTK_LIBRARIES} ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} ${CAMITK_SDK_LIBRARIES}) -# # WARNING check VTK dependency -# # message(WARNING "SHIBOKEN_PYTHON_LIBRARIES = ${SHIBOKEN_PYTHON_LIBRARIES}") -# # message(WARNING "SHIBOKEN_LIBRARY = ${SHIBOKEN_LIBRARY}") -# # add_dependencies(${PROJECT_NAME} camitkcore) -# endif() -# -# # Create the Python package of CamiTK SDK -# # This package is compiled from the generated C++ classes of the camitk-ce-python-wrapping target -# # and link against the CamiTK SDK libraries. -# # Build the custom camitk-ce-python-package target in order to compile the wrapped C++ classes and link against -# # CamiTK SDK dynamic libraries. -# add_custom_target(camitk-ce-python-package -# COMMAND ${CMAKE_COMMAND} -E echo "Creating Python package of CamiTK SDK." -# # COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -# COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target sdk_python -# COMMAND ${CMAKE_COMMAND} -E echo "CamiTK SDK Python package created." -# ) -# add_dependencies(camitk-ce-python-package camitk-ce-python-wrapping) # need all to wrapped before creating the package -# Indicate where to install the python library +#-- install +# During installation, where to install the python library install(TARGETS ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} # TODO proper python lib installation RUNTIME DESTINATION lib - LIBRARY DESTINATION lib + LIBRARY DESTINATION lib #NAMELINK_ONLY ARCHIVE DESTINATION lib COMPONENT ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} ) +# During installation, add a symlink so that C++ actions can link to the Python CamiTK binding lib +if(CMAKE_HOST_UNIX) + install(CODE "execute_process(COMMAND ln -s ${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so lib${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so + WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)" + ) +endif() + +#-- During build-time install, also add symlink from PyCamiTK.so to libPyCamiTK.so in order to be able to link against libPyCamiTK.so +# (e.g. in action that requires python bindings) +if(CMAKE_HOST_UNIX) + # add symlink so that C++ actions can link to the Python CamiTK binding lib + if(NOT IS_SYMLINK lib${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so) + add_custom_command( TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} + POST_BUILD + COMMAND ln -s ${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so lib${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so + WORKING_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} + COMMENT "Creating build-time symlink to lib${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so" + VERBATIM + ) + endif() +endif() + +#-- install binding file +# Check for python dir directory +set(PYTHON_TYPESYSTEM_DEST_DIR share/${CAMITK_SHORT_VERSION_STRING}/python) +set(CAMITK_BUILD_PYTHON_TYPESYSTEM_DIR ${CAMITK_BUILD_DIR}/${PYTHON_TYPESYSTEM_DEST_DIR}) +if (NOT EXISTS ${CAMITK_BUILD_PYTHON_TYPESYSTEM_DIR}) + make_directory( ${CAMITK_BUILD_PYTHON_TYPESYSTEM_DIR} ) +endif() + +# At build-time copy the files to the python typesystem directory +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CAMITK_PYTHON_TYPESYSTEM_FILE} ${CAMITK_BUILD_PYTHON_TYPESYSTEM_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +# During installation, copy the files to install directory +install(FILES ${CAMITK_PYTHON_TYPESYSTEM_FILE} + DESTINATION ${PYTHON_TYPESYSTEM_DEST_DIR} +) + +#-- install python binding header file +set(PYTHON_HEADER_DEST_DIR include/${CAMITK_SHORT_VERSION_STRING}/python) +set(CAMITK_BUILD_PYTHON_HEADER_DIR ${CAMITK_BUILD_DIR}/${PYTHON_HEADER_DEST_DIR}) +if (NOT EXISTS ${CAMITK_BUILD_PYTHON_HEADER_DIR}) + make_directory(${CAMITK_BUILD_PYTHON_HEADER_DIR}) +endif() + +# At build-time copy the files to the python wrapping header directory +set(CAMITK_PYTHON_WRAPPING_HEADER_FILE ${CMAKE_CURRENT_BINARY_DIR}/${CAMITK_PYTHON_BIDINGS_MODULE_NAME}/pycamitk_python.h) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CAMITK_PYTHON_WRAPPING_HEADER_FILE} ${CAMITK_BUILD_PYTHON_HEADER_DIR} +# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) + +# During installation, copy the files to install directory +install(FILES ${CAMITK_PYTHON_WRAPPING_HEADER_FILE} + DESTINATION ${PYTHON_HEADER_DEST_DIR} +) + + + + + diff --git a/tutorials/actions/pythonscripting/CMakeLists.txt b/tutorials/actions/pythonscripting/CMakeLists.txt index 7bd5342f..7283683d 100644 --- a/tutorials/actions/pythonscripting/CMakeLists.txt +++ b/tutorials/actions/pythonscripting/CMakeLists.txt @@ -73,51 +73,19 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ${PYSIDE_TYPESYSTEMS} ${SHIBOKEN_TYPESYSTEM_PATH}) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - camitk_extension(ACTION_EXTENSION INCLUDE_DIRECTORIES ${PYTHON3_INCLUDE_DIRS} ${PYSIDE_INCLUDE_DIR} ${PYSIDE_INCLUDE_DIR}/QtCore ${SHIBOKEN_INCLUDE_DIR} EXTERNAL_LIBRARIES ${PYSIDE_LIBRARY} ${SHIBOKEN_PYTHON_LIBRARIES} ${SHIBOKEN_LIBRARY} # to avoid syntax errors in Python object.h due to the usage of the word "slot" (Same as CONFIG += no_keywords) DEFINES QT_NO_KEYWORDS -# EXTERNAL_LIBRARIES -) - -# TODO add everything necessary to find this library -# link_directories(${CAMITK_BUILD_PUBLIC_LIB_DIR}) -# message(FATAL_ERROR "$$$ ${CAMITK_BUILD_PRIVATE_LIB_DIR}/python") -set(PYCAMITK_LIBRARY_NAME "PyCamiTK") -# transform PyCamiTK.so to libPyCamiTK.so has to be present as well as PyCamiTK.so -find_library( - PYCAMITK_LIB - NAMES lib${PYCAMITK_LIBRARY_NAME}.so # what to look for - HINTS "${CAMITK_BUILD_PUBLIC_LIB_DIR}" # where to look - NO_DEFAULT_PATH # do not search system default paths ) -# check if we found the library -message(STATUS "PYCAMITK_LIB: [${PYCAMITK_LIB}]") - -if (NOT PYCAMITK_LIB) - message(SEND_ERROR "Did not find lib PyCamiTK") +# TODO add a "NEEDS_PYCAMITK" option flag to the camitk_extension +if(CAMITK_COMMUNITY_EDITION_BUILD) + # Because we are in the same CEP set, use the target instead of the find_library(..) + set(CAMITK_PYTHON_BIDINGS_MODULE_NAME "PyCamiTK") + target_link_libraries(${ACTION_TARGET_NAME} $) + add_dependencies(${ACTION_TARGET_NAME} ${CAMITK_PYTHON_BIDINGS_MODULE_NAME}) endif() -# -# add_library(PYCAMITK UNKNOWN IMPORTED) -# # if (MSVC) -# # # not CAMITK_BUILD_BIN_DIR / CAMITK_BUILD_PRIVATE_LIB_DIR -# # set(PYCAMITK_LIBRARY_PATH "${CAMITK_BUILD_PUBLIC_LIB_DIR}/${PYCAMITK_LIBRARY_NAME}.so") -# # else() -# # # not CAMITK_BUILD_PUBLIC_LIB_DIR / CAMITK_BUILD_PRIVATE_LIB_DIR -# # set(PYCAMITK_LIBRARY_PATH "${CAMITK_BUILD_PUBLIC_LIB_DIR}/${PYCAMITK_LIBRARY_NAME}.so") -# # endif() -# set_property(TARGET PYCAMITK PROPERTY IMPORTED_LOCATION "${PYCAMITK_LIB}") -# set_property(TARGET PYCAMITK PROPERTY IMPORTED_SONAME "${PYCAMITK_LIBRARY_NAME}.so") - -target_link_libraries(${ACTION_TARGET_NAME} ${PYCAMITK_LIB}) - -# Find and link to the python library. -# list(GET PYTHON_LINKING_DATA 0 PYTHON_LIBDIR) -# list(GET PYTHON_LINKING_DATA 1 PYTHON_LIB) -# find_library(PYTHON_LINK_FLAGS ${PYTHON_LIB} PATHS ${PYTHON_LIBDIR} HINTS ${PYTHON_LIBDIR}) -# target_link_libraries(${ACTION_TARGET_NAME} ${PYTHON_LINK_FLAGS}) endif() # CAMITK_BINDING_PYTHON -- GitLab From 5883e2e793092043c5bebc46c994fa8fe1f003c4 Mon Sep 17 00:00:00 2001 From: Jean-Loup Haberbusch Date: Fri, 29 Mar 2019 11:20:31 +0100 Subject: [PATCH 18/24] UPDATED fail regular compilation fixed --- imaging/actions/itkfilters/AnisotropicDiffusion.cpp | 2 +- modeling/actions/pml/CreateSC.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/imaging/actions/itkfilters/AnisotropicDiffusion.cpp b/imaging/actions/itkfilters/AnisotropicDiffusion.cpp index 835db967..5e81a641 100644 --- a/imaging/actions/itkfilters/AnisotropicDiffusion.cpp +++ b/imaging/actions/itkfilters/AnisotropicDiffusion.cpp @@ -98,7 +98,7 @@ AnisotropicDiffusion::AnisoDiffType AnisotropicDiffusion::getDiffusionType() { // --------------- apply ------------------- Action::ApplyStatus AnisotropicDiffusion::apply() { for(Component *child : getTargets()) { - ImageComponent* input = dynamic_cast(comp); + ImageComponent* input = dynamic_cast(child); process(input); } return SUCCESS; diff --git a/modeling/actions/pml/CreateSC.h b/modeling/actions/pml/CreateSC.h index ce1a62ab..fe74d2a8 100644 --- a/modeling/actions/pml/CreateSC.h +++ b/modeling/actions/pml/CreateSC.h @@ -27,6 +27,8 @@ #define CREATESC_H #include +#include +#include class PMLComponent; -- GitLab From 58268ac7b498c3ac2bf743e6715a4f1967cc6596 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Fri, 29 Mar 2019 18:15:06 +0100 Subject: [PATCH 19/24] FIXED logger test (one line was added in the source code) --- .../testlogger/log-default-linux.log | 40 +++++++++---------- .../testlogger/log-default-win.log | 40 +++++++++---------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tutorials/applications/testlogger/log-default-linux.log b/tutorials/applications/testlogger/log-default-linux.log index 4d609493..63cc857b 100644 --- a/tutorials/applications/testlogger/log-default-linux.log +++ b/tutorials/applications/testlogger/log-default-linux.log @@ -40,9 +40,9 @@ WARNING message: WARNING_IF(true) message: WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -69,14 +69,14 @@ INFO message: INFO_IF(true) message: INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -102,19 +102,19 @@ TRACE message: TRACE_IF(true) message: TRACE_IF(false) silent message: INFO message: -[INFO ] [printLog@main.cpp:52] Test Log: INFO +[INFO ] [printLog@main.cpp:53] Test Log: INFO INFO_IF(true) message: -[INFO ] [printLog@main.cpp:55] Test Log: INFO_IF +[INFO ] [printLog@main.cpp:56] Test Log: INFO_IF INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -141,24 +141,24 @@ Log level "TRACE": begin test... With debug information: [TRACE ] [virtual void camitk::CamiTKLogger::setDebugInformation(bool)@CamiTKLogger.cpp:223] Logging debug information: true TRACE message: -[TRACE ] [printLog@main.cpp:43] Test Log: TRACE +[TRACE ] [printLog@main.cpp:44] Test Log: TRACE TRACE_IF(true) message: -[TRACE ] [printLog@main.cpp:46] Test Log: TRACE_IF +[TRACE ] [printLog@main.cpp:47] Test Log: TRACE_IF TRACE_IF(false) silent message: INFO message: -[INFO ] [printLog@main.cpp:52] Test Log: INFO +[INFO ] [printLog@main.cpp:53] Test Log: INFO INFO_IF(true) message: -[INFO ] [printLog@main.cpp:55] Test Log: INFO_IF +[INFO ] [printLog@main.cpp:56] Test Log: INFO_IF INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: [TRACE ] Logging debug information: false diff --git a/tutorials/applications/testlogger/log-default-win.log b/tutorials/applications/testlogger/log-default-win.log index 8b584140..ac19eb29 100644 --- a/tutorials/applications/testlogger/log-default-win.log +++ b/tutorials/applications/testlogger/log-default-win.log @@ -40,9 +40,9 @@ WARNING message: WARNING_IF(true) message: WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -69,14 +69,14 @@ INFO message: INFO_IF(true) message: INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -102,19 +102,19 @@ TRACE message: TRACE_IF(true) message: TRACE_IF(false) silent message: INFO message: -[INFO ] [printLog@main.cpp:52] Test Log: INFO +[INFO ] [printLog@main.cpp:53] Test Log: INFO INFO_IF(true) message: -[INFO ] [printLog@main.cpp:55] Test Log: INFO_IF +[INFO ] [printLog@main.cpp:56] Test Log: INFO_IF INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: TRACE message: @@ -141,24 +141,24 @@ Log level "TRACE": begin test... With debug information: [TRACE ] [void __cdecl camitk::CamiTKLogger::setDebugInformation(bool)@CamiTKLogger.cpp:223] Logging debug information: true TRACE message: -[TRACE ] [printLog@main.cpp:43] Test Log: TRACE +[TRACE ] [printLog@main.cpp:44] Test Log: TRACE TRACE_IF(true) message: -[TRACE ] [printLog@main.cpp:46] Test Log: TRACE_IF +[TRACE ] [printLog@main.cpp:47] Test Log: TRACE_IF TRACE_IF(false) silent message: INFO message: -[INFO ] [printLog@main.cpp:52] Test Log: INFO +[INFO ] [printLog@main.cpp:53] Test Log: INFO INFO_IF(true) message: -[INFO ] [printLog@main.cpp:55] Test Log: INFO_IF +[INFO ] [printLog@main.cpp:56] Test Log: INFO_IF INFO_IF(false) silent message: WARNING message: -[WARNING] [printLog@main.cpp:61] Test Log: WARNING +[WARNING] [printLog@main.cpp:62] Test Log: WARNING WARNING_IF(true) message: -[WARNING] [printLog@main.cpp:64] Test Log: WARNING_IF +[WARNING] [printLog@main.cpp:65] Test Log: WARNING_IF WARNING_IF(false) silent message: ERROR message: -[ERROR ] [printLog@main.cpp:70] Test Log: ERROR +[ERROR ] [printLog@main.cpp:71] Test Log: ERROR ERROR_IF(true) message: -[ERROR ] [printLog@main.cpp:73] Test Log: ERROR_IF +[ERROR ] [printLog@main.cpp:74] Test Log: ERROR_IF ERROR_IF(false) silent message: Without debug information: [TRACE ] Logging debug information: false -- GitLab From ecdcb6ccdb4c86b840f270797ba8f96ed6b176cd Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Sun, 31 Mar 2019 11:53:36 +0200 Subject: [PATCH 20/24] NEW print timestamp (=date) at each step of the gitlab pipeline --- .gitlab/before.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitlab/before.sh b/.gitlab/before.sh index 58d24968..2b284064 100755 --- a/.gitlab/before.sh +++ b/.gitlab/before.sh @@ -61,9 +61,14 @@ else OS_FULL_NAME="Win7" fi QT_VERSION=$(qmake --version | grep Qt | cut -f4 -d" " ) +TIMESTAMP=$(date) # output all information to report file -echo "Docker container id....... $CONTAINER_ID" > /tmp/report.txt +echo > /tmp/report.txt +echo "-------------------------------------------------" >> /tmp/report.txt +echo >> /tmp/report.txt +echo "Time stamp................ $TIMESTAMP" >> /tmp/report.txt +echo "Docker container id....... $CONTAINER_ID" >> /tmp/report.txt echo "Job....................... $CI_JOB_NAME" >> /tmp/report.txt echo "PROJECT_SOURCE_DIR........ $PROJECT_SOURCE_DIR" >> /tmp/report.txt echo "CI_PROJECT_DIR............ $CI_PROJECT_DIR" >> /tmp/report.txt @@ -77,6 +82,9 @@ echo "" >> /tmp/report.txt echo "OS Full Name.............. $OS_FULL_NAME" >> /tmp/report.txt echo "CMake Version............. $CMAKE_VERSION" >> /tmp/report.txt echo "Qt Version................ $QT_VERSION" >> /tmp/report.txt +echo >> /tmp/report.txt +echo "-------------------------------------------------" >> /tmp/report.txt +echo >> /tmp/report.txt # cleanup log directory if [ -d ${PROJECT_LOG_DIR} ] ; then -- GitLab From e257eab8ea515b49892671dde2d9981f5bbe11a3 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Wed, 10 Apr 2019 11:05:05 +0200 Subject: [PATCH 21/24] FIXED crash when deleting ImageComponent This was a side effect of commit 5fe00345, a Qt foreach loop was replaced by a C++11 foreach loop but in a case where the loop over a QList was also deleteing the QList elements little by little) --- sdk/actions/application/CloseAction.cpp | 15 ++++++++------- sdk/libraries/core/application/Application.cpp | 17 +++++++++-------- sdk/libraries/core/application/Application.h | 8 +++++--- sdk/libraries/core/component/Component.cpp | 4 ++-- .../core/component/image/ImageComponent.h | 2 +- .../actions/pythonscripting/PythonScripting.cpp | 14 ++++++++++---- .../actions/pythonscripting/PythonScripting.h | 3 +++ 7 files changed, 38 insertions(+), 25 deletions(-) diff --git a/sdk/actions/application/CloseAction.cpp b/sdk/actions/application/CloseAction.cpp index 76abcdff..4dea6552 100644 --- a/sdk/actions/application/CloseAction.cpp +++ b/sdk/actions/application/CloseAction.cpp @@ -66,14 +66,15 @@ Action::ApplyStatus CloseAction::apply() { allTopLevel.insert(comp->getTopLevelComponent()); } - // close all - QSet::const_iterator it = allTopLevel.constBegin(); - - while (it != allTopLevel.constEnd() && Application::close(*it)) { - it++; + // close 'em all + ComponentList allUniqueTopLevel = allTopLevel.toList(); + bool continueClosing = true; + while (continueClosing && allUniqueTopLevel.size() > 0) { + Component* comp = allUniqueTopLevel.takeFirst(); + continueClosing = Application::close(comp); } - - if (it == allTopLevel.constEnd()) { + + if (continueClosing) { return SUCCESS; } else { diff --git a/sdk/libraries/core/application/Application.cpp b/sdk/libraries/core/application/Application.cpp index 4e725c91..6eacbe5f 100644 --- a/sdk/libraries/core/application/Application.cpp +++ b/sdk/libraries/core/application/Application.cpp @@ -193,6 +193,14 @@ Application::~Application() { delete propertyObject; } + if (translator) { + delete translator; //delete instance of internationalization support + } + + // delete all actions (they are instantiated when the extension is loaded) + CAMITK_INFO(tr("Unloading actions...")) + ExtensionManager::unloadAllActionExtensions(); + // finish all logging properly CAMITK_INFO(tr("Exiting application...")) } @@ -206,13 +214,6 @@ QString Application::getName() { void Application::quitting() { // this is connect to the aboutToQuit signal from QApplication // it should contain all the code that frees the resources - - // delete all actions (they are instantiated when the extension is loaded) - ExtensionManager::unloadAllActionExtensions(); - - if (translator) { - delete translator; //delete instance of internationalization support - } } // ----------------- notify -------------------- @@ -913,7 +914,7 @@ void Application::clearSelectedComponents() { for (Component* comp : getSelectedComponentList()) { comp->setSelected(false); } - + getSelectedComponentList().clear(); } diff --git a/sdk/libraries/core/application/Application.h b/sdk/libraries/core/application/Application.h index 71e71e89..cb6f0ee6 100644 --- a/sdk/libraries/core/application/Application.h +++ b/sdk/libraries/core/application/Application.h @@ -354,9 +354,10 @@ public: */ static PropertyObject* getPropertyObject(); ///}@ - + private Q_SLOTS: - void quitting(); + /// This slot is connected to the aboutToQuit() signal and cleanup before quitting + static void quitting(); private: /// name of the CamiTK application (used to differentiate settings between CamiTK applications) @@ -370,7 +371,7 @@ private: /// argv given from command line static char** argv; - + /// @name Recent document management ///@{ /// list of all the remembered recent documents (last opened is last inserted!) @@ -516,6 +517,7 @@ protected: * Each time a property has dynamically changed, this method is called. */ bool eventFilter(QObject* object, QEvent* event) override; + }; diff --git a/sdk/libraries/core/component/Component.cpp b/sdk/libraries/core/component/Component.cpp index 86d1e3a8..08698205 100644 --- a/sdk/libraries/core/component/Component.cpp +++ b/sdk/libraries/core/component/Component.cpp @@ -568,12 +568,12 @@ void Component::removeChild(InterfaceNode* childNode) { void Component::deleteChildren() { // calling clear() on a QSet does not delete the instances // (the destuctor of points is not called, the Component are not deleted from the memory) - for (Component* childComp : childrenComponent) { + while(childrenComponent.size() > 0) { + Component* childComp = childrenComponent.takeFirst(); if (Application::isAlive(childComp)) { delete childComp; } } - childrenComponent.clear(); } // -------------------- setGlyphType -------------------- diff --git a/sdk/libraries/core/component/image/ImageComponent.h b/sdk/libraries/core/component/image/ImageComponent.h index 80843153..1eb49586 100644 --- a/sdk/libraries/core/component/image/ImageComponent.h +++ b/sdk/libraries/core/component/image/ImageComponent.h @@ -91,7 +91,7 @@ public: ImageComponent(vtkSmartPointer anImageData, const QString& name, bool copy = false, ImageOrientationHelper::PossibleImageOrientations initialOrientation = ImageOrientationHelper::RAI); /// Destructor - ~ImageComponent() override; + virtual ~ImageComponent() override; /// set selected will select all the Image components (axial, sagittal and coronal). void setSelected(const bool b, const bool recursive = false) override; diff --git a/tutorials/actions/pythonscripting/PythonScripting.cpp b/tutorials/actions/pythonscripting/PythonScripting.cpp index 2c71db74..165b2e38 100644 --- a/tutorials/actions/pythonscripting/PythonScripting.cpp +++ b/tutorials/actions/pythonscripting/PythonScripting.cpp @@ -58,6 +58,7 @@ PythonScripting::PythonScripting(ActionExtension* extension) : Action(extension) //-- init Python module pythonScriptingIsAvailable = false; + pythonInitialized = false; } // --------------- getWidget ------------------- @@ -82,9 +83,14 @@ QWidget* PythonScripting::getWidget() { // --------------- destructor ------------------- PythonScripting::~PythonScripting() { - // As we are not using qAddPostRoutine(cleanup) in initPython() - // just call this manually here - Py_Finalize(); + + if (pythonInitialized) { + // Only do this if the python scripting was initialized + // As we are not using qAddPostRoutine(cleanup) in initPython() + // just call this manually here + + Py_Finalize(); + } } @@ -419,7 +425,7 @@ void PythonScripting::initPython() { Py_Initialize(); - const bool pythonInitialized = true; + pythonInitialized = true; const bool pyErrorOccurred = PyErr_Occurred() != nullptr; if (pythonInitialized && !pyErrorOccurred) { diff --git a/tutorials/actions/pythonscripting/PythonScripting.h b/tutorials/actions/pythonscripting/PythonScripting.h index c3576e96..803cbd61 100644 --- a/tutorials/actions/pythonscripting/PythonScripting.h +++ b/tutorials/actions/pythonscripting/PythonScripting.h @@ -60,6 +60,9 @@ private: /// current state of python bool pythonScriptingIsAvailable; + /// is python environment initialized + bool pythonInitialized; + /// run the script in python (each python line of code is an QString in the list) bool runScript(const QStringList &); }; -- GitLab From 8522077a7bd1110aa2978e1ab50f960d125fd6e3 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Wed, 10 Apr 2019 11:30:02 +0200 Subject: [PATCH 22/24] NEW interactive python scripting! Just use pycamitk.py and start interacting with a camitk app! --- python/CMakeLists.txt | 21 ++++-- python/PythonBindings.xml | 82 +++++++++++++++++++- python/pycamitk.py | 67 ++++++++++++++++ python/test.py | 155 +++++++++++++++++++------------------- 4 files changed, 239 insertions(+), 86 deletions(-) create mode 100644 python/pycamitk.py diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 41050ec6..6dc3c105 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -408,23 +408,30 @@ install(TARGETS ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} ARCHIVE DESTINATION lib COMPONENT ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} ) + +set(PYCAMITK_LIB_FILENAME ${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so) +set(PYCAMITK_LIB_PREFIXED_FILENAME lib${PYCAMITK_LIB_FILENAME}) + # During installation, add a symlink so that C++ actions can link to the Python CamiTK binding lib if(CMAKE_HOST_UNIX) - install(CODE "execute_process(COMMAND ln -s ${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so lib${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so - WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)" - ) + if(NOT IS_SYMLINK ${CMAKE_INSTALL_PREFIX}/lib/${PYCAMITK_LIB_PREFIXED_FILENAME}) + install(CODE "execute_process(COMMAND ln -s ${PYCAMITK_LIB_FILENAME} ${PYCAMITK_LIB_PREFIXED_FILENAME} + WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib + COMMENT \"Creating install-time symlink to ${PYCAMITK_LIB_PREFIXED_FILENAME}\")" + ) + endif() endif() #-- During build-time install, also add symlink from PyCamiTK.so to libPyCamiTK.so in order to be able to link against libPyCamiTK.so # (e.g. in action that requires python bindings) if(CMAKE_HOST_UNIX) - # add symlink so that C++ actions can link to the Python CamiTK binding lib - if(NOT IS_SYMLINK lib${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so) + if(NOT IS_SYMLINK ${CAMITK_BUILD_PUBLIC_LIB_DIR}/${PYCAMITK_LIB_PREFIXED_FILENAME}) + # add symlink so that C++ actions can link to the Python CamiTK binding lib add_custom_command( TARGET ${CAMITK_PYTHON_BIDINGS_MODULE_NAME} POST_BUILD - COMMAND ln -s ${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so lib${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so + COMMAND ln -s ${PYCAMITK_LIB_FILENAME} ${PYCAMITK_LIB_PREFIXED_FILENAME} WORKING_DIRECTORY ${CAMITK_BUILD_PUBLIC_LIB_DIR} - COMMENT "Creating build-time symlink to lib${CAMITK_PYTHON_BIDINGS_MODULE_NAME}.so" + COMMENT "Creating build-time symlink to ${PYCAMITK_LIB_PREFIXED_FILENAME}" VERBATIM ) endif() diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index 29eb8805..55ffec35 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -207,7 +207,87 @@ static void ApplicationConstructor(PyObject* self, PyObject* pyargv, Application PySide::registerCleanupFunction(&PySide::destroyQCoreApplication); } } - + + + +// +// this code is greatly inspired by the Michiel de Hoon post on the PyQt mailing list: +// https://riverbankcomputing.com/pipermail/pyqt/2007-July/016512.html +// Read this link for a complete explaination about the mechanism +// +// see also see https://docs.python.org/3/c-api/veryhigh.html +// for an explaination about the function pointer PyOS_InputHook of Python + +#include <QCoreApplication> +#include <QThread> + +#if defined(Q_OS_WIN) +#include <conio.h> +#include <QTimer> +#else +#include <QSocketNotifier> +#endif + +// Declare the hook in the pure C space +extern "C" { + static int backgroundExec(); +} + +/// Run the Qt event loop while there is no keyboard input +static int backgroundExec() { + // check if the application singleton was instanciated in the currentthread + QCoreApplication *app = QCoreApplication::instance(); + + if (app && app->thread() == QThread::currentThread()) { +#if defined(Q_OS_WIN) + // on Windows, sockets are not directly linked to the console stdin as on Unix + // therefore a specific timer is required + QTimer timer; + QObject::connect(&timer, SIGNAL(timeout()), app, SLOT(quit())); + + while (!_kbhit()) { + // Run exec and wait for input + timer.start(50); + QCoreApplication::exec(); + timer.stop(); + } + + QObject::disconnect(&timer, SIGNAL(timeout()), app, SLOT(quit())); +#else + // file descriptor #0 on unix is stdin + QSocketNotifier notifier(0, QSocketNotifier::Read, 0); + QObject::connect(&notifier, SIGNAL(activated(int)), app, SLOT(quit())); + QCoreApplication::exec(); + QObject::disconnect(&notifier, SIGNAL(activated(int)), app, SLOT(quit())); +#endif + } + + return 0; +} + +/// Remove the input hook in Python +static void pyCamiTKStopBackgroundExec() { + PyOS_InputHook = 0; +} + +// Add the input hook in Python +static void pyCamiTKStartBackgroundExec() { + // Restore the input hook. + PyOS_InputHook = backgroundExec; +} + + + + + pyCamiTKStartBackgroundExec(); + + + + + pyCamiTKStopBackgroundExec(); + + + diff --git a/python/pycamitk.py b/python/pycamitk.py new file mode 100644 index 00000000..19261211 --- /dev/null +++ b/python/pycamitk.py @@ -0,0 +1,67 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +# In order to use the console +# Either +# 1) cd to where this script is located and type "import pycamitk" in the python3 console +# or +# 2) type "import sys", "sys.pat.append('/path/to/this/script')", "import pycamitk" in the python3 console + +import sys + +## Add the python subdir in order to be able to load PyCamiTK +sys.path.append('.') +sys.path.append('./lib') +sys.path.append('/tmp/camitk/build/camitk/lib') + +## list CamiTK python bindings exported classes +from PyCamiTK import camitk + +from PySide2.QtCore import Qt, QTimer # for Qt.LeftDockWidgetArea +from PySide2.QtWidgets import QApplication, QAction, QMenu, QMainWindow + +#if __name__ == '__main__': +print("Setting log...") + +camitk.Log.getLogger().setTimeStampInformation(True) +camitk.Log.getLogger().setMessageBoxLevel(camitk.InterfaceLogger.NONE) +camitk.Log.getLogger().setLogLevel(camitk.InterfaceLogger.TRACE) + +print("CamiTK version: " + camitk.Core.version) + +app = camitk.Application(sys.argv) +app.getMainWindow().setCentralViewer(camitk.MedicalImageViewer.getInstance()) +app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.Explorer.getInstance()) +app.getMainWindow().addDockViewer(Qt.LeftDockWidgetArea, camitk.PropertyExplorer.getInstance()) +app.getMainWindow().addDockViewer(Qt.RightDockWidgetArea, camitk.ActionViewer.getInstance()) + +fileMenu = QMenu("&File"); +action = camitk.Application.getAction("Open") +fileMenu.addAction(action.getQAction()) +action = camitk.Application.getAction("Close") +fileMenu.addAction(action.getQAction()) +action= camitk.Application.getAction("Quit") +fileMenu.addAction(action.getQAction()) + +## help +helpMenu = QMenu("&Help") +action = camitk.Application.getAction("About...") +helpMenu.addAction(action.getQAction()) + +## add everything in the menu bar +mainWindow = app.getMainWindow() +appMenuBar = mainWindow.menuBar() +appMenuBar.addMenu(fileMenu) +appMenuBar.addSeparator() +appMenuBar.addMenu(helpMenu) + +# show and start exec loop +app.getMainWindow().show() +app.startBackgroundExec() + +print(camitk.Core.getConfig()) + +print("You can start interacting using PyCamiTK:") +print("from PyCamiTK import camitk") +print("comp = camitk.Application.open(camitk.Core.getTestDataDir() + \"/brain.mha\")") + diff --git a/python/test.py b/python/test.py index 82483e99..0df06133 100644 --- a/python/test.py +++ b/python/test.py @@ -17,7 +17,7 @@ import traceback # Add the python subdir in order to be able to load PyCamiTK import sys sys.path.append('.') -sys.path.append('./python') +sys.path.append('./lib') # list CamiTK python bindings exported classes from PyCamiTK import camitk @@ -74,8 +74,6 @@ def generateSphere(imageDimension): if __name__ == "__main__": print("\nTry...\n") try: - # TODO segmentation fault with Explorer - print("Setting log...") camitk.Log.getLogger().setTimeStampInformation(True) @@ -122,87 +120,88 @@ if __name__ == "__main__": comp = camitk.Application.open(camitk.Core.getTestDataDir() + "/brain.mha") - print("Name of component: " + comp.getName()) + + #print("Name of component: " + comp.getName()) - imageDimension = eval(comp.property("Image Dimensions")) # dim - print("Original image dimension: " + str(imageDimension)) - print("Voxel type: " + comp.property("Voxel Data Type")) - - #imageData = vtk.vtkImageData() - #imageData.SetDimensions(dim[0], dim[1], dim[2]) - #imageData.AllocateScalars(vtk.VTK_UNSIGNED_CHAR, 1) - - #dims = imageData.GetDimensions() - #radius = math.sqrt(dims[2]*dims[2] + dims[1]*dims[1] + dims[0]*dims[0])/4.0 - #print("Image half size radius:" + str(radius)) - #halfDims = [x / 2 for x in dims] - - # Fill every entry of the image data with '2.0' - #inside = 0 - #outside = 1 - #i = 0 - #for z in range(dims[2]): - #for y in range(dims[1]): - #for x in range(dims[0]): - #pos = [x-halfDims[0],y-halfDims[1],z-halfDims[2]] - #posSquare = math.sqrt(pos[2]*pos[2] + pos[1]*pos[1] + pos[0]*pos[0]) - #if (posSquare < radius): - #inside+=1 - #value = -127.0 - #else: - #outside+=1 - #value = 127.0 - #i+=1 - ##imageData.SetScalarComponentFromDouble(x, y, z, 0, value) - #imageData.GetPointData().GetScalars().SetTuple1(i, value) - ##imageData.SetScalarComponentFromDouble(x, y, z, 0, 42.0) - - - #imageData = generateSphere(imageDimension) - - # compute radius and center from imageDimension - radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 - center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) - - # 3D array - semisizes = (radius,) * 3 - - # generate the grid for the support points - # centered at the position indicated by center - grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] - center = np.ogrid[grid] - # calculate the distance of all points from center - # scaled by the radius - arr = np.zeros(imageDimension, dtype=float) - for x_i, semisize in zip(center, semisizes): - arr += (np.abs(x_i / semisize) ** 2) - # the inner part of the sphere will have distance below 1 - #return arr <= 1.0 - - # generate vtkImage from an array - f = vtkutil.vtkImageImportFromArray() - f.SetArray( arr ) - #f.SetDataOrigin( ... ) - #f.SetDataSpacing( ... ) - #f.SetDataExtent( ... ) - f.Update() - imageData = f.GetOutput() - - #print("inside=" + str(inside) + ", outside=" + str(outside) + ", inside/outside=" + str(inside/outside)) - #print("imageData=" + str(imageData)) - print("imageData.__this__=" + str(imageData.__this__)) -#print("comp=" + str(comp)) - - backupImageData = comp.getImageData() - print("backup image data =" + str(backupImageData)) + #imageDimension = eval(comp.property("Image Dimensions")) # dim + #print("Original image dimension: " + str(imageDimension)) + #print("Voxel type: " + comp.property("Voxel Data Type")) + + ##imageData = vtk.vtkImageData() + ##imageData.SetDimensions(dim[0], dim[1], dim[2]) + ##imageData.AllocateScalars(vtk.VTK_UNSIGNED_CHAR, 1) + + ##dims = imageData.GetDimensions() + ##radius = math.sqrt(dims[2]*dims[2] + dims[1]*dims[1] + dims[0]*dims[0])/4.0 + ##print("Image half size radius:" + str(radius)) + ##halfDims = [x / 2 for x in dims] + + ## Fill every entry of the image data with '2.0' + ##inside = 0 + ##outside = 1 + ##i = 0 + ##for z in range(dims[2]): + ##for y in range(dims[1]): + ##for x in range(dims[0]): + ##pos = [x-halfDims[0],y-halfDims[1],z-halfDims[2]] + ##posSquare = math.sqrt(pos[2]*pos[2] + pos[1]*pos[1] + pos[0]*pos[0]) + ##if (posSquare < radius): + ##inside+=1 + ##value = -127.0 + ##else: + ##outside+=1 + ##value = 127.0 + ##i+=1 + ###imageData.SetScalarComponentFromDouble(x, y, z, 0, value) + ##imageData.GetPointData().GetScalars().SetTuple1(i, value) + ###imageData.SetScalarComponentFromDouble(x, y, z, 0, 42.0) + + + ##imageData = generateSphere(imageDimension) + + ## compute radius and center from imageDimension + #radius = math.sqrt(imageDimension[2]*imageDimension[2] + imageDimension[1]*imageDimension[1] + imageDimension[0]*imageDimension[0])/4.0 + #center = (imageDimension[0]/2, imageDimension[1]/2, imageDimension[2]/2) + + ## 3D array + #semisizes = (radius,) * 3 + + ## generate the grid for the support points + ## centered at the position indicated by center + #grid = [slice(-x0, dim - x0) for x0, dim in zip(center, imageDimension)] + #center = np.ogrid[grid] + ## calculate the distance of all points from center + ## scaled by the radius + #arr = np.zeros(imageDimension, dtype=float) + #for x_i, semisize in zip(center, semisizes): + #arr += (np.abs(x_i / semisize) ** 2) + ## the inner part of the sphere will have distance below 1 + ##return arr <= 1.0 + + ## generate vtkImage from an array + #f = vtkutil.vtkImageImportFromArray() + #f.SetArray( arr ) + ##f.SetDataOrigin( ... ) + ##f.SetDataSpacing( ... ) + ##f.SetDataExtent( ... ) + #f.Update() + #imageData = f.GetOutput() + + ##print("inside=" + str(inside) + ", outside=" + str(outside) + ", inside/outside=" + str(inside/outside)) + ##print("imageData=" + str(imageData)) + #print("imageData.__this__=" + str(imageData.__this__)) +##print("comp=" + str(comp)) + + #backupImageData = comp.getImageData() + #print("backup image data =" + str(backupImageData)) - comp.replaceImageData(imageData) #setVtkImageData + #comp.replaceImageData(imageData) #setVtkImageData - # add a new component + ## add a new component - print("Number of opened top level components: " + str(len(app.getTopLevelComponents()))) + #print("Number of opened top level components: " + str(len(app.getTopLevelComponents()))) #comp.setSelected(True) app.refresh() -- GitLab From 9c6bd1fb7f0c6f0c0e3f4bb0cb5f0d32e3e6130f Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Thu, 11 Apr 2019 09:50:48 +0200 Subject: [PATCH 23/24] NEW Frame class accessible in Python --- python/CMakeLists.txt | 5 +- python/PythonBindings.h | 2 +- python/PythonBindings.xml | 3 +- python/pycamitk.py | 3 +- python/pyside2_config.py | 302 -------------------------------------- python/utils.py | 49 ------- 6 files changed, 7 insertions(+), 357 deletions(-) delete mode 100755 python/pyside2_config.py delete mode 100755 python/utils.py diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6dc3c105..6bd4d22d 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -259,6 +259,7 @@ set(CAMITK_PYTHON_CLASS_NAMES Core InterfaceFrame ComponentExtension Component + Frame ImageComponent # RendererWidget # InteractiveViewer @@ -416,8 +417,8 @@ set(PYCAMITK_LIB_PREFIXED_FILENAME lib${PYCAMITK_LIB_FILENAME}) if(CMAKE_HOST_UNIX) if(NOT IS_SYMLINK ${CMAKE_INSTALL_PREFIX}/lib/${PYCAMITK_LIB_PREFIXED_FILENAME}) install(CODE "execute_process(COMMAND ln -s ${PYCAMITK_LIB_FILENAME} ${PYCAMITK_LIB_PREFIXED_FILENAME} - WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib - COMMENT \"Creating install-time symlink to ${PYCAMITK_LIB_PREFIXED_FILENAME}\")" + WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)" + CODE "message(STATUS \"Creating install-time symlink to ${PYCAMITK_LIB_PREFIXED_FILENAME}\")" ) endif() endif() diff --git a/python/PythonBindings.h b/python/PythonBindings.h index 451f4afd..ccb958a9 100644 --- a/python/PythonBindings.h +++ b/python/PythonBindings.h @@ -87,7 +87,7 @@ #include #include #include -// Frame.h +#include // SimplisticComponent.h // Geometry.h #include diff --git a/python/PythonBindings.xml b/python/PythonBindings.xml index 55ffec35..1233717a 100644 --- a/python/PythonBindings.xml +++ b/python/PythonBindings.xml @@ -651,7 +651,8 @@ if(vtk_object->IsA(class_name)) { - + + diff --git a/python/pycamitk.py b/python/pycamitk.py index 19261211..1b36bb85 100644 --- a/python/pycamitk.py +++ b/python/pycamitk.py @@ -12,7 +12,7 @@ import sys ## Add the python subdir in order to be able to load PyCamiTK sys.path.append('.') sys.path.append('./lib') -sys.path.append('/tmp/camitk/build/camitk/lib') +sys.path.append('/usr/local/lib') ## list CamiTK python bindings exported classes from PyCamiTK import camitk @@ -20,7 +20,6 @@ from PyCamiTK import camitk from PySide2.QtCore import Qt, QTimer # for Qt.LeftDockWidgetArea from PySide2.QtWidgets import QApplication, QAction, QMenu, QMainWindow -#if __name__ == '__main__': print("Setting log...") camitk.Log.getLogger().setTimeStampInformation(True) diff --git a/python/pyside2_config.py b/python/pyside2_config.py deleted file mode 100755 index 298d40d5..00000000 --- a/python/pyside2_config.py +++ /dev/null @@ -1,302 +0,0 @@ -############################################################################# -## -## Copyright (C) 2018 The Qt Company Ltd. -## Contact: http://www.qt.io/licensing/ -## -## This file is part of the Qt for Python examples of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:BSD$ -## You may use this file under the terms of the BSD license as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# - -import os, glob, re, sys, imp -from distutils import sysconfig - -usage = """ -Utility to determine include/link options of PySide2 and Python for qmake - -Usage: pyside2_config.py [option] -Options: - --python-include Print Python include path - --python-link Print Python link flags - --pyside2 Print PySide2 location - --pyside2-include Print PySide2 include paths - --pyside2-link Print PySide2 link flags - --pyside2-shared-libraries Print paths of PySide2 shared libraries (.so's, .dylib's, .dll's) - -a Print all - --help/-h Print this help -""" - -def cleanPath(path): - return path if sys.platform != 'win32' else path.replace('\\', '/') - -def sharedLibrarySuffix(): - if sys.platform == 'win32': - return 'lib' - elif sys.platform == 'darwin': - return 'dylib' - # Linux - else: - return 'so.*' - -def sharedLibraryGlobPattern(): - glob = '*.' + sharedLibrarySuffix() - return glob if sys.platform == 'win32' else 'lib' + glob - -def filterPySide2SharedLibraries(list, only_shiboken=False): - def predicate(item): - basename = os.path.basename(item) - if 'shiboken' in basename or ('pyside2' in basename and not only_shiboken): - return True - return False - result = [item for item in list if predicate(item)] - return result - -# Return qmake link option for a library file name -def linkOption(lib): - # On Linux: - # Since we cannot include symlinks with wheel packages - # we are using an absolute path for the libpyside and libshiboken - # libraries when compiling the project - baseName = os.path.basename(lib) - link = ' -l' - if sys.platform in ['linux', 'linux2']: # Linux: 'libfoo.so' -> '/absolute/path/libfoo.so' - link = lib - elif sys.platform in ['darwin']: # Darwin: 'libfoo.so' -> '-lfoo' - link += os.path.splitext(baseName[3:])[0] - else: # Windows: 'libfoo.dll' -> 'libfoo.dll' - link += os.path.splitext(baseName)[0] - return link - -# Locate PySide2 via package path -def findPySide2(): - for p in sys.path: - if 'site-' in p: - pyside2 = os.path.join(p, 'PySide2') - if os.path.exists(pyside2): - return cleanPath(os.path.realpath(pyside2)) - return None - -# Return version as "3.5" -def pythonVersion(): - return str(sys.version_info[0]) + '.' + str(sys.version_info[1]) - -def pythonInclude(): - return sysconfig.get_python_inc() - -def pythonLinkQmake(): - flags = pythonLinkData() - if sys.platform == 'win32': - libdir = flags['libdir'] - # This will add the "~1" shortcut for directories that - # contain white spaces - # e.g.: "Program Files" to "Progra~1" - for d in libdir.split("\\"): - if " " in d: - libdir = libdir.replace(d, d.split(" ")[0][:-1]+"~1") - return '-L{} -l{}'.format(libdir, flags['lib']) - elif sys.platform == 'darwin': - return '-L{} -l{}'.format(flags['libdir'], flags['lib']) - - else: - # Linux and anything else - return '-L{} -l{}'.format(flags['libdir'], flags['lib']) - -def pythonLinkCmake(): - flags = pythonLinkData() - libdir = flags['libdir'] - lib = re.sub(r'.dll$', '.lib', flags['lib']) - return '{};{}'.format(libdir, lib) - -def pythonLinkData(): - # @TODO Fix to work with static builds of Python - libdir = sysconfig.get_config_var('LIBDIR') - if libdir is None: - libdir = os.path.abspath(os.path.join( - sysconfig.get_config_var('LIBDEST'), "..", "libs")) - version = pythonVersion() - version_no_dots = version.replace('.', '') - - flags = {} - flags['libdir'] = libdir - if sys.platform == 'win32': - suffix = '_d' if any([tup[0].endswith('_d.pyd') for tup in imp.get_suffixes()]) else '' - flags['lib'] = 'python{}{}'.format(version_no_dots, suffix) - - elif sys.platform == 'darwin': - flags['lib'] = 'python{}'.format(version) - - # Linux and anything else - else: - if sys.version_info[0] < 3: - suffix = '_d' if any([tup[0].endswith('_d.so') for tup in imp.get_suffixes()]) else '' - flags['lib'] = 'python{}{}'.format(version, suffix) - else: - flags['lib'] = 'python{}{}'.format(version, sys.abiflags) - - return flags - -def pyside2Include(only_shiboken=False): - pySide2 = findPySide2() - if pySide2 is None: - return None - - includes = "{0}/include/shiboken2".format(pySide2) - if not only_shiboken: - includes = includes + " {0}/include/PySide2".format(pySide2) - - return includes - -def pyside2Link(): - pySide2 = findPySide2() - if pySide2 is None: - return None - link = "-L{}".format(pySide2) - glob_result = glob.glob(os.path.join(pySide2, sharedLibraryGlobPattern())) - for lib in filterPySide2SharedLibraries(glob_result): - link += ' ' - link += linkOption(lib) - return link - -def pyside2SharedLibrariesData(only_shiboken=False): - pySide2 = findPySide2() - if pySide2 is None: - return None - - glob_result = glob.glob(os.path.join(pySide2, sharedLibraryGlobPattern())) - filtered_libs = filterPySide2SharedLibraries(glob_result, only_shiboken) - libs = [] - if sys.platform == 'win32': - for lib in filtered_libs: - libs.append(os.path.realpath(lib)) - else: - for lib in filtered_libs: - libs.append(lib) - return libs - -def pyside2SharedLibraries(): - libs = pyside2SharedLibrariesData() - if libs is None: - return None - - if sys.platform == 'win32': - if not libs: - return '' - dlls = '' - for lib in libs: - dll = os.path.splitext(lib)[0] + '.dll' - dlls += dll + ' ' - - return dlls - else: - libs_string = '' - for lib in libs: - libs_string += lib + ' ' - return libs_string - -def pyside2SharedLibrariesCmake(only_shiboken=False): - libs = pyside2SharedLibrariesData(only_shiboken) - result = ';'.join(libs) - return result - -option = sys.argv[1] if len(sys.argv) == 2 else '-a' -if option == '-h' or option == '--help': - print(usage) - sys.exit(0) - -generic_error = (' Did you forget to activate your virtualenv? Or perhaps' - ' you forgot to build / install PySide2 into your currently active Python' - ' environment?') -pyside2_error = 'Unable to locate PySide2.' + generic_error -pyside2_libs_error = 'Unable to locate the PySide2 shared libraries.' + generic_error -python_link_error = 'Unable to locate the Python library for linking.' - -if option == '--pyside2' or option == '-a': - pySide2 = findPySide2() - if pySide2 is None: - sys.exit(pyside2_error) - print(pySide2) - -if option == '--pyside2-link' or option == '-a': - l = pyside2Link() - if l is None: - sys.exit(pyside2_error) - - print(l) - -if option == '--shiboken-include' or option == '-a': - i = pyside2Include(only_shiboken=True) - if i is None: - sys.exit(pyside2_error) - print(i) - -if option == '--pyside2-include' or option == '-a': - i = pyside2Include() - if i is None: - sys.exit(pyside2_error) - print(i) - -if option == '--python-include' or option == '-a': - i = pythonInclude() - if i is None: - sys.exit('Unable to locate the Python include headers directory.') - print(i) - -if option == '--python-link' or option == '-a': - l = pythonLinkQmake() - if l is None: - sys.exit(python_link_error) - print(l) - -if option == '--python-link-cmake' or option == '-a': - l = pythonLinkCmake() - if l is None: - sys.exit(python_link_error) - print(l) - -if option == '--pyside2-shared-libraries' or option == '-a': - l = pyside2SharedLibraries() - if l is None: - sys.exit(pyside2_libs_error) - print(l) - -if option == '--pyside2-shared-libraries-cmake' or option == '-a': - l = pyside2SharedLibrariesCmake() - if l is None: - sys.exit(pyside2_libs_error) - print(l) - -if option == '--shiboken-shared-libraries-cmake' or option == '-a': - l = pyside2SharedLibrariesCmake(only_shiboken=True) - if l is None: - sys.exit(pyside2_libs_error) - print(l) diff --git a/python/utils.py b/python/utils.py deleted file mode 100755 index 522f5356..00000000 --- a/python/utils.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/python - -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: http://www.qt.io/licensing/ -## -## This file is part of the Qt for Python examples of the Qt Toolkit. -## -## $QT_BEGIN_LICENSE:BSD$ -## You may use this file under the terms of the BSD license as follows: -## -## "Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## * Redistributions of source code must retain the above copyright -## notice, this list of conditions and the following disclaimer. -## * Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimer in -## the documentation and/or other materials provided with the -## distribution. -## * Neither the name of The Qt Company Ltd nor the names of its -## contributors may be used to endorse or promote products derived -## from this software without specific prior written permission. -## -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -## -## $QT_END_LICENSE$ -## -############################################################################# - -import sys -isPY3 = sys.version_info[0] == 3 - -if isPY3: - text_type = str -else: - text_type = unicode -- GitLab From 5ef059bc2e9d36e03b16cea20a12cf637ac26094 Mon Sep 17 00:00:00 2001 From: Emmanuel Promayon Date: Tue, 7 May 2019 20:23:40 +0200 Subject: [PATCH 24/24] ADD a comment to ref to a blog post --- python/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6bd4d22d..c1a0505b 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -8,6 +8,8 @@ # #-------------------------------------------- +# check https://machinekoder.com/pyqt-vs-qt-for-python-pyside2-pyside/ for a comparison between PyQt and PySide + # TODO add an install target to install the PyCamiTK python module in the right place for system wide installation # as well as locally -- GitLab