Salome HOME
Merge remote branch 'origin/hydro/imps_2015'
[modules/gui.git] / src / SALOME_PY / SalomePy.cxx
index 88d1f758d5b386efb832f4bd798e584f1e64dec1..65cf4ffe864f16434605f8c8c76c004267e10ce5 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -113,7 +113,7 @@ enum {
   \param theClassName Python class name
   \return Python class object or None object if class is not found
 */
-static PyObject* GetPyClass( const char* theClassName ) 
+static PyTypeObject* GetPyClass( const char* theClassName )
 {
   static PyObject* aVTKModule = 0;
   PyObject* aPyClass = 0;
@@ -134,8 +134,10 @@ static PyObject* GetPyClass( const char* theClassName )
   if ( aVTKModule ) {
     PyObject* aVTKDict = PyModule_GetDict( aVTKModule );
     aPyClass = PyDict_GetItemString(aVTKDict, const_cast<char*>( theClassName ) );
+    if (!PyType_Check(aPyClass))
+      return 0;
   }
-  return aPyClass;
+  return (PyTypeObject *)aPyClass;
 }
 
 /*!
@@ -219,7 +221,7 @@ public:
     : myResult( Py_None ), myCreate( toCreate ) {}
   virtual void Execute()
   {
-    PyObject* aPyClass = ::GetPyClass( "vtkRenderer" );
+    PyTypeObject* aPyClass = ::GetPyClass( "vtkRenderer" );
     SVTK_ViewWindow* aVTKViewWindow = 
       ::GetVTKViewWindow( myCreate ? __Create : __FindOrCreate );
     if( aVTKViewWindow && aPyClass ) {
@@ -227,7 +229,7 @@ public:
 #if VTK_XVERSION < 50700
       myResult = PyVTKObject_New( aPyClass, aVTKObject );
 #else
-      myResult = PyVTKObject_New( aPyClass, NULL, aVTKObject );
+      myResult = PyVTKObject_FromPointer( aPyClass, NULL, aVTKObject );
 #endif
     }
   }
@@ -272,7 +274,7 @@ public:
     : myResult( Py_None ), myCreate( toCreate ) {}
   virtual void Execute()
   {
-    PyObject* aPyClass = ::GetPyClass( "vtkRenderWindow" );
+    PyTypeObject* aPyClass = ::GetPyClass( "vtkRenderWindow" );
     SVTK_ViewWindow* aVTKViewWindow = 
       ::GetVTKViewWindow( myCreate ? __Create : __FindOrCreate );
     if( aVTKViewWindow && aPyClass ) {
@@ -280,7 +282,7 @@ public:
 #if VTK_XVERSION < 50700
       myResult = PyVTKObject_New( aPyClass, aVTKObject );
 #else
-      myResult = PyVTKObject_New( aPyClass, NULL, aVTKObject );
+      myResult = PyVTKObject_FromPointer( aPyClass, NULL, aVTKObject );
 #endif
     }
   }
@@ -325,7 +327,7 @@ public:
     : myResult( Py_None ), myCreate( toCreate ) {}
   virtual void Execute()
   {
-    PyObject* aPyClass = ::GetPyClass( "vtkRenderWindowInteractor" );
+    PyTypeObject* aPyClass = ::GetPyClass( "vtkRenderWindowInteractor" );
     SVTK_ViewWindow* aVTKViewWindow = 
       ::GetVTKViewWindow( myCreate ? __Create : __FindOrCreate );
     if( aVTKViewWindow && aPyClass ) {
@@ -333,7 +335,7 @@ public:
 #if VTK_XVERSION < 50700
       myResult = PyVTKObject_New( aPyClass, aVTKObject );
 #else
-      myResult = PyVTKObject_New( aPyClass, NULL, aVTKObject );
+      myResult = PyVTKObject_FromPointer( aPyClass, NULL, aVTKObject );
 #endif
     }
   }
@@ -372,7 +374,7 @@ extern "C" SALOMEPY_EXPORT PyObject* libSalomePy_showTrihedron( PyObject* self,
     {
       if( SVTK_ViewWindow* aVTKViewWindow = GetVTKViewWindow( __Find ) ) {
         if ( aVTKViewWindow->isTrihedronDisplayed() != myShow )
-          aVTKViewWindow->onViewTrihedron();
+          aVTKViewWindow->onViewTrihedron(myShow);
       }
     }
   };