VSDGeometryList.h Source File documentation

VSDGeometryList.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 libvisio 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 __VSDGEOMETRYLIST_H__
11 #define __VSDGEOMETRYLIST_H__
12
13 #include <vector>
14 #include <map>
15 #include <vector>
16 #include <functional>
17 #include <algorithm>
18 #include <boost/optional.hpp>
19 #include "VSDTypes.h"
20
21 namespace libvisio
22 {
23
24 class VSDCollector;
25
26 class VSDGeometryListElement
27 {
28 public:
29 VSDGeometryListElement(unsigned id, unsigned level)
30 : m_id(id), m_level(level) {}
31 virtual ~VSDGeometryListElement() {}
32 virtual void handle(VSDCollector *collector) const = 0;
33 virtual VSDGeometryListElement *clone() = 0;
34 virtual unsigned getDataID() const
35 {
36 return MINUS_ONE;
37 }
38 void setLevel(unsigned level)
39 {
40 m_level = level;
41 }
42 protected:
43 unsigned m_id;
44 unsigned m_level;
45 };
46
47 class VSDGeometryList
48 {
49 public:
50 VSDGeometryList();
51 VSDGeometryList(const VSDGeometryList &geomList);
52 ~VSDGeometryList();
53 VSDGeometryList &operator=(const VSDGeometryList &geomList);
54
55 void addGeometry(unsigned id, unsigned level, const boost::optional<bool> &noFill,
56 const boost::optional<bool> &noLine, const boost::optional<bool> &noShow);
57 void addEmpty(unsigned id, unsigned level);
58 void addMoveTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y);
59 void addLineTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y);
60 void addArcTo(unsigned id, unsigned level, const boost::optional<double> &x2, const boost::optional<double> &y2,
61 const boost::optional<double> &bow);
62 void addNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree,
63 const std::vector<std::pair<double, double> > &controlPoints, const std::vector<double> &knotVector,
64 const std::vector<double> &weights);
65 void addNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID);
66 void addNURBSTo(unsigned id, unsigned level, const boost::optional<double> &x2, const boost::optional<double> &y2,
67 const boost::optional<double> &knot, const boost::optional<double> &knotPrev, const boost::optional<double> &weight,
68 const boost::optional<double> &weightPrev, const boost::optional<NURBSData> &data);
69 void addPolylineTo(unsigned id, unsigned level, double x, double y, unsigned char xType, unsigned char yType,
70 const std::vector<std::pair<double, double> > &points);
71 void addPolylineTo(unsigned id, unsigned level, double x, double y, unsigned dataID);
72 void addPolylineTo(unsigned id, unsigned level, boost::optional<double> &x, boost::optional<double> &y, boost::optional<PolylineData> &data);
73 void addEllipse(unsigned id, unsigned level, const boost::optional<double> &cx, const boost::optional<double> &cy,
74 const boost::optional<double> &xleft, const boost::optional<double> &yleft,
75 const boost::optional<double> &xtop, const boost::optional<double> &ytop);
76 void addEllipticalArcTo(unsigned id, unsigned level, const boost::optional<double> &x3, const boost::optional<double> &y3,
77 const boost::optional<double> &x2, const boost::optional<double> &y2,
78 const boost::optional<double> &angle, const boost::optional<double> &ecc);
79 void addSplineStart(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y,
80 const boost::optional<double> &secondKnot, const boost::optional<double> &firstKnot,
81 const boost::optional<double> &lastKnot, const boost::optional<unsigned> &degree);
82 void addSplineKnot(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y,
83 const boost::optional<double> &knot);
84 void addInfiniteLine(unsigned id, unsigned level, const boost::optional<double> &x1, const boost::optional<double> &y1,
85 const boost::optional<double> &x2, const boost::optional<double> &y2);
86 void addRelCubBezTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y,
87 const boost::optional<double> &a, const boost::optional<double> &b,
88 const boost::optional<double> &c, const boost::optional<double> &d);
89 void addRelEllipticalArcTo(unsigned id, unsigned level, const boost::optional<double> &x3, const boost::optional<double> &y3,
90 const boost::optional<double> &x2, const boost::optional<double> &y2,
91 const boost::optional<double> &angle, const boost::optional<double> &ecc);
92 void addRelMoveTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y);
93 void addRelLineTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y);
94 void addRelQuadBezTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y,
95 const boost::optional<double> &a, const boost::optional<double> &b);
96 void setElementsOrder(const std::vector<unsigned> &m_elementsOrder);
97 void handle(VSDCollector *collector) const;
98 void clear();
99 bool empty() const
100 {
101 return (m_elements.empty());
102 }
103 VSDGeometryListElement *getElement(unsigned index) const;
104 std::vector<unsigned> getElementsOrder() const
105 {
106 return m_elementsOrder;
107 }
108 unsigned count() const
109 {
110 return (unsigned)m_elements.size();
111 }
112 void resetLevel(unsigned level);
113 private:
114 void clearElement(unsigned id);
115 std::map<unsigned, VSDGeometryListElement *> m_elements;
116 std::vector<unsigned> m_elementsOrder;
117 };
118
119 } // namespace libvisio
120
121 #endif // __VSDGEOMETRYLIST_H__
122 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDGeometryList::m_elements
std::map< unsigned, VSDGeometryListElement * > m_elements
Definition: VSDGeometryList.h:115
libvisio::VSDGeometryListElement::getDataID
virtual unsigned getDataID() const
Definition: VSDGeometryList.h:34
libvisio::VSDGeometryList::VSDGeometryList
VSDGeometryList()
Definition: VSDGeometryList.cpp:566
libvisio::VSDGeometryList::addNURBSTo
void addNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree, const std::vector< std::pair< double, double > > &controlPoints, const std::vector< double > &knotVector, const std::vector< double > &weights)
Definition: VSDGeometryList.cpp:667
libvisio::VSDGeometryList::resetLevel
void resetLevel(unsigned level)
Definition: VSDGeometryList.cpp:988
libvisio::VSDGeometryList::operator=
VSDGeometryList & operator=(const VSDGeometryList &geomList)
Definition: VSDGeometryList.cpp:581
libvisio::VSDGeometryList::addSplineKnot
void addSplineKnot(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y, const boost::optional< double > &knot)
Definition: VSDGeometryList.cpp:794
libvisio::VSDGeometryList::addEmpty
void addEmpty(unsigned id, unsigned level)
Definition: VSDGeometryList.cpp:613
libvisio::VSDGeometryList::setElementsOrder
void setElementsOrder(const std::vector< unsigned > &m_elementsOrder)
Definition: VSDGeometryList.cpp:918
libvisio::VSDGeometryListElement::m_level
unsigned m_level
Definition: VSDGeometryList.h:44
libvisio::VSDCollector
Definition: VSDCollector.h:20
libvisio::VSDGeometryList::clear
void clear()
Definition: VSDGeometryList.cpp:957
libvisio::VSDGeometryListElement::setLevel
void setLevel(unsigned level)
Definition: VSDGeometryList.h:38
libvisio::VSDGeometryListElement::~VSDGeometryListElement
virtual ~VSDGeometryListElement()
Definition: VSDGeometryList.h:31
libvisio::VSDGeometryList::addRelEllipticalArcTo
void addRelEllipticalArcTo(unsigned id, unsigned level, const boost::optional< double > &x3, const boost::optional< double > &y3, const boost::optional< double > &x2, const boost::optional< double > &y2, const boost::optional< double > &angle, const boost::optional< double > &ecc)
Definition: VSDGeometryList.cpp:850
libvisio::VSDGeometryListElement::VSDGeometryListElement
VSDGeometryListElement(unsigned id, unsigned level)
Definition: VSDGeometryList.h:29
libvisio::VSDGeometryListElement::m_id
unsigned m_id
Definition: VSDGeometryList.h:43
libvisio::VSDGeometryList::getElementsOrder
std::vector< unsigned > getElementsOrder() const
Definition: VSDGeometryList.h:104
libvisio::VSDGeometryList::empty
bool empty() const
Definition: VSDGeometryList.h:99
VSDTypes.h
libvisio::VSDGeometryList::addArcTo
void addArcTo(unsigned id, unsigned level, const boost::optional< double > &x2, const boost::optional< double > &y2, const boost::optional< double > &bow)
Definition: VSDGeometryList.cpp:650
libvisio::VSDGeometryList::addInfiniteLine
void addInfiniteLine(unsigned id, unsigned level, const boost::optional< double > &x1, const boost::optional< double > &y1, const boost::optional< double > &x2, const boost::optional< double > &y2)
Definition: VSDGeometryList.cpp:811
libvisio::VSDGeometryList::handle
void handle(VSDCollector *collector) const
Definition: VSDGeometryList.cpp:925
libvisio::VSDGeometryList::count
unsigned count() const
Definition: VSDGeometryList.h:108
libvisio::VSDGeometryList::getElement
VSDGeometryListElement * getElement(unsigned index) const
Definition: VSDGeometryList.cpp:965
libvisio::VSDGeometryListElement
Definition: VSDGeometryList.h:26
libvisio::VSDGeometryList::m_elementsOrder
std::vector< unsigned > m_elementsOrder
Definition: VSDGeometryList.h:116
libvisio::VSDGeometryList::addPolylineTo
void addPolylineTo(unsigned id, unsigned level, double x, double y, unsigned char xType, unsigned char yType, const std::vector< std::pair< double, double > > &points)
Definition: VSDGeometryList.cpp:702
MINUS_ONE
#define MINUS_ONE
Definition: VSDTypes.h:18
libvisio
Definition: libvisio_utils.h:48
libvisio::VSDGeometryList::addRelCubBezTo
void addRelCubBezTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y, const boost::optional< double > &a, const boost::optional< double > &b, const boost::optional< double > &c, const boost::optional< double > &d)
Definition: VSDGeometryList.cpp:829
libvisio::VSDGeometryList::addRelLineTo
void addRelLineTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y)
Definition: VSDGeometryList.cpp:886
libvisio::VSDGeometryList::addLineTo
void addLineTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y)
Definition: VSDGeometryList.cpp:635
libvisio::VSDGeometryList::clearElement
void clearElement(unsigned id)
Definition: VSDGeometryList.cpp:977
libvisio::VSDGeometryListElement::handle
virtual void handle(VSDCollector *collector) const =0
libvisio::VSDGeometryList::addGeometry
void addGeometry(unsigned id, unsigned level, const boost::optional< bool > &noFill, const boost::optional< bool > &noLine, const boost::optional< bool > &noShow)
Definition: VSDGeometryList.cpp:596
libvisio::VSDGeometryList::addEllipticalArcTo
void addEllipticalArcTo(unsigned id, unsigned level, const boost::optional< double > &x3, const boost::optional< double > &y3, const boost::optional< double > &x2, const boost::optional< double > &y2, const boost::optional< double > &angle, const boost::optional< double > &ecc)
Definition: VSDGeometryList.cpp:752
libvisio::VSDGeometryList::~VSDGeometryList
~VSDGeometryList()
Definition: VSDGeometryList.cpp:591
libvisio::VSDGeometryList::addRelMoveTo
void addRelMoveTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y)
Definition: VSDGeometryList.cpp:871
libvisio::VSDGeometryList::addMoveTo
void addMoveTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y)
Definition: VSDGeometryList.cpp:619
libvisio::VSDGeometryListElement::clone
virtual VSDGeometryListElement * clone()=0
libvisio::VSDGeometryList::addEllipse
void addEllipse(unsigned id, unsigned level, const boost::optional< double > &cx, const boost::optional< double > &cy, const boost::optional< double > &xleft, const boost::optional< double > &yleft, const boost::optional< double > &xtop, const boost::optional< double > &ytop)
Definition: VSDGeometryList.cpp:731
libvisio::VSDGeometryList::addSplineStart
void addSplineStart(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y, const boost::optional< double > &secondKnot, const boost::optional< double > &firstKnot, const boost::optional< double > &lastKnot, const boost::optional< unsigned > &degree)
Definition: VSDGeometryList.cpp:773
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:47
libvisio::VSDGeometryList::addRelQuadBezTo
void addRelQuadBezTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y, const boost::optional< double > &a, const boost::optional< double > &b)
Definition: VSDGeometryList.cpp:901