Chemical Data Processing Library Python API - Version 1.1.1
Public Member Functions | Properties | List of all members
CDPL.Vis.Renderer2D Class Reference

An interface that provides methods for low level 2D drawing operations. More...

+ Inheritance diagram for CDPL.Vis.Renderer2D:

Public Member Functions

None __init__ ()
 Initializes the Renderer2D instance.
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
None saveState ()
 Saves the current renderer state. More...
 
None restoreState ()
 Restores the last renderer state saved by a call to saveState(). More...
 
None setTransform (Math.Matrix3D xform)
 Sets the applied affine transformation matrix to xform. More...
 
None transform (Math.Matrix3D xform)
 Multiplies the current affine transformation matrix by xform. More...
 
None setPen (Pen pen)
 Sets the pen to be used in subsequent drawing operations. More...
 
None setBrush (Brush brush)
 Sets the brush to be used in subsequent drawing operations. More...
 
None setFont (Font font)
 Sets the font to be used in subsequent text drawing operations. More...
 
None drawRectangle (float x, float y, float width, float height)
 Draws an axis aligned rectangle of the specified width and height whose upper-left corner is located at (x, y). More...
 
None drawEllipse (float x, float y, float width, float height)
 Draws an ellipse with the given width and height around the center position (x, y). More...
 
None drawPolygon (Math.Vector2DArray points)
 Draws the polygon defined by points. More...
 
None drawLine (float x1, float y1, float x2, float y2)
 Draws a line segment from (x1, y1) to (x2, y2). More...
 
None drawPolyline (Math.Vector2DArray points)
 Draws the polyline defined by points. More...
 
None drawLineSegments (Math.Vector2DArray points)
 Draws the sequence of disjoint line segments defined by points. More...
 
None drawPoint (float x, float y)
 Draws a point at the position (x, y). More...
 
None drawText (float x, float y, str txt)
 Draws the specified text at the position (x, y). More...
 
None drawPath (Path2D path)
 Draws the given path. More...
 
None setClipPath (Path2D path)
 
None clearClipPath ()
 Disables clipping.
 

Properties

 objectID = property(getObjectID)
 

Detailed Description

An interface that provides methods for low level 2D drawing operations.

For the drawing of graphical primitives the following methods are provided:

Drawing operations can be clipped to arbitrary shapes defined by a Vis.Path2D object. A new clip region is set by calling the method setClipPath() and disabled by calling clearClipPath().

Coordinates of points that define the geometry of graphical primitives are normally directly mapped to the coordinate system of the drawing device (e.g. an off-screen image buffer). This 1:1 mapping can be changed by applying affine transformations to the input coordinates.

Affine coordinate transformations can be specified by calling the methods:

The former method replaces the current transformation matrix by a matrix that was provided as argument. When the latter method is called, the current matrix gets multiplied with the argument matrix to produce a combined affine transformation. To restore the 1:1 coordinate mapping, call setTransform() with a default constructed Math.AffineTransform3D instance.

The style and color of lines and shape outlines is defined by the current pen which is specified by setPen(). The current pen also defines the color of rendered text and the color and diameter of points. The fill pattern and fill color of shapes (rectangles and polygons) is defined by the current brush which is specified by setBrush().

The current state of the renderer (brush, pen, font and transformation matrix) may be saved by saveState() and restored by restoreState().

Member Function Documentation

◆ getObjectID()

int CDPL.Vis.Renderer2D.getObjectID ( )

Returns the numeric identifier (ID) of the wrapped C++ class instance.

Different Python Renderer2D instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two Renderer2D instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ saveState()

None CDPL.Vis.Renderer2D.saveState ( )

Saves the current renderer state.

The method saves the current pen, brush, font and transformation matrix on an internal stack. The last saved state can be restored later on by a call to restoreState().

See also
restoreState()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ restoreState()

None CDPL.Vis.Renderer2D.restoreState ( )

Restores the last renderer state saved by a call to saveState().

See also
saveState()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ setTransform()

None CDPL.Vis.Renderer2D.setTransform ( Math.Matrix3D  xform)

Sets the applied affine transformation matrix to xform.

Parameters
xformThe new affine transformation matrix.

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ transform()

None CDPL.Vis.Renderer2D.transform ( Math.Matrix3D  xform)

Multiplies the current affine transformation matrix by xform.

Parameters
xformThe matrix by which the current affine transformation matrix is multiplied.

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ setPen()

None CDPL.Vis.Renderer2D.setPen ( Pen  pen)

Sets the pen to be used in subsequent drawing operations.

Parameters
penThe new pen for subsequent drawing operations.
See also
Vis.Pen

◆ setBrush()

None CDPL.Vis.Renderer2D.setBrush ( Brush  brush)

