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 .
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
25 #include <drawinglayer/attribute/lineattribute.hxx>
26 #include <drawinglayer/attribute/strokeattribute.hxx>
27 #include <drawinglayer/attribute/linestartendattribute.hxx>
28 #include <basegfx/matrix/b2dhommatrix.hxx>
29 #include <basegfx/polygon/b2dpolygon.hxx>
30 #include <basegfx/color/bcolor.hxx>
32 namespace drawinglayer::primitive2d
34 /** PolygonHairlinePrimitive2D class
36 This primitive defines a Hairline. Since hairlines are view-dependent,
37 this primitive is view-dependent, too.
39 This is one of the non-decomposable primitives, so a renderer
42 class DRAWINGLAYER_DLLPUBLIC PolygonHairlinePrimitive2D final
: public BasePrimitive2D
45 /// the hairline geometry
46 basegfx::B2DPolygon maPolygon
;
48 /// the hairline color
49 basegfx::BColor maBColor
;
53 PolygonHairlinePrimitive2D(const basegfx::B2DPolygon
& rPolygon
, const basegfx::BColor
& rBColor
);
56 const basegfx::B2DPolygon
& getB2DPolygon() const { return maPolygon
; }
57 const basegfx::BColor
& getBColor() const { return maBColor
; }
60 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
63 virtual basegfx::B2DRange
64 getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
67 virtual sal_uInt32
getPrimitive2DID() const override
;
70 /** PolygonMarkerPrimitive2D class
72 This primitive defines a two-colored marker hairline which is
73 dashed with the given dash length. Since hairlines are view-dependent,
74 this primitive is view-dependent, too.
76 It will be decomposed to the needed PolygonHairlinePrimitive2D if
77 not handled directly by a renderer.
79 class DRAWINGLAYER_DLLPUBLIC PolygonMarkerPrimitive2D final
80 : public BufferedDecompositionPrimitive2D
83 /// the marker hairline geometry
84 basegfx::B2DPolygon maPolygon
;
87 basegfx::BColor maRGBColorA
;
88 basegfx::BColor maRGBColorB
;
90 /// the dash distance in 'pixels'
91 double mfDiscreteDashLength
;
93 /// decomposition is view-dependent, remember last InverseObjectToViewTransformation
94 basegfx::B2DHomMatrix maLastInverseObjectToViewTransformation
;
96 /// local decomposition.
98 create2DDecomposition(Primitive2DContainer
& rContainer
,
99 const geometry::ViewInformation2D
& rViewInformation
) const override
;
103 PolygonMarkerPrimitive2D(const basegfx::B2DPolygon
& rPolygon
, const basegfx::BColor
& rRGBColorA
,
104 const basegfx::BColor
& rRGBColorB
, double fDiscreteDashLength
);
107 const basegfx::B2DPolygon
& getB2DPolygon() const { return maPolygon
; }
108 const basegfx::BColor
& getRGBColorA() const { return maRGBColorA
; }
109 const basegfx::BColor
& getRGBColorB() const { return maRGBColorB
; }
110 double getDiscreteDashLength() const { return mfDiscreteDashLength
; }
113 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
116 virtual basegfx::B2DRange
117 getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
119 /// Override standard getDecomposition to be view-dependent here
121 get2DDecomposition(Primitive2DDecompositionVisitor
& rVisitor
,
122 const geometry::ViewInformation2D
& rViewInformation
) const override
;
124 /// provide unique ID
125 virtual sal_uInt32
getPrimitive2DID() const override
;
128 /** PolygonStrokePrimitive2D class
130 This primitive defines a line with line width, line join, line color
131 and stroke attributes. It will be decomposed dependent on the definition
132 to the needed primitives, e.g. filled PolyPolygons for fat lines.
134 class DRAWINGLAYER_DLLPUBLIC PolygonStrokePrimitive2D
: public BufferedDecompositionPrimitive2D
137 /// the line geometry
138 basegfx::B2DPolygon maPolygon
;
140 /// the line attributes like width, join and color
141 attribute::LineAttribute maLineAttribute
;
143 /// the line stroking (if used)
144 attribute::StrokeAttribute maStrokeAttribute
;
147 /// local decomposition.
149 create2DDecomposition(Primitive2DContainer
& rContainer
,
150 const geometry::ViewInformation2D
& rViewInformation
) const override
;
154 PolygonStrokePrimitive2D(const basegfx::B2DPolygon
& rPolygon
,
155 const attribute::LineAttribute
& rLineAttribute
,
156 const attribute::StrokeAttribute
& rStrokeAttribute
);
158 /// constructor without stroking
159 PolygonStrokePrimitive2D(const basegfx::B2DPolygon
& rPolygon
,
160 const attribute::LineAttribute
& rLineAttribute
);
163 const basegfx::B2DPolygon
& getB2DPolygon() const { return maPolygon
; }
164 const attribute::LineAttribute
& getLineAttribute() const { return maLineAttribute
; }
165 const attribute::StrokeAttribute
& getStrokeAttribute() const { return maStrokeAttribute
; }
168 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
171 virtual basegfx::B2DRange
172 getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
174 /// provide unique ID
175 virtual sal_uInt32
getPrimitive2DID() const override
;
178 /** PolygonWavePrimitive2D class
180 This primitive defines a waveline based on a PolygonStrokePrimitive2D
181 where the wave is defined by wave width and wave length.
183 class PolygonWavePrimitive2D final
: public PolygonStrokePrimitive2D
190 /// local decomposition.
192 create2DDecomposition(Primitive2DContainer
& rContainer
,
193 const geometry::ViewInformation2D
& rViewInformation
) const override
;
197 PolygonWavePrimitive2D(const basegfx::B2DPolygon
& rPolygon
,
198 const attribute::LineAttribute
& rLineAttribute
,
199 const attribute::StrokeAttribute
& rStrokeAttribute
, double fWaveWidth
,
202 /// constructor without stroking
203 PolygonWavePrimitive2D(const basegfx::B2DPolygon
& rPolygon
,
204 const attribute::LineAttribute
& rLineAttribute
, double fWaveWidth
,
208 double getWaveWidth() const { return mfWaveWidth
; }
209 double getWaveHeight() const { return mfWaveHeight
; }
212 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
215 virtual basegfx::B2DRange
216 getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
218 /// provide unique ID
219 virtual sal_uInt32
getPrimitive2DID() const override
;
222 /** PolygonStrokeArrowPrimitive2D class
224 This primitive defines a PolygonStrokePrimitive2D,
225 possibly extended by start and end definitions, which are
226 normally used for arrows.
228 class DRAWINGLAYER_DLLPUBLIC PolygonStrokeArrowPrimitive2D final
: public PolygonStrokePrimitive2D
231 /// geometric definitions for line start and end
232 attribute::LineStartEndAttribute maStart
;
233 attribute::LineStartEndAttribute maEnd
;
235 /// local decomposition.
237 create2DDecomposition(Primitive2DContainer
& rContainer
,
238 const geometry::ViewInformation2D
& rViewInformation
) const override
;
242 PolygonStrokeArrowPrimitive2D(const basegfx::B2DPolygon
& rPolygon
,
243 const attribute::LineAttribute
& rLineAttribute
,
244 const attribute::StrokeAttribute
& rStrokeAttribute
,
245 const attribute::LineStartEndAttribute
& rStart
,
246 const attribute::LineStartEndAttribute
& rEnd
);
248 /// constructor without stroking
249 PolygonStrokeArrowPrimitive2D(const basegfx::B2DPolygon
& rPolygon
,
250 const attribute::LineAttribute
& rLineAttribute
,
251 const attribute::LineStartEndAttribute
& rStart
,
252 const attribute::LineStartEndAttribute
& rEnd
);
255 const attribute::LineStartEndAttribute
& getStart() const { return maStart
; }
256 const attribute::LineStartEndAttribute
& getEnd() const { return maEnd
; }
259 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const override
;
262 virtual basegfx::B2DRange
263 getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
265 /// provide unique ID
266 virtual sal_uInt32
getPrimitive2DID() const override
;
268 } // end of namespace primitive2d::drawinglayer
270 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */