1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 #include <drawinglayer/attribute/lineattribute.hxx>
27 #include <drawinglayer/attribute/strokeattribute.hxx>
28 #include <drawinglayer/attribute/linestartendattribute.hxx>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
30 #include <basegfx/polygon/b2dpolygon.hxx>
31 #include <basegfx/color/bcolor.hxx>
34 // PolygonHairlinePrimitive2D class
36 namespace drawinglayer
40 /** PolygonHairlinePrimitive2D class
42 This primitive defines a Hairline. Since hairlines are view-dependent,
43 this primitive is view-dependent, too.
45 This is one of the non-decomposable primitives, so a renderer
48 class DRAWINGLAYER_DLLPUBLIC PolygonHairlinePrimitive2D
: public BasePrimitive2D
51 /// the hairline geometry
52 basegfx::B2DPolygon maPolygon
;
54 /// the hairline color
55 basegfx::BColor maBColor
;
59 PolygonHairlinePrimitive2D(
60 const basegfx::B2DPolygon
& rPolygon
,
61 const basegfx::BColor
& rBColor
);
64 const basegfx::B2DPolygon
& getB2DPolygon() const { return maPolygon
; }
65 const basegfx::BColor
& getBColor() const { return maBColor
; }
68 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
71 virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
74 DeclPrimitive2DIDBlock()
76 } // end of namespace primitive2d
77 } // end of namespace drawinglayer
80 // PolygonMarkerPrimitive2D class
82 namespace drawinglayer
86 /** PolygonMarkerPrimitive2D class
88 This primitive defines a two-colored marker hairline which is
89 dashed with the given dash length. Since hairlines are view-dependent,
90 this primitive is view-dependent, too.
92 It will be decomposed to the needed PolygonHairlinePrimitive2D if
93 not handled directly by a renderer.
95 class DRAWINGLAYER_DLLPUBLIC PolygonMarkerPrimitive2D
: public BufferedDecompositionPrimitive2D
98 /// the marker hairline geometry
99 basegfx::B2DPolygon maPolygon
;
102 basegfx::BColor maRGBColorA
;
103 basegfx::BColor maRGBColorB
;
105 /// the dash distance in 'pixels'
106 double mfDiscreteDashLength
;
108 /// decomposition is view-dependent, remember last InverseObjectToViewTransformation
109 basegfx::B2DHomMatrix maLastInverseObjectToViewTransformation
;
112 /// local decomposition.
113 virtual void create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
117 PolygonMarkerPrimitive2D(
118 const basegfx::B2DPolygon
& rPolygon
,
119 const basegfx::BColor
& rRGBColorA
,
120 const basegfx::BColor
& rRGBColorB
,
121 double fDiscreteDashLength
);
124 const basegfx::B2DPolygon
& getB2DPolygon() const { return maPolygon
; }
125 const basegfx::BColor
& getRGBColorA() const { return maRGBColorA
; }
126 const basegfx::BColor
& getRGBColorB() const { return maRGBColorB
; }
127 double getDiscreteDashLength() const { return mfDiscreteDashLength
; }
130 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
133 virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
135 /// Override standard getDecomposition to be view-dependent here
136 virtual void get2DDecomposition(Primitive2DDecompositionVisitor
& rVisitor
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
138 /// provide unique ID
139 DeclPrimitive2DIDBlock()
141 } // end of namespace primitive2d
142 } // end of namespace drawinglayer
145 // PolygonStrokePrimitive2D class
147 namespace drawinglayer
149 namespace primitive2d
151 /** PolygonStrokePrimitive2D class
153 This primitive defines a line with line width, line join, line color
154 and stroke attributes. It will be decomposed dependent on the definition
155 to the needed primitives, e.g. filled PolyPolygons for fat lines.
157 class DRAWINGLAYER_DLLPUBLIC PolygonStrokePrimitive2D
: public BufferedDecompositionPrimitive2D
160 /// the line geometry
161 basegfx::B2DPolygon maPolygon
;
163 /// the line attributes like width, join and color
164 attribute::LineAttribute maLineAttribute
;
166 /// the line stroking (if used)
167 attribute::StrokeAttribute maStrokeAttribute
;
170 /// local decomposition.
171 virtual void create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
175 PolygonStrokePrimitive2D(
176 const basegfx::B2DPolygon
& rPolygon
,
177 const attribute::LineAttribute
& rLineAttribute
,
178 const attribute::StrokeAttribute
& rStrokeAttribute
);
180 /// constructor without stroking
181 PolygonStrokePrimitive2D(
182 const basegfx::B2DPolygon
& rPolygon
,
183 const attribute::LineAttribute
& rLineAttribute
);
186 const basegfx::B2DPolygon
& getB2DPolygon() const { return maPolygon
; }
187 const attribute::LineAttribute
& getLineAttribute() const { return maLineAttribute
; }
188 const attribute::StrokeAttribute
& getStrokeAttribute() const { return maStrokeAttribute
; }
191 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
194 virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
196 /// provide unique ID
197 DeclPrimitive2DIDBlock()
199 } // end of namespace primitive2d
200 } // end of namespace drawinglayer
203 // PolygonWavePrimitive2D class
205 namespace drawinglayer
207 namespace primitive2d
209 /** PolygonWavePrimitive2D class
211 This primitive defines a waveline based on a PolygonStrokePrimitive2D
212 where the wave is defined by wave width and wave length.
214 class DRAWINGLAYER_DLLPUBLIC PolygonWavePrimitive2D
: public PolygonStrokePrimitive2D
222 /// local decomposition.
223 virtual void create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
227 PolygonWavePrimitive2D(
228 const basegfx::B2DPolygon
& rPolygon
,
229 const attribute::LineAttribute
& rLineAttribute
,
230 const attribute::StrokeAttribute
& rStrokeAttribute
,
234 /// constructor without stroking
235 PolygonWavePrimitive2D(
236 const basegfx::B2DPolygon
& rPolygon
,
237 const attribute::LineAttribute
& rLineAttribute
,
242 double getWaveWidth() const { return mfWaveWidth
; }
243 double getWaveHeight() const { return mfWaveHeight
; }
246 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
249 virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
251 /// provide unique ID
252 DeclPrimitive2DIDBlock()
254 } // end of namespace primitive2d
255 } // end of namespace drawinglayer
258 // PolygonStrokeArrowPrimitive2D class
260 namespace drawinglayer
262 namespace primitive2d
264 /** PolygonStrokeArrowPrimitive2D class
266 This primitive defines a PolygonStrokePrimitive2D,
267 possibly extended by start and end definitions, which are
268 normally used for arrows.
270 class DRAWINGLAYER_DLLPUBLIC PolygonStrokeArrowPrimitive2D
: public PolygonStrokePrimitive2D
273 /// geometric definitions for line start and end
274 attribute::LineStartEndAttribute maStart
;
275 attribute::LineStartEndAttribute maEnd
;
278 /// local decomposition.
279 virtual void create2DDecomposition(Primitive2DContainer
& rContainer
, const geometry::ViewInformation2D
& rViewInformation
) const override
;
283 PolygonStrokeArrowPrimitive2D(
284 const basegfx::B2DPolygon
& rPolygon
,
285 const attribute::LineAttribute
& rLineAttribute
,
286 const attribute::StrokeAttribute
& rStrokeAttribute
,
287 const attribute::LineStartEndAttribute
& rStart
,
288 const attribute::LineStartEndAttribute
& rEnd
);
290 /// constructor without stroking
291 PolygonStrokeArrowPrimitive2D(
292 const basegfx::B2DPolygon
& rPolygon
,
293 const attribute::LineAttribute
& rLineAttribute
,
294 const attribute::LineStartEndAttribute
& rStart
,
295 const attribute::LineStartEndAttribute
& rEnd
);
298 const attribute::LineStartEndAttribute
& getStart() const { return maStart
; }
299 const attribute::LineStartEndAttribute
& getEnd() const { return maEnd
; }
302 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
305 virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
307 /// provide unique ID
308 DeclPrimitive2DIDBlock()
310 } // end of namespace primitive2d
311 } // end of namespace drawinglayer
314 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
316 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */