Version: 9.12.0
SalomePy.cxx File Reference
#include <Python.h>
#include <vtkPythonUtil.h>
#include <vtkVersion.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <SALOME_Event.h>
#include <SUIT_Session.h>
#include <LightApp_Application.h>
#include <LightApp_Study.h>
#include <SVTK_ViewManager.h>
#include <SVTK_ViewWindow.h>

Classes

class  TGetRendererEvent
 
class  TGetRenderWindowEvent
 
class  TGetRenderWindowInteractorEvent
 
struct  module_state
 

Macros

#define VTK_XVERSION   (VTK_MAJOR_VERSION*10000+VTK_MINOR_VERSION*100+VTK_BUILD_VERSION)
 
#define SALOMEPY_EXPORT
 Python wrappings for VTK viewer of the SALOME desktop. More...
 
#define PUBLISH_ENUM(i)
 
#define GETSTATE(m)   ((struct module_state*)PyModule_GetState(m))
 

Enumerations

enum  {
  ViewFront , ViewBack , ViewTop , ViewBottom ,
  ViewRight , ViewLeft
}
 View operation type. More...
 
enum  { __Find , __FindOrCreate , __Create }
 VTK window find/create mode. More...
 

Functions

static PyTypeObject * GetPyClass (const char *theClassName)
 Get Python class object by name. More...
 
static SVTK_ViewWindowGetVTKViewWindow (int toCreate=__FindOrCreate, int toKeepDetached=0)
 Find or create VTK window. More...
 
PyObject * libSalomePy_getRenderer (PyObject *, PyObject *args)
 
PyObject * libSalomePy_getRenderWindow (PyObject *, PyObject *args)
 
PyObject * libSalomePy_getRenderWindowInteractor (PyObject *, PyObject *args)
 
PyObject * libSalomePy_showTrihedron (PyObject *, PyObject *args)
 
PyObject * libSalomePy_fitAll (PyObject *, PyObject *)
 
PyObject * libSalomePy_setView (PyObject *, PyObject *args)
 
PyObject * libSalomePy_resetView (PyObject *, PyObject *)
 
static int libSalomePy_traverse (PyObject *m, visitproc visit, void *arg)
 
static int libSalomePy_clear (PyObject *m)
 
PyMODINIT_FUNC PyInit_libSalomePy (void)
 Python module initialization. More...
 

Variables

static PyMethodDef libSalomePy_methods []
 
static struct PyModuleDef moduledef
 

Macro Definition Documentation

◆ GETSTATE

#define GETSTATE (   m)    ((struct module_state*)PyModule_GetState(m))

◆ PUBLISH_ENUM

