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