VSDXGeometryList.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libvisio
00003  * Version: MPL 1.1 / GPLv2+ / LGPLv2+
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License or as specified alternatively below. You may obtain a copy of
00008  * the License at http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * Major Contributor(s):
00016  * Copyright (C) 2011 Fridrich Strba <fridrich.strba@bluewin.ch>
00017  * Copyright (C) 2011 Eilidh McAdam <tibbylickle@gmail.com>
00018  *
00019  *
00020  * All Rights Reserved.
00021  *
00022  * For minor contributions see the git repository.
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
00026  * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
00027  * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
00028  * instead of those above.
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 } // namespace libvisio
00126 
00127 #endif // __VSDXGEOMETRYLIST_H__
00128 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */