]> git.mxchange.org Git - simgear.git/blob - simgear/canvas/elements/CanvasPath.hxx
Canvas: Respect clipping while event handling.
[simgear.git] / simgear / canvas / elements / CanvasPath.hxx
1 // An OpenVG path on the Canvas
2 //
3 // Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Library General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Library General Public License for more details.
14 //
15 // You should have received a copy of the GNU Library General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
18
19 #ifndef CANVAS_PATH_HXX_
20 #define CANVAS_PATH_HXX_
21
22 #include "CanvasElement.hxx"
23 #include <boost/preprocessor/iteration/iterate.hpp>
24
25 namespace simgear
26 {
27 namespace canvas
28 {
29   class Path:
30     public Element
31   {
32     public:
33       static const std::string TYPE_NAME;
34       static void staticInit();
35
36       Path( const CanvasWeakPtr& canvas,
37             const SGPropertyNode_ptr& node,
38             const Style& parent_style,
39             Element* parent = 0 );
40       virtual ~Path();
41
42       virtual void update(double dt);
43
44       virtual osg::BoundingBox getTransformedBounds(const osg::Matrix& m) const;
45
46 #define BOOST_PP_ITERATION_LIMITS (0, 6)
47 #define BOOST_PP_FILENAME_1 \
48         <simgear/canvas/elements/detail/add_segment_variadic.hxx>
49 #include BOOST_PP_ITERATE()
50
51       /** Move path cursor */
52       Path& moveTo(float x_abs, float y_abs);
53       Path& move(float x_rel, float y_rel);
54
55       /** Add a line */
56       Path& lineTo(float x_abs, float y_abs);
57       Path& line(float x_rel, float y_rel);
58
59       /** Add a horizontal line */
60       Path& horizTo(float x_abs);
61       Path& horiz(float x_rel);
62
63       /** Add a vertical line */
64       Path& vertTo(float y_abs);
65       Path& vert(float y_rel);
66
67       /** Close the path (implicit lineTo to first point of path) */
68       Path& close();
69
70     protected:
71
72       enum PathAttributes
73       {
74         CMDS       = LAST_ATTRIBUTE << 1,
75         COORDS     = CMDS << 1
76       };
77
78       class PathDrawable;
79       typedef osg::ref_ptr<PathDrawable> PathDrawableRef;
80       PathDrawableRef _path;
81
82       virtual void childRemoved(SGPropertyNode * child);
83       virtual void childChanged(SGPropertyNode * child);
84   };
85
86 } // namespace canvas
87 } // namespace simgear
88
89 #endif /* CANVAS_PATH_HXX_ */