April 2024 - This site, and Kamaelia are being updated. There is significant work needed, and PRs are welcome.

Kamaelia.UI.OpenGL.Container

Container component

A container to control several OpenGLComponents.

Example Usage

In the following example, three components are put into a container and get moved by a SimpleMover and rotated around the Y axis by a SimpleRotator:

o1 = SimpleButton(size=(1,1,1)).activate()
o2 = SimpleCube(size=(1,1,1)).activate()
o3 = ArrowButton(size=(1,1,1)).activate()

containercontents = {
    o1: {"position":(0,1,0)},
    o2: {"position":(1,-1,0)},
    o3: {"position":(-1,-1,0)},
}

Graphline(
    OBJ1=o1,
    OBJ2=o2,
    OBJ3=o3,
    CONTAINER=Container(contents=containercontents, position=(0,0,-10)),
    MOVER=SimpleMover(amount=(0.01,0.02,0.03)),
    ROTATOR=SimpleRotator(amount=(0,0.1,0)),
    linkages = {
        ("MOVER", "outbox") : ("CONTAINER","position"),
        ("ROTATOR", "outbox") : ("CONTAINER","rel_rotation")
    }
).run()

How does it work?

The Container component provides the same inboxes for absolute and relative movement as a OpenGLComponent. These are "position", "rotation", "scaling", "rel_position", "rel_rotation", "rel_scaling", their names are self explanatory. When the container receives a tuple in one of those inboxes, it does update its own transform and uses it to translate the movement to its content components. This is done in the method rearangeContents(). Currently only translation and scaling is supported. This means though components change their position with respect to the rotation of the container and their relative position, the components rotation does not change.

The contents have to be provided as constructor keyword in form of a nested dictionary of the following form:

{
    component1 : { "position":(x,y,z), "rotation":(x,y,z), "scaling":(x,y,z) },
    component2 : { "position":(x,y,z), "rotation":(x,y,z), "scaling":(x,y,z) },
    ...
}

Each of the "position", "rotation" and "scaling" arguments specify the amount relative to the container. They are all optional. As stated earlier, rotation is not supported yet so setting the rotation has no effect.

Container components terminate if a producerFinished or shutdownMicroprocess message is received on their "control" inbox. The received message is also forwarded to the "signal" outbox. Upon termination, this component does not unbind itself from the OpenGLDisplay service and does not free any requested resources.


Kamaelia.UI.OpenGL.Container.Container

class Container(Axon.AdaptiveCommsComponent.AdaptiveCommsComponent)

Container(...) -> A new Container component.

A container to control several OpenGLComponents.

Keyword arguments:

  • position -- Initial container position (default=(0,0,0)).
  • rotation -- Initial container rotation (default=(0,0,0)).
  • scaling -- Initial container scaling (default=(1,1,1)).
  • contents -- Nested dictionary of contained components.

Inboxes

  • control : For shutdown messages
  • scaling : receive scaling triple (x,y,z)
  • inbox :
  • position : receive position triple (x,y,z)
  • rotation : receive rotation triple (x,y,z)
  • rel_scaling : receive scaling triple (x,y,z)
  • rel_position : receive position triple (x,y,z)
  • rel_rotation : receive rotation triple (x,y,z)

Outboxes

  • outbox :
  • signal : For shutdown messages

Methods defined here

Warning!

You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers.

__init__(self, **argd)

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

addElement(self, comp[, position][, rotation][, scaling])

applyTransforms(self)

Use the objects translation/rotation/scaling values to generate a new transformation Matrix if changes have happened.

handleMovement(self)

Handle movement commands received by corresponding inboxes.

main(self)

rearangeContents(self)

removeElement(self, comp)

Feedback

Got a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording!

Please leave you feedback here in reply to the documentation thread in the Kamaelia blog.

-- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT