Chemical Data Processing Library C++ API - Version 1.1.1
CairoRenderer2D.hpp
Go to the documentation of this file.
1 /*
2  * CairoRenderer2D.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_VIS_CAIRORENDERER2D_HPP
30 #define CDPL_VIS_CAIRORENDERER2D_HPP
31 
32 #include <vector>
33 
34 #include "CDPL/Vis/APIPrefix.hpp"
35 #include "CDPL/Vis/Renderer2D.hpp"
36 #include "CDPL/Vis/Pen.hpp"
37 #include "CDPL/Vis/Brush.hpp"
38 #include "CDPL/Vis/Font.hpp"
40 
41 
42 typedef struct _cairo cairo_t;
43 
44 
45 namespace CDPL
46 {
47 
48  namespace Vis
49  {
50 
57  {
58 
59  public:
66 
71 
72  void saveState();
73  void restoreState();
74 
75  void setTransform(const Math::Matrix3D& xform);
76  void transform(const Math::Matrix3D& xform);
77 
78  void setPen(const Pen& pen);
79  void setBrush(const Brush& brush);
80  void setFont(const Font& font);
81 
82  void drawRectangle(double x1, double y1, double x2, double y2);
83  void drawPolygon(const Math::Vector2DArray& points);
84  void drawLine(double x1, double y1, double x2, double y2);
85  void drawPolyline(const Math::Vector2DArray& points);
87  void drawPoint(double x, double y);
88  void drawText(double x, double y, const std::string& txt);
89  void drawEllipse(double x, double y, double width, double height);
90  void drawPath(const Path2D& path);
91 
92  void setClipPath(const Path2D& path);
93  void clearClipPath();
94 
95  private:
96  void fillPath() const;
97  void strokePath() const;
98 
99  typedef std::vector<Pen> PenStack;
100  typedef std::vector<Brush> BrushStack;
101  typedef std::vector<Font> FontStack;
102 
103  CairoPointer<cairo_t> cairoContext;
104  PenStack penStack;
105  BrushStack brushStack;
106  FontStack fontStack;
107  };
108  } // namespace Vis
109 } // namespace CDPL
110 
111 #endif // CDPL_VIS_CAIRORENDERER2D_HPP
CDPL::Vis::CairoRenderer2D::setClipPath
void setClipPath(const Path2D &path)
CDPL::Vis::Renderer2D
An interface that provides methods for low level 2D drawing operations.
Definition: Renderer2D.hpp:86
CDPL::Vis::CairoRenderer2D::drawText
void drawText(double x, double y, const std::string &txt)
Draws the specified text at the position (x, y).
CDPL::Vis::CairoRenderer2D::drawRectangle
void drawRectangle(double x1, double y1, double x2, double y2)
Draws an axis aligned rectangle of the specified width and height whose upper-left corner is located ...
Font.hpp
Definition of the class CDPL::Vis::Font.
CDPL::Vis::Pen
Specifies how to draw lines and outlines of shapes.
Definition: Pen.hpp:53
CDPL::Vis::CairoRenderer2D::drawPoint
void drawPoint(double x, double y)
Draws a point at the position (x, y).
CDPL::Vis::CairoRenderer2D::setBrush
void setBrush(const Brush &brush)
Sets the brush to be used in subsequent drawing operations.
CDPL::Vis::CairoRenderer2D::saveState
void saveState()
Saves the current renderer state.
CDPL::Vis::CairoRenderer2D::setTransform
void setTransform(const Math::Matrix3D &xform)
Sets the applied affine transformation matrix to xform.
CDPL::Vis::CairoRenderer2D::drawPolyline
void drawPolyline(const Math::Vector2DArray &points)
Draws the polyline defined by points.
CDPL::Vis::CairoRenderer2D
Implements the Renderer2D interface on top of the Cairo 2D Graphics Library.
Definition: CairoRenderer2D.hpp:57
cairo_t
struct _cairo cairo_t
Definition: CairoPointer.hpp:35
CDPL::Vis::CairoRenderer2D::setFont
void setFont(const Font &font)
Sets the font to be used in subsequent text drawing operations.
CDPL::Vis::Font
Specifies a font for drawing text.
Definition: Font.hpp:54
Pen.hpp
Definition of the class CDPL::Vis::Pen.
CDPL::Vis::Path2D
Provides a container for painting operations, enabling arbitrary graphical shapes to be constructed a...
Definition: Path2D.hpp:78
CDPL::Vis::CairoRenderer2D::clearClipPath
void clearClipPath()
Disables clipping.
CDPL::Vis::CairoRenderer2D::drawLineSegments
void drawLineSegments(const Math::Vector2DArray &points)
Draws the sequence of disjoint line segments defined by points.
CDPL_VIS_API
#define CDPL_VIS_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Vis::CairoRenderer2D::setPen
void setPen(const Pen &pen)
Sets the pen to be used in subsequent drawing operations.
CDPL::Vis::CairoRenderer2D::drawEllipse
void drawEllipse(double x, double y, double width, double height)
Draws an ellipse with the given width and height around the center position (x, y).
CDPL::Vis::CairoRenderer2D::CairoRenderer2D
CairoRenderer2D(const CairoPointer< cairo_t > &cairo_ctxt)
Constructs a renderer object that operates on the Cairo cdrawing ontext specified by cairo_ctxt.
CDPL::Math::Matrix3D
CMatrix< double, 3, 3 > Matrix3D
A bounded 3x3 matrix holding floating point values of type double.
Definition: Matrix.hpp:1849
Renderer2D.hpp
Definition of the class CDPL::Vis::Renderer2D.
CDPL::Vis::CairoRenderer2D::drawLine
void drawLine(double x1, double y1, double x2, double y2)
Draws a line segment from (x1, y1) to (x2, y2).
CDPL::Vis::CairoRenderer2D::restoreState
void restoreState()
Restores the last renderer state saved by a call to saveState().
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Vis::CairoRenderer2D::drawPath
void drawPath(const Path2D &path)
Draws the given path.
CDPL::Vis::CairoRenderer2D::~CairoRenderer2D
~CairoRenderer2D()
Destructor.
CDPL::Vis::Brush
Specifies the fill pattern and fill color of shapes.
Definition: Brush.hpp:50
Brush.hpp
Definition of the class CDPL::Vis::Brush.
CDPL::Math::Vector2DArray
VectorArray< Vector2D > Vector2DArray
An array of Math::Vector2D objects.
Definition: VectorArray.hpp:79
CDPL::Vis::CairoRenderer2D::drawPolygon
void drawPolygon(const Math::Vector2DArray &points)
Draws the polygon defined by points.
APIPrefix.hpp
Definition of the preprocessor macro CDPL_VIS_API.
CairoPointer.hpp
Definition of the class CDPL::Vis::CairoPointer.
CDPL::Vis::CairoPointer< cairo_t >
CDPL::Vis::CairoRenderer2D::transform
void transform(const Math::Matrix3D &xform)
Multiplies the current affine transformation matrix by xform.