Branch libreoffice-6-3
[LibreOffice.git] / include / drawinglayer / primitive2d / helplineprimitive2d.hxx
blobfd48f0aae5fec7fb2cb03cad690629e76c424103
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_HELPLINEPRIMITIVE2D_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_HELPLINEPRIMITIVE2D_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
26 #include <basegfx/color/bcolor.hxx>
27 #include <basegfx/matrix/b2dhommatrix.hxx>
30 // HelplinePrimitive2D class
32 namespace drawinglayer
34 namespace primitive2d
36 /** HelplineStyle2D definition
38 The available styles of Helplines
40 enum class HelplineStyle2D
42 Point,
43 Line
46 /** HelplinePrimitive2D class
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.
54 The visualisation uses the two given colors to create a dashed line with
55 the given dash length.
57 class DRAWINGLAYER_DLLPUBLIC HelplinePrimitive2D : public BufferedDecompositionPrimitive2D
59 private:
60 /// Helpline geometry definition
61 basegfx::B2DPoint maPosition;
62 basegfx::B2DVector maDirection;
63 HelplineStyle2D meStyle;
65 /// Helpline style definition
66 basegfx::BColor maRGBColA;
67 basegfx::BColor maRGBColB;
68 double mfDiscreteDashLength;
70 /** the last used object to view transformtion and the last Viewport,
71 used from getDecomposition for decide buffering
73 basegfx::B2DHomMatrix maLastObjectToViewTransformation;
74 basegfx::B2DRange maLastViewport;
76 protected:
77 /// create local decomposition
78 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
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);
90 /// data read access
91 const basegfx::B2DPoint& getPosition() const { return maPosition; }
92 const basegfx::B2DVector& getDirection() const { return maDirection; }
93 HelplineStyle2D getStyle() const { return meStyle; }
94 const basegfx::BColor& getRGBColA() const { return maRGBColA; }
95 const basegfx::BColor& getRGBColB() const { return maRGBColB; }
96 double getDiscreteDashLength() const { return mfDiscreteDashLength; }
98 /// compare operator
99 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
101 /// provide unique ID
102 DeclPrimitive2DIDBlock()
104 /// Override standard getDecomposition to be view-dependent here
105 virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
107 } // end of namespace primitive2d
108 } // end of namespace drawinglayer
111 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_HELPLINEPRIMITIVE2D_HXX
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */