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

OpenGL actors for populating the 3D scene.

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():

Actor objects have the following methods:

npoints()
nelems()
pickGL(mode)
class actors.TranslatedActor(A, trl=(0.0, 0.0, 0.0))

An Actor translated to another position.

TranslatedActor objects have the following methods:

bbox()
redraw(mode, color=None)
drawGL(mode, color=None)
class actors.RotatedActor(A, rot=(1.0, 0.0, 0.0), twist=0.0)

An Actor rotated to another position.

Created a new rotated actor.

If rot is an array with shape (3,), the rotation is specified by the direction of the local 0 axis of the actor. If rot is an array with shape (4,4), the rotation is specified by the direction of the local 0, 1 and 2 axes of the actor.

RotatedActor objects have the following methods:

bbox()
redraw(mode, color=None)
drawGL(mode, color=None)
class actors.CubeActor(size, 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)])

An OpenGL actor with cubic shape and 6 colored sides.

CubeActor objects have the following methods:

bbox()
drawGL(mode='wireframe', color=None)
Draw the cube.
class actors.BboxActor(bbox, color=None, linewidth=None)

Draws a bbox.

BboxActor objects have the following methods:

bbox()
drawGL(mode, color=None)
Always draws a wireframe model of the bbox.
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), (0.0, 1.0, 1.0), (1.0, 0.0, 1.0), (1.0, 1.0, 0.0)])

An OpenGL actor representing a triade of global axes.

TriadeActor objects have the following methods:

bbox()
setPos(pos)
setSize(size)
drawGL(mode='wireframe', color=None)
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)

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

GridActor objects have the following methods:

bbox()
drawGL(mode, color=None)
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)

Draws a set of 3 coordinate planes.

CoordPlaneActor objects have the following methods:

bbox()
drawGL(mode, color=None)
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)

A plane in a 3D scene.

A plane perpendicular to the x-axis at the origin.

PlaneActor objects have the following methods:

bbox()
drawGL(mode, color=None)
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, marksize=None)

An OpenGL actor representing a geometrical model.

The model can either be in Formex or Mesh format.

Create a geometry actor.

The geometry is either in Formex model: a coordinate block with shape (nelems,nplex,3), or in Mesh format: a coordinate block with shape (npoints,3) and an elems block with shape (nelems,nplex).

In both cases, an eltype may be specified if the default is not suitable. Default eltypes are Point for plexitude 1, Line for plexitude 2 and Triangle for plexitude 3 and Polygon for all higher plexitudes. Actually, Triangle is just a special case of Polygon.

Here is a list of possible eltype values (which should match the corresponding plexitude):

plexitude eltype element type
1 point3d
a 3D cube with 6 differently colored faces is drawn at each point
4 tet4 a tetrahedron
6 wedge6 a wedge (triangular prism)
8 hex8 a hexahedron

The colors argument specifies a list of OpenGL colors for each of the property values in the Formex. If the list has less values than the PropSet, it is wrapped around. It can also be a single OpenGL color, which will be used for all elements. For surface type elements, a bkcolor color can be given for the backside (inside) of the surface. Default will be the same as the front color. The user can specify a linewidth to be used when drawing in wireframe mode.

GeomActor objects have the following methods:

nplex()
nelems()
shape()
npoints()
vertices()
Return the vertives as a 2-dim array.
nedges()
edges()
setColor(color=None, colormap=None)
Set the color of the Actor.
setBkColor(color=None, colormap=None)
Set the backside color of the Actor.
setAlpha(alpha)
Set the Actors alpha value.
setMarkSize(marksize)

Set the mark size.

The mark size is currently only used with plex-1 Formices.

setMark(size, type)
Create a symbol for drawing 3D points.
bbox()
drawGL(mode='wireframe', color=None, colormap=None, alpha=None)

Draw the formex.

if color is None, it is drawn with the color specified on creation. if color == ‘prop’ and a colormap was installed, props define color. else, color should be an array of RGB values, either with shape (3,) for a single color, or (nelems,3) for differently colored elements

if mode ends with wire (smoothwire or flatwire), two drawing operations are done: one with wireframe and color black, and one with mode[:-4] and self.color.

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.

class actors.TriSurfaceActor(S, color=None, colormap=None, bkcolor=None, bkcolormap=None, linewidth=None, alpha=1.0, mode=None)

Draws a triangulated surface specified by points and connectivity.

TriSurfaceActor objects have the following methods:

setColor(color=None, colormap=None)
Set the color of the Actor.
setBkColor(color=None, colormap=None)
Set the backside color of the Actor.
setAlpha(alpha)
Set the Actors alpha value.
drawGL(mode='wireframe', color=None, colormap=None, alpha=None)
Draw the surface.
pickGL(mode)

Allow picking of parts of the actor.

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

Documentation

Previous topic

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

Next topic

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

This Page