00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __VSDXGEOMETRYLIST_H__
00032 #define __VSDXGEOMETRYLIST_H__
00033
00034 #include <vector>
00035 #include <map>
00036
00037 namespace libvisio
00038 {
00039
00040 class VSDXGeometryListElement;
00041 class VSDXCollector;
00042
00043 class VSDXGeometryList
00044 {
00045 public:
00046 VSDXGeometryList();
00047 VSDXGeometryList(const VSDXGeometryList &geomList);
00048 ~VSDXGeometryList();
00049 VSDXGeometryList &operator=(const VSDXGeometryList &geomList);
00050
00051 void addGeometry(unsigned id, unsigned level, unsigned char geomFlags);
00052 void addMoveTo(unsigned id, unsigned level, double x, double y);
00053 void addLineTo(unsigned id, unsigned level, double x, double y);
00054 void addArcTo(unsigned id, unsigned level, double x2, double y2, double bow);
00055 void addNURBSTo(unsigned id, unsigned level, double x2, double y2, unsigned char xType, unsigned char yType, unsigned degree, std::vector<std::pair<double, double> > controlPoints, std::vector<double> knotVector, std::vector<double> weights);
00056 void addNURBSTo(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID);
00057 void addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned char xType, unsigned char yType, std::vector<std::pair<double, double> > points);
00058 void addPolylineTo(unsigned id , unsigned level, double x, double y, unsigned dataID);
00059 void addEllipse(unsigned id, unsigned level, double cx, double cy, double xleft, double yleft, double xtop, double ytop);
00060 void addEllipticalArcTo(unsigned id, unsigned level, double x3, double y3, double x2, double y2, double angle, double ecc);
00061 void addSplineStart(unsigned id, unsigned level, double x, double y, double secondKnot, double firstKnot, double lastKnot, unsigned degree);
00062 void addSplineKnot(unsigned id, unsigned level, double x, double y, double knot);
00063 void addInfiniteLine(unsigned id, unsigned level, double x1, double y1, double x2, double y2);
00064 void setElementsOrder(const std::vector<unsigned> &m_elementsOrder);
00065 void handle(VSDXCollector *collector) const;
00066 void clear();
00067 bool empty() const
00068 {
00069 return (!m_elements.size());
00070 }
00071 VSDXGeometryListElement *getElement(unsigned index) const;
00072 std::vector<unsigned> getElementsOrder() const
00073 {
00074 return m_elementsOrder;
00075 }
00076 unsigned count() const
00077 {
00078 return m_elements.size();
00079 }
00080 private:
00081 std::map<unsigned, VSDXGeometryListElement *> m_elements;
00082 std::vector<unsigned> m_elementsOrder;
00083 };
00084
00085 class VSDXGeometryListElement
00086 {
00087 public:
00088 VSDXGeometryListElement() {}
00089 virtual ~VSDXGeometryListElement() {}
00090 virtual void handle(VSDXCollector *collector) = 0;
00091 virtual VSDXGeometryListElement *clone() = 0;
00092 };
00093
00094 class VSDXPolylineTo2 : public VSDXGeometryListElement
00095 {
00096 public:
00097 VSDXPolylineTo2(unsigned id , unsigned level, double x, double y, unsigned dataID) :
00098 m_dataID(dataID), m_id(id), m_level(level), m_x(x), m_y(y) {}
00099 ~VSDXPolylineTo2() {}
00100 void handle(VSDXCollector *collector);
00101 VSDXGeometryListElement *clone();
00102 unsigned m_dataID;
00103 private:
00104 unsigned m_id, m_level;
00105 double m_x, m_y;
00106 };
00107
00108 class VSDXNURBSTo2 : public VSDXGeometryListElement
00109 {
00110 public:
00111 VSDXNURBSTo2(unsigned id, unsigned level, double x2, double y2, double knot, double knotPrev, double weight, double weightPrev, unsigned dataID) :
00112 m_dataID(dataID), m_id(id), m_level(level), m_x2(x2), m_y2(y2), m_knot(knot), m_knotPrev(knotPrev), m_weight(weight), m_weightPrev(weightPrev) {}
00113 ~VSDXNURBSTo2() {}
00114 void handle(VSDXCollector *collector);
00115 VSDXGeometryListElement *clone();
00116 unsigned m_dataID;
00117 private:
00118 unsigned m_id, m_level;
00119 double m_x2, m_y2;
00120 double m_knot, m_knotPrev;
00121 double m_weight, m_weightPrev;
00122
00123 };
00124
00125 }
00126
00127 #endif // __VSDXGEOMETRYLIST_H__
00128