Equalizer  1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
fabric/observer.h
1 
2 /* Copyright (c) 2009-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 2.1 as published
6  * by the Free Software Foundation.
7  *
8  * This library is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 
18 #ifndef EQFABRIC_OBSERVER_H
19 #define EQFABRIC_OBSERVER_H
20 
21 #include <eq/fabric/api.h>
22 #include <eq/fabric/eye.h> // enum
23 #include <eq/fabric/focusMode.h> // enum
24 #include <eq/fabric/object.h> // base class
25 #include <eq/fabric/types.h>
26 #include <string>
27 #include <vector>
28 
29 namespace eq
30 {
31 namespace fabric
32 {
34  template< class C, class O > class Observer : public Object
35  {
36  public:
39 
55  EQFABRIC_INL bool setHeadMatrix( const Matrix4f& matrix );
56 
58  const Matrix4f& getHeadMatrix() const { return _data.headMatrix; }
59 
60 #ifdef EQ_1_0_API
61 
62  EQFABRIC_INL void setEyeBase( const float eyeBase );
63 
65  EQFABRIC_INL float getEyeBase() const;
66 #endif
67 
75  EQFABRIC_INL void setEyePosition( const Eye eye, const Vector3f& pos );
76 
78  EQFABRIC_INL const Vector3f& getEyePosition( const Eye eye ) const;
79 
80 
82  EQFABRIC_INL void setFocusDistance( const float focusDistance );
83 
85  float getFocusDistance() const { return _data.focusDistance; }
86 
88  EQFABRIC_INL void setFocusMode( const FocusMode focusMode );
89 
91  FocusMode getFocusMode() const { return _data.focusMode; }
92 
94  EQFABRIC_INL void setOpenCVCamera( const int32_t index );
95 
97  int32_t getOpenCVCamera() const { return _data.camera; }
98 
100  EQFABRIC_INL void setVRPNTracker( const std::string& index );
101 
103  const std::string& getVRPNTracker() const { return _data.vrpnTracker; }
104 
106  const C* getConfig() const { return _config; }
107 
109  C* getConfig() { return _config; }
110 
112  ObserverPath getPath() const;
114 
124  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
125 
127  EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
128 
129  virtual void backup();
130  virtual void restore();
131 
132 
133  protected:
135  EQFABRIC_INL Observer( C* config );
136 
138  EQFABRIC_INL virtual ~Observer();
139 
141  virtual void serialize( co::DataOStream& os,
142  const uint64_t dirtyBits );
144  virtual void deserialize( co::DataIStream& is,
145  const uint64_t dirtyBits );
146  virtual void setDirty( const uint64_t bits );
147 
149  enum DirtyBits
150  {
151  DIRTY_EYE_POSITION = Object::DIRTY_CUSTOM << 0,
152  DIRTY_HEAD = Object::DIRTY_CUSTOM << 1,
153  DIRTY_FOCUS = Object::DIRTY_CUSTOM << 2,
154  DIRTY_TRACKER = Object::DIRTY_CUSTOM << 3,
155  DIRTY_OBSERVER_BITS =
156  DIRTY_EYE_POSITION | DIRTY_HEAD | DIRTY_FOCUS | DIRTY_TRACKER |
157  DIRTY_OBJECT_BITS
158  };
159 
161  virtual uint64_t getRedistributableBits() const
162  { return DIRTY_OBSERVER_BITS; }
163 
164  private:
166  C* const _config;
167 
168  struct BackupData
169  {
170  BackupData();
171 
172  Matrix4f headMatrix;
173  Vector3f eyePosition[ NUM_EYES ];
174  float focusDistance;
175  FocusMode focusMode;
176  int32_t camera;
177  std::string vrpnTracker;
178  }
179  _data, _backup;
180 
181  struct Private;
182  Private* _private; // placeholder for binary-compatible changes
183  };
184 
185  template< class C, class O >
186  EQFABRIC_INL std::ostream& operator << ( std::ostream&,
187  const Observer< C, O >& );
188 }
189 }
190 #endif // EQFABRIC_OBSERVER_H
const C * getConfig() const
EQFABRIC_INL bool setHeadMatrix(const Matrix4f &matrix)
Set the head matrix.
EQFABRIC_INL void setFocusDistance(const float focusDistance)
Set the focal distance.
EQFABRIC_INL void setVRPNTracker(const std::string &index)
Set the VRPN tracker device.
Base data transport class for observers.
FocusMode getFocusMode() const
A visitor to traverse leaf nodes of a graph.
Definition: admin/types.h:32
const Matrix4f & getHeadMatrix() const
EQFABRIC_INL void setEyePosition(const Eye eye, const Vector3f &pos)
Set the position of the given eye relative to the observer.
int32_t getOpenCVCamera() const
EQFABRIC_INL const Vector3f & getEyePosition(const Eye eye) const
const std::string & getVRPNTracker() const
Eye
Eye pass bit mask for which is enabled.
Definition: fabric/eye.h:33
LeafVisitor< O > Visitor
The observer visitor type.
vmml::vector< 3, float > Vector3f
A three-component float vector.
Definition: vmmlib.h:48
float getFocusDistance() const
FocusMode
The algorithm to use for observer focal distance calculation.
Definition: focusMode.h:29
vmml::matrix< 4, 4, float > Matrix4f
A 4x4 float matrix.
Definition: vmmlib.h:41
EQFABRIC_INL VisitorResult accept(Visitor &visitor)
Traverse this observer using a observer visitor.
Internal base class for all distributed, inheritable Equalizer objects.
Definition: object.h:41
EQFABRIC_INL void setFocusMode(const FocusMode focusMode)
Set the focal mode.
EQFABRIC_INL void setOpenCVCamera(const int32_t index)
Set the index of the OpenCV camera for tracking.