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 { 37 Primitive2DSequence DiscreteMetricDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const 38 { 39 ::osl::MutexGuard aGuard( m_aMutex ); 40 41 // get the current DiscreteUnit 42 const double fDiscreteUnit((rViewInformation.getInverseObjectToViewTransformation() * basegfx::B2DVector(1.0, 0.0)).getLength()); 43 44 if(getBuffered2DDecomposition().hasElements() && !basegfx::fTools::equal(fDiscreteUnit, getDiscreteUnit())) 45 { 46 // conditions of last local decomposition have changed, delete 47 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); 48 } 49 50 if(!getBuffered2DDecomposition().hasElements()) 51 { 52 // remember new valid DiscreteUnit 53 const_cast< DiscreteMetricDependentPrimitive2D* >(this)->updateDiscreteUnit(fDiscreteUnit); 54 } 55 56 // call base implementation 57 return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); 58 } 59 } // end of namespace primitive2d 60 } // end of namespace drawinglayer 61 62 ////////////////////////////////////////////////////////////////////////////// 63 64 namespace drawinglayer 65 { 66 namespace primitive2d 67 { 68 Primitive2DSequence ViewportDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const 69 { 70 ::osl::MutexGuard aGuard( m_aMutex ); 71 72 // get the current Viewport 73 const basegfx::B2DRange& rViewport = rViewInformation.getViewport(); 74 75 if(getBuffered2DDecomposition().hasElements() && !rViewport.equal(getViewport())) 76 { 77 // conditions of last local decomposition have changed, delete 78 const_cast< ViewportDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); 79 } 80 81 if(!getBuffered2DDecomposition().hasElements()) 82 { 83 // remember new valid DiscreteUnit 84 const_cast< ViewportDependentPrimitive2D* >(this)->maViewport = rViewport; 85 } 86 87 // call base implementation 88 return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); 89 } 90 } // end of namespace primitive2d 91 } // end of namespace drawinglayer 92 93 ////////////////////////////////////////////////////////////////////////////// 94 95 namespace drawinglayer 96 { 97 namespace primitive2d 98 { 99 Primitive2DSequence ViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const 100 { 101 ::osl::MutexGuard aGuard( m_aMutex ); 102 103 // get the current ViewTransformation 104 const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation(); 105 106 if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation()) 107 { 108 // conditions of last local decomposition have changed, delete 109 const_cast< ViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); 110 } 111 112 if(!getBuffered2DDecomposition().hasElements()) 113 { 114 // remember new valid ViewTransformation 115 const_cast< ViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation; 116 } 117 118 // call base implementation 119 return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); 120 } 121 } // end of namespace primitive2d 122 } // end of namespace drawinglayer 123 124 ////////////////////////////////////////////////////////////////////////////// 125 126 namespace drawinglayer 127 { 128 namespace primitive2d 129 { 130 Primitive2DSequence ObjectAndViewTransformationDependentPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const 131 { 132 ::osl::MutexGuard aGuard( m_aMutex ); 133 134 // get the current ViewTransfromation 135 const basegfx::B2DHomMatrix& rViewTransformation = rViewInformation.getViewTransformation(); 136 137 if(getBuffered2DDecomposition().hasElements() && rViewTransformation != getViewTransformation()) 138 { 139 // conditions of last local decomposition have changed, delete 140 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); 141 } 142 143 // get the current ObjectTransformation 144 const basegfx::B2DHomMatrix& rObjectTransformation = rViewInformation.getObjectTransformation(); 145 146 if(getBuffered2DDecomposition().hasElements() && rObjectTransformation != getObjectTransformation()) 147 { 148 // conditions of last local decomposition have changed, delete 149 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->setBuffered2DDecomposition(Primitive2DSequence()); 150 } 151 152 if(!getBuffered2DDecomposition().hasElements()) 153 { 154 // remember new valid ViewTransformation, and ObjectTransformation 155 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maViewTransformation = rViewTransformation; 156 const_cast< ObjectAndViewTransformationDependentPrimitive2D* >(this)->maObjectTransformation = rObjectTransformation; 157 } 158 159 // call base implementation 160 return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); 161 } 162 } // end of namespace primitive2d 163 } // end of namespace drawinglayer 164 165 ////////////////////////////////////////////////////////////////////////////// 166 // eof 167