Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX
21 : #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX
22 :
23 : #include <drawinglayer/drawinglayerdllapi.h>
24 :
25 : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 : #include <basegfx/matrix/b2dhommatrix.hxx>
27 : #include <basegfx/color/bcolor.hxx>
28 : #include <vcl/bitmapex.hxx>
29 :
30 :
31 : // GridPrimitive2D class
32 :
33 : namespace drawinglayer
34 : {
35 : namespace primitive2d
36 : {
37 : /** GridPrimitive2D class
38 :
39 : This primitive is specialized to Grid visualisation. The graphic definition
40 : (Transform) contains the whole grid area, but will of course be combined
41 : with the visible area (Viewport) when decomposed. Also a reolution-dependent
42 : point reduction is used to not create too much grid visualisation data. This
43 : makes this primitive highly view-dependent and it dynamically buffers
44 : the last decomposition dependent from the Viewport used.
45 : */
46 2500 : class DRAWINGLAYER_DLLPUBLIC GridPrimitive2D : public BufferedDecompositionPrimitive2D
47 : {
48 : private:
49 : /// The geometry definition for the grid area
50 : basegfx::B2DHomMatrix maTransform;
51 :
52 : /// grid layout definitions
53 : double mfWidth;
54 : double mfHeight;
55 : double mfSmallestViewDistance;
56 : double mfSmallestSubdivisionViewDistance;
57 : sal_uInt32 mnSubdivisionsX;
58 : sal_uInt32 mnSubdivisionsY;
59 :
60 : /// Grid color for single-pixel grid points
61 : basegfx::BColor maBColor;
62 :
63 : /// The Bitmap (with transparence) for grid cross points
64 : BitmapEx maCrossMarker;
65 :
66 : /** the last used object to view transformtion and the last Viewport,
67 : used from getDecomposition for decide buffering
68 : */
69 : basegfx::B2DHomMatrix maLastObjectToViewTransformation;
70 : basegfx::B2DRange maLastViewport;
71 :
72 : protected:
73 : /// create local decomposition
74 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
75 :
76 : public:
77 : /// constructor
78 : GridPrimitive2D(
79 : const basegfx::B2DHomMatrix& rTransform,
80 : double fWidth,
81 : double fHeight,
82 : double fSmallestViewDistance,
83 : double fSmallestSubdivisionViewDistance,
84 : sal_uInt32 nSubdivisionsX,
85 : sal_uInt32 nSubdivisionsY,
86 : const basegfx::BColor& rBColor,
87 : const BitmapEx& rCrossMarker);
88 :
89 : /// data read access
90 4062 : const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
91 532 : double getWidth() const { return mfWidth; }
92 532 : double getHeight() const { return mfHeight; }
93 532 : double getSmallestViewDistance() const { return mfSmallestViewDistance; }
94 532 : double getSmallestSubdivisionViewDistance() const { return mfSmallestSubdivisionViewDistance; }
95 532 : sal_uInt32 getSubdivisionsX() const { return mnSubdivisionsX; }
96 532 : sal_uInt32 getSubdivisionsY() const { return mnSubdivisionsY; }
97 532 : const basegfx::BColor& getBColor() const { return maBColor; }
98 532 : const BitmapEx& getCrossMarker() const { return maCrossMarker; }
99 :
100 : /// compare operator
101 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
102 :
103 : /// get 2d range
104 : virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
105 :
106 : /// provide unique ID
107 : DeclPrimitive2DIDBlock()
108 :
109 : /// Overload standard getDecomposition call to be view-dependent here
110 : virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
111 : };
112 : } // end of namespace primitive2d
113 : } // end of namespace drawinglayer
114 :
115 :
116 :
117 : #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_GRIDPRIMITIVE2D_HXX
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|