fillhatchprimitive2d.cxx (0702bc67) | fillhatchprimitive2d.cxx (64b14621) |
---|---|
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 --- 28 unchanged lines hidden (view full) --- 37////////////////////////////////////////////////////////////////////////////// 38 39using namespace com::sun::star; 40 41////////////////////////////////////////////////////////////////////////////// 42 43namespace drawinglayer 44{ | 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 --- 28 unchanged lines hidden (view full) --- 37////////////////////////////////////////////////////////////////////////////// 38 39using namespace com::sun::star; 40 41////////////////////////////////////////////////////////////////////////////// 42 43namespace drawinglayer 44{ |
45 namespace primitive2d 46 { 47 Primitive2DSequence FillHatchPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const 48 { 49 Primitive2DSequence aRetval; | 45 namespace primitive2d 46 { 47 Primitive2DSequence FillHatchPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const 48 { 49 Primitive2DSequence aRetval; |
50 51 if(!getFillHatch().isDefault()) 52 { | 50 51 if(!getFillHatch().isDefault()) 52 { |
53 // create hatch 54 const basegfx::BColor aHatchColor(getFillHatch().getColor()); 55 const double fAngle(getFillHatch().getAngle()); 56 ::std::vector< basegfx::B2DHomMatrix > aMatrices; | 53 // create hatch 54 const basegfx::BColor aHatchColor(getFillHatch().getColor()); 55 const double fAngle(getFillHatch().getAngle()); 56 ::std::vector< basegfx::B2DHomMatrix > aMatrices; |
57 double fDistance(getFillHatch().getDistance()); 58 const bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance()); 59 60 // #120230# evtl. adapt distance 61 if(bAdaptDistance) 62 { 63 const double fDiscreteDistance(getFillHatch().getDistance() / getDiscreteUnit()); 64 65 if(fDiscreteDistance < (double)getFillHatch().getMinimalDiscreteDistance()) 66 { 67 fDistance = (double)getFillHatch().getMinimalDiscreteDistance() * getDiscreteUnit(); 68 } 69 } 70 | 57 double fDistance(getFillHatch().getDistance()); 58 const bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance()); 59 60 // #120230# evtl. adapt distance 61 if(bAdaptDistance) 62 { 63 const double fDiscreteDistance(getFillHatch().getDistance() / getDiscreteUnit()); 64 65 if(fDiscreteDistance < (double)getFillHatch().getMinimalDiscreteDistance()) 66 { 67 fDistance = (double)getFillHatch().getMinimalDiscreteDistance() * getDiscreteUnit(); 68 } 69 } 70 |
71 // get hatch transformations 72 switch(getFillHatch().getStyle()) 73 { 74 case attribute::HATCHSTYLE_TRIPLE: 75 { 76 // rotated 45 degrees 77 texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle - F_PI4); 78 aHatch.appendTransformations(aMatrices); | 71 // get hatch transformations 72 switch(getFillHatch().getStyle()) 73 { 74 case attribute::HATCHSTYLE_TRIPLE: 75 { 76 // rotated 45 degrees 77 texture::GeoTexSvxHatch aHatch( 78 getDefinitionRange(), 79 getOutputRange(), 80 fDistance, 81 fAngle - F_PI4); |
79 | 82 |
80 // fall-through by purpose 81 } 82 case attribute::HATCHSTYLE_DOUBLE: 83 { 84 // rotated 90 degrees 85 texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle - F_PI2); 86 aHatch.appendTransformations(aMatrices); | 83 aHatch.appendTransformations(aMatrices); |
87 | 84 |
88 // fall-through by purpose 89 } 90 case attribute::HATCHSTYLE_SINGLE: 91 { 92 // angle as given 93 texture::GeoTexSvxHatch aHatch(getObjectRange(), fDistance, fAngle); 94 aHatch.appendTransformations(aMatrices); 95 } 96 } | 85 // fall-through by purpose 86 } 87 case attribute::HATCHSTYLE_DOUBLE: 88 { 89 // rotated 90 degrees 90 texture::GeoTexSvxHatch aHatch( 91 getDefinitionRange(), 92 getOutputRange(), 93 fDistance, 94 fAngle - F_PI2); |
97 | 95 |
98 // prepare return value 99 const bool bFillBackground(getFillHatch().isFillBackground()); 100 aRetval.realloc(bFillBackground ? aMatrices.size() + 1L : aMatrices.size()); | 96 aHatch.appendTransformations(aMatrices); |
101 | 97 |
102 // evtl. create filled background 103 if(bFillBackground) 104 { 105 // create primitive for background 106 const Primitive2DReference xRef( | 98 // fall-through by purpose 99 } 100 case attribute::HATCHSTYLE_SINGLE: 101 { 102 // angle as given 103 texture::GeoTexSvxHatch aHatch( 104 getDefinitionRange(), 105 getOutputRange(), 106 fDistance, 107 fAngle); 108 109 aHatch.appendTransformations(aMatrices); 110 } 111 } 112 113 // prepare return value 114 const bool bFillBackground(getFillHatch().isFillBackground()); 115 aRetval.realloc(bFillBackground ? aMatrices.size() + 1L : aMatrices.size()); 116 117 // evtl. create filled background 118 if(bFillBackground) 119 { 120 // create primitive for background 121 const Primitive2DReference xRef( |
107 new PolyPolygonColorPrimitive2D( 108 basegfx::B2DPolyPolygon( | 122 new PolyPolygonColorPrimitive2D( 123 basegfx::B2DPolyPolygon( |
109 basegfx::tools::createPolygonFromRect(getObjectRange())), getBColor())); 110 aRetval[0] = xRef; 111 } | 124 basegfx::tools::createPolygonFromRect(getOutputRange())), getBColor())); 125 aRetval[0] = xRef; 126 } |
112 | 127 |
113 // create primitives 114 const basegfx::B2DPoint aStart(0.0, 0.0); 115 const basegfx::B2DPoint aEnd(1.0, 0.0); | 128 // create primitives 129 const basegfx::B2DPoint aStart(0.0, 0.0); 130 const basegfx::B2DPoint aEnd(1.0, 0.0); |
116 | 131 |
117 for(sal_uInt32 a(0L); a < aMatrices.size(); a++) 118 { 119 const basegfx::B2DHomMatrix& rMatrix = aMatrices[a]; 120 basegfx::B2DPolygon aNewLine; | 132 for(sal_uInt32 a(0L); a < aMatrices.size(); a++) 133 { 134 const basegfx::B2DHomMatrix& rMatrix = aMatrices[a]; 135 basegfx::B2DPolygon aNewLine; |
121 | 136 |
122 aNewLine.append(rMatrix * aStart); 123 aNewLine.append(rMatrix * aEnd); | 137 aNewLine.append(rMatrix * aStart); 138 aNewLine.append(rMatrix * aEnd); |
124 | 139 |
125 // create hairline 126 const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aNewLine, aHatchColor)); 127 aRetval[bFillBackground ? (a + 1) : a] = xRef; 128 } | 140 // create hairline 141 const Primitive2DReference xRef(new PolygonHairlinePrimitive2D(aNewLine, aHatchColor)); 142 aRetval[bFillBackground ? (a + 1) : a] = xRef; 143 } |
129 } 130 131 return aRetval; | 144 } 145 146 return aRetval; |
132 } | 147 } |
133 | 148 |
134 FillHatchPrimitive2D::FillHatchPrimitive2D( 135 const basegfx::B2DRange& rObjectRange, 136 const basegfx::BColor& rBColor, 137 const attribute::FillHatchAttribute& rFillHatch) 138 : DiscreteMetricDependentPrimitive2D(), 139 maObjectRange(rObjectRange), 140 maFillHatch(rFillHatch), 141 maBColor(rBColor) 142 { 143 } | 149 FillHatchPrimitive2D::FillHatchPrimitive2D( 150 const basegfx::B2DRange& rOutputRange, 151 const basegfx::BColor& rBColor, 152 const attribute::FillHatchAttribute& rFillHatch) 153 : DiscreteMetricDependentPrimitive2D(), 154 maOutputRange(rOutputRange), 155 maDefinitionRange(rOutputRange), 156 maFillHatch(rFillHatch), 157 maBColor(rBColor) 158 { 159 } |
144 | 160 |
145 bool FillHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 146 { 147 if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) 148 { 149 const FillHatchPrimitive2D& rCompare = (FillHatchPrimitive2D&)rPrimitive; | 161 FillHatchPrimitive2D::FillHatchPrimitive2D( 162 const basegfx::B2DRange& rOutputRange, 163 const basegfx::B2DRange& rDefinitionRange, 164 const basegfx::BColor& rBColor, 165 const attribute::FillHatchAttribute& rFillHatch) 166 : DiscreteMetricDependentPrimitive2D(), 167 maOutputRange(rOutputRange), 168 maDefinitionRange(rDefinitionRange), 169 maFillHatch(rFillHatch), 170 maBColor(rBColor) 171 { 172 } |
150 | 173 |
151 return (getObjectRange() == rCompare.getObjectRange() 152 && getFillHatch() == rCompare.getFillHatch() 153 && getBColor() == rCompare.getBColor()); 154 } | 174 bool FillHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const 175 { 176 if(DiscreteMetricDependentPrimitive2D::operator==(rPrimitive)) 177 { 178 const FillHatchPrimitive2D& rCompare = (FillHatchPrimitive2D&)rPrimitive; |
155 | 179 |
156 return false; 157 } | 180 return (getOutputRange() == rCompare.getOutputRange() 181 && getDefinitionRange() == rCompare.getDefinitionRange() 182 && getFillHatch() == rCompare.getFillHatch() 183 && getBColor() == rCompare.getBColor()); 184 } |
158 | 185 |
159 basegfx::B2DRange FillHatchPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const 160 { 161 // return ObjectRange 162 return getObjectRange(); 163 } | 186 return false; 187 } |
164 | 188 |
165 Primitive2DSequence FillHatchPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const | 189 basegfx::B2DRange FillHatchPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const |
166 { | 190 { |
167 ::osl::MutexGuard aGuard( m_aMutex ); | 191 // return the geometrically visible area 192 return getOutputRange(); 193 } 194 195 Primitive2DSequence FillHatchPrimitive2D::get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const 196 { 197 ::osl::MutexGuard aGuard( m_aMutex ); |
168 bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance()); 169 170 if(bAdaptDistance) 171 { 172 // behave view-dependent 173 return DiscreteMetricDependentPrimitive2D::get2DDecomposition(rViewInformation); 174 } 175 else 176 { 177 // behave view-independent 178 return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); 179 } 180 } 181 182 // provide unique ID | 198 bool bAdaptDistance(0 != getFillHatch().getMinimalDiscreteDistance()); 199 200 if(bAdaptDistance) 201 { 202 // behave view-dependent 203 return DiscreteMetricDependentPrimitive2D::get2DDecomposition(rViewInformation); 204 } 205 else 206 { 207 // behave view-independent 208 return BufferedDecompositionPrimitive2D::get2DDecomposition(rViewInformation); 209 } 210 } 211 212 // provide unique ID |
183 ImplPrimitrive2DIDBlock(FillHatchPrimitive2D, PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D) | 213 ImplPrimitrive2DIDBlock(FillHatchPrimitive2D, PRIMITIVE2D_ID_FILLHATCHPRIMITIVE2D) |
184 | 214 |
185 } // end of namespace primitive2d | 215 } // end of namespace primitive2d |
186} // end of namespace drawinglayer 187 188////////////////////////////////////////////////////////////////////////////// 189// eof | 216} // end of namespace drawinglayer 217 218////////////////////////////////////////////////////////////////////////////// 219// eof |