klampt.vis.glcommon module

Defines GLWidgetPlugin, GLMultiViewportProgram, and CachedGLObject, which are used by the core visualization module. They may be useful for writing your own GLPluginInterface classes, too.

class klampt.vis.glcommon.CachedGLObject[source]

Bases: object

An object whose drawing is accelerated by means of a display list. The draw function may draw the object in the local frame, and the object may be transformed without having to recompile the display list.

destroy()[source]

Must be called to free up resources used by this object

draw(renderFunction, transform=None, args=None, parameters=None)[source]

Given the function that actually makes OpenGL calls, this will draw the object.

If parameters is given, the object’s local appearance is assumed to be defined deterministically from these parameters. The display list will be redrawn if the parameters change.

markChanged()[source]

Marked by an outside source to indicate the object has changed and should be redrawn.

class klampt.vis.glcommon.GLMultiViewportProgram[source]

Bases: klampt.vis.glprogram.GLProgram

A GLProgram that splits the window into several sub-views. Each view is a GLProgram or GLPluginInterface.

addView(view)[source]
clearViews()[source]
click_ray(x, y)[source]
display()[source]

Do drawing of objects in world

display_screen()[source]

Do drawing of objects on screen

displayfunc()[source]

All OpenGL calls go here. May be overridden, although you may wish to override display() and display_screen() instead.

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

Draws text of the given size and color at the given point. Usually called during display_screen.

fit()[source]
get_view()[source]
idlefunc()[source]

Called on idle. Default value stops all additional idle calls. Must be overridden if you want to do something in the idle loop.

initialize()[source]

Called after the GL context is initialized, but before main loop. May be overridden. Users should not call this directly!

keyboardfunc(c, x, y)[source]

Called on keypress down. May be overridden. c is either the ASCII/unicode character of the key pressed or a string describing the character (up,down,left,right, home,end,delete,enter,f1,…,f12)

keyboardupfunc(c, x, y)[source]

Called on keyboard up (if your system allows it). May be overridden.

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

Called when the mouse moves on screen. May be overridden.

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

Called when the mouse is clicked. May be overridden.

refresh()[source]

Spoofs the window’s refresh function

removeView(view)[source]
reshape(w, h)[source]

Spoofs the window’s reshape function

reshapefunc(w, h)[source]

Called on window resize. May be overridden.

set_view(vp)[source]
updateActive(x, y)[source]
class klampt.vis.glcommon.GLWidgetPlugin[source]

Bases: klampt.vis.glinterface.GLPluginInterface

A GL plugin that sends user events to one or more Klamp’t widgets. To use, add this to a GLPluginProgram and call addWidget to add widgets

addWidget(widget)[source]
display()[source]
idlefunc()[source]
keyboardfunc(c, x, y)[source]
keyboardupfunc(c, x, y)[source]
motionfunc(x, y, dx, dy)[source]
mousefunc(button, state, x, y)[source]
widgetchangefunc(event)[source]

Called whenever a widget is clicked or dragged. event can be ‘mousedown’, ‘mousedrag’, ‘mouseup’. Subclasses can use this to respond to widget click events

widgethoverfunc()[source]

Called whenever a widget changes appearance due to hover. Subclasses can use this to respond to widget click events