VR-Vantage 2.5 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtObserver.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
11 
12 #include <vrvCore/DtElementData.h>
15 #include <matrix/vlVector.h>
16 
18 
19 
20 class DtTaitBryan;
21 
22 namespace makVrv
23 {
24  class DtObserverObjectAgent;
25  class DtDe;
26  class DtAgentManagerInterface;
27  class DtObserverConfiguration;
28  class DtSensor;
29  class DtOceanLayer;
30  class DtQuat;
31  class DtCameraShake;
32 
36  {
37  public:
38 
39  typedef std::vector<DtElementID> ElementList;
40 
42  DtObserver(DtDe& de, DtAgentManagerInterface& sceneInterface,
43  const DtObserverConfiguration& config );
44 
46  virtual ~DtObserver();
47 
49  inline DtDe& de()
50  {
51  return myDe;
52  }
53 
55  DtObserverObjectAgent& agent();
56 
58  const DtObserverObjectAgent& agent() const;
59 
60  //@name Saved View loading / setting functions.
62 
64  bool getRecord(makArchives::DtObserverStateRecord& recOut) const;
65 
67  void setFromRecord(const makArchives::DtObserverStateRecord& rec);
68 
70  bool getRecord(makArchives::DtObserverSettingsRecord& recOut) const;
71 
73  void setFromRecord(const makArchives::DtObserverSettingsRecord& rec);
74 
79  makArchives::DtObserverStateRecord getCachedObserverStateRecord() const;
80 
83  bool hasInitialLocation() const;
84 
86 
87 
88 
89 
90 
91 
92 
93 
94  bool projectionIs2D() const;
95  void setProjectionIs2D( bool is2d );
97 
99 
101  const std::string& name() const;
102  void setName( const std::string& name );
103 
108 
109  int observerMode() const;
110  void setObserverMode( int observerMode );
112 
114  double viewResolution() const;
115 
117  void setViewResolution( double resolution );
118 
120  double viewMagnification() const;
121 
123  void setViewMagnification( double magnficationFactor );
124 
125  DtObserverConfiguration& configuration();
126  const DtObserverConfiguration& configuration() const;
127 
129  bool inUse( const std::string& channelKeyToIgnore = "" ) const;
130 
131  //@name Attachment functions.
133 
135  void attachToNextElement();
136 
138  void attachToPreviousElement();
139 
141  bool isAttached(DtElementID) const;
142 
144  bool isPrimaryAttached(DtElementID) const;
145 
147  bool isSecondaryAttached(DtElementID) const;
148 
150 
151 
152 
153  void setPrimaryAttachment(const ElementList& elements);
154  void setPrimaryAttachment(DtElementID element);
156 
158 
159 
160 
161 
162  void setSecondaryAttachment(const ElementList& element);
163  void setSecondaryAttachment(DtElementID element);
165 
168  void setLocationTrackAttachment( double x, double y, double z );
169 
172  void getLocationTrackAttachment( double& x, double& y, double& z ) const;
173 
177  void setPartAttachment(int partId);
178 
180  int partAttachment() const;
181 
183  void detach();
184 
186  bool attached() const;
187 
189  bool tracking() const;
190 
192  const ElementList& primaryAttachments() const;
193 
195  const ElementList& secondaryAttachments() const;
196 
197  void setHideModelOnAttach( bool hide );
198  bool hideModelOnAttach() const;
199 
203 
204  void setAttachmentHas3DCockpit( bool cockpit);
205  bool attachmentHas3DCockpit() const;
207 
208  void setAttachType( DtObserverObject::AttachType type );
209  DtObserverObject::AttachType attachType() const;
210 
211  void setOrientToTargetConstraint( bool orient );
212  bool orientToTargetConstraint() const;
213 
216  DtElementID lastSingleAttached() const;
217 
219  bool haveLastSingleAttached() const;
220 
222 
223  //@name Movement functions
225 
228  void reset();
229 
232  void setAllowReset(bool b);
233 
235  bool allowReset() const;
236 
238  void setAllowAttach(bool b);
239 
241  bool allowAttach() const;
242 
244  void setAllowDetach(bool b);
245 
247  bool allowDetach() const;
248 
250  void centerOnTerrain();
251 
253  void centerOnTerrain( const DtUniqueID& terrainPatch );
254 
257  void suppressConstrainToTerrain( bool trueFalse );
258 
260  void setConstrainToCenter( bool trueFalse );
261  void toggleConstrainToCenter();
262  bool constrainToCenter() const;
263 
265  void getLocation( double &x, double &y, double& z ) const;
266 
268  DtVector location() const;
269 
271  DtVector observerCameraPosition() const;
272 
274  void setLocation( double x, double y, double z );
275 
277  void getOrientation( double& psi, double& theta, double& phi ) const;
278 
280  void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
281 
283  void setOrientation( double psi, double theta, double phi );
284 
286  void setTopographicOrientation( double psi, double theta, double phi );
287 
289  void getOrientation( double& x, double& y, double& z, double& w ) const;
290 
292  void setOrientation( double x, double y, double z, double w );
293 
296  DtTaitBryan observerCameraOrientation(bool includeShake=true) const;
297 
300  virtual DtVector observerPlatformFront() const;
301 
304  virtual DtVector observerPlatformUp() const;
305 
308  virtual DtVector observerPlatformRight() const;
309 
313  virtual DtVector observerCameraFront(bool includeShake=true) const;
314 
316  virtual DtVector observerCameraUp(bool includeShake = true) const;
317 
319  virtual DtVector observerCameraRight(bool includeShake = true) const;
320 
323  void moveUnit(const DtVector& direction);
324 
327  void rotateUnit(const DtTaitBryan& rotation);
328 
330 
331  void getLinearVelocity(double &x, double &y, double &z) const;
332  DtVector linearVelocity() const;
334 
336 
337  void getRotationalVelocity( double& x, double& y, double& z ) const;
338  DtVector rotationalVelocity() const;
340 
342  bool observerObjectMoving() const;
343 
345  double observerAltitude() const;
347 
348  //@name Attached Movement functions
350 
353  void setAttachedLocation( double x, double y, double z );
354 
357  void setAttachedOrientation( double psi, double theta, double phi );
358 
361  void setLocalModelScalingEnabled( bool enabled );
362 
365  void setLocalModelScalingAmount( float amount );
366 
368 
369  //@name Speed functions
371 
373  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
374 
376  int orbitSpeedGain() const;
377 
379  int orbitSpeedGainFromSpeed( double speed ) const;
380 
381  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
382  int rotationSpeedGain() const;
383 
385  void setLinearSpeedGain( int gain );
386  int linearSpeedGain() const;
387 
388  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
389  int linearScaledSpeedGain() const;
390 
391  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
392  int linearUnscaledSpeedGain() const;
393 
394  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
395  int gainPrecision() const;
396 
397  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
398  double modelScaleFactor() const;
399 
400  void setModelScaleType( const std::string& modelScaleType, bool forwardToObserverModeManager = true );
401  const std::string& modelScaleType() const;
402 
403  void setMaxModelScaleFactor(double maxModelScaleFactor, bool forwardToObserverModeManager = true);
404  double maxModelScaleFactor() const;
405 
406  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
407  bool forwardToObserverModeManager = true );
408  DtObserverObject::SpeedScalingMode speedScalingMode() const;
409 
410  void setSpeedScalingMslModeOffset( double offset,
411  bool forwardToObserverModeManager = true );
412  double speedScalingMslModeOffset() const;
413 
414  void setOrbitSpeed( double speed );
415  double orbitSpeed() const;
416 
417  void setRotationSpeed( double speed );
418  double rotationSpeed() const;
419 
420  void setLinearSpeed( double speed );
421  double linearSpeed() const;
422 
424 
426  virtual void toggleFlashlight();
427 
429  virtual DtCameraShake* cameraShake();
430 
432  virtual bool setCameraShake(const std::string& shakeType);
433 
436  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
437 
438  //@name Sensor functions
440 
441  virtual void setSensor(const std::string& sensorName);
442 
444  virtual std::string findSensor();
445 
447  virtual void disableSensor();
448 
450  virtual void slot_sensorRemoved(DtSensor* sensor);
452 
453  // Called by the input driver before any mouse or keyboard input is processed for the
454  // frame, to sync local and remote observers.
455  virtual void synchronize();
456 
458  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
459 
461  boost::signal<void(const std::string&)> signal_objectsDetached;
462 
464  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
465 
467  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
468 
470  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
471 
473  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
474 
476  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
477 
479  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
480 
482  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
483 
485  boost::signal<void(DtObserver*, std::string)> signal_modelScaleTypeChanged;
486 
488  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
489 
490 
492  boost::signal<void (DtObserver*,
495 
498  boost::signal<void (DtObserver*, double offset)>
500 
504  boost::signal<void (DtSensor*)> signal_sensorChanged;
505 
508  boost::signal<void ()> signal_terrainChanged;
509 
510  protected:
511 
513  void slot_terrainCleared();
514  void slot_oceanLayerAdded(const DtOceanLayer&);
515  void slot_oceanLayerDeleted(const std::string&);
516 
517  void updateGlobalTerrainFlag(bool flag);
518 
519  double calcLinearSpeed() const;
520  double calcRotationSpeed() const;
521  double calcOrbitSpeed() const;
522 
523  void getObserverOffsetVector( double& x, double& y, double& z ) const;
524  void setObserverOffsetVector( double x, double y, double z );
525 
526  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
527  void setObserverRotationOffset( double x, double y, double z, double w );
528 
529  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
530  std::set<std::string>& displayNamesOut) const;
531  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
532  std::vector<DtUniqueID>& idsOut) const;
533 
534  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
536  DtObserverObject::AttachType convertObserverSettingsAttachType(
538 
539  void connectToElementDataSignals();
540  void disconnectFromElementDataSignals();
541 
542  void setModeSpecificObserverObjectData();
543 
545  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
546 
548  virtual void slot_onElementAttributesChanged(
549  const DtElementData::EntryAttributesList& attributes );
550 
553  void slot_completeAttachment();
554 
555  void slot_observerModeModelSetChanged( int observerMode );
556  void slot_observerModeSensorChanged( int observerMode );
557  void slot_observerModeIs2DChanged( int observerMode );
558  void slot_observerModeKeyMapChanged( int observerMode );
559  void slot_observerModeGainPrecisionChanged( int observerMode );
560  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
561  void slot_observerModeRotationSpeedGainChanged( int observerMode );
562  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
563  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
564  void slot_observerModeModelScaleFactorChanged( int observerMode );
565  void slot_observerModeModelScaleTypeChanged( int observerMode );
566  void slot_observerModeSpeedScalingModeChanged( int observerMode );
567  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
568  void slot_observerModeSettingChanged( int observerMode, int settingKey );
569  void slot_observerModeAdded( int observerMode );
570 
572  void attachTo( bool afterTrue );
573 
574  protected:
575 
576  static const double theMoveStepSize;
577 
590  std::vector<DtUniqueID> myCurrentAttachments;
591  std::vector<DtUniqueID> mySecondaryAttachments;
593  unsigned int myPartId;
606  };
607 }


Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)