VR-Forces 4.3.1 Class 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) 2015 MAK Technologies, Inc.
3  * All rights reserved.
4  ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/vrvCore.h>
13 #include <vrvCore/DtElementData.h>
14 #include <vrvCore/DtUniqueID.h>
17 
20 
21 #include <boost/signals.hpp>
22 
23 #include <string>
24 #include <vector>
25 
26 class DtTaitBryan;
27 class DtVector;
28 
29 namespace makVrv
30 {
31  class DtObserverObjectAgent;
32  class DtDe;
33  class DtAgentManagerInterface;
34  class DtObserverConfiguration;
35  class DtSensor;
36  class DtOceanLayer;
37  class DtQuat;
38  class DtCameraShake;
39 
43  {
44  public:
45 
46  typedef std::vector<DtElementID> ElementList;
47 
49  DtObserver(DtDe& de, DtAgentManagerInterface& sceneInterface,
50  const DtObserverConfiguration& config );
51 
53  virtual ~DtObserver();
54 
56  inline DtDe& de()
57  {
58  return myDe;
59  }
60 
62  DtObserverObjectAgent& agent();
63 
65  const DtObserverObjectAgent& agent() const;
66 
68  bool getRecord(makArchives::DtObserverStateRecord& recOut) const;
69 
71  void setFromRecord(const makArchives::DtObserverStateRecord& rec);
72 
74  bool getRecord(makArchives::DtObserverSettingsRecord& recOut) const;
75 
77  void setFromRecord(const makArchives::DtObserverSettingsRecord& rec);
78 
83  makArchives::DtObserverStateRecord getCachedObserverStateRecord() const;
84 
87  bool hasInitialLocation() const;
88 
90  const std::string& name() const;
91  void setName( const std::string& name );
92 
97 
98  int observerMode() const;
99  void setObserverMode( int observerMode );
101 
103  double viewResolution() const;
104 
106  void setViewResolution( double resolution );
107 
109  double viewMagnification() const;
110 
112  void setViewMagnification( double magnficationFactor );
113 
114  DtObserverConfiguration& configuration();
115  const DtObserverConfiguration& configuration() const;
116 
118  bool inUse( const std::string& channelKeyToIgnore = "" ) const;
119 
120  //@name Attachment functions.
122 
124  void attachToNextElement();
125 
127  void attachToPreviousElement();
128 
130  bool isAttached(DtElementID) const;
131 
133  bool isPrimaryAttached(DtElementID) const;
134 
136  bool isSecondaryAttached(DtElementID) const;
137 
141  void setPrimaryAttachment( const ElementList& element );
142 
147  void setSecondaryAttachment( const ElementList& objects );
148 
152  void setPartAttachment(int partId);
153 
155  int partAttachment() const;
156 
158  void detach();
159 
161  bool attached() const;
162 
164  bool tracking() const;
165 
167  const ElementList& primaryAttachments() const;
168 
170  const ElementList& secondaryAttachments() const;
171 
172  void setHideModelOnAttach( bool hide );
173  bool hideModelOnAttach() const;
174 
178 
179  void setAttachmentHas3DCockpit( bool cockpit);
180  bool attachmentHas3DCockpit() const;
182 
183  void setAttachType( DtObserverObject::AttachType type );
184  DtObserverObject::AttachType attachType() const;
185 
186  void setOrientToTargetConstraint( bool orient );
187  bool orientToTargetConstraint() const;
188 
191  DtElementID lastSingleAttached() const;
192 
194  bool haveLastSingleAttached() const;
195 
197 
198  //@name Movement functions
200 
203  void reset();
204 
207  void setAllowReset(bool b);
208 
210  bool allowReset() const;
211 
213  void setAllowAttach(bool b);
214 
216  bool allowAttach() const;
217 
219  void setAllowDetach(bool b);
220 
222  bool allowDetach() const;
223 
225  void centerOnTerrain();
226 
228  void centerOnTerrain( const DtUniqueID& terrainPatch );
229 
232  void suppressConstrainToTerrain( bool trueFalse );
233 
235  void setConstrainToCenter( bool trueFalse );
236  void toggleConstrainToCenter();
237  bool constrainToCenter() const;
238 
240  void getLocation( double &x, double &y, double& z ) const;
241 
243  DtVector location() const;
244 
246  void setLocation( double x, double y, double z );
247 
249  void getOrientation( double& psi, double& theta, double& phi ) const;
250 
252  void getTopographicOrientation( double& psi, double& theta, double& phi ) const;
253 
255  void setOrientation( double psi, double theta, double phi );
256 
258  void setTopographicOrientation( double psi, double theta, double phi );
259 
261  void getOrientation( double& x, double& y, double& z, double& w ) const;
262 
264  void setOrientation( double x, double y, double z, double w );
265 
268  void moveUnit(const DtVector& direction);
269 
272  void rotateUnit(const DtTaitBryan& rotation);
273 
275  void getLinearVelocity(double &x, double &y, double &z) const;
276 
278  void getRotationalVelocity( double& x, double& y, double& z ) const;
279 
281  bool observerObjectMoving() const;
282 
284  double observerAltitude() const;
286 
287  //@name Attached Movement functions
289 
292  void setAttachedLocation( double x, double y, double z );
293 
296  void setAttachedOrientation( double psi, double theta, double phi );
297 
300  void setLocalModelScalingEnabled( bool enabled );
301 
304  void setLocalModelScalingAmount( float amount );
305 
307 
308  //@name Speed functions
310 
312  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
313 
315  int orbitSpeedGain() const;
316 
318  int orbitSpeedGainFromSpeed( double speed ) const;
319 
320  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
321  int rotationSpeedGain() const;
322 
324  void setLinearSpeedGain( int gain );
325  int linearSpeedGain() const;
326 
327  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
328  int linearScaledSpeedGain() const;
329 
330  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
331  int linearUnscaledSpeedGain() const;
332 
333  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
334  int gainPrecision() const;
335 
336  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
337  double modelScaleFactor() const;
338 
339  void setModelScaleType( DtObserverObject::ScaleType modelScaleType,
340  bool forwardToObserverModeManager = true );
341  DtObserverObject::ScaleType modelScaleType() const;
342 
343  void setSpeedScalingMode( DtObserverObject::SpeedScalingMode mode,
344  bool forwardToObserverModeManager = true );
345  DtObserverObject::SpeedScalingMode speedScalingMode() const;
346 
347  void setSpeedScalingAslModeOffset( double offset,
348  bool forwardToObserverModeManager = true );
349  double speedScalingAslModeOffset() const;
350 
351  void setOrbitSpeed( double speed );
352  double orbitSpeed() const;
353 
354  void setRotationSpeed( double speed );
355  double rotationSpeed() const;
356 
357  void setLinearSpeed( double speed );
358  double linearSpeed() const;
359 
361 
363  virtual void toggleFlashlight();
364 
366  virtual DtCameraShake* cameraShake();
367 
369  virtual bool setCameraShake(const std::string& shakeType);
370 
373  virtual void setCameraShakeRotation(const DtQuat& rotQuat) const;
374 
375  //@name Sensor functions
377 
378  virtual void setSensor(const std::string& sensorName);
379 
381  virtual std::string findSensor();
382 
384  virtual void disableSensor();
385 
387  virtual void slot_sensorRemoved(DtSensor* sensor);
389 
390  // Called by the input driver before any mouse or keyboard input is processed for the
391  // frame, to sync local and remote observers.
392  virtual void synchronize();
393 
395  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
396 
398  boost::signal<void(const std::string&)> signal_objectsDetached;
399 
401  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
402 
404  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
405 
407  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
408 
410  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
411 
413  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
414 
416  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
417 
419  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
420 
422  boost::signal<void(DtObserver*, DtObserverObject::ScaleType)> signal_modelScaleTypeChanged;
423 
425  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
426 
427 
429  boost::signal<void (DtObserver*,
432 
435  boost::signal<void (DtObserver*, double offset)>
437 
441  boost::signal<void (DtSensor*)> signal_sensorChanged;
442 
445  boost::signal<void ()> signal_terrainChanged;
446 
447  protected:
448 
450  void slot_terrainCleared();
451  void slot_oceanLayerAdded(const DtOceanLayer&);
452  void slot_oceanLayerToBeDeleted(const DtOceanLayer&);
453 
454  void updateGlobalTerrainFlag(bool flag);
455 
456  double calcLinearSpeed() const;
457  double calcRotationSpeed() const;
458  double calcOrbitSpeed() const;
459 
460  void getObserverOffsetVector( double& x, double& y, double& z ) const;
461  void setObserverOffsetVector( double x, double y, double z );
462 
463  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
464  void setObserverRotationOffset( double x, double y, double z, double w );
465 
466  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
467  std::set<std::string>& displayNamesOut) const;
468  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
469  std::vector<DtUniqueID>& idsOut) const;
470 
471  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
472  DtObserverObject::AttachType type) const;
473  DtObserverObject::AttachType convertObserverSettingsAttachType(
475 
476  void connectToElementDataSignals();
477  void disconnectFromElementDataSignals();
478 
479  void setModeSpecificObserverObjectData();
480 
482  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
483 
485  virtual void slot_onElementAttributesChanged(
486  const DtElementData::EntryAttributesList& attributes );
487 
488  void slot_observerModeModelSetChanged( int observerMode );
489  void slot_observerModeSensorChanged( int observerMode );
490  void slot_observerModeIs2DChanged( int observerMode );
491  void slot_observerModeKeyMapChanged( int observerMode );
492  void slot_observerModeGainPrecisionChanged( int observerMode );
493  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
494  void slot_observerModeRotationSpeedGainChanged( int observerMode );
495  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
496  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
497  void slot_observerModeModelScaleFactorChanged( int observerMode );
498  void slot_observerModeModelScaleTypeChanged( int observerMode );
499  void slot_observerModeSpeedScalingModeChanged( int observerMode );
500  void slot_observerModeSpeedScalingAslModeOffsetChanged( int observerMode );
501  void slot_observerModeSettingChanged( int observerMode, int settingKey );
502  void slot_observerModeAdded( int observerMode );
503 
505  void attachTo( bool afterTrue );
506 
507  protected:
508 
509  static const double theMoveStepSize;
510 
513  DtObserverObjectAgent* myObserverObjectAgent;
523  std::vector<DtUniqueID> myCurrentAttachments;
524  std::vector<DtUniqueID> mySecondaryAttachments;
526  unsigned int myPartId;
538  };
539 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)