vrj::Viewport Class Reference

Base class for window viewports and for all viewport data. More...

#include <vrj/Display/Viewport.h>

Inheritance diagram for vrj::Viewport:

Inheritance graph
[legend]
Collaboration diagram for vrj::Viewport:

Collaboration 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 Member Functions

 Viewport ()
 Viewport (const Viewport &v)
virtual ~Viewport ()
virtual bool config (jccl::ConfigElementPtr element)
 Takes a viewport element and configures the display based one it.
virtual void updateProjections (const float positionScale)=0
 Updates the projection data for this viewport.
Viewport::Type getType () const
 Gets the type of this viewport.
bool isSimulator () const
 Determines if this is a simulator viewport.
bool isSurface () const
 Determines if this is a surface viewport.
bool isActive () const
 Determines if this viewport is active.
void setName (const std::string &name)
 Sets the name of this viewport.
const std::string & getName ()
 Gets the name of this display.
bool inStereo () const
 Determines if this viewport is rendering in stereo.
Viewport::View getView ()
 Which view are we supposed to render?
void setOriginAndSize (const float xOrigin, const float yOrigin, const float width, const float height)
 Sets the origin and size of this viewport.
void getOriginAndSize (float &xOrigin, float &yOrigin, float &width, float &height) const
 Gets the origin and size of this viewport.
jccl::ConfigElementPtr getConfigElement () const
 Gets the config element that configured this viewport.
UsergetUser ()
 Gets the user associated with this viewport.
void setDisplay (Display *disp)
 Sets the display containing this viewport.
DisplaygetDisplay ()
 Gets the display containing this viewport.
ProjectiongetLeftProj ()
 Gets the left projection.
ProjectiongetRightProj ()
 Gets the right projection.
virtual std::ostream & outStream (std::ostream &out, const unsigned int indentLevel=0)

Protected Attributes

std::string mName
 The name of the viewport being displayed.
UsermUser
 The user being rendered by this window.
Viewport::Type mType
 The type of display.
Viewport::View mView
 Which buffer(s) to display (left, right, stereo).
bool mActive
 Is this viewport active.
DisplaymDisplay
 The parent display.
jccl::ConfigElementPtr mViewportElement
 The config data for this display.
Location and size of viewport
ASSERT: all values are >= 0.0 and <= 1.0

float mXorigin
float mYorigin
float mXsize
float mYsize
Projections
Defines the projection for this window.

ProjectionmLeftProj
 Left eye projection.
ProjectionmRightProj
 Right eye projection.

Detailed Description

Base class for window viewports and for all viewport data.

Stores projection data, viewport info, and relevant user.

Date:
3-5-2001

Definition at line 56 of file Viewport.h.


Member Enumeration Documentation

enum vrj::Viewport::Type

Type of viewport.

Enumerator:
UNDEFINED  Undefined type.
SURFACE  Surface viewport.
SIM  Simulator viewport.

Definition at line 98 of file Viewport.h.

00099    {
00100       UNDEFINED,  
00101       SURFACE,    
00102       SIM         
00103    };

enum vrj::Viewport::View

Used for referencing which eye(s) to draw.

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

Definition at line 106 of file Viewport.h.

00107    {
00108       NONE=0,       
00109       LEFT_EYE=1,   
00110       RIGHT_EYE=2,  
00111       STEREO=3      
00112    };


Constructor & Destructor Documentation

vrj::Viewport::Viewport (  )  [inline]

Definition at line 59 of file Viewport.h.

00060       : mUser(NULL)
00061       , mType(Viewport::UNDEFINED)
00062       , mActive(false)
00063       , mDisplay(NULL)
00064       , mXorigin(-1.0f)
00065       , mYorigin(-1.0f)
00066       , mXsize(-1.0f)
00067       , mYsize(-1.0f)
00068       , mLeftProj(NULL)
00069       , mRightProj(NULL)
00070    {
00071       ;
00072    }

vrj::Viewport::Viewport ( const Viewport v  )  [inline]

Definition at line 74 of file Viewport.h.

00075       : mName(v.mName)
00076       , mUser(v.mUser)
00077       , mType(v.mType)
00078       , mView(v.mView)
00079       , mActive(v.mActive)
00080       , mDisplay(v.mDisplay)
00081       , mViewportElement(v.mViewportElement)
00082       , mXorigin(v.mXorigin)
00083       , mYorigin(v.mYorigin)
00084       , mXsize(v.mXsize)
00085       , mYsize(v.mYsize)
00086       , mLeftProj(v.mLeftProj)
00087       , mRightProj(v.mRightProj)
00088    {
00089       ;
00090    }

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

