OpenWalnut  1.5.0dev
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 
36 /**
37  * 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
38  * on the side of the screen.
39  */
41 {
42 friend class SafeUpdateCallback; //!< Grant access for its inner class
43 public:
44  /**
45  * Default constructor.
46  */
48 
49  /**
50  * Destructor.
51  */
52  virtual ~WGEBorderLayout();
53 
54  /**
55  * Adds the specified object to the list of layouted objects.
56  *
57  * \param obj the layoutable object.
58  * \todo(ebaum): this is ugly, use a common baseclass instead
59  */
60  virtual void addLayoutable( osg::ref_ptr< WGELabel > obj );
61 
62 protected:
63  /**
64  * The geode containing all drawables.
65  */
66  osg::ref_ptr< osg::Geode > m_geode;
67 
68  /**
69  * Contains all lead lines.
70  */
71  osg::ref_ptr< osg::Geode > m_lineGeode;
72 
73  /**
74  * The projection to the screen
75  */
76  osg::ref_ptr< osg::Projection > m_screen;
77 
78  /**
79  * Node callback to actually layout the objects.
80  */
81  class SafeUpdateCallback : public osg::NodeCallback
82  {
83  public: // NOLINT
84  /**
85  * Constructor.
86  *
87  * \param layout just set the creating layout as pointer for later reference.
88  */
89  explicit SafeUpdateCallback( osg::ref_ptr< WGEBorderLayout > layout ): m_layouter( layout )
90  {
91  };
92 
93  /**
94  * operator () - called during the update traversal.
95  *
96  * \param node the osg node
97  * \param nv the node visitor
98  */
99  virtual void operator()( osg::Node* node, osg::NodeVisitor* nv );
100 
101  /**
102  * The layouter owning this callback
103  * \todo(ebaum) the layoiter insance will never be freed -> cyclic dependency
104  */
105  osg::ref_ptr< WGEBorderLayout > m_layouter;
106  };
107 
108 private:
109 };
110 
111 #endif // WGEBORDERLAYOUT_H
112 
Node callback to actually layout the objects.
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
operator () - called during the update traversal.
SafeUpdateCallback(osg::ref_ptr< WGEBorderLayout > layout)
Constructor.
osg::ref_ptr< WGEBorderLayout > m_layouter
The layouter owning this callback.
This class contains a label layout for positioning labels at the side of the screen.
WGEBorderLayout()
Default constructor.
virtual ~WGEBorderLayout()
Destructor.
osg::ref_ptr< osg::Projection > m_screen
The projection to the screen.
osg::ref_ptr< osg::Geode > m_lineGeode
Contains all lead lines.
virtual void addLayoutable(osg::ref_ptr< WGELabel > obj)
Adds the specified object to the list of layouted objects.
osg::ref_ptr< osg::Geode > m_geode
The geode containing all drawables.
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
Definition: WGEGroupNode.h:48