VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtObserver.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (c) 2022 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 
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(const 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  void setPrimaryAttachment(const ElementList& elements);
176  void setPrimaryAttachment(DtElementID element);
178 
180  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  void getLinearVelocity(double &x, double &y, double &z) const;
354  DtVector linearVelocity() const;
356 
358  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  void setAttachedX( double x );
377  void setAttachedY( double y );
378  void setAttachedZ( double z );
379 
382  void setAttachedOrientation( double psi, double theta, double phi );
383  void setAttachedYaw(double psi);
384  void setAttachedPitch(double theta);
385  void setAttachedRoll(double phi);
386 
389  void setLocalModelScalingEnabled( bool enabled );
390 
393  void setLocalModelScalingAmount( float amount );
394 
396 
397  //@name Speed functions
399 
401  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
402 
404  int orbitSpeedGain() const;
405 
407  int orbitSpeedGainFromSpeed( double speed ) const;
408 
409  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
410  int rotationSpeedGain() const;
411 
413  void setLinearSpeedGain( int gain );
414  int linearSpeedGain() const;
415 
416  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
417  int linearScaledSpeedGain() const;
418 
419  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
420  int linearUnscaledSpeedGain() const;
421 
422  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
423  int gainPrecision() const;
424 
425  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
426  double modelScaleFactor() const;
427 
428  void setModelScaleType( const std::string& modelScaleType, bool forwardToObserverModeManager = true );
429  const std::string& modelScaleType() const;
430 
431  void setMaxModelScaleFactor(double maxModelScaleFactor, bool forwardToObserverModeManager = true);
432  double maxModelScaleFactor() const;
433 
434  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
435  bool forwardToObserverModeManager = true );
436  DtObserverObject::SpeedScalingMode speedScalingMode() const;
437 
438  void setLodScaleCenterEnabled(bool enabled, bool forwardToObserverModeManager = true);
439  bool lodScaleCenterEnabled() const;
440 
441  void setLodScaleCenterMagMinLimit(double limit, bool forwardToObserverModeManager = true);
442  double lodScaleCenterMagMinLimit() const;
443 
445  void setNorthType(DtObserverObject::NorthType northType, bool forwardToObserverModeManager = true);
446 
448  DtObserverObject::NorthType northType() const;
449 
450  void setSpeedScalingMslModeOffset(double offset,
451  bool forwardToObserverModeManager = true );
452  double speedScalingMslModeOffset() const;
453 
454  void setOrbitSpeed( double speed );
455  double orbitSpeed() const;
456 
457  void setRotationSpeed( double speed );
458  double rotationSpeed() const;
459 
460  void setLinearSpeed( double speed );
461  double linearSpeed() const;
462 
464 
466  virtual void toggleFlashlight();
467 
469  virtual DtCameraShake* cameraShake();
470 
472  virtual bool setCameraShake(const std::string& shakeType);
473 
476  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
477 
478  //@name Sensor functions
480  virtual void setSensor(const std::string& sensorName);
482 
484  virtual std::string findSensor();
485 
487  virtual void disableSensor();
488 
490  virtual void slot_sensorRemoved(DtSensor* sensor);
492 
493  // Called by the input driver before any mouse or keyboard input is processed for the
494  // frame, to sync local and remote observers.
495  virtual void synchronize();
496 
498  boost::signalslib::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
499 
501  boost::signalslib::signal<void(const std::string&)> signal_objectsDetached;
502 
504  boost::signalslib::signal<void(DtObserver*, int)> signal_observerModeChanged;
505 
507  boost::signalslib::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
508 
510  boost::signalslib::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
511 
513  boost::signalslib::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
514 
516  boost::signalslib::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
517 
519  boost::signalslib::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
520 
522  boost::signalslib::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
523 
525  boost::signalslib::signal<void(DtObserver*, std::string)> signal_modelScaleTypeChanged;
526 
528  boost::signalslib::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
529 
531  boost::signalslib::signal<void(DtObserver*, double)> signal_lodScaleChanged;
532 
534  boost::signalslib::signal<void(DtObserver*, std::string)> signal_paperMapLayerChanged;
535 
537  boost::signalslib::signal<void (DtObserver*,
540 
543  boost::signalslib::signal<void (DtObserver*, double offset)>
545 
547  boost::signalslib::signal<void(DtObserver*, bool)> signal_lodScaleCenterEnabledChanged;
548 
550  boost::signalslib::signal<void(DtObserver*, double)> signal_lodScaleCenterMagMinLimitChanged;
551 
553  boost::signalslib::signal<void(DtObserver*, DtObserverObject::NorthType northType)>
555 
559  boost::signalslib::signal<void (DtSensor*)> signal_sensorChanged;
560 
563  boost::signalslib::signal<void ()> signal_terrainChanged;
564 
566  void getObserverOffsetVector( double& x, double& y, double& z ) const;
567  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
568 
571 
572  void getCameraFromParentOffsetVector( double& x, double& y, double& z ) const;
573  void getCameraFromParentRotationOffset( double& x, double& y, double& z, double& w ) const;
575 
576 
579  virtual void setUsesBoundingVolumeForAttachedOffsets(bool useBoundingVolume);
580 
583  virtual bool usesBoundingVolumeForAttachedOffsets() const;
584 
585  protected:
586 
588  void slot_terrainCleared();
589  void slot_oceanLayerAdded(const DtOceanLayer&);
590  void slot_oceanLayerDeleted(const std::string&);
591 
592  void updateGlobalTerrainFlag(bool flag);
593 
594  double calcLinearSpeed() const;
595  double calcRotationSpeed() const;
596  double calcOrbitSpeed() const;
597 
598  void setObserverOffsetVector( double x, double y, double z );
599 
600  void setObserverRotationOffset( double x, double y, double z, double w );
601 
602  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
603  std::set<std::string>& displayNamesOut) const;
604  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
605  std::vector<DtUniqueID>& idsOut) const;
606 
607  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
608  DtObserverObject::AttachType type) const;
609  DtObserverObject::AttachType convertObserverSettingsAttachType(
611 
612  void connectToElementDataSignals();
613  void disconnectFromElementDataSignals();
614 
615  void setModeSpecificObserverObjectData();
616 
618  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
619 
627 
628  virtual void attachToObjects(const ElementList& objects);
631 
634  virtual void slot_attachNextTick(const ElementList objects);
635 
637  virtual bool sceneObjectsAvailable(const ElementList& elements);
639 
641  virtual void slot_onElementAttributesChanged(
643 
646  void slot_completeAttachment();
647 
648  void slot_observerModeModelSetChanged( int observerMode );
649  void slot_observerModeSensorChanged( int observerMode );
650  void slot_observerModeIs2DChanged( int observerMode );
651  void slot_observerModeKeyMapChanged( int observerMode );
652  void slot_observerModeGainPrecisionChanged( int observerMode );
653  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
654  void slot_observerModeRotationSpeedGainChanged( int observerMode );
655  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
656  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
657  void slot_observerModeModelScaleFactorChanged( int observerMode );
658  void slot_observerModeModelScaleTypeChanged( int observerMode );
659  void slot_observerModeSpeedScalingModeChanged( int observerMode );
660  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
661  void slot_observerModeLodScaleCenterEnabledChanged(int observerMode);
662  void slot_observerModeLodScaleCenterMagMinLimitChanged(int observerMode);
663  void slot_observerModeNorthTypeChanged(int observerMode);
664  void slot_observerModeSettingChanged(int observerMode, int settingKey);
665  void slot_observerModeAdded( int observerMode );
666 
667  // Called when the DE raises the channel configuration modified signal. If a channel
668  // config has it's lod scale modified, the observer will modify all the other channels that
669  // it controls to keep them in sync.
670  void slot_channelModified(const DtChannelConfiguration& config);
671 
673  void attachTo( bool afterTrue );
674 
675  protected:
676 
677  static const double theMoveStepSize;
678 
681  DtObserverObjectAgent* myObserverObjectAgent;
691  std::vector<DtUniqueID> myCurrentAttachments;
692  std::vector<DtUniqueID> mySecondaryAttachments;
694  unsigned int myPartId;
704  float myLodScale;
708  std::string myPaperMapLayer;
709  };
710 }
DtObserverObjectAgent * myObserverObjectAgent
Definition: DtObserver.h:681
bool myAllowDetach
Definition: DtObserver.h:700
int myObserverMode
Definition: DtObserver.h:687
AttachType
Definition: DtObserverSettingsRecord.h:24
std::vector< DtUniqueID > mySecondaryAttachments
Definition: DtObserver.h:692
makArchives::DtObserverStateRecord myCachedObserverStateRecord
This is used as a work-around to cache attachments for entities which have not yet been created...
Definition: DtObserver.h:686
DtUniqueID myLastSingleAttached
Definition: DtObserver.h:693
TODO: This class is used to encapsulate a set of default observer settings and parameters.
Definition: DtObserverConfiguration.h:22
bool myConstrainToCenter
Definition: DtObserver.h:696
bool myFlashlightEnabled
Definition: DtObserver.h:702
std::vector< DtElementID > ElementList
Definition: DtObserver.h:41
boost::signalslib::signal< void(DtObserver *, int)> signal_linearScaledSpeedGainChanged
Boost signal called when the scaled linear speed gain is changed.
Definition: DtObserver.h:507
boost::signalslib::signal< void(DtObserver *, int)> signal_linearUnscaledSpeedGainChanged
Boost signal called when the unscaled linear speed gain is changed.
Definition: DtObserver.h:510
boost::signalslib::signal< void(DtObserver *, DtObserverObject::NorthType northType)> signal_northTypeChanged
Signal emitted when an observer&#39;s north type changed.
Definition: DtObserver.h:554
Contains makVrv::DtElementData class.
boost::signalslib::signal< void(const std::string &)> signal_objectsDetached
Boost signal called when observer detaches from all.
Definition: DtObserver.h:501
A DtObserverSettingsRecord contains the state of an observer.
Definition: DtObserverStateRecord.h:20
DtObserverObject::AttachType myAttachType
Definition: DtObserver.h:690
boost::signalslib::signal< void(DtObserver *, double offset)> signal_speedScalingMslModeOffsetChanged
Signal emitted when an observer&#39;s speed scaling MSL mode offset changes.
Definition: DtObserver.h:544
DtSensor * mySensor
Definition: DtObserver.h:705
bool myAllowAttach
Definition: DtObserver.h:699
boost::signalslib::signal< void(DtSensor *)> signal_sensorChanged
Called when the observer changes which sensor it&#39;s using.
Definition: DtObserver.h:559
static const double theMoveStepSize
Definition: DtObserver.h:677
SpeedScalingMode
Definition: DtObserverObject.h:50
A facade for a DtObserverObject.
Definition: DtObserver.h:37
bool myAllowReset
Definition: DtObserver.h:698
Contains makVrv::DtObserverObject class.
bool myConnectedToElementDataSignals
Definition: DtObserver.h:697
DtCameraShake * myCameraShake
Definition: DtObserver.h:706
#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:45
boost::signalslib::signal< void(DtObserver *, int)> signal_rotationSpeedGainChanged
Boost signal called when the rotation speed gain is changed.
Definition: DtObserver.h:513
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
unsigned int myPartId
Definition: DtObserver.h:694
boost::signalslib::signal< void(DtObserver *, int)> signal_orbitSpeedGainChanged
Boost signal called when the orbit speed gain is changed.
Definition: DtObserver.h:516
boost::signalslib::signal< void(DtObserver *, int)> signal_gainPrecisionChanged
Boost signal called when the gain precision is changed.
Definition: DtObserver.h:519
boost::signalslib::signal< void(DtObserver *, double)> signal_modelScaleFactorChanged
Boost signal called when the model scale factor is changed.
Definition: DtObserver.h:522
NorthType
Definition: DtObserverObject.h:56
Definition of a sensor.
Definition: DtSensor.h:30
boost::signalslib::signal< void(DtObserver *, DtObserverObject::SpeedScalingMode scalingMode)> signal_speedScalingModeChanged
Signal emitted when an observer&#39;s speed scaling mode changes.
Definition: DtObserver.h:539
boost::signalslib::signal< void(const std::string &, DtUniqueID)> signal_objectAttached
Boost signal called when observer attaches to an object.
Definition: DtObserver.h:498
bool myAttachmentHas3DCockpit
Definition: DtObserver.h:689
std::string myPaperMapLayer
Definition: DtObserver.h:708
bool myProjectionIs2D
Definition: DtObserver.h:707
bool myOrientToTargetConstraint
Definition: DtObserver.h:695
The ocean layer is a type of terrain layer which contains information about an area that should be re...
Definition: DtOceanLayer.h:25
DtObserverConfiguration * myConfiguration
Definition: DtObserver.h:682
std::vector< DtElementEntry * > ElementList
Type definition for a vector of DtElementEntry pointers.
Definition: DtElementData.h:47
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::signalslib::signal< void()> signal_terrainChanged
Called when the observer sees a change in terrain which might require updates to observer settings...
Definition: DtObserver.h:563
bool myHideModelOnAttach
Definition: DtObserver.h:688
A DtObserverSettingsRecord contains the settings of an observer.
Definition: DtObserverSettingsRecord.h:20
const char int mode
Definition: ioapi.h:38
boost::signalslib::signal< void(DtObserver *, bool)> signal_lodScaleCenterEnabledChanged
Boost signal called when the observer&#39;s lod scale center enabled is changed.
Definition: DtObserver.h:547
boost::signalslib::signal< void(DtObserver *, double)> signal_lodScaleChanged
Boost signal called when the observer&#39;s view magnification is changed.
Definition: DtObserver.h:531
Contains the DtElementAttributeManager class declaration.
The abstract interface necessary for agents.
Definition: DtAgentManagerInterface.h:33
bool myHasInitialLocation
Definition: DtObserver.h:701
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:70
std::vector< DtUniqueID > myCurrentAttachments
Definition: DtObserver.h:691
A utility Quaternion class.
Definition: DtQuat.h:19
boost::signalslib::signal< void(DtObserver *, double)> signal_viewMagnificationChanged
Boost signal called when the observer&#39;s view magnification is changed.
Definition: DtObserver.h:528
boost::signalslib::signal< void(DtObserver *, std::string)> signal_paperMapLayerChanged
Signal called when the observer&#39;s paper map layer is changed.
Definition: DtObserver.h:534
boost::signalslib::signal< void(DtObserver *, double)> signal_lodScaleCenterMagMinLimitChanged
Boost signal called when the observer&#39;s lod scale view magnification minimum is changed.
Definition: DtObserver.h:550
voidpf uLong offset
Definition: ioapi.h:42
float myLodScale
Definition: DtObserver.h:704
Provides an algorithm for shaking the camera.
Definition: DtCameraShake.h:23
DtSignalConnectionManager myConnections
Definition: DtObserver.h:680
boost::signalslib::signal< void(DtObserver *, int)> signal_observerModeChanged
Boost signal called when observer&#39;s mode changed.
Definition: DtObserver.h:504
DtDe & myDe
Definition: DtObserver.h:679
DtDe & de()
Get the observer&#39;s DtDe.
Definition: DtObserver.h:51
double myViewMagnification
Definition: DtObserver.h:703
boost::signalslib::signal< void(DtObserver *, std::string)> signal_modelScaleTypeChanged
Boost signal called when the model scale type is changed.
Definition: DtObserver.h:525
AttachType
Definition: DtObserverObject.h:36

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)