VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtInputDriver.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2017 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
12 #include <vrvCore/DtDriver.h>
16 #include <boost/signal.hpp>
17 
18 #include <string>
19 #include <vector>
20 
21 namespace makVrv
22 {
23  class DtAgentManager;
24  class DtChannel;
25  class DtChannelManager;
26  class DtDe;
27  class DtEventProcessorInterface;
28  class DtInputDriverConfiguration;
29  class DtKeyAndMouseEventListener;
30  class DtKeyMap;
31  class DtKeyMapManager;
32  class DtMouseEvent;
33  class DtPinchGesture;
34  class DtObserver;
35  class DtObserverController;
36  class DtChannelConfiguration;
37  class DtObserverAnimator;
38  class DtObserverViewsManager;
39 
44  {
45  public:
48  typedef std::list<DtEventProcessorInterface*> EventProcessorList;
49 
51  typedef std::map<std::string, makArchives::DtObserverStateRecord> ObserverStateMap;
52 
54  typedef std::map<std::string, DtObserverConfiguration> ObserverConfigurationMap;
55 
57  DtInputDriver(DtAgentManager& agentManager,
58  const std::string& instanceName);
59 
61  virtual ~DtInputDriver();
62 
64  virtual bool onStart();
65 
67  virtual bool onStop();
68 
70  virtual bool onTick();
71 
73  virtual const std::string& className() const;
74 
76  virtual bool processKeyEvent(const DtKeyEvent& keyEvent,
77  DtChannel* channel);
78 
80  virtual bool processMouseEvent(const DtMouseEvent& mouseEvent,
81  DtChannel* channel);
82 
83  virtual bool processPinchGesture(const DtPinchGesture& pinchGesture,
84  DtChannel* channel);
85 
87  virtual void hideMouse(DtChannel* channel, float mouseX, float mouseY);
88 
90  virtual bool isMouseHidden() const;
91 
93  virtual void showMouse(DtChannel* channel);
94 
96  virtual void centerMouse(DtChannel* channel);
97 
99  virtual void setMousePosition(DtChannel* channel, float x, float y);
100 
103  virtual void clearState();
104 
110  DtChannel* currentChannel() const;
111 
114  virtual void addEventProcessorToFront(DtEventProcessorInterface* epi);
115 
120  virtual void addEventProcessorToBack(DtEventProcessorInterface* epi);
121 
125  virtual EventProcessorList& eventProcessorList();
126 
129  virtual DtEventProcessorInterface* findEventProcessor(
130  const std::string& className);
131 
136  virtual void removeEventProcessor(DtEventProcessorInterface* epi);
137 
139  bool saveKeyMapToFile(const DtKeyMap& keyMap, const std::string& filename) const;
140 
143  DtKeyMap* loadKeyMapFromFile(const std::string& filename, bool createBackup = false);
144 
146  //
149  void setKeyMap(const std::string& mapName);
150 
152  const std::string& keyMap() const;
153 
155  DtKeyMap* createKeyMap(const std::string& mapName);
156 
158  DtKeyMap* findKeyMap(const std::string& mapName);
159 
161  void addKeyBinding(DtKeyMap* map, DtKeyState::KeyType key,
162  const std::string& functionName,
164  bool replace = false,
166 
169  void addBinaryKeyBinding(DtKeyMap* map, DtKeyState::KeyType key,
170  const std::string& binaryName,
172  bool replace = false);
173 
175  virtual void realizeConfiguration(
176  const DtConfiguration& configuration);
177 
178  virtual void realizeObserverConfiguration(
179  const DtObserverConfiguration& configuration);
180 
181  const ObserverConfigurationMap& observerConfigurations() const;
182 
189  void addObserverConfiguration(const DtObserverConfiguration& config);
190 
193  void addObserverState(const std::string& observerName,
194  const makArchives::DtObserverStateRecord& stateRecord);
195 
199  void initializeObserver(DtObserver* observer,
200  const makArchives::DtObserverStateRecord& stateRecord);
201 
202  //-----
204 
206  virtual void addObserver(DtObserver* observer);
207 
209  virtual void removeObserver(DtObserver* observer);
210 
212  virtual void removeObserver(const std::string& name);
213 
215  virtual std::vector<DtObserver*> observers() const;
216 
218 
219  virtual DtObserver* findObserverByName(const std::string& name);
220  virtual const DtObserver* findObserverByName(const std::string& name) const;
222 
224  void setCurrentObserver(const std::string& observerName);
225 
227  DtObserver* currentObserver() const;
228 
230  void setTerrainContextEnabled(bool enabled);
231  bool terrainContextEnabled() const;
232 
234 
236  virtual void performObserverAction(const DtViewStateProcessor::ObserverAction& action);
237 
239  virtual void toggleTerrainScaling();
240 
242  virtual void toggleWireframe();
243 
245  virtual void toggleSimulationTimePaused();
246 
248  virtual void incrementTerrainScaleFactor();
249 
251  virtual void decrementTerrainScaleFactor();
252 
254  virtual void toggleEntityLabels();
255 
257  virtual void toggleRotateEntitySymbols();
258 
260  virtual void toggleTacticalGraphics();
261 
263  virtual void toggleEntityHatLines();
264 
266  virtual void toggleTacticalGraphicsHatLines();
268  virtual void toggleEntityHatMode();
269 
271  virtual void toggleTacticalGraphicsHatMode();
272 
274  virtual void togglePropTransparencySelected();
275 
278  virtual void toggleViewControl();
279 
281  void resetObservers(DtUniqueID id);
282 
285  void setAllowObserverReset(bool allow);
286 
288  void saveObservers(const std::string& filename);
289 
293  void loadObservers(const std::string& filename, bool force = false);
294 
295  DtElementEntry::ObjectType typeFromId(const DtUniqueID& id);
296 
300  virtual void animateObserver(DtObserverAnimator* newAnimator);
301 
303  virtual void removeAnimatorFromObserver(DtObserver *observer);
304 
306  virtual void takeScreenCapture();
307 
309  virtual void toggleDeveloperDebugUI();
310 
312  DtObserverViewsManager& observerViewsManager() const;
313 
314 
315  protected:
316 
317  void setCurrentObserver(DtObserver* observer);
318 
320  virtual void initializeKeyMapManager(const std::string& defaultKeyMap);
321  virtual void bindFunctions();
323  virtual void createMaps();
324 
327  virtual void loadMaps(bool loadFromFactory = false);
328 
330  typedef std::map<std::string, DtObserver*> ObserversMap;
331 
332  void removeObserver(ObserversMap& observers, DtObserver* observer);
333  void removeObserver(ObserversMap& observers, const std::string& name);
334 
335  void destroyObservers();
336 
337  bool setCurrentObserverFromChannel(const DtChannel& channel);
338 
339  void slot_channelCreated(DtChannelManager* channelManager, DtChannel* channel);
340  void slot_channelDestroyed(DtChannelManager* channelManager, DtChannel* channel);
341  void slot_channelConfigurationModified(const std::string& deName,
342  const std::string& winName, const std::string& oldChannelName,
343  const DtChannelConfiguration& config);
344  void slot_attachedToChanged(DtObserver* observer);
345 
346 
347  void createRequiredObservers(const std::string& engineName);
348 
350  virtual void slot_displayEngineAdded(const DtDeRecord& igRecord);
351 
355  std::string restoreObserversPart1();
356 
358  void restoreObserversPart2(const std::string& filename);
359 
360  virtual void slot_displayEngineRealized(const std::string&,
361  const std::string& engineName);
362 
363  private:
366 
368  DtInputDriver& operator=(const DtInputDriver&);
369 
370  protected:
372 
374 
377 
380 
381  std::string myClassName;
383 
386 
389 
392 
394 
396 
398  std::list<DtObserverAnimator*> myAnimatingObservers;
399 
400  // Pointer to the DtObserverViewsManager
402  };
403 
407  {
408  public:
409 
412 
414  virtual ~DtInputDriverCreator();
415 
417  static DtInputDriverCreator& instance(DtDe& de);
418 
422  static void registerInstance(DtDe& de, DtInputDriverCreator* creator);
423 
425  virtual DtInputDriver* create(DtAgentManager& sm);
426 
427  };
428 
429 }

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)