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_GRIDPRIMITIVE2D_HXX 25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX 26 27 #include <drawinglayer/drawinglayerdllapi.h> 28 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 29 #include <basegfx/matrix/b2dhommatrix.hxx> 30 #include <basegfx/color/bcolor.hxx> 31 #include <vcl/bitmapex.hxx> 32 33 ////////////////////////////////////////////////////////////////////////////// 34 // GridPrimitive2D class 35 36 namespace drawinglayer 37 { 38 namespace primitive2d 39 { 40 /** GridPrimitive2D class 41 42 This primitive is specialized to Grid visualisation. The graphic definition 43 (Transform) contains the whole grid area, but will of course be combined 44 with the visible area (Viewport) when decomposed. Also a reolution-dependent 45 point reduction is used to not create too much grid visualisation data. This 46 makes this primitive highly view-dependent and it dynamically buffers 47 the last decomposition dependent from the Viewport used. 48 */ 49 class DRAWINGLAYER_DLLPUBLIC GridPrimitive2D : public BufferedDecompositionPrimitive2D 50 { 51 private: 52 /// The geometry definition for the grid area 53 basegfx::B2DHomMatrix maTransform; 54 55 /// grid layout definitions 56 double mfWidth; 57 double mfHeight; 58 double mfSmallestViewDistance; 59 double mfSmallestSubdivisionViewDistance; 60 sal_uInt32 mnSubdivisionsX; 61 sal_uInt32 mnSubdivisionsY; 62 63 /// Grid color for single-pixel grid points 64 basegfx::BColor maBColor; 65 66 /// The Bitmap (with transparence) for grid cross points 67 BitmapEx maCrossMarker; 68 69 /** the last used object to view transformtion and the last Viewport, 70 used from getDecomposition for decide buffering 71 */ 72 basegfx::B2DHomMatrix maLastObjectToViewTransformation; 73 basegfx::B2DRange maLastViewport; 74 75 protected: 76 /// create local decomposition 77 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 78 79 public: 80 /// constructor 81 GridPrimitive2D( 82 const basegfx::B2DHomMatrix& rTransform, 83 double fWidth, 84 double fHeight, 85 double fSmallestViewDistance, 86 double fSmallestSubdivisionViewDistance, 87 sal_uInt32 nSubdivisionsX, 88 sal_uInt32 nSubdivisionsY, 89 const basegfx::BColor& rBColor, 90 const BitmapEx& rCrossMarker); 91 92 /// data read access getTransform() const93 const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } getWidth() const94 double getWidth() const { return mfWidth; } getHeight() const95 double getHeight() const { return mfHeight; } getSmallestViewDistance() const96 double getSmallestViewDistance() const { return mfSmallestViewDistance; } getSmallestSubdivisionViewDistance() const97 double getSmallestSubdivisionViewDistance() const { return mfSmallestSubdivisionViewDistance; } getSubdivisionsX() const98 sal_uInt32 getSubdivisionsX() const { return mnSubdivisionsX; } getSubdivisionsY() const99 sal_uInt32 getSubdivisionsY() const { return mnSubdivisionsY; } getBColor() const100 const basegfx::BColor& getBColor() const { return maBColor; } getCrossMarker() const101 const BitmapEx& getCrossMarker() const { return maCrossMarker; } 102 103 /// compare operator 104 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 105 106 /// get 2d range 107 virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const; 108 109 /// provide unique ID 110 DeclPrimitrive2DIDBlock() 111 112 /// Overload standard getDecomposition call to be view-dependent here 113 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 114 }; 115 } // end of namespace primitive2d 116 } // end of namespace drawinglayer 117 118 ////////////////////////////////////////////////////////////////////////////// 119 120 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX 121 122 ////////////////////////////////////////////////////////////////////////////// 123 // eof 124