CDRPath.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libcdr project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef __CDRPATH_H__
00011 #define __CDRPATH_H__
00012 
00013 #include <vector>
00014 #include <librevenge/librevenge.h>
00015 
00016 namespace libcdr
00017 {
00018 
00019 class CDRTransform;
00020 class CDRTransforms;
00021 
00022 class CDRPathElement
00023 {
00024 public:
00025   CDRPathElement() {}
00026   virtual ~CDRPathElement() {}
00027   virtual void writeOut(librevenge::RVNGPropertyListVector &vec) const = 0;
00028   virtual void transform(const CDRTransforms &trafos) = 0;
00029   virtual void transform(const CDRTransform &trafo) = 0;
00030   virtual CDRPathElement *clone() = 0;
00031 };
00032 
00033 
00034 class CDRPath : public CDRPathElement
00035 {
00036 public:
00037   CDRPath() : m_elements(), m_isClosed(false) {}
00038   CDRPath(const CDRPath &path);
00039   ~CDRPath();
00040 
00041   CDRPath &operator=(const CDRPath &path);
00042 
00043   void appendMoveTo(double x, double y);
00044   void appendLineTo(double x, double y);
00045   void appendCubicBezierTo(double x1, double y1, double x2, double y2, double x, double y);
00046   void appendQuadraticBezierTo(double x1, double y1, double x, double y);
00047   void appendSplineTo(std::vector<std::pair<double, double> > &points);
00048   void appendArcTo(double rx, double ry, double rotation, bool longAngle, bool sweep, double x, double y);
00049   void appendClosePath();
00050   void appendPath(const CDRPath &path);
00051 
00052   void writeOut(librevenge::RVNGPropertyListVector &vec) const;
00053   void writeOut(librevenge::RVNGString &path, librevenge::RVNGString &viewBox, double &width) const;
00054   void transform(const CDRTransforms &trafos);
00055   void transform(const CDRTransform &trafo);
00056   CDRPathElement *clone();
00057 
00058   void clear();
00059   bool empty() const;
00060   bool isClosed() const;
00061 
00062 private:
00063   std::vector<CDRPathElement *> m_elements;
00064   bool m_isClosed;
00065 };
00066 
00067 } // namespace libcdr
00068 
00069 #endif /* __CDRPATH_H__ */
00070 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */