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.
Methods
Create a CursorHandler for the specified widget.
Methods
CursorShapeHandler objects have the following methods:
A class for handling the mouse events on the Canvas.
Methods
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.
Methods
Initialize an empty canvas with default settings.
Methods
QtCanvas objects have the following methods:
Process mouse events during interactive rectangle zooming.
On PRESS, record the mouse position. On MOVE, create a rectangular zoom window. On RELEASE, zoom to the picked 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.
Interactively draw on the canvas.
This function allows the user to interactively create points in 3D space and collects the subsequent points in a Coords object. The interpretation of these points is left to the caller.
The drawing operation is finished when the number of requested points has been reached, or when the user clicks the right mouse button or hits ‘ENTER’. The return value is a (n,3) shaped Coords array.
Cancel an interactive drawing mode.
If clear == True, the current drawing is cleared.
Process mouse events during interactive drawing.
On PRESS, do nothing. On MOVE, do nothing. On RELEASE, add the point to the point list.
Cancel an interactive drawing mode.
If clear == True, the current drawing is cleared.
Interactively draw lines on the canvas.
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
A list of actors from which can be picked may be given. If so, the resulting keys are indices in this list. By default, the full actor list is used.
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.
Methods
Initialize the multicanvas.
Methods
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.
Methods
Initialize the multicanvas.
Methods
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)¶