Equalizer  1.11.0
Parallel Rendering Framework
fabric/view.h
1 
2 /* Copyright (c) 2008-2015, 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/frustum.h> // base class
26 #include <eq/fabric/object.h> // base class
27 #include <eq/fabric/types.h>
28 #include <eq/fabric/viewport.h> // member
29 
30 #define EQ_MM 1000.f
31 #define EQ_CM 100.f
32 #define EQ_DM 10.f
33 #define EQ_M 1.f
34 #define EQ_KM 0.001f
35 #define EQ_UNDEFINED_UNIT -1.f
36 
37 namespace eq
38 {
39 namespace fabric
40 {
42 template< class L, class V, class O >
43 // cppcheck-suppress noConstructor
44 class View : public Object, public Frustum
45 {
46 public:
48  enum Mode
49  {
50  MODE_MONO = 1,
52  };
53 
57  EQFABRIC_INL const Viewport& getViewport() const;
58 
63  L* getLayout() { return _layout; }
64 
69  const L* getLayout() const { return _layout; }
70 
72  EQFABRIC_INL void setObserver( O* observer );
73 
78  O* getObserver() { return _observer; }
79 
81  const O* getObserver() const { return _observer; }
82 
84  EQFABRIC_INL void setOverdraw( const Vector2i& pixels );
85 
87  const Vector2i& getOverdraw() const { return _overdraw; }
88 
90  EQFABRIC_INL void useEqualizer( uint32_t equalizerMask );
91 
93  uint32_t getEqualizers() const { return _equalizers; }
94 
96  EQFABRIC_INL const Equalizer& getEqualizer() const;
97 
99  EQFABRIC_INL Equalizer& getEqualizer();
100 
102  EQFABRIC_INL void setViewport( const Viewport& viewport );
103 
105  Mode getMode() const { return _data.mode; }
106 
113  EQFABRIC_INL virtual void changeMode( const Mode mode );
114 
121  virtual void activateMode( const Mode mode ){ _data.mode = mode; }
122 
124  EQFABRIC_INL bool isActive() const;
125 
136  EQFABRIC_INL bool setModelUnit( const float modelUnit );
137 
146  EQFABRIC_INL float getModelUnit() const;
148 
158  EQFABRIC_INL VisitorResult accept( LeafVisitor< V >& visitor );
159 
161  EQFABRIC_INL VisitorResult accept( LeafVisitor< V >& visitor ) const;
162 
163  virtual EQFABRIC_INL void backup();
164  virtual EQFABRIC_INL void restore();
165 
175  EQFABRIC_INL void setMinimumCapabilities( const uint64_t bitmask );
176 
178  EQFABRIC_INL uint64_t getMinimumCapabilities() const;
179 
197  EQFABRIC_INL void setMaximumCapabilities(const uint64_t bitmask);
198 
203  EQFABRIC_INL uint64_t getMaximumCapabilities() const;
204 
210  EQFABRIC_INL uint64_t getCapabilities() const;
212 
213  void setCapabilities( const uint64_t bitmask );
214  virtual void updateCapabilities() {}
215 
217  enum DirtyBits
218  {
219  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 0,
220  DIRTY_OBSERVER = Object::DIRTY_CUSTOM << 1,
221  DIRTY_OVERDRAW = Object::DIRTY_CUSTOM << 2,
222  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3,
223  DIRTY_MODE = Object::DIRTY_CUSTOM << 4,
224  DIRTY_MINCAPS = Object::DIRTY_CUSTOM << 5,
225  DIRTY_MAXCAPS = Object::DIRTY_CUSTOM << 6,
226  DIRTY_CAPABILITIES = Object::DIRTY_CUSTOM << 7,
227  DIRTY_EQUALIZER = Object::DIRTY_CUSTOM << 8,
228  DIRTY_EQUALIZERS = Object::DIRTY_CUSTOM << 9,
229  DIRTY_MODELUNIT = Object::DIRTY_CUSTOM << 10,
230  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 11,
231  DIRTY_VIEW_BITS =
232  DIRTY_VIEWPORT | DIRTY_OBSERVER | DIRTY_OVERDRAW |
233  DIRTY_FRUSTUM | DIRTY_MODE | DIRTY_MINCAPS | DIRTY_MAXCAPS |
234  DIRTY_CAPABILITIES | DIRTY_OBJECT_BITS | DIRTY_EQUALIZER |
235  DIRTY_EQUALIZERS | DIRTY_MODELUNIT | DIRTY_ATTRIBUTES
236  };
237 
240  {
241  SATTR_DISPLAYCLUSTER,
242  SATTR_PIXELSTREAM_NAME,
243  SATTR_LAST,
244  SATTR_ALL = SATTR_LAST + 5
245  };
246 
248  EQFABRIC_INL
249  const std::string& getSAttribute( const SAttribute attr ) const;
250 
252  EQFABRIC_INL
253  static const std::string& getSAttributeString( const SAttribute attr );
254 
255 protected:
257  EQFABRIC_INL explicit View( L* layout );
258 
260  EQFABRIC_INL virtual ~View();
261 
267  virtual bool hasMasterUserData() { return getLayout() != 0; }
268 
274  EQFABRIC_INL virtual uint32_t getUserDataLatency() const;
275 
277  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
278  const uint64_t dirtyBits );
279 
281  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
282  const uint64_t dirtyBits );
283 
285  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
286 
288  void setSAttribute( const SAttribute attr, const std::string& value )
289  { _sAttributes[attr] = value; setDirty( DIRTY_ATTRIBUTES ); }
290 
292  virtual uint64_t getRedistributableBits() const
293  { return DIRTY_VIEW_BITS; }
294 
296  virtual void notifyFrustumChanged() { setDirty( DIRTY_FRUSTUM ); }
297 
298 private:
300  L* const _layout;
301 
303  O* _observer;
304 
305  Equalizer _equalizer;
306 
307  Vector2i _overdraw;
308 
309  uint64_t _minimumCapabilities;
310  uint64_t _maximumCapabilities;
311  uint64_t _capabilities;
312  uint32_t _equalizers;
313  float _modelUnit;
314 
315  struct BackupData
316  {
317  BackupData();
318 
320  Viewport viewport;
321 
322  Mode mode;
323  }
324  _data, _backup;
325 
327  std::string _sAttributes[SATTR_ALL];
328 
329  struct Private;
330  Private* _private; // placeholder for binary-compatible changes
331 };
332 
333 template< class L, class V, class O >
334 EQFABRIC_INL std::ostream& operator << ( std::ostream& os,
335  const View< L, V, O >& view );
336 }
337 }
338 #endif // EQFABRIC_VIEW_H
Mode getMode() const
Definition: fabric/view.h:105
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:50
Defines export visibility macros for library EqualizerFabric.
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
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:81
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:87
Mode
The current rendering mode.
Definition: fabric/view.h:48
Render in stereo (left & right eye)
Definition: fabric/view.h:51
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:93
virtual bool hasMasterUserData()
The application view instance holds the user data master by default.
Definition: fabric/view.h:267
EQFABRIC_INL const Viewport & getViewport() const
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:38
EQFABRIC_INL const Equalizer & getEqualizer() const