VR-Vantage 2.2 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  virtual DtVector observerPlatformFront() const;
270 
273  virtual DtVector observerPlatformUp() const;
274 
277  virtual DtVector observerPlatformRight() const;
278 
281  virtual DtVector observerFront() const;
282 
284  virtual DtVector observerUp() const;
285 
287  virtual DtVector observerRight() const;
288 
291  void moveUnit(const DtVector& direction);
292 
295  void rotateUnit(const DtTaitBryan& rotation);
296 
298  void getLinearVelocity(double &x, double &y, double &z) const;
299 
301  void getRotationalVelocity( double& x, double& y, double& z ) const;
302 
304  bool observerObjectMoving() const;
305 
307  double observerAltitude() const;
309 
310  //@name Attached Movement functions
312 
315  void setAttachedLocation( double x, double y, double z );
316 
319  void setAttachedOrientation( double psi, double theta, double phi );
320 
323  void setLocalModelScalingEnabled( bool enabled );
324 
327  void setLocalModelScalingAmount( float amount );
328 
330 
331  //@name Speed functions
333 
335  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
336 
338  int orbitSpeedGain() const;
339 
341  int orbitSpeedGainFromSpeed( double speed ) const;
342 
343  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
344  int rotationSpeedGain() const;
345 
347  void setLinearSpeedGain( int gain );
348  int linearSpeedGain() const;
349 
350  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
351  int linearScaledSpeedGain() const;
352 
353  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
354  int linearUnscaledSpeedGain() const;
355 
356  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
357  int gainPrecision() const;
358 
359  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
360  double modelScaleFactor() const;
361 
362  void setModelScaleType( DtObserverObject::ScaleType modelScaleType,
363  bool forwardToObserverModeManager = true );
364  DtObserverObject::ScaleType modelScaleType() const;
365 
366  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
367  bool forwardToObserverModeManager = true );
368  DtObserverObject::SpeedScalingMode speedScalingMode() const;
369 
370  void setSpeedScalingMslModeOffset( double offset,
371  bool forwardToObserverModeManager = true );
372  double speedScalingMslModeOffset() const;
373 
374  void setOrbitSpeed( double speed );
375  double orbitSpeed() const;
376 
377  void setRotationSpeed( double speed );
378  double rotationSpeed() const;
379 
380  void setLinearSpeed( double speed );
381  double linearSpeed() const;
382 
384 
386  virtual void toggleFlashlight();
387 
389  virtual DtCameraShake* cameraShake();
390 
392  virtual bool setCameraShake(const std::string& shakeType);
393 
396  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
397 
398  //@name Sensor functions
400 
401  virtual void setSensor(const std::string& sensorName);
402 
404  virtual std::string findSensor();
405 
407  virtual void disableSensor();
408 
410  virtual void slot_sensorRemoved(DtSensor* sensor);
412 
413  // Called by the input driver before any mouse or keyboard input is processed for the
414  // frame, to sync local and remote observers.
415  virtual void synchronize();
416 
418  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
419 
421  boost::signal<void(const std::string&)> signal_objectsDetached;
422 
424  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
425 
427  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
428 
430  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
431 
433  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
434 
436  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
437 
439  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
440 
442  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
443 
445  boost::signal<void(DtObserver*, DtObserverObject::ScaleType)> signal_modelScaleTypeChanged;
446 
448  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
449 
450 
452  boost::signal<void (DtObserver*,
455 
458  boost::signal<void (DtObserver*, double offset)>
460 
464  boost::signal<void (DtSensor*)> signal_sensorChanged;
465 
468  boost::signal<void ()> signal_terrainChanged;
469 
470  protected:
471 
473  void slot_terrainCleared();
474  void slot_oceanLayerAdded(const DtOceanLayer&);
475  void slot_oceanLayerToBeDeleted(const DtOceanLayer&);
476 
477  void updateGlobalTerrainFlag(bool flag);
478 
479  double calcLinearSpeed() const;
480  double calcRotationSpeed() const;
481  double calcOrbitSpeed() const;
482 
483  void getObserverOffsetVector( double& x, double& y, double& z ) const;
484  void setObserverOffsetVector( double x, double y, double z );
485 
486  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
487  void setObserverRotationOffset( double x, double y, double z, double w );
488 
489  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
490  std::set<std::string>& displayNamesOut) const;
491  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
492  std::vector<DtUniqueID>& idsOut) const;
493 
494  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
496  DtObserverObject::AttachType convertObserverSettingsAttachType(
498 
499  void connectToElementDataSignals();
500  void disconnectFromElementDataSignals();
501 
502  void setModeSpecificObserverObjectData();
503 
505  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
506 
508  virtual void slot_onElementAttributesChanged(
509  const DtElementData::EntryAttributesList& attributes );
510 
513  void slot_completeAttachment();
514 
515  void slot_observerModeModelSetChanged( int observerMode );
516  void slot_observerModeSensorChanged( int observerMode );
517  void slot_observerModeIs2DChanged( int observerMode );
518  void slot_observerModeKeyMapChanged( int observerMode );
519  void slot_observerModeGainPrecisionChanged( int observerMode );
520  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
521  void slot_observerModeRotationSpeedGainChanged( int observerMode );
522  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
523  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
524  void slot_observerModeModelScaleFactorChanged( int observerMode );
525  void slot_observerModeModelScaleTypeChanged( int observerMode );
526  void slot_observerModeSpeedScalingModeChanged( int observerMode );
527  void slot_observerModeSpeedScalingMslModeOffsetChanged( int observerMode );
528  void slot_observerModeSettingChanged( int observerMode, int settingKey );
529  void slot_observerModeAdded( int observerMode );
530 
532  void attachTo( bool afterTrue );
533 
534  protected:
535 
536  static const double theMoveStepSize;
537 
550  std::vector<DtUniqueID> myCurrentAttachments;
551  std::vector<DtUniqueID> mySecondaryAttachments;
553  unsigned int myPartId;
565  };
566 }


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