xref: /AOO41X/main/drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx (revision 47148b3bc50811ceb41802e4cc50a5db21535900)
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_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
29 #include <drawinglayer/attribute/fillgraphicattribute.hxx>
30 #include <basegfx/polygon/b2dpolypolygon.hxx>
31 #include <drawinglayer/attribute/lineattribute.hxx>
32 #include <drawinglayer/attribute/strokeattribute.hxx>
33 #include <drawinglayer/attribute/linestartendattribute.hxx>
34 #include <drawinglayer/attribute/fillgradientattribute.hxx>
35 #include <drawinglayer/attribute/fillhatchattribute.hxx>
36 #include <drawinglayer/primitive2d/primitivetools2d.hxx>
37 #include <basegfx/color/bcolor.hxx>
38 
39 //////////////////////////////////////////////////////////////////////////////
40 // PolyPolygonHairlinePrimitive2D class
41 
42 namespace drawinglayer
43 {
44     namespace primitive2d
45     {
46         /** PolyPolygonHairlinePrimitive2D class
47 
48             This primitive defines a multi-PolygonHairlinePrimitive2D and is
49             just for convenience. The definition is not different from the single
50             defined PolygonHairlinePrimitive2Ds.
51          */
52         class DRAWINGLAYER_DLLPUBLIC PolyPolygonHairlinePrimitive2D : public BufferedDecompositionPrimitive2D
53         {
54         private:
55             /// the hairline geometry
56             basegfx::B2DPolyPolygon                 maPolyPolygon;
57 
58             /// the hairline color
59             basegfx::BColor                         maBColor;
60 
61         protected:
62             /// local decomposition.
63             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
64 
65         public:
66             /// constructor
67             PolyPolygonHairlinePrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor);
68 
69             /// data read access
getB2DPolyPolygon() const70             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
getBColor() const71             const basegfx::BColor& getBColor() const { return maBColor; }
72 
73             /// compare operator
74             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
75 
76             /// get range
77             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
78 
79             /// provide unique ID
80             DeclPrimitrive2DIDBlock()
81         };
82     } // end of namespace primitive2d
83 } // end of namespace drawinglayer
84 
85 //////////////////////////////////////////////////////////////////////////////
86 // PolyPolygonMarkerPrimitive2D class
87 
88 namespace drawinglayer
89 {
90     namespace primitive2d
91     {
92         /** PolyPolygonMarkerPrimitive2D class
93 
94             This primitive defines a multi-PolygonMarkerPrimitive2D and is
95             just for convenience. The definition is not different from the single
96             defined PolygonMarkerPrimitive2Ds.
97          */
98         class DRAWINGLAYER_DLLPUBLIC PolyPolygonMarkerPrimitive2D : public BufferedDecompositionPrimitive2D
99         {
100         private:
101             /// the marker hairline geometry
102             basegfx::B2DPolyPolygon                 maPolyPolygon;
103 
104             /// the two colors
105             basegfx::BColor                         maRGBColorA;
106             basegfx::BColor                         maRGBColorB;
107 
108             /// the dash distance in 'pixels'
109             double                                  mfDiscreteDashLength;
110 
111         protected:
112             /// local decomposition.
113             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
114 
115         public:
116             /// constructor
117             PolyPolygonMarkerPrimitive2D(
118                 const basegfx::B2DPolyPolygon& rPolyPolygon,
119                 const basegfx::BColor& rRGBColorA,
120                 const basegfx::BColor& rRGBColorB,
121                 double fDiscreteDashLength);
122 
123             // data read access
getB2DPolyPolygon() const124             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
getRGBColorA() const125             const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
getRGBColorB() const126             const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
getDiscreteDashLength() const127             double getDiscreteDashLength() const { return mfDiscreteDashLength; }
128 
129             /// compare operator
130             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
131 
132             /// get range
133             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
134 
135             /// provide unique ID
136             DeclPrimitrive2DIDBlock()
137         };
138     } // end of namespace primitive2d
139 } // end of namespace drawinglayer
140 
141 //////////////////////////////////////////////////////////////////////////////
142 // PolyPolygonStrokePrimitive2D class
143 
144 namespace drawinglayer
145 {
146     namespace primitive2d
147     {
148         /** PolyPolygonStrokePrimitive2D class
149 
150             This primitive defines a multi-PolygonStrokePrimitive2D and is
151             just for convenience. The definition is not different from the single
152             defined PolygonStrokePrimitive2Ds.
153          */
154         class DRAWINGLAYER_DLLPUBLIC PolyPolygonStrokePrimitive2D : public BufferedDecompositionPrimitive2D
155         {
156         private:
157             /// the line geometry
158             basegfx::B2DPolyPolygon                 maPolyPolygon;
159 
160             /// the line attributes like width, join and color
161             attribute::LineAttribute                maLineAttribute;
162 
163             /// the line stroking (if used)
164             attribute::StrokeAttribute              maStrokeAttribute;
165 
166         protected:
167             /// local decomposition.
168             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
169 
170         public:
171             /// constructor
172             PolyPolygonStrokePrimitive2D(
173                 const basegfx::B2DPolyPolygon& rPolyPolygon,
174                 const attribute::LineAttribute& rLineAttribute,
175                 const attribute::StrokeAttribute& rStrokeAttribute);
176 
177             /// constructor without stroking
178             PolyPolygonStrokePrimitive2D(
179                 const basegfx::B2DPolyPolygon& rPolyPolygon,
180                 const attribute::LineAttribute& rLineAttribute);
181 
182             /// data read access
getB2DPolyPolygon() const183             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
getLineAttribute() const184             const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; }
getStrokeAttribute() const185             const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
186 
187             /// compare operator
188             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
189 
190             /// get range
191             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
192 
193             /// provide unique ID
194             DeclPrimitrive2DIDBlock()
195         };
196     } // end of namespace primitive2d
197 } // end of namespace drawinglayer
198 
199 //////////////////////////////////////////////////////////////////////////////
200 // PolyPolygonStrokeArrowPrimitive2D class
201 
202 namespace drawinglayer
203 {
204     namespace primitive2d
205     {
206         /** PolyPolygonStrokePrimitive2D class
207 
208             This primitive defines a multi-PolygonStrokeArrowPrimitive2D and is
209             just for convenience. The definition is not different from the single
210             defined PolygonStrokeArrowPrimitive2Ds.
211          */
212         class DRAWINGLAYER_DLLPUBLIC PolyPolygonStrokeArrowPrimitive2D : public PolyPolygonStrokePrimitive2D
213         {
214         private:
215             /// geometric definitions for line start and end
216             attribute::LineStartEndAttribute                maStart;
217             attribute::LineStartEndAttribute                maEnd;
218 
219         protected:
220             /// local decomposition.
221             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
222 
223         public:
224             /// constructor
225             PolyPolygonStrokeArrowPrimitive2D(
226                 const basegfx::B2DPolyPolygon& rPolyPolygon,
227                 const attribute::LineAttribute& rLineAttribute,
228                 const attribute::StrokeAttribute& rStrokeAttribute,
229                 const attribute::LineStartEndAttribute& rStart,
230                 const attribute::LineStartEndAttribute& rEnd);
231 
232             /// constructor without stroking
233             PolyPolygonStrokeArrowPrimitive2D(
234                 const basegfx::B2DPolyPolygon& rPolyPolygon,
235                 const attribute::LineAttribute& rLineAttribute,
236                 const attribute::LineStartEndAttribute& rStart,
237                 const attribute::LineStartEndAttribute& rEnd);
238 
239             /// data read access
getStart() const240             const attribute::LineStartEndAttribute& getStart() const { return maStart; }
getEnd() const241             const attribute::LineStartEndAttribute& getEnd() const { return maEnd; }
242 
243             /// compare operator
244             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
245 
246             /// get range
247             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
248 
249             /// provide unique ID
250             DeclPrimitrive2DIDBlock()
251         };
252     } // end of namespace primitive2d
253 } // end of namespace drawinglayer
254 
255 //////////////////////////////////////////////////////////////////////////////
256 // PolyPolygonColorPrimitive2D class
257 
258 namespace drawinglayer
259 {
260     namespace primitive2d
261     {
262         /** PolyPolygonColorPrimitive2D class
263 
264             This primitive defines a PolyPolygon filled with a single color.
265             This is one of the non-decomposable primitives, so a renderer
266             should proccess it.
267          */
268         class DRAWINGLAYER_DLLPUBLIC PolyPolygonColorPrimitive2D : public BasePrimitive2D
269         {
270         private:
271             /// the PolyPolygon geometry
272             basegfx::B2DPolyPolygon                 maPolyPolygon;
273 
274             /// the polygon fill color
275             basegfx::BColor                         maBColor;
276 
277         public:
278             /// constructor
279             PolyPolygonColorPrimitive2D(
280                 const basegfx::B2DPolyPolygon& rPolyPolygon,
281                 const basegfx::BColor& rBColor);
282 
283             /// data read access
getB2DPolyPolygon() const284             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
getBColor() const285             const basegfx::BColor& getBColor() const { return maBColor; }
286 
287             /// compare operator
288             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
289 
290             /// get range
291             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
292 
293             /// provide unique ID
294             DeclPrimitrive2DIDBlock()
295         };
296     } // end of namespace primitive2d
297 } // end of namespace drawinglayer
298 
299 //////////////////////////////////////////////////////////////////////////////
300 // PolyPolygonGradientPrimitive2D class
301 
302 namespace drawinglayer
303 {
304     namespace primitive2d
305     {
306         /** PolyPolygonColorPrimitive2D class
307 
308             This primitive defines a PolyPolygon filled with a gradient. The
309             decomosition will create a MaskPrimitive2D containing a
310             FillGradientPrimitive2D.
311          */
312         class DRAWINGLAYER_DLLPUBLIC PolyPolygonGradientPrimitive2D : public BufferedDecompositionPrimitive2D
313         {
314         private:
315             /// the PolyPolygon geometry
316             basegfx::B2DPolyPolygon                     maPolyPolygon;
317 
318             /// the gradient definition
319             attribute::FillGradientAttribute            maFillGradient;
320 
321         protected:
322             /// local decomposition.
323             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
324 
325         public:
326             /// constructor
327             PolyPolygonGradientPrimitive2D(
328                 const basegfx::B2DPolyPolygon& rPolyPolygon,
329                 const attribute::FillGradientAttribute& rFillGradient);
330 
331             /// data read access
getB2DPolyPolygon() const332             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
getFillGradient() const333             const attribute::FillGradientAttribute& getFillGradient() const { return maFillGradient; }
334 
335             /// compare operator
336             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
337 
338             /// provide unique ID
339             DeclPrimitrive2DIDBlock()
340         };
341     } // end of namespace primitive2d
342 } // end of namespace drawinglayer
343 
344 //////////////////////////////////////////////////////////////////////////////
345 // PolyPolygonHatchPrimitive2D class
346 
347 namespace drawinglayer
348 {
349     namespace primitive2d
350     {
351         /** PolyPolygonHatchPrimitive2D class
352 
353             This primitive defines a PolyPolygon filled with a hatch. The
354             decomosition will create a MaskPrimitive2D containing a
355             FillHatchPrimitive2D.
356          */
357         class DRAWINGLAYER_DLLPUBLIC PolyPolygonHatchPrimitive2D : public BufferedDecompositionPrimitive2D
358         {
359         private:
360             /// the PolyPolygon geometry
361             basegfx::B2DPolyPolygon                     maPolyPolygon;
362 
363             /// the hatch background color (if used)
364             basegfx::BColor                             maBackgroundColor;
365 
366             /// the hatch definition
367             attribute::FillHatchAttribute               maFillHatch;
368 
369         protected:
370             /// local decomposition.
371             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
372 
373         public:
374             /// constructor
375             PolyPolygonHatchPrimitive2D(
376                 const basegfx::B2DPolyPolygon& rPolyPolygon,
377                 const basegfx::BColor& rBackgroundColor,
378                 const attribute::FillHatchAttribute& rFillHatch);
379 
380             /// data read access
getB2DPolyPolygon() const381             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
getBackgroundColor() const382             const basegfx::BColor& getBackgroundColor() const { return maBackgroundColor; }
getFillHatch() const383             const attribute::FillHatchAttribute& getFillHatch() const { return maFillHatch; }
384 
385             /// compare operator
386             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
387 
388             /// provide unique ID
389             DeclPrimitrive2DIDBlock()
390         };
391     } // end of namespace primitive2d
392 } // end of namespace drawinglayer
393 
394 //////////////////////////////////////////////////////////////////////////////
395 // PolyPolygonGraphicPrimitive2D class
396 
397 namespace drawinglayer
398 {
399     namespace primitive2d
400     {
401         /** PolyPolygonGraphicPrimitive2D class
402 
403             This primitive defines a PolyPolygon filled with bitmap data
404             (including transparence). The decomosition will create a MaskPrimitive2D
405             containing a FillGraphicPrimitive2D.
406          */
407         class DRAWINGLAYER_DLLPUBLIC PolyPolygonGraphicPrimitive2D : public BufferedDecompositionPrimitive2D
408         {
409         private:
410             /// the PolyPolygon geometry
411             basegfx::B2DPolyPolygon                     maPolyPolygon;
412 
413             /// the bitmap fill definition (may include tiling)
414             attribute::FillGraphicAttribute             maFillGraphic;
415 
416         protected:
417             /// local decomposition.
418             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
419 
420         public:
421             /// constructor
422             PolyPolygonGraphicPrimitive2D(
423                 const basegfx::B2DPolyPolygon& rPolyPolygon,
424                 const attribute::FillGraphicAttribute& rFillGraphic);
425 
426             /// data read access
getB2DPolyPolygon() const427             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
getFillGraphic() const428             const attribute::FillGraphicAttribute& getFillGraphic() const { return maFillGraphic; }
429 
430             /// compare operator
431             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
432 
433             /// provide unique ID
434             DeclPrimitrive2DIDBlock()
435         };
436     } // end of namespace primitive2d
437 } // end of namespace drawinglayer
438 
439 //////////////////////////////////////////////////////////////////////////////
440 // PolyPolygonSelectionPrimitive2D class
441 
442 namespace drawinglayer
443 {
444     namespace primitive2d
445     {
446         /** PolyPolygonSelectionPrimitive2D class
447 
448             This primitive defines a PolyPolygon which gets filled with a defined color
449             and a defined transparence, but also gets extended ('grown') by the given
450             discrete size (thus being a view-dependent primitive)
451          */
452         class DRAWINGLAYER_DLLPUBLIC PolyPolygonSelectionPrimitive2D : public DiscreteMetricDependentPrimitive2D
453         {
454         private:
455             /// the PolyPolygon geometry
456             basegfx::B2DPolyPolygon                 maPolyPolygon;
457 
458             /// the color
459             basegfx::BColor                         maColor;
460 
461             /// the transparence [0.0 .. 1.0]
462             double                                  mfTransparence;
463 
464             /// the discrete grow size ('pixels'), only posivive values allowed
465             double                                  mfDiscreteGrow;
466 
467             /// bitfield
468             /// draw polygons filled when fill is set
469             bool                                    mbFill : 1;
470 
471         protected:
472             /// local decomposition.
473             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
474 
475         public:
476             /// constructor
477             PolyPolygonSelectionPrimitive2D(
478                 const basegfx::B2DPolyPolygon& rPolyPolygon,
479                 const basegfx::BColor& rColor,
480                 double fTransparence,
481                 double fDiscreteGrow,
482                 bool bFill);
483 
484             /// data read access
getB2DPolyPolygon() const485             const basegfx::B2DPolyPolygon& getB2DPolyPolygon() const { return maPolyPolygon; }
getColor() const486             const basegfx::BColor& getColor() const { return maColor; }
getTransparence() const487             double getTransparence() const { return mfTransparence; }
getDiscreteGrow() const488             double getDiscreteGrow() const { return mfDiscreteGrow; }
getFill() const489             bool getFill() const { return mbFill; }
490 
491             /// compare operator
492             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
493 
494             /// get range
495             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
496 
497             /// provide unique ID
498             DeclPrimitrive2DIDBlock()
499         };
500     } // end of namespace primitive2d
501 } // end of namespace drawinglayer
502 
503 //////////////////////////////////////////////////////////////////////////////
504 
505 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYPOLYGONPRIMITIVE2D_HXX
506 
507 //////////////////////////////////////////////////////////////////////////////
508 // eof
509