Equalizer  1.11.0
Parallel Rendering Framework
fabric/observer.h
1 
2 /* Copyright (c) 2009-2016, 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/vmmlib.h>
26 #include <string>
27 #include <vector>
28 
29 namespace eq
30 {
31 namespace fabric
32 {
34 // cppcheck-suppress noConstructor
35 template< class C, class O > class Observer : public Object
36 {
37 public:
40 
56  EQFABRIC_INL bool setHeadMatrix( const Matrix4f& matrix );
57 
59  const Matrix4f& getHeadMatrix() const { return _data.headMatrix; }
60 
69  EQFABRIC_INL void setEyePosition( const Eye eye, const Vector3f& pos );
70 
72  EQFABRIC_INL const Vector3f& getEyePosition( const Eye eye ) const;
73 
74 
76  EQFABRIC_INL void setFocusDistance( const float focusDistance );
77 
79  float getFocusDistance() const { return _data.focusDistance; }
80 
82  EQFABRIC_INL void setFocusMode( const FocusMode focusMode );
83 
85  FocusMode getFocusMode() const { return _data.focusMode; }
86 
88  EQFABRIC_INL void setOpenCVCamera( const int32_t index );
89 
91  int32_t getOpenCVCamera() const { return _data.camera; }
92 
94  EQFABRIC_INL void setVRPNTracker( const std::string& index );
95 
97  const std::string& getVRPNTracker() const { return _data.vrpnTracker; }
98 
100  const C* getConfig() const { return _config; }
101 
103  C* getConfig() { return _config; }
104 
106  ObserverPath getPath() const;
108 
118  EQFABRIC_INL VisitorResult accept( Visitor& visitor );
119 
121  EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
122 
123  virtual void backup();
124  virtual void restore();
125 
126 
127 protected:
129  EQFABRIC_INL explicit Observer( C* config );
130 
132  EQFABRIC_INL virtual ~Observer();
133 
135  virtual void serialize( co::DataOStream& os,
136  const uint64_t dirtyBits );
138  virtual void deserialize( co::DataIStream& is,
139  const uint64_t dirtyBits );
140  virtual void setDirty( const uint64_t bits );
141 
143  enum DirtyBits
144  {
145  DIRTY_EYE_POSITION = Object::DIRTY_CUSTOM << 0,
146  DIRTY_HEAD = Object::DIRTY_CUSTOM << 1,
147  DIRTY_FOCUS = Object::DIRTY_CUSTOM << 2,
148  DIRTY_TRACKER = Object::DIRTY_CUSTOM << 3,
149  DIRTY_OBSERVER_BITS =
150  DIRTY_EYE_POSITION | DIRTY_HEAD | DIRTY_FOCUS | DIRTY_TRACKER |
151  DIRTY_OBJECT_BITS
152  };
153 
155  virtual uint64_t getRedistributableBits() const
156  { return DIRTY_OBSERVER_BITS; }
157 
158 private:
160  C* const _config;
161 
162  struct BackupData
163  {
164  BackupData();
165 
166  Matrix4f headMatrix;
167  Vector3f eyePosition[ NUM_EYES ];
168  float focusDistance;
169  FocusMode focusMode;
170  int32_t camera;
171  std::string vrpnTracker;
172  }
173  _data, _backup;
174 
175  struct Private;
176  Private* _private; // placeholder for binary-compatible changes
177 };
178 
179 template< class C, class O >
180 EQFABRIC_INL std::ostream& operator << ( std::ostream&,
181  const Observer< C, O >& );
182 }
183 }
184 #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.
Defines export visibility macros for library EqualizerFabric.
Base data transport class for observers.
FocusMode getFocusMode() const
A visitor to traverse leaf nodes of a graph.
Definition: leafVisitor.h:28
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.
float getFocusDistance() const
FocusMode
The algorithm to use for observer focal distance calculation.
Definition: focusMode.h:29
The Equalizer client library.
Definition: eq/agl/types.h:23
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.