klampt.vis.glinterface module

Defines the GLPluginInterface class, which is a unified base class for plugins to the klampt.vis module.

class klampt.vis.glinterface.GLPluginInterface[source]

Bases: object

Users can add their own hooks into the visualizer by overloading this class’s methods. Each method should return True if the user event was processed. A return value of True stops cascading events to a parent interface.

window

the window to which this plugin is attached. May be None if not attached to an OpenGL window.

Type

QtGLWindow or GLUTWindow

view

the viewport that is currently being used for this plugin.

Type

GLViewport

actions

internally used.

Type

list

initialize()[source]

Called by backend after the GL context is created but before the event loop starts.

Return type

bool

displayfunc()[source]
Return type

bool

display()[source]
Return type

bool

display_screen()[source]
Return type

bool

reshapefunc(w, h)[source]
Return type

bool

keyboardfunc(c, x, y)[source]
Return type

bool

keyboardupfunc(c, x, y)[source]
Return type

bool

mousefunc(button, state, x, y)[source]
Return type

bool

motionfunc(x, y, dx, dy)[source]
Return type

bool

idle()[source]
Return type

bool

eventfunc(type, args='')[source]

Generic hook for other events, e.g., button presses, from the GUI

Return type

bool

closefunc()[source]
Return type

bool

add_action(callback, short_name, key, description=None)[source]

Defines a new generic GUI action. The action will be available in a menu in Qt or as keyboard commands in GLUT.

Return type

None

reshape(w, h)[source]

Asks to resize the GL window

Return type

None

idlesleep(seconds)[source]

Asks to sleep the idle function for seconds seconds.

Return type

None

modifiers()[source]

Retrieves a list of currently pressed keyboard modifiers. Values can be any combination of ‘ctrl’, ‘shift’, ‘alt’.

Return type

List[str]

refresh()[source]

Asks for a redraw

Return type

None

draw_text(point, text, size=12, color=None)[source]

Draws text of the given size and color at the point (x,y) or (x,y,z). The former method is usually called during display_screen.

Return type

None

click_ray(x, y)[source]

Returns the world-space ray associated with the camera click at pixel coordinates x,y.

Return type

Tuple[Sequence[float], Sequence[float]]

viewport()[source]

Returns the Viewport instance associated with the current GL view. Used for interfacing with C++ widgets.

Return type

Viewport