- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

VSDGeometryList.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* libvisio
3 * Version: MPL 1.1 / GPLv2+ / LGPLv2+
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License or as specified alternatively below. You may obtain a copy of
8 * the License at http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * Major Contributor(s):
16 * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch>
17 * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com>
18 *
19 *
20 * All Rights Reserved.
21 *
22 * For minor contributions see the git repository.
23 *
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
26 * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
27 * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
28 * instead of those above.
29 */
30
31 #ifndef __VSDGEOMETRYLIST_H__
32 #define __VSDGEOMETRYLIST_H__
33
34 #include <vector>
35 #include <map>
36 #include <vector>
37 #include <functional>
38 #include <algorithm>
39 #include <boost/optional.hpp>
40 #include "VSDTypes.h"
41
42 namespace libvisio
43 {
44
45 class VSDCollector;
46
47 class VSDGeometryListElement
48 {
49 public:
50 VSDGeometryListElement(unsigned id, unsigned level)
51 : m_id(id), m_level(level) {}
52 virtual ~VSDGeometryListElement() {}
53 virtual void handle(VSDCollector *collector) const = 0;
54 virtual VSDGeometryListElement *clone() = 0;
55 virtual unsigned getDataID() const
56 {
57 return MINUS_ONE;
58 }
59 void setLevel(unsigned level)
60 {
61 m_level = level;
62 }
63 protected:
64 unsigned m_id;
65 unsigned m_level;
66 };
67
68 class VSDGeometryList
69 {
70 public:
71 VSDGeometryList();
72 VSDGeometryList(const VSDGeometryList &geomList);
73 ~VSDGeometryList();
74 VSDGeometryList &operator=(const VSDGeometryList &geomList);
75
76 void addGeometry(unsigned id, unsigned level, const boost::optional<bool> &noFill,
77 const boost::optional<bool> &noLine, const boost::optional<bool> &noShow);
78 void addEmpty(unsigned id, unsigned level);
79 void addMoveTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y);
80 void addLineTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y);
81 void addArcTo(unsigned id, unsigned level, const boost::optional<double> &x2, const boost::optional<double> &y2,
82 const boost::optional<double> &bow);
83 void addNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree,
84 const std::vector<std::pair<double, double> > &controlPoints, const std::vector<double> &knotVector,
85 const std::vector<double> &weights);
86 void addNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID);
87 void addNURBSTo(unsigned id, unsigned level, const boost::optional<double> &x2, const boost::optional<double> &y2,
88 const boost::optional<double> &knot, const boost::optional<double> &knotPrev, const boost::optional<double> &weight,
89 const boost::optional<double> &weightPrev, const boost::optional<NURBSData> &data);
90 void addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned char xType, unsigned char yType,
91 const std::vector<std::pair<double, double> > &points);
92 void addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned dataID);
93 void addPolylineTo(unsigned id , unsigned level, boost::optional<double> &x, boost::optional<double> &y, boost::optional<PolylineData> &data);
94 void addEllipse(unsigned id, unsigned level, const boost::optional<double> &cx, const boost::optional<double> &cy,
95 const boost::optional<double> &xleft, const boost::optional<double> &yleft,
96 const boost::optional<double> &xtop, const boost::optional<double> &ytop);
97 void addEllipticalArcTo(unsigned id, unsigned level, const boost::optional<double> &x3, const boost::optional<double> &y3,
98 const boost::optional<double> &x2, const boost::optional<double> &y2,
99 const boost::optional<double> &angle, const boost::optional<double> &ecc);
100 void addSplineStart(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y,
101 const boost::optional<double> &secondKnot, const boost::optional<double> &firstKnot,
102 const boost::optional<double> &lastKnot, const boost::optional<unsigned> &degree);
103 void addSplineKnot(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y,
104 const boost::optional<double> &knot);
105 void addInfiniteLine(unsigned id, unsigned level, const boost::optional<double> &x1, const boost::optional<double> &y1,
106 const boost::optional<double> &x2, const boost::optional<double> &y2);
107 void addRelCubBezTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y,
108 const boost::optional<double> &a, const boost::optional<double> &b,
109 const boost::optional<double> &c, const boost::optional<double> &d);
110 void addRelEllipticalArcTo(unsigned id, unsigned level, const boost::optional<double> &x3, const boost::optional<double> &y3,
111 const boost::optional<double> &x2, const boost::optional<double> &y2,
112 const boost::optional<double> &angle, const boost::optional<double> &ecc);
113 void addRelMoveTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y);
114 void addRelLineTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y);
115 void addRelQuadBezTo(unsigned id, unsigned level, const boost::optional<double> &x, const boost::optional<double> &y,
116 const boost::optional<double> &a, const boost::optional<double> &b);
117 void setElementsOrder(const std::vector<unsigned> &m_elementsOrder);
118 void handle(VSDCollector *collector) const;
119 void clear();
120 bool empty() const
121 {
122 return (m_elements.empty());
123 }
124 VSDGeometryListElement *getElement(unsigned index) const;
125 std::vector<unsigned> getElementsOrder() const
126 {
127 return m_elementsOrder;
128 }
129 unsigned count() const
130 {
131 return m_elements.size();
132 }
133 void resetLevel(unsigned level);
134 private:
135 void clearElement(unsigned id);
136 std::map<unsigned, VSDGeometryListElement *> m_elements;
137 std::vector<unsigned> m_elementsOrder;
138 };
139
140 } // namespace libvisio
141
142 #endif // __VSDGEOMETRYLIST_H__
143 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
libvisio::VSDGeometryList::m_elements
std::map< unsigned, VSDGeometryListElement * > m_elements
Definition: VSDGeometryList.h:136
libvisio::VSDGeometryList::getElement
VSDGeometryListElement * getElement(unsigned index) const
Definition: VSDGeometryList.cpp:986
libvisio::VSDGeometryList::VSDGeometryList
VSDGeometryList()
Definition: VSDGeometryList.cpp:587
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:688
libvisio::VSDGeometryList::resetLevel
void resetLevel(unsigned level)
Definition: VSDGeometryList.cpp:1009
libvisio::VSDGeometryList::operator=
VSDGeometryList & operator=(const VSDGeometryList &geomList)
Definition: VSDGeometryList.cpp:602
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:815
libvisio::VSDGeometryList::addEmpty
void addEmpty(unsigned id, unsigned level)
Definition: VSDGeometryList.cpp:634
libvisio::VSDGeometryList::getElementsOrder
std::vector< unsigned > getElementsOrder() const
Definition: VSDGeometryList.h:125
libvisio::VSDGeometryList::handle
void handle(VSDCollector *collector) const
Definition: VSDGeometryList.cpp:946
libvisio::VSDGeometryList::setElementsOrder
void setElementsOrder(const std::vector< unsigned > &m_elementsOrder)
Definition: VSDGeometryList.cpp:939
libvisio::VSDGeometryListElement::m_level
unsigned m_level
Definition: VSDGeometryList.h:65
libvisio::VSDCollector
Definition: VSDCollector.h:41
libvisio::VSDGeometryList::clear
void clear()
Definition: VSDGeometryList.cpp:978
libvisio::VSDGeometryListElement::setLevel
void setLevel(unsigned level)
Definition: VSDGeometryList.h:59
libvisio::VSDGeometryList::empty
bool empty() const
Definition: VSDGeometryList.h:120
libvisio::VSDGeometryList::count
unsigned count() const
Definition: VSDGeometryList.h:129
libvisio::VSDGeometryListElement::~VSDGeometryListElement
virtual ~VSDGeometryListElement()
Definition: VSDGeometryList.h:52
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:871
libvisio::VSDGeometryListElement::VSDGeometryListElement
VSDGeometryListElement(unsigned id, unsigned level)
Definition: VSDGeometryList.h:50
libvisio::VSDGeometryListElement::m_id
unsigned m_id
Definition: VSDGeometryList.h:64
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:671
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:832
libvisio::VSDGeometryListElement
Definition: VSDGeometryList.h:47
libvisio::VSDGeometryList::m_elementsOrder
std::vector< unsigned > m_elementsOrder
Definition: VSDGeometryList.h:137
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:723
MINUS_ONE
#define MINUS_ONE
Definition: VSDTypes.h:39
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:850
libvisio::VSDGeometryList::addRelLineTo
void addRelLineTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y)
Definition: VSDGeometryList.cpp:907
libvisio::VSDGeometryList::addLineTo
void addLineTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y)
Definition: VSDGeometryList.cpp:656
libvisio::VSDGeometryList::clearElement
void clearElement(unsigned id)
Definition: VSDGeometryList.cpp:998
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:617
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:773
libvisio::VSDGeometryList::~VSDGeometryList
~VSDGeometryList()
Definition: VSDGeometryList.cpp:612
libvisio::VSDGeometryList::addRelMoveTo
void addRelMoveTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y)
Definition: VSDGeometryList.cpp:892
libvisio::VSDGeometryList::addMoveTo
void addMoveTo(unsigned id, unsigned level, const boost::optional< double > &x, const boost::optional< double > &y)
Definition: VSDGeometryList.cpp:640
libvisio::VSDGeometryListElement::getDataID
virtual unsigned getDataID() const
Definition: VSDGeometryList.h:55
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:752
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:794
libvisio::VSDGeometryList
Definition: VSDGeometryList.h:68
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:922