22. decors — 2D decorations for the OpenGL canvas. — pyFormex 0.9.1 documentation

### Navigation

- index
- modules |
- next |
- previous |
- pyFormex 0.9.1 documentation >
- pyFormex reference manual >

# 22. `decors` — 2D decorations for the OpenGL canvas.

2D decorations are objects that are drawn in 2D on the flat canvas instead of through the 3D OpenGL engine.

`Classes defined in module decors`

class `decors.` `Decoration`(x, y, **kargs)

  A decoration is a 2-D drawing at canvas position x,y.

  All decorations have at least the following attributes:

  - x,y : (int) window coordinates of the insertion point

  - drawGL() : function that draws the decoration at (x,y).

      This should only use openGL function that are allowed in a display list.

  `drawGL`(**kargs)

    Perform the OpenGL drawing functions to display the actor.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

class `decors.` `Mark`(x, y, mark='dot', color=None, linewidth=None, **kargs)

  A mark at a fixed position on the canvas.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

class `decors.` `Line`(x1, y1, x2, y2, color=None, linewidth=None, **kargs)

  A straight line on the canvas.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

class `decors.` `GlutText`(text, x, y, font='9x15', size=None, gravity=None, color=None, zoom=None, **kargs)

  A viewport decoration showing a text string.

  - text: a simple string, a multiline string or a list of strings. If it is a string, it will be splitted on the occurrence of ‘n’ characters.
  - x,y: insertion position on the canvas
  - gravity: a string that determines the adjusting of the text with respect to the insert position. It can be a combination of one of the characters ‘N or ‘S’ to specify the vertical positon, and ‘W’ or ‘E’ for the horizontal. The default(empty) string will center the text.
  `drawGL`(**kargs)

    Draw the text.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

`decors.` `Text`

  alias of `GlutText`

class `decors.` `ColorLegend`(colorlegend, x, y, w, h, ngrid=0, linewidth=None, nlabel=-1, font=None, size=None, dec=2, scale=0, lefttext=False, **kargs)

  A labeled colorscale legend.

  When showing the distribution of some variable over a domain by means of a color encoding, the viewer expects some labeled colorscale as a guide to decode the colors. The ColorLegend decoration provides such a color legend. This class only provides the visual details of the scale. The conversion of the numerical values to the matching colors is provided by the `colorscale.ColorLegend` class.

  Parameters:

  - colorlegend: a `colorscale.ColorLegend` instance providing conversion between numerical values and colors
  - x,y,w,h: four integers specifying the position and size of the color bar rectangle
  - ngrid: int: number of intervals for the grid lines to be shown. If > 0, grid lines are drawn around the color bar and between the `ngrid` intervals. If = 0, no grid lines are drawn. If < 0 (default), the value is set equal to the number of colors (as set in the `colorlegend`) or to 0 if this number is higher than 50.
  - linewidth: float: width of the grid lines. If not specified, the current canvas line width is used.
  - nlabel: int: number of intervals for the labels to be shown. If > 0, labels will be displayed at nlabel interval borders, if possible. The number of labels displayed thus will be `nlabel+1`, or less if the labels would otherwise be too close or overlapping. If 0, no labels are shown. If < 0 (default), a default number of labels is shown.
  - font, size: font and size to be used for the labels
  - dec: int: number of decimals to be used in the labels
  - scale: int: exponent of 10 for the scaling factor of the label values. The displayed values will be equal to the real values multiplied with `10**scale`.
  - lefttext: bool: if True, the labels will be drawn to the left of the color bar. The default is to draw the labels at the right.

  Some practical guidelines:

  - The number of colors is defined by the `colorlegend` argument.
  - Large numbers of colors result inb a quasi continuous color scheme.
  - With a high number of colors, grid lines disturb the image, so either use `ngrid=0` or `ngrid=` to only draw a border around the colors.
  - With a small number of colors, set `ngrid = len(colorlegend.colors)` to add gridlines between each color. Without it, the individual colors in the color bar may seem to be not constant, due to an optical illusion. Adding the grid lines reduces this illusion.
  - When using both grid lines and labels, set both `ngrid` and `nlabel` to the same number or make one a multiple of the other. Not doing so may result in a very confusing picture.
  - The best practices are to use either a low number of colors (<=20) and the default `ngrid` and `nlabel`, or a high number of colors (>=200) and the default values or a low value for `nlabel`.

  The ColorScale example script provides opportunity to experiment with different settings.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

class `decors.` `Rectangle`(x1, y1, x2, y2, color=None, texture=None, **kargs)

  A 2D-rectangle on the canvas.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

class `decors.` `Grid`(x1, y1, x2, y2, nx=1, ny=1, color=None, linewidth=None, **kargs)

  A 2D-grid on the canvas.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

class `decors.` `LineDrawing`(data, color=None, linewidth=None, **kargs)

  A collection of straight lines on the canvas.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

class `decors.` `Triade`(pos='lb', siz=100, pat='3:012934', legend='xyz', color=[(1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0), (0.0, 1.0, 1.0), (1.0, 0.0, 1.0), (1.0, 1.0, 0.0)], **kargs)

  An OpenGL actor representing a triade of global axes.

  - pos: position on the canvas: two characters, of which first sets horizontal position (‘l’, ‘c’ or ‘r’) and second sets vertical position (‘b’, ‘c’ or ‘t’).
  - size: size in pixels of the zone displaying the triade.
  - pat: shape to be drawn in the coordinate planes. Default is a square. ‘16’ givec a triangle. ‘’ disables the planes.
  - legend: text symbols to plot at the end of the axes. A 3-character string or a tuple of 3 strings.
  `drawGL`(**kargs)

    Perform the OpenGL drawing functions to display the actor.

  `pickGL`(**kargs)

    Mimick the OpenGL drawing functions to pick (from) the actor.

  `setLineWidth`(linewidth)

    Set the linewidth of the Drawable.

  `setLineStipple`(linestipple)

    Set the linewidth of the Drawable.

  `setColor`(color=None, colormap=None, ncolors=1)

    Set the color of the Drawable.

  `setTexture`(texture)

    Set the texture data of the Drawable.

`Functions defined in module decors`

`decors.` `drawDot`(x, y)

  Draw a dot at canvas coordinates (x,y).

`decors.` `drawLine`(x1, y1, x2, y2)

  Draw a straight line from (x1,y1) to (x2,y2) in canvas coordinates.

`decors.` `drawGrid`(x1, y1, x2, y2, nx, ny)

  Draw a rectangular grid of lines

  The rectangle has (x1,y1) and and (x2,y2) as opposite corners. There are (nx,ny) subdivisions along the (x,y)-axis. So the grid has (nx+1) * (ny+1) lines. nx=ny=1 draws a rectangle. nx=0 draws 1 vertical line (at x1). nx=-1 draws no vertical lines. ny=0 draws 1 horizontal line (at y1). ny=-1 draws no horizontal lines.

`decors.` `drawRect`(x1, y1, x2, y2)

  Draw the circumference of a rectangle.

`decors.` `drawRectangle`(x1, y1, x2, y2, color, texture=None)

  Draw a single rectangular quad.

### Navigation

- index
- modules |
- next |
- previous |
- pyFormex 0.9.1 documentation >
- pyFormex reference manual >