16. actors — OpenGL actors for populating the 3D scene.

OpenGL actors for populating the 3D scene.

Classes defined in module actors

class actors.Actor

An Actor is anything that can be drawn in an OpenGL 3D Scene.

The visualisation of the Scene Actors is dependent on camera position and angles, clipping planes, rendering mode and lighting.

An Actor subclass should minimally reimplement the following methods:

  • bbox(): return the actors bounding box.
  • drawGL(mode): to draw the actor. Takes a mode argument so the drawing function can act differently depending on the mode. There are currently 5 modes: wireframe, flat, smooth, flatwire, smoothwire. drawGL should only contain OpenGL calls that are allowed inside a display list. This may include calling the display list of another actor but not creating a new display list.

The interactive picking functionality requires the following methods, for which we porvide do-nothing defaults here:

  • npoints():
  • nelems():
  • pickGL():

Methods

bbox()

Default implementation for bbox().

class actors.TranslatedActor(A, trl=(0.0, 0.0, 0.0), **kargs)

An Actor translated to another position.

Methods

class actors.RotatedActor(A, rot=(1.0, 0.0, 0.0), twist=0.0, **kargs)

An Actor rotated to another position.

Methods

class actors.CubeActor(size=1.0, color=[(1.0, 0.0, 0.0), (0.0, 1.0, 1.0), (0.0, 1.0, 0.0), (1.0, 0.0, 1.0), (0.0, 0.0, 1.0), (1.0, 1.0, 0.0)], **kargs)

An OpenGL actor with cubic shape and 6 colored sides.

Methods

drawGL(**kargs)

Draw the cube.

class actors.SphereActor(size=1.0, color=None, **kargs)

An OpenGL actor representing a sphere.

Methods

drawGL(**kargs)

Draw the cube.

class actors.BboxActor(bbox, color=None, linewidth=None, **kargs)

Draws a bbox.

Methods

drawGL(**kargs)

Always draws a wireframe model of the bbox.

class actors.AxesActor(cs=None, size=1.0, color=[(1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)], colored_axes=True, draw_planes=False, **kargs)

An actor showing the three axes of a CoordinateSystem.

If no CoordinateSystem is specified, the global coordinate system is drawn.

The default actor consists of three colored lines of unit length along the unit vectors of the axes and three colored triangles representing the coordinate planes. This can be modified by the following parameters:

size: scale factor for the unit vectors. color: a set of three colors to use for x,y,z axes. colored_axes = False: draw black axes. draw_planes = False: do not draw the coordinate planes.

Methods

drawGL(**kargs)

Draw the axes.

class actors.TriadeActor(size=1.0, pos=[0.0, 0.0, 0.0], color=[(1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)], colored_axes=True, draw_planes=True, **kargs)

An OpenGL actor representing a triade of global axes.

By default, this draws three unit length axes at the origin, and three colored triangles representing the coordinate planes. The size and position of the axes can be changed.

colored_axes = False draws black axes. draw_planes = False suppress the drawing of the coordinate planes.

Methods

drawGL(**kargs)

Draw the triade.

class actors.GridActor(nx=(1, 1, 1), ox=(0.0, 0.0, 0.0), dx=(1.0, 1.0, 1.0), linecolor=(0.0, 0.0, 0.0), linewidth=None, planecolor=(1.0, 1.0, 1.0), alpha=0.20000000000000001, lines=True, planes=True, **kargs)

Draws a (set of) grid(s) in one of the coordinate planes.

Methods

drawGL(**kargs)

Draw the grid.

class actors.CoordPlaneActor(nx=(1, 1, 1), ox=(0.0, 0.0, 0.0), dx=(1.0, 1.0, 1.0), linecolor=(0.0, 0.0, 0.0), linewidth=None, planecolor=(1.0, 1.0, 1.0), alpha=0.5, lines=True, planes=True, **kargs)

Draws a set of 3 coordinate planes.

Methods

drawGL(**kargs)

Draw the grid.

class actors.PlaneActor(nx=(2, 2, 2), ox=(0.0, 0.0, 0.0), size=((0.0, 1.0, 1.0), (0.0, 1.0, 1.0)), linecolor=(0.0, 0.0, 0.0), linewidth=None, planecolor=(1.0, 1.0, 1.0), alpha=0.5, lines=True, planes=True, **kargs)

A plane in a 3D scene.

Methods

drawGL(**kargs)

Draw the grid.

class actors.GeomActor(data, elems=None, eltype=None, color=None, colormap=None, bkcolor=None, bkcolormap=None, alpha=1.0, mode=None, linewidth=None, linestipple=None, marksize=None, **kargs)

An OpenGL actor representing a geometrical model.

The model can either be in Formex or Mesh format.

Methods

vertices()

Return the vertives as a 2-dim array.

setColor(color, colormap=None)

Set the color of the Actor.

setBkColor(color, colormap=None)

Set the backside color of the Actor.

setAlpha(alpha)

Set the Actors alpha value.

drawGL(canvas=None, mode=None, color=None, **kargs)

Draw the geometry on the specified canvas.

The drawing parameters not provided by the Actor itself, are derived from the canvas defaults.

mode and color can be overridden for the sole purpose of allowing the recursive use for modes ending on ‘wire’ (‘smoothwire’ or ‘flatwire’). In these cases, two drawing operations are done: one with mode=’wireframe’ and color=black, and one with mode=mode[:-4].

pickGL(mode)

Allow picking of parts of the actor.

mode can be ‘element’, ‘edge’ or ‘point’

select(sel)

Return a GeomActor with a selection of this actor’s elements

Currently, the resulting Actor will not inherit the properties of its parent, but the eltype will be retained.

Functions defined in module actors

Documentation

Previous topic

15. colorscale — Color mapping of a range of values.

Next topic

17. decors — 2D decorations for the OpenGL canvas.

This Page