1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
29 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
30 
31 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
32 #include <drawinglayer/attribute/lineattribute.hxx>
33 #include <drawinglayer/attribute/strokeattribute.hxx>
34 #include <drawinglayer/attribute/linestartendattribute.hxx>
35 #include <basegfx/matrix/b2dhommatrix.hxx>
36 #include <basegfx/polygon/b2dpolygon.hxx>
37 #include <basegfx/color/bcolor.hxx>
38 
39 //////////////////////////////////////////////////////////////////////////////
40 // PolygonHairlinePrimitive2D class
41 
42 namespace drawinglayer
43 {
44 	namespace primitive2d
45 	{
46         /** PolygonHairlinePrimitive2D class
47 
48             This primitive defines a Hairline. Since hairlines are view-dependent,
49             this primitive is view-dependent, too.
50 
51             This is one of the non-decomposable primitives, so a renderer
52             should proccess it.
53          */
54 		class PolygonHairlinePrimitive2D : public BasePrimitive2D
55 		{
56 		private:
57             /// the hairline geometry
58 			basegfx::B2DPolygon						maPolygon;
59 
60             /// the hairline color
61 			basegfx::BColor							maBColor;
62 
63 		public:
64             /// constructor
65 			PolygonHairlinePrimitive2D(
66                 const basegfx::B2DPolygon& rPolygon,
67                 const basegfx::BColor& rBColor);
68 
69 			/// data read access
70 			const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; }
71 			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 // PolygonMarkerPrimitive2D class
87 
88 namespace drawinglayer
89 {
90 	namespace primitive2d
91 	{
92         /** PolygonMarkerPrimitive2D class
93 
94             This primitive defines a two-colored marker hairline which is
95             dashed with the given dash length. Since hairlines are view-dependent,
96             this primitive is view-dependent, too.
97 
98             It will be decomposed to the needed PolygonHairlinePrimitive2D if
99             not handled directly by a renderer.
100          */
101 		class PolygonMarkerPrimitive2D : public BufferedDecompositionPrimitive2D
102 		{
103 		private:
104             /// the marker hairline geometry
105 			basegfx::B2DPolygon						maPolygon;
106 
107             /// the two colors
108 			basegfx::BColor							maRGBColorA;
109 			basegfx::BColor							maRGBColorB;
110 
111             /// the dash distance in 'pixels'
112 			double									mfDiscreteDashLength;
113 
114 			/// decomposition is view-dependent, remember last InverseObjectToViewTransformation
115 			basegfx::B2DHomMatrix					maLastInverseObjectToViewTransformation;
116 
117 		protected:
118 			/// local decomposition.
119 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
120 
121 		public:
122             /// constructor
123 			PolygonMarkerPrimitive2D(
124 				const basegfx::B2DPolygon& rPolygon,
125 				const basegfx::BColor& rRGBColorA,
126 				const basegfx::BColor& rRGBColorB,
127 				double fDiscreteDashLength);
128 
129 			/// data read access
130 			const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; }
131 			const basegfx::BColor& getRGBColorA() const { return maRGBColorA; }
132 			const basegfx::BColor& getRGBColorB() const { return maRGBColorB; }
133 			double getDiscreteDashLength() const { return mfDiscreteDashLength; }
134 
135 			/// compare operator
136 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
137 
138 			/// get range
139 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
140 
141 			/// get local decomposition. Overloaded since this decomposition is view-dependent
142 			virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
143 
144 			/// provide unique ID
145 			DeclPrimitrive2DIDBlock()
146 		};
147 	} // end of namespace primitive2d
148 } // end of namespace drawinglayer
149 
150 //////////////////////////////////////////////////////////////////////////////
151 // PolygonStrokePrimitive2D class
152 
153 namespace drawinglayer
154 {
155 	namespace primitive2d
156 	{
157         /** PolygonStrokePrimitive2D class
158 
159             This primitive defines a line with line width, line join, line color
160             and stroke attributes. It will be decomposed dependent on the definition
161             to the needed primitives, e.g. filled PolyPolygons for fat lines.
162          */
163 		class PolygonStrokePrimitive2D : public BufferedDecompositionPrimitive2D
164 		{
165 		private:
166             /// the line geometry
167 			basegfx::B2DPolygon						maPolygon;
168 
169             /// the line attributes like width, join and color
170 			attribute::LineAttribute				maLineAttribute;
171 
172             /// the line stroking (if used)
173 			attribute::StrokeAttribute				maStrokeAttribute;
174 
175 		protected:
176 			/// local decomposition.
177 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
178 
179 		public:
180             /// constructor
181 			PolygonStrokePrimitive2D(
182 				const basegfx::B2DPolygon& rPolygon,
183                 const attribute::LineAttribute& rLineAttribute,
184 				const attribute::StrokeAttribute& rStrokeAttribute);
185 
186             /// constructor without stroking
187 			PolygonStrokePrimitive2D(
188 				const basegfx::B2DPolygon& rPolygon,
189                 const attribute::LineAttribute& rLineAttribute);
190 
191 			/// data read access
192 			const basegfx::B2DPolygon& getB2DPolygon() const { return maPolygon; }
193 			const attribute::LineAttribute& getLineAttribute() const { return maLineAttribute; }
194 			const attribute::StrokeAttribute& getStrokeAttribute() const { return maStrokeAttribute; }
195 
196 			/// compare operator
197 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
198 
199 			/// get range
200 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
201 
202 			/// provide unique ID
203 			DeclPrimitrive2DIDBlock()
204 		};
205 	} // end of namespace primitive2d
206 } // end of namespace drawinglayer
207 
208 //////////////////////////////////////////////////////////////////////////////
209 // PolygonWavePrimitive2D class
210 
211 namespace drawinglayer
212 {
213 	namespace primitive2d
214 	{
215         /** PolygonWavePrimitive2D class
216 
217             This primitive defines a waveline based on a PolygonStrokePrimitive2D
218             where the wave is defined by wave width and wave length.
219          */
220 		class PolygonWavePrimitive2D : public PolygonStrokePrimitive2D
221 		{
222 		private:
223             /// wave definition
224 			double									mfWaveWidth;
225 			double									mfWaveHeight;
226 
227 		protected:
228 			/// local decomposition.
229 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
230 
231 		public:
232             /// constructor
233 			PolygonWavePrimitive2D(
234 				const basegfx::B2DPolygon& rPolygon,
235                 const attribute::LineAttribute& rLineAttribute,
236 				const attribute::StrokeAttribute& rStrokeAttribute,
237 				double fWaveWidth,
238 				double fWaveHeight);
239 
240             /// constructor without stroking
241 			PolygonWavePrimitive2D(
242 				const basegfx::B2DPolygon& rPolygon,
243                 const attribute::LineAttribute& rLineAttribute,
244 				double fWaveWidth,
245 				double fWaveHeight);
246 
247 			/// data read access
248 			double getWaveWidth() const { return mfWaveWidth; }
249 			double getWaveHeight() const { return mfWaveHeight; }
250 
251 			/// compare operator
252 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
253 
254 			/// get range
255 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
256 
257 			/// provide unique ID
258 			DeclPrimitrive2DIDBlock()
259 		};
260 	} // end of namespace primitive2d
261 } // end of namespace drawinglayer
262 
263 //////////////////////////////////////////////////////////////////////////////
264 // PolygonStrokeArrowPrimitive2D class
265 
266 namespace drawinglayer
267 {
268 	namespace primitive2d
269 	{
270         /** PolygonStrokeArrowPrimitive2D class
271 
272             This primitive defines a PolygonStrokePrimitive2D which is extended
273             eventually by start and end definitions which are normally used for
274             arrows.
275          */
276 		class PolygonStrokeArrowPrimitive2D : public PolygonStrokePrimitive2D
277 		{
278 		private:
279             /// geometric definitions for line start and end
280 			attribute::LineStartEndAttribute				maStart;
281 			attribute::LineStartEndAttribute				maEnd;
282 
283 		protected:
284 			/// local decomposition.
285 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
286 
287 		public:
288             /// constructor
289 			PolygonStrokeArrowPrimitive2D(
290 				const basegfx::B2DPolygon& rPolygon,
291                 const attribute::LineAttribute& rLineAttribute,
292 				const attribute::StrokeAttribute& rStrokeAttribute,
293 				const attribute::LineStartEndAttribute& rStart,
294 				const attribute::LineStartEndAttribute& rEnd);
295 
296             /// constructor without stroking
297 			PolygonStrokeArrowPrimitive2D(
298 				const basegfx::B2DPolygon& rPolygon,
299                 const attribute::LineAttribute& rLineAttribute,
300 				const attribute::LineStartEndAttribute& rStart,
301 				const attribute::LineStartEndAttribute& rEnd);
302 
303 			/// data read access
304 			const attribute::LineStartEndAttribute& getStart() const { return maStart; }
305 			const attribute::LineStartEndAttribute& getEnd() const { return maEnd; }
306 
307 			/// compare operator
308 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
309 
310 			/// get range
311 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
312 
313 			/// provide unique ID
314 			DeclPrimitrive2DIDBlock()
315 		};
316 	} // end of namespace primitive2d
317 } // end of namespace drawinglayer
318 
319 //////////////////////////////////////////////////////////////////////////////
320 
321 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_POLYGONPRIMITIVE2D_HXX
322 
323 //////////////////////////////////////////////////////////////////////////////
324 // eof
325