From Stephan Huber, add basic support for CompositeViewer in StatsHandler
This commit is contained in:
@@ -1625,3 +1625,85 @@ bool View::computeIntersections(float x,float y, osg::NodePath& nodePath, osgUti
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void View::getCameras(Cameras& cameras, bool onlyActive)
|
||||
{
|
||||
cameras.clear();
|
||||
|
||||
if (_camera.valid() &&
|
||||
(!onlyActive || (_camera->getGraphicsContext() && _camera->getGraphicsContext()->valid())) ) cameras.push_back(_camera.get());
|
||||
|
||||
for(Slaves::iterator itr = _slaves.begin();
|
||||
itr != _slaves.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->_camera.valid() &&
|
||||
(!onlyActive || (itr->_camera->getGraphicsContext() && itr->_camera->getGraphicsContext()->valid())) ) cameras.push_back(itr->_camera.get());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 View::getContexts(Contexts& contexts, bool onlyValid)
|
||||
{
|
||||
typedef std::set<osg::GraphicsContext*> ContextSet;
|
||||
ContextSet contextSet;
|
||||
|
||||
if (_camera.valid() &&
|
||||
_camera->getGraphicsContext() &&
|
||||
(_camera->getGraphicsContext()->valid() || !onlyValid))
|
||||
{
|
||||
contextSet.insert(_camera->getGraphicsContext());
|
||||
}
|
||||
|
||||
for(unsigned int i=0; i<getNumSlaves(); ++i)
|
||||
{
|
||||
Slave& slave = getSlave(i);
|
||||
if (slave._camera.valid() &&
|
||||
slave._camera->getGraphicsContext() &&
|
||||
(slave._camera->getGraphicsContext()->valid() || !onlyValid))
|
||||
{
|
||||
contextSet.insert(slave._camera->getGraphicsContext());
|
||||
}
|
||||
}
|
||||
|
||||
contexts.clear();
|
||||
contexts.reserve(contextSet.size());
|
||||
|
||||
for(ContextSet::iterator itr = contextSet.begin();
|
||||
itr != contextSet.end();
|
||||
++itr)
|
||||
{
|
||||
contexts.push_back(const_cast<osg::GraphicsContext*>(*itr));
|
||||
}
|
||||
|
||||
if (contexts.size()>=2)
|
||||
{
|
||||
std::sort(contexts.begin(), contexts.end(), LessGraphicsContext());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user