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