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) 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 
89 
90  int observerMode() const;
91  void setObserverMode( int observerMode );
93 
95  double viewResolution() const;
96 
98  void setViewResolution( double resolution );
99 
101  double viewMagnification() const;
102 
104  void setViewMagnification( double magnficationFactor );
105 
108  bool acceptingViewControl() const;
109 
110  DtObserverConfiguration& configuration();
111  const DtObserverConfiguration& configuration() const;
112 
114  bool inUse( const std::string& channelKeyToIgnore = "" ) const;
115 
116  //@name Attachment functions.
118 
120  void attachToNextElement();
121 
123  void attachToPreviousElement();
124 
126  bool isAttached(DtElementID) const;
127 
129  bool isPrimaryAttached(DtElementID) const;
130 
132  bool isSecondaryAttached(DtElementID) const;
133 
137  void setPrimaryAttachment( const ElementList& element );
138 
143  void setSecondaryAttachment( const ElementList& objects );
144 
148  void setPartAttachment(int partId);
149 
151  int partAttachment() const;
152 
154  void detach();
155 
157  bool attached() const;
158 
160  bool tracking() const;
161 
163  const ElementList& primaryAttachments() const;
164 
166  const ElementList& secondaryAttachments() const;
167 
168  void setHideModelOnAttach( bool hide );
169  bool hideModelOnAttach() const;
170 
171  void setAttachType( DtObserverObject::AttachType type );
172  DtObserverObject::AttachType attachType() const;
173 
174  void setOrientToTargetConstraint( bool orient );
175  bool orientToTargetConstraint() const;
176 
179  DtElementID lastSingleAttached() const;
180 
182  bool haveLastSingleAttached() const;
183 
185 
186  //@name Movement functions
188 
191  void reset();
192 
195  void setAllowReset(bool b);
196 
198  bool allowReset() const;
199 
201  void setAllowAttach(bool b);
202 
204  bool allowAttach() const;
205 
207  void setAllowDetach(bool b);
208 
210  bool allowDetach() const;
211 
213  void centerOnTerrain();
214 
216  void centerOnTerrain( const DtUniqueID& terrainPatch );
217 
220  void suppressConstrainToTerrain( bool trueFalse );
221 
223  void setConstrainToCenter( bool trueFalse );
224  void toggleConstrainToCenter();
225  bool constrainToCenter() const;
226 
228  void getLocation( double &x, double &y, double& z ) const;
229 
231  DtVector location() const;
232 
234  void setLocation( double x, double y, double z );
235 
237  void getOrientation( double& psi, double& theta, double& phi ) const;
238 
240  void setOrientation( double psi, double theta, double phi );
241 
243  void getOrientation( double& x, double& y, double& z, double& w ) const;
244 
246  void setOrientation( double x, double y, double z, double w );
247 
250  void moveUnit(const DtVector& direction);
251 
254  void rotateUnit(const DtTaitBryan& rotation);
255 
257  void getLinearVelocity(double &x, double &y, double &z) const;
258 
260  void getRotationalVelocity( double& x, double& y, double& z ) const;
261 
263  bool observerObjectMoving() const;
264 
266  double observerAltitude() const;
268 
269  //@name Attached Movement functions
271 
274  void setAttachedLocation( double x, double y, double z );
275 
278  void setAttachedOrientation( double psi, double theta, double phi );
279 
282  void setLocalModelScalingEnabled( bool enabled );
283 
286  void setLocalModelScalingAmount( float amount );
287 
289 
290  //@name Speed functions
292 
294  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
295 
297  int orbitSpeedGain() const;
298 
300  int orbitSpeedGainFromSpeed( double speed ) const;
301 
302  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
303  int rotationSpeedGain() const;
304 
306  void setLinearSpeedGain( int gain );
307  int linearSpeedGain() const;
308 
309  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
310  int linearScaledSpeedGain() const;
311 
312  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
313  int linearUnscaledSpeedGain() const;
314 
315  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
316  int gainPrecision() const;
317 
318  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
319  double modelScaleFactor() const;
320 
321  void setModelScaleType( DtObserverObject::ScaleType modelScaleType,
322  bool forwardToObserverModeManager = true );
323  DtObserverObject::ScaleType modelScaleType() const;
324 
325  void setOrbitSpeed( double speed );
326  double orbitSpeed() const;
327 
328  void setRotationSpeed( double speed );
329  double rotationSpeed() const;
330 
331  void setLinearSpeed( double speed );
332  double linearSpeed() const;
333 
335 
336  //@name Sensor functions
338 
339  virtual void setSensor(const std::string& sensorName);
340 
342  virtual std::string findSensor();
343 
345  virtual void disableSensor();
346 
348  virtual void slot_sensorRemoved(DtSensor* sensor);
350 
351  // Called by the input driver before any mouse or keyboard input is processed for the
352  // frame, to sync local and remote observers.
353  virtual void synchronize();
354 
356  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
357 
359  boost::signal<void(const std::string&)> signal_objectsDetached;
360 
362  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
363 
365  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
366 
368  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
369 
371  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
372 
374  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
375 
377  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
378 
380  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
381 
383  boost::signal<void(DtObserver*, DtObserverObject::ScaleType)> signal_modelScaleTypeChanged;
384 
386  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
387 
391  boost::signal<void (DtSensor*)> signal_sensorChanged;
392 
395  boost::signal<void ()> signal_terrainChanged;
396 
397  protected:
398 
400  void slot_terrainCleared();
401  void slot_oceanLayerAdded(const DtOceanLayer&);
402  void slot_oceanLayerToBeDeleted(const DtOceanLayer&);
403 
404  void updateGlobalTerrainFlag(bool flag);
405 
406  double calcLinearSpeed() const;
407  double calcRotationSpeed() const;
408  double calcOrbitSpeed() const;
409 
410  void getObserverOffsetVector( double& x, double& y, double& z ) const;
411  void setObserverOffsetVector( double x, double y, double z );
412 
413  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
414  void setObserverRotationOffset( double x, double y, double z, double w );
415 
416  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
417  std::set<std::string>& displayNamesOut) const;
418  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
419  std::vector<DtUniqueID>& idsOut) const;
420 
421  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
423  DtObserverObject::AttachType convertObserverSettingsAttachType(
425 
426  void connectToElementDataSignals();
427  void disconnectFromElementDataSignals();
428 
429  void setModeSpecificObserverObjectData();
430 
432  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
433 
435  virtual void slot_onElementAttributesChanged(
436  const DtElementData::EntryAttributesList& attributes );
437 
438  void slot_observerModeModelSetChanged( int observerMode );
439  void slot_observerModeSensorChanged( int observerMode );
440  void slot_observerModeIs2DChanged( int observerMode );
441  void slot_observerModeKeyMapChanged( int observerMode );
442  void slot_observerModeGainPrecisionChanged( int observerMode );
443  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
444  void slot_observerModeRotationSpeedGainChanged( int observerMode );
445  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
446  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
447  void slot_observerModeModelScaleFactorChanged( int observerMode );
448  void slot_observerModeModelScaleTypeChanged( int observerMode );
449  void slot_observerModeSettingChanged( int observerMode, int settingKey );
450  void slot_observerModeAdded( int observerMode );
451 
453  void attachTo( bool afterTrue );
454 
455  protected:
456 
457  static const double theMoveStepSize;
458 
467  std::vector<DtUniqueID> myCurrentAttachments;
468  std::vector<DtUniqueID> mySecondaryAttachments;
470  unsigned int myPartId;
480  };
481 }


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