VR-Forces 4.1.1 Class Documentation
DtObserver.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2008 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtObserver.h,v $ $Revision: 1.43 $ $State: Exp $
7 ******************************************************************************/
8 
12 
13 #pragma once
14 
15 #include <vrvCore/vrvCore.h>
16 #include <vrvCore/DtElementData.h>
17 #include <vrvCore/DtUniqueID.h>
20 
23 
24 #include <boost/signals.hpp>
25 
26 #include <string>
27 #include <vector>
28 
29 class DtTaitBryan;
30 class DtVector;
31 
32 namespace makVrv
33 {
34  class DtObserverObjectAgent;
35  class DtDe;
36  class DtAgentManagerInterface;
37  class DtObserverConfiguration;
38  class DtSensor;
39 
43  {
44  public:
45 
46  typedef std::vector<DtElementID> ElementList;
47 
49  DtObserver(DtDe& de, DtAgentManagerInterface& sceneInterface,
50  const DtObserverConfiguration& config );
51 
53  ~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 
81  bool hasInitialLocation() const;
82 
84  const std::string& name() const;
85  void setName( const std::string& name );
86 
88  int observerMode() const;
89 
91  void setObserverMode( int observerMode );
92 
94  double viewResolution() const;
95 
97  void setViewResolution( double resolution );
98 
100  double viewMagnification() const;
101 
103  void setViewMagnification( double magnficationFactor );
104 
107  bool acceptingViewControl() const;
108 
109  DtObserverConfiguration& configuration();
110  const DtObserverConfiguration& configuration() const;
111 
113  bool inUse( const std::string& channelKeyToIgnore = "" ) const;
114 
115  //@name Attachment functions.
117 
119  void attachToNextElement();
120 
122  void attachToPreviousElement();
123 
125  bool isAttached(DtElementID) const;
126 
128  bool isPrimaryAttached(DtElementID) const;
129 
131  bool isSecondaryAttached(DtElementID) const;
132 
136  void setPrimaryAttachment( const ElementList& element );
137 
142  void setSecondaryAttachment( const ElementList& objects );
143 
147  void setPartAttachment(int partId);
148 
150  int partAttachment() const;
151 
153  void detach();
154 
156  bool attached() const;
157 
159  bool tracking() const;
160 
162  const ElementList& primaryAttachments() const;
163 
165  const ElementList& secondaryAttachments() const;
166 
167  void setHideModelOnAttach( bool hide );
168  bool hideModelOnAttach() const;
169 
170  void setAttachType( DtObserverObject::AttachType type );
171  DtObserverObject::AttachType attachType() const;
172 
173  void setOrientToTargetConstraint( bool orient );
174  bool orientToTargetConstraint() const;
175 
178  DtElementID lastSingleAttached() const;
179 
181  bool haveLastSingleAttached() const;
182 
184 
185  //@name Movement functions
187 
190  void reset();
191 
194  void setAllowReset(bool b);
195 
197  bool allowReset() const;
198 
200  void setAllowAttach(bool b);
201 
203  bool allowAttach() const;
204 
206  void setAllowDetach(bool b);
207 
209  bool allowDetach() const;
210 
212  void centerOnTerrain();
213 
215  void centerOnTerrain( const DtUniqueID& terrainPatch );
216 
219  void suppressConstrainToTerrain( bool trueFalse );
220 
222  void setConstrainToCenter( bool trueFalse );
223  void toggleConstrainToCenter();
224  bool constrainToCenter() const;
225 
227  void getLocation( double &x, double &y, double& z ) const;
228 
230  DtVector location() const;
231 
233  void setLocation( double x, double y, double z );
234 
236  void getOrientation( double& psi, double& theta, double& phi ) const;
237 
239  void setOrientation( double psi, double theta, double phi );
240 
242  void getOrientation( double& x, double& y, double& z, double& w ) const;
243 
245  void setOrientation( double x, double y, double z, double w );
246 
249  void moveUnit(const DtVector& direction);
250 
253  void rotateUnit(const DtTaitBryan& rotation);
254 
256  void getLinearVelocity(double &x, double &y, double &z) const;
257 
259  void getRotationalVelocity( double& x, double& y, double& z ) const;
260 
262  bool observerObjectMoving() const;
263 
265  double observerAltitude() const;
267 
268  //@name Attached Movement functions
270 
273  void setAttachedLocation( double x, double y, double z );
274 
277  void setAttachedOrientation( double psi, double theta, double phi );
278 
281  void setLocalModelScalingEnabled( bool enabled );
282 
285  void setLocalModelScalingAmount( float amount );
286 
288 
289  //@name Speed functions
291 
293  void setOrbitSpeedGain( int gain, bool forwardToObserverModeManager = true );
294 
296  int orbitSpeedGain() const;
297 
299  int orbitSpeedGainFromSpeed( double speed ) const;
300 
301  void setRotationSpeedGain( int gain, bool forwardToObserverModeManager = true );
302  int rotationSpeedGain() const;
303 
305  void setLinearSpeedGain( int gain );
306  int linearSpeedGain() const;
307 
308  void setLinearScaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
309  int linearScaledSpeedGain() const;
310 
311  void setLinearUnscaledSpeedGain( int gain, bool forwardToObserverModeManager = true );
312  int linearUnscaledSpeedGain() const;
313 
314  void setGainPrecision( int amt, bool forwardToObserverModeManager = true );
315  int gainPrecision() const;
316 
317  void setModelScaleFactor( double modelScaleFactor, bool forwardToObserverModeManager = true );
318  double modelScaleFactor() const;
319 
320  void setModelScaleType( DtObserverObject::ScaleType modelScaleType,
321  bool forwardToObserverModeManager = true );
322  DtObserverObject::ScaleType modelScaleType() const;
323 
324  void setOrbitSpeed( double speed );
325  double orbitSpeed() const;
326 
327  void setRotationSpeed( double speed );
328  double rotationSpeed() const;
329 
330  void setLinearSpeed( double speed );
331  double linearSpeed() const;
332 
334 
335  //@name Sensor functions
337 
338  virtual void setSensor(const std::string& sensorName);
339 
341  virtual std::string findSensor();
342 
344  virtual void disableSensor();
345 
347  virtual void slot_sensorRemoved(DtSensor* sensor);
349 
350  // Called by the input driver before any mouse or keyboard input is processed for the
351  // frame, to sync local and remote observers.
352  virtual void synchronize();
353 
355  boost::signal<void(const std::string&, DtUniqueID)> signal_objectAttached;
356 
358  boost::signal<void(const std::string&)> signal_objectsDetached;
359 
361  boost::signal<void(DtObserver*, int)> signal_observerModeChanged;
362 
364  boost::signal<void(DtObserver*, int)> signal_linearScaledSpeedGainChanged;
365 
367  boost::signal<void(DtObserver*, int)> signal_linearUnscaledSpeedGainChanged;
368 
370  boost::signal<void(DtObserver*, int)> signal_rotationSpeedGainChanged;
371 
373  boost::signal<void(DtObserver*, int)> signal_orbitSpeedGainChanged;
374 
376  boost::signal<void(DtObserver*, int)> signal_gainPrecisionChanged;
377 
379  boost::signal<void(DtObserver*, double)> signal_modelScaleFactorChanged;
380 
382  boost::signal<void(DtObserver*, DtObserverObject::ScaleType)> signal_modelScaleTypeChanged;
383 
385  boost::signal<void(DtObserver*, double)> signal_viewMagnificationChanged;
386 
390  boost::signal<void (DtSensor*)> signal_sensorChanged;
391 
392  protected:
393 
395  void slot_terrainCleared();
396 
397  void updateGlobalTerrainFlag(bool flag);
398 
399  double calcLinearSpeed() const;
400  double calcRotationSpeed() const;
401  double calcOrbitSpeed() const;
402 
403  void getObserverOffsetVector( double& x, double& y, double& z ) const;
404  void setObserverOffsetVector( double x, double y, double z );
405 
406  void getObserverRotationOffset( double& x, double& y, double& z, double& w ) const;
407  void setObserverRotationOffset( double x, double y, double z, double w );
408 
409  void getDisplayNamesFromUniqueIds(const std::vector<DtUniqueID>& idsIn,
410  std::set<std::string>& displayNamesOut) const;
411  bool getUniqueIdsFromDisplayNames(const std::set<std::string>& displayNamesIn,
412  std::vector<DtUniqueID>& idsOut) const;
413 
414  makArchives::DtObserverSettingsRecord::AttachType convertObserverAttachType(
415  DtObserverObject::AttachType type) const;
416  DtObserverObject::AttachType convertObserverSettingsAttachType(
418 
419  void connectToElementDataSignals();
420  void disconnectFromElementDataSignals();
421 
422  void setModeSpecificObserverObjectData();
423 
425  virtual void slot_onElementsAdded( const DtElementData::ElementList& elements );
426 
428  virtual void slot_onElementAttributesChanged(
429  const DtElementData::EntryAttributesList& attributes );
430 
431  void slot_observerModeModelSetChanged( int observerMode );
432  void slot_observerModeSensorChanged( int observerMode );
433  void slot_observerModeIs2DChanged( int observerMode );
434  void slot_observerModeKeyMapChanged( int observerMode );
435  void slot_observerModeGainPrecisionChanged( int observerMode );
436  void slot_observerModeOrbitSpeedGainChanged( int observerMode );
437  void slot_observerModeRotationSpeedGainChanged( int observerMode );
438  void slot_observerModeLinearScaledSpeedGainChanged( int observerMode );
439  void slot_observerModeLinearUnscaledSpeedGainChanged( int observerMode );
440  void slot_observerModeModelScaleFactorChanged( int observerMode );
441  void slot_observerModeModelScaleTypeChanged( int observerMode );
442  void slot_observerModeSettingChanged( int observerMode, int settingKey );
443  void slot_observerModeAdded( int observerMode );
444 
446  void attachTo( bool afterTrue );
447 
448  protected:
449 
450  static const double theMoveStepSize;
451 
454  DtObserverObjectAgent* myObserverObjectAgent;
460  std::vector<DtUniqueID> myCurrentAttachments;
461  std::vector<DtUniqueID> mySecondaryAttachments;
463  unsigned int myPartId;
473  };
474 }

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)