Commit a35517e8 authored by Ben Boeckel's avatar Ben Boeckel Committed by Kitware Robot
Browse files

Merge topic 'remove-sip-wrapping'

83bc3bc3

 wrapping: remove support for SIP wrapping
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: David Gobbi's avatarDavid Gobbi <david.gobbi@gmail.com>
Merge-request: !3631
parents b5984fef 83bc3bc3
......@@ -533,8 +533,6 @@ if (NOT VTK_INSTALL_NO_DEVELOPMENT)
CMake/vtkWrapperInit.data.in
CMake/vtkWrapping.cmake
CMake/vtkWrapPython.cmake
CMake/vtkWrapPythonSIP.cmake
CMake/vtkWrapPython.sip.in
CMake/vtkWrapTcl.cmake
DESTINATION ${VTK_INSTALL_PACKAGE_DIR})
......
%MappedType @VTK_CLASS@ /AllowNone, NoRelease/
{
%TypeHeaderCode
#include "@VTK_CLASS@.h"
#include "vtkPythonUtil.h"
%End
%ConvertToTypeCode
if(!sipIsErr)
{
return NULL == vtkPythonUtil::GetPointerFromObject(sipPy, "@VTK_CLASS@") ? 0 : 1;
}
*sipCppPtr = static_cast<@VTK_CLASS@*>(vtkPythonUtil::GetPointerFromObject(sipPy, "@VTK_CLASS@"));
return 0;
%End
%ConvertFromTypeCode
return vtkPythonUtil::GetObjectFromPointer(sipCpp);
%End
};
#
# a cmake implementation of the Wrap Python SIP command
# it creates bridge code for mixing vtkWrapPython code with SIP code
#
# VTK_WRAP_PYTHON_SIP takes a list of vtk source files to create sip bindings for
# it creates .sip files from a template and then creates .cxx files from those
# the .cxx files are returned from this macro
FUNCTION(VTK_WRAP_PYTHON_SIP KIT SRC_LIST_NAME SOURCES)
IF(NOT SIP_EXECUTABLE)
MESSAGE(SEND_ERROR "SIP_EXECUTABLE not specified when calling VTK_WRAP_PYTHON_SIP")
ENDIF()
# the name of the module
SET(SIP_MOD vtk${KIT}PythonSIP)
SET(SIP_OUT_SRCS)
SET(SIP_IN_SRCS)
SET(VTK_WRAPPER_INIT_DATA "%Module vtk.${SIP_MOD} 0\n\n")
# For each class
FOREACH(FILE ${SOURCES})
# should we wrap the file?
GET_SOURCE_FILE_PROPERTY(TMP_WRAP_EXCLUDE ${FILE} WRAP_EXCLUDE)
# if we should wrap it
IF (NOT TMP_WRAP_EXCLUDE)
# what is the filename without the extension
GET_FILENAME_COMPONENT(TMP_FILENAME ${FILE} NAME_WE)
# the input file might be full path so handle that
GET_FILENAME_COMPONENT(TMP_FILEPATH ${FILE} PATH)
# compute the input filename
IF (TMP_FILEPATH)
SET(TMP_INPUT ${TMP_FILEPATH}/${TMP_FILENAME}.h)
ELSE ()
SET(TMP_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${TMP_FILENAME}.h)
ENDIF ()
# new source file is namePython.cxx, add to resulting list
SET(sip_output_src sip${SIP_MOD}${TMP_FILENAME}.cpp)
SET(SIP_OUT_SRCS ${SIP_OUT_SRCS} ${sip_output_src})
SET(VTK_CLASS ${TMP_FILENAME})
SET(sip_input_src ${CMAKE_CURRENT_BINARY_DIR}/${TMP_FILENAME}Python.sip)
SET(SIP_IN_SRCS ${SIP_IN_SRCS} ${sip_input_src})
CONFIGURE_FILE(${VTK_CMAKE_DIR}/vtkWrapPython.sip.in ${sip_input_src} @ONLY)
SET(VTK_WRAPPER_INIT_DATA "${VTK_WRAPPER_INIT_DATA}%Include ${TMP_FILENAME}Python.sip\n")
ENDIF ()
ENDFOREACH()
# finish the data file for the init file
CONFIGURE_FILE(
${VTK_CMAKE_DIR}/vtkWrapperInit.data.in
${CMAKE_CURRENT_BINARY_DIR}/${SIP_MOD}.sip
@ONLY
)
SET(SIP_IN_SRCS ${SIP_IN_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/${SIP_MOD}.sip)
SET(SIP_OUT_SRCS ${SIP_OUT_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/sip${SIP_MOD}cmodule.cpp)
ADD_CUSTOM_COMMAND(
OUTPUT ${SIP_OUT_SRCS}
DEPENDS ${SIP_EXECUTABLE} ${SIP_IN_SRCS}
COMMAND ${SIP_EXECUTABLE}
ARGS -c ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${SIP_MOD}.sip
COMMENT "Python SIP Wrapping - generating for vtk${KIT}"
)
SET(${SRC_LIST_NAME} ${${SRC_LIST_NAME}} ${SIP_OUT_SRCS} PARENT_SCOPE)
ENDFUNCTION()
# create sip module library
# one is created for use within a VTK build, and another is created for use in an install tree
# all files passed in WRAP_SRCS are wrapped with sip/vtk bridge code
function(VTK_CREATE_SIP_MODULE KIT WRAP_SRCS)
IF(NOT SIP_EXECUTABLE)
MESSAGE(SEND_ERROR "SIP_EXECUTABLE not set.")
ELSE()
INCLUDE_DIRECTORIES(${SIP_INCLUDE_DIR})
VTK_WRAP_PYTHON_SIP(${KIT} KitPythonSIP_SRCS "${WRAP_SRCS}")
VTK_ADD_LIBRARY(vtk${KIT}PythonSIP MODULE ${KitPythonSIP_SRCS})
SET_TARGET_PROPERTIES(vtk${KIT}PythonSIP PROPERTIES PREFIX "" SKIP_BUILD_RPATH 1)
IF(WIN32 AND NOT CYGWIN)
SET_TARGET_PROPERTIES(vtk${KIT}PythonSIP PROPERTIES SUFFIX ".pyd")
ENDIF()
TARGET_LINK_LIBRARIES(vtk${KIT}PythonSIP vtk${KIT}PythonD)
get_target_property(lib_loc vtk${KIT}PythonSIP LOCATION)
ADD_CUSTOM_COMMAND(TARGET vtk${KIT}PythonSIP POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${lib_loc}" "${VTK_BUILD_PYTHON_MODULES_DIR}/vtk/"
)
IF(NOT VTK_INSTALL_NO_LIBRARIES)
INSTALL(TARGETS vtk${KIT}PythonSIP
EXPORT ${VTK_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${VTK_INSTALL_RUNTIME_DIR} COMPONENT RuntimeLibraries
LIBRARY DESTINATION ${VTK_INSTALL_LIBRARY_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${VTK_INSTALL_ARCHIVE_DIR} COMPONENT Development)
ENDIF()
ENDIF()
endfunction()
%MappedType QVTKInteractor /AllowNone, NoRelease/
{
%TypeHeaderCode
#include "QVTKInteractor.h"
#include "vtkPythonUtil.h"
%End
%ConvertToTypeCode
if(!sipIsErr)
{
return 1;
}
*sipCppPtr = static_cast<QVTKInteractor*>(vtkPythonUtil::GetPointerFromObject(sipPy, "QVTKInteractor"));
return 0;
%End
%ConvertFromTypeCode
return vtkPythonUtil::GetObjectFromPointer(sipCpp);
%End
};
%Import QtCore/QtCoremod.sip
%Import vtkRenderingPythonSIP.sip
class QVTKInteractorAdapter : QObject
{
%TypeHeaderCode
#include "QVTKInteractorAdapter.h"
%End
public:
QVTKInteractorAdapter(QObject* parent);
~QVTKInteractorAdapter();
bool ProcessEvent(QEvent* e, vtkRenderWindowInteractor* iren);
};
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%Import vtkRenderingPythonSIP.sip
%Include QVTKInteractor.sip
class QVTKWidget : QWidget
{
%TypeHeaderCode
#include "QVTKWidget.h"
%End
public:
QVTKWidget(QWidget* parent = nullptr, Qt::WindowFlags f = 0);
~QVTKWidget();
vtkRenderWindow* GetRenderWindow();
void SetRenderWindow(vtkRenderWindow*);
QVTKInteractor* GetInteractor();
protected:
void resizeEvent(QResizeEvent* event);
void moveEvent(QMoveEvent* event);
void paintEvent(QPaintEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);
void enterEvent(QEvent*);
void leaveEvent(QEvent*);
void wheelEvent(QWheelEvent*);
void focusInEvent(QFocusEvent*);
void focusOutEvent(QFocusEvent*);
bool event( QEvent* e );
void contextMenuEvent(QContextMenuEvent*);
void dragEnterEvent(QDragEnterEvent*);
void dragMoveEvent(QDragMoveEvent*);
void dragLeaveEvent(QDragLeaveEvent*);
void dropEvent(QDropEvent*);
};
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%Import vtkFilteringPythonSIP.sip
class vtkQtAbstractModelAdapter : QAbstractItemModel
{
%TypeHeaderCode
#include "vtkQtAbstractModelAdapter.h"
%End
public:
enum
{
FULL_VIEW,
DATA_VIEW
};
vtkQtAbstractModelAdapter(QObject* p);
virtual void SetVTKDataObject(vtkDataObject *data) = 0;
virtual vtkDataObject* GetVTKDataObject() const = 0;
virtual vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const = 0;
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const = 0;
virtual void SetViewType(int type);
virtual int GetViewType();
virtual void SetKeyColumn(int col);
virtual int GetKeyColumn();
virtual void SetKeyColumnName(const char* name) = 0;
virtual void SetColorColumn(int col);
virtual int GetColorColumn();
virtual void SetColorColumnName(const char* name) = 0;
virtual void SetDataColumnRange(int c1, int c2);
void reset();
};
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%Import vtkFilteringPythonSIP.sip
%Include vtkQtAbstractModelAdapter.sip
class vtkQtAnnotationLayersModelAdapter : vtkQtAbstractModelAdapter
{
%TypeHeaderCode
#include "vtkQtAnnotationLayersModelAdapter.h"
%End
public:
vtkQtAnnotationLayersModelAdapter(QObject *parent = 0);
vtkQtAnnotationLayersModelAdapter(vtkAnnotationLayers* ann, QObject *parent = 0);
~vtkQtAnnotationLayersModelAdapter();
virtual void SetVTKDataObject(vtkDataObject *data);
virtual vtkDataObject* GetVTKDataObject() const;
virtual vtkAnnotationLayers* QModelIndexListToVTKAnnotationLayers(const QModelIndexList qmil) const;
virtual QItemSelection VTKAnnotationLayersToQItemSelection(vtkAnnotationLayers *vtkann) const;
virtual vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const;
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const;
virtual void SetKeyColumnName(const char* name);
virtual void SetColorColumnName(const char* name);
void setAnnotationLayers(vtkAnnotationLayers* annotations);
vtkAnnotationLayers* annotationLayers() const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
};
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%Import vtkFilteringPythonSIP.sip
%Include vtkQtAbstractModelAdapter.sip
class vtkQtTableModelAdapter : vtkQtAbstractModelAdapter
{
%TypeHeaderCode
#include "vtkQtTableModelAdapter.h"
%End
public:
vtkQtTableModelAdapter(QObject *parent = 0);
vtkQtTableModelAdapter(vtkTable* table, QObject *parent = 0);
~vtkQtTableModelAdapter();
virtual void SetVTKDataObject(vtkDataObject *data);
virtual vtkDataObject* GetVTKDataObject() const;
virtual vtkSelection* QModelIndexListToVTKIndexSelection(
const QModelIndexList qmil) const;
virtual QItemSelection VTKIndexSelectionToQItemSelection(
vtkSelection *vtksel) const;
virtual void SetKeyColumnName(const char* name);
virtual void SetColorColumnName(const char* name);
void SetIconIndexColumnName(const char* name);
enum
{
HEADER = 0,
ITEM = 1
};
enum
{
COLORS = 0,
ICONS = 1,
NONE = 2
};
void SetDecorationLocation(int s);
void SetDecorationStrategy(int s);
bool GetSplitMultiComponentColumns() const;
void SetSplitMultiComponentColumns(bool value);
void setTable(vtkTable* table);
vtkTable* table() const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) ;
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
virtual QStringList mimeTypes () const ;
Qt::DropActions supportedDropActions() const;
void SetIconSheet(QImage sheet);
void SetIconSize(int w, int h);
void SetIconSheetSize(int w, int h);
};
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%Import vtkFilteringPythonSIP.sip
%Include vtkQtAbstractModelAdapter.sip
class vtkQtTreeModelAdapter : vtkQtAbstractModelAdapter
{
%TypeHeaderCode
#include "vtkQtTreeModelAdapter.h"
%End
public:
vtkQtTreeModelAdapter(QObject *parent = 0, vtkTree* tree = 0);
~vtkQtTreeModelAdapter();
virtual void SetVTKDataObject(vtkDataObject *data);
virtual vtkDataObject* GetVTKDataObject() const;
vtkMTimeType GetVTKDataObjectMTime() const;
virtual vtkSelection* QModelIndexListToVTKIndexSelection(const QModelIndexList qmil) const;
virtual QItemSelection VTKIndexSelectionToQItemSelection(vtkSelection *vtksel) const;
virtual void SetKeyColumnName(const char* name);
virtual void SetColorColumnName(const char* name);
void setTree(vtkTree* t);
vtkTree* tree() const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
Qt::DropActions supportedDragActions() const;
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
virtual QStringList mimeTypes () const ;
};
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%Import vtkCommonPythonSIP.sip
%Import vtkRenderingPythonSIP.sip
%Include QVTKInteractor.sip
class QVTKGraphicsItem : QGraphicsWidget
{
%TypeHeaderCode
#include "QVTKGraphicsItem.h"
%End
public:
QVTKGraphicsItem(QGLContext* ctx, QGraphicsItem* p = 0);
~QVTKGraphicsItem();
void SetRenderWindow(vtkGenericOpenGLRenderWindow* win);
vtkGenericOpenGLRenderWindow* GetRenderWindow() const;
QVTKInteractor* GetInteractor() const;
virtual void Update();
protected:
void MakeCurrent();
void Start();
void End();
void IsCurrent(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
void keyPressEvent(QKeyEvent* e);
void keyReleaseEvent(QKeyEvent* e);
void mousePressEvent(QGraphicsSceneMouseEvent* e);
void mouseReleaseEvent(QGraphicsSceneMouseEvent* e);
void mouseMoveEvent(QGraphicsSceneMouseEvent* e);
void resizeEvent(QGraphicsSceneResizeEvent* e);
void moveEvent(QGraphicsSceneMoveEvent* e);
void wheelEvent(QGraphicsSceneWheelEvent* e);
void hoverEnterEvent(QGraphicsSceneHoverEvent* e);
void hoverLeaveEvent(QGraphicsSceneHoverEvent* e);
void hoverMoveEvent(QGraphicsSceneHoverEvent* e);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
};
%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip
%Import QtOpenGL/QtOpenGLmod.sip
%Import vtkRenderingPythonSIP.sip
%Include QVTKInteractor.sip
class QVTKWidget2 : QGLWidget
{
%TypeHeaderCode
#include "QVTKWidget2.h"
%End
public:
QVTKWidget2(QWidget* parent = nullptr, const QGLWidget* shareWidget=0, Qt::WindowFlags f = 0);
QVTKWidget2(QGLContext* ctx, QWidget* parent = nullptr, const QGLWidget* shareWidget=0, Qt::WindowFlags f = 0);
QVTKWidget2(const QGLFormat& fmt, QWidget* parent = nullptr, const QGLWidget* shareWidget=0, Qt::WindowFlags f = 0);
~QVTKWidget2();
vtkGenericOpenGLRenderWindow* GetRenderWindow();
void SetRenderWindow(vtkGenericOpenGLRenderWindow*);
QVTKInteractor* GetInteractor();
protected:
void resizeGL(int, int);
void moveEvent(QMoveEvent*);
void paintGL();
void mousePressEvent(QMouseEvent*);
void mouseMoveEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void enterEvent(QEvent*);
void leaveEvent(QEvent*);
void keyPressEvent(QKeyEvent*);
void keyReleaseEvent(QKeyEvent*);
void wheelEvent(QWheelEvent*);
void MakeCurrent();
void Frame();
void Start();
void End();
};
......@@ -32,11 +32,7 @@ include_directories(
${VTK_SOURCE_DIR}/Utilities
)
# SIP directory will be searched before other python dirs
set(PYTHON_WRAPPING_INCLUDE_DIRS)
if(VTK_WRAP_PYTHON_SIP)
list(APPEND PYTHON_WRAPPING_INCLUDE_DIRS "${SIP_INCLUDE_DIR}")
endif()
set(${vtk-module}_SYSTEM_INCLUDE_DIRS ${PYTHON_WRAPPING_INCLUDE_DIRS})
set(${vtk-module}_NO_HeaderTest 1)
......
......@@ -961,48 +961,6 @@ int vtkPythonArgs::GetArgAsEnum(
}
//--------------------------------------------------------------------
// Define the methods for SIP objects
void *vtkPythonArgs::GetArgAsSIPObject(const char *classname, bool &valid)
{
PyObject *o = PyTuple_GET_ITEM(this->Args, this->I++);
void *r = vtkPythonArgs::GetArgAsSIPObject(o, classname, valid);
if (!valid)
{
this->RefineArgTypeError(this->I - this->M - 1);
}
return r;
}
void *vtkPythonArgs::GetArgAsSIPObject(
PyObject *o, const char *classname, bool &valid)
{
void *r = vtkPythonUtil::SIPGetPointerFromObject(o, classname);
valid = (r || !PyErr_Occurred());
return (valid ? r : nullptr);
}
int vtkPythonArgs::GetArgAsSIPEnum(const char *classname, bool &valid)
{
PyObject *o = PyTuple_GET_ITEM(this->Args, this->I++);
int i = vtkPythonArgs::GetArgAsSIPEnum(o, classname, valid);
if (!valid)
{
this->RefineArgTypeError(this->I - this->M - 1);
}
return i;
}
int vtkPythonArgs::GetArgAsSIPEnum(
PyObject *o, const char *classname, bool &valid)
{
int i = 0;
valid = (vtkPythonUtil::SIPGetPointerFromObject(o, classname) &&
vtkPythonGetValue(o, i));
return (valid ? i : 0);
}
//--------------------------------------------------------------------
// Define all the "GetValue" methods in the class.
......
......@@ -224,38 +224,6 @@ public:
return r; }
//@}
//@{
/**
* Get the next argument as a SIP object.
*/
template<class T>
bool GetSIPObject(T *&v, const char *classname) {
bool r;
v = (T *)this->GetArgAsSIPObject(classname, r);
return r; }
template<class T>
static bool GetSIPObject(PyObject *o, T *&v, const char *classname) {
bool r;
v = (T *)vtkPythonArgs::GetArgAsSIPObject(o, classname, r);
return r; }
//@}
//@{
/**
* Get the next argument as a SIP enum value.
*/
template<class T>
bool GetSIPEnumValue(T &v, const char *enumname) {
bool r;
v = static_cast<T>(this->GetArgAsSIPEnum(enumname, r));
return r; }
template<class T>
static bool GetSIPEnumValue(PyObject *o, T &v, const char *enumname) {
bool r;
v = static_cast<T>(vtkPythonArgs::GetArgAsSIPEnum(o, enumname, r));
return