VR-Vantage 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) 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 
61  bool getRecord(makArchives::DtObserverStateRecord& recOut) const;
62 
64  void setFromRecord(const makArchives::DtObserverStateRecord& rec);
65 
67  bool getRecord(makArchives::DtObserverSettingsRecord& recOut) const;
68 
70  void setFromRecord(const makArchives::DtObserverSettingsRecord& rec);
71 
76  makArchives::DtObserverStateRecord getCachedObserverStateRecord() const;
77 
80  bool hasInitialLocation() const;
81 
83  const std::string& name() const;
84  void setName( const std::string& name );
85 
90 
91  int observerMode() const;
92  void setObserverMode( int observerMode );
94 
96  double viewResolution() const;
97 
99  void setViewResolution( double resolution );
100 
102  double viewMagnification() const;
103 
105  void setViewMagnification( double magnficationFactor );
106 
107  DtObserverConfiguration& configuration();
108  const DtObserverConfiguration& configuration() const;
109 
111  bool inUse( const std::string& channelKeyToIgnore = "" ) const;
112 
113  //@name Attachment functions.
115 
117  void attachToNextElement();
118 
120  void attachToPreviousElement();
121 
123  bool isAttached(DtElementID) const;
124 
126  bool isPrimaryAttached(DtElementID) const;
127 
129  bool isSecondaryAttached(DtElementID) const;
130 
134  void setPrimaryAttachment( const ElementList& element );
135 
140  void setSecondaryAttachment( const ElementList& objects );
141 
144  void setLocationTrackAttachment( double x, double y, double z );
145 
148  void getLocationTrackAttachment( double& x, double& y, double& z ) const;
149 
153  void setPartAttachment(int partId);
154 
156  int partAttachment() const;
157 
159  void detach();
160 
162  bool attached() const;
163 
165  bool tracking() const;
166 
168  const ElementList& primaryAttachments() const;
169 
171  const ElementList& secondaryAttachments() const;
172 
173  void setHideModelOnAttach( bool hide );
174  bool hideModelOnAttach() const;
175 
179 
180  void setAttachmentHas3DCockpit( bool cockpit);
181  bool attachmentHas3DCockpit() const;
183 
184  void setAttachType( DtObserverObject::AttachType type );
185  DtObserverObject::AttachType attachType() const;
186 
187  void setOrientToTargetConstraint( bool orient );
188  bool orientToTargetConstraint() const;
189 
192  DtElementID lastSingleAttached() const;
193 
195  bool haveLastSingleAttached() const;
196 
198 
199  //@name Movement functions
201 
204  void reset();
205 
208  void setAllowReset(bool b);
209 
211  bool allowReset() const;
212 
214  void setAllowAttach(bool b);
215 
217  bool allowAttach() const;
218 
220  void setAllowDetach(bool b);
221 
223  bool allowDetach() const;
224 
226  void centerOnTerrain();
227 
229  void centerOnTerrain( const DtUniqueID& terrainPatch );
230 
233  void suppressConstrainToTerrain( bool trueFalse );
234 
236  void setConstrainToCenter( bool trueFalse );
237  void toggleConstrainToCenter();
238  bool constrainToCenter() const;
239 
241  void getLocation( double &x, double &y, double& z ) const;
242 
244  DtVector location() const;
245 
247  void setLocation( double x, double y, double z );
248 
250  void getOrientation( double& psi, double& theta, double& phi ) const;
251 
253  void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
254 
256  void setOrientation( double psi, double theta, double phi );
257 
259  void setTopographicOrientation( double psi, double theta, double phi );
260 
262  void getOrientation( double& x, double& y, double& z, double& w ) const;
263 
265  void setOrientation( double x, double y, double z, double w );
266 
269  void moveUnit(const DtVector& direction);
270 
273  void rotateUnit(const DtTaitBryan& rotation);
274 
276  void getLinearVelocity(double &x, double &y, double &z) const;
277 
279  void getRotationalVelocity( double& x, double& y, double& z ) const;
280 
282  bool observerObjectMoving() const;
283 
285  double observerAltitude() const;
287 
288  //@name Attached Movement functions
290 
293  void setAttachedLocation( double x, double y, double z );
294 
297  void setAttachedOrientation( double psi, double theta, double phi );
298 
301  void setLocalModelScalingEnabled( bool enabled );
302 
305  void setLocalModelScalingAmount( float amount );
306 
308 
309  //@name Speed functions
311 
313  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
314 
316  int orbitSpeedGain() const;
317 
319  int orbitSpeedGainFromSpeed( double speed ) const;
320 
321  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
322  int rotationSpeedGain() const;
323 
325  void setLinearSpeedGain( int gain );
326  int linearSpeedGain() const;
327 
328  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
329  int linearScaledSpeedGain() const;
330 
331  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
332  int linearUnscaledSpeedGain() const;
333 
334  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
335  int gainPrecision() const;
336 
337  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
338  double modelScaleFactor() const;
339 
340  void setModelScaleType( DtObserverObject::ScaleType modelScaleType,
341  bool forwardToObserverModeManager = true );
342  DtObserverObject::ScaleType modelScaleType() const;
343 
344  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
345  bool forwardToObserverModeManager = true );
346  DtObserverObject::SpeedScalingMode speedScalingMode() const;
347 
348  void setSpeedScalingMslModeOffset( double offset,
349  bool forwardToObserverModeManager = true );
350  double speedScalingMslModeOffset() const;
351 
352  void setOrbitSpeed( double speed );
353  double orbitSpeed() const;
354 
355  void setRotationSpeed( double speed );
356  double rotationSpeed() const;
357 
358  void setLinearSpeed( double speed );
359  double linearSpeed() const;
360 
362 
364  virtual void toggleFlashlight();
365 
367  virtual DtCameraShake* cameraShake();
368 
370  virtual bool setCameraShake(const std::string& shakeType);
371 
374  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
375 
376  //@name Sensor functions
378 
379  virtual void setSensor(const std::string& sensorName);
380 
382  virtual std::string findSensor();
383 
385  virtual void disableSensor();
386 
388  virtual void slot_sensorRemoved(DtSensor* sensor);
390 
391  // Called by the input driver before any mouse or keyboard input is processed for the
392  // frame, to sync local and remote observers.
393  virtual void synchronize();
394 
396  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
397 
399  boost::signal<void(const std::string&)> signal_objectsDetached;
400 
402  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
403 
405  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
406 
408  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
409 
411  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
412 
414  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
415 
417  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
418 
420  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
421 
423  boost::signal<void(DtObserver*, DtObserverObject::ScaleType)> signal_modelScaleTypeChanged;
424 
426  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
427 
428 
430  boost::signal<void (DtObserver*,
433 
436  boost::signal<void (DtObserver*, double offset)>
438 
442  boost::signal<void (DtSensor*)> signal_sensorChanged;
443 
446  boost::signal<void ()> signal_terrainChanged;
447 
448  protected:
449 
451  void slot_terrainCleared();
452  void slot_oceanLayerAdded(const DtOceanLayer&);
453  void slot_oceanLayerToBeDeleted(const DtOceanLayer&);
454 
455  void updateGlobalTerrainFlag(bool flag);
456 
457  double calcLinearSpeed() const;
458  double calcRotationSpeed() const;
459  double calcOrbitSpeed() const;
460 
461  void getObserverOffsetVector( double& x, double& y, double& z ) const;
462  void setObserverOffsetVector( double x, double y, double z );
463 
464  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
465  void setObserverRotationOffset( double x, double y, double z, double w );
466 
467  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
468  std::set<std::string>& displayNamesOut) const;
469  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
470  std::vector<DtUniqueID>& idsOut) const;
471 
472  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
474  DtObserverObject::AttachType convertObserverSettingsAttachType(
476 
477  void connectToElementDataSignals();
478  void disconnectFromElementDataSignals();
479 
480  void setModeSpecificObserverObjectData();
481 
483  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
484 
486  virtual void slot_onElementAttributesChanged(
487  const DtElementData::EntryAttributesList& attributes );
488 
491  void slot_completeAttachment();
492 
493  void slot_observerModeModelSetChanged( int observerMode );
494  void slot_observerModeSensorChanged( int observerMode );
495  void slot_observerModeIs2DChanged( int observerMode );
496  void slot_observerModeKeyMapChanged( int observerMode );
497  void slot_observerModeGainPrecisionChanged( int observerMode );
498  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
499  void slot_observerModeRotationSpeedGainChanged( int observerMode );
500  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
501  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
502  void slot_observerModeModelScaleFactorChanged( int observerMode );
503  void slot_observerModeModelScaleTypeChanged( int observerMode );
504  void slot_observerModeSpeedScalingModeChanged( int observerMode );
505  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
506  void slot_observerModeSettingChanged( int observerMode, int settingKey );
507  void slot_observerModeAdded( int observerMode );
508 
510  void attachTo( bool afterTrue );
511 
512  protected:
513 
514  static const double theMoveStepSize;
515 
528  std::vector<DtUniqueID> myCurrentAttachments;
529  std::vector<DtUniqueID> mySecondaryAttachments;
531  unsigned int myPartId;
543  };
544 }


Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)