Equalizer  2.1.0
Parallel Rendering Framework
fabric/view.h
1 
2 /* Copyright (c) 2008-2017, Stefan Eilemann <eile@equalizergraphics.com>
3  * Daniel Nachbaur <danielnachbaur@gmail.com>
4  * Cedric Stalder <cedric.stalder@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License version 2.1 as published
8  * by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef EQFABRIC_VIEW_H
21 #define EQFABRIC_VIEW_H
22 
23 #include <eq/fabric/api.h>
24 #include <eq/fabric/equalizer.h> // member
25 #include <eq/fabric/frame.h> // enum Frame::Buffer
26 #include <eq/fabric/frustum.h> // base class
27 #include <eq/fabric/object.h> // base class
28 #include <eq/fabric/types.h>
29 #include <eq/fabric/viewport.h> // member
30 
31 #define EQ_MM 1000.f
32 #define EQ_CM 100.f
33 #define EQ_DM 10.f
34 #define EQ_M 1.f
35 #define EQ_KM 0.001f
36 #define EQ_UNDEFINED_UNIT -1.f
37 
38 namespace eq
39 {
40 namespace fabric
41 {
43 template <class L, class V, class O>
44 // cppcheck-suppress noConstructor
45 class View : public Object, public Frustum
46 {
47 public:
49  enum Mode
50  {
51  MODE_MONO = 1,
53  };
54 
58  EQFABRIC_INL const Viewport& getViewport() const;
59 
64  L* getLayout() { return _layout; }
69  const L* getLayout() const { return _layout; }
71  EQFABRIC_INL void setObserver(O* observer);
72 
77  O* getObserver() { return _observer; }
79  const O* getObserver() const { return _observer; }
81  EQFABRIC_INL void setOverdraw(const Vector2i& pixels);
82 
84  const Vector2i& getOverdraw() const { return _overdraw; }
86  EQFABRIC_INL void useEqualizer(uint32_t equalizerMask);
87 
89  uint32_t getEqualizers() const { return _equalizers; }
91  EQFABRIC_INL const Equalizer& getEqualizer() const;
92 
94  EQFABRIC_INL Equalizer& getEqualizer();
95 
97  EQFABRIC_INL void setViewport(const Viewport& viewport);
98 
100  Mode getMode() const { return _data.mode; }
107  EQFABRIC_INL virtual void changeMode(const Mode mode);
108 
115  virtual void activateMode(const Mode mode) { _data.mode = mode; }
117  EQFABRIC_INL bool isActive() const;
118 
129  EQFABRIC_INL bool setModelUnit(const float modelUnit);
130 
139  EQFABRIC_INL float getModelUnit() const;
141 
151  EQFABRIC_INL VisitorResult accept(LeafVisitor<V>& visitor);
152 
154  EQFABRIC_INL VisitorResult accept(LeafVisitor<V>& visitor) const;
155 
156  virtual EQFABRIC_INL void backup();
157  virtual EQFABRIC_INL void restore();
158 
168  EQFABRIC_INL void setMinimumCapabilities(const uint64_t bitmask);
169 
171  EQFABRIC_INL uint64_t getMinimumCapabilities() const;
172 
190  EQFABRIC_INL void setMaximumCapabilities(const uint64_t bitmask);
191 
196  EQFABRIC_INL uint64_t getMaximumCapabilities() const;
197 
203  EQFABRIC_INL uint64_t getCapabilities() const;
204 
209  EQFABRIC_INL Frame::Buffer getScreenshotBuffers() const;
211 
212  void setCapabilities(const uint64_t bitmask);
213  virtual void updateCapabilities() {}
214 
215  enum DirtyBits
216  {
217  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 0,
218  DIRTY_OBSERVER = Object::DIRTY_CUSTOM << 1,
219  DIRTY_OVERDRAW = Object::DIRTY_CUSTOM << 2,
220  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3,
221  DIRTY_MODE = Object::DIRTY_CUSTOM << 4,
222  DIRTY_MINCAPS = Object::DIRTY_CUSTOM << 5,
223  DIRTY_MAXCAPS = Object::DIRTY_CUSTOM << 6,
224  DIRTY_CAPABILITIES = Object::DIRTY_CUSTOM << 7,
225  DIRTY_EQUALIZER = Object::DIRTY_CUSTOM << 8,
226  DIRTY_EQUALIZERS = Object::DIRTY_CUSTOM << 9,
227  DIRTY_MODELUNIT = Object::DIRTY_CUSTOM << 10,
228  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 11,
229  DIRTY_SCREENSHOT = Object::DIRTY_CUSTOM << 12,
230  DIRTY_VIEW_BITS =
231  DIRTY_VIEWPORT | DIRTY_OBSERVER | DIRTY_OVERDRAW | DIRTY_FRUSTUM |
232  DIRTY_MODE | DIRTY_MINCAPS | DIRTY_MAXCAPS | DIRTY_CAPABILITIES |
233  DIRTY_OBJECT_BITS | DIRTY_EQUALIZER | DIRTY_EQUALIZERS |
234  DIRTY_MODELUNIT | DIRTY_ATTRIBUTES | DIRTY_SCREENSHOT
235  };
236 
239  {
240  SATTR_DEFLECT_HOST,
241  SATTR_DEFLECT_ID,
242  SATTR_LAST,
243  SATTR_ALL = SATTR_LAST + 5
244  };
245 
247  EQFABRIC_INL
248  const std::string& getSAttribute(const SAttribute attr) const;
249 
251  EQFABRIC_INL
252  static const std::string& getSAttributeString(const SAttribute attr);
253 
254 protected:
256  EQFABRIC_INL explicit View(L* layout);
257 
259  EQFABRIC_INL virtual ~View();
260 
266  virtual bool hasMasterUserData() { return getLayout() != 0; }
272  EQFABRIC_INL virtual uint32_t getUserDataLatency() const;
273 
275  EQFABRIC_INL virtual void serialize(co::DataOStream& os,
276  const uint64_t dirtyBits);
277 
279  EQFABRIC_INL virtual void deserialize(co::DataIStream& is,
280  const uint64_t dirtyBits);
281 
283  EQFABRIC_INL virtual void setDirty(const uint64_t bits);
284 
286  void setSAttribute(const SAttribute attr, const std::string& value)
287  {
288  _sAttributes[attr] = value;
289  setDirty(DIRTY_ATTRIBUTES);
290  }
291 
293  virtual uint64_t getRedistributableBits() const { return DIRTY_VIEW_BITS; }
295  virtual void notifyFrustumChanged() { setDirty(DIRTY_FRUSTUM); }
297  void _setScreenshotBuffers(Frame::Buffer buffers);
298 
299 private:
301  L* const _layout;
302 
304  O* _observer;
305 
306  Equalizer _equalizer;
307 
308  Vector2i _overdraw;
309 
310  uint64_t _minimumCapabilities;
311  uint64_t _maximumCapabilities;
312  uint64_t _capabilities;
313  uint32_t _equalizers;
314  float _modelUnit;
315  Frame::Buffer _screenshotBuffers;
316 
317  struct BackupData
318  {
319  BackupData();
320 
322  Viewport viewport;
323 
324  Mode mode;
325  } _data, _backup;
326 
328  std::string _sAttributes[SATTR_ALL];
329 };
330 
331 template <class L, class V, class O>
332 EQFABRIC_INL std::ostream& operator<<(std::ostream& os,
333  const View<L, V, O>& view);
334 }
335 }
336 #endif // EQFABRIC_VIEW_H
Mode getMode() const
Definition: fabric/view.h:100
EQFABRIC_INL void useEqualizer(uint32_t equalizerMask)
EQFABRIC_INL float getModelUnit() const
Get the model unit of this view.
EQFABRIC_INL VisitorResult accept(LeafVisitor< V > &visitor)
Traverse this view using a view visitor.
Render in mono (cyclop eye)
Definition: fabric/view.h:51
Defines export visibility macros for library EqualizerFabric.
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
A visitor to traverse leaf nodes of a graph.
Definition: leafVisitor.h:29
EQFABRIC_INL uint64_t getMinimumCapabilities() const
const L * getLayout() const
Definition: fabric/view.h:69
const O * getObserver() const
const version of getObserver().
Definition: fabric/view.h:79
DirtyBits
The changed parts of the object since the last pack().
Definition: object.h:107
EQFABRIC_INL uint64_t getMaximumCapabilities() const
Base data transport class for views.
EQFABRIC_INL void setOverdraw(const Vector2i &pixels)
EQFABRIC_INL const std::string & getSAttribute(const SAttribute attr) const
virtual EQFABRIC_INL void changeMode(const Mode mode)
Set the mode of this view.
const Vector2i & getOverdraw() const
Definition: fabric/view.h:84
Mode
The current rendering mode.
Definition: fabric/view.h:49
Render in stereo (left & right eye)
Definition: fabric/view.h:52
EQFABRIC_INL void setObserver(O *observer)
Set the entity tracking this view.
EQFABRIC_INL uint64_t getCapabilities() const
The Equalizer client library.
Definition: eq/agl/types.h:23
uint32_t getEqualizers() const
Definition: fabric/view.h:89
virtual bool hasMasterUserData()
The application view instance holds the user data master by default.
Definition: fabric/view.h:266
EQFABRIC_INL Frame::Buffer getScreenshotBuffers() const
std::ostream & operator<<(std::ostream &os, const AxisEvent &event)
Print the axis event to the given output stream.
Definition: axisEvent.h:49
EQFABRIC_INL const Viewport & getViewport() const
Buffer
Components of the frame are to be used during readback and assembly.
Definition: fabric/frame.h:42
EQFABRIC_INL bool setModelUnit(const float modelUnit)
Set the model unit of this view.
virtual EQFABRIC_INL uint32_t getUserDataLatency() const
The view user data instance uses the config latency by default.
static EQFABRIC_INL const std::string & getSAttributeString(const SAttribute attr)
EQFABRIC_INL void setMinimumCapabilities(const uint64_t bitmask)
Set the minimum required capabilities for this view.
EQFABRIC_INL void setMaximumCapabilities(const uint64_t bitmask)
Set the maximum desired capabilities for this view.
EQFABRIC_INL bool isActive() const
Base data transport class for equalizers.
Definition: equalizer.h:40
EQFABRIC_INL const Equalizer & getEqualizer() const