From: vsr Date: Thu, 21 Jan 2021 08:33:11 +0000 (+0300) Subject: From Community Forum: libSalomePy.getRenderer() does not work X-Git-Tag: V9_7_0a1~26 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f5e9fedd434c9ef8a2fefa9c2a82715ca11f2ee4;p=modules%2Fgui.git From Community Forum: libSalomePy.getRenderer() does not work --- diff --git a/src/SALOME_PY/CMakeLists.txt b/src/SALOME_PY/CMakeLists.txt index ec5b16d43..e7825e2a0 100644 --- a/src/SALOME_PY/CMakeLists.txt +++ b/src/SALOME_PY/CMakeLists.txt @@ -62,3 +62,7 @@ IF(WIN32) ENDIF(WIN32) # TODO: check if PYTHON_ADD_MODULE() macro can be used to build this target + +# --- tests --- + +ADD_TEST(NAME GUI_libSalomePy COMMAND ${PYTHON_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/test_vtk_rendering_module.py) diff --git a/src/SALOME_PY/SalomePy.cxx b/src/SALOME_PY/SalomePy.cxx index 3bf9cf31f..3087b1eb7 100644 --- a/src/SALOME_PY/SalomePy.cxx +++ b/src/SALOME_PY/SalomePy.cxx @@ -118,7 +118,7 @@ static PyTypeObject* GetPyClass( const char* theClassName ) static PyObject* aVTKModule = 0; PyObject* aPyClass = 0; if( !aVTKModule ) { - aVTKModule = PyImport_ImportModule( "vtk.vtkRenderingCorePython" ); + aVTKModule = PyImport_ImportModule( "vtk.vtkRenderingCore" ); if( PyErr_Occurred() ) { PyErr_Print(); } @@ -221,11 +221,7 @@ public: ::GetVTKViewWindow( myCreate ? __Create : __FindOrCreate, myKeepDetached ); if( aVTKViewWindow && aPyClass ) { vtkRenderer* aVTKObject = aVTKViewWindow->getRenderer(); -#if VTK_XVERSION < 50700 - myResult = PyVTKObject_New( aPyClass, aVTKObject ); -#else myResult = PyVTKObject_FromPointer( aPyClass, NULL, aVTKObject ); -#endif } } }; @@ -276,11 +272,7 @@ public: ::GetVTKViewWindow( myCreate ? __Create : __FindOrCreate, myKeepDetached ); if( aVTKViewWindow && aPyClass ) { vtkRenderWindow* aVTKObject = aVTKViewWindow->getRenderWindow(); -#if VTK_XVERSION < 50700 - myResult = PyVTKObject_New( aPyClass, aVTKObject ); -#else myResult = PyVTKObject_FromPointer( aPyClass, NULL, aVTKObject ); -#endif } } }; @@ -331,11 +323,7 @@ public: ::GetVTKViewWindow( myCreate ? __Create : __FindOrCreate, myKeepDetached ); if( aVTKViewWindow && aPyClass ) { vtkRenderWindowInteractor* aVTKObject = aVTKViewWindow->getInteractor(); -#if VTK_XVERSION < 50700 - myResult = PyVTKObject_New( aPyClass, aVTKObject ); -#else myResult = PyVTKObject_FromPointer( aPyClass, NULL, aVTKObject ); -#endif } } }; diff --git a/src/SALOME_PY/test_vtk_rendering_module.py b/src/SALOME_PY/test_vtk_rendering_module.py new file mode 100644 index 000000000..25b466a26 --- /dev/null +++ b/src/SALOME_PY/test_vtk_rendering_module.py @@ -0,0 +1,14 @@ +import sys + +# Try importing the same VTK module as used by libSalomePy +try: + import vtk.vtkRenderingCore + ok = True +except Exception as e: + ok = False + +# VTK rendering Python module might change in newer versions of ParaView +# In this case ask developers to modify SalomePy.cxx correspondingly +if not ok: + print("VTK Rendering Python module seems to have changed, libSalomePy may not work, please correct this!") + sys.exit(1)