VR-Vantage 2.4 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) 2018 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 
152  void setPrimaryAttachment( const ElementList& element );
153 
158  void setSecondaryAttachment( const ElementList& objects );
159 
162  void setLocationTrackAttachment( double x, double y, double z );
163 
166  void getLocationTrackAttachment( double& x, double& y, double& z ) const;
167 
171  void setPartAttachment(int partId);
172 
174  int partAttachment() const;
175 
177  void detach();
178 
180  bool attached() const;
181 
183  bool tracking() const;
184 
186  const ElementList& primaryAttachments() const;
187 
189  const ElementList& secondaryAttachments() const;
190 
191  void setHideModelOnAttach( bool hide );
192  bool hideModelOnAttach() const;
193 
197 
198  void setAttachmentHas3DCockpit( bool cockpit);
199  bool attachmentHas3DCockpit() const;
201 
202  void setAttachType( DtObserverObject::AttachType type );
203  DtObserverObject::AttachType attachType() const;
204 
205  void setOrientToTargetConstraint( bool orient );
206  bool orientToTargetConstraint() const;
207 
210  DtElementID lastSingleAttached() const;
211 
213  bool haveLastSingleAttached() const;
214 
216 
217  //@name Movement functions
219 
222  void reset();
223 
226  void setAllowReset(bool b);
227 
229  bool allowReset() const;
230 
232  void setAllowAttach(bool b);
233 
235  bool allowAttach() const;
236 
238  void setAllowDetach(bool b);
239 
241  bool allowDetach() const;
242 
244  void centerOnTerrain();
245 
247  void centerOnTerrain( const DtUniqueID& terrainPatch );
248 
251  void suppressConstrainToTerrain( bool trueFalse );
252 
254  void setConstrainToCenter( bool trueFalse );
255  void toggleConstrainToCenter();
256  bool constrainToCenter() const;
257 
259  void getLocation( double &x, double &y, double& z ) const;
260 
262  DtVector location() const;
263 
265  DtVector observerCameraPosition() const;
266 
268  void setLocation( double x, double y, double z );
269 
271  void getOrientation( double& psi, double& theta, double& phi ) const;
272 
274  void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
275 
277  void setOrientation( double psi, double theta, double phi );
278 
280  void setTopographicOrientation( double psi, double theta, double phi );
281 
283  void getOrientation( double& x, double& y, double& z, double& w ) const;
284 
286  void setOrientation( double x, double y, double z, double w );
287 
290  DtTaitBryan observerCameraOrientation(bool includeShake=true) const;
291 
294  virtual DtVector observerPlatformFront() const;
295 
298  virtual DtVector observerPlatformUp() const;
299 
302  virtual DtVector observerPlatformRight() const;
303 
307  virtual DtVector observerCameraFront(bool includeShake=true) const;
308 
310  virtual DtVector observerCameraUp(bool includeShake = true) const;
311 
313  virtual DtVector observerCameraRight(bool includeShake = true) const;
314 
317  void moveUnit(const DtVector& direction);
318 
321  void rotateUnit(const DtTaitBryan& rotation);
322 
324 
325  void getLinearVelocity(double &x, double &y, double &z) const;
326  DtVector linearVelocity() const;
328 
330 
331  void getRotationalVelocity( double& x, double& y, double& z ) const;
332  DtVector rotationalVelocity() const;
334 
336  bool observerObjectMoving() const;
337 
339  double observerAltitude() const;
341 
342  //@name Attached Movement functions
344 
347  void setAttachedLocation( double x, double y, double z );
348 
351  void setAttachedOrientation( double psi, double theta, double phi );
352 
355  void setLocalModelScalingEnabled( bool enabled );
356 
359  void setLocalModelScalingAmount( float amount );
360 
362 
363  //@name Speed functions
365 
367  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
368 
370  int orbitSpeedGain() const;
371 
373  int orbitSpeedGainFromSpeed( double speed ) const;
374 
375  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
376  int rotationSpeedGain() const;
377 
379  void setLinearSpeedGain( int gain );
380  int linearSpeedGain() const;
381 
382  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
383  int linearScaledSpeedGain() const;
384 
385  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
386  int linearUnscaledSpeedGain() const;
387 
388  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
389  int gainPrecision() const;
390 
391  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
392  double modelScaleFactor() const;
393 
394  void setModelScaleType( DtObserverObject::ScaleType modelScaleType,
395  bool forwardToObserverModeManager = true );
396  DtObserverObject::ScaleType modelScaleType() const;
397 
398  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
399  bool forwardToObserverModeManager = true );
400  DtObserverObject::SpeedScalingMode speedScalingMode() const;
401 
402  void setSpeedScalingMslModeOffset( double offset,
403  bool forwardToObserverModeManager = true );
404  double speedScalingMslModeOffset() const;
405 
406  void setOrbitSpeed( double speed );
407  double orbitSpeed() const;
408 
409  void setRotationSpeed( double speed );
410  double rotationSpeed() const;
411 
412  void setLinearSpeed( double speed );
413  double linearSpeed() const;
414 
416 
418  virtual void toggleFlashlight();
419 
421  virtual DtCameraShake* cameraShake();
422 
424  virtual bool setCameraShake(const std::string& shakeType);
425 
428  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
429 
430  //@name Sensor functions
432 
433  virtual void setSensor(const std::string& sensorName);
434 
436  virtual std::string findSensor();
437 
439  virtual void disableSensor();
440 
442  virtual void slot_sensorRemoved(DtSensor* sensor);
444 
445  // Called by the input driver before any mouse or keyboard input is processed for the
446  // frame, to sync local and remote observers.
447  virtual void synchronize();
448 
450  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
451 
453  boost::signal<void(const std::string&)> signal_objectsDetached;
454 
456  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
457 
459  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
460 
462  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
463 
465  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
466 
468  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
469 
471  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
472 
474  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
475 
477  boost::signal<void(DtObserver*, DtObserverObject::ScaleType)> signal_modelScaleTypeChanged;
478 
480  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
481 
482 
484  boost::signal<void (DtObserver*,
487 
490  boost::signal<void (DtObserver*, double offset)>
492 
496  boost::signal<void (DtSensor*)> signal_sensorChanged;
497 
500  boost::signal<void ()> signal_terrainChanged;
501 
502  protected:
503 
505  void slot_terrainCleared();
506  void slot_oceanLayerAdded(const DtOceanLayer&);
507  void slot_oceanLayerDeleted(const std::string&);
508 
509  void updateGlobalTerrainFlag(bool flag);
510 
511  double calcLinearSpeed() const;
512  double calcRotationSpeed() const;
513  double calcOrbitSpeed() const;
514 
515  void getObserverOffsetVector( double& x, double& y, double& z ) const;
516  void setObserverOffsetVector( double x, double y, double z );
517 
518  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
519  void setObserverRotationOffset( double x, double y, double z, double w );
520 
521  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
522  std::set<std::string>& displayNamesOut) const;
523  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
524  std::vector<DtUniqueID>& idsOut) const;
525 
526  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
528  DtObserverObject::AttachType convertObserverSettingsAttachType(
530 
531  void connectToElementDataSignals();
532  void disconnectFromElementDataSignals();
533 
534  void setModeSpecificObserverObjectData();
535 
537  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
538 
540  virtual void slot_onElementAttributesChanged(
541  const DtElementData::EntryAttributesList& attributes );
542 
545  void slot_completeAttachment();
546 
547  void slot_observerModeModelSetChanged( int observerMode );
548  void slot_observerModeSensorChanged( int observerMode );
549  void slot_observerModeIs2DChanged( int observerMode );
550  void slot_observerModeKeyMapChanged( int observerMode );
551  void slot_observerModeGainPrecisionChanged( int observerMode );
552  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
553  void slot_observerModeRotationSpeedGainChanged( int observerMode );
554  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
555  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
556  void slot_observerModeModelScaleFactorChanged( int observerMode );
557  void slot_observerModeModelScaleTypeChanged( int observerMode );
558  void slot_observerModeSpeedScalingModeChanged( int observerMode );
559  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
560  void slot_observerModeSettingChanged( int observerMode, int settingKey );
561  void slot_observerModeAdded( int observerMode );
562 
564  void attachTo( bool afterTrue );
565 
566  protected:
567 
568  static const double theMoveStepSize;
569 
582  std::vector<DtUniqueID> myCurrentAttachments;
583  std::vector<DtUniqueID> mySecondaryAttachments;
585  unsigned int myPartId;
598  };
599 }


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