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