vtkmodules.qt.QVTKRenderWindowInteractor#

A simple VTK widget for PyQt or PySide. See http://www.trolltech.com for Qt documentation, http://www.riverbankcomputing.co.uk for PyQt, and http://pyside.github.io for PySide.

This class is based on the vtkGenericRenderWindowInteractor and is therefore fairly powerful. It should also play nicely with the vtk3DWidget code.

Created by Prabhu Ramachandran, May 2002 Based on David Gobbi’s QVTKRenderWidget.py

Changes by Gerard Vermeulen Feb. 2003 Win32 support.

Changes by Gerard Vermeulen, May 2003 Bug fixes and better integration with the Qt framework.

Changes by Phil Thompson, Nov. 2006 Ported to PyQt v4. Added support for wheel events.

Changes by Phil Thompson, Oct. 2007 Bug fixes.

Changes by Phil Thompson, Mar. 2008 Added cursor support.

Changes by Rodrigo Mologni, Sep. 2013 (Credit to Daniele Esposti) Bug fix to PySide: Converts PyCObject to void pointer.

Changes by Greg Schussman, Aug. 2014 The keyPressEvent function now passes keysym instead of None.

Changes by Alex Tsui, Apr. 2015 Port from PyQt4 to PyQt5.

Changes by Fabian Wenzel, Jan. 2016 Support for Python3

Changes by Tobias Hänel, Sep. 2018 Support for PySide2

Changes by Ruben de Bruin, Aug. 2019 Fixes to the keyPressEvent function

Changes by Chen Jintao, Aug. 2021 Support for PySide6

Changes by Eric Larson and Guillaume Favelier, Apr. 2022 Support for PyQt6

Module Contents#

Classes#

QVTKRenderWindowInteractor

A QVTKRenderWindowInteractor for Python and Qt. Uses a vtkGenericRenderWindowInteractor to handle the interactions. Use GetRenderWindow() to get the vtkRenderWindow. Create with the keyword stereo=1 in order to generate a stereo-capable window.

Functions#

_get_event_pos

QVTKRenderWidgetConeExample

A simple example that uses the QVTKRenderWindowInteractor class.

Data#

API#

vtkmodules.qt.QVTKRenderWindowInteractor.QVTKRWIBase#

‘QWidget’

vtkmodules.qt.QVTKRenderWindowInteractor._get_event_pos(ev)#
class vtkmodules.qt.QVTKRenderWindowInteractor.QVTKRenderWindowInteractor(parent=None, **kw)#

Bases: vtkmodules.qt.QVTKRenderWindowInteractor.QVTKRWIBaseClass

A QVTKRenderWindowInteractor for Python and Qt. Uses a vtkGenericRenderWindowInteractor to handle the interactions. Use GetRenderWindow() to get the vtkRenderWindow. Create with the keyword stereo=1 in order to generate a stereo-capable window.

The user interface is summarized in vtkInteractorStyle.h:

  • Keypress j / Keypress t: toggle between joystick (position sensitive) and trackball (motion sensitive) styles. In joystick style, motion occurs continuously as long as a mouse button is pressed. In trackball style, motion occurs when the mouse button is pressed and the mouse pointer moves.

  • Keypress c / Keypress o: toggle between camera and object (actor) modes. In camera mode, mouse events affect the camera position and focal point. In object mode, mouse events affect the actor that is under the mouse pointer.

  • Button 1: rotate the camera around its focal point (if camera mode) or rotate the actor around its origin (if actor mode). The rotation is in the direction defined from the center of the renderer’s viewport towards the mouse position. In joystick mode, the magnitude of the rotation is determined by the distance the mouse is from the center of the render window.

  • Button 2: pan the camera (if camera mode) or translate the actor (if object mode). In joystick mode, the direction of pan or translation is from the center of the viewport towards the mouse position. In trackball mode, the direction of motion is the direction the mouse moves. (Note: with 2-button mice, pan is defined as -Button 1.)

  • Button 3: zoom the camera (if camera mode) or scale the actor (if object mode). Zoom in/increase scale if the mouse position is in the top half of the viewport; zoom out/decrease scale if the mouse position is in the bottom half. In joystick mode, the amount of zoom is controlled by the distance of the mouse pointer from the horizontal centerline of the window.

  • Keypress 3: toggle the render window into and out of stereo mode. By default, red-blue stereo pairs are created. Some systems support Crystal Eyes LCD stereo glasses; you have to invoke SetStereoTypeToCrystalEyes() on the rendering window. Note: to use stereo you also need to pass a stereo=1 keyword argument to the constructor.

  • Keypress e: exit the application.

  • Keypress f: fly to the picked point

  • Keypress p: perform a pick operation. The render window interactor has an internal instance of vtkCellPicker that it uses to pick.

  • Keypress r: reset the camera view along the current view direction. Centers the actors and moves the camera so that all actors are visible.

  • Keypress s: modify the representation of all actors so that they are surfaces.

  • Keypress u: invoke the user-defined function. Typically, this keypress will bring up an interactor that you can type commands in.

  • Keypress w: modify the representation of all actors so that they are wireframe.

Initialization

_CURSOR_MAP#

None

__getattr__(attr)#

Makes the object behave like a vtkGenericRenderWindowInteractor

Finalize()#

Call internal cleanup method on VTK objects

CreateTimer(obj, evt)#
DestroyTimer(obj, evt)#
TimerEvent()#
CursorChangedEvent(obj, evt)#

Called when the CursorChangedEvent fires on the render window.

HideCursor()#

Hides the cursor.

ShowCursor()#

Shows the cursor.

closeEvent(evt)#
sizeHint()#
paintEngine()#
paintEvent(ev)#
resizeEvent(ev)#
_GetKeyCharAndKeySym(ev)#

Convert a Qt key into a char and a vtk keysym.

This is essentially copied from the c++ implementation in GUISupport/Qt/QVTKInteractorAdapter.cxx.

_GetCtrlShift(ev)#
static _getPixelRatio()#
_setEventInformation(x, y, ctrl, shift, key, repeat=0, keysum=None)#
enterEvent(ev)#
leaveEvent(ev)#
mousePressEvent(ev)#
mouseReleaseEvent(ev)#
mouseMoveEvent(ev)#
keyPressEvent(ev)#
keyReleaseEvent(ev)#
wheelEvent(ev)#
GetRenderWindow()#
Render()#
vtkmodules.qt.QVTKRenderWindowInteractor.QVTKRenderWidgetConeExample()#

A simple example that uses the QVTKRenderWindowInteractor class.

vtkmodules.qt.QVTKRenderWindowInteractor._keysyms_for_ascii#

(None, None, None, None, None, None, None, None, None, ‘Tab’, None, None, None, None, None, None, No…

vtkmodules.qt.QVTKRenderWindowInteractor._keysyms#

None