#define PUBLISH_ENUM (   i)
Value:
{ \
PyObject *w; \
int rc; \
if ( ( w = PyLong_FromLong( i ) ) == NULL ) return NULL; \
rc = PyDict_SetItemString( aModuleDict, #i, w ); \
Py_DECREF( w ); \
if ( rc < 0 ) return NULL; \
}

◆ SALOMEPY_EXPORT

#define SALOMEPY_EXPORT

Python wrappings for VTK viewer of the SALOME desktop.

All methods are implemented using Event mechanism. The module provides the following functions:

  • getRenderer()
  • getRenderWindow()
  • getRenderWindowInteractor()
  • showTrihedron()
  • fitAll()
  • setView()
  • resetView()

Usage in Python:

import SalomePy
renderer = SalomePy.getRenderer() # get VTK renderer
window = SalomePy.getRenderWindow() # get render window
Definition: VTKViewer_Algorithm.cxx:23

The methods getRenderer(), getRenderWindow() and getRenderWindowInteractor() open new VTK viewer if there is no one opened. In case of any error these methods return None object to the Python.

◆ VTK_XVERSION

#define VTK_XVERSION   (VTK_MAJOR_VERSION*10000+VTK_MINOR_VERSION*100+VTK_BUILD_VERSION)

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

View operation type.

Enumerator
ViewFront 

front view

ViewBack 

back view

ViewTop 

top view

ViewBottom 

bottom view

ViewRight 

right view

ViewLeft 

left view

◆ anonymous enum

anonymous enum

VTK window find/create mode.

Enumerator
__Find 
__FindOrCreate 
__Create 

Function Documentation

◆ GetPyClass()

static PyTypeObject* GetPyClass ( const char *  theClassName)
static

Get Python class object by name.

Parameters
theClassNamePython class name
Returns
Python class object or None object if class is not found

◆ GetVTKViewWindow()

static SVTK_ViewWindow* GetVTKViewWindow ( int  toCreate = __FindOrCreate,
int  toKeepDetached = 0 
)
static

◆ libSalomePy_clear()

static int libSalomePy_clear ( PyObject *  m)
static

References GETSTATE.

◆ libSalomePy_fitAll()

PyObject* libSalomePy_fitAll ( PyObject *  ,
PyObject *   
)

◆ libSalomePy_getRenderer()

PyObject* libSalomePy_getRenderer ( PyObject *  ,
PyObject *  args 
)

References ProcessEvent().

◆ libSalomePy_getRenderWindow()

PyObject* libSalomePy_getRenderWindow ( PyObject *  ,
PyObject *  args 
)

References ProcessEvent().

◆ libSalomePy_getRenderWindowInteractor()

PyObject* libSalomePy_getRenderWindowInteractor ( PyObject *  ,
PyObject *  args 
)

References ProcessEvent().

◆ libSalomePy_resetView()

PyObject* libSalomePy_resetView ( PyObject *  ,
PyObject *   
)

◆ libSalomePy_setView()

PyObject* libSalomePy_setView ( PyObject *  ,
PyObject *  args 
)

◆ libSalomePy_showTrihedron()

PyObject* libSalomePy_showTrihedron ( PyObject *  ,
PyObject *  args 
)

◆ libSalomePy_traverse()

static int libSalomePy_traverse ( PyObject *  m,
visitproc  visit,
void *  arg 
)
static

References GETSTATE.

◆ PyInit_libSalomePy()

PyMODINIT_FUNC PyInit_libSalomePy ( void  )

Python module initialization.

References moduledef, PUBLISH_ENUM, ViewBack, ViewBottom, ViewFront, ViewLeft, ViewRight, and ViewTop.

Variable Documentation

◆ libSalomePy_methods

PyMethodDef libSalomePy_methods[]
static
Initial value:
=
{
{ "getRenderer", libSalomePy_getRenderer, METH_VARARGS, PyDoc_STR("Get renderer from current vtk view") },
{ "getRenderWindow", libSalomePy_getRenderWindow, METH_VARARGS, PyDoc_STR("Get render window from current vtk view") },
{ "getRenderWindowInteractor", libSalomePy_getRenderWindowInteractor, METH_VARARGS, PyDoc_STR("Get interactor from current vtk view") },
{ "showTrihedron", libSalomePy_showTrihedron, METH_VARARGS, PyDoc_STR("Show/hide trihedron in current vtk view") },
{ "fitAll", libSalomePy_fitAll, METH_NOARGS, PyDoc_STR("Fit current vtk view to show all contents") },
{ "setView", libSalomePy_setView, METH_VARARGS, PyDoc_STR("Set side view for the current VTK viewer") },
{ "resetView", libSalomePy_resetView, METH_NOARGS, PyDoc_STR("Reset camera for current vtk view") },
{ 0, 0, 0, 0 }
}
PyObject * libSalomePy_getRenderWindowInteractor(PyObject *, PyObject *args)
Definition: SalomePy.cxx:331
PyObject * libSalomePy_getRenderer(PyObject *, PyObject *args)
Definition: SalomePy.cxx:229
PyObject * libSalomePy_getRenderWindow(PyObject *, PyObject *args)
Definition: SalomePy.cxx:280
PyObject * libSalomePy_setView(PyObject *, PyObject *args)
Definition: SalomePy.cxx:416
PyObject * libSalomePy_resetView(PyObject *, PyObject *)
Definition: SalomePy.cxx:467
PyObject * libSalomePy_showTrihedron(PyObject *, PyObject *args)
Definition: SalomePy.cxx:353
PyObject * libSalomePy_fitAll(PyObject *, PyObject *)
Definition: SalomePy.cxx:388

◆ moduledef

struct PyModuleDef moduledef
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"libSalomePy",
NULL,
sizeof(struct module_state),
NULL,
NULL
}
static PyMethodDef libSalomePy_methods[]
Definition: SalomePy.cxx:485
static int libSalomePy_clear(PyObject *m)
Definition: SalomePy.cxx:508
static int libSalomePy_traverse(PyObject *m, visitproc visit, void *arg)
Definition: SalomePy.cxx:503
Definition: SalomePy.cxx:497