Definition at line 92 of file Viewport.h.

00093    {
00094       ;
00095    }


Member Function Documentation

bool 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, and vrj::SurfaceViewport.

Definition at line 48 of file Viewport.cpp.

References mActive, mUser, mView, mViewportElement, setName(), setOriginAndSize(), and vrjDBG_DISP_MGR().

Referenced by vrj::SurfaceViewport::config(), and vrj::SimViewport::config().

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

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

Updates the projection data for this viewport.

This uses the data from the head position for this viewport.

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

Implemented in vrj::SimViewport, and vrj::SurfaceViewport.

Viewport::Type vrj::Viewport::getType (  )  const [inline]

Gets the type of this viewport.

Definition at line 139 of file Viewport.h.

00140    {
00141       return mType;
00142    }

bool vrj::Viewport::isSimulator (  )  const [inline]

Determines if this is a simulator viewport.

Definition at line 145 of file Viewport.h.

Referenced by vrj::PfDrawManager::addDisplay(), vrj::PfDrawManager::releaseViewport(), and vrj::PfDrawManager::updatePfProjections().

00146    {
00147       return (mType == SIM);
00148    }

bool vrj::Viewport::isSurface (  )  const [inline]

Determines if this is a surface viewport.

Definition at line 151 of file Viewport.h.

Referenced by vrj::PfDrawManager::addDisplay(), and vrj::PfDrawManager::releaseViewport().

00152    {
00153       return (mType == SURFACE);
00154    }

bool vrj::Viewport::isActive (  )  const [inline]

Determines if this viewport is active.

Definition at line 157 of file Viewport.h.

Referenced by vrj::PfDrawManager::addDisplay().

00158    {
00159       return mActive;
00160    }

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

Sets the name of this viewport.

Definition at line 163 of file Viewport.h.

Referenced by config().

00164    {
00165       mName = name;
00166    }

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

Gets the name of this display.

Definition at line 169 of file Viewport.h.

Referenced by outStream().

00170    {
00171       return mName;
00172    }

bool vrj::Viewport::inStereo (  )  const [inline]

Determines if this viewport is rendering in stereo.

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

Definition at line 179 of file Viewport.h.

00180    {
00181       return (mView == STEREO);
00182    }

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

Which view are we supposed to render?

Definition at line 185 of file Viewport.h.

Referenced by vrj::PfDrawManager::updatePfProjections().

00186    {
00187       return mView;
00188    }

void vrj::Viewport::setOriginAndSize ( const float  xOrigin,
const float  yOrigin,
const float  width,
const float  height 
) [inline]

Sets the origin and size of this viewport.

Definition at line 191 of file Viewport.h.

Referenced by config().

00193    {
00194       mXorigin = xOrigin;
00195       mYorigin = yOrigin;
00196       mXsize   = width;
00197       mYsize   = height;
00198    }

void vrj::Viewport::getOriginAndSize ( float &  xOrigin,
float &  yOrigin,
float &  width,
float &  height 
) const [inline]

Gets the origin and size of this viewport.

Definition at line 201 of file Viewport.h.

Referenced by vrj::PfDrawManager::addDisplay(), vrj::CameraProjection::calcViewMatrix(), and vrj::OsgApp::draw().

00204    {
00205       xOrigin = mXorigin;
00206       yOrigin = mYorigin;
00207       width   = mXsize;
00208       height  = mYsize;
00209    }

jccl::ConfigElementPtr vrj::Viewport::getConfigElement (  )  const [inline]

Gets the config element that configured this viewport.

Definition at line 212 of file Viewport.h.

Referenced by vrj::PfDrawManager::addDisplay(), and vrj::GlDrawManager::addDisplay().

00213    {
00214       return mViewportElement;
00215    }

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

Gets the user associated with this viewport.

Definition at line 218 of file Viewport.h.

Referenced by vrj::GlBasicSimulator::drawSimulator(), outStream(), vrj::PfBasicSimulator::updateInternalData(), vrj::GlBasicSimulator::updateInternalData(), vrj::PfBasicSimulator::updateProjectionData(), and vrj::GlBasicSimulator::updateProjectionData().

00219    {
00220       return mUser;
00221    }

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

Sets the display containing this viewport.

Definition at line 224 of file Viewport.h.

Referenced by vrj::Display::configViewports().

00225    {
00226       mDisplay = disp;
00227    }

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

Gets the display containing this viewport.

Definition at line 230 of file Viewport.h.

Referenced by vrj::CameraProjection::calcViewMatrix().

00231    {
00232       return mDisplay;
00233    }

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

