1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski 
24*b1cdbd2cSJim Jagielski #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX
25*b1cdbd2cSJim Jagielski #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX
26*b1cdbd2cSJim Jagielski 
27*b1cdbd2cSJim Jagielski #include <drawinglayer/drawinglayerdllapi.h>
28*b1cdbd2cSJim Jagielski #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
29*b1cdbd2cSJim Jagielski #include <basegfx/matrix/b2dhommatrix.hxx>
30*b1cdbd2cSJim Jagielski #include <basegfx/color/bcolor.hxx>
31*b1cdbd2cSJim Jagielski #include <vcl/bitmapex.hxx>
32*b1cdbd2cSJim Jagielski 
33*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
34*b1cdbd2cSJim Jagielski // GridPrimitive2D class
35*b1cdbd2cSJim Jagielski 
36*b1cdbd2cSJim Jagielski namespace drawinglayer
37*b1cdbd2cSJim Jagielski {
38*b1cdbd2cSJim Jagielski 	namespace primitive2d
39*b1cdbd2cSJim Jagielski 	{
40*b1cdbd2cSJim Jagielski         /** GridPrimitive2D class
41*b1cdbd2cSJim Jagielski 
42*b1cdbd2cSJim Jagielski             This primitive is specialized to Grid visualisation. The graphic definition
43*b1cdbd2cSJim Jagielski             (Transform) contains the whole grid area, but will of course be combined
44*b1cdbd2cSJim Jagielski             with the visible area (Viewport) when decomposed. Also a reolution-dependent
45*b1cdbd2cSJim Jagielski             point reduction is used to not create too much grid visualisation data. This
46*b1cdbd2cSJim Jagielski             makes this primitive highly view-dependent and it dynamically buffers
47*b1cdbd2cSJim Jagielski             the last decomposition dependent from the Viewport used.
48*b1cdbd2cSJim Jagielski          */
49*b1cdbd2cSJim Jagielski 		class DRAWINGLAYER_DLLPUBLIC GridPrimitive2D : public BufferedDecompositionPrimitive2D
50*b1cdbd2cSJim Jagielski 		{
51*b1cdbd2cSJim Jagielski 		private:
52*b1cdbd2cSJim Jagielski             /// The geometry definition for the grid area
53*b1cdbd2cSJim Jagielski 			basegfx::B2DHomMatrix							maTransform;
54*b1cdbd2cSJim Jagielski 
55*b1cdbd2cSJim Jagielski             /// grid layout definitions
56*b1cdbd2cSJim Jagielski 			double											mfWidth;
57*b1cdbd2cSJim Jagielski 			double											mfHeight;
58*b1cdbd2cSJim Jagielski 			double											mfSmallestViewDistance;
59*b1cdbd2cSJim Jagielski 			double											mfSmallestSubdivisionViewDistance;
60*b1cdbd2cSJim Jagielski 			sal_uInt32										mnSubdivisionsX;
61*b1cdbd2cSJim Jagielski 			sal_uInt32										mnSubdivisionsY;
62*b1cdbd2cSJim Jagielski 
63*b1cdbd2cSJim Jagielski             /// Grid color for single-pixel grid points
64*b1cdbd2cSJim Jagielski 			basegfx::BColor									maBColor;
65*b1cdbd2cSJim Jagielski 
66*b1cdbd2cSJim Jagielski             /// The Bitmap (with transparence) for grid cross points
67*b1cdbd2cSJim Jagielski 			BitmapEx										maCrossMarker;
68*b1cdbd2cSJim Jagielski 
69*b1cdbd2cSJim Jagielski 			/** the last used object to view transformtion and the last Viewport,
70*b1cdbd2cSJim Jagielski                 used from getDecomposition for decide buffering
71*b1cdbd2cSJim Jagielski              */
72*b1cdbd2cSJim Jagielski 			basegfx::B2DHomMatrix							maLastObjectToViewTransformation;
73*b1cdbd2cSJim Jagielski 			basegfx::B2DRange								maLastViewport;
74*b1cdbd2cSJim Jagielski 
75*b1cdbd2cSJim Jagielski 		protected:
76*b1cdbd2cSJim Jagielski 			/// create local decomposition
77*b1cdbd2cSJim Jagielski 			virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
78*b1cdbd2cSJim Jagielski 
79*b1cdbd2cSJim Jagielski 		public:
80*b1cdbd2cSJim Jagielski             /// constructor
81*b1cdbd2cSJim Jagielski 			GridPrimitive2D(
82*b1cdbd2cSJim Jagielski 				const basegfx::B2DHomMatrix& rTransform,
83*b1cdbd2cSJim Jagielski 				double fWidth,
84*b1cdbd2cSJim Jagielski 				double fHeight,
85*b1cdbd2cSJim Jagielski 				double fSmallestViewDistance,
86*b1cdbd2cSJim Jagielski 				double fSmallestSubdivisionViewDistance,
87*b1cdbd2cSJim Jagielski 				sal_uInt32 nSubdivisionsX,
88*b1cdbd2cSJim Jagielski 				sal_uInt32 nSubdivisionsY,
89*b1cdbd2cSJim Jagielski 				const basegfx::BColor& rBColor,
90*b1cdbd2cSJim Jagielski 				const BitmapEx& rCrossMarker);
91*b1cdbd2cSJim Jagielski 
92*b1cdbd2cSJim Jagielski 			/// data read access
getTransform() const93*b1cdbd2cSJim Jagielski 			const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
getWidth() const94*b1cdbd2cSJim Jagielski 			double getWidth() const { return mfWidth; }
getHeight() const95*b1cdbd2cSJim Jagielski 			double getHeight() const { return mfHeight; }
getSmallestViewDistance() const96*b1cdbd2cSJim Jagielski 			double getSmallestViewDistance() const { return mfSmallestViewDistance; }
getSmallestSubdivisionViewDistance() const97*b1cdbd2cSJim Jagielski 			double getSmallestSubdivisionViewDistance() const { return mfSmallestSubdivisionViewDistance; }
getSubdivisionsX() const98*b1cdbd2cSJim Jagielski 			sal_uInt32 getSubdivisionsX() const { return mnSubdivisionsX; }
getSubdivisionsY() const99*b1cdbd2cSJim Jagielski 			sal_uInt32 getSubdivisionsY() const { return mnSubdivisionsY; }
getBColor() const100*b1cdbd2cSJim Jagielski 			const basegfx::BColor& getBColor() const { return maBColor; }
getCrossMarker() const101*b1cdbd2cSJim Jagielski 			const BitmapEx& getCrossMarker() const { return maCrossMarker; }
102*b1cdbd2cSJim Jagielski 
103*b1cdbd2cSJim Jagielski 			/// compare operator
104*b1cdbd2cSJim Jagielski 			virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
105*b1cdbd2cSJim Jagielski 
106*b1cdbd2cSJim Jagielski 			/// get 2d range
107*b1cdbd2cSJim Jagielski 			virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
108*b1cdbd2cSJim Jagielski 
109*b1cdbd2cSJim Jagielski 			/// provide unique ID
110*b1cdbd2cSJim Jagielski 			DeclPrimitrive2DIDBlock()
111*b1cdbd2cSJim Jagielski 
112*b1cdbd2cSJim Jagielski 			/// Overload standard getDecomposition call to be view-dependent here
113*b1cdbd2cSJim Jagielski 			virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
114*b1cdbd2cSJim Jagielski 		};
115*b1cdbd2cSJim Jagielski 	} // end of namespace primitive2d
116*b1cdbd2cSJim Jagielski } // end of namespace drawinglayer
117*b1cdbd2cSJim Jagielski 
118*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
119*b1cdbd2cSJim Jagielski 
120*b1cdbd2cSJim Jagielski #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX
121*b1cdbd2cSJim Jagielski 
122*b1cdbd2cSJim Jagielski //////////////////////////////////////////////////////////////////////////////
123*b1cdbd2cSJim Jagielski // eof
124