bump product version to 6.4.0.3
[LibreOffice.git] / drawinglayer / source / primitive2d / primitivetools2d.cxx
blob6507e9384f7eac70921f29c81441dc1a26feabf4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <drawinglayer/primitive2d/primitivetools2d.hxx>
21 #include <basegfx/vector/b2dvector.hxx>
22 #include <drawinglayer/geometry/viewinformation2d.hxx>
25 namespace drawinglayer
27 namespace primitive2d
29 void DiscreteMetricDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
31 ::osl::MutexGuard aGuard( m_aMutex );
33 // get the current DiscreteUnit, look at X and Y and use the maximum
34 const basegfx::B2DVector aDiscreteVector(rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 1.0));
35 const double fDiscreteUnit(std::min(fabs(aDiscreteVector.getX()), fabs(aDiscreteVector.getY())));
37 if(!getBuffered2DDecomposition().empty() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit()))
39 // conditions of last local decomposition have changed, delete
40 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
43 if(getBuffered2DDecomposition().empty())
45 // remember new valid DiscreteUnit
46 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->mfDiscreteUnit = fDiscreteUnit;
49 // call base implementation
50 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
52 } // end of namespace primitive2d
53 } // end of namespace drawinglayer
56 namespace drawinglayer
58 namespace primitive2d
60 void ViewportDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
62 ::osl::MutexGuard aGuard( m_aMutex );
64 // get the current Viewport
65 const basegfx::B2DRange& rViewport = rViewInformation.getViewport();
67 if(!getBuffered2DDecomposition().empty() && !rViewport.equal(getViewport()))
69 // conditions of last local decomposition have changed, delete
70 const_cast< ViewportDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
73 if(getBuffered2DDecomposition().empty())
75 // remember new valid DiscreteUnit
76 const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport;
79 // call base implementation
80 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
82 } // end of namespace primitive2d
83 } // end of namespace drawinglayer
86 namespace drawinglayer
88 namespace primitive2d
90 void ViewTransformationDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
92 ::osl::MutexGuard aGuard( m_aMutex );
94 // get the current ViewTransformation
95 const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
97 if(!getBuffered2DDecomposition().empty() && rViewTransformation != getViewTransformation())
99 // conditions of last local decomposition have changed, delete
100 const_cast< ViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
103 if(getBuffered2DDecomposition().empty())
105 // remember new valid ViewTransformation
106 const_cast< ViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
109 // call base implementation
110 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
112 } // end of namespace primitive2d
113 } // end of namespace drawinglayer
116 namespace drawinglayer
118 namespace primitive2d
120 void ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const
122 ::osl::MutexGuard aGuard( m_aMutex );
124 // get the current ViewTransformation
125 const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation();
127 if(!getBuffered2DDecomposition().empty() && rViewTransformation != getViewTransformation())
129 // conditions of last local decomposition have changed, delete
130 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
133 // get the current ObjectTransformation
134 const basegfx::B2DHomMatrix& rObjectTransformation = rViewInformation.getObjectTransformation();
136 if(!getBuffered2DDecomposition().empty() && rObjectTransformation != getObjectTransformation())
138 // conditions of last local decomposition have changed, delete
139 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DContainer());
142 if(getBuffered2DDecomposition().empty())
144 // remember new valid ViewTransformation, and ObjectTransformation
145 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation;
146 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maObjectTransformation = rObjectTransformation;
149 // call base implementation
150 BufferedDecompositionPrimitive2D::get2DDecomposition(rVisitor, rViewInformation);
152 } // end of namespace primitive2d
153 } // end of namespace drawinglayer
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */