CDRTransforms.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 __CDRTRANSFORMS_H__
00011 #define __CDRTRANSFORMS_H__
00012 
00013 #include <vector>
00014 #include <math.h>
00015 
00016 namespace libcdr
00017 {
00018 class CDRPath;
00019 
00020 class CDRTransform
00021 {
00022 public:
00023   CDRTransform();
00024   CDRTransform(double v0, double v1, double x0, double v3, double v4, double y0);
00025   CDRTransform(const CDRTransform &trafo);
00026 
00027   void applyToPoint(double &x, double &y) const;
00028   void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &endx, double &endy) const;
00029 
00030 private:
00031   double m_v0;
00032   double m_v1;
00033   double m_x0;
00034   double m_v3;
00035   double m_v4;
00036   double m_y0;
00037 };
00038 
00039 class CDRTransforms
00040 {
00041 public:
00042   CDRTransforms();
00043   CDRTransforms(const CDRTransforms &trafos);
00044   ~CDRTransforms();
00045 
00046   void append(double v0, double v1, double x0, double v3, double v4, double y0);
00047   void append(const CDRTransform &trafo);
00048   void clear();
00049   bool empty() const;
00050 
00051   void applyToPoint(double &x, double &y) const;
00052   void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &x, double &y) const;
00053   double getScaleX() const;
00054   double getScaleY() const;
00055   double getTranslateX() const;
00056   double getTranslateY() const;
00057   bool getFlipX() const;
00058   bool getFlipY() const;
00059 
00060 private:
00061   double _getScaleX() const;
00062   double _getScaleY() const;
00063   std::vector<CDRTransform> m_trafos;
00064 };
00065 
00066 } // namespace libcdr
00067 
00068 #endif /* __CDRTRANSFORMS_H__ */
00069 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */