IWORKPath.h Source File documentation

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 bool empty() const;
46
47 void appendMoveTo(double x, double y);
48 void appendLineTo(double x, double y);
49 void appendQCurveTo(double x1, double y1, double x, double y);
50 void appendCCurveTo(double x1, double y1, double x2, double y2, double x, double y);
51 void appendClose();
52
53 void closePath(bool closeOnlyIsSamePoint=true);
54 void computeBoundingBox(double &minX, double &minY, double &maxX, double &maxY, double factor=1) const;
55 bool isRectangle() const;
60 void operator*=(const glm::dmat3 &tr);
61
62 /* Create a string representation of this path.
63 *
64 * @return an SVG path representing this.
65 */
66 const std::string str() const;
67
70 void write(librevenge::RVNGPropertyListVector &vec, double deltaX=0, double deltaY=0) const;
71 private:
72 std::shared_ptr<Impl> m_impl;
73 };
74
75 bool approxEqual(const IWORKPath &left, const IWORKPath &right, double eps = ETONYEK_EPSILON);
76 bool operator==(const IWORKPath &left, const IWORKPath &right);
77 bool operator!=(const IWORKPath &left, const IWORKPath &right);
78
85 IWORKPath operator*(const IWORKPath &path, const glm::dmat3 &tr);
86
87 class IWORKConnectionPath
88 {
89 public:
90 IWORKConnectionPath();
91 IWORKPathPtr_t getPath() const;
92
93 boost::optional<IWORKPosition> m_positions[3];
94 boost::optional<IWORKSize> m_size;
95 bool m_isSpline;
96 };
97
98 }
99
100 #endif // IWORKPATH_H_INCLUDED
101
102 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libetonyek::IWORKToken::double_
@ double_
Definition: IWORKToken.h:655
libetonyek::Curve_t
std::deque< CurveElement_t > Curve_t
Definition: IWORKPath.cpp:75
libetonyek
Definition: IWORKBezierElement.cpp:20
libetonyek::IWORKPath::clear
void clear()
libetonyek::IWORKConnectionPath::m_isSpline
bool m_isSpline
Definition: IWORKPath.h:95
libetonyek::IWORKConnectionPath::IWORKConnectionPath
IWORKConnectionPath()
libetonyek::Path_t
std::deque< Curve_t > Path_t
Definition: IWORKPath.cpp:76
libetonyek::IWORKPath::Impl::m_path
Path_t m_path
Definition: IWORKPath.cpp:82
libetonyek::IWORKPath::appendMoveTo
void appendMoveTo(double x, double y)
libetonyek::KEY1Token::tr
@ tr
Definition: KEY1Token.h:206
libetonyek::IWORKConnectionPath::m_size
boost::optional< IWORKSize > m_size
Definition: IWORKPath.h:94
libetonyek::IWORKPath
Definition: IWORKPath.h:28
libetonyek::CCurveTo::m_y2
double m_y2
Definition: IWORKPath.cpp:55
libetonyek::IWORKPath::appendQCurveTo
void appendQCurveTo(double x1, double y1, double x, double y)
libetonyek::IWORKPath::empty
bool empty() const
m_y
boost::optional< unsigned > m_y
Definition: IWORKFormulaElement.cpp:111
libetonyek::IWORKPath::isRectangle
bool isRectangle() const
libetonyek::CurveElement_t
boost::variant< MoveTo, LineTo, CCurveTo, QCurveTo, ClosePolygon > CurveElement_t
Definition: IWORKPath.cpp:74
ETONYEK_DEBUG_MSG
#define ETONYEK_DEBUG_MSG(M)
Definition: libetonyek_utils.h:54
libetonyek::IWORKPath::write
void write(librevenge::RVNGPropertyListVector &vec, double deltaX=0, double deltaY=0) const
Create librevenge representation of this path.
libetonyek::KEY2Token::i
@ i
Definition: KEY2Token.h:101
libetonyek::IWORKPath::str
const std::string str() const
libetonyek::operator!=
bool operator!=(const IWORKPath &left, const IWORKPath &right)
IWORKTransformation.h
libetonyek::IWORKPath::Impl::m_closed
bool m_closed
Definition: IWORKPath.cpp:83
libetonyek::ClosePolygon
Definition: IWORKPath.cpp:68
libetonyek::QCurveTo::m_x1
double m_x1
Definition: IWORKPath.cpp:62
libetonyek::IWORKToken::path
@ path
Definition: IWORKToken.h:358
m_size
optional< IWORKSize > m_size
Definition: IWORKPathElement.cpp:48
libetonyek::IWORKToken::d
@ d
Definition: IWORKToken.h:173
libetonyek::operator*
IWORKPath operator*(const IWORKPath &path, const glm::dmat3 &tr)
Create a transformed path.
libetonyek::IWORKPath::m_impl
std::shared_ptr< Impl > m_impl
Definition: IWORKPath.h:72
libetonyek::IWORKToken::right
@ right
Definition: IWORKToken.h:597
libetonyek::LineTo::m_x
double m_x
Definition: IWORKPath.cpp:46
libetonyek::IWORKPath::swap
void swap(IWORKPath &other)
libetonyek::IWORKPath::appendClose
void appendClose()
libetonyek::pt2in
double pt2in(const double d)
Convert a length from points to inches.
Definition: libetonyek_utils.cpp:225
libetonyek::IWORKPath::computeBoundingBox
void computeBoundingBox(double &minX, double &minY, double &maxX, double &maxY, double factor=1) const
libetonyek::IWORKConnectionPath
Definition: IWORKPath.h:87
libetonyek::IWORKPath::InvalidException
Definition: IWORKPath.h:34
libetonyek::QCurveTo::m_x
double m_x
Definition: IWORKPath.cpp:64
libetonyek::IWORKToken::line
@ line
Definition: IWORKToken.h:298
libetonyek::LineTo
Definition: IWORKPath.cpp:44
libetonyek::IWORKPath::IWORKPath
IWORKPath()
libetonyek::IWORKPath::operator*=
void operator*=(const glm::dmat3 &tr)
Transform all elements of the path.
libetonyek::IWORKToken::c
@ c
Definition: IWORKToken.h:509
IWORKPath.h
libetonyek::IWORKToken::left
@ left
Definition: IWORKToken.h:568
libetonyek::CCurveTo::m_x
double m_x
Definition: IWORKPath.cpp:56
libetonyek::transformations::scale
glm::dmat3 scale(const double ratioX, const double ratioY)
Scale along x and/or y axis.
Definition: IWORKTransformation.cpp:72
libetonyek::approxEqual
bool approxEqual(const IWORKPath &left, const IWORKPath &right, double eps=ETONYEK_EPSILON)
m_path
IWORKPathPtr_t m_path
Definition: IWORKPathElement.cpp:284
libetonyek::IWORKPathPtr_t
std::shared_ptr< IWORKPath > IWORKPathPtr_t
Definition: IWORKPath_fwd.h:20
libetonyek::ClosePolygon::m_char
char m_char
Definition: IWORKPath.cpp:70
libetonyek::IWORKToken::t
@ t
Definition: IWORKToken.h:420
libetonyek::MoveTo::m_y
double m_y
Definition: IWORKPath.cpp:41
libetonyek::IWORKToken::r
@ r
Definition: IWORKToken.h:373
libetonyek::IWORKToken::element
@ element
Definition: IWORKToken.h:188
libetonyek::IWORKPath::appendCCurveTo
void appendCCurveTo(double x1, double y1, double x2, double y2, double x, double y)
libetonyek::CCurveTo::m_x2
double m_x2
Definition: IWORKPath.cpp:54
libetonyek::IWORKToken::string
@ string
Definition: IWORKToken.h:411
libetonyek::IWORKPath::approxEqual
friend bool approxEqual(const IWORKPath &left, const IWORKPath &right, const double eps)
libetonyek::IWORKToken::pos
@ pos
Definition: IWORKToken.h:592
libetonyek_utils.h
m_tr
unsigned m_tr
Definition: KEY1TableElement.cpp:107
libetonyek::IWORKConnectionPath::m_positions
boost::optional< IWORKPosition > m_positions[3]
Definition: IWORKPath.h:93
m_width
boost::optional< double > m_width
Definition: IWORKStrokeContext.cpp:229
IWORKTypes.h
y
double y
Definition: IWORKShape.cpp:46
libetonyek::IWORKPath::closePath
void closePath(bool closeOnlyIsSamePoint=true)
libetonyek::IWORKPath::operator=
IWORKPath & operator=(const IWORKPath &other)
x
double x
Definition: IWORKShape.cpp:45
libetonyek::IWORKToken::a
@ a
Definition: IWORKToken.h:501
libetonyek::MoveTo::m_x
double m_x
Definition: IWORKPath.cpp:40
libetonyek::QCurveTo
Definition: IWORKPath.cpp:60
libetonyek::transformations::origin
glm::dmat3 origin(const double width, const double height)
Translate from the center of viewport to the origin.
Definition: IWORKTransformation.cpp:55
libetonyek::LineTo::m_y
double m_y
Definition: IWORKPath.cpp:47
libetonyek::IWORKToken::first
@ first
Definition: IWORKToken.h:524
libetonyek::IWORKToken::b
@ b
Definition: IWORKToken.h:507
IWORKPath_fwd.h
libetonyek::MoveTo
Definition: IWORKPath.cpp:38
libetonyek::CCurveTo
Definition: IWORKPath.cpp:50
libetonyek::QCurveTo::m_y1
double m_y1
Definition: IWORKPath.cpp:63
libetonyek::QCurveTo::m_y
double m_y
Definition: IWORKPath.cpp:65
libetonyek::IWORKPath::appendLineTo
void appendLineTo(double x, double y)
libetonyek::CCurveTo::m_y
double m_y
Definition: IWORKPath.cpp:57
libetonyek::IWORKPath::Impl
Definition: IWORKPath.cpp:78
ETONYEK_EPSILON
#define ETONYEK_EPSILON
Definition: libetonyek_utils.h:26
libetonyek::get
const ValueT & get(const detail::IWAFieldImpl< TagV, ValueT, Reader > &field)
Definition: IWAField.h:190
libetonyek::IWORKConnectionPath::getPath
IWORKPathPtr_t getPath() const
libetonyek::CCurveTo::m_y1
double m_y1
Definition: IWORKPath.cpp:53
m_x
boost::optional< unsigned > m_x
Definition: IWORKFormulaElement.cpp:111
libetonyek::CCurveTo::m_x1
double m_x1
Definition: IWORKPath.cpp:52
libetonyek::IWORKPath::Impl::Impl
Impl()
Definition: IWORKPath.cpp:86
libetonyek::operator==
bool operator==(const IWORKPath &left, const IWORKPath &right)