Commit bb0d4eb5 authored by jcfr's avatar jcfr
Browse files

COMP: Superbuild - Added advanced option Slicer3_USE_PYTHONQT_WITH_TCL

Waiting the TCL adapter layer is fully functional (see below), the Slicer3_USE_PYTHONQT_WITH_TCL
option is OFF and remains (for now) an advanced feature.

See http://www.cdash.org/CDash/index.php?project=Slicer3&date=2010-08-11
Dashboard are still complaining :(

git-svn-id: http://svn.slicer.org/Slicer4/trunk@14551 3bd1e089-480b-0410-8dfb-8563597acbee
parent cdd1407a
......@@ -15,13 +15,20 @@ SET(Slicer_PYTHON_FILES
slicer/remoteio
slicer/slicerqt
slicer/vtk/__init__
tpycl/__init__
tpycl/tpycl
)
SET(Slicer_PYTHON_RESOURCES
tpycl/tpycl.tcl
)
IF(Slicer3_USE_PYTHONQT_WITH_TCL)
LIST(APPEND Slicer_PYTHON_FILES
tpycl/__init__
tpycl/tpycl
)
LIST(APPEND Slicer_PYTHON_RESOURCES
tpycl/tpycl.tcl
)
ENDIF()
SET(copied_python_files)
......@@ -78,5 +85,7 @@ INSTALL(DIRECTORY "${Slicer3_BINARY_DIR}/bin/Python"
# Testing
#
if(Slicer3_BUILD_TESTING)
add_subdirectory(tpycl/Testing)
IF(Slicer3_USE_PYTHONQT_WITH_TCL)
add_subdirectory(tpycl/Testing)
ENDIF()
endif(Slicer3_BUILD_TESTING)
......@@ -21,8 +21,10 @@
#include "qSlicerApplication.h"
#include "qSlicerBaseQTGUIPythonQtDecorators.h"
#ifdef Slicer3_USE_PYTHONQT_WITH_TCL
// SlicerVTK includes
#include "vtkEventBroker.h"
#endif
// PythonQt wrapper initialization methods
void PythonQt_init_org_commontk_CTKWidgets(PyObject*);
......@@ -71,6 +73,7 @@ void qSlicerPythonManager::preInitialization()
// Evaluate application script
this->executeFile(app->slicerHome() + "/bin/Python/slicer/slicerqt.py");
#ifdef Slicer3_USE_PYTHONQT_WITH_TCL
// -- event broker
// - script handler to pass callback strings to the tcl interpeter
// - synchronous mode so that redundant events do not get collapsed
......@@ -80,17 +83,20 @@ void qSlicerPythonManager::preInitialization()
reinterpret_cast<void *>(this));
vtkEventBroker::GetInstance()->SetEventModeToSynchronous();
this->addVTKObjectToPythonMain("slicer.broker", vtkEventBroker::GetInstance());
#endif
}
//-----------------------------------------------------------------------------
void qSlicerPythonManager::eventBrokerScriptHandler(const char *script, void *clientData)
{
#ifdef Slicer3_USE_PYTHONQT_WITH_TCL
QString pythonScript = QString("global _tpycl; _tpycl.tcl_callback('%1')").arg(script);
qSlicerPythonManager * self = reinterpret_cast<qSlicerPythonManager*>(clientData);
Q_ASSERT(self);
logger.setTrace();
logger.trace(QString("Running broker observation script: %1").arg(script));
self->executeString(pythonScript);
#endif
}
......@@ -242,7 +242,9 @@ if(Slicer3_USE_QT)
# Includes Qt headers
INCLUDE(${QT_USE_FILE})
option(Slicer3_USE_PYTHONQT "Integrate a python-QT interpreter into Slicer." OFF)
option(Slicer3_USE_PYTHONQT "Integrate a PythonQt interpreter into Slicer." OFF)
option(Slicer3_USE_PYTHONQT_WITH_TCL "Enable PythonQt Tcl adapter layer" OFF)
mark_as_advanced(Slicer3_USE_PYTHONQT_WITH_TCL)
else()
MESSAGE(FATAL_ERROR "error: Qt >= ${minimum_required_qt_version} was not found on your system. You probably need to set the QT_QMAKE_EXECUTABLE variable")
......@@ -358,9 +360,11 @@ set(slicer_DEPENDENCIES VTK Insight BatchMake OpenIGTLink teem cmcurl)
# Conditionnaly include ExternalProject Target
#------------------------------------------------------------------------------
include(External_Tcl)
include(External_Tk)
include(External_incrTcl)
if(Slicer3_USE_KWWIDGETS OR Slicer3_USE_PYTHONQT_WITH_TCL)
include(External_Tcl)
include(External_Tk)
include(External_incrTcl)
endif()
if(Slicer3_USE_KWWIDGETS)
include(External_iwidgets)
include(External_blt)
......@@ -479,6 +483,7 @@ ExternalProject_Add(${proj}
# Python
-DSlicer3_USE_PYTHON:BOOL=${Slicer3_USE_PYTHON}
-DSlicer3_USE_PYTHONQT:BOOL=${Slicer3_USE_PYTHONQT}
-DSlicer3_USE_PYTHONQT_WITH_TCL:BOOL=${Slicer3_USE_PYTHONQT_WITH_TCL}
-DSlicer3_USE_SYSTEM_PYTHON:BOOL=OFF
-DSlicer3_USE_NUMPY:BOOL=${Slicer3_BUILD_NUMPY}
-DPYTHON_EXECUTABLE:FILEPATH=${slicer_PYTHON_EXECUTABLE}
......
......@@ -16,15 +16,17 @@ if(WIN32)
# point the tkinter build file to the slicer tcl-build
set(python_PATCH_COMMAND)
set(python_tkinter ${python_base}/pyproject.vsprops)
string(REPLACE "/" "\\" python_tkinter ${python_tkinter})
if(Slicer3_USE_KWWIDGETS OR Slicer3_USE_PYTHONQT_WITH_TCL)
set(python_tkinter ${python_base}/pyproject.vsprops)
string(REPLACE "/" "\\" python_tkinter ${python_tkinter})
set(script ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/StringFindReplace.cmake)
set(out ${python_tkinter})
set(in ${python_tkinter})
set(script ${CMAKE_CURRENT_SOURCE_DIR}/../CMake/StringFindReplace.cmake)
set(out ${python_tkinter})
set(in ${python_tkinter})
set(python_PATCH_COMMAND
${CMAKE_COMMAND} -Din=${in} -Dout=${out} -Dfind=tcltk\" -Dreplace=tcl-build\" -P ${script})
set(python_PATCH_COMMAND
${CMAKE_COMMAND} -Din=${in} -Dout=${out} -Dfind=tcltk\" -Dreplace=tcl-build\" -P ${script})
endif()
ExternalProject_Add(${proj}
#SVN_REPOSITORY ${python_SVN_REPOSITORY}
......@@ -42,12 +44,14 @@ if(WIN32)
${python_DEPENDENCIES}
)
# this must match the version of tcl we are building for slicer.
ExternalProject_Add_Step(${proj} Patch_tcltk_version
COMMAND ${CMAKE_COMMAND} -Din=${in} -Dout=${out} -Dfind=85 -Dreplace=84 -P ${script}
DEPENDEES configure
DEPENDERS build
)
if(Slicer3_USE_KWWIDGETS OR Slicer3_USE_PYTHONQT_WITH_TCL)
# this must match the version of tcl we are building for slicer.
ExternalProject_Add_Step(${proj} Patch_tcltk_version
COMMAND ${CMAKE_COMMAND} -Din=${in} -Dout=${out} -Dfind=85 -Dreplace=84 -P ${script}
DEPENDEES configure
DEPENDERS build
)
endif()
# Convenient helper function
function(build_python_target target depend)
......@@ -64,8 +68,12 @@ if(WIN32)
build_python_target(pythoncore Build_w9xpopen)
build_python_target(_socket Build_pythoncore)
build_python_target(_tkinter Build__socket)
build_python_target(_testcapi Build__tkinter)
if(Slicer3_USE_KWWIDGETS OR Slicer3_USE_PYTHONQT_WITH_TCL)
build_python_target(_tkinter Build__socket)
build_python_target(_testcapi Build__tkinter)
else()
build_python_target(_testcapi Build__pythoncore)
endif()
build_python_target(_msi Build__testcapi)
build_python_target(_elementtree Build__msi)
......
......@@ -25,12 +25,12 @@ if(NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR)
list(APPEND VTK_DEPENDENCIES tk)
endif(NOT WIN32)
set(VTK_WRAP_TCL ON)
endif(Slicer3_USE_KWWIDGETS)
endif()
if (Slicer3_USE_PYTHONQT)
set(VTK_WRAP_PYTHON ON)
list(APPEND VTK_DEPENDENCIES python)
endif(Slicer3_USE_PYTHONQT)
endif()
set(VTK_PYTHON_ARGS)
if(Slicer3_USE_PYTHON OR Slicer3_USE_PYTHONQT)
......@@ -38,7 +38,7 @@ if(NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR)
-DPYTHON_INCLUDE_DIR:PATH=${slicer_PYTHON_INCLUDE}
-DPYTHON_LIBRARY:FILEPATH=${slicer_PYTHON_LIBRARY}
)
endif(Slicer3_USE_PYTHON OR Slicer3_USE_PYTHONQT)
endif()
# On Mac, since:
# - Qt can't be build with X11 support
......@@ -55,7 +55,7 @@ if(NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR)
-DVTK_USE_QT:BOOL=ON
-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}
)
endif(Slicer3_USE_QT)
endif()
else()
if(Slicer3_USE_KWWIDGETS AND NOT Slicer3_USE_QT)
set(VTK_QT_ARGS
......
......@@ -3,11 +3,16 @@ if(UNIX)
set(ENV{LD_LIBRARY_PATH} "@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib:@CMAKE_CURRENT_BINARY_DIR@/python-build/lib")
set(ENV{CXX} "@CMAKE_CXX_COMPILER@")
set(ENV{LDFLAGS} "-L@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib")
set(ENV{CPPFLAGS} "-I@CMAKE_CURRENT_BINARY_DIR@/tcl-build/include")
set(with_tcl_param)
if(Slicer3_USE_KWWIDGETS OR Slicer3_USE_PYTHONQT_WITH_TCL)
set(ENV{LDFLAGS} "-L@CMAKE_CURRENT_BINARY_DIR@/tcl-build/lib")
set(ENV{CPPFLAGS} "-I@CMAKE_CURRENT_BINARY_DIR@/tcl-build/include")
set(with_tcl_param "--with-tcl=@CMAKE_CURRENT_BINARY_DIR@/tcl-build")
endif()
EXECUTE_PROCESS(
COMMAND sh configure --prefix=@CMAKE_CURRENT_BINARY_DIR@/python-build --with-tcl=@CMAKE_CURRENT_BINARY_DIR@/tcl-build --enable-unicode=ucs2 --enable-shared
COMMAND sh configure --prefix=@CMAKE_CURRENT_BINARY_DIR@/python-build ${with_tcl_param} --enable-unicode=ucs2 --enable-shared
WORKING_DIRECTORY "@python_base@"
RESULT_VARIABLE rv
)
......
......@@ -26,6 +26,7 @@
#cmakedefine Slicer3_USE_NUMPY
#cmakedefine Slicer3_USE_PYTHON
#cmakedefine Slicer3_USE_PYTHONQT
#cmakedefine Slicer3_USE_PYTHONQT_WITH_TCL
#cmakedefine Slicer3_USE_OPENTRACKER
#cmakedefine Slicer3_USE_QT
#cmakedefine Slicer3_USE_KWWIDGETS
......
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