Added support for sorting the graphics contexts so that the first context/window

returned from Viewer::getContexts/getWindows will be the left most window on the lowest screen number.

Added ability for StatsHandler and HelpHandler to support end users setting their
Camera's graphics context.
This commit is contained in:
Robert Osfield
2007-04-20 16:17:48 +00:00
parent 6a67b66e8e
commit abd0c7fe67
5 changed files with 73 additions and 11 deletions

View File

@@ -1299,6 +1299,29 @@ void Viewer::checkWindowStatus()
}
struct LessGraphicsContext
{
bool operator () (const osg::GraphicsContext* lhs, const osg::GraphicsContext* rhs) const
{
int screenLeft = lhs->getTraits()? lhs->getTraits()->screenNum : 0;
int screenRight = rhs->getTraits()? rhs->getTraits()->screenNum : 0;
if (screenLeft < screenRight) return true;
if (screenLeft > screenRight) return false;
screenLeft = lhs->getTraits()? lhs->getTraits()->x : 0;
screenRight = rhs->getTraits()? rhs->getTraits()->x : 0;
if (screenLeft < screenRight) return true;
if (screenLeft > screenRight) return false;
screenLeft = lhs->getTraits()? lhs->getTraits()->y : 0;
screenRight = rhs->getTraits()? rhs->getTraits()->y : 0;
if (screenLeft < screenRight) return true;
if (screenLeft > screenRight) return false;
return lhs < rhs;
}
};
void Viewer::getContexts(Contexts& contexts, bool onlyValid)
{
typedef std::set<osg::GraphicsContext*> ContextSet;
@@ -1331,6 +1354,11 @@ void Viewer::getContexts(Contexts& contexts, bool onlyValid)
{
contexts.push_back(const_cast<osg::GraphicsContext*>(*itr));
}
if (contexts.size()>=2)
{
std::sort(contexts.begin(), contexts.end(), LessGraphicsContext());
}
}
void Viewer::getWindows(Windows& windows, bool onlyValid)