OpenWalnut  1.5.0dev
WUIViewWidget.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 WUIVIEWWIDGET_H
26 #define WUIVIEWWIDGET_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <osg/ref_ptr>
32 
33 #include "../graphicsEngine/WGEViewer.h"
34 #include "WUIWidgetBase.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  *
64  * \note Please read documentation of \ref WUIWidgetFactory for limitations, requirements and creation of these widgets.
65  */
67 {
68 public:
69  /**
70  * Abbreviation for a shared pointer on a instance of this class.
71  */
72  typedef std::shared_ptr< WUIViewWidget > SPtr;
73 
74  /**
75  * Abbreviation for a const shared pointer on a instance of this class.
76  */
77  typedef std::shared_ptr< const WUIViewWidget > ConstSPtr;
78 
79  /**
80  * Destructor
81  */
82  virtual ~WUIViewWidget();
83 
84  /**
85  * Get the scene which is displayed
86  *
87  * \return the scene as osg::ref_ptr
88  */
89  virtual osg::ref_ptr< WGEGroupNode > getScene() const = 0;
90 
91  /**
92  * Get the viewer which is used
93  *
94  * \return the viewer as shared_ptr
95  */
96  virtual std::shared_ptr< WGEViewer > getViewer() const = 0;
97 
98  /**
99  * Returns the height of the viewport of the camera.
100  *
101  * \return Height in pixels.
102  */
103  virtual size_t height() const = 0;
104 
105  /**
106  * Returns the width of the viewport of the camera.
107  *
108  * \return Width in pixels.
109  */
110  virtual size_t width() const = 0;
111 
112  /**
113  * Adds an event handler to the widget's view.
114  *
115  * \param handler Pointer to the handler.
116  */
117  virtual void addEventHandler( osgGA::GUIEventHandler* handler ) = 0;
118 
119  /**
120  * Remove any pre-existing camera preset. Very useful when adding custom presets or presets do not make sense at all.
121  */
122  virtual void clearCameraPresets() = 0;
123 
124  /**
125  * Add a custom camera preset. Appends at the end of any pre-existing presets. The presets are not directly specified via a matrix or
126  * quaternion. A trigger property allows implementing own callbacks to actually set the preset. This is very useful when using your own
127  * osg::CameraManupulator implementation for your view.
128  *
129  * \param preset the trigger to set the preset.
130  * \param icon optional icon.
131  */
132  virtual void addCameraPreset( WPropTrigger preset, WGEImage::SPtr icon = WGEImage::SPtr() ) = 0;
133 protected:
134  /**
135  * Constructor. Create a custom widget instance.
136  *
137  * \param title the title of the widget
138  */
139  explicit WUIViewWidget( std::string title );
140 private:
141 };
142 
143 #endif // WUIVIEWWIDGET_H
Is just a short hand to the long name "osgGA::GUIEventAdapter".
Definition: WUIViewWidget.h:42
GUIEvents()
The constructor is private to forbid instance generation.
Definition: WUIViewWidget.h:56
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
Definition: WGEGroupNode.h:48
std::shared_ptr< WGEImage > SPtr
Convenience typedef for a std::shared_ptr< WGEImage >.
Definition: WGEImage.h:48
Custom widget which is created by a module to display custom information.
Definition: WUIViewWidget.h:67
std::shared_ptr< const WUIViewWidget > ConstSPtr
Abbreviation for a const shared pointer on a instance of this class.
Definition: WUIViewWidget.h:77
virtual void clearCameraPresets()=0
Remove any pre-existing camera preset.
virtual std::shared_ptr< WGEViewer > getViewer() const =0
Get the viewer which is used.
virtual ~WUIViewWidget()
Destructor.
virtual size_t height() const =0
Returns the height of the viewport of the camera.
std::shared_ptr< WUIViewWidget > SPtr
Abbreviation for a shared pointer on a instance of this class.
Definition: WUIViewWidget.h:72
virtual size_t width() const =0
Returns the width of the viewport of the camera.
virtual void addCameraPreset(WPropTrigger preset, WGEImage::SPtr icon=WGEImage::SPtr())=0
Add a custom camera preset.
WUIViewWidget(std::string title)
Constructor.
virtual void addEventHandler(osgGA::GUIEventHandler *handler)=0
Adds an event handler to the widget's view.
virtual osg::ref_ptr< WGEGroupNode > getScene() const =0
Get the scene which is displayed.
Base class for all the widget abstraction the core UI provides.
Definition: WUIWidgetBase.h:45