Chemical Data Processing Library C++ API - Version 1.4.0
QtRenderer2D.hpp
Go to the documentation of this file.
1 /*
2  * QtRenderer2D.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_QTRENDERER2D_HPP
30 #define CDPL_VIS_QTRENDERER2D_HPP
31 
32 #include <memory>
33 
34 #include "CDPL/Vis/APIPrefix.hpp"
35 #include "CDPL/Vis/Renderer2D.hpp"
36 
37 
38 class QPainter;
39 class QPolygonF;
40 class QPainterPath;
41 
42 
43 namespace CDPL
44 {
45 
46  namespace Vis
47  {
48 
58  {
59 
60  public:
65  QtRenderer2D(QPainter& painter);
66 
67  QtRenderer2D(const QtRenderer2D&) = delete;
68 
73 
74  QtRenderer2D& operator=(const QtRenderer2D&) = delete;
75 
76  void saveState();
77 
78  void restoreState();
79 
80  void setTransform(const Math::Matrix3D& xform);
81 
82  void transform(const Math::Matrix3D& xform);
83 
84  void setPen(const Pen& pen);
85 
86  void setBrush(const Brush& brush);
87 
88  void setFont(const Font& font);
89 
90  void drawRectangle(double x1, double y1, double x2, double y2);
91 
92  void drawPolygon(const Math::Vector2DArray& points);
93 
94  void drawLine(double x1, double y1, double x2, double y2);
95 
96  void drawPolyline(const Math::Vector2DArray& points);
97 
99 
100  void drawPoint(double x, double y);
101 
102  void drawText(double x, double y, const std::string& txt);
103 
104  void drawEllipse(double x, double y, double width, double height);
105 
106  void drawPath(const Path2D& path);
107 
108  void setClipPath(const Path2D& path);
109 
111 
112  private:
113  void convertToQPolygon(const Math::Vector2DArray&);
114 
115  QPainter& qPainter;
116  std::unique_ptr<QPolygonF> qPolygon;
117  std::unique_ptr<QPainterPath> qPainterPath;
118  };
119  } // namespace Vis
120 } // namespace CDPL
121 
122 #endif // CDPL_VIS_QTRENDERER2D_HPP
Definition of class CDPL::Vis::Renderer2D.
Definition of the preprocessor macro CDPL_VIS_API.
#define CDPL_VIS_QT_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
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
Implements the Vis::Renderer2D interface on top of the Qt Toolkit.
Definition: QtRenderer2D.hpp:58
void transform(const Math::Matrix3D &xform)
Right-multiplies the current affine transformation matrix by xform.
void setTransform(const Math::Matrix3D &xform)
Sets the applied affine transformation matrix to xform.
void saveState()
Saves the current renderer state.
void drawPolyline(const Math::Vector2DArray &points)
Draws the polyline defined by points.
QtRenderer2D(QPainter &painter)
Constructs a QtRenderer2D instance which uses the QPainter instance painter for its drawing operation...
void restoreState()
Restores the last renderer state saved by a call to saveState().
void drawLineSegments(const Math::Vector2DArray &points)
Draws the sequence of disjoint line segments defined by points.
QtRenderer2D & operator=(const QtRenderer2D &)=delete
void setPen(const Pen &pen)
Sets the pen to be used in subsequent drawing operations.
void drawEllipse(double x, double y, double width, double height)
Draws an axis-aligned ellipse with the given width and height around the center position (x,...
void drawPath(const Path2D &path)
Draws the given path.
void drawLine(double x1, double y1, double x2, double y2)
Draws a line segment from (x1, y1) to (x2, y2).
void clearClipPath()
Disables any currently active clipping region.
void drawPolygon(const Math::Vector2DArray &points)
Draws the polygon defined by points.
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 ...
void setBrush(const Brush &brush)
Sets the brush to be used in subsequent drawing operations.
QtRenderer2D(const QtRenderer2D &)=delete
void drawPoint(double x, double y)
Draws a point at the position (x, y).
void drawText(double x, double y, const std::string &txt)
Draws the specified text at the position (x, y).
void setFont(const Font &font)
Sets the font to be used in subsequent text drawing operations.
~QtRenderer2D()
Destructor.
void setClipPath(const Path2D &path)
Enables clipping and establishes a new clip region.
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:82
CMatrix< double, 3, 3 > Matrix3D
Bounded 3×3 matrix holding floating-point values of type double.
Definition: Matrix.hpp:3504
The namespace of the Chemical Data Processing Library.