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.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]
add_widget(widget)[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

display()[source]
keyboardfunc(c, x, y)[source]
keyboardupfunc(c, x, y)[source]
mousefunc(button, state, x, y)[source]
motionfunc(x, y, dx, dy)[source]
idle()[source]
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.

initialize()[source]

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

addView(view)[source]
removeView(view)[source]
clearViews()[source]
add_view(view)[source]
remove_view(view)[source]
clear_views()[source]
update_active(x, y)[source]
fit()[source]
reshapefunc(w, h)[source]

Called on window resize. May be overridden.

displayfunc()[source]

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

display()[source]

Do drawing of objects in world

display_screen()[source]

Do drawing of objects on screen

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.

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

Called when the mouse is clicked. May be overridden.

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

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

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.

refresh()[source]

Spoofs the window’s refresh function

reshape(w, h)[source]

Spoofs the window’s reshape function

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.

click_ray(x, y)[source]
get_view()[source]
set_view(vp)[source]
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

markChanged()[source]
mark_changed()[source]

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

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.