Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Viewport.h

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile: Viewport.h,v $
00027  * Date modified: $Date: 2003/07/10 23:59:14 $
00028  * Version:       $Revision: 1.31 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _VRJ_VIEWPORT_H_
00034 #define _VRJ_VIEWPORT_H_
00035 
00036 #include <vrj/vrjConfig.h>
00037 
00038 #include <string>
00039 #include <gmtl/Vec.h>
00040 #include <jccl/Config/ConfigElementPtr.h>
00041 
00042 namespace vrj
00043 {
00044 
00045 class Display;
00046 class Projection;
00047 class User;
00048 
00055 class VJ_CLASS_API Viewport
00056 {
00057 public:
00058    Viewport()
00059       : mUser(NULL), mDisplay(NULL),
00060         mLeftProj(NULL), mRightProj(NULL)
00061    {
00062       mXorigin = mYorigin = mXsize = mYsize = -1.0f;
00063       mType = Viewport::UNDEFINED;
00064       mActive = false;
00065    }
00066 
00067    Viewport(const Viewport& v)
00068       : mName(v.mName), mUser(v.mUser), mType(v.mType), mView(v.mView),
00069         mActive(v.mActive), mDisplay(v.mDisplay),
00070         mViewportElement(v.mViewportElement), mXorigin(v.mXorigin),
00071         mYorigin(v.mYorigin), mXsize(v.mXsize), mYsize(v.mYsize),
00072         mLeftProj(v.mLeftProj), mRightProj(v.mRightProj)
00073    {
00074    }
00075 
00076    virtual ~Viewport()
00077    {;}
00078 
00080    enum Type
00081    {
00082       UNDEFINED,  
00083       SURFACE,    
00084       SIM         
00085    };
00086 
00088    enum View
00089    {
00090       NONE=0,       
00091       LEFT_EYE=1,   
00092       RIGHT_EYE=2,  
00093       STEREO=3      
00094    };
00095 
00096 public:
00107    virtual void config(jccl::ConfigElementPtr element);
00108 
00114    virtual void updateProjections(const float positionScale) = 0;
00115 
00116 public:
00117    Viewport::Type getType()
00118    { return mType;}
00119 
00120    bool isSimulator()
00121    { return (mType == SIM); }
00122 
00123    bool isSurface()
00124    { return (mType == SURFACE); }
00125 
00126    bool isActive()
00127    { return mActive; }
00128 
00129    void setName(const std::string& name)
00130    {
00131       mName = name;
00132    }
00133 
00135    const std::string& getName()
00136    {
00137       return mName;
00138    }
00139 
00143    bool inStereo()
00144    { return (mView == STEREO); }
00145 
00146    // Which view are we supposed to render
00147    Viewport::View getView()
00148    { return mView; }
00149 
00150    void setOriginAndSize(float xo, float yo, float xs, float ys)
00151    { mXorigin = xo; mYorigin = yo; mXsize = xs; mYsize = ys;}
00152    void getOriginAndSize(float& xo, float& yo, float& xs, float& ys)
00153    {
00154       xo = mXorigin; yo = mYorigin; xs = mXsize; ys = mYsize;
00155    }
00156 
00158    jccl::ConfigElementPtr getConfigElement()
00159    {
00160       return mViewportElement;
00161    }
00162 
00164    User*  getUser()
00165    { return mUser;}
00166 
00167    void setDisplay(Display* disp)
00168    { mDisplay = disp; }
00169    Display* getDisplay()
00170    { return mDisplay; }
00171 
00172    Projection* getLeftProj()
00173    { return mLeftProj; }
00174 
00175    Projection* getRightProj()
00176    { return mRightProj; }
00177 
00178 
00179    virtual std::ostream& outStream(std::ostream& out,
00180                                    const unsigned int indentLevel = 0);
00181    friend VJ_API(std::ostream&) operator<<(std::ostream& out, Viewport& viewport);
00182 
00183 protected:
00184    std::string       mName;               
00185    User*             mUser;               
00186    Viewport::Type    mType;               
00187    Viewport::View    mView;               
00188    bool              mActive;             
00190    Display*          mDisplay;            
00192    jccl::ConfigElementPtr mViewportElement; 
00198    float          mXorigin, mYorigin, mXsize, mYsize;
00200 
00205    Projection*   mLeftProj;      
00206    Projection*   mRightProj;     
00208 
00209 };
00210 
00211 }
00212 
00213 #endif

Generated on Sun May 2 15:10:18 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002