1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVETOOLS2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVETOOLS2D_HXX
22 
23 #include <drawinglayer/drawinglayerdllapi.h>
24 
25 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 #include <basegfx/matrix/b2dhommatrix.hxx>
27 
28 
29 namespace drawinglayer
30 {
31     namespace primitive2d
32     {
33         /** DiscreteMetricDependentPrimitive2D class
34 
35             tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent
36             regarding the size of a discrete unit. The implementation of get2DDecomposition
37             guards the buffered local decomposition and ensures that a create2DDecomposition
38             implementation may use an up-to-date DiscreteUnit accessible using getDiscreteUnit()
39          */
40         class DRAWINGLAYER_DLLPUBLIC DiscreteMetricDependentPrimitive2D : public BufferedDecompositionPrimitive2D
41         {
42         private:
43             /** the last used fDiscreteUnit definitions for decomposition. Since this
44                 is checked and updated from get2DDecomposition() it will be current and
45                 usable in create2DDecomposition()
46              */
47             double                                  mfDiscreteUnit;
48 
49         public:
50             /// constructor
DiscreteMetricDependentPrimitive2D()51             DiscreteMetricDependentPrimitive2D()
52             :   BufferedDecompositionPrimitive2D(),
53                 mfDiscreteUnit(0.0)
54             {
55             }
56 
57             /// data read access
getDiscreteUnit() const58             double getDiscreteUnit() const { return mfDiscreteUnit; }
59 
60             /// Override standard getDecomposition to be view-dependent here
61             virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
62         };
63     } // end of namespace primitive2d
64 } // end of namespace drawinglayer
65 
66 
67 namespace drawinglayer
68 {
69     namespace primitive2d
70     {
71         /** ViewportDependentPrimitive2D class
72 
73             tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent
74             regarding the viewport. The implementation of get2DDecomposition
75             guards the buffered local decomposition and ensures that a create2DDecomposition
76             implementation may use an up-to-date Viewport accessible using getViewport()
77          */
78         class DRAWINGLAYER_DLLPUBLIC ViewportDependentPrimitive2D : public BufferedDecompositionPrimitive2D
79         {
80         private:
81             /** the last used Viewport definition for decomposition. Since this
82                 is checked and updated from get2DDecomposition() it will be current and
83                 usable in create2DDecomposition()
84              */
85             basegfx::B2DRange                       maViewport;
86 
87         public:
88             /// constructor
ViewportDependentPrimitive2D()89             ViewportDependentPrimitive2D()
90             :   BufferedDecompositionPrimitive2D(),
91                 maViewport()
92             {
93             }
94 
95             /// data read access
getViewport() const96             const basegfx::B2DRange& getViewport() const { return maViewport; }
97 
98             /// Override standard getDecomposition to be view-dependent here
99             virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
100         };
101     } // end of namespace primitive2d
102 } // end of namespace drawinglayer
103 
104 
105 namespace drawinglayer
106 {
107     namespace primitive2d
108     {
109         /** ViewTransformationDependentPrimitive2D class
110 
111             tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent
112             regarding the complete Viewtransformation. The implementation of get2DDecomposition
113             guards the buffered local decomposition and ensures that a create2DDecomposition
114             implementation may use an up-to-date ViewTransformation accessible using getViewTransformation()
115          */
116         class DRAWINGLAYER_DLLPUBLIC ViewTransformationDependentPrimitive2D : public BufferedDecompositionPrimitive2D
117         {
118         private:
119             /** the last used ViewTransformation definition for decomposition. Since this
120                 is checked and updated from get2DDecomposition() it will be current and
121                 usable in create2DDecomposition()
122              */
123             basegfx::B2DHomMatrix                   maViewTransformation;
124 
125         public:
126             /// constructor
ViewTransformationDependentPrimitive2D()127             ViewTransformationDependentPrimitive2D()
128             :   BufferedDecompositionPrimitive2D(),
129                 maViewTransformation()
130             {
131             }
132 
133             /// data read access
getViewTransformation() const134             const basegfx::B2DHomMatrix& getViewTransformation() const { return maViewTransformation; }
135 
136             /// Override standard getDecomposition to be view-dependent here
137             virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
138         };
139     } // end of namespace primitive2d
140 } // end of namespace drawinglayer
141 
142 
143 namespace drawinglayer
144 {
145     namespace primitive2d
146     {
147         /** ObjectAndViewTransformationDependentPrimitive2D class
148 
149             tooling class for BufferedDecompositionPrimitive2D based classes which are view-dependent
150             and Object-Transform dependent. The implementation of get2DDecomposition
151             guards the buffered local decomposition and ensures that a create2DDecomposition
152             implementation may use an up-to-date ViewTransformation accessible using getViewTransformation()
153             and an object transformation via getObjectTransformation()
154          */
155         class DRAWINGLAYER_DLLPUBLIC ObjectAndViewTransformationDependentPrimitive2D : public BufferedDecompositionPrimitive2D
156         {
157         private:
158             /** the last used ViewTransformation and the last ObjectTransformation
159                 definition for decomposition. Since this is checked and updated from
160                 get2DDecomposition() it will be current and usable in create2DDecomposition()
161              */
162             basegfx::B2DHomMatrix                   maViewTransformation;
163             basegfx::B2DHomMatrix                   maObjectTransformation;
164 
165         public:
166             /// constructor
ObjectAndViewTransformationDependentPrimitive2D()167             ObjectAndViewTransformationDependentPrimitive2D()
168             :   BufferedDecompositionPrimitive2D(),
169                 maViewTransformation(),
170                 maObjectTransformation()
171             {
172             }
173 
174             /// data read access
getViewTransformation() const175             const basegfx::B2DHomMatrix& getViewTransformation() const { return maViewTransformation; }
getObjectTransformation() const176             const basegfx::B2DHomMatrix& getObjectTransformation() const { return maObjectTransformation; }
177 
178             /// Override standard getDecomposition to be view-dependent here
179             virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
180         };
181     } // end of namespace primitive2d
182 } // end of namespace drawinglayer
183 
184 
185 #endif // INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVETOOLS2D_HXX
186 
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
188