Commit 1a2714db authored by saubatn's avatar saubatn

FEATURE 144 : Python binding of IMP works !

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1197 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 80f48df3
......@@ -27,6 +27,9 @@ endif()
find_package(Qt4 REQUIRED)
find_package(PySide REQUIRED)
# TEST Using VTK dependency
find_package(VTK REQUIRED)
#--------------------------------------------
#
# Recursively parse subdirectories for classes to expose
......@@ -58,7 +61,7 @@ add_subdirectory(libraries)
# 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
#:${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
......@@ -72,7 +75,7 @@ set(PYSIDE_INCLUDE_ALL_DIR_SHIBOKEN
add_custom_target( sdk_wrap_to_python
# OUTPUT ${lib_python_SRC}
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
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}
--typesystem-paths=${PYSIDE_TYPESYSTEMS}:${SHIBOKEN_TYPESYSTEM_PATH}
......@@ -100,14 +103,20 @@ if(NOT SDK_WRAPPED_CLASSES STREQUAL "") # only create camitk_sdk target if camit
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
# message(WARNING "CAMITK_SDK_INCLUDE_DIR = ${CAMITK_SDK_INCLUDE_DIR}")
# message(WARNING "PYSIDE_INCLUDE_ALL_DIR = ${PYSIDE_INCLUDE_ALL_DIR}")
include_directories(${PROJECT_NAME} ${CAMITK_SDK_INCLUDE_DIR} ${PYSIDE_INCLUDE_ALL_DIR} ${SHIBOKEN_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} ${PYSIDE_INCLUDE_ALL_DIR_CPP} ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR})
add_library(${PROJECT_NAME} MODULE ${SDK_WRAPPED_CLASSES}) # TODO test if SHARED library type generation works
# Qt libraries dependencies
set(QT_LIBRARIES "${QT_QTCORE_LIBRARY};${QT_QTGUI_LIBRARY}")
# message(WARNING "QT_LIBRARIES = ${QT_LIBRARIES}")
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})
add_library(${PROJECT_NAME} SHARED ${SDK_WRAPPED_CLASSES}) # TODO test if SHARED library type generation works
# # set_property(TARGET ${PROJECT_NAME} PROPERTY PREFIX "")
target_link_libraries(${PROJECT_NAME} ${CAMITK_SDK_LIBRARIES})
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()
endif()
# Create the Python package of CamiTK SDK
......
<?xml version="1.0"?>
<typesystem>
<!-- CamiTK sdk classes exposition to Python -->
<object-type name="ImpMainWindow" />
</typesystem>
</typesystem>
// local header files
#include <MainWindow.h>
#include <Application.h>
<?xml version="1.0"?>
<typesystem>
<!-- CamiTK sdk classes exposition to Python -->
<object-type name="camitk::MainWindow" />
<object-type name="camitk::Application">
<!-- Modfiying Application constructor for the argc, argv typical entries -->
<modify-function signature="Application(QString, int &amp;, char **, bool, bool)">
<modify-argument index="2">
<replace-type modified-type="PySequence" />
</modify-argument>
<modify-argument index="3">
<remove-argument />
</modify-argument>
<!-- Make the correspondance C++ (argc, argv) <-> Python (argv) -->
<inject-code class="target" position="beginning">
int argc;
char** argv;
if (!Shiboken::sequenceToArgcArgv(%PYARG_2, &amp;argc, &amp;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
camitk::%CPPTYPE* app = new %FUNCTION_NAME(%1, argc, argv, %4, %5);
delete app;
%0 = new %CPPTYPEWrapper(%1, argc, argv, %4, %5);
delete[] argv;
</inject-code>
</modify-function>
</object-type>
</typesystem>
// local header files
#include <Component.h>
#include <InterfaceNode.h>
#include <InterfaceBitMap.h>
#include <InterfaceGeometry.h>
#include <InterfaceProperty.h>
<?xml version="1.0"?>
<typesystem>
<!-- CamiTK sdk classes exposition to Python -->
<!-- <object-type name="camitk::Component" />
<enum-type name="camitk::Component::Representation" />
<object-type name="camitk::InterfaceNode" />
<object-type name="camitk::InterfaceBitMap" />
<enum-type name="camitk::InterfaceBitMap::PossibleOrientation" />
<object-type name="camitk::InterfaceGeometry" />
<enum-type name="camitk::InterfaceGeometry::EnhancedMode" />
<enum-type name="camitk::InterfaceGeometry::RenderingMode" />
<enum-type name="camitk::InterfaceGeometry::GlyphType" />
<object-type name="camitk::InterfaceProperty" />-->
</typesystem>
......@@ -6,5 +6,5 @@
#include "./viewer/global_sdk_libraries_core_viewer.h"
// include here the classes you want to be exposed to Python for sdk/library/core
#include <ExtensionManager.h>
......@@ -7,5 +7,8 @@
<load-typesystem name="typesystem_sdk_libraries_core_utils.xml" generate="yes" />
<load-typesystem name="typesystem_sdk_libraries_core_viewer.xml" generate="yes" />
<!-- Add here C++ Classes to expose to Python -->S
<!-- Add here C++ Classes to expose to Python -->
<object-type name="camitk::ExtensionManager" />
<enum-type name="camitk::ExtensionManager::ExtensionType" />
</typesystem>
<?xml version="1.0"?>
<typesystem>
<!-- CamiTK sdk classes exposition to Python -->
<!-- <object-type name="camitk::Viewer" /> -->
</typesystem>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment