VR-Forces 5.0.1 Developer's Guide
 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) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
12 #include <vrvCore/DtDriver.h>
16 
17 #include <string>
18 #include <vector>
19 
20 namespace makVrv
21 {
22  class DtAgentManager;
23  class DtChannel;
24  class DtChannelManager;
25  class DtDe;
26  class DtEventProcessorInterface;
27  class DtInputDriverConfiguration;
28  class DtKeyAndMouseEventListener;
29  class DtKeyMap;
30  class DtKeyMapManager;
31  class DtMouseEvent;
32  class DtPinchGesture;
33  class DtObserver;
34  class DtObserverController;
35  class DtChannelConfiguration;
36  class DtObserverAnimator;
37  class DtObserverViewsManager;
38  class DtMouseHideProcessor;
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  // hides the mouse if it hasn't moved for some period of time
88  virtual void setMouseHideProccessorEnabled(bool enabled);
89 
91  virtual void hideMouse(DtChannel* channel, float mouseX, float mouseY);
92 
94  virtual bool isMouseHidden() const;
95 
97  virtual void showMouse(DtChannel* channel);
98 
100  virtual void centerMouse(DtChannel* channel);
101 
103  virtual void setMousePosition(DtChannel* channel, float x, float y);
104 
107  virtual void clearState();
108 
110  DtChannel* currentChannel() const;
118  virtual DtChannel* findCurrentChannel() const;
120 
123  virtual void addEventProcessorToFront(DtEventProcessorInterface* epi);
124 
129  virtual void addEventProcessorToBack(DtEventProcessorInterface* epi);
130 
134  virtual EventProcessorList& eventProcessorList();
135 
138  virtual DtEventProcessorInterface* findEventProcessor(
139  const std::string& className);
140 
145  virtual void removeEventProcessor(DtEventProcessorInterface* epi);
146 
148  bool saveKeyMapToFile(const DtKeyMap& keyMap, const std::string& filename) const;
149 
152  DtKeyMap* loadKeyMapFromFile(const std::string& filename, bool createBackup = false);
153 
155  //
158  void setKeyMap(const std::string& mapName);
159 
161  const std::string& keyMap() const;
162 
164  DtKeyMap* createKeyMap(const std::string& mapName);
165 
167  DtKeyMap* findKeyMap(const std::string& mapName);
168 
170  void addKeyBinding(DtKeyMap* map, DtKeyState::KeyType key,
171  const std::string& functionName,
173  bool replace = false,
175 
178  void addBinaryKeyBinding(DtKeyMap* map, DtKeyState::KeyType key,
179  const std::string& binaryName,
181  bool replace = false);
182 
184  virtual void realizeConfiguration(
185  const DtConfiguration& configuration);
186 
187  virtual void realizeObserverConfiguration(
188  const DtObserverConfiguration& configuration);
189 
190  const ObserverConfigurationMap& observerConfigurations() const;
191 
198  void addObserverConfiguration(const DtObserverConfiguration& config);
199 
202  void addObserverState(const std::string& observerName,
203  const makArchives::DtObserverStateRecord& stateRecord);
204 
208  void initializeObserver(DtObserver* observer,
209  const makArchives::DtObserverStateRecord& stateRecord);
210 
211  //-----
213 
215  virtual void addObserver(DtObserver* observer);
216 
218  virtual void removeObserver(DtObserver* observer);
219 
221  virtual void removeObserver(const std::string& name);
222 
224  virtual std::vector<DtObserver*> observers() const;
225 
227  virtual DtObserver* findObserverByName(const std::string& name);
229  virtual const DtObserver* findObserverByName(const std::string& name) const;
231 
233  virtual void setCurrentObserver(const std::string& observerName);
234 
236  DtObserver* currentObserver() const;
242  virtual DtObserver* findCurrentObserver() const;
244 
246  void setTerrainContextEnabled(bool enabled);
247  bool terrainContextEnabled() const;
248 
250 
252  virtual void performObserverAction(const DtViewStateProcessor::ObserverAction& action);
253 
255  virtual void toggleTerrainScaling();
256 
258  virtual void toggleWireframe();
259 
261  virtual void toggleSimulationTimePaused();
262 
264  virtual void incrementTerrainScaleFactor();
265 
267  virtual void decrementTerrainScaleFactor();
268 
270  virtual void toggleEntityLabels();
271 
273  virtual void toggleRotateEntitySymbols();
274 
276  virtual void toggleTacticalGraphics();
277 
279  virtual void toggleEntityHatLines();
280 
282  virtual void toggleTacticalGraphicsHatLines();
284  virtual void toggleEntityHatMode();
285 
287  virtual void toggleTacticalGraphicsHatMode();
288 
290  virtual void togglePropTransparencySelected();
291 
294  virtual void toggleViewControl();
295 
297  void resetObservers(DtUniqueID id);
298 
301  virtual void setAllowObserverReset(bool allow);
302  virtual bool allowObserverReset();
303 
307  virtual void setObserverRestoreOnSlaveConnectEnabled(bool enable);
308  virtual bool isObserverRestoreOnSlaveConnectEnabled();
309 
311  void saveObservers(const std::string& filename);
312 
316  void loadObservers(const std::string& filename, bool force = false);
317 
318  DtElementEntry::ObjectType typeFromId(const DtUniqueID& id);
319 
323  virtual void animateObserver(DtObserverAnimator* newAnimator);
324 
326  virtual void removeAnimatorFromObserver(DtObserver *observer);
327 
329  virtual void takeScreenCapture();
330 
332  virtual void toggleDeveloperDebugUI();
333 
335  const DtObserverViewsManager& observerViewsManager() const;
337  DtObserverViewsManager& observerViewsManager();
339 
341  bool getLastMouseEventPosition(int& x, int& y);
342 
344  DtChannel* lastMouseEventChannel() const;
345 
346  protected:
347 
348  void setCurrentObserver(DtObserver* observer);
349 
351  virtual void initializeKeyMapManager(const std::string& defaultKeyMap);
352  virtual void bindFunctions();
354  virtual void createMaps();
355 
358  virtual void loadMaps(bool loadFromFactory = false);
359 
361  typedef std::map<std::string, DtObserver*> ObserversMap;
362 
363  void removeObserver(ObserversMap& observers, DtObserver* observer);
364  void removeObserver(ObserversMap& observers, const std::string& name);
365 
366  void destroyObservers();
367 
368  bool setCurrentObserverFromChannel(const DtChannel& channel);
369 
370  void slot_channelCreated(DtChannelManager* channelManager, DtChannel* channel);
371  void slot_channelDestroyed(DtChannelManager* channelManager, DtChannel* channel);
372  void slot_channelConfigurationModified(const std::string& deName,
373  const std::string& winName, const std::string& oldChannelName,
374  const DtChannelConfiguration& config);
375  void slot_attachedToChanged(DtObserver* observer);
376 
377 
378  void createRequiredObservers(const std::string& engineName);
379 
381  virtual void slot_displayEngineAdded(const DtDeRecord& igRecord);
382 
386  std::string restoreObserversPart1();
387 
389  void restoreObserversPart2(const std::string& filename);
390 
391  virtual void slot_displayEngineRealized(const std::string&,
392  const std::string& engineName);
393 
397  bool trimmedMatch(DtObserver* observer);
398 
400  bool showObserverNameWarning();
401 
404  void setShowObserverNameWarning(bool warn);
405 
406  private:
409 
411  DtInputDriver& operator=(const DtInputDriver&);
412 
413  protected:
415 
417 
420 
423 
424  std::string myClassName;
426 
430 
433 
436 
439 
441 
443 
445  std::list<DtObserverAnimator*> myAnimatingObservers;
446 
447  // Pointer to the DtObserverViewsManager
449 
450  // Object used to hide mouse (if enabled) when mouse hasn't moved for some period
451  // of time
453 
455 
457  };
458 
462  {
463  public:
464 
467 
469  virtual ~DtInputDriverCreator();
470 
472  static DtInputDriverCreator& instance(DtDe& de);
473 
477  static void registerInstance(DtDe& de, DtInputDriverCreator* creator);
478 
480  virtual DtInputDriver* create(DtAgentManager& sm);
481 
482  };
483 
484 }
bool myShowObserverNameWarning
Definition: DtInputDriver.h:456
Creator class for the DtInputDriver.
Definition: DtInputDriver.h:461
boost::function< void(DtObserver &)> ObserverAction
Definition: DtViewStateProcessor.h:29
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
std::map< std::string, DtObserver * > ObserversMap
Observer Manager bound.
Definition: DtInputDriver.h:361
ObserversMap myObservers
Definition: DtInputDriver.h:418
DtMouseHideProcessor * myMouseHideProcessor
Definition: DtInputDriver.h:452
ObserverStateMap myObserverStates
Definition: DtInputDriver.h:422
This class encapsulates a Key event.
Definition: DtKeyEvent.h:16
bool myIsTerrainContextEnabled
Switch to enable or disable terrain context menus;.
Definition: DtInputDriver.h:438
TODO: This class is used to encapsulate a set of default observer settings and parameters.
Definition: DtObserverConfiguration.h:22
DtPinchGesture represents a Pinch Multitouch Gesture. Instances of the DtPinchGesture class are used ...
Definition: DtPinchGesture.h:26
DtChannel * myCurrentChannel
Definition: DtInputDriver.h:440
std::list< DtEventProcessorInterface * > EventProcessorList
A list of DtEventProcessorInterface, called in order for each event until one handles it...
Definition: DtInputDriver.h:48
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:54
Contains makVrv::DtObserverConfiguration class.
EventProcessorList myEventProcessors
Definition: DtInputDriver.h:416
int myLastMouseEventPositionX
Definition: DtInputDriver.h:427
A DtObserverSettingsRecord contains the state of an observer.
Definition: DtObserverStateRecord.h:20
int myLastMouseEventPositionY
Definition: DtInputDriver.h:428
This class encapsulates a mouse button event.
Definition: DtMouseEvent.h:19
a Key Map contains a map of keys to FunctionMapEntrys, as well as a list of functions to execute when...
Definition: DtKeyMap.h:312
KeyModifier
Describe which modifier(s) are pressed.
Definition: DtKeyState.h:136
Definition: DtKeyEvent.h:22
std::map< std::string, makArchives::DtObserverStateRecord > ObserverStateMap
A map of observer names, to DtObserverStateRecords.
Definition: DtInputDriver.h:51
DtObserver * myCurrentObserver
Temp, so we can look this up ONCE each event.
Definition: DtInputDriver.h:432
unsigned int ObjectType
Definition: DtElementEntry.h:51
The manager for owning key maps.
Definition: DtKeyMapManager.h:32
The abstract Channel Class.
Definition: DtChannel.h:35
A facade for a DtObserverObject.
Definition: DtObserver.h:37
The DtDriver is an abstract class. Developers derive from this to create logic that &quot;directs&quot; things ...
Definition: DtDriver.h:31
DtDe & myDe
Definition: DtInputDriver.h:414
#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:43
bool myAllowResetFlag
Control whether observers can be reset.
Definition: DtInputDriver.h:435
ObserverConfigurationMap myObserverConfigurations
Definition: DtInputDriver.h:421
Contains makVrv::DtKeyMapManager class.
bool myObserverRestoreOnSlaveConnectEnabled
Definition: DtInputDriver.h:454
The DtAgentManager manages the distributed scene object framework. This includes the objects and upda...
Definition: DtAgentManager.h:38
Contains makVrv:DtDriver class.
DtKeyMapManager & myCachedKeyMapManager
Definition: DtInputDriver.h:442
Definition: DtKeyState.h:137
Base class for handling DtChannels. Derived classes should override the tick() method and advance the...
Definition: DtChannelManager.h:32
DtObserverViewsManager * myObserverViewsManager
Definition: DtInputDriver.h:448
Contains makArchives::DtObserverStateRecord class.
Encapsulates the process of animating an observer to a given location. The animator will smoothly mov...
Definition: DtObserverAnimator.h:39
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:24
DtMouseHideProcessor tracks mouse move events and when they happen. If a mouse move event does not ha...
Definition: DtMouseHideProcessor.h:32
std::string myClassName
Definition: DtInputDriver.h:424
DtObserverController * myObserverController
Definition: DtInputDriver.h:419
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
DtKeyAndMouseEventListener * myKeyAndMouseEventListener
Definition: DtInputDriver.h:425
The DtEventProcessorInterface defines the generic interface for classes which handle input events...
Definition: DtEventProcessorInterface.h:34
KeyType
Enumerate the key types. These are based on Virtual Key Codes.
Definition: DtKeyState.h:25
KeyEventType
Enumerate the types of key events supported.
Definition: DtKeyEvent.h:20
bool mySyncingObservers
Definition: DtInputDriver.h:444
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
DtChannel * myLastMouseEventChannel
Definition: DtInputDriver.h:429
std::list< DtObserverAnimator * > myAnimatingObservers
Definition: DtInputDriver.h:445

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)