76. opengl.scene — This implements an OpenGL drawing widget for painting 3D scenes. — pyFormex 1.0.5 documentation

# 76. `opengl.scene` — This implements an OpenGL drawing widget for painting 3D scenes.

## 76.1. Classes defined in module opengl.scene

class `opengl.scene.` `ItemList`(scene)

  A list of drawn objects of the same kind.

  This is used to collect the Actors, Decorations and Annotations in a scene. Currently the implementation does not check that the objects are of the proper type.

  `add`(item)

    Add an item or a list thereof to a ItemList.

  `delete`(items, sticky=True)

    Remove item(s) from an ItemList.

    Parameters:

    - items: a single item or a list or tuple of items
    - sticky: bool: if True, also sticky items are removed. The default is to not remove sticky items. Sticky items are items having an attribute sticky=True.
  `clear`(sticky=False)

    Clear the list.

    Parameters:

    - sticky: bool: if True, also sticky items are removed. The default is to not remove sticky items. Sticky items are items having an attribute sticky=True.

class `opengl.scene.` `Scene`(canvas=None)

  An OpenGL scene.

  The Scene is a class holding a collection of Actors, Decorations and Annotations. It can also have a background.

  `bbox`

    Return the bounding box of the scene.

    The bounding box is normally computed automatically as the box enclosing all Actors in the scene. Decorations and Annotations are not included. The user can however set the bbox himself, in which case that value will be used. It can also be set to the special value None to force recomputing the bbox from all Actors.

  `set_bbox`(bb)

    Set the bounding box of the scene.

    This can be used to set the scene bounding box to another value than the one autocomputed from all actors.

    bb is a (2,3) shaped array specifying a bounding box. A special value None may be given to force recomputing the bbox from all Actors.

  `changeMode`(canvas, mode=None)

    This function is called when the rendering mode is changed

    This method should be called to update the actors on a rendering mode change.

  `addAny`(actor)

    Add any actor type or a list thereof.

    This will add any actor/annotation/decoration item or a list of any such items to the scene. This is the prefered method to add an item to the scene, because it makes sure that each item is added to the proper list.

  `removeAny`(actor)

    Remove a list of any actor/highlights/annotation/decoration items.

    This will remove the items from any of the canvas lists in which the item appears. itemlist can also be a single item instead of a list. If None is specified, all items from all lists will be removed.

  `drawn`(obj)

    List the graphical representations of the given object.

    Returns a list with the actors that point to the specifief object.

  `removeDrawn`(obj)

    Remove all graphical representations of the given object.

    Removes all actors returned by `drawn(obj)()`.

  `clear`(sticky=False)

    Clear the whole scene

  `removeHighlight`(actors=None)

    Remove the highlight from the actors in the list.

    If no actors list is specified, all the highlights are removed.

  `highlighted`()

    List highlighted actors

  `removeHighlighted`()

    Remove the highlighted actors.

## 76.2. Functions defined in module opengl.scene

`opengl.scene.` `sane_bbox`(bb)

  Return a sane nonzero bbox.

  bb should be a (2,3) float array or compatible Returns a (2,3) float array where the values of the second row are guaranteed larger than the first. A value 1 is added in the directions where the input bbox has zero size. Also, any NaNs will be transformed to numbers.