#include <vrj/Display/Viewport.h>
Inheritance diagram for vrj::Viewport:


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. | |
| User * | getUser () |
| Gets the user associated with this viewport. | |
| void | setDisplay (Display *disp) |
| Sets the display containing this viewport. | |
| Display * | getDisplay () |
| Gets the display containing this viewport. | |
| Projection * | getLeftProj () |
| Gets the left projection. | |
| Projection * | getRightProj () |
| 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. | |
| User * | mUser |
| 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. | |
| Display * | mDisplay |
| 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. | |
| Projection * | mLeftProj |
| Left eye projection. | |
| Projection * | mRightProj |
| Right eye projection. | |
Stores projection data, viewport info, and relevant user.
Definition at line 56 of file Viewport.h.
| enum vrj::Viewport::Type |
| enum vrj::Viewport::View |
| 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] |
| bool vrj::Viewport::config | ( | jccl::ConfigElementPtr | element | ) | [virtual] |
Takes a viewport element and configures the display based one it.
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.
| 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().
| 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().
| 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.
Definition at line 179 of file Viewport.h.
| 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] |
| 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 }
std::string vrj::Viewport::mName [protected] |
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] |
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] |
float vrj::Viewport::mYorigin [protected] |
float vrj::Viewport::mXsize [protected] |
float vrj::Viewport::mYsize [protected] |
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().
1.5.1