1 // Interface for 2D canvas element
3 // Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef CANVAS_ELEMENT_HXX_
20 #define CANVAS_ELEMENT_HXX_
22 #include <simgear/props/props.hxx>
23 #include <osg/MatrixTransform>
24 #include <simgear/misc/stdint.hxx> // for uint32_t
35 private SGPropertyChangeListener
38 virtual ~Element() = 0;
41 * Called every frame to update internal state
43 * @param dt Frame time in seconds
45 virtual void update(double dt);
47 osg::ref_ptr<osg::MatrixTransform> getMatrixTransform();
55 BOUNDING_BOX = 0x0004,
56 LAST_ATTRIBUTE = BOUNDING_BOX
68 uint32_t _attributes_used;
69 uint32_t _attributes_dirty;
71 bool _transform_dirty;
72 osg::ref_ptr<osg::MatrixTransform> _transform;
73 std::vector<TransformType> _transform_types;
75 SGPropertyNode_ptr _node;
76 std::vector<SGPropertyNode_ptr> _color,
78 std::vector<SGPropertyNode_ptr> _bounding_box;
80 Element(SGPropertyNode_ptr node, uint32_t attributes_used = 0);
82 virtual void childAdded(SGPropertyNode * child) {}
83 virtual void childRemoved(SGPropertyNode * child){}
84 virtual void childChanged(SGPropertyNode * child){}
86 virtual void colorChanged(const osg::Vec4& color) {}
87 virtual void colorFillChanged(const osg::Vec4& color){}
89 void setDrawable( osg::Drawable* drawable );
93 osg::Drawable *_drawable;
95 Element(const Element&);// = delete
97 virtual void childAdded( SGPropertyNode * parent,
98 SGPropertyNode * child );
99 virtual void childRemoved( SGPropertyNode * parent,
100 SGPropertyNode * child );
101 virtual void valueChanged(SGPropertyNode * child);
104 } // namespace canvas
106 #endif /* CANVAS_ELEMENT_HXX_ */