LCOV - code coverage report
Current view: top level - eq/fabric - observer.h (source / functions) Hit Total Coverage
Test: lcov2.info Lines: 9 10 90.0 %
Date: 2014-06-18 Functions: 11 20 55.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2009-2013, Stefan Eilemann <eile@equalizergraphics.com>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : #ifndef EQFABRIC_OBSERVER_H
      19             : #define EQFABRIC_OBSERVER_H
      20             : 
      21             : #include <eq/fabric/api.h>
      22             : #include <eq/fabric/eye.h>           // enum
      23             : #include <eq/fabric/focusMode.h>     // enum
      24             : #include <eq/fabric/object.h>        // base class
      25             : #include <eq/fabric/types.h>
      26             : #include <string>
      27             : #include <vector>
      28             : 
      29             : namespace eq
      30             : {
      31             : namespace fabric
      32             : {
      33             :     /** Base data transport class for observers. @sa eq::Observer */
      34             :     template< class C, class O > class Observer : public Object
      35             :     {
      36             :     public:
      37             :         /** The observer visitor type. @version 1.0 */
      38             :         typedef LeafVisitor< O > Visitor;
      39             : 
      40             :         /** @name Data Access */
      41             :         //@{
      42             :         /**
      43             :          * Set the head matrix.
      44             :          *
      45             :          * The head matrix specifies the transformation origin->observer.
      46             :          * Together with the eye separation, this determines the eye positions
      47             :          * in the global coordinate system. The eye position and wall or
      48             :          * projection description define the shape of the frustum and the
      49             :          * channel's head transformation during rendering.
      50             :          *
      51             :          * @param matrix the matrix
      52             :          * @return true if the matrix was changed, false otherwise.
      53             :          * @version 1.0
      54             :          */
      55             :         EQFABRIC_INL bool setHeadMatrix( const Matrix4f& matrix );
      56             : 
      57             :         /** @return the current head matrix. @version 1.0 */
      58         241 :         const Matrix4f& getHeadMatrix() const { return _data.headMatrix; }
      59             : 
      60             : #ifdef EQ_1_0_API
      61             :         /** @deprecated Use setEyePosition() */
      62             :         EQFABRIC_INL void setEyeBase( const float eyeBase );
      63             : 
      64             :         /** @deprecated Use getEyePosition() */
      65             :         EQFABRIC_INL float getEyeBase() const;
      66             : #endif
      67             :         /**
      68             :          * Set the position of the given eye relative to the observer.
      69             :          *
      70             :          * A standard symmetric eye setup uses (+-eyeBase/2, 0, 0).
      71             :          * @param eye the eye to update.
      72             :          * @param pos the new eye position.
      73             :          * @version 1.5.2
      74             :          */
      75             :         EQFABRIC_INL void setEyePosition( const Eye eye, const Vector3f& pos );
      76             : 
      77             :         /** @return the position of the given eye. @version 1.5.2 */
      78             :         EQFABRIC_INL const Vector3f& getEyePosition( const Eye eye ) const;
      79             : 
      80             : 
      81             :         /** Set the focal distance. @sa setFocusMode @version 1.1 */
      82             :         EQFABRIC_INL void setFocusDistance( const float focusDistance );
      83             : 
      84             :         /** @return the current focal distance. @version 1.1 */
      85         121 :         float getFocusDistance() const { return _data.focusDistance; }
      86             : 
      87             :         /** Set the focal mode. @version 1.1 */
      88             :         EQFABRIC_INL void setFocusMode( const FocusMode focusMode );
      89             : 
      90             :         /** @return the current focal mode. @version 1.1 */
      91         489 :         FocusMode getFocusMode() const { return _data.focusMode; }
      92             : 
      93             :         /** Set the index of the OpenCV camera for tracking. @version 1.5.2 */
      94             :         EQFABRIC_INL void setOpenCVCamera( const int32_t index );
      95             : 
      96             :         /** @return the current OpenCV camera. @version 1.5.2 */
      97         121 :         int32_t getOpenCVCamera() const { return _data.camera; }
      98             : 
      99             :         /** Set the VRPN tracker device. @version 1.5.2 */
     100             :         EQFABRIC_INL void setVRPNTracker( const std::string& index );
     101             : 
     102             :         /** @return the current VRPN tracker device name. @version 1.5.2 */
     103         121 :         const std::string& getVRPNTracker() const { return _data.vrpnTracker; }
     104             : 
     105             :         /** @return the parent config of this observer. @version 1.0 */
     106           0 :         const C* getConfig() const { return _config; }
     107             : 
     108             :         /** @return the parent config of this observer. @version 1.0 */
     109         473 :         C* getConfig() { return _config; }
     110             : 
     111             :         /** @internal @return the index path to this observer. */
     112             :         ObserverPath getPath() const;
     113             :         //@}
     114             : 
     115             :         /** @name Operations */
     116             :         //@{
     117             :         /**
     118             :          * Traverse this observer using a observer visitor.
     119             :          *
     120             :          * @param visitor the visitor.
     121             :          * @return the result of the visitor traversal.
     122             :          * @version 1.0
     123             :          */
     124             :         EQFABRIC_INL VisitorResult accept( Visitor& visitor );
     125             : 
     126             :         /** Const-version of accept(). @version 1.0 */
     127             :         EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
     128             : 
     129             :         virtual void backup(); //!< @internal
     130             :         virtual void restore(); //!< @internal
     131             :         //@}
     132             : 
     133             :     protected:
     134             :         /** @internal Construct a new Observer. */
     135             :         EQFABRIC_INL Observer( C* config );
     136             : 
     137             :         /** @internal Destruct this observer. */
     138             :         EQFABRIC_INL virtual ~Observer();
     139             : 
     140             :         /** @internal */
     141             :         virtual void serialize( co::DataOStream& os,
     142             :                                 const uint64_t dirtyBits );
     143             :         /** @internal */
     144             :         virtual void deserialize( co::DataIStream& is,
     145             :                                   const uint64_t dirtyBits );
     146             :         virtual void setDirty( const uint64_t bits ); //!< @internal
     147             : 
     148             :         /** @internal */
     149             :         enum DirtyBits
     150             :         {
     151             :             DIRTY_EYE_POSITION = Object::DIRTY_CUSTOM << 0,
     152             :             DIRTY_HEAD         = Object::DIRTY_CUSTOM << 1,
     153             :             DIRTY_FOCUS        = Object::DIRTY_CUSTOM << 2,
     154             :             DIRTY_TRACKER      = Object::DIRTY_CUSTOM << 3,
     155             :             DIRTY_OBSERVER_BITS =
     156             :                 DIRTY_EYE_POSITION | DIRTY_HEAD | DIRTY_FOCUS | DIRTY_TRACKER |
     157             :                 DIRTY_OBJECT_BITS
     158             :         };
     159             : 
     160             :         /** @internal @return the bits to be re-committed by the master. */
     161           8 :         virtual uint64_t getRedistributableBits() const
     162           8 :             { return DIRTY_OBSERVER_BITS; }
     163             : 
     164             :     private:
     165             :         /** The parent Config. */
     166             :         C* const _config;
     167             : 
     168         464 :         struct BackupData
     169             :         {
     170             :             BackupData();
     171             : 
     172             :             Matrix4f headMatrix; //!< The current head position
     173             :             Vector3f eyePosition[ NUM_EYES ]; //!< The current eye positions
     174             :             float focusDistance; //!< The current focal distance
     175             :             FocusMode focusMode; //!< The current focal distance mode
     176             :             int32_t camera; //!< The OpenCV camera used for head tracking
     177             :             std::string vrpnTracker; //!< VRPN tracking device
     178             :         }
     179             :             _data, _backup;
     180             : 
     181             :         struct Private;
     182             :         Private* _private; // placeholder for binary-compatible changes
     183             :     };
     184             : 
     185             :     template< class C, class O >
     186             :     EQFABRIC_INL std::ostream& operator << ( std::ostream&,
     187             :                                              const Observer< C, O >& );
     188             : }
     189             : }
     190             : #endif // EQFABRIC_OBSERVER_H

Generated by: LCOV version 1.10