VR-Vantage 2.6 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  bool projectionIs2D() const;
97  void setProjectionIs2D( bool is2d );
99 
101 
103  const std::string& name() const;
104  void setName( const std::string& name );
105 
110 
111  int observerMode() const;
112  void setObserverMode( int observerMode );
114 
116  double viewResolution() const;
117 
119  void setViewResolution(double resolution);
120 
122  void setViewResolutionFromHeightAboveTerrain(double hat);
123 
125  double viewMagnification() const;
126 
128  void setViewMagnification(double magnficationFactor);
129 
131  void setLodScale(double lodScale);
132 
134  double lodScale() const;
135 
136  DtObserverConfiguration& configuration();
137  const DtObserverConfiguration& configuration() const;
138 
140  bool inUse( const std::string& channelKeyToIgnore = "" ) const;
141 
142  //@name Attachment functions.
144 
146  void attachToNextElement();
147 
149  void attachToPreviousElement();
150 
152  bool isAttached(DtElementID) const;
153 
155  bool isPrimaryAttached(DtElementID) const;
156 
158  bool isSecondaryAttached(DtElementID) const;
159 
161  void setPrimaryAttachment(const ElementList& elements);
165  void setPrimaryAttachment(DtElementID element);
167 
169  void setSecondaryAttachment(const ElementList& element);
174  void setSecondaryAttachment(DtElementID element);
176 
179  void setLocationTrackAttachment( double x, double y, double z );
180 
183  void getLocationTrackAttachment( double& x, double& y, double& z ) const;
184 
188  void setPartAttachment(int partId);
189 
191  int partAttachment() const;
192 
194  void detach();
195 
197  bool attached() const;
198 
200  bool tracking() const;
201 
203  const ElementList& primaryAttachments() const;
204 
206  const ElementList& secondaryAttachments() const;
207 
208  void setHideModelOnAttach( bool hide );
209  bool hideModelOnAttach() const;
210 
214 
215  void setAttachmentHas3DCockpit( bool cockpit);
216  bool attachmentHas3DCockpit() const;
218 
219  void setAttachType( DtObserverObject::AttachType type );
220  DtObserverObject::AttachType attachType() const;
221 
222  void setOrientToTargetConstraint( bool orient );
223  bool orientToTargetConstraint() const;
224 
227  DtElementID lastSingleAttached() const;
228 
230  bool haveLastSingleAttached() const;
231 
233 
234  //@name Movement functions
236 
239  void reset();
240 
243  void setAllowReset(bool b);
244 
246  bool allowReset() const;
247 
249  void setAllowAttach(bool b);
250 
252  bool allowAttach() const;
253 
255  void setAllowDetach(bool b);
256 
258  bool allowDetach() const;
259 
261  void centerOnTerrain();
262 
264  void centerOnTerrain( const DtUniqueID& terrainPatch );
265 
268  void suppressConstrainToTerrain( bool trueFalse );
269 
271  void setConstrainToCenter( bool trueFalse );
272  void toggleConstrainToCenter();
273  bool constrainToCenter() const;
274 
276  void getLocation( double &x, double &y, double& z ) const;
277 
279  DtVector location() const;
280 
282  DtVector observerCameraPosition() const;
283 
285  void setLocation( double x, double y, double z );
286 
288  void getOrientation( double& psi, double& theta, double& phi ) const;
289 
291  void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
292 
294  void setOrientation( double psi, double theta, double phi );
295 
297  void setTopographicOrientation( double psi, double theta, double phi );
298 
300  void getOrientation( double& x, double& y, double& z, double& w ) const;
301 
303  void setOrientation( double x, double y, double z, double w );
304 
307  DtTaitBryan observerCameraOrientation(bool includeShake=true) const;
308 
311  virtual DtVector observerPlatformFront() const;
312 
315  virtual DtVector observerPlatformUp() const;
316 
319  virtual DtVector observerPlatformRight() const;
320 
324  virtual DtVector observerCameraFront(bool includeShake=true) const;
325 
327  virtual DtVector observerCameraUp(bool includeShake = true) const;
328 
330  virtual DtVector observerCameraRight(bool includeShake = true) const;
331 
334  void moveUnit(const DtVector& direction);
335 
338  void rotateUnit(const DtTaitBryan& rotation);
339 
341  void getLinearVelocity(double &x, double &y, double &z) const;
343  DtVector linearVelocity() const;
345 
347  void getRotationalVelocity( double& x, double& y, double& z ) const;
349  DtVector rotationalVelocity() const;
351 
353  bool observerObjectMoving() const;
354 
356  double observerAltitude() const;
358 
359  //@name Attached Movement functions
361 
364  void setAttachedLocation( double x, double y, double z );
365 
368  void setAttachedOrientation( double psi, double theta, double phi );
369 
372  void setLocalModelScalingEnabled( bool enabled );
373 
376  void setLocalModelScalingAmount( float amount );
377 
379 
380  //@name Speed functions
382 
384  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
385 
387  int orbitSpeedGain() const;
388 
390  int orbitSpeedGainFromSpeed( double speed ) const;
391 
392  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
393  int rotationSpeedGain() const;
394 
396  void setLinearSpeedGain( int gain );
397  int linearSpeedGain() const;
398 
399  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
400  int linearScaledSpeedGain() const;
401 
402  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
403  int linearUnscaledSpeedGain() const;
404 
405  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
406  int gainPrecision() const;
407 
408  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
409  double modelScaleFactor() const;
410 
411  void setModelScaleType( const std::string& modelScaleType, bool forwardToObserverModeManager = true );
412  const std::string& modelScaleType() const;
413 
414  void setMaxModelScaleFactor(double maxModelScaleFactor, bool forwardToObserverModeManager = true);
415  double maxModelScaleFactor() const;
416 
417  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
418  bool forwardToObserverModeManager = true );
419  DtObserverObject::SpeedScalingMode speedScalingMode() const;
420 
421  void setLodScaleCenterEnabled(bool enabled, bool forwardToObserverModeManager = true);
422  bool lodScaleCenterEnabled() const;
423 
424  void setLodScaleCenterMagMinLimit(double limit, bool forwardToObserverModeManager = true);
425  double lodScaleCenterMagMinLimit() const;
426 
427  void setSpeedScalingMslModeOffset(double offset,
428  bool forwardToObserverModeManager = true );
429  double speedScalingMslModeOffset() const;
430 
431  void setOrbitSpeed( double speed );
432  double orbitSpeed() const;
433 
434  void setRotationSpeed( double speed );
435  double rotationSpeed() const;
436 
437  void setLinearSpeed( double speed );
438  double linearSpeed() const;
439 
441 
443  virtual void toggleFlashlight();
444 
446  virtual DtCameraShake* cameraShake();
447 
449  virtual bool setCameraShake(const std::string& shakeType);
450 
453  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
454 
455  //@name Sensor functions
457  virtual void setSensor(const std::string& sensorName);
459 
461  virtual std::string findSensor();
462 
464  virtual void disableSensor();
465 
467  virtual void slot_sensorRemoved(DtSensor* sensor);
469 
470  // Called by the input driver before any mouse or keyboard input is processed for the
471  // frame, to sync local and remote observers.
472  virtual void synchronize();
473 
475  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
476 
478  boost::signal<void(const std::string&)> signal_objectsDetached;
479 
481  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
482 
484  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
485 
487  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
488 
490  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
491 
493  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
494 
496  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
497 
499  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
500 
502  boost::signal<void(DtObserver*, std::string)> signal_modelScaleTypeChanged;
503 
505  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
506 
508  boost::signal<void(DtObserver*, double)> signal_lodScaleChanged;
509 
510 
512  boost::signal<void (DtObserver*,
515 
518  boost::signal<void (DtObserver*, double offset)>
520 
522  boost::signal<void(DtObserver*, bool)> signal_lodScaleCenterEnabledChanged;
523 
525  boost::signal<void(DtObserver*, double)> signal_lodScaleCenterMagMinLimitChanged;
526 
530  boost::signal<void (DtSensor*)> signal_sensorChanged;
531 
534  boost::signal<void ()> signal_terrainChanged;
535 
537  void getObserverOffsetVector( double& x, double& y, double& z ) const;
538  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
539 
542 
543  void getCameraFromParentOffsetVector( double& x, double& y, double& z ) const;
544  void getCameraFromParentRotationOffset( double& x, double& y, double& z, double& w ) const;
546  protected:
547 
549  void slot_terrainCleared();
550  void slot_oceanLayerAdded(const DtOceanLayer&);
551  void slot_oceanLayerDeleted(const std::string&);
552 
553  void updateGlobalTerrainFlag(bool flag);
554 
555  double calcLinearSpeed() const;
556  double calcRotationSpeed() const;
557  double calcOrbitSpeed() const;
558 
559  void setObserverOffsetVector( double x, double y, double z );
560 
561  void setObserverRotationOffset( double x, double y, double z, double w );
562 
563  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
564  std::set<std::string>& displayNamesOut) const;
565  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
566  std::vector<DtUniqueID>& idsOut) const;
567 
568  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
569  DtObserverObject::AttachType type) const;
570  DtObserverObject::AttachType convertObserverSettingsAttachType(
572 
573  void connectToElementDataSignals();
574  void disconnectFromElementDataSignals();
575 
576  void setModeSpecificObserverObjectData();
577 
579  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
580 
582  virtual void slot_onElementAttributesChanged(
584 
587  void slot_completeAttachment();
588 
589  void slot_observerModeModelSetChanged( int observerMode );
590  void slot_observerModeSensorChanged( int observerMode );
591  void slot_observerModeIs2DChanged( int observerMode );
592  void slot_observerModeKeyMapChanged( int observerMode );
593  void slot_observerModeGainPrecisionChanged( int observerMode );
594  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
595  void slot_observerModeRotationSpeedGainChanged( int observerMode );
596  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
597  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
598  void slot_observerModeModelScaleFactorChanged( int observerMode );
599  void slot_observerModeModelScaleTypeChanged( int observerMode );
600  void slot_observerModeSpeedScalingModeChanged( int observerMode );
601  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
602  void slot_observerModeLodScaleCenterEnabledChanged(int observerMode);
603  void slot_observerModeLodScaleCenterMagMinLimitChanged(int observerMode);
604  void slot_observerModeSettingChanged(int observerMode, int settingKey);
605  void slot_observerModeAdded( int observerMode );
606 
607  // Called when the DE raises the channel configuration modified signal. If a channel
608  // config has it's lod scale modified, the observer will modify all the other channels that
609  // it controls to keep them in sync.
610  void slot_channelModified(const DtChannelConfiguration& config);
611 
613  void attachTo( bool afterTrue );
614 
615  protected:
616 
617  static const double theMoveStepSize;
618 
621  DtObserverObjectAgent* myObserverObjectAgent;
631  std::vector<DtUniqueID> myCurrentAttachments;
632  std::vector<DtUniqueID> mySecondaryAttachments;
634  unsigned int myPartId;
644  float myLodScale;
648  };
649 }
boost::signal< void(const std::string &)> signal_objectsDetached
Boost signal called when observer detaches from all.
Definition: DtObserver.h:478
boost::signal< void(DtObserver *, int)> signal_gainPrecisionChanged
Boost signal called when the gain precision is changed.
Definition: DtObserver.h:496
DtObserverObjectAgent * myObserverObjectAgent
Definition: DtObserver.h:621
bool myAllowDetach
Definition: DtObserver.h:640
int myObserverMode
Definition: DtObserver.h:627
AttachType
Definition: DtObserverSettingsRecord.h:24
boost::signal< void(DtObserver *, double offset)> signal_speedScalingMslModeOffsetChanged
Signal emitted when an observer&#39;s speed scaling MSL mode offset changes.
Definition: DtObserver.h:519
std::vector< DtUniqueID > mySecondaryAttachments
Definition: DtObserver.h:632
makArchives::DtObserverStateRecord myCachedObserverStateRecord
This is used as a work-around to cache attachments for entities which have not yet been created...
Definition: DtObserver.h:626
DtUniqueID myLastSingleAttached
Definition: DtObserver.h:633
boost::signal< void(DtObserver *, int)> signal_orbitSpeedGainChanged
Boost signal called when the orbit speed gain is changed.
Definition: DtObserver.h:493
TODO: This class is used to encapsulate a set of default observer settings and parameters.
Definition: DtObserverConfiguration.h:25
bool myConstrainToCenter
Definition: DtObserver.h:636
bool myFlashlightEnabled
Definition: DtObserver.h:642
std::vector< DtElementID > ElementList
Definition: DtObserver.h:41
boost::signal< void(DtObserver *, int)> signal_observerModeChanged
Boost signal called when observer&#39;s mode changed.
Definition: DtObserver.h:481
boost::signal< void(DtObserver *, int)> signal_linearScaledSpeedGainChanged
Boost signal called when the scaled linear speed gain is changed.
Definition: DtObserver.h:484
boost::signal< void(DtObserver *, double)> signal_viewMagnificationChanged
Boost signal called when the observer&#39;s view magnification is changed.
Definition: DtObserver.h:505
boost::signal< void(const std::string &, DtUniqueID)> signal_objectAttached
Boost signal called when observer attaches to an object.
Definition: DtObserver.h:475
Contains makVrv::DtElementData class.
A DtObserverSettingsRecord contains the state of an observer.
Definition: DtObserverStateRecord.h:20
boost::signal< void(DtSensor *)> signal_sensorChanged
Called when the observer changes which sensor it&#39;s using.
Definition: DtObserver.h:530
DtObserverObject::AttachType myAttachType
Definition: DtObserver.h:630
DtUniqueID DtElementID
The ElementID is a specific type of unique ID used to represent VR-Vantage uniquely defined elements...
Definition: DtUniqueID.h:26
DtSensor * mySensor
Definition: DtObserver.h:645
bool myAllowAttach
Definition: DtObserver.h:639
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t x *y t *t t x *y t *t *t x y *z t t *t t x *y *z t *t *t t x y z t t t t x *y z t *t t t x * y(z *w))
boost::signal< void(DtObserver *, DtObserverObject::SpeedScalingMode scalingMode)> signal_speedScalingModeChanged
Signal emitted when an observer&#39;s speed scaling mode changes.
Definition: DtObserver.h:514
static const double theMoveStepSize
Definition: DtObserver.h:617
SpeedScalingMode
Definition: DtObserverObject.h:50
boost::signal< void(DtObserver *, std::string)> signal_modelScaleTypeChanged
Boost signal called when the model scale type is changed.
Definition: DtObserver.h:502
A facade for a DtObserverObject.
Definition: DtObserver.h:37
boost::signal< void(DtObserver *, double)> signal_lodScaleChanged
Boost signal called when the observer&#39;s view magnification is changed.
Definition: DtObserver.h:508
bool myAllowReset
Definition: DtObserver.h:638
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t x *y t *t t x *y t *t *t x y *z w
Definition: exprtk.hpp:9210
Contains makVrv::DtObserverObject class.
bool myConnectedToElementDataSignals
Definition: DtObserver.h:637
DtCameraShake * myCameraShake
Definition: DtObserver.h:646
boost::signal< void(DtObserver *, double)> signal_modelScaleFactorChanged
Boost signal called when the model scale factor is changed.
Definition: DtObserver.h:499
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
std::vector< EntryAttributes > EntryAttributesList
Define the type used to signal changes to one or more attributes for one or more elements.
Definition: DtElementAttributeManager.h:41
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:24
unsigned int myPartId
Definition: DtObserver.h:634
Definition of a sensor.
Definition: DtSensor.h:30
x y * z
Definition: exprtk.hpp:9133
unsigned long long DtUniqueID
Definition: DtUniqueID.h:22
boost::signal< void(DtObserver *, bool)> signal_lodScaleCenterEnabledChanged
Boost signal called when the observer&#39;s lod scale center enabled is changed.
Definition: DtObserver.h:522
bool myAttachmentHas3DCockpit
Definition: DtObserver.h:629
bool myProjectionIs2D
Definition: DtObserver.h:647
bool myOrientToTargetConstraint
Definition: DtObserver.h:635
The ocean layer is a type of terrain layer which contains information about an area that should be re...
Definition: DtOceanLayer.h:27
DtObserverConfiguration * myConfiguration
Definition: DtObserver.h:622
std::vector< DtElementEntry * > ElementList
Type definition for a vector of DtElementEntry pointers.
Definition: DtElementData.h:46
Contains makArchives::DtObserverStateRecord class.
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:26
boost::signal< void(DtObserver *, double)> signal_lodScaleCenterMagMinLimitChanged
Boost signal called when the observer&#39;s lod scale view magnificaion minimum is changed.
Definition: DtObserver.h:525
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t x(y+z)
bool myHideModelOnAttach
Definition: DtObserver.h:628
A DtObserverSettingsRecord contains the settings of an observer.
Definition: DtObserverSettingsRecord.h:20
Contains the DtElementAttributeManager class declaration.
The abstract interface necessary for agents.
Definition: DtAgentManagerInterface.h:36
bool myHasInitialLocation
Definition: DtObserver.h:641
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
std::vector< DtUniqueID > myCurrentAttachments
Definition: DtObserver.h:631
A utility Quaternion class.
Definition: DtQuat.h:22
boost::signal< void(DtObserver *, int)> signal_linearUnscaledSpeedGainChanged
Boost signal called when the unscaled linear speed gain is changed.
Definition: DtObserver.h:487
float myLodScale
Definition: DtObserver.h:644
boost::signal< void(DtObserver *, int)> signal_rotationSpeedGainChanged
Boost signal called when the rotation speed gain is changed.
Definition: DtObserver.h:490
Provides an algorithm for shaking the camera.
Definition: DtCameraShake.h:23
DtSignalConnectionManager myConnections
Definition: DtObserver.h:620
boost::signal< void()> signal_terrainChanged
Called when the observer sees a change in terrain which might require updates to observer settings...
Definition: DtObserver.h:534
DtDe & myDe
Definition: DtObserver.h:619
DtDe & de()
Get the observer&#39;s DtDe.
Definition: DtObserver.h:51
double myViewMagnification
Definition: DtObserver.h:643
AttachType
Definition: DtObserverObject.h:36


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