nss: upgrade to release 3.73
[LibreOffice.git] / include / drawinglayer / primitive2d / polygonprimitive2d.hxx
blobac56461e35b0a7b9724f9be9664984f2a14573d7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
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
40 should process it.
42 class DRAWINGLAYER_DLLPUBLIC PolygonHairlinePrimitive2D final : public BasePrimitive2D
44 private:
45 /// the hairline geometry
46 basegfx::B2DPolygon maPolygon;
48 /// the hairline color
49 basegfx::BColor maBColor;
51 public:
52 /// constructor
53 PolygonHairlinePrimitive2D(const basegfx::B2DPolygon& rPolygon, const basegfx::BColor& rBColor);
55 /// data read access
56 const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; }
57 const basegfx::BColor& getBColor() const { return maBColor; }
59 /// compare operator
60 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
62 /// get range
63 virtual basegfx::B2DRange
64 getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
66 /// provide unique ID
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
82 private:
83 /// the marker hairline geometry
84 basegfx::B2DPolygon maPolygon;
86 /// the two colors
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.
97 virtual void
98 create2DDecomposition(Primitive2DContainer& rContainer,
99 const geometry::ViewInformation2D& rViewInformation) const override;
101 public:
102 /// constructor
103 PolygonMarkerPrimitive2D(const basegfx::B2DPolygon& rPolygon, const basegfx::BColor& rRGBColorA,
104 const basegfx::BColor& rRGBColorB, double fDiscreteDashLength);
106 /// data read access
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; }
112 /// compare operator
113 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
115 /// get range
116 virtual basegfx::B2DRange
117 getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
119 /// Override standard getDecomposition to be view-dependent here
120 virtual void
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
136 private:
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;
146 protected:
147 /// local decomposition.
148 virtual void
149 create2DDecomposition(Primitive2DContainer& rContainer,
150 const geometry::ViewInformation2D& rViewInformation) const override;
152 public:
153 /// constructor
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);
162 /// data read access
163 const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; }
164 const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; }
165 const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
167 /// compare operator
168 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
170 /// get range
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
185 private:
186 /// wave definition
187 double mfWaveWidth;
188 double mfWaveHeight;
190 /// local decomposition.
191 virtual void
192 create2DDecomposition(Primitive2DContainer& rContainer,
193 const geometry::ViewInformation2D& rViewInformation) const override;
195 public:
196 /// constructor
197 PolygonWavePrimitive2D(const basegfx::B2DPolygon& rPolygon,
198 const attribute::LineAttribute& rLineAttribute,
199 const attribute::StrokeAttribute& rStrokeAttribute, double fWaveWidth,
200 double fWaveHeight);
202 /// constructor without stroking
203 PolygonWavePrimitive2D(const basegfx::B2DPolygon& rPolygon,
204 const attribute::LineAttribute& rLineAttribute, double fWaveWidth,
205 double fWaveHeight);
207 /// data read access
208 double getWaveWidth() const { return mfWaveWidth; }
209 double getWaveHeight() const { return mfWaveHeight; }
211 /// compare operator
212 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
214 /// get range
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
230 private:
231 /// geometric definitions for line start and end
232 attribute::LineStartEndAttribute maStart;
233 attribute::LineStartEndAttribute maEnd;
235 /// local decomposition.
236 virtual void
237 create2DDecomposition(Primitive2DContainer& rContainer,
238 const geometry::ViewInformation2D& rViewInformation) const override;
240 public:
241 /// constructor
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);
254 /// data read access
255 const attribute::LineStartEndAttribute& getStart() const { return maStart; }
256 const attribute::LineStartEndAttribute& getEnd() const { return maEnd; }
258 /// compare operator
259 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
261 /// get range
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: */