VR-Vantage 2.8 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 
142  void setPaperMapLayer(std::string paperMapLayer);
143 
145  std::string paperMapLayer() const;
146 
147  DtObserverConfiguration& configuration();
148  const DtObserverConfiguration& configuration() const;
149 
151  bool inUse( const std::string& channelKeyToIgnore = "" ) const;
152 
153  //@name Attachment functions.
155 
157  void attachToNextElement();
158 
160  void attachToPreviousElement();
161 
163  bool isAttached(DtElementID) const;
164 
166  bool isPrimaryAttached(DtElementID) const;
167 
169  bool isSecondaryAttached(DtElementID) const;
170 
172 
173 
174 
175  void setPrimaryAttachment(const ElementList& elements);
176  void setPrimaryAttachment(DtElementID element);
178 
180 
181 
182 
183 
184  void setSecondaryAttachment(const ElementList& element);
185  void setSecondaryAttachment(DtElementID element);
187 
190  void setLocationTrackAttachment( double x, double y, double z );
191 
194  void getLocationTrackAttachment( double& x, double& y, double& z ) const;
195 
199  void setPartAttachment(int partId);
200 
202  int partAttachment() const;
203 
205  void detach();
206 
208  bool attached() const;
209 
211  bool tracking() const;
212 
214  const ElementList& primaryAttachments() const;
215 
217  const ElementList& secondaryAttachments() const;
218 
219  void setHideModelOnAttach( bool hide );
220  bool hideModelOnAttach() const;
221 
225 
226  void setAttachmentHas3DCockpit( bool cockpit);
227  bool attachmentHas3DCockpit() const;
229 
230  void setAttachType( DtObserverObject::AttachType type );
231  DtObserverObject::AttachType attachType() const;
232 
233  void setOrientToTargetConstraint( bool orient );
234  bool orientToTargetConstraint() const;
235 
238  DtElementID lastSingleAttached() const;
239 
241  bool haveLastSingleAttached() const;
242 
244 
245  //@name Movement functions
247 
250  void reset();
251 
254  void setAllowReset(bool b);
255 
257  bool allowReset() const;
258 
260  void setAllowAttach(bool b);
261 
263  bool allowAttach() const;
264 
266  void setAllowDetach(bool b);
267 
269  bool allowDetach() const;
270 
272  void centerOnTerrain();
273 
275  void centerOnTerrain( const DtUniqueID& terrainPatch );
276 
279  void suppressConstrainToTerrain( bool trueFalse );
280 
282  void setConstrainToCenter( bool trueFalse );
283  void toggleConstrainToCenter();
284  bool constrainToCenter() const;
285 
287  void getLocation( double &x, double &y, double& z ) const;
288 
290  DtVector location() const;
291 
293  DtVector observerCameraPosition() const;
294 
296  void setLocation( double x, double y, double z );
297 
299  void getOrientation( double& psi, double& theta, double& phi ) const;
300 
302  void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
303 
305  void setOrientation( double psi, double theta, double phi );
306 
308  void setTopographicOrientation( double psi, double theta, double phi );
309 
311  void getOrientation( double& x, double& y, double& z, double& w ) const;
312 
314  void setOrientation( double x, double y, double z, double w );
315 
318  DtTaitBryan observerCameraOrientation(bool includeShake=true) const;
319 
322  virtual DtVector observerPlatformFront() const;
323 
326  virtual DtVector observerPlatformUp() const;
327 
330  virtual DtVector observerPlatformRight() const;
331 
335  virtual DtVector observerCameraFront(bool includeShake=true) const;
336 
338  virtual DtVector observerCameraUp(bool includeShake = true) const;
339 
341  virtual DtVector observerCameraRight(bool includeShake = true) const;
342 
345  void moveUnit(const DtVector& direction);
346 
349  void rotateUnit(const DtTaitBryan& rotation);
350 
352 
353  void getLinearVelocity(double &x, double &y, double &z) const;
354  DtVector linearVelocity() const;
356 
358 
359  void getRotationalVelocity( double& x, double& y, double& z ) const;
360  DtVector rotationalVelocity() const;
362 
364  bool observerObjectMoving() const;
365 
367  double observerAltitude() const;
369 
370  //@name Attached Movement functions
372 
375  void setAttachedLocation( double x, double y, double z );
376 
379  void setAttachedOrientation( double psi, double theta, double phi );
380  void setAttachedYaw(double psi);
381  void setAttachedPitch(double theta);
382  void setAttachedRoll(double phi);
383 
386  void setLocalModelScalingEnabled( bool enabled );
387 
390  void setLocalModelScalingAmount( float amount );
391 
393 
394  //@name Speed functions
396 
398  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
399 
401  int orbitSpeedGain() const;
402 
404  int orbitSpeedGainFromSpeed( double speed ) const;
405 
406  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
407  int rotationSpeedGain() const;
408 
410  void setLinearSpeedGain( int gain );
411  int linearSpeedGain() const;
412 
413  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
414  int linearScaledSpeedGain() const;
415 
416  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
417  int linearUnscaledSpeedGain() const;
418 
419  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
420  int gainPrecision() const;
421 
422  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
423  double modelScaleFactor() const;
424 
425  void setModelScaleType( const std::string& modelScaleType, bool forwardToObserverModeManager = true );
426  const std::string& modelScaleType() const;
427 
428  void setMaxModelScaleFactor(double maxModelScaleFactor, bool forwardToObserverModeManager = true);
429  double maxModelScaleFactor() const;
430 
431  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
432  bool forwardToObserverModeManager = true );
433  DtObserverObject::SpeedScalingMode speedScalingMode() const;
434 
435  void setLodScaleCenterEnabled(bool enabled, bool forwardToObserverModeManager = true);
436  bool lodScaleCenterEnabled() const;
437 
438  void setLodScaleCenterMagMinLimit(double limit, bool forwardToObserverModeManager = true);
439  double lodScaleCenterMagMinLimit() const;
440 
442  void setNorthType(DtObserverObject::NorthType northType, bool forwardToObserverModeManager = true);
443 
445  DtObserverObject::NorthType northType() const;
446 
447  void setSpeedScalingMslModeOffset(double offset,
448  bool forwardToObserverModeManager = true );
449  double speedScalingMslModeOffset() const;
450 
451  void setOrbitSpeed( double speed );
452  double orbitSpeed() const;
453 
454  void setRotationSpeed( double speed );
455  double rotationSpeed() const;
456 
457  void setLinearSpeed( double speed );
458  double linearSpeed() const;
459 
461 
463  virtual void toggleFlashlight();
464 
466  virtual DtCameraShake* cameraShake();
467 
469  virtual bool setCameraShake(const std::string& shakeType);
470 
473  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
474 
475  //@name Sensor functions
477 
478  virtual void setSensor(const std::string& sensorName);
479 
481  virtual std::string findSensor();
482 
484  virtual void disableSensor();
485 
487  virtual void slot_sensorRemoved(DtSensor* sensor);
489 
490  // Called by the input driver before any mouse or keyboard input is processed for the
491  // frame, to sync local and remote observers.
492  virtual void synchronize();
493 
495  boost::signalslib::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
496 
498  boost::signalslib::signal<void(const std::string&)> signal_objectsDetached;
499 
501  boost::signalslib::signal<void(DtObserver*, int)> signal_observerModeChanged;
502 
504  boost::signalslib::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
505 
507  boost::signalslib::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
508 
510  boost::signalslib::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
511 
513  boost::signalslib::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
514 
516  boost::signalslib::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
517 
519  boost::signalslib::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
520 
522  boost::signalslib::signal<void(DtObserver*, std::string)> signal_modelScaleTypeChanged;
523 
525  boost::signalslib::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
526 
528  boost::signalslib::signal<void(DtObserver*, double)> signal_lodScaleChanged;
529 
531  boost::signalslib::signal<void(DtObserver*, std::string)> signal_paperMapLayerChanged;
532 
534  boost::signalslib::signal<void (DtObserver*,
537 
540  boost::signalslib::signal<void (DtObserver*, double offset)>
542 
544  boost::signalslib::signal<void(DtObserver*, bool)> signal_lodScaleCenterEnabledChanged;
545 
547  boost::signalslib::signal<void(DtObserver*, double)> signal_lodScaleCenterMagMinLimitChanged;
548 
550  boost::signalslib::signal<void(DtObserver*, DtObserverObject::NorthType northType)>
552 
556  boost::signalslib::signal<void (DtSensor*)> signal_sensorChanged;
557 
560  boost::signalslib::signal<void ()> signal_terrainChanged;
561 
563  void getObserverOffsetVector( double& x, double& y, double& z ) const;
564  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
565 
568 
569  void getCameraFromParentOffsetVector( double& x, double& y, double& z ) const;
570  void getCameraFromParentRotationOffset( double& x, double& y, double& z, double& w ) const;
572  protected:
573 
575  void slot_terrainCleared();
576  void slot_oceanLayerAdded(const DtOceanLayer&);
577  void slot_oceanLayerDeleted(const std::string&);
578 
579  void updateGlobalTerrainFlag(bool flag);
580 
581  double calcLinearSpeed() const;
582  double calcRotationSpeed() const;
583  double calcOrbitSpeed() const;
584 
585  void setObserverOffsetVector( double x, double y, double z );
586 
587  void setObserverRotationOffset( double x, double y, double z, double w );
588 
589  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
590  std::set<std::string>& displayNamesOut) const;
591  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
592  std::vector<DtUniqueID>& idsOut) const;
593 
594  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
596  DtObserverObject::AttachType convertObserverSettingsAttachType(
598 
599  void connectToElementDataSignals();
600  void disconnectFromElementDataSignals();
601 
602  void setModeSpecificObserverObjectData();
603 
605  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
606 
608  virtual void slot_onElementAttributesChanged(
610 
613  void slot_completeAttachment();
614 
615  void slot_observerModeModelSetChanged( int observerMode );
616  void slot_observerModeSensorChanged( int observerMode );
617  void slot_observerModeIs2DChanged( int observerMode );
618  void slot_observerModeKeyMapChanged( int observerMode );
619  void slot_observerModeGainPrecisionChanged( int observerMode );
620  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
621  void slot_observerModeRotationSpeedGainChanged( int observerMode );
622  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
623  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
624  void slot_observerModeModelScaleFactorChanged( int observerMode );
625  void slot_observerModeModelScaleTypeChanged( int observerMode );
626  void slot_observerModeSpeedScalingModeChanged( int observerMode );
627  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
628  void slot_observerModeLodScaleCenterEnabledChanged(int observerMode);
629  void slot_observerModeLodScaleCenterMagMinLimitChanged(int observerMode);
630  void slot_observerModeNorthTypeChanged(int observerMode);
631  void slot_observerModeSettingChanged(int observerMode, int settingKey);
632  void slot_observerModeAdded( int observerMode );
633 
634  // Called when the DE raises the channel configuration modified signal. If a channel
635  // config has it's lod scale modified, the observer will modify all the other channels that
636  // it controls to keep them in sync.
637  void slot_channelModified(const DtChannelConfiguration& config);
638 
640  void attachTo( bool afterTrue );
641 
642  protected:
643 
644  static const double theMoveStepSize;
645 
658  std::vector<DtUniqueID> myCurrentAttachments;
659  std::vector<DtUniqueID> mySecondaryAttachments;
661  unsigned int myPartId;
671  float myLodScale;
676  };
677 }


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