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_POLYGONPRIMITIVE2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
29 #include <drawinglayer/attribute/lineattribute.hxx>
30 #include <drawinglayer/attribute/strokeattribute.hxx>
31 #include <drawinglayer/attribute/linestartendattribute.hxx>
32 #include <basegfx/matrix/b2dhommatrix.hxx>
33 #include <basegfx/polygon/b2dpolygon.hxx>
34 #include <basegfx/color/bcolor.hxx>
35 
36 //////////////////////////////////////////////////////////////////////////////
37 // PolygonHairlinePrimitive2D class
38 
39 namespace drawinglayer
40 {
41 	namespace primitive2d
42 	{
43         /** PolygonHairlinePrimitive2D class
44 
45             This primitive defines a Hairline. Since hairlines are view-dependent,
46             this primitive is view-dependent, too.
47 
48             This is one of the non-decomposable primitives, so a renderer
49             should process it.
50          */
51 		class DRAWINGLAYER_DLLPUBLIC PolygonHairlinePrimitive2D : public BasePrimitive2D
52 		{
53 		private:
54             /// the hairline geometry
55 			basegfx::B2DPolygon						maPolygon;
56 
57             /// the hairline color
58 			basegfx::BColor							maBColor;
59 
60 		public:
61             /// constructor
62 			PolygonHairlinePrimitive2D(
63                 const basegfx::B2DPolygon& rPolygon,
64                 const basegfx::BColor& rBColor);
65 
66 			/// data read access
getB2DPolygon() const67 			const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; }
getBColor() const68 			const basegfx::BColor& getBColor() const { return maBColor; }
69 
70 			/// compare operator
71 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
72 
73 			/// get range
74 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
75 
76 			/// provide unique ID
77 			DeclPrimitrive2DIDBlock()
78 		};
79 	} // end of namespace primitive2d
80 } // end of namespace drawinglayer
81 
82 //////////////////////////////////////////////////////////////////////////////
83 // PolygonMarkerPrimitive2D class
84 
85 namespace drawinglayer
86 {
87 	namespace primitive2d
88 	{
89         /** PolygonMarkerPrimitive2D class
90 
91             This primitive defines a two-colored marker hairline which is
92             dashed with the given dash length. Since hairlines are view-dependent,
93             this primitive is view-dependent, too.
94 
95             It will be decomposed to the needed PolygonHairlinePrimitive2D if
96             not handled directly by a renderer.
97          */
98 		class DRAWINGLAYER_DLLPUBLIC PolygonMarkerPrimitive2D : public BufferedDecompositionPrimitive2D
99 		{
100 		private:
101             /// the marker hairline geometry
102 			basegfx::B2DPolygon						maPolygon;
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 			/// decomposition is view-dependent, remember last InverseObjectToViewTransformation
112 			basegfx::B2DHomMatrix					maLastInverseObjectToViewTransformation;
113 
114 		protected:
115 			/// local decomposition.
116 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
117 
118 		public:
119             /// constructor
120 			PolygonMarkerPrimitive2D(
121 				const basegfx::B2DPolygon& rPolygon,
122 				const basegfx::BColor& rRGBColorA,
123 				const basegfx::BColor& rRGBColorB,
124 				double fDiscreteDashLength);
125 
126 			/// data read access
getB2DPolygon() const127 			const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; }
getRGBColorA() const128 			const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
getRGBColorB() const129 			const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
getDiscreteDashLength() const130 			double getDiscreteDashLength() const { return mfDiscreteDashLength; }
131 
132 			/// compare operator
133 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
134 
135 			/// get range
136 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
137 
138 			/// get local decomposition. Overloaded since this decomposition is view-dependent
139 			virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
140 
141 			/// provide unique ID
142 			DeclPrimitrive2DIDBlock()
143 		};
144 	} // end of namespace primitive2d
145 } // end of namespace drawinglayer
146 
147 //////////////////////////////////////////////////////////////////////////////
148 // PolygonStrokePrimitive2D class
149 
150 namespace drawinglayer
151 {
152 	namespace primitive2d
153 	{
154         /** PolygonStrokePrimitive2D class
155 
156             This primitive defines a line with line width, line join, line color
157             and stroke attributes. It will be decomposed dependent on the definition
158             to the needed primitives, e.g. filled PolyPolygons for fat lines.
159          */
160 		class DRAWINGLAYER_DLLPUBLIC PolygonStrokePrimitive2D : public BufferedDecompositionPrimitive2D
161 		{
162 		private:
163             /// the line geometry
164 			basegfx::B2DPolygon						maPolygon;
165 
166             /// the line attributes like width, join and color
167 			attribute::LineAttribute				maLineAttribute;
168 
169             /// the line stroking (if used)
170 			attribute::StrokeAttribute				maStrokeAttribute;
171 
172 		protected:
173 			/// local decomposition.
174 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
175 
176 		public:
177             /// constructor
178 			PolygonStrokePrimitive2D(
179 				const basegfx::B2DPolygon& rPolygon,
180                 const attribute::LineAttribute& rLineAttribute,
181 				const attribute::StrokeAttribute& rStrokeAttribute);
182 
183             /// constructor without stroking
184 			PolygonStrokePrimitive2D(
185 				const basegfx::B2DPolygon& rPolygon,
186                 const attribute::LineAttribute& rLineAttribute);
187 
188 			/// data read access
getB2DPolygon() const189 			const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; }
getLineAttribute() const190 			const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; }
getStrokeAttribute() const191 			const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
192 
193 			/// compare operator
194 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
195 
196 			/// get range
197 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
198 
199 			/// provide unique ID
200 			DeclPrimitrive2DIDBlock()
201 		};
202 	} // end of namespace primitive2d
203 } // end of namespace drawinglayer
204 
205 //////////////////////////////////////////////////////////////////////////////
206 // PolygonWavePrimitive2D class
207 
208 namespace drawinglayer
209 {
210 	namespace primitive2d
211 	{
212         /** PolygonWavePrimitive2D class
213 
214             This primitive defines a waveline based on a PolygonStrokePrimitive2D
215             where the wave is defined by wave width and wave length.
216          */
217 		class DRAWINGLAYER_DLLPUBLIC PolygonWavePrimitive2D : public PolygonStrokePrimitive2D
218 		{
219 		private:
220             /// wave definition
221 			double									mfWaveWidth;
222 			double									mfWaveHeight;
223 
224 		protected:
225 			/// local decomposition.
226 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
227 
228 		public:
229             /// constructor
230 			PolygonWavePrimitive2D(
231 				const basegfx::B2DPolygon& rPolygon,
232                 const attribute::LineAttribute& rLineAttribute,
233 				const attribute::StrokeAttribute& rStrokeAttribute,
234 				double fWaveWidth,
235 				double fWaveHeight);
236 
237             /// constructor without stroking
238 			PolygonWavePrimitive2D(
239 				const basegfx::B2DPolygon& rPolygon,
240                 const attribute::LineAttribute& rLineAttribute,
241 				double fWaveWidth,
242 				double fWaveHeight);
243 
244 			/// data read access
getWaveWidth() const245 			double getWaveWidth() const { return mfWaveWidth; }
getWaveHeight() const246 			double getWaveHeight() const { return mfWaveHeight; }
247 
248 			/// compare operator
249 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
250 
251 			/// get range
252 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
253 
254 			/// provide unique ID
255 			DeclPrimitrive2DIDBlock()
256 		};
257 	} // end of namespace primitive2d
258 } // end of namespace drawinglayer
259 
260 //////////////////////////////////////////////////////////////////////////////
261 // PolygonStrokeArrowPrimitive2D class
262 
263 namespace drawinglayer
264 {
265 	namespace primitive2d
266 	{
267         /** PolygonStrokeArrowPrimitive2D class
268 
269             This primitive defines a PolygonStrokePrimitive2D which is extended
270             eventually by start and end definitions which are normally used for
271             arrows.
272          */
273 		class DRAWINGLAYER_DLLPUBLIC PolygonStrokeArrowPrimitive2D : public PolygonStrokePrimitive2D
274 		{
275 		private:
276             /// geometric definitions for line start and end
277 			attribute::LineStartEndAttribute				maStart;
278 			attribute::LineStartEndAttribute				maEnd;
279 
280 		protected:
281 			/// local decomposition.
282 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
283 
284 		public:
285             /// constructor
286 			PolygonStrokeArrowPrimitive2D(
287 				const basegfx::B2DPolygon& rPolygon,
288                 const attribute::LineAttribute& rLineAttribute,
289 				const attribute::StrokeAttribute& rStrokeAttribute,
290 				const attribute::LineStartEndAttribute& rStart,
291 				const attribute::LineStartEndAttribute& rEnd);
292 
293             /// constructor without stroking
294 			PolygonStrokeArrowPrimitive2D(
295 				const basegfx::B2DPolygon& rPolygon,
296                 const attribute::LineAttribute& rLineAttribute,
297 				const attribute::LineStartEndAttribute& rStart,
298 				const attribute::LineStartEndAttribute& rEnd);
299 
300 			/// data read access
getStart() const301 			const attribute::LineStartEndAttribute& getStart() const { return maStart; }
getEnd() const302 			const attribute::LineStartEndAttribute& getEnd() const { return maEnd; }
303 
304 			/// compare operator
305 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
306 
307 			/// get range
308 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
309 
310 			/// provide unique ID
311 			DeclPrimitrive2DIDBlock()
312 		};
313 	} // end of namespace primitive2d
314 } // end of namespace drawinglayer
315 
316 //////////////////////////////////////////////////////////////////////////////
317 
318 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
319 
320 //////////////////////////////////////////////////////////////////////////////
321 // eof
322