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