VR-Vantage API Documentation
DtObserver.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2013 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 
41  {
42  public:
43 
44  typedef std::vector<DtElementID> ElementList;
45 
47  DtObserver(DtDe& de, DtAgentManagerInterface& sceneInterface,
48  const DtObserverConfiguration& config );
49 
51  ~DtObserver();
52 
54  inline DtDe& de()
55  {
56  return myDe;
57  }
58 
60  DtObserverObjectAgent& agent();
61 
63  const DtObserverObjectAgent& agent() const;
64 
66  bool getRecord(makArchives::DtObserverStateRecord& recOut) const;
67 
69  void setFromRecord(const makArchives::DtObserverStateRecord& rec);
70 
72  bool getRecord(makArchives::DtObserverSettingsRecord& recOut) const;
73 
75  void setFromRecord(const makArchives::DtObserverSettingsRecord& rec);
76 
79  bool hasInitialLocation() const;
80 
82  const std::string& name() const;
83  void setName( const std::string& name );
84 
86  int observerMode() const;
87 
89  void setObserverMode( int observerMode );
90 
92  double viewResolution() const;
93 
95  void setViewResolution( double resolution );
96 
98  double viewMagnification() const;
99 
101  void setViewMagnification( double magnficationFactor );
102 
105  bool acceptingViewControl() const;
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 
145  void setPartAttachment(int partId);
146 
148  int partAttachment() const;
149 
151  void detach();
152 
154  bool attached() const;
155 
157  bool tracking() const;
158 
160  const ElementList& primaryAttachments() const;
161 
163  const ElementList& secondaryAttachments() const;
164 
165  void setHideModelOnAttach( bool hide );
166  bool hideModelOnAttach() const;
167 
168  void setAttachType( DtObserverObject::AttachType type );
169  DtObserverObject::AttachType attachType() const;
170 
171  void setOrientToTargetConstraint( bool orient );
172  bool orientToTargetConstraint() const;
173 
176  DtElementID lastSingleAttached() const;
177 
179  bool haveLastSingleAttached() const;
180 
182 
183  //@name Movement functions
185 
188  void reset();
189 
192  void setAllowReset(bool b);
193 
195  bool allowReset() const;
196 
198  void setAllowAttach(bool b);
199 
201  bool allowAttach() const;
202 
204  void setAllowDetach(bool b);
205 
207  bool allowDetach() const;
208 
210  void centerOnTerrain();
211 
213  void centerOnTerrain( const DtUniqueID& terrainPatch );
214 
217  void suppressConstrainToTerrain( bool trueFalse );
218 
220  void setConstrainToCenter( bool trueFalse );
221  void toggleConstrainToCenter();
222  bool constrainToCenter() const;
223 
225  void getLocation( double &x, double &y, double& z ) const;
226 
228  DtVector location() const;
229 
231  void setLocation( double x, double y, double z );
232 
234  void getOrientation( double& psi, double& theta, double& phi ) const;
235 
237  void setOrientation( double psi, double theta, double phi );
238 
240  void getOrientation( double& x, double& y, double& z, double& w ) const;
241 
243  void setOrientation( double x, double y, double z, double w );
244 
247  void moveUnit(const DtVector& direction);
248 
251  void rotateUnit(const DtTaitBryan& rotation);
252 
254  void getLinearVelocity(double &x, double &y, double &z) const;
255 
257  void getRotationalVelocity( double& x, double& y, double& z ) const;
258 
260  bool observerObjectMoving() const;
261 
263  double observerAltitude() const;
265 
266  //@name Attached Movement functions
268 
271  void setAttachedLocation( double x, double y, double z );
272 
275  void setAttachedOrientation( double psi, double theta, double phi );
276 
279  void setLocalModelScalingEnabled( bool enabled );
280 
283  void setLocalModelScalingAmount( float amount );
284 
286 
287  //@name Speed functions
289 
291  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
292 
294  int orbitSpeedGain() const;
295 
297  int orbitSpeedGainFromSpeed( double speed ) const;
298 
299  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
300  int rotationSpeedGain() const;
301 
303  void setLinearSpeedGain( int gain );
304  int linearSpeedGain() const;
305 
306  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
307  int linearScaledSpeedGain() const;
308 
309  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
310  int linearUnscaledSpeedGain() const;
311 
312  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
313  int gainPrecision() const;
314 
315  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
316  double modelScaleFactor() const;
317 
318  void setModelScaleType( DtObserverObject::ScaleType modelScaleType,
319  bool forwardToObserverModeManager = true );
320  DtObserverObject::ScaleType modelScaleType() const;
321 
322  void setOrbitSpeed( double speed );
323  double orbitSpeed() const;
324 
325  void setRotationSpeed( double speed );
326  double rotationSpeed() const;
327 
328  void setLinearSpeed( double speed );
329  double linearSpeed() const;
330 
332 
333  //@name Sensor functions
335 
336  virtual void setSensor(const std::string& sensorName);
337 
339  virtual std::string findSensor();
340 
342  virtual void disableSensor();
343 
345  virtual void slot_sensorRemoved(DtSensor* sensor);
347 
348  // Called by the input driver before any mouse or keyboard input is processed for the
349  // frame, to sync local and remote observers.
350  virtual void synchronize();
351 
353  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
354 
356  boost::signal<void(const std::string&)> signal_objectsDetached;
357 
359  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
360 
362  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
363 
365  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
366 
368  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
369 
371  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
372 
374  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
375 
377  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
378 
380  boost::signal<void(DtObserver*, DtObserverObject::ScaleType)> signal_modelScaleTypeChanged;
381 
383  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
384 
388  boost::signal<void (DtSensor*)> signal_sensorChanged;
389 
392  boost::signal<void ()> signal_terrainChanged;
393 
394  protected:
395 
397  void slot_terrainCleared();
398  void slot_oceanLayerAdded(const DtOceanLayer&);
399  void slot_oceanLayerToBeDeleted(const DtOceanLayer&);
400 
401  void updateGlobalTerrainFlag(bool flag);
402 
403  double calcLinearSpeed() const;
404  double calcRotationSpeed() const;
405  double calcOrbitSpeed() const;
406 
407  void getObserverOffsetVector( double& x, double& y, double& z ) const;
408  void setObserverOffsetVector( double x, double y, double z );
409 
410  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
411  void setObserverRotationOffset( double x, double y, double z, double w );
412 
413  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
414  std::set<std::string>& displayNamesOut) const;
415  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
416  std::vector<DtUniqueID>& idsOut) const;
417 
418  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
420  DtObserverObject::AttachType convertObserverSettingsAttachType(
422 
423  void connectToElementDataSignals();
424  void disconnectFromElementDataSignals();
425 
426  void setModeSpecificObserverObjectData();
427 
429  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
430 
432  virtual void slot_onElementAttributesChanged(
433  const DtElementData::EntryAttributesList& attributes );
434 
435  void slot_observerModeModelSetChanged( int observerMode );
436  void slot_observerModeSensorChanged( int observerMode );
437  void slot_observerModeIs2DChanged( int observerMode );
438  void slot_observerModeKeyMapChanged( int observerMode );
439  void slot_observerModeGainPrecisionChanged( int observerMode );
440  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
441  void slot_observerModeRotationSpeedGainChanged( int observerMode );
442  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
443  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
444  void slot_observerModeModelScaleFactorChanged( int observerMode );
445  void slot_observerModeModelScaleTypeChanged( int observerMode );
446  void slot_observerModeSettingChanged( int observerMode, int settingKey );
447  void slot_observerModeAdded( int observerMode );
448 
450  void attachTo( bool afterTrue );
451 
452  protected:
453 
454  static const double theMoveStepSize;
455 
464  std::vector<DtUniqueID> myCurrentAttachments;
465  std::vector<DtUniqueID> mySecondaryAttachments;
467  unsigned int myPartId;
477  };
478 }


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