Interactive OpenGL Canvas embedded in a Qt4 widget.
This module implements user interaction with the OpenGL canvas defined in module canvas. QtCanvas is a single interactive OpenGL canvas, while MultiCanvas implements a dynamic array of multiple canvases.
A class for handling the mouse cursor shape on the Canvas.
Create a CursorHandler for the specified widget.
CursorShapeHandler objects have the following methods:
A class for handling the mouse events on the Canvas.
CanvasMouseHandler objects have the following methods:
A canvas for OpenGL rendering.
This class provides interactive functionality for the OpenGL canvas provided by the canvas.Canvas class.
Interactivity is highly dependent on Qt4. Putting the interactive functions in a separate class makes it esier to use the Canvas class in non-interactive situations or combining it with other GUI toolsets.
Initialize an empty canvas with default settings.
QtCanvas objects have the following methods:
Process mouse events during interactive picking.
On PRESS, record the mouse position. On MOVE, create a rectangular picking window. On RELEASE, pick the objects inside the rectangle.
Start an interactive picking mode.
If selection mode was already started, mode is disregarded and this can be used to change the filter method.
Accept or cancel an interactive picking mode.
If clear == True, the current selection is cleared.
Interactively pick objects from the viewport.
mode: defines what to pick : one of ['actor','element','point','number','edge']
single: if True, the function returns as soon as the user ends a picking operation. The default is to let the user modify his selection and only to return after an explicit cancel (ESC or right mouse button).
func: if specified, this function will be called after each atomic pick operation. The Collection with the currently selected objects is passed as an argument. This can e.g. be used to highlight the selected objects during picking.
filter: defines what elements to retain from the selection: one of [None,'closest,'connected'].
None (default) will return the complete selection.
‘closest’ will only keep the element closest to the user.
‘connected’ will only keep elements connected to - the closest element (set picked) - what is already in the selection (add picked).
Currently this only works when picking mode is ‘element’ and for Actors having a partitionByConnection method.
When the picking operation is finished, the selection is returned. The return value is always a Collection object.
Cancel an interactive drawing mode.
If clear == True, the current drawing is cleared.
Interactively draw lines on the canvas.
a drawing operation. The default is to let the user draw multiple lines and only to return after an explicit cancel (ESC or right mouse button). - func: if specified, this function will be called after each atomic drawing operation. The current drawing is passed as an argument. This can e.g. be used to show the drawing. When the drawing operation is finished, the drawing is returned. The return value is a (n,2,2) shaped array.
Perform dynamic rotation operation.
This function processes mouse button events controlling a dynamic rotation operation. The action is one of PRESS, MOVE or RELEASE.
Perform dynamic pan operation.
This function processes mouse button events controlling a dynamic pan operation. The action is one of PRESS, MOVE or RELEASE.
Perform dynamic zoom operation.
This function processes mouse button events controlling a dynamic zoom operation. The action is one of PRESS, MOVE or RELEASE.
Emit a DONE event by clicking the mouse.
This is equivalent to pressing the ENTER button.
Emit a CANCEL event by clicking the mouse.
This is equivalent to pressing the ESC button.
Process mouse events during interactive picking.
On PRESS, record the mouse position. On MOVE, create a rectangular picking window. On RELEASE, pick the objects inside the rectangle.
Set the list of actor parts inside the pick_window.
obj_type can be ‘element’, ‘edge’ or ‘point’ ‘edge’ is only available for mesh type geometry max_objects specifies the maximum number of objects
The picked object numbers are stored in self.picked. If store_closest==True, the closest picked object is stored in as a tuple ( [actor,object] ,distance) in self.picked_closest
Process mouse events during interactive drawing.
On PRESS, record the mouse position. On MOVE, draw a line. On RELEASE, add the line to the drawing.
A QtGui.QGridLayout where each added widget is framed.
Initialize the multicanvas.
FramedGridLayout objects have the following methods:
An OpenGL canvas with multiple viewports and QT interaction.
The MultiCanvas implements a central QT widget containing one or more QtCanvas widgets.
Initialize the multicanvas.
MultiCanvas objects have the following methods:
Make the specified viewport the current one.
canv can be either a viewport or viewport number.
Lay out the viewports.
You can specify the number of viewports and the number of columns or rows.
If a number of viewports is given, viewports will be added or removed to match the number requested. By default they are layed out rowwise over two columns.
If ncols is an int, viewports are laid out rowwise over ncols columns and nrows is ignored. If ncols is None and nrows is an int, viewports are laid out columnwise over nrows rows.
Functions defined in the module viewport
- viewport.dotpr(v, w)¶
- Return the dot product of vectors v and w
- viewport.length(v)¶
- Return the length of the vector v
- viewport.projection(v, w)¶
- Return the (signed) length of the projection of vector v on vector w.
- viewport.modifierName(mod)¶
- viewport.setOpenGLFormat()¶
Set the correct OpenGL format.
On a correctly installed system, the default should do well. The default OpenGL format can be changed by command line options:
--dri : use the Direct Rendering Infrastructure --nodri : do not use the DRI --alpha : enable the alpha buffer
- viewport.getOpenGLContext()¶
- viewport.OpenGLFormat(fmt=None)¶
- Some information about the OpenGL format.
- viewport.printOpenGLContext(ctxt)¶