CDRPath.h Source File documentation

CDRPath.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 libcdr 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 __CDRPATH_H__
11 #define __CDRPATH_H__
12
13 #include <memory>
14 #include <utility>
15 #include <vector>
16 #include <librevenge/librevenge.h>
17
18 namespace libcdr
19 {
20
21 class CDRTransform;
22 class CDRTransforms;
23
24 class CDRPathElement
25 {
26 public:
27 CDRPathElement() {}
28 virtual ~CDRPathElement() {}
29 virtual void writeOut(librevenge::RVNGPropertyListVector &vec) const = 0;
30 virtual void transform(const CDRTransforms &trafos) = 0;
31 virtual void transform(const CDRTransform &trafo) = 0;
32 virtual std::unique_ptr<CDRPathElement> clone() = 0;
33 };
34
35
36 class CDRPath : public CDRPathElement
37 {
38 public:
39 CDRPath() : m_elements(), m_isClosed(false) {}
40 CDRPath(const CDRPath &path);
41 ~CDRPath() override;
42
43 CDRPath &operator=(const CDRPath &path);
44
45 void appendMoveTo(double x, double y);
46 void appendLineTo(double x, double y);
47 void appendCubicBezierTo(double x1, double y1, double x2, double y2, double x, double y);
48 void appendQuadraticBezierTo(double x1, double y1, double x, double y);
49 void appendSplineTo(const std::vector<std::pair<double, double> > &points);
50 void appendArcTo(double rx, double ry, double rotation, bool longAngle, bool sweep, double x, double y);
51 void appendClosePath();
52 void appendPath(const CDRPath &path);
53
54 void writeOut(librevenge::RVNGPropertyListVector &vec) const override;
55 void writeOut(librevenge::RVNGString &path, librevenge::RVNGString &viewBox, double &width) const;
56 void transform(const CDRTransforms &trafos) override;
57 void transform(const CDRTransform &trafo) override;
58 std::unique_ptr<CDRPathElement> clone() override;
59
60 void clear();
61 bool empty() const;
62 bool isClosed() const;
63
64 private:
65 std::vector<std::unique_ptr<CDRPathElement>> m_elements;
66 bool m_isClosed;
67 };
68
69 } // namespace libcdr
70
71 #endif /* __CDRPATH_H__ */
72 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libcdr::CDRPathElement::clone
virtual std::unique_ptr< CDRPathElement > clone()=0
libcdr::CDRClosePathElement::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:624
libcdr::CDRMoveToElement::CDRMoveToElement
CDRMoveToElement(double x, double y)
Definition: CDRPath.cpp:228
libcdr::CDRSplineToElement
Definition: CDRPath.cpp:301
libcdr::CDRArcToElement::~CDRArcToElement
~CDRArcToElement() override
Definition: CDRPath.cpp:327
libcdr::CDRQuadraticBezierToElement::m_x
double m_x
Definition: CDRPath.cpp:297
libcdr::CDRLineToElement
Definition: CDRPath.cpp:241
libcdr::CDRPath::appendPath
void appendPath(const CDRPath &path)
Definition: CDRPath.cpp:694
libcdr::CDRQuadraticBezierToElement::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:444
libcdr::CDRSplineToElement::m_points
std::vector< std::pair< double, double > > m_points
Definition: CDRPath.cpp:312
libcdr::CDRPath::appendQuadraticBezierTo
void appendQuadraticBezierTo(double x1, double y1, double x, double y)
Definition: CDRPath.cpp:651
libcdr::CDRArcToElement::m_x
double m_x
Definition: CDRPath.cpp:338
libcdr::CDRQuadraticBezierToElement::~CDRQuadraticBezierToElement
~CDRQuadraticBezierToElement() override
Definition: CDRPath.cpp:289
libcdr::CDRClosePathElement::CDRClosePathElement
CDRClosePathElement()
Definition: CDRPath.cpp:345
libcdr::CDRPathElement
Definition: CDRPath.h:24
libcdr::CDRQuadraticBezierToElement
Definition: CDRPath.cpp:281
libcdr::CDRPath::clear
void clear()
Definition: CDRPath.cpp:865
CDR_SPLINE_DEGREE
#define CDR_SPLINE_DEGREE
Definition: CDRPath.cpp:461
libcdr::CDRPathElement::~CDRPathElement
virtual ~CDRPathElement()
Definition: CDRPath.h:28
libcdr::CDRClosePathElement::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:616
libcdr::CDRPath::appendSplineTo
void appendSplineTo(const std::vector< std::pair< double, double > > &points)
Definition: CDRPath.cpp:661
libcdr::CDRPath::isClosed
bool isClosed() const
Definition: CDRPath.cpp:876
libcdr::CDRCubicBezierToElement::CDRCubicBezierToElement
CDRCubicBezierToElement(double x1, double y1, double x2, double y2, double x, double y)
Definition: CDRPath.cpp:260
libcdr::CDRCubicBezierToElement::m_x
double m_x
Definition: CDRPath.cpp:277
libcdr::CDRPath::~CDRPath
~CDRPath() override
Definition: CDRPath.cpp:690
libcdr::CDRPath::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:860
libcdr::CDRMoveToElement::~CDRMoveToElement
~CDRMoveToElement() override
Definition: CDRPath.cpp:231
libcdr::CDRLineToElement::~CDRLineToElement
~CDRLineToElement() override
Definition: CDRPath.cpp:247
libcdr::CDRPath::operator=
CDRPath & operator=(const CDRPath &path)
Definition: CDRPath.cpp:678
libcdr::CDRSplineToElement::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:582
CDRTransforms.h
libcdr::CDRQuadraticBezierToElement::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:456
libcdr::CDRTransform
Definition: CDRTransforms.h:19
libcdr::CDRCubicBezierToElement::m_y1
double m_y1
Definition: CDRPath.cpp:274
libcdr::CDRCubicBezierToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:401
libcdr::CDRPath::appendCubicBezierTo
void appendCubicBezierTo(double x1, double y1, double x2, double y2, double x, double y)
Definition: CDRPath.cpp:646
libcdr::CDRClosePathElement
Definition: CDRPath.cpp:342
CDRPath.h
libcdr::CDRTransform::applyToPoint
void applyToPoint(double &x, double &y) const
Definition: CDRTransforms.cpp:31
libcdr::CDRArcToElement::CDRArcToElement
CDRArcToElement(double rx, double ry, double rotation, bool largeArc, bool sweep, double x, double y)
Definition: CDRPath.cpp:319
libcdr::CDRLineToElement::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:396
libcdr::CDRPathElement::transform
virtual void transform(const CDRTransforms &trafos)=0
libcdr::CDRMoveToElement::m_x
double m_x
Definition: CDRPath.cpp:237
libcdr::CDRCubicBezierToElement::~CDRCubicBezierToElement
~CDRCubicBezierToElement() override
Definition: CDRPath.cpp:267
libcdr
Definition: CDRCollector.h:24
libcdr::CDRTransforms::applyToPoint
void applyToPoint(double &x, double &y) const
Definition: CDRTransforms.cpp:254
libcdr::CDRQuadraticBezierToElement::CDRQuadraticBezierToElement
CDRQuadraticBezierToElement(double x1, double y1, double x, double y)
Definition: CDRPath.cpp:284
libcdr::CDRPath::appendClosePath
void appendClosePath()
Definition: CDRPath.cpp:666
libcdr::CDRSplineToElement::knot
unsigned knot(unsigned i) const
Definition: CDRPath.cpp:463
libcdr::CDRCubicBezierToElement::m_x2
double m_x2
Definition: CDRPath.cpp:275
libcdr::CDRPath::m_isClosed
bool m_isClosed
Definition: CDRPath.h:66
libcdr::CDRMoveToElement::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:372
libcdr::CDRArcToElement
Definition: CDRPath.cpp:316
libcdr::CDRLineToElement::CDRLineToElement
CDRLineToElement(double x, double y)
Definition: CDRPath.cpp:244
libcdr::CDRTransform::applyToArc
void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &endx, double &endy) const
Definition: CDRTransforms.cpp:38
libcdr::CDRQuadraticBezierToElement::m_x1
double m_x1
Definition: CDRPath.cpp:295
libcdr::CDRArcToElement::m_rx
double m_rx
Definition: CDRPath.cpp:333
libcdr::CDRPathElement::writeOut
virtual void writeOut(librevenge::RVNGPropertyListVector &vec) const =0
libcdr::CDRPath::appendArcTo
void appendArcTo(double rx, double ry, double rotation, bool longAngle, bool sweep, double x, double y)
Definition: CDRPath.cpp:656
libcdr::CDRQuadraticBezierToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:433
libcdr::CDRPath::CDRPath
CDRPath()
Definition: CDRPath.h:39
libcdr::CDRLineToElement::m_y
double m_y
Definition: CDRPath.cpp:254
libcdr::CDRSplineToElement::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:570
libcdr::CDRPath::empty
bool empty() const
Definition: CDRPath.cpp:871
libcdr::CDRPath::appendMoveTo
void appendMoveTo(double x, double y)
Definition: CDRPath.cpp:636
libcdr::CDRCubicBezierToElement::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:414
libcdr::CDRSplineToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:473
libcdr::CDRArcToElement::m_rotation
double m_rotation
Definition: CDRPath.cpp:335
libcdr::CDRTransforms
Definition: CDRTransforms.h:48
libcdr::CDRSplineToElement::CDRSplineToElement
CDRSplineToElement(const std::vector< std::pair< double, double > > &points)
Definition: CDRPath.cpp:304
libcdr::CDRQuadraticBezierToElement::m_y1
double m_y1
Definition: CDRPath.cpp:296
libcdr::CDRArcToElement::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:601
libcdr::CDRPathElement::CDRPathElement
CDRPathElement()
Definition: CDRPath.h:27
libcdr::CDRQuadraticBezierToElement::m_y
double m_y
Definition: CDRPath.cpp:298
libcdr::CDRMoveToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:353
libcdr::CDRClosePathElement::~CDRClosePathElement
~CDRClosePathElement() override
Definition: CDRPath.cpp:346
libcdr::CDRArcToElement::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:611
libcdr::CDRMoveToElement
Definition: CDRPath.cpp:225
libcdr::CDRArcToElement::m_largeArc
bool m_largeArc
Definition: CDRPath.cpp:336
libcdr::CDRCubicBezierToElement
Definition: CDRPath.cpp:257
libcdr::CDRCubicBezierToElement::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:428
libcdr::CDRArcToElement::m_y
double m_y
Definition: CDRPath.cpp:339
libcdr::CDRArcToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:587
libcdr::CDRLineToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:377
M_PI
#define M_PI
Definition: libcdr_utils.h:27
libcdr::CDRMoveToElement::m_y
double m_y
Definition: CDRPath.cpp:238
libcdr::CDRPath::appendLineTo
void appendLineTo(double x, double y)
Definition: CDRPath.cpp:641
libcdr::CDRSplineToElement::~CDRSplineToElement
~CDRSplineToElement() override
Definition: CDRPath.cpp:306
libcdr::CDRArcToElement::m_ry
double m_ry
Definition: CDRPath.cpp:334
libcdr::CDRPath::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:848
libcdr::CDRCubicBezierToElement::m_x1
double m_x1
Definition: CDRPath.cpp:273
libcdr::CDRPath
Definition: CDRPath.h:36
libcdr::CDRPath::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:700
libcdr::CDRCubicBezierToElement::m_y2
double m_y2
Definition: CDRPath.cpp:276
libcdr_utils.h
libcdr::CDRClosePathElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:629
libcdr::CDRPath::m_elements
std::vector< std::unique_ptr< CDRPathElement > > m_elements
Definition: CDRPath.h:65
libcdr::CDRArcToElement::m_sweep
bool m_sweep
Definition: CDRPath.cpp:337
libcdr::CDRCubicBezierToElement::m_y
double m_y
Definition: CDRPath.cpp:278
libcdr::CDRMoveToElement::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:362
libcdr::CDRLineToElement::m_x
double m_x
Definition: CDRPath.cpp:253
libcdr::CDRLineToElement::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:386
libcdr::CDRTransforms::applyToArc
void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &x, double &y) const
Definition: CDRTransforms.cpp:260