vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GUI_Controller.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "GUI_item.h"
4 #include "Menu.h"
5 #include "Layout.h"
6 #include "ItemsGroup.h"
7 
8 # ifdef GUI_LIBRARY
9 # define GUI_EXPORT __declspec(dllexport)
10 # else
11 # define GUI_EXPORT __declspec(dllimport)
12 #endif
13 
14 //FIXME solve somehow nicer... ask Martin - he will know some elegant solution, for sure
15 // if needed, this can be increased to any value
16 // see also 'OptiTrack.h' and 'InputConnector.h', some limitations is also there
17 // Kinect uses 20 sensors
18 
19 // Is it really necessary to work with all tracked sensors in GUI controller ??
20 #define SENSOR_MAX_COUNT 20
21 
22 
23 
24 using namespace vrecko;
25 
26 namespace APGUI
27 {
28  typedef std::map<string, osg::ref_ptr<Layout>> LayoutMapType;
29 
30 
32 
42 {
43 public:
44 
46  ~GUI_Controller();
47 
48 
50  void enableGUI( bool enable );
51 
53 
57  ItemsGroup *getorCreateGroup( string groupName );
58 
59  GUI_Item *getItembyName( string itemName );
60 
61  string getLayoutString() { return _actualLayout->getName(); }
62 
63  // Is called after all Environment Objects and abilities defined in XML are created (their constructors were called}
64  bool initialize(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *parametersNode);
65 
67 
74  void registerPointableGuiItem( const unsigned int ID, GUI_Item* item);
75 
76  void registerGlobalGuiItem( const int sensor, GUI_Item* item);
77 
79  void reset();
80 
82 
87  void setMenuShown(const int sensor, Menu *shownMenu);
88 
89 
90  //TODO are both functions necessary?
91  bool setLayout(string name);
92 
93  //TODO are both functions necessary?
94  bool switchLayout(string name);
95 
96 
97 
98  void update();
99 
100 
101 
102  void unregisterGlobalGuiItem( const int sensor, GUI_Item* item);
103 
105 
111  void unregisterPointableGuiItem( const unsigned int ID );
112 
113 protected:
114 
116 
119  bool _disabled;
120 
122 
127 
129 
134 
135  // flag, used in update to post-post initialize some things, that can't be initialized earlier
137 
140 
143 
145  std::vector<GUI_Item *> *_globalAbilities;
146 
147  // array of lastly shown menus, indicating if there is menu shown for each sensor, or not ~ NULL value
149 
151  osg::Vec3 *_actualPositions;
152 
153 
154  osg::Vec4 _colourActive;
155 
156  osg::Vec4 _colourDefault;
157 
158  osg::Vec4 _colourHovered;
159 
160  osg::Vec4 _colourPressed;
161 
162  osg::Vec4 _colourDisabled;
163 
164 
166 
173 
174  //std::vector<osg::ref_ptr<Layout>> _layouts;
175 
177 
181 
182 
185 
187  osg::Timer _timer;
188 
190  osg::Timer_t *_pointedTime;
191 
194 
195 
197 
205 
207  std::vector<osg::ref_ptr<ItemsGroup>> _groups;
208 
210 
219  void pointObjectByID( int sensor_number, unsigned long selectedID );
220 
221 
222  bool processAction( const int sensorNumber, const GUI_ACTION action, const bool pressed );
223  bool processContextClick( const int sensorNumber, const bool value );
224 
225  // obsoleted - remove
226  //void processPosition( int sensor_num, osg::Vec3 pos );
227 
228 
229  // Buttons clicks (from Input Controller preferably)
230  DECLARE_REQUEST_INPUT(Sensor_0_mainClick, MessageBool, MessageBool);
231  DECLARE_REQUEST_INPUT(Sensor_1_mainClick, MessageBool, MessageBool);
232  DECLARE_REQUEST_INPUT(Sensor_0_contextClick, MessageBool, MessageBool);
233  DECLARE_REQUEST_INPUT(Sensor_1_contextClick, MessageBool, MessageBool);
234 
235  // asking about what object is actually selected - Input Connector should answer
236  DECLARE_REQUEST_OUTPUT(SelectedObjectID, MessageInt, MessageObjectID);
237 
238 
239  // from other parts of vrecko
240  DECLARE_INPUT(SwitchLayout, MessageString);
241 
242 
243 
244 
245 
248  unsigned int _selectionaccumulator;
249 };
250 
251 }