/src/libreoffice/include/drawinglayer/primitive2d/gridprimitive2d.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <drawinglayer/drawinglayerdllapi.h> |
23 | | |
24 | | #include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx> |
25 | | #include <basegfx/matrix/b2dhommatrix.hxx> |
26 | | #include <basegfx/color/bcolor.hxx> |
27 | | #include <vcl/bitmap.hxx> |
28 | | |
29 | | |
30 | | // GridPrimitive2D class |
31 | | |
32 | | namespace drawinglayer::primitive2d |
33 | | { |
34 | | /** GridPrimitive2D class |
35 | | |
36 | | This primitive is specialized to grid visualization. The graphic definition |
37 | | (Transform) contains the whole grid area, but will of course be combined |
38 | | with the visible area (Viewport) when decomposed. Also a resolution-dependent |
39 | | point reduction is used to not create too much grid visualization data. This |
40 | | makes this primitive highly view-dependent and it dynamically buffers |
41 | | the last decomposition depending on the Viewport used. |
42 | | */ |
43 | | class DRAWINGLAYER_DLLPUBLIC GridPrimitive2D final : public BufferedDecompositionPrimitive2D |
44 | | { |
45 | | private: |
46 | | /// The geometry definition for the grid area |
47 | | basegfx::B2DHomMatrix maTransform; |
48 | | |
49 | | /// grid layout definitions |
50 | | double mfWidth; |
51 | | double mfHeight; |
52 | | double mfSmallestViewDistance; |
53 | | double mfSmallestSubdivisionViewDistance; |
54 | | sal_uInt32 mnSubdivisionsX; |
55 | | sal_uInt32 mnSubdivisionsY; |
56 | | |
57 | | /// Grid color for single-pixel grid points |
58 | | basegfx::BColor maBColor; |
59 | | |
60 | | /// The Bitmap (with transparency) for grid cross points |
61 | | Bitmap maCrossMarker; |
62 | | |
63 | | /** the last used object to view transformation and the last Viewport, |
64 | | used from getDecomposition to decide buffering |
65 | | */ |
66 | | basegfx::B2DHomMatrix maLastObjectToViewTransformation; |
67 | | basegfx::B2DRange maLastViewport; |
68 | | |
69 | | /// create local decomposition |
70 | | virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override; |
71 | | |
72 | | public: |
73 | | /// constructor |
74 | | GridPrimitive2D( |
75 | | basegfx::B2DHomMatrix aTransform, |
76 | | double fWidth, |
77 | | double fHeight, |
78 | | double fSmallestViewDistance, |
79 | | double fSmallestSubdivisionViewDistance, |
80 | | sal_uInt32 nSubdivisionsX, |
81 | | sal_uInt32 nSubdivisionsY, |
82 | | const basegfx::BColor& rBColor, |
83 | | const Bitmap& rCrossMarker); |
84 | | |
85 | | /// data read access |
86 | 0 | const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } |
87 | 0 | double getWidth() const { return mfWidth; } |
88 | 0 | double getHeight() const { return mfHeight; } |
89 | 0 | double getSmallestViewDistance() const { return mfSmallestViewDistance; } |
90 | 0 | double getSmallestSubdivisionViewDistance() const { return mfSmallestSubdivisionViewDistance; } |
91 | 0 | sal_uInt32 getSubdivisionsX() const { return mnSubdivisionsX; } |
92 | 0 | sal_uInt32 getSubdivisionsY() const { return mnSubdivisionsY; } |
93 | 0 | const basegfx::BColor& getBColor() const { return maBColor; } |
94 | 0 | const Bitmap& getCrossMarker() const { return maCrossMarker; } |
95 | | |
96 | | /// compare operator |
97 | | virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; |
98 | | |
99 | | /// get 2d range |
100 | | virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override; |
101 | | |
102 | | /// provide unique ID |
103 | | virtual sal_uInt32 getPrimitive2DID() const override; |
104 | | |
105 | | /// Override standard getDecomposition to be view-dependent here |
106 | | virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override; |
107 | | }; |
108 | | } // end of namespace drawinglayer::primitive2d |
109 | | |
110 | | |
111 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |