IWORKPath.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * This file is part of the libetonyek project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef IWORKPATH_H_INCLUDED
11 #define IWORKPATH_H_INCLUDED
12 
13 #include "IWORKPath_fwd.h"
14 
15 #include <string>
16 
17 #include <glm/glm.hpp>
18 
19 #include <librevenge/librevenge.h>
20 
21 #include "libetonyek_utils.h"
22 
23 #include "IWORKTypes.h"
24 
25 namespace libetonyek
26 {
27 
28 class IWORKPath
29 {
30  friend bool approxEqual(const IWORKPath &left, const IWORKPath &right, const double eps);
31 
32 public:
33  struct Impl;
34  struct InvalidException {};
35 
36 public:
37  IWORKPath();
38  explicit IWORKPath(const std::string &path);
39  IWORKPath(const IWORKPath &other);
40  IWORKPath &operator=(const IWORKPath &other);
41 
42  void swap(IWORKPath &other);
43 
44  void clear();
45 
46  void appendMoveTo(double x, double y);
47  void appendLineTo(double x, double y);
48  void appendQCurveTo(double x1, double y1, double x, double y);
49  void appendCCurveTo(double x1, double y1, double x2, double y2, double x, double y);
50  void appendClose();
51 
52  void closePath(bool closeOnlyIsSamePoint=true);
53  void computeBoundingBox(double &minX, double &minY, double &maxX, double &maxY, double factor=1) const;
54  bool isRectangle() const;
59  void operator*=(const glm::dmat3 &tr);
60 
61  /* Create a string representation of this path.
62  *
63  * @return an SVG path representing this.
64  */
65  const std::string str() const;
66 
69  void write(librevenge::RVNGPropertyListVector &vec, double deltaX=0, double deltaY=0) const;
70 private:
71  std::shared_ptr<Impl> m_impl;
72 };
73 
74 bool approxEqual(const IWORKPath &left, const IWORKPath &right, double eps = ETONYEK_EPSILON);
75 bool operator==(const IWORKPath &left, const IWORKPath &right);
76 bool operator!=(const IWORKPath &left, const IWORKPath &right);
77 
84 IWORKPath operator*(const IWORKPath &path, const glm::dmat3 &tr);
85 
87 {
88 public:
90  IWORKPathPtr_t getPath() const;
91 
92  boost::optional<IWORKPosition> m_positions[3];
93  boost::optional<IWORKSize> m_size;
94  bool m_isSpline;
95 };
96 
97 }
98 
99 #endif // IWORKPATH_H_INCLUDED
100 
101 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
Definition: IWORKBezierElement.cpp:20
bool isRectangle() const
Definition: IWORKToken.h:358
IWORKPath operator*(const IWORKPath &path, const glm::dmat3 &tr)
Create a transformed path.
void write(librevenge::RVNGPropertyListVector &vec, double deltaX=0, double deltaY=0) const
Create librevenge representation of this path.
double y
Definition: IWORKShape.cpp:46
void swap(IWORKPath &other)
void computeBoundingBox(double &minX, double &minY, double &maxX, double &maxY, double factor=1) const
boost::optional< IWORKSize > m_size
Definition: IWORKPath.h:93
void operator*=(const glm::dmat3 &tr)
Transform all elements of the path.
Definition: IWORKToken.h:568
void appendQCurveTo(double x1, double y1, double x, double y)
double x
Definition: IWORKShape.cpp:45
void appendMoveTo(double x, double y)
const std::string str() const
Definition: IWORKPath.h:28
Definition: KEY1Token.h:206
Definition: IWORKPath.h:34
Definition: IWORKToken.h:597
void closePath(bool closeOnlyIsSamePoint=true)
bool operator==(const IWORKPath &left, const IWORKPath &right)
std::shared_ptr< Impl > m_impl
Definition: IWORKPath.h:71
bool m_isSpline
Definition: IWORKPath.h:94
void appendLineTo(double x, double y)
Definition: IWORKPath.h:86
bool operator!=(const IWORKPath &left, const IWORKPath &right)
Definition: IWORKToken.h:411
#define ETONYEK_EPSILON
Definition: libetonyek_utils.h:26
std::shared_ptr< IWORKPath > IWORKPathPtr_t
Definition: IWORKPath_fwd.h:20
Definition: IWORKPath.cpp:78
void appendCCurveTo(double x1, double y1, double x2, double y2, double x, double y)
friend bool approxEqual(const IWORKPath &left, const IWORKPath &right, const double eps)
IWORKPath & operator=(const IWORKPath &other)

Generated for libetonyek by doxygen 1.8.12