1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_drawinglayer.hxx"
26 
27 #include <drawinglayer/primitive2d/primitivetools2d.hxx>
28 #include <basegfx/vector/b2dvector.hxx>
29 #include <drawinglayer/geometry/viewinformation2d.hxx>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 
33 namespace drawinglayer
34 {
35 	namespace primitive2d
36 	{
get2DDecomposition(const geometry::ViewInformation2D & rViewInformation) const37 		Primitive2DSequence DiscreteMetricDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
38 		{
39 			::osl::MutexGuard aGuard( m_aMutex );
40 
41 			// get the current DiscreteUnit, look at X and Y and use the maximum
42             const basegfx::B2DVector aDiscreteVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0));
43             const double fDiscreteUnit(std::min(fabs(aDiscreteVector.getX()), fabs(aDiscreteVector.getY())));
44 
45 			if(getBuffered2DDecomposition().hasElements() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit()))
46 			{
47 				// conditions of last local decomposition have changed, delete
48 				const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
49 			}
50 
51 			if(!getBuffered2DDecomposition().hasElements())
52 			{
53 				// remember new valid DiscreteUnit
54 				const_cast< DiscreteMetricDependentPrimitive2D* >(this)->updateDiscreteUnit(fDiscreteUnit);
55 			}
56 
57 			// call base implementation
58 			return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
59 		}
60 	} // end of namespace primitive2d
61 } // end of namespace drawinglayer
62 
63 //////////////////////////////////////////////////////////////////////////////
64 
65 namespace drawinglayer
66 {
67 	namespace primitive2d
68 	{
get2DDecomposition(const geometry::ViewInformation2D & rViewInformation) const69 		Primitive2DSequence ViewportDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
70 		{
71 			::osl::MutexGuard aGuard( m_aMutex );
72 
73 			// get the current Viewport
74 			const basegfx::B2DRange& rViewport = rViewInformation.getViewport();
75 
76 			if(getBuffered2DDecomposition().hasElements() && !rViewport.equal(getViewport()))
77 			{
78 				// conditions of last local decomposition have changed, delete
79 				const_cast< ViewportDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
80 			}
81 
82 			if(!getBuffered2DDecomposition().hasElements())
83 			{
84 				// remember new valid DiscreteUnit
85 				const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport;
86 			}
87 
88 			// call base implementation
89 			return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
90 		}
91 	} // end of namespace primitive2d
92 } // end of namespace drawinglayer
93 
94 //////////////////////////////////////////////////////////////////////////////
95 
96 namespace drawinglayer
97 {
98 	namespace primitive2d
99 	{
get2DDecomposition(const geometry::ViewInformation2D & rViewInformation) const100 		Primitive2DSequence ViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
101 		{
102 			::osl::MutexGuard aGuard( m_aMutex );
103 
104 			// get the current ViewTransformation
105 			const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
106 
107 			if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation())
108 			{
109 				// conditions of last local decomposition have changed, delete
110 				const_cast< ViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
111 			}
112 
113 			if(!getBuffered2DDecomposition().hasElements())
114 			{
115 				// remember new valid ViewTransformation
116 				const_cast< ViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
117 			}
118 
119 			// call base implementation
120 			return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
121 		}
122 	} // end of namespace primitive2d
123 } // end of namespace drawinglayer
124 
125 //////////////////////////////////////////////////////////////////////////////
126 
127 namespace drawinglayer
128 {
129 	namespace primitive2d
130 	{
get2DDecomposition(const geometry::ViewInformation2D & rViewInformation) const131 		Primitive2DSequence ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const
132 		{
133 			::osl::MutexGuard aGuard( m_aMutex );
134 
135 			// get the current ViewTransfromation
136 			const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
137 
138 			if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation())
139 			{
140 				// conditions of last local decomposition have changed, delete
141 				const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
142 			}
143 
144 			// get the current ObjectTransformation
145 			const basegfx::B2DHomMatrix& rObjectTransformation = rViewInformation.getObjectTransformation();
146 
147 			if(getBuffered2DDecomposition().hasElements() && rObjectTransformation != getObjectTransformation())
148 			{
149 				// conditions of last local decomposition have changed, delete
150 				const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence());
151 			}
152 
153 			if(!getBuffered2DDecomposition().hasElements())
154 			{
155 				// remember new valid ViewTransformation, and ObjectTransformation
156 				const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
157 				const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maObjectTransformation = rObjectTransformation;
158 			}
159 
160 			// call base implementation
161 			return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation);
162 		}
163 	} // end of namespace primitive2d
164 } // end of namespace drawinglayer
165 
166 //////////////////////////////////////////////////////////////////////////////
167 // eof
168