OpenWalnut  1.4.0
WCustomWidget.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 WCUSTOMWIDGET_H
26 #define WCUSTOMWIDGET_H
27 
28 #include <string>
29 
30 #ifndef Q_MOC_RUN
31 #include <boost/shared_ptr.hpp>
32 #endif
33 
34 #include <osg/ref_ptr>
35 
36 #include "../graphicsEngine/WGEViewer.h"
37 
38 class WGEGroupNode;
39 
40 /**
41  * Is just a short hand to the long name "osgGA::GUIEventAdapter".
42  */
43 class GUIEvents : public osgGA::GUIEventAdapter
44 {
45 public:
46  using osgGA::GUIEventAdapter::EventType;
47  using osgGA::GUIEventAdapter::MouseButtonMask;
48  using osgGA::GUIEventAdapter::KeySymbol;
49  using osgGA::GUIEventAdapter::ModKeyMask;
50  using osgGA::GUIEventAdapter::MouseYOrientation;
51  using osgGA::GUIEventAdapter::ScrollingMotion;
52  using osgGA::GUIEventAdapter::TabletPointerType;
53 
54 private:
55  /**
56  * The constructor is private to forbid instance generation.
57  */
59  {
60  }
61 };
62 
63 /**
64  * Custom widget which is created by a module to display custom information.
65  */
67 {
68 public:
69  /**
70  * Abbreviation for a shared pointer on a instance of this class.
71  */
72  typedef boost::shared_ptr< WCustomWidget > SPtr;
73 
74  /**
75  * Abbreviation for a const shared pointer on a instance of this class.
76  */
77  typedef boost::shared_ptr< const WCustomWidget > ConstSPtr;
78 
79  /**
80  * Constructor. Create a custom widget instance.
81  *
82  * \param title the title of the widget
83  */
84  explicit WCustomWidget( std::string title );
85 
86  /**
87  * Destructor
88  */
89  virtual ~WCustomWidget();
90 
91  /**
92  * Get the scene which is displayed
93  *
94  * \return the scene as osg::ref_ptr
95  */
96  virtual osg::ref_ptr< WGEGroupNode > getScene() const = 0;
97 
98  /**
99  * Get the viewer which is used
100  *
101  * \return the viewer as boost::shard_ptr
102  */
103  virtual boost::shared_ptr< WGEViewer > getViewer() const = 0;
104 
105  /**
106  * Get the title of the widget.
107  *
108  * \return title as string
109  */
110  virtual std::string getTitle() const;
111 
112  /**
113  * Returns the height of the viewport of the camera.
114  *
115  * \return Height in pixels.
116  */
117  virtual size_t height() const = 0;
118 
119  /**
120  * Returns the width of the viewport of the camera.
121  *
122  * \return Width in pixels.
123  */
124  virtual size_t width() const = 0;
125 
126  /**
127  * Adds an event handler to the widget's view.
128  *
129  * \param handler Pointer to the handler.
130  */
131  virtual void addEventHandler( osgGA::GUIEventHandler* handler ) = 0;
132 
133 protected:
134 private:
135  /**
136  * The widget's title string.
137  */
138  std::string m_title;
139 };
140 
141 #endif // WCUSTOMWIDGET_H
virtual boost::shared_ptr< WGEViewer > getViewer() const =0
Get the viewer which is used.
virtual size_t height() const =0
Returns the height of the viewport of the camera.
virtual void addEventHandler(osgGA::GUIEventHandler *handler)=0
Adds an event handler to the widget's view.
boost::shared_ptr< const WCustomWidget > ConstSPtr
Abbreviation for a const shared pointer on a instance of this class.
Definition: WCustomWidget.h:77
Is just a short hand to the long name "osgGA::GUIEventAdapter".
Definition: WCustomWidget.h:43
std::string m_title
The widget's title string.
virtual size_t width() const =0
Returns the width of the viewport of the camera.
WCustomWidget(std::string title)
Constructor.
virtual osg::ref_ptr< WGEGroupNode > getScene() const =0
Get the scene which is displayed.
virtual std::string getTitle() const
Get the title of the widget.
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
Definition: WGEGroupNode.h:48
virtual ~WCustomWidget()
Destructor.
GUIEvents()
The constructor is private to forbid instance generation.
Definition: WCustomWidget.h:58
Custom widget which is created by a module to display custom information.
Definition: WCustomWidget.h:66
boost::shared_ptr< WCustomWidget > SPtr
Abbreviation for a shared pointer on a instance of this class.
Definition: WCustomWidget.h:72