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

vrj::Viewport Class Reference

Base class for window viewports. More...

#include <Viewport.h>

Inheritance diagram for vrj::Viewport:

Inheritance graph
[legend]
List of all members.

Public Types

enum  Type { UNDEFINED, SURFACE, SIM }
 Type of viewport. More...

enum  View { NONE = 0, LEFT_EYE = 1, RIGHT_EYE = 2, STEREO = 3 }
 Used for referencing which eye(s) to draw. More...


Public Methods

 Viewport ()
 Viewport (const Viewport &v)
virtual ~Viewport ()
virtual void config (jccl::ConfigElementPtr element)
 Takes a viewport element and configures the display based one it. More...

virtual void updateProjections (const float positionScale)=0
 Updates the projection data for this display. More...

Viewport::Type getType ()
bool isSimulator ()
bool isSurface ()
bool isActive ()
void setName (const std::string &name)
const std::string & getName ()
 Gets the name of this display. More...

bool inStereo ()
Viewport::View getView ()
void setOriginAndSize (float xo, float yo, float xs, float ys)
void getOriginAndSize (float &xo, float &yo, float &xs, float &ys)
jccl::ConfigElementPtr getConfigElement ()
 Gets the config element that configured this viewport. More...

UsergetUser ()
 Gets the user associated with this display. More...

void setDisplay (Display *disp)
DisplaygetDisplay ()
ProjectiongetLeftProj ()
ProjectiongetRightProj ()
virtual std::ostream & outStream (std::ostream &out, const unsigned int indentLevel=0)

Detailed Description

Base class for window viewports.

Base class for all viewport data. Stores projection data, viewport info, and relevant user.

Date:
3-5-2001

Definition at line 55 of file Viewport.h.


Member Enumeration Documentation

enum vrj::Viewport::Type
 

Type of viewport.

Enumeration values:
UNDEFINED  Undefined type.
SURFACE  Surface viewport.
SIM  Simulator viewport.

Definition at line 80 of file Viewport.h.

00081    {
00082       UNDEFINED,  
00083       SURFACE,    
00084       SIM         
00085    };

enum vrj::Viewport::View
 

Used for referencing which eye(s) to draw.

Enumeration values:
NONE  Neither eye.
LEFT_EYE  Left eye only.
RIGHT_EYE  Right eye only.
STEREO  Both left and right eyes.

Definition at line 88 of file Viewport.h.

Referenced by vrj::GlWindow::setViewBuffer.

00089    {
00090       NONE=0,       
00091       LEFT_EYE=1,   
00092       RIGHT_EYE=2,  
00093       STEREO=3      
00094    };


Constructor & Destructor Documentation

vrj::Viewport::Viewport   [inline]
 

Definition at line 58 of file Viewport.h.

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    }

vrj::Viewport::Viewport const Viewport &    v [inline]
 

Definition at line 67 of file Viewport.h.

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    }

virtual vrj::Viewport::~Viewport   [inline, virtual]
 

Definition at line 76 of file Viewport.h.

00077    {;}


Member Function Documentation

void vrj::Viewport::config jccl::ConfigElementPtr    element [virtual]
 

Takes a viewport element and configures the display based one it.

Precondition:
element is a valid configuration element.
Postcondition:
viewport is configured. If there is an error is the specified config, we output error and "fix" the error.
Note:
All derived viewport classes MUST call this function after doing local configuration.

Reimplemented in vrj::SimViewport.

Definition at line 45 of file Viewport.cpp.

References setName, setOriginAndSize, and vrjDBG_DISP_MGR.

00046 {
00047    vprASSERT(element.get() != NULL);
00048 
00049    // -- Get config info from element -- //
00050     float originX = element->getProperty<float>("origin", 0);
00051     float originY = element->getProperty<float>("origin", 1);
00052     float sizeX   = element->getProperty<float>("size", 0);
00053     float sizeY   = element->getProperty<float>("size", 1);
00054     std::string name  = element->getName();
00055     mView    = (Viewport::View) element->getProperty<int>("view");
00056     mActive  = element->getProperty<bool>("active");
00057 
00058    // -- Check for error in configuration -- //
00059    // NOTE: If there are errors, set them to some default value
00060    if(sizeX <= 0)
00061    {
00062       vprDEBUG(vrjDBG_DISP_MGR, vprDBG_WARNING_LVL)
00063          << "WARNING: viewport sizeX set to: " << sizeX
00064          << ".  Setting to 1." << std::endl << vprDEBUG_FLUSH;
00065       sizeX = 1.0f;
00066    }
00067 
00068    if(sizeY <= 0)
00069    {
00070       vprDEBUG(vrjDBG_DISP_MGR, vprDBG_WARNING_LVL)
00071          << "WARNING: viewport sizeY set to: " << sizeY
00072          << ".  Setting to 1." << std::endl << vprDEBUG_FLUSH;
00073       sizeY = 1.0f;
00074    }
00075 
00076     // -- Set local window attributes --- //
00077     setOriginAndSize(originX, originY, sizeX, sizeY);
00078 
00079     // Get the user for this display
00080     std::string user_name = element->getProperty<std::string>("user");
00081     mUser = Kernel::instance()->getUser(user_name);
00082 
00083     if(NULL == mUser)
00084     {
00085        vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
00086           << clrOutNORM(clrRED, "ERROR:") << " User not found named: '"
00087           << user_name << "'" << std::endl << vprDEBUG_FLUSH;
00088        vprASSERT(false && "User not found in Viewport::config");
00089     }
00090 
00091     setName(name);
00092     mViewportElement = element;        // Save the element for later use
00093 
00094     std::string bufname = "Head Latency " + name;
00095 }

