Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* libcdr
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) 2012 Fridrich Strba <fridrich.strba@bluewin.ch>
17 : *
18 : * All Rights Reserved.
19 : *
20 : * For minor contributions see the git repository.
21 : *
22 : * Alternatively, the contents of this file may be used under the terms of
23 : * either the GNU General Public License Version 2 or later (the "GPLv2+"), or
24 : * the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"),
25 : * in which case the provisions of the GPLv2+ or the LGPLv2+ are applicable
26 : * instead of those above.
27 : */
28 :
29 : #ifndef __CDRTRANSFORMS_H__
30 : #define __CDRTRANSFORMS_H__
31 :
32 : #include <vector>
33 : #include <math.h>
34 :
35 : namespace libcdr
36 : {
37 : class CDRPath;
38 :
39 : class CDRTransform
40 : {
41 : public:
42 : CDRTransform();
43 : CDRTransform(double v0, double v1, double x0, double v3, double v4, double y0);
44 : CDRTransform(const CDRTransform &trafo);
45 :
46 : void applyToPoint(double &x, double &y) const;
47 : void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &x, double &y) const;
48 : double getScaleX() const;
49 : double getScaleY() const;
50 : double getRotation() const;
51 : double getTranslateX() const;
52 : double getTranslateY() const;
53 : bool getFlipX() const;
54 : bool getFlipY() const;
55 :
56 : private:
57 : double _getScaleX() const;
58 : double _getScaleY() const;
59 : double m_v0;
60 : double m_v1;
61 : double m_x0;
62 : double m_v3;
63 : double m_v4;
64 : double m_y0;
65 : };
66 :
67 0 : class CDRTransforms
68 : {
69 : public:
70 : CDRTransforms();
71 : CDRTransforms(const CDRTransforms &trafos);
72 : ~CDRTransforms();
73 :
74 : void append(double v0, double v1, double x0, double v3, double v4, double y0);
75 : void append(const CDRTransform &trafo);
76 : void clear();
77 : bool empty() const;
78 :
79 : void applyToPoint(double &x, double &y) const;
80 : void applyToArc(double &rx, double &ry, double &rotation, bool &sweep, double &x, double &y) const;
81 : double getScaleX() const;
82 : double getScaleY() const;
83 : double getRotation() const;
84 : double getTranslateX() const;
85 : double getTranslateY() const;
86 : bool getFlipX() const;
87 : bool getFlipY() const;
88 :
89 : private:
90 : double _getScaleX() const;
91 : double _getScaleY() const;
92 : std::vector<CDRTransform> m_trafos;
93 : };
94 :
95 : } // namespace libcdr
96 :
97 : #endif /* __CDRTRANSFORMS_H__ */
98 : /* vim:set shiftwidth=2 softtabstop=2 expandtab: */
|