]> git.mxchange.org Git - simgear.git/blob - simgear/canvas/CanvasObjectPlacement.hxx
canvas::Layout: clear parent/canvas after calling onRemove.
[simgear.git] / simgear / canvas / CanvasObjectPlacement.hxx
1 ///@file Placement for putting a canvas texture onto OpenSceneGraph objects.
2 //
3 // It also provides a SGPickCallback for passing mouse events to the canvas and
4 // manages emissive lighting of the placed canvas.
5 //
6 // Copyright (C) 2013  Thomas Geymayer <tomgey@gmail.com>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
21
22 #ifndef CANVAS_OBJECT_PLACEMENT_HXX_
23 #define CANVAS_OBJECT_PLACEMENT_HXX_
24
25 #include "CanvasPlacement.hxx"
26 #include "canvas_fwd.hxx"
27
28 #include <simgear/scene/util/SGSceneUserData.hxx>
29 #include <osg/Material>
30
31 namespace simgear
32 {
33 namespace canvas
34 {
35
36   /**
37    * Place a Canvas onto an osg object (as texture).
38    */
39   class ObjectPlacement:
40     public Placement
41   {
42     public:
43
44       typedef osg::ref_ptr<osg::Group> GroupPtr;
45       typedef osg::ref_ptr<osg::Material> MaterialPtr;
46
47       ObjectPlacement( SGPropertyNode* node,
48                        const GroupPtr& group,
49                        const CanvasWeakPtr& canvas );
50       virtual ~ObjectPlacement();
51
52       /**
53        * Set emissive lighting of the object the canvas is placed on.
54        */
55       void setEmission(float emit);
56
57       /**
58        * Set whether pick events should be captured.
59        */
60       void setCaptureEvents(bool enable);
61
62       virtual bool childChanged(SGPropertyNode* child);
63
64     protected:
65       typedef SGSharedPtr<SGPickCallback> PickCallbackPtr;
66       typedef osg::ref_ptr<SGSceneUserData> SGSceneUserDataPtr;
67
68       GroupPtr            _group;
69       MaterialPtr         _material;
70       CanvasWeakPtr       _canvas;
71       PickCallbackPtr     _pick_cb;
72       SGSceneUserDataPtr  _scene_user_data;
73   };
74
75 } // namespace canvas
76 } // namespace simgear
77
78 #endif /* CANVAS_OBJECT_PLACEMENT_HXX_ */