OpenWalnut  1.2.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
WGEBorderLayout.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGEBORDERLAYOUT_H
26 #define WGEBORDERLAYOUT_H
27 
28 #include <osg/Drawable>
29 #include <osg/Geode>
30 #include <osgText/Text>
31 #include <osg/Projection>
32 
33 #include "../../WGEGroupNode.h"
34 #include "WGELabel.h"
35 #include "../../WExportWGE.h"
36 
37 /**
38  * This class contains a label layout for positioning labels at the side of the screen. There is a line from the point of interest to the label
39  * on the side of the screen.
40  */
41 class WGE_EXPORT WGEBorderLayout: public WGEGroupNode
42 {
43 friend class SafeUpdateCallback;
44 public:
45 
46 
47  /**
48  * Default constructor.
49  */
51 
52  /**
53  * Destructor.
54  */
55  virtual ~WGEBorderLayout();
56 
57  /**
58  * Adds the specified object to the list of layouted objects.
59  *
60  * \param obj the layoutable object.
61  * \todo(ebaum): this is ugly, use a common baseclass instead
62  */
63  virtual void addLayoutable( osg::ref_ptr< WGELabel > obj );
64 
65 protected:
66 
67  /**
68  * The geode containing all drawables.
69  */
70  osg::ref_ptr< osg::Geode > m_geode;
71 
72  /**
73  * Contains all lead lines.
74  */
75  osg::ref_ptr< osg::Geode > m_lineGeode;
76 
77  /**
78  * The projection to the screen
79  */
80  osg::ref_ptr< osg::Projection > m_screen;
81 
82  /**
83  * Node callback to actually layout the objects.
84  */
85  class SafeUpdateCallback : public osg::NodeCallback
86  {
87  public: // NOLINT
88 
89  /**
90  * Constructor.
91  *
92  * \param layout just set the creating layout as pointer for later reference.
93  */
94  explicit SafeUpdateCallback( osg::ref_ptr< WGEBorderLayout > layout ): m_layouter( layout )
95  {
96  };
97 
98  /**
99  * operator () - called during the update traversal.
100  *
101  * \param node the osg node
102  * \param nv the node visitor
103  */
104  virtual void operator()( osg::Node* node, osg::NodeVisitor* nv );
105 
106  /**
107  * The layouter owning this callback
108  * \todo(ebaum) the layoiter insance will never be freed -> cyclic dependency
109  */
110  osg::ref_ptr< WGEBorderLayout > m_layouter;
111  };
112 
113 private:
114 };
115 
116 #endif // WGEBORDERLAYOUT_H
117