VR-Forces 4.6 Class Documentation
 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) 2016 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  void setLocation( double x, double y, double z );
266 
268  void getOrientation( double& psi, double& theta, double& phi ) const;
269 
271  void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
272 
274  void setOrientation( double psi, double theta, double phi );
275 
277  void setTopographicOrientation( double psi, double theta, double phi );
278 
280  void getOrientation( double& x, double& y, double& z, double& w ) const;
281 
283  void setOrientation( double x, double y, double z, double w );
284 
287  virtual DtVector observerPlatformFront() const;
288 
291  virtual DtVector observerPlatformUp() const;
292 
295  virtual DtVector observerPlatformRight() const;
296 
299  virtual DtVector observerFront() const;
300 
302  virtual DtVector observerUp() const;
303 
305  virtual DtVector observerRight() const;
306 
309  void moveUnit(const DtVector& direction);
310 
313  void rotateUnit(const DtTaitBryan& rotation);
314 
316  void getLinearVelocity(double &x, double &y, double &z) const;
317 
319  void getRotationalVelocity( double& x, double& y, double& z ) const;
320 
322  bool observerObjectMoving() const;
323 
325  double observerAltitude() const;
327 
328  //@name Attached Movement functions
330 
333  void setAttachedLocation( double x, double y, double z );
334 
337  void setAttachedOrientation( double psi, double theta, double phi );
338 
341  void setLocalModelScalingEnabled( bool enabled );
342 
345  void setLocalModelScalingAmount( float amount );
346 
348 
349  //@name Speed functions
351 
353  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
354 
356  int orbitSpeedGain() const;
357 
359  int orbitSpeedGainFromSpeed( double speed ) const;
360 
361  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
362  int rotationSpeedGain() const;
363 
365  void setLinearSpeedGain( int gain );
366  int linearSpeedGain() const;
367 
368  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
369  int linearScaledSpeedGain() const;
370 
371  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
372  int linearUnscaledSpeedGain() const;
373 
374  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
375  int gainPrecision() const;
376 
377  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
378  double modelScaleFactor() const;
379 
380  void setModelScaleType( DtObserverObject::ScaleType modelScaleType,
381  bool forwardToObserverModeManager = true );
382  DtObserverObject::ScaleType modelScaleType() const;
383 
384  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
385  bool forwardToObserverModeManager = true );
386  DtObserverObject::SpeedScalingMode speedScalingMode() const;
387 
388  void setSpeedScalingMslModeOffset( double offset,
389  bool forwardToObserverModeManager = true );
390  double speedScalingMslModeOffset() const;
391 
392  void setOrbitSpeed( double speed );
393  double orbitSpeed() const;
394 
395  void setRotationSpeed( double speed );
396  double rotationSpeed() const;
397 
398  void setLinearSpeed( double speed );
399  double linearSpeed() const;
400 
402 
404  virtual void toggleFlashlight();
405 
407  virtual DtCameraShake* cameraShake();
408 
410  virtual bool setCameraShake(const std::string& shakeType);
411 
414  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
415 
416  //@name Sensor functions
418 
419  virtual void setSensor(const std::string& sensorName);
420 
422  virtual std::string findSensor();
423 
425  virtual void disableSensor();
426 
428  virtual void slot_sensorRemoved(DtSensor* sensor);
430 
431  // Called by the input driver before any mouse or keyboard input is processed for the
432  // frame, to sync local and remote observers.
433  virtual void synchronize();
434 
436  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
437 
439  boost::signal<void(const std::string&)> signal_objectsDetached;
440 
442  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
443 
445  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
446 
448  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
449 
451  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
452 
454  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
455 
457  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
458 
460  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
461 
463  boost::signal<void(DtObserver*, DtObserverObject::ScaleType)> signal_modelScaleTypeChanged;
464 
466  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
467 
468 
470  boost::signal<void (DtObserver*,
473 
476  boost::signal<void (DtObserver*, double offset)>
478 
482  boost::signal<void (DtSensor*)> signal_sensorChanged;
483 
486  boost::signal<void ()> signal_terrainChanged;
487 
488  protected:
489 
491  void slot_terrainCleared();
492  void slot_oceanLayerAdded(const DtOceanLayer&);
493  void slot_oceanLayerDeleted(const std::string&);
494 
495  void updateGlobalTerrainFlag(bool flag);
496 
497  double calcLinearSpeed() const;
498  double calcRotationSpeed() const;
499  double calcOrbitSpeed() const;
500 
501  void getObserverOffsetVector( double& x, double& y, double& z ) const;
502  void setObserverOffsetVector( double x, double y, double z );
503 
504  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
505  void setObserverRotationOffset( double x, double y, double z, double w );
506 
507  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
508  std::set<std::string>& displayNamesOut) const;
509  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
510  std::vector<DtUniqueID>& idsOut) const;
511 
512  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
513  DtObserverObject::AttachType type) const;
514  DtObserverObject::AttachType convertObserverSettingsAttachType(
516 
517  void connectToElementDataSignals();
518  void disconnectFromElementDataSignals();
519 
520  void setModeSpecificObserverObjectData();
521 
523  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
524 
526  virtual void slot_onElementAttributesChanged(
527  const DtElementData::EntryAttributesList& attributes );
528 
531  void slot_completeAttachment();
532 
533  void slot_observerModeModelSetChanged( int observerMode );
534  void slot_observerModeSensorChanged( int observerMode );
535  void slot_observerModeIs2DChanged( int observerMode );
536  void slot_observerModeKeyMapChanged( int observerMode );
537  void slot_observerModeGainPrecisionChanged( int observerMode );
538  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
539  void slot_observerModeRotationSpeedGainChanged( int observerMode );
540  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
541  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
542  void slot_observerModeModelScaleFactorChanged( int observerMode );
543  void slot_observerModeModelScaleTypeChanged( int observerMode );
544  void slot_observerModeSpeedScalingModeChanged( int observerMode );
545  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
546  void slot_observerModeSettingChanged( int observerMode, int settingKey );
547  void slot_observerModeAdded( int observerMode );
548 
550  void attachTo( bool afterTrue );
551 
552  protected:
553 
554  static const double theMoveStepSize;
555 
558  DtObserverObjectAgent* myObserverObjectAgent;
568  std::vector<DtUniqueID> myCurrentAttachments;
569  std::vector<DtUniqueID> mySecondaryAttachments;
571  unsigned int myPartId;
584  };
585 }

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)