Chemical Data Processing Library C++ API - Version 1.4.0
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 
75  void saveState();
76 
80  void restoreState();
81 
86  void setTransform(const Math::Matrix3D& xform);
87 
92  void transform(const Math::Matrix3D& xform);
93 
98  void setPen(const Pen& pen);
99 
104  void setBrush(const Brush& brush);
105 
110  void setFont(const Font& font);
111 
119  void drawRectangle(double x1, double y1, double x2, double y2);
120 
125  void drawPolygon(const Math::Vector2DArray& points);
126 
134  void drawLine(double x1, double y1, double x2, double y2);
135 
140  void drawPolyline(const Math::Vector2DArray& points);
141 
147 
153  void drawPoint(double x, double y);
154 
161  void drawText(double x, double y, const std::string& txt);
162 
170  void drawEllipse(double x, double y, double width, double height);
171 
176  void drawPath(const Path2D& path);
177 
182  void setClipPath(const Path2D& path);
183 
188 
189  private:
190  void fillPath() const;
191  void strokePath() const;
192 
193  typedef std::vector<Pen> PenStack;
194  typedef std::vector<Brush> BrushStack;
195  typedef std::vector<Font> FontStack;
196 
197  CairoPointer<cairo_t> cairoContext;
198  PenStack penStack;
199  BrushStack brushStack;
200  FontStack fontStack;
201  };
202  } // namespace Vis
203 } // namespace CDPL
204 
205 #endif // CDPL_VIS_CAIRORENDERER2D_HPP
Definition of class CDPL::Vis::Brush.
Definition of class CDPL::Vis::CairoPointer.
struct _cairo cairo_t
Definition: CairoPointer.hpp:35
Definition of class CDPL::Vis::Font.
Definition of class CDPL::Vis::Pen.
Definition of class CDPL::Vis::Renderer2D.
Definition of the preprocessor macro CDPL_VIS_API.
#define CDPL_VIS_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Specifies the fill pattern and fill color of shapes.
Definition: Brush.hpp:50
Implements the Renderer2D interface on top of the Cairo 2D Graphics Library.
Definition: CairoRenderer2D.hpp:57
void transform(const Math::Matrix3D &xform)
Right-multiplies the current transformation matrix by xform.
void drawPoint(double x, double y)
Draws a single point at (x, y).
void restoreState()
Pops the topmost stack entry and restores the renderer to the saved state.
void drawPath(const Path2D &path)
Draws (strokes and fills) the 2D path path.
void drawPolyline(const Math::Vector2DArray &points)
Draws the open polyline defined by the vertex sequence points.
void drawLine(double x1, double y1, double x2, double y2)
Draws a single line segment from (x1, y1) to (x2, y2).
void setPen(const Pen &pen)
Sets the pen used for drawing outlines and lines.
void drawPolygon(const Math::Vector2DArray &points)
Draws the (filled) polygon defined by the vertex sequence points.
void drawLineSegments(const Math::Vector2DArray &points)
Draws the disjoint line segments defined by consecutive vertex pairs in points.
void setFont(const Font &font)
Sets the font used for rendering text.
void drawRectangle(double x1, double y1, double x2, double y2)
Draws an axis-aligned rectangle from (x1, y1) to (x2, y2).
void setBrush(const Brush &brush)
Sets the brush used for filling shapes.
void setClipPath(const Path2D &path)
Sets the renderer's active clipping region to path.
void drawText(double x, double y, const std::string &txt)
Draws the text txt with its baseline starting at (x, y).
void setTransform(const Math::Matrix3D &xform)
Replaces the current transformation matrix by xform.
void clearClipPath()
Disables any currently active clipping region.
void saveState()
Pushes the current pen, brush, font, transformation and clip path onto an internal state stack.
CairoRenderer2D(const CairoPointer< cairo_t > &cairo_ctxt)
Constructs a renderer object that operates on the Cairo cdrawing ontext specified by cairo_ctxt.
void drawEllipse(double x, double y, double width, double height)
Draws an axis-aligned ellipse centered at (x, y) with the given width and height.
Specifies a font for drawing text.
Definition: Font.hpp:54
Provides a container for painting operations, enabling arbitrary graphical shapes to be constructed a...
Definition: Path2D.hpp:78
Specifies how to draw lines and outlines of shapes.
Definition: Pen.hpp:53
Interface providing methods for low level 2D drawing operations.
Definition: Renderer2D.hpp:86
VectorArray< Vector2D > Vector2DArray
Array storing vectors of type Math::Vector2D.
Definition: VectorArray.hpp:80
CMatrix< double, 3, 3 > Matrix3D
Bounded 3x3 matrix holding floating point values of type double.
Definition: Matrix.hpp:3180
The namespace of the Chemical Data Processing Library.