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_HELPLINEPRIMITIVE2D_HXX
29 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_HELPLINEPRIMITIVE2D_HXX
30 
31 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
32 #include <basegfx/color/bcolor.hxx>
33 #include <basegfx/matrix/b2dhommatrix.hxx>
34 
35 //////////////////////////////////////////////////////////////////////////////
36 // HelplinePrimitive2D class
37 
38 namespace drawinglayer
39 {
40 	namespace primitive2d
41 	{
42         /** HelplineStyle2D definition
43 
44             The available styles of Helplines
45         */
46 		enum HelplineStyle2D
47 		{
48 			HELPLINESTYLE2D_POINT,
49 			HELPLINESTYLE2D_LINE
50 		};
51 
52         /** HelplinePrimitive2D class
53 
54             This primitive provides a view-dependent helpline definition. The Helpline
55             is defined by a line equation (Point and vector) and a style. When the style
56             is a line, dependent from Viewport the visible part of that Helpline is
57             constructed. For Point, a cross is constructed. This primitive is highly
58             view-dependent.
59 
60             The visualisation uses the two given colors to create a dashed line with
61             the given dash length.
62          */
63 		class HelplinePrimitive2D : public BufferedDecompositionPrimitive2D
64 		{
65 		private:
66             /// Helpline geometry definition
67 			basegfx::B2DPoint								maPosition;
68 			basegfx::B2DVector								maDirection;
69 			HelplineStyle2D									meStyle;
70 
71             /// Helpline style definition
72 			basegfx::BColor									maRGBColA;
73 			basegfx::BColor									maRGBColB;
74 			double											mfDiscreteDashLength;
75 
76 			/** the last used object to view transformtion and the last Viewport,
77                 used from getDecomposition for decide buffering
78              */
79 			basegfx::B2DHomMatrix							maLastObjectToViewTransformation;
80 			basegfx::B2DRange								maLastViewport;
81 
82 		protected:
83 			/// create local decomposition
84 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
85 
86 		public:
87             /// constructor
88 			HelplinePrimitive2D(
89 				const basegfx::B2DPoint& rPosition,
90 				const basegfx::B2DVector& rDirection,
91 				HelplineStyle2D eStyle,
92 				const basegfx::BColor& rRGBColA,
93 				const basegfx::BColor& aRGBColB,
94 				double fDiscreteDashLength);
95 
96 			/// data read access
97 			const basegfx::B2DPoint& getPosition() const { return maPosition; }
98 			const basegfx::B2DVector& getDirection() const { return maDirection; }
99 			HelplineStyle2D getStyle() const { return meStyle; }
100 			const basegfx::BColor& getRGBColA() const { return maRGBColA; }
101 			const basegfx::BColor& getRGBColB() const { return maRGBColB; }
102 			double getDiscreteDashLength() const { return mfDiscreteDashLength; }
103 
104 			/// compare operator
105 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
106 
107 			/// provide unique ID
108 			DeclPrimitrive2DIDBlock()
109 
110 			/// Overload standard getDecomposition call to be view-dependent here
111 			virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
112 		};
113 	} // end of namespace primitive2d
114 } // end of namespace drawinglayer
115 
116 //////////////////////////////////////////////////////////////////////////////
117 
118 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_HELPLINEPRIMITIVE2D_HXX
119 
120 //////////////////////////////////////////////////////////////////////////////
121 // eof
122