102. opengl.canvas_settings — This modules defines the CanvasSettings class

102.1. Classes defined in module opengl.canvas_settings

class opengl.canvas_settings.Light(ambient=0.0, diffuse=0.0, specular=0.0, position=[0.0, 0.0, 1.0], enabled=True)[source]

A class representing an OpenGL light.

The light can emit 3 types of light: ambient, diffuse and specular, which can have different color and are all off by default.

class opengl.canvas_settings.LightProfile(ambient, lights)[source]

A lightprofile contains all the lighting parameters.

Currently this consists off: - ambient: the global ambient lighting (currently a float) - lights: a list of 1 to 4 Lights

class opengl.canvas_settings.CanvasSettings(**kargs)[source]

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:

  • mode settings are set during the initialization of the canvas and can/should not be changed during the drawing of actors and decorations;

  • default settings can be used as default values but may be changed during the drawing of actors/decorations: they are reset before each individual draw instruction.

Currently the following mode settings are defined:

  • bgmode: the viewport background color mode

  • bgcolor: the viewport background color: a single color or a list of colors (max. 4 are used).

  • bgimage: background image filename

  • alphablend: boolean (transparency on/off)

The list of default settings includes:

  • fgcolor: the default drawing color

  • bkcolor: the default backface color

  • slcolor: the highlight color

  • colormap: the default color map to be used if color is an index

  • bklormap: the default color map to be used if bkcolor is an index

  • textcolor: the default color for text drawing

  • smooth: boolean (smooth/flat shading)

  • lighting: boolean (lights on/off)

  • culling: boolean

  • transparency: float (0.0..1.0)

  • avgnormals: boolean

  • wiremode: integer -3..3

  • pointsize: the default size for drawing points

  • marksize: the default size for drawing markers

  • linewidth: the default width for drawing lines

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(d={})[source]

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(d, strict=True)[source]

Update current values with the specified settings

Returns the sanitized update values.

classmethod checkDict(dict, strict=True)[source]

Transform a dict to acceptable settings.

activate()[source]

Activate the default canvas settings in the GL machine.

static extractCanvasSettings(d)[source]

Split a dict in canvas settings and other items.

Returns a tuple of two dicts: the first one contains the items that are canvas settings, the second one the rest.