Chemical Data Processing Library C++ API - Version 1.1.1
Public Member Functions | List of all members
CDPL::Vis::Renderer2D Class Referenceabstract

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

#include <Renderer2D.hpp>

+ Inheritance diagram for CDPL::Vis::Renderer2D:

Public Member Functions

virtual ~Renderer2D ()
 Virtual destructor. More...
 
virtual void saveState ()=0
 Saves the current renderer state. More...
 
virtual void restoreState ()=0
 Restores the last renderer state saved by a call to saveState(). More...
 
virtual void setTransform (const Math::Matrix3D &xform)=0
 Sets the applied affine transformation matrix to xform. More...
 
virtual void transform (const Math::Matrix3D &xform)=0
 Multiplies the current affine transformation matrix by xform. More...
 
virtual void setPen (const Pen &pen)=0
 Sets the pen to be used in subsequent drawing operations. More...
 
virtual void setBrush (const Brush &brush)=0
 Sets the brush to be used in subsequent drawing operations. More...
 
virtual void setFont (const Font &font)=0
 Sets the font to be used in subsequent text drawing operations. More...
 
virtual void drawRectangle (double x, double y, double width, double height)=0
 Draws an axis aligned rectangle of the specified width and height whose upper-left corner is located at (x, y). More...
 
virtual void drawPolygon (const Math::Vector2DArray &points)=0
 Draws the polygon defined by points. More...
 
virtual void drawLine (double x1, double y1, double x2, double y2)=0
 Draws a line segment from (x1, y1) to (x2, y2). More...
 
virtual void drawPolyline (const Math::Vector2DArray &points)=0
 Draws the polyline defined by points. More...
 
virtual void drawLineSegments (const Math::Vector2DArray &points)=0
 Draws the sequence of disjoint line segments defined by points. More...
 
virtual void drawPoint (double x, double y)=0
 Draws a point at the position (x, y). More...
 
virtual void drawEllipse (double x, double y, double width, double height)=0
 Draws an ellipse with the given width and height around the center position (x, y). More...
 
virtual void drawPath (const Path2D &path)=0
 Draws the given path. More...
 
virtual void drawText (double x, double y, const std::string &txt)=0
 Draws the specified text at the position (x, y). More...
 
virtual void setClipPath (const Path2D &path)=0
 
virtual void clearClipPath ()=0
 Disables clipping. More...
 

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().

Constructor & Destructor Documentation

◆ ~Renderer2D()

virtual CDPL::Vis::Renderer2D::~Renderer2D ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ saveState()

virtual void CDPL::Vis::Renderer2D::saveState ( )
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ restoreState()

virtual void CDPL::Vis::Renderer2D::restoreState ( )
pure virtual

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

See also
saveState()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ setTransform()

virtual void CDPL::Vis::Renderer2D::setTransform ( const Math::Matrix3D xform)
pure virtual

Sets the applied affine transformation matrix to xform.

Parameters
xformThe new affine transformation matrix.

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ transform()

virtual void CDPL::Vis::Renderer2D::transform ( const Math::Matrix3D xform)
pure virtual

Multiplies the current affine transformation matrix by xform.

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

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ setPen()

virtual void CDPL::Vis::Renderer2D::setPen ( const Pen pen)
pure virtual

Sets the pen to be used in subsequent drawing operations.

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

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ setBrush()

virtual void CDPL::Vis::Renderer2D::setBrush ( const Brush brush)
pure virtual

Sets the brush to be used in subsequent drawing operations.

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

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ setFont()

virtual void CDPL::Vis::Renderer2D::setFont ( const Font font)
pure virtual

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

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawRectangle()

virtual void CDPL::Vis::Renderer2D::drawRectangle ( double  x,
double  y,
double  width,
double  height 
)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawPolygon()

virtual void CDPL::Vis::Renderer2D::drawPolygon ( const Math::Vector2DArray points)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawLine()

virtual void CDPL::Vis::Renderer2D::drawLine ( double  x1,
double  y1,
double  x2,
double  y2 
)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawPolyline()

virtual void CDPL::Vis::Renderer2D::drawPolyline ( const Math::Vector2DArray points)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawLineSegments()

virtual void CDPL::Vis::Renderer2D::drawLineSegments ( const Math::Vector2DArray points)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawPoint()

virtual void CDPL::Vis::Renderer2D::drawPoint ( double  x,
double  y 
)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawEllipse()

virtual void CDPL::Vis::Renderer2D::drawEllipse ( double  x,
double  y,
double  width,
double  height 
)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawPath()

virtual void CDPL::Vis::Renderer2D::drawPath ( const Path2D path)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ drawText()

virtual void CDPL::Vis::Renderer2D::drawText ( double  x,
double  y,
const std::string &  txt 
)
pure virtual

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()

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.

◆ setClipPath()

virtual void CDPL::Vis::Renderer2D::setClipPath ( const Path2D path)
pure virtual

◆ clearClipPath()

virtual void CDPL::Vis::Renderer2D::clearClipPath ( )
pure virtual

Disables clipping.

Implemented in CDPL::Vis::QtRenderer2D, and CDPL::Vis::CairoRenderer2D.


The documentation for this class was generated from the following file: