Equalizer  2.1.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>
36 class Observer : public Object
37 {
38 public:
41 
57  EQFABRIC_INL bool setHeadMatrix(const Matrix4f& matrix);
58 
60  const Matrix4f& getHeadMatrix() const { return _data.headMatrix; }
69  EQFABRIC_INL void setEyePosition(const Eye eye, const Vector3f& pos);
70 
72  EQFABRIC_INL const Vector3f& getEyePosition(const Eye eye) const;
73 
75  EQFABRIC_INL void setFocusDistance(const float focusDistance);
76 
78  float getFocusDistance() const { return _data.focusDistance; }
80  EQFABRIC_INL void setFocusMode(const FocusMode focusMode);
81 
83  FocusMode getFocusMode() const { return _data.focusMode; }
85  EQFABRIC_INL void setOpenCVCamera(const int32_t index);
86 
88  int32_t getOpenCVCamera() const { return _data.camera; }
90  EQFABRIC_INL void setVRPNTracker(const std::string& index);
91 
93  const std::string& getVRPNTracker() const { return _data.vrpnTracker; }
95  const C* getConfig() const { return _config; }
97  C* getConfig() { return _config; }
99  ObserverPath getPath() const;
101 
111  EQFABRIC_INL VisitorResult accept(Visitor& visitor);
112 
114  EQFABRIC_INL VisitorResult accept(Visitor& visitor) const;
115 
116  virtual void backup();
117  virtual void restore();
118 
119 
120 protected:
122  EQFABRIC_INL explicit Observer(C* config);
123 
125  EQFABRIC_INL virtual ~Observer();
126 
128  virtual void serialize(co::DataOStream& os, const uint64_t dirtyBits);
130  virtual void deserialize(co::DataIStream& is, const uint64_t dirtyBits);
131  virtual void setDirty(const uint64_t bits);
132 
134  enum DirtyBits
135  {
136  DIRTY_EYE_POSITION = Object::DIRTY_CUSTOM << 0,
137  DIRTY_HEAD = Object::DIRTY_CUSTOM << 1,
138  DIRTY_FOCUS = Object::DIRTY_CUSTOM << 2,
139  DIRTY_TRACKER = Object::DIRTY_CUSTOM << 3,
140  DIRTY_OBSERVER_BITS = DIRTY_EYE_POSITION | DIRTY_HEAD | DIRTY_FOCUS |
141  DIRTY_TRACKER | DIRTY_OBJECT_BITS
142  };
143 
145  virtual uint64_t getRedistributableBits() const
146  {
147  return DIRTY_OBSERVER_BITS;
148  }
149 
150 private:
152  C* const _config;
153 
154  struct BackupData
155  {
156  BackupData();
157 
158  Matrix4f headMatrix;
159  Vector3f eyePosition[NUM_EYES];
160  float focusDistance;
161  FocusMode focusMode;
162  int32_t camera;
163  std::string vrpnTracker;
164  } _data, _backup;
165 
166  struct Private;
167  Private* _private; // placeholder for binary-compatible changes
168 };
169 
170 template <class C, class O>
171 EQFABRIC_INL std::ostream& operator<<(std::ostream&, const Observer<C, O>&);
172 }
173 }
174 #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:29
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
LeafVisitor< O > Visitor
The observer visitor type.
const std::string & getVRPNTracker() const
DirtyBits
The changed parts of the object since the last pack().
Definition: object.h:107
Eye
Eye pass bit mask for which rendering is enabled.
Definition: fabric/eye.h:31
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:44
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.