virtual void vrj::Viewport::updateProjections const float    positionScale [pure virtual]
 

Updates the projection data for this display.

Uses the data for the head position for this window.

Parameters:
positionScale  - Scale value for converting from Juggler units (meters) to the display units

Implemented in vrj::SimViewport.

Viewport::Type vrj::Viewport::getType   [inline]
 

Definition at line 117 of file Viewport.h.

00118    { return mType;}

bool vrj::Viewport::isSimulator   [inline]
 

Definition at line 120 of file Viewport.h.

00121    { return (mType == SIM); }

bool vrj::Viewport::isSurface   [inline]
 

Definition at line 123 of file Viewport.h.

00124    { return (mType == SURFACE); }

bool vrj::Viewport::isActive   [inline]
 

Definition at line 126 of file Viewport.h.

00127    { return mActive; }

void vrj::Viewport::setName const std::string &    name [inline]
 

Definition at line 129 of file Viewport.h.

Referenced by config.

00130    {
00131       mName = name;
00132    }

const std::string& vrj::Viewport::getName   [inline]
 

Gets the name of this display.

Definition at line 135 of file Viewport.h.

Referenced by outStream.

00136    {
00137       return mName;
00138    }

bool vrj::Viewport::inStereo   [inline]
 

Note:
If we are in simulator, we can not be in stereo.

Definition at line 143 of file Viewport.h.

00144    { return (mView == STEREO); }

Viewport::View vrj::Viewport::getView   [inline]
 

Definition at line 147 of file Viewport.h.

00148    { return mView; }

void vrj::Viewport::setOriginAndSize float    xo,
float    yo,
float    xs,
float    ys
[inline]
 

Definition at line 150 of file Viewport.h.

Referenced by config.

00151    { mXorigin = xo; mYorigin = yo; mXsize = xs; mYsize = ys;}

void vrj::Viewport::getOriginAndSize float &    xo,
float &    yo,
float &    xs,
float &    ys
[inline]
 

Definition at line 152 of file Viewport.h.

00153    {
00154       xo = mXorigin; yo = mYorigin; xs = mXsize; ys = mYsize;
00155    }

jccl::ConfigElementPtr vrj::Viewport::getConfigElement   [inline]
 

Gets the config element that configured this viewport.

Definition at line 158 of file Viewport.h.

00159    {
00160       return mViewportElement;
00161    }

User* vrj::Viewport::getUser   [inline]
 

Gets the user associated with this display.

Definition at line 164 of file Viewport.h.

Referenced by outStream.

00165    { return mUser;}

void vrj::Viewport::setDisplay Display   disp [inline]
 

Definition at line 167 of file Viewport.h.

00168    { mDisplay = disp; }

Display* vrj::Viewport::getDisplay   [inline]
 

Definition at line 169 of file Viewport.h.

00170    { return mDisplay; }

Projection* vrj::Viewport::getLeftProj   [inline]
 

Definition at line 172 of file Viewport.h.

00173    { return mLeftProj; }

Projection* vrj::Viewport::getRightProj   [inline]
 

Definition at line 175 of file Viewport.h.

00176    { return mRightProj; }

std::ostream & vrj::Viewport::outStream std::ostream &    out,
const unsigned int    indentLevel = 0
[virtual]
 

Reimplemented in vrj::SurfaceViewport.

Definition at line 102 of file Viewport.cpp.

References getName, and getUser.

00104 {
00105    const int pad_width_dot(20 - indentLevel);
00106    const std::string indent_text(indentLevel, ' ');
00107 
00108    out << indent_text << std::setw(pad_width_dot)
00109        << "Name " << " " << getName() << std::endl;
00110    out << indent_text << std::setw(pad_width_dot)
00111        << "Active " << " " << (mActive ? "Yes" : "No") << std::endl;
00112    out << indent_text << std::setw(pad_width_dot)
00113        << "User " << " " << getUser()->getName() << std::endl;
00114    out << indent_text << std::setw(pad_width_dot)
00115        << "Origin " << " " << mXorigin << ", " << mYorigin << std::endl;
00116    out << indent_text << std::setw(pad_width_dot)
00117        << "Size " << " " << mXsize << "x" << mYsize << std::endl;
00118    out << indent_text << std::setw(pad_width_dot)
00119        << "View " << " "
00120        << ((mView == Viewport::LEFT_EYE) ? "Left" : ((mView==Viewport::RIGHT_EYE)?"Right" : "Stereo") );
00121 
00122    out << std::flush;
00123 
00124    return out;
00125 }


The documentation for this class was generated from the following files:
Generated on Sun May 2 15:11:07 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002