Equalizer  1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
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 
148  void setDisplayCluster( const std::string& hostname );
149 
151  const std::string& getDisplayCluster() const;
153 
163  EQFABRIC_INL VisitorResult accept( LeafVisitor< V >& visitor );
164 
166  EQFABRIC_INL VisitorResult accept( LeafVisitor< V >& visitor ) const;
167 
168  virtual EQFABRIC_INL void backup();
169  virtual EQFABRIC_INL void restore();
170 
180  EQFABRIC_INL void setMinimumCapabilities( const uint64_t bitmask );
181 
183  EQFABRIC_INL uint64_t getMinimumCapabilities() const;
184 
202  EQFABRIC_INL void setMaximumCapabilities(const uint64_t bitmask);
203 
208  EQFABRIC_INL uint64_t getMaximumCapabilities() const;
209 
215  EQFABRIC_INL uint64_t getCapabilities() const;
217 
218  void setCapabilities( const uint64_t bitmask );
219  virtual void updateCapabilities() {}
220 
222  enum DirtyBits
223  {
224  DIRTY_VIEWPORT = Object::DIRTY_CUSTOM << 0,
225  DIRTY_OBSERVER = Object::DIRTY_CUSTOM << 1,
226  DIRTY_OVERDRAW = Object::DIRTY_CUSTOM << 2,
227  DIRTY_FRUSTUM = Object::DIRTY_CUSTOM << 3,
228  DIRTY_MODE = Object::DIRTY_CUSTOM << 4,
229  DIRTY_MINCAPS = Object::DIRTY_CUSTOM << 5,
230  DIRTY_MAXCAPS = Object::DIRTY_CUSTOM << 6,
231  DIRTY_CAPABILITIES = Object::DIRTY_CUSTOM << 7,
232  DIRTY_EQUALIZER = Object::DIRTY_CUSTOM << 8,
233  DIRTY_EQUALIZERS = Object::DIRTY_CUSTOM << 9,
234  DIRTY_MODELUNIT = Object::DIRTY_CUSTOM << 10,
235  DIRTY_DISPLAYCLUSTER = Object::DIRTY_CUSTOM << 11,
236  DIRTY_VIEW_BITS =
237  DIRTY_VIEWPORT | DIRTY_OBSERVER | DIRTY_OVERDRAW |
238  DIRTY_FRUSTUM | DIRTY_MODE | DIRTY_MINCAPS | DIRTY_MAXCAPS |
239  DIRTY_CAPABILITIES | DIRTY_OBJECT_BITS | DIRTY_EQUALIZER |
240  DIRTY_EQUALIZERS | DIRTY_MODELUNIT | DIRTY_DISPLAYCLUSTER
241  };
242 
243  protected:
245  EQFABRIC_INL View( L* layout );
246 
248  EQFABRIC_INL virtual ~View();
249 
255  virtual bool hasMasterUserData() { return getLayout() != 0; }
256 
262  EQFABRIC_INL virtual uint32_t getUserDataLatency() const;
263 
265  EQFABRIC_INL virtual void serialize( co::DataOStream& os,
266  const uint64_t dirtyBits );
267 
269  EQFABRIC_INL virtual void deserialize( co::DataIStream& is,
270  const uint64_t dirtyBits );
271 
273  EQFABRIC_INL virtual void setDirty( const uint64_t bits );
274 
276  virtual uint64_t getRedistributableBits() const
277  { return DIRTY_VIEW_BITS; }
278 
280  virtual void notifyFrustumChanged() { setDirty( DIRTY_FRUSTUM ); }
281 
282  private:
284  L* const _layout;
285 
287  O* _observer;
288 
289  Equalizer _equalizer;
290 
291  Vector2i _overdraw;
292 
293  uint64_t _minimumCapabilities;
294  uint64_t _maximumCapabilities;
295  uint64_t _capabilities;
296  uint32_t _equalizers;
297  float _modelUnit;
298  std::string _displayCluster;
299 
300  struct BackupData
301  {
302  BackupData();
303 
305  Viewport viewport;
306 
307  Mode mode;
308  }
309  _data, _backup;
310 
311  struct Private;
312  Private* _private; // placeholder for binary-compatible changes
313  };
314 
315  template< class L, class V, class O >
316  EQFABRIC_INL std::ostream& operator << ( std::ostream& os,
317  const View< L, V, O >& view );
318 }
319 }
320 #endif // EQFABRIC_VIEW_H
Render in stereo (left & right eye)
Definition: fabric/view.h:50
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
const std::string & getDisplayCluster() const
EQFABRIC_INL const Equalizer & getEqualizer() const
uint32_t getEqualizers() const
Definition: fabric/view.h:92
EQFABRIC_INL void setObserver(O *observer)
Set the entity tracking this view.
EQFABRIC_INL uint64_t getCapabilities() const
EQFABRIC_INL void setOverdraw(const Vector2i &pixels)
Mode
The current rendering mode.
Definition: fabric/view.h:47
void setDisplayCluster(const std::string &hostname)
Set the DisplayCluster hostname for this view.
virtual bool hasMasterUserData()
The application view instance holds the user data master by default.
Definition: fabric/view.h:255
Mode getMode() const
Definition: fabric/view.h:104
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 void setMaximumCapabilities(const uint64_t bitmask)
Set the maximum desired capabilities for this view.
const L * getLayout() const
Definition: fabric/view.h:68
const O * getObserver() const
const version of getObserver().
Definition: fabric/view.h:80
EQFABRIC_INL bool isActive() const
const Vector2i & getOverdraw() const
Definition: fabric/view.h:86
Render in mono (cyclop eye)
Definition: fabric/view.h:49
Base data transport class for equalizers.
Definition: equalizer.h:38
vmml::vector< 2, int > Vector2i
A two-component integer vector.
Definition: vmmlib.h:42