Equalizer  1.8.0
Parallel Rendering Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
include/eq/fabric/view.h
1 
2 /* Copyright (c) 2008-2013, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2011-2012, Daniel Nachbaur <danielnachbaur@gmail.com>
4  * 2010, 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  class View : public Object, public Frustum
44  {
45  public:
47  enum Mode
48  {
49  MODE_MONO = 1,
51  };
52 
56  EQFABRIC_INL const Viewport& getViewport() const;
57 
62  L* getLayout() { return _layout; }
63 
68  const L* getLayout() const { return _layout; }
69 
71  EQFABRIC_INL void setObserver( O* observer );
72 
77  O* getObserver() { return _observer; }
78 
80  const O* getObserver() const { return _observer; }
81 
83  EQFABRIC_INL void setOverdraw( const Vector2i& pixels );
84 
86  const Vector2i& getOverdraw() const { return _overdraw; }
87 
89  EQFABRIC_INL void useEqualizer( uint32_t equalizerMask );
90 
92  uint32_t getEqualizers() const { return _equalizers; }
93 
95  EQFABRIC_INL const Equalizer& getEqualizer() const;
96 
98  EQFABRIC_INL Equalizer& getEqualizer();
99 
101  EQFABRIC_INL void setViewport( const Viewport& viewport );
102 
104  Mode getMode() const { return _data.mode; }
105 
112  EQFABRIC_INL virtual void changeMode( const Mode mode );
113 
120  virtual void activateMode( const Mode mode ){ _data.mode = mode; }
121 
123  EQFABRIC_INL bool isActive() const;
124 
135  EQFABRIC_INL bool setModelUnit( const float modelUnit );
136 
145  EQFABRIC_INL float getModelUnit() const;
146 
147 #ifdef EQ_1_0_API
148 
153  void setDisplayCluster( const std::string& hostname );
154 
160  const std::string& getDisplayCluster() const;
161 #endif
162 
163 
173  EQFABRIC_INL VisitorResult accept( LeafVisitor< V >& visitor );
174 
176  EQFABRIC_INL VisitorResult accept( LeafVisitor< V >& visitor ) const;
177 
178  virtual EQFABRIC_INL void backup();
179  virtual EQFABRIC_INL void restore();
180 
190  EQFABRIC_INL void setMinimumCapabilities( const uint64_t bitmask );
191 
193  EQFABRIC_INL uint64_t getMinimumCapabilities() const;
194 
212  EQFABRIC_INL void setMaximumCapabilities(const uint64_t bitmask);
213 
218  EQFABRIC_INL uint64_t getMaximumCapabilities() const;
219 
225  EQFABRIC_INL uint64_t getCapabilities() const;
227 
228  void setCapabilities( const uint64_t bitmask );
229  virtual void updateCapabilities() {}
230 
232  enum DirtyBits
233  {
234  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 0,
235  DIRTY_OBSERVER = Object::DIRTY_CUSTOM << 1,
236  DIRTY_OVERDRAW = Object::DIRTY_CUSTOM << 2,
237  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3,
238  DIRTY_MODE = Object::DIRTY_CUSTOM << 4,
239  DIRTY_MINCAPS = Object::DIRTY_CUSTOM << 5,
240  DIRTY_MAXCAPS = Object::DIRTY_CUSTOM << 6,
241  DIRTY_CAPABILITIES = Object::DIRTY_CUSTOM << 7,
242  DIRTY_EQUALIZER = Object::DIRTY_CUSTOM << 8,
243  DIRTY_EQUALIZERS = Object::DIRTY_CUSTOM << 9,
244  DIRTY_MODELUNIT = Object::DIRTY_CUSTOM << 10,
245  DIRTY_ATTRIBUTES = Object::DIRTY_CUSTOM << 11,
246  DIRTY_VIEW_BITS =
247  DIRTY_VIEWPORT | DIRTY_OBSERVER | DIRTY_OVERDRAW |
248  DIRTY_FRUSTUM | DIRTY_MODE | DIRTY_MINCAPS | DIRTY_MAXCAPS |
249  DIRTY_CAPABILITIES | DIRTY_OBJECT_BITS | DIRTY_EQUALIZER |
250  DIRTY_EQUALIZERS | DIRTY_MODELUNIT | DIRTY_ATTRIBUTES
251  };
252 
255  {
256  SATTR_DISPLAYCLUSTER,
257  SATTR_PIXELSTREAM_NAME,
258  SATTR_LAST,
259  SATTR_ALL = SATTR_LAST + 5
260  };
261 
263  EQFABRIC_INL
264  const std::string& getSAttribute( const SAttribute attr ) const;
265 
267  EQFABRIC_INL
268  static const std::string& getSAttributeString( const SAttribute attr );
269 
270  protected:
272  EQFABRIC_INL View( L* layout );
273 
275  EQFABRIC_INL virtual ~View();
276 
282  virtual bool hasMasterUserData() { return getLayout() != 0; }
283 
289  EQFABRIC_INL virtual uint32_t getUserDataLatency() const;
290 
292  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
293  const uint64_t dirtyBits );
294 
296  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
297  const uint64_t dirtyBits );
298 
300  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
301 
303  void setSAttribute( const SAttribute attr, const std::string& value )
304  { _sAttributes[attr] = value; setDirty( DIRTY_ATTRIBUTES ); }
305 
307  virtual uint64_t getRedistributableBits() const
308  { return DIRTY_VIEW_BITS; }
309 
311  virtual void notifyFrustumChanged() { setDirty( DIRTY_FRUSTUM ); }
312 
313  private:
315  L* const _layout;
316 
318  O* _observer;
319 
320  Equalizer _equalizer;
321 
322  Vector2i _overdraw;
323 
324  uint64_t _minimumCapabilities;
325  uint64_t _maximumCapabilities;
326  uint64_t _capabilities;
327  uint32_t _equalizers;
328  float _modelUnit;
329 
330  struct BackupData
331  {
332  BackupData();
333 
335  Viewport viewport;
336 
337  Mode mode;
338  }
339  _data, _backup;
340 
342  std::string _sAttributes[SATTR_ALL];
343 
344  struct Private;
345  Private* _private; // placeholder for binary-compatible changes
346  };
347 
348  template< class L, class V, class O >
349  EQFABRIC_INL std::ostream& operator << ( std::ostream& os,
350  const View< L, V, O >& view );
351 }
352 }
353 #endif // EQFABRIC_VIEW_H
Render in stereo (left & right eye)
EQFABRIC_INL float getModelUnit() const
Get the model unit of this view.
A fractional viewport with methods for manipulation.
Definition: viewport.h:34
EQFABRIC_INL const Viewport & getViewport() const
virtual EQFABRIC_INL void changeMode(const Mode mode)
Set the mode of this view.
EQFABRIC_INL void useEqualizer(uint32_t equalizerMask)
virtual EQFABRIC_INL uint32_t getUserDataLatency() const
The view user data instance uses the config latency by default.
EQFABRIC_INL uint64_t getMaximumCapabilities() const
EQFABRIC_INL uint64_t getMinimumCapabilities() const
EQFABRIC_INL const Equalizer & getEqualizer() const
uint32_t getEqualizers() const
EQFABRIC_INL void setObserver(O *observer)
Set the entity tracking this view.
Base data transport class for views.
EQFABRIC_INL uint64_t getCapabilities() const
EQFABRIC_INL void setOverdraw(const Vector2i &pixels)
virtual bool hasMasterUserData()
The application view instance holds the user data master by default.
static EQFABRIC_INL const std::string & getSAttributeString(const SAttribute attr)
EQFABRIC_INL VisitorResult accept(LeafVisitor< V > &visitor)
Traverse this view using a view visitor.
EQFABRIC_INL void setMinimumCapabilities(const uint64_t bitmask)
Set the minimum required capabilities for this view.
EQFABRIC_INL bool setModelUnit(const float modelUnit)
Set the model unit of this view.
EQFABRIC_INL const std::string & getSAttribute(const SAttribute attr) const
EQFABRIC_INL void setMaximumCapabilities(const uint64_t bitmask)
Set the maximum desired capabilities for this view.
const L * getLayout() const
const O * getObserver() const
const version of getObserver().
EQFABRIC_INL bool isActive() const
const Vector2i & getOverdraw() const
Render in mono (cyclop eye)
Base data transport class for equalizers.
Definition: equalizer.h:38