OpenWalnut  1.5.0dev
WMTemplateUI.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 WMTEMPLATEUI_H
26 #define WMTEMPLATEUI_H
27 
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 #include <boost/thread.hpp>
33 
34 #include "core/kernel/WModule.h"
35 #include "core/kernel/WModuleInputData.h"
36 #include "core/kernel/WModuleOutputData.h"
37 
38 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
39 // If you want to learn how to program a module, refer to WMTemplate.cpp. It is an extensive tutorial on all the details.
40 // In this tutorial, we assume you already know how to write modules. For other examples, refer to the README file.
41 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42 
43 /**
44  * \class WMTemplateUI
45  *
46  * A module that explains the usage of the abstract UI interface in OpenWalnut. Please read the C++ code.
47  *
48  * \ingroup modules
49  */
50 class WMTemplateUI : public WModule
51 {
52 public:
53  /**
54  * Constuctor.
55  */
56  WMTemplateUI();
57 
58  /**
59  * Destructor.
60  */
61  virtual ~WMTemplateUI();
62 
63  /**
64  * Gives back the name of this module.
65  * \return the module's name.
66  */
67  virtual const std::string getName() const;
68 
69  /**
70  * Gives back a description of this module.
71  * \return description to module.
72  */
73  virtual const std::string getDescription() const;
74 
75  /**
76  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
77  * should never be initialized or modified in some other way. A simple new instance is required.
78  *
79  * \return the prototype used to create every module in OpenWalnut.
80  */
81  virtual std::shared_ptr< WModule > factory() const;
82 
83 protected:
84  /**
85  * Entry point after loading the module. Runs in separate thread.
86  */
87  virtual void moduleMain();
88 
89  /**
90  * Initialize the connectors this module is using.
91  */
92  virtual void connectors();
93 
94  /**
95  * Initialize the properties for this module.
96  */
97  virtual void properties();
98 
99  /**
100  * Initialize requirements for this module.
101  */
102  virtual void requirements();
103 
104 private:
105  /**
106  * Called on every mouse drag-move event from the custom widget.
107  *
108  * \note this runs in OSG thread.
109  * \param pos New mouse position.
110  * \param button the button.
111  */
112  void handleMouseDrag( WVector2f pos, int button );
113 
114  /**
115  * Called on every mouse move event from the custom widget.
116  *
117  * \note this runs in OSG thread.
118  * \param pos New mouse position.
119  */
120  void handleMouseMove( WVector2f pos );
121 
122  /**
123  * Called on every resize event from the custom widget.
124  *
125  * \note this runs in OSG thread.
126  * \param x X pos
127  * \param y Y pos
128  * \param width Widht
129  * \param height Height
130  */
131  void handleResize( int x, int y, int width, int height );
132 
133  /**
134  * Handle mouse clicks
135  *
136  * \param coords where
137  * \param button the button
138  */
139  void handleButtonRelease( WVector2f coords , int button );
140 
141  /**
142  * Handle camera presets.
143  */
144  void cameraPresetCallback();
145 
146  //! A condition for property updates.
147  std::shared_ptr< WCondition > m_propCondition;
148 
149  /**
150  * A boolean property used in this example.
151  */
152  WPropBool m_boolProp;
153 
154  /**
155  * A trigger property used in this example.
156  */
157  WPropTrigger m_triggerProp;
158 };
159 
160 #endif // WMTEMPLATEUI_H
A module that explains the usage of the abstract UI interface in OpenWalnut.
Definition: WMTemplateUI.h:51
void handleButtonRelease(WVector2f coords, int button)
Handle mouse clicks.
void cameraPresetCallback()
Handle camera presets.
virtual void connectors()
Initialize the connectors this module is using.
void handleMouseDrag(WVector2f pos, int button)
Called on every mouse drag-move event from the custom widget.
WPropTrigger m_triggerProp
A trigger property used in this example.
Definition: WMTemplateUI.h:157
WMTemplateUI()
Constuctor.
virtual const std::string getDescription() const
Gives back a description of this module.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
virtual void moduleMain()
Entry point after loading the module.
virtual ~WMTemplateUI()
Destructor.
WPropBool m_boolProp
A boolean property used in this example.
Definition: WMTemplateUI.h:152
void handleResize(int x, int y, int width, int height)
Called on every resize event from the custom widget.
virtual void properties()
Initialize the properties for this module.
virtual void requirements()
Initialize requirements for this module.
virtual const std::string getName() const
Gives back the name of this module.
void handleMouseMove(WVector2f pos)
Called on every mouse move event from the custom widget.
std::shared_ptr< WCondition > m_propCondition
A condition for property updates.
Definition: WMTemplateUI.h:147
A fixed size matrix class.
Definition: WMatrixFixed.h:150
Class representing a single module of OpenWalnut.
Definition: WModule.h:72