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 #ifndef INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX 25 #define INCLUDED_DRAWINGLAYER_TEXTURE_TEXTURE_HXX 26 27 #include <drawinglayer/drawinglayerdllapi.h> 28 #include <basegfx/matrix/b2dhommatrix.hxx> 29 #include <basegfx/range/b2drange.hxx> 30 #include <basegfx/color/bcolor.hxx> 31 #include <basegfx/tools/gradienttools.hxx> 32 #include <vector> 33 34 ////////////////////////////////////////////////////////////////////////////// 35 namespace drawinglayer 36 { 37 namespace texture 38 { 39 class DRAWINGLAYER_DLLPUBLIC GeoTexSvx 40 { 41 public: 42 GeoTexSvx(); 43 virtual ~GeoTexSvx(); 44 45 // compare operator 46 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const; operator !=(const GeoTexSvx & rGeoTexSvx) const47 bool operator!=(const GeoTexSvx& rGeoTexSvx) const { return !operator==(rGeoTexSvx); } 48 49 // virtual base methods 50 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; 51 virtual void modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const; 52 }; 53 } // end of namespace texture 54 } // end of namespace drawinglayer 55 56 ////////////////////////////////////////////////////////////////////////////// 57 58 namespace drawinglayer 59 { 60 namespace texture 61 { 62 /// helper class for processing equal number of matrices and colors 63 /// for texture processing 64 struct B2DHomMatrixAndBColor 65 { 66 basegfx::B2DHomMatrix maB2DHomMatrix; 67 basegfx::BColor maBColor; 68 }; 69 } // end of namespace texture 70 } // end of namespace drawinglayer 71 72 ////////////////////////////////////////////////////////////////////////////// 73 74 namespace drawinglayer 75 { 76 namespace texture 77 { 78 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradient : public GeoTexSvx 79 { 80 protected: 81 basegfx::ODFGradientInfo maGradientInfo; 82 basegfx::B2DRange maDefinitionRange; 83 basegfx::BColor maStart; 84 basegfx::BColor maEnd; 85 double mfBorder; 86 87 public: 88 GeoTexSvxGradient( 89 const basegfx::B2DRange& rDefinitionRange, 90 const basegfx::BColor& rStart, 91 const basegfx::BColor& rEnd, 92 sal_uInt32 nSteps, 93 double fBorder); 94 virtual ~GeoTexSvxGradient(); 95 96 // compare operator 97 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const; 98 99 // virtual base methods 100 virtual void appendTransformationsAndColors( 101 std::vector< B2DHomMatrixAndBColor >& rEntries, 102 basegfx::BColor& rOuterColor) = 0; 103 104 // data access getStart() const105 const basegfx::BColor& getStart() const { return maStart; } getEnd() const106 const basegfx::BColor& getEnd() const { return maEnd; } 107 }; 108 } // end of namespace texture 109 } // end of namespace drawinglayer 110 111 ////////////////////////////////////////////////////////////////////////////// 112 113 namespace drawinglayer 114 { 115 namespace texture 116 { 117 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientLinear : public GeoTexSvxGradient 118 { 119 protected: 120 double mfUnitMinX; 121 double mfUnitWidth; 122 double mfUnitMaxY; 123 124 public: 125 GeoTexSvxGradientLinear( 126 const basegfx::B2DRange& rDefinitionRange, 127 const basegfx::B2DRange& rOutputRange, 128 const basegfx::BColor& rStart, 129 const basegfx::BColor& rEnd, 130 sal_uInt32 nSteps, 131 double fBorder, 132 double fAngle); 133 virtual ~GeoTexSvxGradientLinear(); 134 135 virtual void appendTransformationsAndColors( 136 std::vector< B2DHomMatrixAndBColor >& rEntries, 137 basegfx::BColor& rOuterColor); 138 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; 139 }; 140 } // end of namespace texture 141 } // end of namespace drawinglayer 142 143 ////////////////////////////////////////////////////////////////////////////// 144 145 namespace drawinglayer 146 { 147 namespace texture 148 { 149 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientAxial : public GeoTexSvxGradient 150 { 151 protected: 152 double mfUnitMinX; 153 double mfUnitWidth; 154 155 public: 156 GeoTexSvxGradientAxial( 157 const basegfx::B2DRange& rDefinitionRange, 158 const basegfx::B2DRange& rOutputRange, 159 const basegfx::BColor& rStart, 160 const basegfx::BColor& rEnd, 161 sal_uInt32 nSteps, 162 double fBorder, 163 double fAngle); 164 virtual ~GeoTexSvxGradientAxial(); 165 166 virtual void appendTransformationsAndColors( 167 std::vector< B2DHomMatrixAndBColor >& rEntries, 168 basegfx::BColor& rOuterColor); 169 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; 170 }; 171 } // end of namespace texture 172 } // end of namespace drawinglayer 173 174 ////////////////////////////////////////////////////////////////////////////// 175 176 namespace drawinglayer 177 { 178 namespace texture 179 { 180 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRadial : public GeoTexSvxGradient 181 { 182 public: 183 GeoTexSvxGradientRadial( 184 const basegfx::B2DRange& rDefinitionRange, 185 const basegfx::BColor& rStart, 186 const basegfx::BColor& rEnd, 187 sal_uInt32 nSteps, 188 double fBorder, 189 double fOffsetX, 190 double fOffsetY); 191 virtual ~GeoTexSvxGradientRadial(); 192 193 virtual void appendTransformationsAndColors( 194 std::vector< B2DHomMatrixAndBColor >& rEntries, 195 basegfx::BColor& rOuterColor); 196 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; 197 }; 198 } // end of namespace texture 199 } // end of namespace drawinglayer 200 201 ////////////////////////////////////////////////////////////////////////////// 202 203 namespace drawinglayer 204 { 205 namespace texture 206 { 207 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientElliptical : public GeoTexSvxGradient 208 { 209 public: 210 GeoTexSvxGradientElliptical( 211 const basegfx::B2DRange& rDefinitionRange, 212 const basegfx::BColor& rStart, 213 const basegfx::BColor& rEnd, 214 sal_uInt32 nSteps, 215 double fBorder, 216 double fOffsetX, 217 double fOffsetY, 218 double fAngle); 219 virtual ~GeoTexSvxGradientElliptical(); 220 221 virtual void appendTransformationsAndColors( 222 std::vector< B2DHomMatrixAndBColor >& rEntries, 223 basegfx::BColor& rOuterColor); 224 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; 225 }; 226 } // end of namespace texture 227 } // end of namespace drawinglayer 228 229 ////////////////////////////////////////////////////////////////////////////// 230 231 namespace drawinglayer 232 { 233 namespace texture 234 { 235 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientSquare : public GeoTexSvxGradient 236 { 237 public: 238 GeoTexSvxGradientSquare( 239 const basegfx::B2DRange& rDefinitionRange, 240 const basegfx::BColor& rStart, 241 const basegfx::BColor& rEnd, 242 sal_uInt32 nSteps, 243 double fBorder, 244 double fOffsetX, 245 double fOffsetY, 246 double fAngle); 247 virtual ~GeoTexSvxGradientSquare(); 248 249 virtual void appendTransformationsAndColors( 250 std::vector< B2DHomMatrixAndBColor >& rEntries, 251 basegfx::BColor& rOuterColor); 252 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; 253 }; 254 } // end of namespace texture 255 } // end of namespace drawinglayer 256 257 ////////////////////////////////////////////////////////////////////////////// 258 259 namespace drawinglayer 260 { 261 namespace texture 262 { 263 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxGradientRect : public GeoTexSvxGradient 264 { 265 public: 266 GeoTexSvxGradientRect( 267 const basegfx::B2DRange& rDefinitionRange, 268 const basegfx::BColor& rStart, 269 const basegfx::BColor& rEnd, 270 sal_uInt32 nSteps, 271 double fBorder, 272 double fOffsetX, 273 double fOffsetY, 274 double fAngle); 275 virtual ~GeoTexSvxGradientRect(); 276 277 virtual void appendTransformationsAndColors( 278 std::vector< B2DHomMatrixAndBColor >& rEntries, 279 basegfx::BColor& rOuterColor); 280 virtual void modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& rfOpacity) const; 281 }; 282 } // end of namespace texture 283 } // end of namespace drawinglayer 284 285 ////////////////////////////////////////////////////////////////////////////// 286 287 namespace drawinglayer 288 { 289 namespace texture 290 { 291 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxHatch : public GeoTexSvx 292 { 293 protected: 294 basegfx::B2DRange maOutputRange; 295 basegfx::B2DHomMatrix maTextureTransform; 296 basegfx::B2DHomMatrix maBackTextureTransform; 297 double mfDistance; 298 double mfAngle; 299 sal_uInt32 mnSteps; 300 301 /// bitfield 302 bool mbDefinitionRangeEqualsOutputRange : 1; 303 304 public: 305 GeoTexSvxHatch( 306 const basegfx::B2DRange& rDefinitionRange, 307 const basegfx::B2DRange& rOutputRange, 308 double fDistance, 309 double fAngle); 310 virtual ~GeoTexSvxHatch(); 311 312 // compare operator 313 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const; 314 315 void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); 316 double getDistanceToHatch(const basegfx::B2DPoint& rUV) const; 317 const basegfx::B2DHomMatrix& getBackTextureTransform() const; 318 }; 319 } // end of namespace texture 320 } // end of namespace drawinglayer 321 322 ////////////////////////////////////////////////////////////////////////////// 323 324 namespace drawinglayer 325 { 326 namespace texture 327 { 328 // This class applies a tiling to the unit range. The given range 329 // will be repeated inside the unit range in X and Y and for each 330 // tile a matrix will be created (by appendTransformations) that 331 // represents the needed transformation to map a filling in unit 332 // coordinates to that tile. 333 // When offsetX is given, every 2nd line will be ofsetted by the 334 // given percentage value (offsetX has to be 0.0 <= offsetX <= 1.0). 335 // Accordingly to offsetY. If both are given, offsetX is preferred 336 // and offsetY is ignored. 337 class DRAWINGLAYER_DLLPUBLIC GeoTexSvxTiled : public GeoTexSvx 338 { 339 protected: 340 basegfx::B2DRange maRange; 341 double mfOffsetX; 342 double mfOffsetY; 343 344 public: 345 GeoTexSvxTiled( 346 const basegfx::B2DRange& rRange, 347 double fOffsetX = 0.0, 348 double fOffsetY = 0.0); 349 virtual ~GeoTexSvxTiled(); 350 351 // compare operator 352 virtual bool operator==(const GeoTexSvx& rGeoTexSvx) const; 353 354 void appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices); 355 }; 356 } // end of namespace texture 357 } // end of namespace drawinglayer 358 359 ////////////////////////////////////////////////////////////////////////////// 360 361 #endif //_DRAWINGLAYER_TEXTURE_TEXTURE_HXX 362 363 // eof 364