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
Definition: CDRPath.h:25
libcdr::CDRPathElement::transform
virtual void transform(const CDRTransform &trafo)=0
libcdr::CDRPathElement::CDRPathElement
CDRPathElement()
Definition: CDRPath.h:27
libcdr::CDRPathElement::writeOut
virtual void writeOut(librevenge::RVNGPropertyListVector &vec) const =0
libcdr::CDRPathElement::transform
virtual void transform(const CDRTransforms &trafos)=0
libcdr::CDRPathElement::~CDRPathElement
virtual ~CDRPathElement()
Definition: CDRPath.h:28
libcdr::CDRPathElement::clone
virtual std::unique_ptr< CDRPathElement > clone()=0
libcdr::CDRPath
Definition: CDRPath.h:37
libcdr::CDRPath::appendPath
void appendPath(const CDRPath &path)
Definition: CDRPath.cpp:694
libcdr::CDRPath::appendArcTo
void appendArcTo(double rx, double ry, double rotation, bool longAngle, bool sweep, double x, double y)
Definition: CDRPath.cpp:656
libcdr::CDRPath::operator=
CDRPath & operator=(const CDRPath &path)
Definition: CDRPath.cpp:678
libcdr::CDRPath::clone
std::unique_ptr< CDRPathElement > clone() override
Definition: CDRPath.cpp:860
libcdr::CDRPath::appendMoveTo
void appendMoveTo(double x, double y)
Definition: CDRPath.cpp:636
libcdr::CDRPath::isClosed
bool isClosed() const
Definition: CDRPath.cpp:876
libcdr::CDRPath::writeOut
void writeOut(librevenge::RVNGPropertyListVector &vec) const override
Definition: CDRPath.cpp:700
libcdr::CDRPath::appendSplineTo
void appendSplineTo(const std::vector< std::pair< double, double > > &points)
Definition: CDRPath.cpp:661
libcdr::CDRPath::empty
bool empty() const
Definition: CDRPath.cpp:871
libcdr::CDRPath::m_isClosed
bool m_isClosed
Definition: CDRPath.h:66
libcdr::CDRPath::~CDRPath
~CDRPath() override
Definition: CDRPath.cpp:690
libcdr::CDRPath::CDRPath
CDRPath()
Definition: CDRPath.h:39
libcdr::CDRPath::appendQuadraticBezierTo
void appendQuadraticBezierTo(double x1, double y1, double x, double y)
Definition: CDRPath.cpp:651
libcdr::CDRPath::appendLineTo
void appendLineTo(double x, double y)
Definition: CDRPath.cpp:641
libcdr::CDRPath::transform
void transform(const CDRTransforms &trafos) override
Definition: CDRPath.cpp:848
libcdr::CDRPath::m_elements
std::vector< std::unique_ptr< CDRPathElement > > m_elements
Definition: CDRPath.h:65
libcdr::CDRPath::appendCubicBezierTo
void appendCubicBezierTo(double x1, double y1, double x2, double y2, double x, double y)
Definition: CDRPath.cpp:646
libcdr::CDRPath::appendClosePath
void appendClosePath()
Definition: CDRPath.cpp:666
libcdr::CDRPath::clear
void clear()
Definition: CDRPath.cpp:865
libcdr::CDRTransform
Definition: CDRTransforms.h:20
libcdr::CDRTransforms
Definition: CDRTransforms.h:51
libcdr
Definition: CDRDocument.h:17