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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user