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