Sets the brush to be used in subsequent drawing operations.

Parameters
brushThe new brush for subsequent drawing operations.
See also
Vis.Brush

◆ setFont()

None CDPL.Vis.Renderer2D.setFont ( Font  font)

Sets the font to be used in subsequent text drawing operations.

Parameters
fontThe new font used in subsequent text drawing operations.
See also
Vis.Font

◆ drawRectangle()

None CDPL.Vis.Renderer2D.drawRectangle ( float  x,
float  y,
float  width,
float  height 
)

Draws an axis aligned rectangle of the specified width and height whose upper-left corner is located at (x, y).

The rectangle is filled as specified by the current brush and the outline will be drawn as specified by the current pen.

Parameters
xThe x-coordinate of the upper-left corner.
yThe y-coordinate of the upper-left corner.
widthThe width of the rectangle.
heightThe height of the rectangle.
See also
setPen(), setBrush()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ drawEllipse()

None CDPL.Vis.Renderer2D.drawEllipse ( float  x,
float  y,
float  width,
float  height 
)

Draws an ellipse with the given width and height around the center position (x, y).

The ellipse is filled as specified by the current brush and the outline will be drawn as specified by the current pen.

Parameters
xThe x-coordinate of the center point.
yThe y-coordinate of the center point.
widthThe width of the ellipse.
heightThe height of the ellipse.
See also
setPen(), setBrush()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ drawPolygon()

None CDPL.Vis.Renderer2D.drawPolygon ( Math.Vector2DArray  points)

Draws the polygon defined by points.

For a given set of \( N \) corner points \( p_i \) with \( i = 1, 2, \ldots, N \), the polygon's \( N \) edges are given by \( (p_1, p_2), (p_2, p_3), \ldots, (p_N, p_0) \). The polygon is filled as specified by the current brush and the outline will be drawn as specified by the current pen.

Parameters
pointsAn array of points specifying the corners of the polygon.
See also
setPen(), setBrush()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ drawLine()

None CDPL.Vis.Renderer2D.drawLine ( float  x1,
float  y1,
float  x2,
float  y2 
)

Draws a line segment from (x1, y1) to (x2, y2).

The line style, color, cap style and line width is specified by the current pen.

Parameters
x1The x-coordinate of the starting point.
y1The y-coordinate of the starting point.
x2The x-coordinate of the end point.
y2The y-coordinate of the end point.
See also
setPen()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ drawPolyline()

None CDPL.Vis.Renderer2D.drawPolyline ( Math.Vector2DArray  points)

Draws the polyline defined by points.

For a given set of \( N \) points \( p_i \) with \( i = 1, 2, \ldots, N \), \( N - 1 \) connected line segments \( (p_1, p_2), (p_2, p_3), \ldots, (p_{N - 1}, p_N) \) will be drawn. The line style, color, cap style, join style and line width is specified by the current pen.

Parameters
pointsAn array of points defining the polyline.
See also
setPen()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ drawLineSegments()

None CDPL.Vis.Renderer2D.drawLineSegments ( Math.Vector2DArray  points)

Draws the sequence of disjoint line segments defined by points.

For a given set of \( 2N \) points \( p_i \) with \( i = 1, 2, \ldots, 2N \), \( N \) disjoint line segments \( (p_1, p_2), (p_3, p_4), \ldots, (p_{2N - 1}, p_2N) \) will be drawn. The line style, color, cap style and line width is specified by the current pen.

Parameters
pointsAn array of points defining the line segments.
See also
setPen()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ drawPoint()

None CDPL.Vis.Renderer2D.drawPoint ( float  x,
float  y 
)

Draws a point at the position (x, y).

The diameter and color of the point is specified by the current pen.

Parameters
xThe x-coordinate of the point.
yThe y-coordinate of the point.
See also
setPen()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ drawText()

None CDPL.Vis.Renderer2D.drawText ( float  x,
float  y,
str  txt 
)

Draws the specified text at the position (x, y).

The text color is specified by the current pen. The font has to be specified by setFont().

Parameters
xThe x-position of the drawn text.
yThe y-position of the baseline.
txtThe text to draw.
See also
setPen(), setFont()

Reimplemented in CDPL.Vis.QtBackend.QtRenderer2D, and CDPL.Vis.CairoBackend.CairoRenderer2D.

◆ drawPath()

None CDPL.Vis.Renderer2D.drawPath ( Path2D  path)

Draws the given path.

The path is filled as specified by the current brush and the outline will be drawn as specified by the current pen.

Parameters
pathThe path to draw.
See also
setPen(), setBrush()

◆ setClipPath()

None CDPL.Vis.Renderer2D.setClipPath ( Path2D  path)
Parameters
path