Equalizer  1.4.1
include/eq/fabric/view.h
00001 
00002 /* Copyright (c) 2008-2012, Stefan Eilemann <eile@equalizergraphics.com>
00003  *                    2010, Cedric Stalder <cedric.stalder@gmail.com>
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef EQFABRIC_VIEW_H
00020 #define EQFABRIC_VIEW_H
00021 
00022 #include <eq/fabric/api.h>
00023 #include <eq/fabric/frustum.h>        // base class
00024 #include <eq/fabric/object.h>         // base class
00025 #include <eq/fabric/types.h>
00026 #include <eq/fabric/viewport.h>       // member
00027 #include <eq/fabric/visitorResult.h>  // enum
00028 
00029 #define EQ_MM 1000.f
00030 #define EQ_CM 100.f
00031 #define EQ_DM 10.f
00032 #define EQ_M  1.f
00033 #define EQ_KM 0.001f
00034 #define EQ_UNDEFINED_UNIT -1.f
00035 
00036 namespace eq
00037 {
00038 namespace fabric
00039 {
00041     template< class L, class V, class O >
00042     class View : public Object, public Frustum
00043     {
00044     public:
00046         enum Mode
00047         {
00048             MODE_MONO = 1,   
00049             MODE_STEREO      
00050         };
00051 
00055         EQFABRIC_INL const Viewport& getViewport() const;
00056 
00061         L* getLayout() { return _layout; }
00062 
00067         const L* getLayout() const { return _layout; }
00068 
00070         EQFABRIC_INL void setObserver( O* observer );
00071         
00076         O* getObserver() { return _observer; }
00077 
00079         const O* getObserver() const { return _observer; }
00080 
00082         EQFABRIC_INL virtual void setWall( const Wall& wall );
00083         
00085         EQFABRIC_INL virtual void setProjection( const Projection& );
00086 
00088         EQFABRIC_INL virtual void unsetFrustum();
00089 
00091         EQFABRIC_INL void setOverdraw( const Vector2i& pixels );
00092 
00094         const Vector2i& getOverdraw() const { return _data.overdraw; }
00095 
00097         EQFABRIC_INL void useEqualizer( uint32_t equalizerMask );
00098 
00100         uint32_t getEqualizers() const { return _data.equalizers; }
00101 
00103         EQFABRIC_INL void setTileSize( const Vector2i& size );
00104 
00106         const Vector2i& getTileSize() const { return _data.tileSize; }
00107 
00109         EQFABRIC_INL void setViewport( const Viewport& viewport );
00110 
00112         Mode getMode() const { return _data.mode; }
00113         
00120         EQFABRIC_INL virtual void changeMode( const Mode mode );
00121         
00128         virtual void activateMode( const Mode mode ){ _data.mode = mode; }
00129 
00131         EQFABRIC_INL bool isActive() const;
00132 
00143         EQFABRIC_INL bool setModelUnit( const float modelUnit );
00144 
00153         EQFABRIC_INL float getModelUnit() const;
00155 
00165         EQFABRIC_INL VisitorResult accept( LeafVisitor< V >& visitor );
00166 
00168         EQFABRIC_INL VisitorResult accept( LeafVisitor< V >& visitor ) const;
00169 
00170         virtual EQFABRIC_INL void backup(); 
00171         virtual EQFABRIC_INL void restore(); 
00172 
00182         EQFABRIC_INL void setMinimumCapabilities( const uint64_t bitmask );
00183 
00185         EQFABRIC_INL uint64_t getMinimumCapabilities() const;
00186 
00204         EQFABRIC_INL void setMaximumCapabilities(const uint64_t bitmask);
00205 
00210         EQFABRIC_INL uint64_t getMaximumCapabilities() const;
00211 
00217         EQFABRIC_INL uint64_t getCapabilities() const;
00219 
00220         void setCapabilities( const uint64_t bitmask ); 
00221         virtual void updateCapabilities() {} 
00222 
00224         enum DirtyBits
00225         {
00226             DIRTY_VIEWPORT      = Object::DIRTY_CUSTOM << 0,
00227             DIRTY_OBSERVER      = Object::DIRTY_CUSTOM << 1,
00228             DIRTY_OVERDRAW      = Object::DIRTY_CUSTOM << 2,
00229             DIRTY_FRUSTUM       = Object::DIRTY_CUSTOM << 3,
00230             DIRTY_MODE          = Object::DIRTY_CUSTOM << 4,
00231             DIRTY_MINCAPS       = Object::DIRTY_CUSTOM << 5,
00232             DIRTY_MAXCAPS       = Object::DIRTY_CUSTOM << 6,
00233             DIRTY_CAPABILITIES  = Object::DIRTY_CUSTOM << 7,
00234             DIRTY_TILESIZE      = Object::DIRTY_CUSTOM << 8,
00235             DIRTY_EQUALIZERS    = Object::DIRTY_CUSTOM << 9,
00236             DIRTY_MODELUNIT     = Object::DIRTY_CUSTOM << 10,
00237             DIRTY_VIEW_BITS =
00238                 DIRTY_VIEWPORT | DIRTY_OBSERVER | DIRTY_OVERDRAW |
00239                 DIRTY_FRUSTUM | DIRTY_MODE | DIRTY_MINCAPS | DIRTY_MAXCAPS |
00240                 DIRTY_CAPABILITIES | DIRTY_OBJECT_BITS | DIRTY_TILESIZE |
00241                 DIRTY_EQUALIZERS | DIRTY_MODELUNIT
00242         };
00243 
00244     protected:
00246         EQFABRIC_INL View( L* layout );
00247 
00249         EQFABRIC_INL virtual ~View();
00250 
00256         virtual bool hasMasterUserData() { return getLayout() != 0; }
00257 
00263         EQFABRIC_INL virtual uint32_t getUserDataLatency() const;
00264 
00266         EQFABRIC_INL virtual void serialize( co::DataOStream& os,
00267                                              const uint64_t dirtyBits );
00268 
00270         EQFABRIC_INL virtual void deserialize( co::DataIStream& is, 
00271                                                const uint64_t dirtyBits );
00272 
00274         EQFABRIC_INL virtual void setDirty( const uint64_t bits );
00275 
00277         virtual uint64_t getRedistributableBits() const
00278             { return DIRTY_VIEW_BITS; }
00279 
00280     private:
00282         L* const _layout;
00283 
00285         O* _observer;
00286 
00287         struct BackupData
00288         {
00289             BackupData();
00290 
00292             Viewport viewport;
00293 
00295             Vector2i overdraw;
00296 
00297             Vector2i tileSize; 
00298 
00299             uint64_t minimumCapabilities; 
00300             uint64_t maximumCapabilities; 
00301             uint64_t capabilities; 
00302         
00303             Mode mode; 
00304             uint32_t equalizers; 
00305 
00306             float modelUnit;
00307         }
00308             _data, _backup;
00309 
00310         struct Private;
00311         Private* _private; // placeholder for binary-compatible changes
00312     };
00313 
00314     template< class L, class V, class O >
00315     EQFABRIC_INL std::ostream& operator << ( std::ostream& os,
00316                                              const View< L, V, O >& view );
00317 }
00318 }
00319 #endif // EQFABRIC_VIEW_H
Generated on Mon Nov 26 2012 14:41:50 for Equalizer 1.4.1 by  doxygen 1.7.6.1