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) 2023 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 toggleEmbarkedEntityLabels();
274 
276  virtual void toggleRotateEntitySymbols();
277 
279  virtual void toggleTacticalGraphics();
280 
282  virtual void toggleEntityHatLines();
283 
285  virtual void toggleTacticalGraphicsHatLines();
287  virtual void toggleEntityHatMode();
288 
290  virtual void toggleTacticalGraphicsHatMode();
291 
293  virtual void toggleShowActiveTacticalGraphics();
294 
296  virtual void togglePropTransparencySelected();
297 
300  virtual void toggleViewControl();
301 
303  void resetObservers(DtUniqueID id);
304 
307  virtual void setAllowObserverReset(bool allow);
308  virtual bool allowObserverReset();
309 
313  virtual void setObserverRestoreOnSlaveConnectEnabled(bool enable);
314  virtual bool isObserverRestoreOnSlaveConnectEnabled();
315 
317  void saveObservers(const std::string& filename);
318 
322  void loadObservers(const std::string& filename, bool force = false);
323 
324  DtElementEntry::ObjectType typeFromId(const DtUniqueID& id);
325 
329  virtual void animateObserver(DtObserverAnimator* newAnimator);
330 
332  virtual void removeAnimatorFromObserver(DtObserver *observer);
333 
335  virtual void takeScreenCapture();
336 
338  virtual void toggleDeveloperDebugUI();
339 
341  const DtObserverViewsManager& observerViewsManager() const;
343  DtObserverViewsManager& observerViewsManager();
345 
347  bool getLastMouseEventPosition(int& x, int& y);
348 
350  DtChannel* lastMouseEventChannel() const;
351 
352  protected:
353 
354  void setCurrentObserver(DtObserver* observer);
355 
357  virtual void initializeKeyMapManager(const std::string& defaultKeyMap);
358  virtual void bindFunctions();
360  virtual void createMaps();
361 
364  virtual void loadMaps(bool loadFromFactory = false);
365 
367  typedef std::map<std::string, DtObserver*> ObserversMap;
368 
369  void removeObserver(ObserversMap& observers, DtObserver* observer);
370  void removeObserver(ObserversMap& observers, const std::string& name);
371 
372  void destroyObservers();
373 
374  bool setCurrentObserverFromChannel(const DtChannel& channel);
375 
376  void slot_channelCreated(DtChannelManager* channelManager, DtChannel* channel);
377  void slot_channelDestroyed(DtChannelManager* channelManager, DtChannel* channel);
378  void slot_channelConfigurationModified(const std::string& deName,
379  const std::string& winName, const std::string& oldChannelName,
380  const DtChannelConfiguration& config);
381  void slot_attachedToChanged(DtObserver* observer);
382 
383 
384  void createRequiredObservers(const std::string& engineName);
385 
387  virtual void slot_displayEngineAdded(const DtDeRecord& igRecord);
388 
392  std::string restoreObserversPart1();
393 
395  void restoreObserversPart2(const std::string& filename);
396 
397  virtual void slot_displayEngineRealized(const std::string&,
398  const std::string& engineName);
399 
403  bool trimmedMatch(DtObserver* observer);
404 
406  bool showObserverNameWarning();
407 
410  void setShowObserverNameWarning(bool warn);
411 
412  private:
415 
417  DtInputDriver& operator=(const DtInputDriver&);
418 
419  protected:
421 
423 
426 
429 
430  std::string myClassName;
432 
436 
439 
442 
445 
447 
449 
451  std::list<DtObserverAnimator*> myAnimatingObservers;
452 
453  // Pointer to the DtObserverViewsManager
455 
456  // Object used to hide mouse (if enabled) when mouse hasn't moved for some period
457  // of time
459 
461 
463  };
464 
468  {
469  public:
470 
473 
475  virtual ~DtInputDriverCreator();
476 
478  static DtInputDriverCreator& instance(DtDe& de);
479 
483  static void registerInstance(DtDe& de, DtInputDriverCreator* creator);
484 
486  virtual DtInputDriver* create(DtAgentManager& sm);
487 
488  };
489 
490 }
bool myShowObserverNameWarning
Definition: DtInputDriver.h:462
Creator class for the DtInputDriver.
Definition: DtInputDriver.h:467
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:367
ObserversMap myObservers
Definition: DtInputDriver.h:424
DtMouseHideProcessor * myMouseHideProcessor
Definition: DtInputDriver.h:458
ObserverStateMap myObserverStates
Definition: DtInputDriver.h:428
This class encapsulates a Key event.
Definition: DtKeyEvent.h:16
bool myIsTerrainContextEnabled
Switch to enable or disable terrain context menus;.
Definition: DtInputDriver.h:444
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:446
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:422
int myLastMouseEventPositionX
Definition: DtInputDriver.h:433
A DtObserverSettingsRecord contains the state of an observer.
Definition: DtObserverStateRecord.h:20
int myLastMouseEventPositionY
Definition: DtInputDriver.h:434
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:438
unsigned int ObjectType
Definition: DtElementEntry.h:54
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:420
#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:441
ObserverConfigurationMap myObserverConfigurations
Definition: DtInputDriver.h:427
Contains makVrv::DtKeyMapManager class.
bool myObserverRestoreOnSlaveConnectEnabled
Definition: DtInputDriver.h:460
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:448
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:454
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: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:430
DtObserverController * myObserverController
Definition: DtInputDriver.h:425
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:72
DtKeyAndMouseEventListener * myKeyAndMouseEventListener
Definition: DtInputDriver.h:431
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:450
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:435
std::list< DtObserverAnimator * > myAnimatingObservers
Definition: DtInputDriver.h:451

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)