1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 20 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX 21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX 22 23 #include <drawinglayer/drawinglayerdllapi.h> 24 25 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 26 #include <drawinglayer/attribute/fillgraphicattribute.hxx> 27 #include <basegfx/polygon/b2dpolypolygon.hxx> 28 #include <drawinglayer/attribute/lineattribute.hxx> 29 #include <drawinglayer/attribute/strokeattribute.hxx> 30 #include <drawinglayer/attribute/fillgradientattribute.hxx> 31 #include <drawinglayer/attribute/fillhatchattribute.hxx> 32 #include <drawinglayer/primitive2d/primitivetools2d.hxx> 33 #include <basegfx/color/bcolor.hxx> 34 35 36 // PolyPolygonHairlinePrimitive2D class 37 38 namespace drawinglayer 39 { 40 namespace primitive2d 41 { 42 /** PolyPolygonHairlinePrimitive2D class 43 44 This primitive defines a multi-PolygonHairlinePrimitive2D and is 45 just for convenience. The definition is not different from the single 46 defined PolygonHairlinePrimitive2Ds. 47 */ 48 class DRAWINGLAYER_DLLPUBLIC PolyPolygonHairlinePrimitive2D final : public BufferedDecompositionPrimitive2D 49 { 50 private: 51 /// the hairline geometry 52 basegfx::B2DPolyPolygon maPolyPolygon; 53 54 /// the hairline color 55 basegfx::BColor maBColor; 56 57 /// local decomposition. 58 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; 59 60 public: 61 /// constructor 62 PolyPolygonHairlinePrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor); 63 64 /// data read access getB2DPolyPolygon() const65 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } getBColor() const66 const basegfx::BColor& getBColor() const { return maBColor; } 67 68 /// compare operator 69 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; 70 71 /// get range 72 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; 73 74 /// provide unique ID 75 DeclPrimitive2DIDBlock() 76 }; 77 } // end of namespace primitive2d 78 } // end of namespace drawinglayer 79 80 81 // PolyPolygonMarkerPrimitive2D class 82 83 namespace drawinglayer 84 { 85 namespace primitive2d 86 { 87 /** PolyPolygonMarkerPrimitive2D class 88 89 This primitive defines a multi-PolygonMarkerPrimitive2D and is 90 just for convenience. The definition is not different from the single 91 defined PolygonMarkerPrimitive2Ds. 92 */ 93 class DRAWINGLAYER_DLLPUBLIC PolyPolygonMarkerPrimitive2D final : public BufferedDecompositionPrimitive2D 94 { 95 private: 96 /// the marker hairline geometry 97 basegfx::B2DPolyPolygon maPolyPolygon; 98 99 /// the two colors 100 basegfx::BColor maRGBColorA; 101 basegfx::BColor maRGBColorB; 102 103 /// the dash distance in 'pixels' 104 double mfDiscreteDashLength; 105 106 /// local decomposition. 107 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; 108 109 public: 110 /// constructor 111 PolyPolygonMarkerPrimitive2D( 112 const basegfx::B2DPolyPolygon& rPolyPolygon, 113 const basegfx::BColor& rRGBColorA, 114 const basegfx::BColor& rRGBColorB, 115 double fDiscreteDashLength); 116 117 // data read access getB2DPolyPolygon() const118 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } getRGBColorA() const119 const basegfx::BColor& getRGBColorA() const { return maRGBColorA; } getRGBColorB() const120 const basegfx::BColor& getRGBColorB() const { return maRGBColorB; } getDiscreteDashLength() const121 double getDiscreteDashLength() const { return mfDiscreteDashLength; } 122 123 /// compare operator 124 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; 125 126 /// get range 127 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; 128 129 /// provide unique ID 130 DeclPrimitive2DIDBlock() 131 }; 132 } // end of namespace primitive2d 133 } // end of namespace drawinglayer 134 135 136 // PolyPolygonStrokePrimitive2D class 137 138 namespace drawinglayer 139 { 140 namespace primitive2d 141 { 142 /** PolyPolygonStrokePrimitive2D class 143 144 This primitive defines a multi-PolygonStrokePrimitive2D and is 145 just for convenience. The definition is not different from the single 146 defined PolygonStrokePrimitive2Ds. 147 */ 148 class DRAWINGLAYER_DLLPUBLIC PolyPolygonStrokePrimitive2D final : public BufferedDecompositionPrimitive2D 149 { 150 private: 151 /// the line geometry 152 basegfx::B2DPolyPolygon maPolyPolygon; 153 154 /// the line attributes like width, join and color 155 attribute::LineAttribute maLineAttribute; 156 157 /// the line stroking (if used) 158 attribute::StrokeAttribute maStrokeAttribute; 159 160 /// local decomposition. 161 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; 162 163 public: 164 /// constructor 165 PolyPolygonStrokePrimitive2D( 166 const basegfx::B2DPolyPolygon& rPolyPolygon, 167 const attribute::LineAttribute& rLineAttribute, 168 const attribute::StrokeAttribute& rStrokeAttribute); 169 170 PolyPolygonStrokePrimitive2D( 171 const basegfx::B2DPolyPolygon& rPolyPolygon, 172 const attribute::LineAttribute& rLineAttribute); 173 174 /// data read access getB2DPolyPolygon() const175 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } getLineAttribute() const176 const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; } getStrokeAttribute() const177 const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; } 178 179 /// compare operator 180 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; 181 182 /// get range 183 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; 184 185 /// provide unique ID 186 DeclPrimitive2DIDBlock() 187 }; 188 } // end of namespace primitive2d 189 } // end of namespace drawinglayer 190 191 192 // PolyPolygonColorPrimitive2D class 193 194 namespace drawinglayer 195 { 196 namespace primitive2d 197 { 198 /** PolyPolygonColorPrimitive2D class 199 200 This primitive defines a tools::PolyPolygon filled with a single color. 201 This is one of the non-decomposable primitives, so a renderer 202 should process it. 203 */ 204 class DRAWINGLAYER_DLLPUBLIC PolyPolygonColorPrimitive2D final : public BasePrimitive2D 205 { 206 private: 207 /// the tools::PolyPolygon geometry 208 basegfx::B2DPolyPolygon maPolyPolygon; 209 210 /// the polygon fill color 211 basegfx::BColor maBColor; 212 213 public: 214 /// constructor 215 PolyPolygonColorPrimitive2D( 216 const basegfx::B2DPolyPolygon& rPolyPolygon, 217 const basegfx::BColor& rBColor); 218 219 /// data read access getB2DPolyPolygon() const220 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } getBColor() const221 const basegfx::BColor& getBColor() const { return maBColor; } 222 223 /// compare operator 224 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; 225 226 /// get range 227 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; 228 229 /// provide unique ID 230 DeclPrimitive2DIDBlock() 231 }; 232 } // end of namespace primitive2d 233 } // end of namespace drawinglayer 234 235 236 // PolyPolygonGradientPrimitive2D class 237 238 namespace drawinglayer 239 { 240 namespace primitive2d 241 { 242 /** PolyPolygonColorPrimitive2D class 243 244 This primitive defines a tools::PolyPolygon filled with a gradient. The 245 decomosition will create a MaskPrimitive2D containing a 246 FillGradientPrimitive2D. 247 */ 248 class DRAWINGLAYER_DLLPUBLIC PolyPolygonGradientPrimitive2D final : public BufferedDecompositionPrimitive2D 249 { 250 private: 251 /// the tools::PolyPolygon geometry 252 basegfx::B2DPolyPolygon maPolyPolygon; 253 254 /// the definition range 255 basegfx::B2DRange maDefinitionRange; 256 257 /// the gradient definition 258 attribute::FillGradientAttribute maFillGradient; 259 260 /// local decomposition. 261 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; 262 263 public: 264 /// constructors. The one without definition range will use output range as definition range 265 PolyPolygonGradientPrimitive2D( 266 const basegfx::B2DPolyPolygon& rPolyPolygon, 267 const attribute::FillGradientAttribute& rFillGradient); 268 PolyPolygonGradientPrimitive2D( 269 const basegfx::B2DPolyPolygon& rPolyPolygon, 270 const basegfx::B2DRange& rDefinitionRange, 271 const attribute::FillGradientAttribute& rFillGradient); 272 273 /// data read access getB2DPolyPolygon() const274 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } getDefinitionRange() const275 const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } getFillGradient() const276 const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; } 277 278 /// compare operator 279 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; 280 281 /// provide unique ID 282 DeclPrimitive2DIDBlock() 283 }; 284 } // end of namespace primitive2d 285 } // end of namespace drawinglayer 286 287 288 // PolyPolygonHatchPrimitive2D class 289 290 namespace drawinglayer 291 { 292 namespace primitive2d 293 { 294 /** PolyPolygonHatchPrimitive2D class 295 296 This primitive defines a tools::PolyPolygon filled with a hatch. The 297 decomosition will create a MaskPrimitive2D containing a 298 FillHatchPrimitive2D. 299 */ 300 class DRAWINGLAYER_DLLPUBLIC PolyPolygonHatchPrimitive2D final : public BufferedDecompositionPrimitive2D 301 { 302 private: 303 /// the tools::PolyPolygon geometry 304 basegfx::B2DPolyPolygon maPolyPolygon; 305 306 /// the definition range 307 basegfx::B2DRange maDefinitionRange; 308 309 /// the hatch background color (if used) 310 basegfx::BColor maBackgroundColor; 311 312 /// the hatch definition 313 attribute::FillHatchAttribute maFillHatch; 314 315 /// local decomposition. 316 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; 317 318 public: 319 /// constructors. The one without definition range will use output range as definition range 320 PolyPolygonHatchPrimitive2D( 321 const basegfx::B2DPolyPolygon& rPolyPolygon, 322 const basegfx::BColor& rBackgroundColor, 323 const attribute::FillHatchAttribute& rFillHatch); 324 PolyPolygonHatchPrimitive2D( 325 const basegfx::B2DPolyPolygon& rPolyPolygon, 326 const basegfx::B2DRange& rDefinitionRange, 327 const basegfx::BColor& rBackgroundColor, 328 const attribute::FillHatchAttribute& rFillHatch); 329 330 /// data read access getB2DPolyPolygon() const331 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } getDefinitionRange() const332 const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } getBackgroundColor() const333 const basegfx::BColor& getBackgroundColor() const { return maBackgroundColor; } getFillHatch() const334 const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; } 335 336 /// compare operator 337 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; 338 339 /// provide unique ID 340 DeclPrimitive2DIDBlock() 341 }; 342 } // end of namespace primitive2d 343 } // end of namespace drawinglayer 344 345 346 // PolyPolygonGraphicPrimitive2D class 347 348 namespace drawinglayer 349 { 350 namespace primitive2d 351 { 352 /** PolyPolygonGraphicPrimitive2D class 353 354 This primitive defines a tools::PolyPolygon filled with bitmap data 355 (including transparence). The decomosition will create a MaskPrimitive2D 356 containing a FillGraphicPrimitive2D. 357 */ 358 class DRAWINGLAYER_DLLPUBLIC PolyPolygonGraphicPrimitive2D final : public BufferedDecompositionPrimitive2D 359 { 360 private: 361 /// the tools::PolyPolygon geometry 362 basegfx::B2DPolyPolygon maPolyPolygon; 363 364 /// the definition range 365 basegfx::B2DRange maDefinitionRange; 366 367 /// the bitmap fill definition (may include tiling) 368 attribute::FillGraphicAttribute maFillGraphic; 369 370 /// local decomposition. 371 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; 372 373 public: 374 PolyPolygonGraphicPrimitive2D( 375 const basegfx::B2DPolyPolygon& rPolyPolygon, 376 const basegfx::B2DRange& rDefinitionRange, 377 const attribute::FillGraphicAttribute& rFillGraphic); 378 379 /// data read access getB2DPolyPolygon() const380 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } getDefinitionRange() const381 const basegfx::B2DRange& getDefinitionRange() const { return maDefinitionRange; } getFillGraphic() const382 const attribute::FillGraphicAttribute& getFillGraphic() const { return maFillGraphic; } 383 384 /// compare operator 385 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; 386 387 /// provide unique ID 388 DeclPrimitive2DIDBlock() 389 }; 390 } // end of namespace primitive2d 391 } // end of namespace drawinglayer 392 393 394 // PolyPolygonSelectionPrimitive2D class 395 396 namespace drawinglayer 397 { 398 namespace primitive2d 399 { 400 /** PolyPolygonSelectionPrimitive2D class 401 402 This primitive defines a tools::PolyPolygon which gets filled with a defined color 403 and a defined transparence, but also gets extended ('grown') by the given 404 discrete size (thus being a view-dependent primitive) 405 */ 406 class DRAWINGLAYER_DLLPUBLIC PolyPolygonSelectionPrimitive2D final : public DiscreteMetricDependentPrimitive2D 407 { 408 private: 409 /// the tools::PolyPolygon geometry 410 basegfx::B2DPolyPolygon maPolyPolygon; 411 412 /// the color 413 basegfx::BColor maColor; 414 415 /// the transparence [0.0 .. 1.0] 416 double mfTransparence; 417 418 /// the discrete grow size ('pixels'), only positive values allowed 419 double mfDiscreteGrow; 420 421 /// draw polygons filled when fill is set 422 bool mbFill : 1; 423 424 /// local decomposition. 425 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override; 426 427 public: 428 /// constructor 429 PolyPolygonSelectionPrimitive2D( 430 const basegfx::B2DPolyPolygon& rPolyPolygon, 431 const basegfx::BColor& rColor, 432 double fTransparence, 433 double fDiscreteGrow, 434 bool bFill); 435 436 /// data read access getB2DPolyPolygon() const437 const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; } getColor() const438 const basegfx::BColor& getColor() const { return maColor; } getTransparence() const439 double getTransparence() const { return mfTransparence; } getDiscreteGrow() const440 double getDiscreteGrow() const { return mfDiscreteGrow; } getFill() const441 bool getFill() const { return mbFill; } 442 443 /// compare operator 444 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; 445 446 /// get range 447 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; 448 449 /// provide unique ID 450 DeclPrimitive2DIDBlock() 451 }; 452 } // end of namespace primitive2d 453 } // end of namespace drawinglayer 454 455 456 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX 457 458 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 459