FHPath.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 libfreehand 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 __FHPATH_H__
11 #define __FHPATH_H__
12 
13 #include <memory>
14 #include <vector>
15 #include <ostream>
16 
17 #include <librevenge/librevenge.h>
18 
19 namespace libfreehand
20 {
21 
22 struct FHTransform;
23 
25 {
26 public:
28  virtual ~FHPathElement() {}
29  virtual void writeOut(librevenge::RVNGPropertyListVector &vec) const = 0;
30  virtual void writeOut(std::ostream &s) const = 0;
31  virtual void transform(const FHTransform &trafo) = 0;
32  virtual FHPathElement *clone() = 0;
33  virtual void getBoundingBox(double x0, double y0, double &px, double &py, double &qx, double &qy) const = 0;
34  virtual double getX() const = 0;
35  virtual double getY() const = 0;
36 };
37 
38 
39 class FHPath
40 {
41 public:
43  FHPath(const FHPath &path);
44  ~FHPath();
45 
46  FHPath &operator=(const FHPath &path);
47 
48  void appendMoveTo(double x, double y);
49  void appendLineTo(double x, double y);
50  void appendCubicBezierTo(double x1, double y1, double x2, double y2, double x, double y);
51  void appendQuadraticBezierTo(double x1, double y1, double x, double y);
52  void appendArcTo(double rx, double ry, double rotation, bool longAngle, bool sweep, double x, double y);
53  void appendClosePath();
54  void appendPath(const FHPath &path);
55  void setXFormId(unsigned xFormId);
56  void setGraphicStyleId(unsigned graphicStyleId);
57  void setEvenOdd(bool evenOdd);
58 
59  void writeOut(librevenge::RVNGPropertyListVector &vec) const;
60  std::string getPathString() const;
61  void transform(const FHTransform &trafo);
62  void getBoundingBox(double x0, double y0, double &xmin, double &ymin, double &xmax, double &ymax) const;
63  double getX() const;
64  double getY() const;
65 
66  void clear();
67  bool empty() const;
68  bool isClosed() const;
69  unsigned getXFormId() const;
70  unsigned getGraphicStyleId() const;
71  bool getEvenOdd() const;
72  void getBoundingBox(double &xmin, double &ymin, double &xmax, double &ymax) const;
73 
74 private:
75  std::vector<std::unique_ptr<FHPathElement>> m_elements;
76  bool m_isClosed;
77  unsigned m_xFormId;
78  unsigned m_graphicStyleId;
79  bool m_evenOdd;
80 };
81 
82 } // namespace libfreehand
83 
84 #endif /* __FHPATH_H__ */
85 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libfreehand::FHArcToElement::m_sweep
bool m_sweep
Definition: FHPath.cpp:370
libfreehand::FHCubicBezierToElement::~FHCubicBezierToElement
~FHCubicBezierToElement() override
Definition: FHPath.cpp:288
libfreehand::FHPathElement
Definition: FHPath.h:25
libfreehand::FHArcToElement::clone
FHPathElement * clone() override
Definition: FHPath.cpp:597
libfreehand::FHCubicBezierToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: FHPath.cpp:456
libfreehand::FHPath::getX
double getX() const
Definition: FHPath.cpp:732
libfreehand::FHTransform::applyToArc
void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &endx, double &endy) const
Definition: FHTransform.cpp:37
libfreehand::FHPath::m_graphicStyleId
unsigned m_graphicStyleId
Definition: FHPath.h:78
FHTransform.h
libfreehand::FHArcToElement::m_rx
double m_rx
Definition: FHPath.cpp:366
libfreehand::FHLineToElement::FHLineToElement
FHLineToElement(double x, double y)
Definition: FHPath.cpp:256
libfreehand::FHMoveToElement::getY
double getY() const override
Definition: FHPath.cpp:244
libfreehand::FHQuadraticBezierToElement::m_x
double m_x
Definition: FHPath.cpp:336
libfreehand::FHLineToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: FHPath.cpp:417
libfreehand::FHLineToElement::getY
double getY() const override
Definition: FHPath.cpp:269
libfreehand::FHPath::FHPath
FHPath()
Definition: FHPath.h:42
libfreehand::FHArcToElement::FHArcToElement
FHArcToElement(double rx, double ry, double rotation, bool largeArc, bool sweep, double x, double y)
Definition: FHPath.cpp:343
libfreehand::FHMoveToElement::getX
double getX() const override
Definition: FHPath.cpp:240
libfreehand::FHArcToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: FHPath.cpp:571
libfreehand::FHArcToElement
Definition: FHPath.cpp:341
libfreehand::FHPath::transform
void transform(const FHTransform &trafo)
Definition: FHPath.cpp:708
libfreehand::FHLineToElement
Definition: FHPath.cpp:254
libfreehand::FHQuadraticBezierToElement
Definition: FHPath.cpp:312
libfreehand::FHPath::appendQuadraticBezierTo
void appendQuadraticBezierTo(double x1, double y1, double x, double y)
Definition: FHPath.cpp:633
libfreehand::FHQuadraticBezierToElement::getY
double getY() const override
Definition: FHPath.cpp:329
libfreehand::FHMoveToElement::m_y
double m_y
Definition: FHPath.cpp:250
libfreehand::FHQuadraticBezierToElement::m_y
double m_y
Definition: FHPath.cpp:337
libfreehand::FHPath::m_elements
std::vector< std::unique_ptr< FHPathElement > > m_elements
Definition: FHPath.h:75
libfreehand_utils.h
libfreehand::FHPath::appendPath
void appendPath(const FHPath &path)
Definition: FHPath.cpp:669
libfreehand::FHMoveToElement::m_x
double m_x
Definition: FHPath.cpp:249
libfreehand::FHPathElement::clone
virtual FHPathElement * clone()=0
libfreehand::FHArcToElement::m_largeArc
bool m_largeArc
Definition: FHPath.cpp:369
libfreehand::FHMoveToElement
Definition: FHPath.cpp:229
libfreehand::FHPath::appendMoveTo
void appendMoveTo(double x, double y)
Definition: FHPath.cpp:618
libfreehand::FHPath::setXFormId
void setXFormId(unsigned xFormId)
Definition: FHPath.cpp:679
M_PI
#define M_PI
Definition: libfreehand_utils.h:26
libfreehand
Definition: FHCollector.h:23
libfreehand::FHPath::getPathString
std::string getPathString() const
Definition: FHPath.cpp:700
libfreehand::FHPath::isClosed
bool isClosed() const
Definition: FHPath.cpp:727
libfreehand::FHCubicBezierToElement::m_y
double m_y
Definition: FHPath.cpp:308
libfreehand::FHTransform
Definition: FHTransform.h:19
libfreehand::FHArcToElement::m_rotation
double m_rotation
Definition: FHPath.cpp:368
libfreehand::FHCubicBezierToElement::transform
void transform(const FHTransform &trafo) override
Definition: FHPath.cpp:475
libfreehand::FHQuadraticBezierToElement::getX
double getX() const override
Definition: FHPath.cpp:325
libfreehand::FHPath::getBoundingBox
void getBoundingBox(double x0, double y0, double &xmin, double &ymin, double &xmax, double &ymax) const
Definition: FHPath.cpp:761
FH_DEBUG_MSG
#define FH_DEBUG_MSG(M)
Definition: libfreehand_utils.h:50
libfreehand::FHLineToElement::transform
void transform(const FHTransform &trafo) override
Definition: FHPath.cpp:431
libfreehand::FHTransform::applyToPoint
void applyToPoint(double &x, double &y) const
Definition: FHTransform.cpp:30
libfreehand::FHPath::appendArcTo
void appendArcTo(double rx, double ry, double rotation, bool longAngle, bool sweep, double x, double y)
Definition: FHPath.cpp:638
libfreehand::FHPath::getXFormId
unsigned getXFormId() const
Definition: FHPath.cpp:746
libfreehand::FHLineToElement::clone
FHPathElement * clone() override
Definition: FHPath.cpp:436
libfreehand::FHMoveToElement::~FHMoveToElement
~FHMoveToElement() override
Definition: FHPath.cpp:234
libfreehand::FHPath::setEvenOdd
void setEvenOdd(bool evenOdd)
Definition: FHPath.cpp:689
FHPath.h
libfreehand::FHPathElement::~FHPathElement
virtual ~FHPathElement()
Definition: FHPath.h:28
libfreehand::FHQuadraticBezierToElement::getBoundingBox
void getBoundingBox(double x0, double y0, double &xmin, double &ymin, double &xmax, double &ymax) const override
Definition: FHPath.cpp:540
FHTypes.h
libfreehand::FHQuadraticBezierToElement::~FHQuadraticBezierToElement
~FHQuadraticBezierToElement() override
Definition: FHPath.cpp:319
libfreehand::FHCubicBezierToElement::getBoundingBox
void getBoundingBox(double x0, double y0, double &xmin, double &ymin, double &xmax, double &ymax) const override
Definition: FHPath.cpp:487
libfreehand::FHPath::m_isClosed
bool m_isClosed
Definition: FHPath.h:76
libfreehand::FHPath::getY
double getY() const
Definition: FHPath.cpp:739
libfreehand::FHPath::m_evenOdd
bool m_evenOdd
Definition: FHPath.h:79
libfreehand::FHPath::m_xFormId
unsigned m_xFormId
Definition: FHPath.h:77
libfreehand::FHPath::clear
void clear()
Definition: FHPath.cpp:714
libfreehand::FHPathElement::getBoundingBox
virtual void getBoundingBox(double x0, double y0, double &px, double &py, double &qx, double &qy) const =0
libfreehand::FHPathElement::writeOut
virtual void writeOut(librevenge::RVNGPropertyListVector &vec) const =0
libfreehand::FHLineToElement::getX
double getX() const override
Definition: FHPath.cpp:265
libfreehand::FHArcToElement::m_ry
double m_ry
Definition: FHPath.cpp:367
libfreehand::FHQuadraticBezierToElement::m_y1
double m_y1
Definition: FHPath.cpp:335
libfreehand::FHCubicBezierToElement::getY
double getY() const override
Definition: FHPath.cpp:298
libfreehand::FHPathElement::transform
virtual void transform(const FHTransform &trafo)=0
libfreehand::FHCubicBezierToElement::m_y2
double m_y2
Definition: FHPath.cpp:306
libfreehand::FHPath
Definition: FHPath.h:40
libfreehand::FHLineToElement::getBoundingBox
void getBoundingBox(double x0, double y0, double &xmin, double &ymin, double &xmax, double &ymax) const override
Definition: FHPath.cpp:441
libfreehand::FHQuadraticBezierToElement::FHQuadraticBezierToElement
FHQuadraticBezierToElement(double x1, double y1, double x, double y)
Definition: FHPath.cpp:314
libfreehand::FHPath::setGraphicStyleId
void setGraphicStyleId(unsigned graphicStyleId)
Definition: FHPath.cpp:684
libfreehand::FHArcToElement::getBoundingBox
void getBoundingBox(double x0, double y0, double &xmin, double &ymin, double &xmax, double &ymax) const override
Definition: FHPath.cpp:602
libfreehand::FHArcToElement::transform
void transform(const FHTransform &trafo) override
Definition: FHPath.cpp:592
libfreehand::FHPathElement::getX
virtual double getX() const =0
libfreehand::FHPath::appendClosePath
void appendClosePath()
Definition: FHPath.cpp:643
libfreehand::FHPath::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const
Definition: FHPath.cpp:694
libfreehand::FHMoveToElement::transform
void transform(const FHTransform &trafo) override
Definition: FHPath.cpp:392
libfreehand::FHPath::~FHPath
~FHPath()
Definition: FHPath.cpp:675
libfreehand::FHMoveToElement::clone
FHPathElement * clone() override
Definition: FHPath.cpp:397
libfreehand::FHLineToElement::m_x
double m_x
Definition: FHPath.cpp:274
libfreehand::FHQuadraticBezierToElement::clone
FHPathElement * clone() override
Definition: FHPath.cpp:535
libfreehand::FHLineToElement::m_y
double m_y
Definition: FHPath.cpp:275
libfreehand::FHPath::getEvenOdd
bool getEvenOdd() const
Definition: FHPath.cpp:756
libfreehand::FHQuadraticBezierToElement::m_x1
double m_x1
Definition: FHPath.cpp:334
libfreehand::FHQuadraticBezierToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: FHPath.cpp:513
libfreehand::FHPath::appendCubicBezierTo
void appendCubicBezierTo(double x1, double y1, double x2, double y2, double x, double y)
Definition: FHPath.cpp:628
libfreehand::FHCubicBezierToElement::m_x1
double m_x1
Definition: FHPath.cpp:303
libfreehand::FHArcToElement::m_y
double m_y
Definition: FHPath.cpp:372
libfreehand::FHPath::getGraphicStyleId
unsigned getGraphicStyleId() const
Definition: FHPath.cpp:751
libfreehand::FHArcToElement::getX
double getX() const override
Definition: FHPath.cpp:357
libfreehand::FHPathElement::writeOut
virtual void writeOut(std::ostream &s) const =0
libfreehand::FHArcToElement::~FHArcToElement
~FHArcToElement() override
Definition: FHPath.cpp:351
libfreehand::FHCubicBezierToElement::m_y1
double m_y1
Definition: FHPath.cpp:304
libfreehand::FHPathElement::getY
virtual double getY() const =0
libfreehand::FHCubicBezierToElement::clone
FHPathElement * clone() override
Definition: FHPath.cpp:482
libfreehand::FHCubicBezierToElement::FHCubicBezierToElement
FHCubicBezierToElement(double x1, double y1, double x2, double y2, double x, double y)
Definition: FHPath.cpp:281
libfreehand::FHPath::empty
bool empty() const
Definition: FHPath.cpp:722
libfreehand::FHMoveToElement::FHMoveToElement
FHMoveToElement(double x, double y)
Definition: FHPath.cpp:231
libfreehand::FHArcToElement::m_x
double m_x
Definition: FHPath.cpp:371
libfreehand::FHPathElement::FHPathElement
FHPathElement()
Definition: FHPath.h:27
libfreehand::FHQuadraticBezierToElement::transform
void transform(const FHTransform &trafo) override
Definition: FHPath.cpp:529
libfreehand::FHCubicBezierToElement::m_x2
double m_x2
Definition: FHPath.cpp:305
libfreehand::FHCubicBezierToElement::m_x
double m_x
Definition: FHPath.cpp:307
libfreehand::FHLineToElement::~FHLineToElement
~FHLineToElement() override
Definition: FHPath.cpp:259
libfreehand::FHPath::appendLineTo
void appendLineTo(double x, double y)
Definition: FHPath.cpp:623
libfreehand::FHCubicBezierToElement
Definition: FHPath.cpp:279
libfreehand::FHPath::operator=
FHPath & operator=(const FHPath &path)
Definition: FHPath.cpp:655
libfreehand::FHMoveToElement::getBoundingBox
void getBoundingBox(double x0, double y0, double &xmin, double &ymin, double &xmax, double &ymax) const override
Definition: FHPath.cpp:402
libfreehand::FHCubicBezierToElement::getX
double getX() const override
Definition: FHPath.cpp:294
libfreehand::FHArcToElement::getY
double getY() const override
Definition: FHPath.cpp:361
libfreehand::FHMoveToElement::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: FHPath.cpp:378

Generated for libfreehand by doxygen 1.8.20