Gets the left projection.

Definition at line 236 of file Viewport.h.

Referenced by vrj::PfDrawManager::updatePfProjections().

00237    {
00238       return mLeftProj;
00239    }

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

Gets the right projection.

Definition at line 242 of file Viewport.h.

Referenced by vrj::PfDrawManager::updatePfProjections().

00243    {
00244       return mRightProj;
00245    }

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

Reimplemented in vrj::SurfaceViewport.

Definition at line 112 of file Viewport.cpp.

References vrj::User::getName(), getName(), getUser(), LEFT_EYE, mActive, mView, mXorigin, mXsize, mYorigin, mYsize, and RIGHT_EYE.

Referenced by vrj::operator<<(), and vrj::SurfaceViewport::outStream().

00114 {
00115    const int pad_width_dot(20 - indentLevel);
00116    const std::string indent_text(indentLevel, ' ');
00117 
00118    out << indent_text << std::setw(pad_width_dot)
00119        << "Name " << " " << getName() << std::endl;
00120    out << indent_text << std::setw(pad_width_dot)
00121        << "Active " << " " << (mActive ? "Yes" : "No") << std::endl;
00122    out << indent_text << std::setw(pad_width_dot)
00123        << "User " << " " << getUser()->getName() << std::endl;
00124    out << indent_text << std::setw(pad_width_dot)
00125        << "Origin " << " " << mXorigin << ", " << mYorigin << std::endl;
00126    out << indent_text << std::setw(pad_width_dot)
00127        << "Size " << " " << mXsize << "x" << mYsize << std::endl;
00128    out << indent_text << std::setw(pad_width_dot)
00129        << "View " << " "
00130        << ((mView == Viewport::LEFT_EYE) ? "Left" : ((mView==Viewport::RIGHT_EYE)?"Right" : "Stereo") );
00131 
00132    out << std::flush;
00133 
00134    return out;
00135 }


Member Data Documentation

std::string vrj::Viewport::mName [protected]

The name of the viewport being displayed.

Definition at line 250 of file Viewport.h.

User* vrj::Viewport::mUser [protected]

The user being rendered by this window.

Definition at line 254 of file Viewport.h.

Referenced by config(), and vrj::SurfaceViewport::updateProjections().

Viewport::Type vrj::Viewport::mType [protected]

The type of display.

Definition at line 255 of file Viewport.h.

Referenced by vrj::SurfaceViewport::config(), and vrj::SimViewport::config().

Viewport::View vrj::Viewport::mView [protected]

Which buffer(s) to display (left, right, stereo).

Definition at line 256 of file Viewport.h.

Referenced by config(), outStream(), and vrj::SurfaceViewport::outStream().

bool vrj::Viewport::mActive [protected]

Is this viewport active.

Definition at line 257 of file Viewport.h.

Referenced by config(), and outStream().

Display* vrj::Viewport::mDisplay [protected]

The parent display.

Definition at line 259 of file Viewport.h.

jccl::ConfigElementPtr vrj::Viewport::mViewportElement [protected]

The config data for this display.

Definition at line 261 of file Viewport.h.

Referenced by config().

float vrj::Viewport::mXorigin [protected]

Definition at line 268 of file Viewport.h.

Referenced by outStream().

float vrj::Viewport::mYorigin [protected]

Definition at line 269 of file Viewport.h.

Referenced by outStream().

float vrj::Viewport::mXsize [protected]

Definition at line 270 of file Viewport.h.

Referenced by outStream().

float vrj::Viewport::mYsize [protected]

Definition at line 271 of file Viewport.h.

Referenced by outStream().

Projection* vrj::Viewport::mLeftProj [protected]

Left eye projection.

Definition at line 279 of file Viewport.h.

Referenced by vrj::SurfaceViewport::config(), vrj::SimViewport::config(), vrj::SurfaceViewport::outStream(), vrj::SurfaceViewport::updateProjections(), vrj::SimViewport::updateProjections(), vrj::SimViewport::~SimViewport(), and vrj::SurfaceViewport::~SurfaceViewport().

Projection* vrj::Viewport::mRightProj [protected]

Right eye projection.

Definition at line 280 of file Viewport.h.

Referenced by vrj::SurfaceViewport::config(), vrj::SimViewport::config(), vrj::SurfaceViewport::outStream(), vrj::SurfaceViewport::updateProjections(), vrj::SimViewport::updateProjections(), vrj::SimViewport::~SimViewport(), and vrj::SurfaceViewport::~SurfaceViewport().


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:58:09 2007 for VR Juggler by  doxygen 1.5.1