Chemical Data Processing Library C++ API - Version 1.2.0
Path2D.hpp
Go to the documentation of this file.
1 /*
2  * Path2D.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_PATH2D_HPP
30 #define CDPL_VIS_PATH2D_HPP
31 
32 #include <vector>
33 
34 #include "CDPL/Vis/APIPrefix.hpp"
35 #include "CDPL/Math/Vector.hpp"
36 
37 
38 namespace CDPL
39 {
40 
41  namespace Vis
42  {
43 
44  class Path2DConverter;
45  class Rectangle2D;
46 
78  {
79 
80  public:
84  enum FillRule
85  {
86 
95 
104  WINDING
105  };
106 
111 
116  Path2D(const Path2D& path);
117 
121  virtual ~Path2D();
122 
127  bool isEmpty() const;
128 
133  bool hasDrawingElements() const;
134 
139  void clear();
140 
146  void setFillRule(FillRule rule);
147 
153 
159  void moveTo(double x, double y);
160 
165  void moveTo(const Math::Vector2D& pos);
166 
184  void arc(double cx, double cy, double rx, double ry, double start_ang, double sweep);
185 
202  void arc(const Math::Vector2D& ctr, double rx, double ry, double start_ang, double sweep);
203 
221  void arcTo(double cx, double cy, double rx, double ry, double start_ang, double sweep);
222 
239  void arcTo(const Math::Vector2D& ctr, double rx, double ry, double start_ang, double sweep);
240 
250  void lineTo(double x, double y);
251 
260  void lineTo(const Math::Vector2D& pos);
261 
269  void closePath();
270 
279  void addEllipse(double x, double y, double width, double height);
280 
288  void addEllipse(const Math::Vector2D& pos, double width, double height);
289 
298  void addRectangle(double x, double y, double width, double height);
299 
307  void addRectangle(const Math::Vector2D& pos, double width, double height);
308 
313  void getBounds(Rectangle2D& bounds) const;
314 
319  void convert(Path2DConverter& conv) const;
320 
326  bool operator==(const Path2D& path) const;
327 
333  bool operator!=(const Path2D& path) const;
334 
340  Path2D& operator+=(const Path2D& path);
341 
347  Path2D& operator=(const Path2D& path);
348 
349  private:
350  struct Element;
351 
352  typedef std::vector<Element> ElementList;
353 
354  FillRule fillRule;
355  ElementList elements;
356  };
357  } // namespace Vis
358 } // namespace CDPL
359 
360 #endif // CDPL_VIS_PATH2D_HPP
Definition of vector data types.
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.
Provides an interface for classes that implement the conversion of Vis::Path2D objects into rendering...
Definition: Path2DConverter.hpp:48
Provides a container for painting operations, enabling arbitrary graphical shapes to be constructed a...
Definition: Path2D.hpp:78
Path2D & operator=(const Path2D &path)
Assignment operator.
bool isEmpty() const
Tells whether the Path2D instance does not contain any elements.
Path2D & operator+=(const Path2D &path)
Appends the elements stored in the Path2D instance path to this path.
void addEllipse(const Math::Vector2D &pos, double width, double height)
Creates an ellipse positioned at pos with the specified width and height, and adds it to this path as...
void arc(double cx, double cy, double rx, double ry, double start_ang, double sweep)
Creates an elliptical arc centered at (cx, cy) with ellipse radii rx and ry beginning at the angle st...
void addRectangle(double x, double y, double width, double height)
Creates a rectangle positioned at (x, y) with the specified width and height, and adds it to this pat...
void moveTo(const Math::Vector2D &pos)
Sets the current position to pos and starts a new subpath, implicitly closing the previous path.
void closePath()
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting ...
void arcTo(double cx, double cy, double rx, double ry, double start_ang, double sweep)
Creates an elliptical arc centered at (cx, cy) with ellipse radii rx and ry beginning at the angle st...
bool operator!=(const Path2D &path) const
Non-equality comparison operator.
FillRule getFillRule() const
Returns the currently set fill rule.
virtual ~Path2D()
Virtual destructor.
void addRectangle(const Math::Vector2D &pos, double width, double height)
Creates a rectangle positioned at pos with the specified width and height, and adds it to this path a...
void clear()
Deletes all path elements added so far and sets the fill rule to its default.
void lineTo(double x, double y)
Adds a straight line from the current position to the point (x, y).
void lineTo(const Math::Vector2D &pos)
Adds a straight line from the current position to the point (x, y).
bool hasDrawingElements() const
Tells whether the Path2D instance contains any elements representing drawing operations (lines and ar...
void arcTo(const Math::Vector2D &ctr, double rx, double ry, double start_ang, double sweep)
Creates an elliptical arc centered at ctr with ellipse radii rx and ry beginning at the angle start_a...
Path2D(const Path2D &path)
Constructs a copy of the Path2D instance path.
void moveTo(double x, double y)
Sets the current position to (x, y) and starts a new subpath, implicitly closing the previous path.
void arc(const Math::Vector2D &ctr, double rx, double ry, double start_ang, double sweep)
Creates an elliptical arc centered at ctr with ellipse radii rx and ry beginning at the angle start_a...
void setFillRule(FillRule rule)
Sets the fill rule of the path to the specified value.
bool operator==(const Path2D &path) const
Equality comparison operator.
Path2D()
Constructs an empty Path2D instance.
void getBounds(Rectangle2D &bounds) const
Calculates the axis-aligned bounding box of the path.
void convert(Path2DConverter &conv) const
Iterates over the stored path elements and calls the corresponding method of conv for each visited el...
FillRule
Specifies which method to use for filling closed shapes described by the Path2D object.
Definition: Path2D.hpp:85
@ EVEN_ODD
Specifies that the path has to be filled using the odd even fill rule.
Definition: Path2D.hpp:94
void addEllipse(double x, double y, double width, double height)
Creates an ellipse positioned at (x, y) with the specified width and height, and adds it to this path...
Specifies an axis aligned rectangular area in 2D space.
Definition: Rectangle2D.hpp:51
CVector< double, 2 > Vector2D
A bounded 2 element vector holding floating point values of type double.
Definition: Vector.hpp:1632
The namespace of the Chemical Data Processing Library.