VR-Forces 4.8 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) 2019 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  class DtMouseHideProcessor;
40 
45  {
46  public:
49  typedef std::list<DtEventProcessorInterface*> EventProcessorList;
50 
52  typedef std::map<std::string, makArchives::DtObserverStateRecord> ObserverStateMap;
53 
55  typedef std::map<std::string, DtObserverConfiguration> ObserverConfigurationMap;
56 
58  DtInputDriver(DtAgentManager& agentManager,
59  const std::string& instanceName);
60 
62  virtual ~DtInputDriver();
63 
65  virtual bool onStart();
66 
68  virtual bool onStop();
69 
71  virtual bool onTick();
72 
74  virtual const std::string& className() const;
75 
77  virtual bool processKeyEvent(const DtKeyEvent& keyEvent,
78  DtChannel* channel);
79 
81  virtual bool processMouseEvent(const DtMouseEvent& mouseEvent,
82  DtChannel* channel);
83 
84  virtual bool processPinchGesture(const DtPinchGesture& pinchGesture,
85  DtChannel* channel);
86 
88  // hides the mouse if it hasn't moved for some period of time
89  virtual void setMouseHideProccessorEnabled(bool enabled);
90 
92  virtual void hideMouse(DtChannel* channel, float mouseX, float mouseY);
93 
95  virtual bool isMouseHidden() const;
96 
98  virtual void showMouse(DtChannel* channel);
99 
101  virtual void centerMouse(DtChannel* channel);
102 
104  virtual void setMousePosition(DtChannel* channel, float x, float y);
105 
108  virtual void clearState();
109 
111  DtChannel* currentChannel() const;
119  virtual DtChannel* findCurrentChannel() const;
121 
124  virtual void addEventProcessorToFront(DtEventProcessorInterface* epi);
125 
130  virtual void addEventProcessorToBack(DtEventProcessorInterface* epi);
131 
135  virtual EventProcessorList& eventProcessorList();
136 
139  virtual DtEventProcessorInterface* findEventProcessor(
140  const std::string& className);
141 
146  virtual void removeEventProcessor(DtEventProcessorInterface* epi);
147 
149  bool saveKeyMapToFile(const DtKeyMap& keyMap, const std::string& filename) const;
150 
153  DtKeyMap* loadKeyMapFromFile(const std::string& filename, bool createBackup = false);
154 
156  //
159  void setKeyMap(const std::string& mapName);
160 
162  const std::string& keyMap() const;
163 
165  DtKeyMap* createKeyMap(const std::string& mapName);
166 
168  DtKeyMap* findKeyMap(const std::string& mapName);
169 
171  void addKeyBinding(DtKeyMap* map, DtKeyState::KeyType key,
172  const std::string& functionName,
174  bool replace = false,
176 
179  void addBinaryKeyBinding(DtKeyMap* map, DtKeyState::KeyType key,
180  const std::string& binaryName,
182  bool replace = false);
183 
185  virtual void realizeConfiguration(
186  const DtConfiguration& configuration);
187 
188  virtual void realizeObserverConfiguration(
189  const DtObserverConfiguration& configuration);
190 
191  const ObserverConfigurationMap& observerConfigurations() const;
192 
199  void addObserverConfiguration(const DtObserverConfiguration& config);
200 
203  void addObserverState(const std::string& observerName,
204  const makArchives::DtObserverStateRecord& stateRecord);
205 
209  void initializeObserver(DtObserver* observer,
210  const makArchives::DtObserverStateRecord& stateRecord);
211 
212  //-----
214 
216  virtual void addObserver(DtObserver* observer);
217 
219  virtual void removeObserver(DtObserver* observer);
220 
222  virtual void removeObserver(const std::string& name);
223 
225  virtual std::vector<DtObserver*> observers() const;
226 
228  virtual DtObserver* findObserverByName(const std::string& name);
230  virtual const DtObserver* findObserverByName(const std::string& name) const;
232 
234  virtual void setCurrentObserver(const std::string& observerName);
235 
237  DtObserver* currentObserver() const;
243  virtual DtObserver* findCurrentObserver() const;
245 
247  void setTerrainContextEnabled(bool enabled);
248  bool terrainContextEnabled() const;
249 
251 
253  virtual void performObserverAction(const DtViewStateProcessor::ObserverAction& action);
254 
256  virtual void toggleTerrainScaling();
257 
259  virtual void toggleWireframe();
260 
262  virtual void toggleSimulationTimePaused();
263 
265  virtual void incrementTerrainScaleFactor();
266 
268  virtual void decrementTerrainScaleFactor();
269 
271  virtual void toggleEntityLabels();
272 
274  virtual void toggleRotateEntitySymbols();
275 
277  virtual void toggleTacticalGraphics();
278 
280  virtual void toggleEntityHatLines();
281 
283  virtual void toggleTacticalGraphicsHatLines();
285  virtual void toggleEntityHatMode();
286 
288  virtual void toggleTacticalGraphicsHatMode();
289 
291  virtual void togglePropTransparencySelected();
292 
295  virtual void toggleViewControl();
296 
298  void resetObservers(DtUniqueID id);
299 
302  virtual void setAllowObserverReset(bool allow);
303  virtual bool allowObserverReset();
304 
308  virtual void setObserverRestoreOnSlaveConnectEnabled(bool enable);
309  virtual bool isObserverRestoreOnSlaveConnectEnabled();
310 
312  void saveObservers(const std::string& filename);
313 
317  void loadObservers(const std::string& filename, bool force = false);
318 
319  DtElementEntry::ObjectType typeFromId(const DtUniqueID& id);
320 
324  virtual void animateObserver(DtObserverAnimator* newAnimator);
325 
327  virtual void removeAnimatorFromObserver(DtObserver *observer);
328 
330  virtual void takeScreenCapture();
331 
333  virtual void toggleDeveloperDebugUI();
334 
336  const DtObserverViewsManager& observerViewsManager() const;
338  DtObserverViewsManager& observerViewsManager();
340 
341 
342  protected:
343 
344  void setCurrentObserver(DtObserver* observer);
345 
347  virtual void initializeKeyMapManager(const std::string& defaultKeyMap);
348  virtual void bindFunctions();
350  virtual void createMaps();
351 
354  virtual void loadMaps(bool loadFromFactory = false);
355 
357  typedef std::map<std::string, DtObserver*> ObserversMap;
358 
359  void removeObserver(ObserversMap& observers, DtObserver* observer);
360  void removeObserver(ObserversMap& observers, const std::string& name);
361 
362  void destroyObservers();
363 
364  bool setCurrentObserverFromChannel(const DtChannel& channel);
365 
366  void slot_channelCreated(DtChannelManager* channelManager, DtChannel* channel);
367  void slot_channelDestroyed(DtChannelManager* channelManager, DtChannel* channel);
368  void slot_channelConfigurationModified(const std::string& deName,
369  const std::string& winName, const std::string& oldChannelName,
370  const DtChannelConfiguration& config);
371  void slot_attachedToChanged(DtObserver* observer);
372 
373 
374  void createRequiredObservers(const std::string& engineName);
375 
377  virtual void slot_displayEngineAdded(const DtDeRecord& igRecord);
378 
382  std::string restoreObserversPart1();
383 
385  void restoreObserversPart2(const std::string& filename);
386 
387  virtual void slot_displayEngineRealized(const std::string&,
388  const std::string& engineName);
389 
393  bool trimmedMatch(DtObserver* observer);
394 
396  bool showObserverNameWarning();
397 
400  void setShowObserverNameWarning(bool warn);
401 
402  private:
405 
407  DtInputDriver& operator=(const DtInputDriver&);
408 
409  protected:
411 
413 
416 
419 
420  std::string myClassName;
422 
425 
428 
431 
433 
435 
437  std::list<DtObserverAnimator*> myAnimatingObservers;
438 
439  // Pointer to the DtObserverViewsManager
441 
442  // Object used to hide mouse (if enabled) when mouse hasn't moved for some period
443  // of time
445 
447 
449  };
450 
454  {
455  public:
456 
459 
461  virtual ~DtInputDriverCreator();
462 
464  static DtInputDriverCreator& instance(DtDe& de);
465 
469  static void registerInstance(DtDe& de, DtInputDriverCreator* creator);
470 
472  virtual DtInputDriver* create(DtAgentManager& sm);
473 
474  };
475 
476 }
bool myShowObserverNameWarning
Definition: DtInputDriver.h:448
Creator class for the DtInputDriver.
Definition: DtInputDriver.h:453
boost::function< void(DtObserver &)> ObserverAction
Definition: DtViewStateProcessor.h:32
Virtual base class.
Definition: DtVirtualBaseClass.h:22
std::map< std::string, DtObserver * > ObserversMap
Observer Manager bound.
Definition: DtInputDriver.h:357
ObserversMap myObservers
Definition: DtInputDriver.h:414
DtMouseHideProcessor * myMouseHideProcessor
Definition: DtInputDriver.h:444
ObserverStateMap myObserverStates
Definition: DtInputDriver.h:418
This class encapsulates a Key event.
Definition: DtKeyEvent.h:19
bool myIsTerrainContextEnabled
Switch to enable or disable terrain context menus;.
Definition: DtInputDriver.h:430
TODO: This class is used to encapsulate a set of default observer settings and parameters.
Definition: DtObserverConfiguration.h:25
DtPinchGesture represents a Pinch Multitouch Gesture.
Definition: DtPinchGesture.h:26
DtChannel * myCurrentChannel
Definition: DtInputDriver.h:432
std::list< DtEventProcessorInterface * > EventProcessorList
A list of DtEventProcessorInterface, called in order for each event until one handles it...
Definition: DtInputDriver.h:49
A Record of an IG instance.
Definition: DtDeRecord.h:24
std::map< std::string, DtObserverConfiguration > ObserverConfigurationMap
A map of observer names, to DtObserverConfigurations.
Definition: DtInputDriver.h:55
Contains makVrv::DtObserverConfiguration class.
EventProcessorList myEventProcessors
Definition: DtInputDriver.h:412
A DtObserverSettingsRecord contains the state of an observer.
Definition: DtObserverStateRecord.h:20
This class encapsulates a mouse button event.
Definition: DtMouseEvent.h:22
a Key Map contains a map of keys to FunctionMapEntrys, as well as a list of functions to execute when...
Definition: DtKeyMap.h:315
KeyModifier
Describe which modifier(s) are pressed.
Definition: DtKeyState.h:139
Definition: DtKeyEvent.h:25
std::map< std::string, makArchives::DtObserverStateRecord > ObserverStateMap
A map of observer names, to DtObserverStateRecords.
Definition: DtInputDriver.h:52
DtObserver * myCurrentObserver
Temp, so we can look this up ONCE each event.
Definition: DtInputDriver.h:424
unsigned int ObjectType
Definition: DtElementEntry.h:50
The manager for owning key maps.
Definition: DtKeyMapManager.h:32
The abstract Channel Class.
Definition: DtChannel.h:29
A facade for a DtObserverObject.
Definition: DtObserver.h:37
The DtDriver is an abstract class.
Definition: DtDriver.h:34
DtDe & myDe
Definition: DtInputDriver.h:410
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
This class&#39;s main responsibility is to handle keyboard and mouse events from OSG (Qt events are route...
Definition: DtInputDriver.h:44
bool myAllowResetFlag
Control whether observers can be reset.
Definition: DtInputDriver.h:427
ObserverConfigurationMap myObserverConfigurations
Definition: DtInputDriver.h:417
Contains makVrv::DtKeyMapManager class.
bool myObserverRestoreOnSlaveConnectEnabled
Definition: DtInputDriver.h:446
The DtAgentManager manages the distributed scene object framework.
Definition: DtAgentManager.h:38
unsigned long long DtUniqueID
Definition: DtUniqueID.h:22
Contains makVrv:DtDriver class.
DtKeyMapManager & myCachedKeyMapManager
Definition: DtInputDriver.h:434
Definition: DtKeyState.h:140
Base class for handling DtChannels.
Definition: DtChannelManager.h:35
DtObserverViewsManager * myObserverViewsManager
Definition: DtInputDriver.h:440
Contains makArchives::DtObserverStateRecord class.
Encapsulates the process of animating an observer to a given location.
Definition: DtObserverAnimator.h:37
Configuration for a single channel Serialized and sent to remote displays as necessary to configure r...
Definition: DtChannelConfiguration.h:26
Manager for the observer view records loaded in the application.
Definition: DtObserverViewsManager.h:28
The base implementation of a configuration.
Definition: DtConfiguration.h:27
DtMouseHideProcessor tracks mouse move events and when they happen.
Definition: DtMouseHideProcessor.h:32
std::string myClassName
Definition: DtInputDriver.h:420
DtObserverController * myObserverController
Definition: DtInputDriver.h:415
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
DtKeyAndMouseEventListener * myKeyAndMouseEventListener
Definition: DtInputDriver.h:421
The DtEventProcessorInterface defines the generic interface for classes which handle input events...
Definition: DtEventProcessorInterface.h:37
KeyType
Enumerate the key types. These are based on Virtual Key Codes.
Definition: DtKeyState.h:28
KeyEventType
Enumerate the types of key events supported.
Definition: DtKeyEvent.h:23
bool mySyncingObservers
Definition: DtInputDriver.h:436
This class&#39;s main responsibility is to provide the functions used to control an observer.
Definition: DtObserverController.h:29
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtKeyAndMouseEventListener.h:25
std::list< DtObserverAnimator * > myAnimatingObservers
Definition: DtInputDriver.h:437

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)