Classes defined in module canvas
A collection of settings for an OpenGL Canvas.
The canvas settings are a collection of settings and default values affecting the rendering in an individual viewport. There are two type of settings:
Currently the following mode settings are defined:
The list of default settings includes:
Any of these values can be set in the constructor using a keyword argument. All items that are not set, will get their value from the configuration file(s).
Reset the CanvasSettings to its defaults.
The default values are taken from the configuration files. An optional dictionary may be specified to override (some of) these defaults.
Update current values with the specified settings
Returns the sanitized update values.
Transform a dict to acceptable settings.
Activate the mode canvas settings in the GL machine.
Activate the default canvas settings in the GL machine.
Return the value for key or a default.
This is the equivalent of the dict get method, except that it returns only the default value if the key was not found in self, and there is no _default_ method or it raised a KeyError.
Replaces the setdefault function of a normal dictionary.
This is the same as the get method, except that it also sets the default value if get found a KeyError.
A canvas for OpenGL rendering.
The Canvas is a class holding all global data of an OpenGL scene rendering. This includes colors, line types, rendering mode. It also keeps lists of all the actors and decorations in the scene. It always has a Camera object holding import viewing parameters. And finally it stores the lighting information.
It does not however contain the viewport size and position.
Toggle lights on/off.
Return the status of the lighting.
Return all the settings to their default values.
Set the global ambient lighting for the canvas
Set the default material light properties for the canvas
Change the light parameters
Set the rendering mode.
This sets or changes the rendermode and lighting attributes. If lighting is not specified, it is set depending on the rendermode.
If the canvas has not been initialized, this merely sets the attributes self.rendermode and self.lighting. If the canvas was already initialized (it has a camera), and one of the specified settings is fdifferent from the existing, the new mode is set, the canvas is re-initialized according to the newly set mode, and everything is redrawn with the new mode.
Set the linewidth for line rendering.
Set the linestipple for line rendering.
Set the size for point drawing.
Set the background color.
If one color is specified, a solid background is set. If two colors are specified, a graded background is set and an object is created to display the background.
Create the background object.
Set the default foreground color.
Set the highlight color.
Toggle the display of the global axes on or off.
If on is True, a triade of global axes is displayed, if False it is removed. The default (None) toggles between on and off.
Initialize the rendering machine.
The rendering machine is initialized according to: - self.rendermode: one of - self.lighting
Flush all OpenGL commands, making sure the display is updated.
Clear the canvas to the background color.
Activate the canvas settings in the GL machine.
(Re)display all the actors in the scene.
This should e.g. be used when actors are added to the scene, or after changing camera position/orientation or lens.
Set up the canvas for 2D drawing on top of 3D canvas.
The 2D drawing operation should be ended by calling end_2D_drawing. It is assumed that you will not try to change/refresh the normal 3D drawing cycle during this operation.
Cancel the 2D drawing mode initiated by begin_2D_drawing.
Set the bounding box of the scene you want to be visible.
Add a 3D actor to the 3D scene.
Remove a 3D actor from the 3D scene.
Add a 3D actor highlight to the 3D scene.
Remove a 3D actor highlight from the 3D scene.
Add an annotation to the 3D scene.
Remove an annotation from the 3D scene.
Add a 2D decoration to the canvas.
Remove a 2D decoration from the canvas.
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.
Remove all actors in actorlist (default = all) from the scene.
Remove all highlights in actorlist (default = all) from the scene.
Remove all annotations in actorlist (default = all) from the scene.
Remove all decorations in actorlist (default = all) from the scene.
Remove all actors and decorations
Redraw all actors in the scene.
Sets the camera looking under angles at bbox.
This function sets the camera angles and adjusts the zooming. The camera distance remains unchanged.
If a bbox is specified, the camera will be zoomed to make the whole bbox visible. If no bbox is specified, the current scene bbox will be used. If no current bbox has been set, it will be calculated as the bbox of the whole scene.
If no camera angles are given, the camera orientation is kept. angles can be a set of 3 angles, or a string
Map the object coordinates (x,y,z) to window coordinates.
Map the window coordinates (x,y,z) to object coordinates.
Dolly zooming.
Zooms in with a factor f by moving the camera closer to the scene. This does noet change the camera’s FOV setting. It will change the perspective view though.
Rectangle zooming.
Zooms in/out by changing the area and position of the visible part of the lens. Unlike zoom(), this does not change the perspective view.
x0,y0,x1,y1 are pixel coordinates of the lower left and upper right corners of the area of the lens that will be mapped on the canvas viewport. Specifying values that lead to smaller width/height will zoom in.
Rectangle zooming with specified center.
This is like zoomRectangle, but the zoom rectangle is specified by its center and size, which may be more appropriate when using off-center zooming.
Rectangle zoom to make full scene visible.
Save the current OpenGL buffer
Show the saved buffer
Draw the focus rectangle.
The specified width is HALF of the line width
draw the cursor
Functions defined in module canvas
Return a list of the 2nd numbers in the openGL pick buffer.
Set the line stipple pattern.
When drawing lines, OpenGl can use a stipple pattern. The stipple is defined by two values: a pattern (on/off) of maximum 16 bits, used on the pixel level, and a multiplier factor for each bit.
If factor <= 0, the stippling is disabled.
Enable smooth shading
Disable smooth shading
Convert On/Off strings to a boolean
Enable/Disable an OpenGL facility, depending on onoff value
facility is an OpenGL facility. onoff can be True or False to enable, resp. disable the facility, or None to leave it unchanged.