VR-Forces 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) 2025 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
12 #include <vrvCore/DtDriver.h>
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 DtWindow;
37  class DtChannelConfiguration;
38  class DtObserverAnimator;
39  class DtObserverViewsManager;
40  class DtMouseHideProcessor;
41 
46  {
47  public:
50  typedef std::list<DtEventProcessorInterface*> EventProcessorList;
51 
53  typedef std::map<std::string, makArchives::DtObserverStateRecord> ObserverStateMap;
54 
56  typedef std::map<std::string, DtObserverConfiguration> ObserverConfigurationMap;
57 
59  DtInputDriver(DtAgentManager& agentManager,
60  const std::string& instanceName);
61 
63  virtual ~DtInputDriver();
64 
66  virtual bool onStart();
67 
69  virtual bool onStop();
70 
72  virtual bool onTick();
73 
75  virtual const std::string& className() const;
76 
78  virtual bool processKeyEvent(const DtKeyEvent& keyEvent,
79  DtChannel* channel);
80 
82  virtual bool processMouseEvent(const DtMouseEvent& mouseEvent,
83  DtChannel* channel);
84 
85  virtual bool processPinchGesture(const DtPinchGesture& pinchGesture,
86  DtChannel* channel);
87 
89  // hides the mouse if it hasn't moved for some period of time
90  virtual void setMouseHideProccessorEnabled(bool enabled);
91 
93  virtual void hideMouse(DtChannel* channel, float mouseX, float mouseY);
94 
96  virtual bool isMouseHidden() const;
97 
99  virtual void showMouse(DtChannel* channel);
100 
102  virtual void centerMouse(DtChannel* channel);
103 
105  virtual void setMousePosition(DtChannel* channel, float x, float y);
106 
109  virtual void clearState();
110 
112  DtChannel* currentChannel() const;
120  virtual DtChannel* findCurrentChannel() const;
122 
125  virtual void addEventProcessorToFront(DtEventProcessorInterface* epi);
126 
131  virtual void addEventProcessorToBack(DtEventProcessorInterface* epi);
132 
136  virtual EventProcessorList& eventProcessorList();
137 
140  virtual DtEventProcessorInterface* findEventProcessor(
141  const std::string& className);
142 
147  virtual void removeEventProcessor(DtEventProcessorInterface* epi);
148 
150  bool saveKeyMapToFile(const DtKeyMap& keyMap, const std::string& filename) const;
151 
154  DtKeyMap* loadKeyMapFromFile(const std::string& filename, bool createBackup = false);
155 
157  //
160  void setKeyMap(const std::string& mapName);
161 
163  const std::string& keyMap() const;
164 
166  DtKeyMap* createKeyMap(const std::string& mapName);
167 
169  DtKeyMap* findKeyMap(const std::string& mapName);
170 
172  void addKeyBinding(DtKeyMap* map, DtKeyState::KeyType key,
173  const std::string& functionName,
175  bool replace = false,
177 
180  void addBinaryKeyBinding(DtKeyMap* map, DtKeyState::KeyType key,
181  const std::string& binaryName,
183  bool replace = false);
184 
186  virtual void realizeConfiguration(
187  const DtConfiguration& configuration);
188 
189  virtual void realizeObserverConfiguration(
190  const DtObserverConfiguration& configuration);
191 
192  const ObserverConfigurationMap& observerConfigurations() const;
193 
200  void addObserverConfiguration(const DtObserverConfiguration& config);
201 
204  void addObserverState(const std::string& observerName,
205  const makArchives::DtObserverStateRecord& stateRecord);
206 
210  void initializeObserver(DtObserver* observer,
211  const makArchives::DtObserverStateRecord& stateRecord);
212 
213  //-----
215 
217  virtual void addObserver(DtObserver* observer);
218 
220  virtual void removeObserver(DtObserver* observer);
221 
223  virtual void removeObserver(const std::string& name);
224 
226  virtual std::vector<DtObserver*> observers() const;
227 
229  virtual DtObserver* findObserverByName(const std::string& name);
231  virtual const DtObserver* findObserverByName(const std::string& name) const;
233 
235  virtual void setCurrentObserver(const std::string& observerName);
236 
238  DtObserver* currentObserver() const;
244  virtual DtObserver* findCurrentObserver() const;
246 
248  void setTerrainContextEnabled(bool enabled);
249  bool terrainContextEnabled() const;
250 
252 
254  virtual void performObserverAction(const DtViewStateProcessor::ObserverAction& action);
255 
257  virtual void toggleTerrainScaling();
258 
260  virtual void toggleWireframe();
261 
263  virtual void toggleSimulationTimePaused();
264 
266  virtual void incrementTerrainScaleFactor();
267 
269  virtual void decrementTerrainScaleFactor();
270 
272  virtual void toggleEntityLabels();
273 
275  virtual void toggleEmbarkedEntityLabels();
276 
278  virtual void toggleRotateEntitySymbols();
279 
281  virtual void toggleTacticalGraphics();
282 
284  virtual void toggleEntityHatLines();
285 
287  virtual void toggleTacticalGraphicsHatLines();
289  virtual void toggleEntityHatMode();
290 
292  virtual void toggleTacticalGraphicsHatMode();
293 
295  virtual void toggleShowActiveTacticalGraphics();
296 
298  virtual void togglePropTransparencySelected();
299 
302  virtual void toggleViewControl();
303 
305  virtual void clearAllTrackHistories();
306 
308  void resetObservers(DtUniqueID id);
309 
312  virtual void setAllowObserverReset(bool allow);
313  virtual bool allowObserverReset();
314 
318  virtual void setObserverRestoreOnSlaveConnectEnabled(bool enable);
319  virtual bool isObserverRestoreOnSlaveConnectEnabled();
320 
322  void saveObservers(const std::string& filename);
323 
327  void loadObservers(const std::string& filename, bool force = false);
328 
329  DtElementEntry::ObjectType typeFromId(const DtUniqueID& id);
330 
334  virtual void animateObserver(DtObserverAnimator* newAnimator);
335 
337  virtual void removeAnimatorFromObserver(DtObserver *observer);
338 
340  virtual void takeScreenCapture();
341 
343  virtual void toggleDeveloperDebugUI();
344 
346  const DtObserverViewsManager& observerViewsManager() const;
348  DtObserverViewsManager& observerViewsManager();
350 
352  bool getLastMouseEventPosition(int& x, int& y);
353 
355  DtChannel* lastMouseEventChannel() const;
356 
357  protected:
358 
359  void setCurrentObserver(DtObserver* observer);
360 
362  virtual void initializeKeyMapManager(const std::string& defaultKeyMap);
363  virtual void bindFunctions();
365  virtual void createMaps();
366 
369  virtual void loadMaps(bool loadFromFactory = false);
370 
372  typedef std::map<std::string, DtObserver*> ObserversMap;
373 
374  void removeObserver(ObserversMap& observers, DtObserver* observer);
375  void removeObserver(ObserversMap& observers, const std::string& name);
376 
377  void destroyObservers();
378 
379  bool setCurrentObserverFromChannel(const DtChannel& channel);
380 
381  void slot_channelCreated(DtChannelManager* channelManager, DtChannel* channel);
382  void slot_channelDestroyed(DtChannelManager* channelManager, DtChannel* channel);
383  void slot_windowToBeDestroyed(DtWindow*);
384  void slot_channelConfigurationModified(const std::string& deName,
385  const std::string& winName, const std::string& oldChannelName,
386  const DtChannelConfiguration& config);
387  void slot_attachedToChanged(DtObserver* observer);
388 
389 
390  void createRequiredObservers(const std::string& engineName);
391 
393  virtual void slot_displayEngineAdded(const DtDeRecord& igRecord);
394 
398  std::string restoreObserversPart1();
399 
401  void restoreObserversPart2(const std::string& filename);
402 
403  virtual void slot_displayEngineRealized(const std::string&,
404  const std::string& engineName);
405 
409  bool trimmedMatch(DtObserver* observer);
410 
412  bool showObserverNameWarning();
413 
416  void setShowObserverNameWarning(bool warn);
417 
418  private:
421 
423  DtInputDriver& operator=(const DtInputDriver&);
424 
425  protected:
427 
429 
432 
435 
436  std::string myClassName;
438 
440 
444 
447 
450 
453 
455 
457 
459  std::list<DtObserverAnimator*> myAnimatingObservers;
460 
461  // Pointer to the DtObserverViewsManager
463 
464  // Object used to hide mouse (if enabled) when mouse hasn't moved for some period
465  // of time
467 
469 
471  };
472 
476  {
477  public:
478 
481 
483  virtual ~DtInputDriverCreator();
484 
486  static DtInputDriverCreator& instance(DtDe& de);
487 
491  static void registerInstance(DtDe& de, DtInputDriverCreator* creator);
492 
494  virtual DtInputDriver* create(DtAgentManager& sm);
495 
496  };
497 
498 }
bool myShowObserverNameWarning
Definition: DtInputDriver.h:470
Creator class for the DtInputDriver.
Definition: DtInputDriver.h:475
Abstract Base class.
Definition: DtWindow.h:25
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:372
ObserversMap myObservers
Definition: DtInputDriver.h:430
DtMouseHideProcessor * myMouseHideProcessor
Definition: DtInputDriver.h:466
ObserverStateMap myObserverStates
Definition: DtInputDriver.h:434
This class encapsulates a Key event.
Definition: DtKeyEvent.h:16
bool myIsTerrainContextEnabled
Switch to enable or disable terrain context menus;.
Definition: DtInputDriver.h:452
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:454
std::list< DtEventProcessorInterface * > EventProcessorList
A list of DtEventProcessorInterface, called in order for each event until one handles it...
Definition: DtInputDriver.h:50
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:56
Contains makVrv::DtObserverConfiguration class.
EventProcessorList myEventProcessors
Definition: DtInputDriver.h:428
int myLastMouseEventPositionX
Definition: DtInputDriver.h:441
A DtObserverSettingsRecord contains the state of an observer.
Definition: DtObserverStateRecord.h:20
int myLastMouseEventPositionY
Definition: DtInputDriver.h:442
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:53
DtObserver * myCurrentObserver
Temp, so we can look this up ONCE each event.
Definition: DtInputDriver.h:446
unsigned int ObjectType
Definition: DtElementEntry.h:54
The manager for owning key maps.
Definition: DtKeyMapManager.h:31
The abstract Channel Class.
Definition: DtChannel.h:35
A facade for a DtObserverObject.
Definition: DtObserver.h:38
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:426
#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:45
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
bool myAllowResetFlag
Control whether observers can be reset.
Definition: DtInputDriver.h:449
ObserverConfigurationMap myObserverConfigurations
Definition: DtInputDriver.h:433
Contains makVrv::DtKeyMapManager class.
bool myObserverRestoreOnSlaveConnectEnabled
Definition: DtInputDriver.h:468
The DtAgentManager manages the distributed scene object framework. This includes the objects and upda...
Definition: DtAgentManager.h:38
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
Contains makVrv:DtDriver class.
DtKeyMapManager & myCachedKeyMapManager
Definition: DtInputDriver.h:456
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:462
Contains makArchives::DtObserverStateRecord class.
Encapsulates the process of animating an observer to a given location. The animator will smoothly mov...
Definition: DtObserverAnimator.h:40
Base class to provide boost signal/slot management.
Configuration for a single channel Serialized and sent to remote displays as necessary to configure r...
Definition: DtChannelConfiguration.h:24
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:436
DtObserverController * myObserverController
Definition: DtInputDriver.h:431
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:76
DtKeyAndMouseEventListener * myKeyAndMouseEventListener
Definition: DtInputDriver.h:437
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
DtSignalConnectionManager myConnections
Definition: DtInputDriver.h:439
bool mySyncingObservers
Definition: DtInputDriver.h:458
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:443
std::list< DtObserverAnimator * > myAnimatingObservers
Definition: DtInputDriver.h:459

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)