VR-Vantage 2.7 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) 2020 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
9 
10 #pragma once
11 
13 #include <vrvCore/DtElementData.h>
16 #include <matrix/vlVector.h>
17 
19 
20 
21 class DtTaitBryan;
22 
23 namespace makVrv
24 {
25  class DtObserverObjectAgent;
26  class DtDe;
27  class DtAgentManagerInterface;
28  class DtObserverConfiguration;
29  class DtSensor;
30  class DtOceanLayer;
31  class DtQuat;
32  class DtCameraShake;
33  class DtChannelConfiguration;
34 
38  {
39  public:
40 
41  typedef std::vector<DtElementID> ElementList;
42 
44  DtObserver(DtDe& de, DtAgentManagerInterface& sceneInterface,
45  const DtObserverConfiguration& config );
46 
48  virtual ~DtObserver();
49 
51  inline DtDe& de()
52  {
53  return myDe;
54  }
55 
57  DtObserverObjectAgent& agent();
58 
60  const DtObserverObjectAgent& agent() const;
61 
62  //@name Saved View loading / setting functions.
64 
66  bool getRecord(makArchives::DtObserverStateRecord& recOut) const;
67 
69  void setFromRecord(const makArchives::DtObserverStateRecord& rec);
70 
72  bool getRecord(makArchives::DtObserverSettingsRecord& recOut) const;
73 
75  void setFromRecord(const makArchives::DtObserverSettingsRecord& rec);
76 
81  makArchives::DtObserverStateRecord getCachedObserverStateRecord() const;
82 
85  bool hasInitialLocation() const;
86 
88 
89 
90 
91 
92 
93 
94 
95 
96  bool projectionIs2D() const;
97  void setProjectionIs2D( bool is2d );
99 
101 
103  const std::string& name() const;
104  void setName( const std::string& name );
105 
115 
116  int observerMode() const;
117  bool setObserverMode( int observerMode );
119 
121  double viewResolution() const;
122 
124  void setViewResolution(double resolution);
125 
127  void setViewResolutionFromHeightAboveTerrain(double hat);
128 
130  double viewMagnification() const;
131 
133  void setViewMagnification(double magnficationFactor);
134 
136  void setLodScale(double lodScale);
137 
139  double lodScale() const;
140 
141  DtObserverConfiguration& configuration();
142  const DtObserverConfiguration& configuration() const;
143 
145  bool inUse( const std::string& channelKeyToIgnore = "" ) const;
146 
147  //@name Attachment functions.
149 
151  void attachToNextElement();
152 
154  void attachToPreviousElement();
155 
157  bool isAttached(DtElementID) const;
158 
160  bool isPrimaryAttached(DtElementID) const;
161 
163  bool isSecondaryAttached(DtElementID) const;
164 
166 
167 
168 
169  void setPrimaryAttachment(const ElementList& elements);
170  void setPrimaryAttachment(DtElementID element);
172 
174 
175 
176 
177 
178  void setSecondaryAttachment(const ElementList& element);
179  void setSecondaryAttachment(DtElementID element);
181 
184  void setLocationTrackAttachment( double x, double y, double z );
185 
188  void getLocationTrackAttachment( double& x, double& y, double& z ) const;
189 
193  void setPartAttachment(int partId);
194 
196  int partAttachment() const;
197 
199  void detach();
200 
202  bool attached() const;
203 
205  bool tracking() const;
206 
208  const ElementList& primaryAttachments() const;
209 
211  const ElementList& secondaryAttachments() const;
212 
213  void setHideModelOnAttach( bool hide );
214  bool hideModelOnAttach() const;
215 
219 
220  void setAttachmentHas3DCockpit( bool cockpit);
221  bool attachmentHas3DCockpit() const;
223 
224  void setAttachType( DtObserverObject::AttachType type );
225  DtObserverObject::AttachType attachType() const;
226 
227  void setOrientToTargetConstraint( bool orient );
228  bool orientToTargetConstraint() const;
229 
232  DtElementID lastSingleAttached() const;
233 
235  bool haveLastSingleAttached() const;
236 
238 
239  //@name Movement functions
241 
244  void reset();
245 
248  void setAllowReset(bool b);
249 
251  bool allowReset() const;
252 
254  void setAllowAttach(bool b);
255 
257  bool allowAttach() const;
258 
260  void setAllowDetach(bool b);
261 
263  bool allowDetach() const;
264 
266  void centerOnTerrain();
267 
269  void centerOnTerrain( const DtUniqueID& terrainPatch );
270 
273  void suppressConstrainToTerrain( bool trueFalse );
274 
276  void setConstrainToCenter( bool trueFalse );
277  void toggleConstrainToCenter();
278  bool constrainToCenter() const;
279 
281  void getLocation( double &x, double &y, double& z ) const;
282 
284  DtVector location() const;
285 
287  DtVector observerCameraPosition() const;
288 
290  void setLocation( double x, double y, double z );
291 
293  void getOrientation( double& psi, double& theta, double& phi ) const;
294 
296  void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
297 
299  void setOrientation( double psi, double theta, double phi );
300 
302  void setTopographicOrientation( double psi, double theta, double phi );
303 
305  void getOrientation( double& x, double& y, double& z, double& w ) const;
306 
308  void setOrientation( double x, double y, double z, double w );
309 
312  DtTaitBryan observerCameraOrientation(bool includeShake=true) const;
313 
316  virtual DtVector observerPlatformFront() const;
317 
320  virtual DtVector observerPlatformUp() const;
321 
324  virtual DtVector observerPlatformRight() const;
325 
329  virtual DtVector observerCameraFront(bool includeShake=true) const;
330 
332  virtual DtVector observerCameraUp(bool includeShake = true) const;
333 
335  virtual DtVector observerCameraRight(bool includeShake = true) const;
336 
339  void moveUnit(const DtVector& direction);
340 
343  void rotateUnit(const DtTaitBryan& rotation);
344 
346 
347  void getLinearVelocity(double &x, double &y, double &z) const;
348  DtVector linearVelocity() const;
350 
352 
353  void getRotationalVelocity( double& x, double& y, double& z ) const;
354  DtVector rotationalVelocity() const;
356 
358  bool observerObjectMoving() const;
359 
361  double observerAltitude() const;
363 
364  //@name Attached Movement functions
366 
369  void setAttachedLocation( double x, double y, double z );
370 
373  void setAttachedOrientation( double psi, double theta, double phi );
374 
377  void setLocalModelScalingEnabled( bool enabled );
378 
381  void setLocalModelScalingAmount( float amount );
382 
384 
385  //@name Speed functions
387 
389  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
390 
392  int orbitSpeedGain() const;
393 
395  int orbitSpeedGainFromSpeed( double speed ) const;
396 
397  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
398  int rotationSpeedGain() const;
399 
401  void setLinearSpeedGain( int gain );
402  int linearSpeedGain() const;
403 
404  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
405  int linearScaledSpeedGain() const;
406 
407  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
408  int linearUnscaledSpeedGain() const;
409 
410  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
411  int gainPrecision() const;
412 
413  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
414  double modelScaleFactor() const;
415 
416  void setModelScaleType( const std::string& modelScaleType, bool forwardToObserverModeManager = true );
417  const std::string& modelScaleType() const;
418 
419  void setMaxModelScaleFactor(double maxModelScaleFactor, bool forwardToObserverModeManager = true);
420  double maxModelScaleFactor() const;
421 
422  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
423  bool forwardToObserverModeManager = true );
424  DtObserverObject::SpeedScalingMode speedScalingMode() const;
425 
426  void setLodScaleCenterEnabled(bool enabled, bool forwardToObserverModeManager = true);
427  bool lodScaleCenterEnabled() const;
428 
429  void setLodScaleCenterMagMinLimit(double limit, bool forwardToObserverModeManager = true);
430  double lodScaleCenterMagMinLimit() const;
431 
433  void setNorthType(DtObserverObject::NorthType northType, bool forwardToObserverModeManager = true);
434 
436  DtObserverObject::NorthType DtObserver::northType() const;
437 
438  void setSpeedScalingMslModeOffset(double offset,
439  bool forwardToObserverModeManager = true );
440  double speedScalingMslModeOffset() const;
441 
442  void setOrbitSpeed( double speed );
443  double orbitSpeed() const;
444 
445  void setRotationSpeed( double speed );
446  double rotationSpeed() const;
447 
448  void setLinearSpeed( double speed );
449  double linearSpeed() const;
450 
452 
454  virtual void toggleFlashlight();
455 
457  virtual DtCameraShake* cameraShake();
458 
460  virtual bool setCameraShake(const std::string& shakeType);
461 
464  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
465 
466  //@name Sensor functions
468 
469  virtual void setSensor(const std::string& sensorName);
470 
472  virtual std::string findSensor();
473 
475  virtual void disableSensor();
476 
478  virtual void slot_sensorRemoved(DtSensor* sensor);
480 
481  // Called by the input driver before any mouse or keyboard input is processed for the
482  // frame, to sync local and remote observers.
483  virtual void synchronize();
484 
486  boost::signalslib::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
487 
489  boost::signalslib::signal<void(const std::string&)> signal_objectsDetached;
490 
492  boost::signalslib::signal<void(DtObserver*, int)> signal_observerModeChanged;
493 
495  boost::signalslib::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
496 
498  boost::signalslib::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
499 
501  boost::signalslib::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
502 
504  boost::signalslib::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
505 
507  boost::signalslib::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
508 
510  boost::signalslib::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
511 
513  boost::signalslib::signal<void(DtObserver*, std::string)> signal_modelScaleTypeChanged;
514 
516  boost::signalslib::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
517 
519  boost::signalslib::signal<void(DtObserver*, double)> signal_lodScaleChanged;
520 
521 
523  boost::signalslib::signal<void (DtObserver*,
526 
529  boost::signalslib::signal<void (DtObserver*, double offset)>
531 
533  boost::signalslib::signal<void(DtObserver*, bool)> signal_lodScaleCenterEnabledChanged;
534 
536  boost::signalslib::signal<void(DtObserver*, double)> signal_lodScaleCenterMagMinLimitChanged;
537 
539  boost::signalslib::signal<void(DtObserver*, DtObserverObject::NorthType northType)>
541 
545  boost::signalslib::signal<void (DtSensor*)> signal_sensorChanged;
546 
549  boost::signalslib::signal<void ()> signal_terrainChanged;
550 
552  void getObserverOffsetVector( double& x, double& y, double& z ) const;
553  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
554 
557 
558  void getCameraFromParentOffsetVector( double& x, double& y, double& z ) const;
559  void getCameraFromParentRotationOffset( double& x, double& y, double& z, double& w ) const;
561  protected:
562 
564  void slot_terrainCleared();
565  void slot_oceanLayerAdded(const DtOceanLayer&);
566  void slot_oceanLayerDeleted(const std::string&);
567 
568  void updateGlobalTerrainFlag(bool flag);
569 
570  double calcLinearSpeed() const;
571  double calcRotationSpeed() const;
572  double calcOrbitSpeed() const;
573 
574  void setObserverOffsetVector( double x, double y, double z );
575 
576  void setObserverRotationOffset( double x, double y, double z, double w );
577 
578  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
579  std::set<std::string>& displayNamesOut) const;
580  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
581  std::vector<DtUniqueID>& idsOut) const;
582 
583  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
585  DtObserverObject::AttachType convertObserverSettingsAttachType(
587 
588  void connectToElementDataSignals();
589  void disconnectFromElementDataSignals();
590 
591  void setModeSpecificObserverObjectData();
592 
594  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
595 
597  virtual void slot_onElementAttributesChanged(
599 
602  void slot_completeAttachment();
603 
604  void slot_observerModeModelSetChanged( int observerMode );
605  void slot_observerModeSensorChanged( int observerMode );
606  void slot_observerModeIs2DChanged( int observerMode );
607  void slot_observerModeKeyMapChanged( int observerMode );
608  void slot_observerModeGainPrecisionChanged( int observerMode );
609  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
610  void slot_observerModeRotationSpeedGainChanged( int observerMode );
611  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
612  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
613  void slot_observerModeModelScaleFactorChanged( int observerMode );
614  void slot_observerModeModelScaleTypeChanged( int observerMode );
615  void slot_observerModeSpeedScalingModeChanged( int observerMode );
616  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
617  void slot_observerModeLodScaleCenterEnabledChanged(int observerMode);
618  void slot_observerModeLodScaleCenterMagMinLimitChanged(int observerMode);
619  void slot_observerModeNorthTypeChanged(int observerMode);
620  void slot_observerModeSettingChanged(int observerMode, int settingKey);
621  void slot_observerModeAdded( int observerMode );
622 
623  // Called when the DE raises the channel configuration modified signal. If a channel
624  // config has it's lod scale modified, the observer will modify all the other channels that
625  // it controls to keep them in sync.
626  void slot_channelModified(const DtChannelConfiguration& config);
627 
629  void attachTo( bool afterTrue );
630 
631  protected:
632 
633  static const double theMoveStepSize;
634 
647  std::vector<DtUniqueID> myCurrentAttachments;
648  std::vector<DtUniqueID> mySecondaryAttachments;
650  unsigned int myPartId;
660  float myLodScale;
664  };
665 }


Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)