本文整理汇总了C++中refviews::iterator类的典型用法代码示例。如果您正苦于以下问题:C++ iterator类的具体用法?C++ iterator怎么用?C++ iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkNeedToDoFrame
bool CompositeViewer::checkNeedToDoFrame()
{
if (_requestRedraw) return true;
if (_requestContinousUpdate) return true;
for(RefViews::iterator itr = _views.begin();
itr != _views.end();
++itr)
{
osgViewer::View* view = itr->get();
if (view)
{
// If the database pager is going to update the scene the render flag is
// set so that the updates show up
if (view->getDatabasePager()->requiresUpdateSceneGraph() ||
view->getDatabasePager()->getRequestsInProgress()) return true;
// if there update callbacks then we need to do frame.
if (view->getCamera()->getUpdateCallback()) return true;
if (view->getSceneData()!=0 && view->getSceneData()->getNumChildrenRequiringUpdateTraversal()>0) return true;
}
}
// check if events are available and need processing
if (checkEvents()) return true;
if (_requestRedraw) return true;
if (_requestContinousUpdate) return true;
return false;
}
示例2: advance
void CompositeViewer::advance( const uint32_t frameNumber,
const FrameData& frameData )
{
_frameStamp->setFrameNumber( frameNumber );
// reference time has to use osg::Timer because other OSG internals that
// attempt to compute relative time based on the frame stamp also use it
// (e.g. IncrementalCompileOperation)
_frameStamp->setReferenceTime( osg::Timer::instance( )->delta_s( _startTick,
osg::Timer::instance( )->tick( )));
_frameStamp->setSimulationTime( frameData.getSimulationTime( ));
const time_t calendar = frameData.getCalendarTime( );
struct tm now;
if( NULL != gmtime_r( &calendar, &now ))
_frameStamp->setCalendarTime( now );
#if OSG_VERSION_GREATER_OR_EQUAL( 3, 0, 0 )
for( RefViews::iterator vitr = _views.begin( );
vitr != _views.end( ); ++vitr )
{
osgViewer::View *view = vitr->get( );
view->getEventQueue( )->frame( _frameStamp->getReferenceTime( ));
}
#endif
if( osg::Referenced::getDeleteHandler( ))
{
osg::Referenced::getDeleteHandler( )->flush( );
osg::Referenced::getDeleteHandler( )->setFrameNumber( frameNumber );
}
}
示例3: checkNeedToDoFrame
bool CompositeViewer::checkNeedToDoFrame()
{
if (_requestRedraw) return true;
if (_requestContinousUpdate) return true;
for(RefViews::iterator itr = _views.begin();
itr != _views.end();
++itr)
{
osgViewer::View* view = itr->get();
if (view)
{
// If the database pager is going to update the scene the render flag is
// set so that the updates show up
if (view->getDatabasePager()->requiresUpdateSceneGraph() ||
view->getDatabasePager()->getRequestsInProgress()) return true;
}
}
// now do a eventTraversal to see if any events might require a new frame.
eventTraversal();
if (_requestRedraw) return true;
if (_requestContinousUpdate) return true;
return false;
}
示例4: getViews
void CompositeViewer::getViews(Views& views, bool onlyValid)
{
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
views.push_back(vitr->get());
}
}
示例5: run
int CompositeViewer::run()
{
for(RefViews::iterator itr = _views.begin();
itr != _views.end();
++itr)
{
osgViewer::View* view = itr->get();
if ((view->getCameraManipulator()==0) && view->getCamera()->getAllowEventFocus())
{
view->setCameraManipulator(new osgGA::TrackballManipulator());
}
}
setReleaseContextAtEndOfFrameHint(false);
return ViewerBase::run();
}
示例6: setCameraWithFocus
void CompositeViewer::setCameraWithFocus(osg::Camera* camera)
{
_cameraWithFocus = camera;
if (camera)
{
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
View* view = vitr->get();
if (view->containsCamera(camera))
{
_viewWithFocus = view;
return;
}
}
}
_viewWithFocus = 0;
}
示例7: getScenes
void CompositeViewer::getScenes(Scenes& scenes, bool onlyValid)
{
scenes.clear();
typedef std::set<osgViewer::Scene*> SceneSet;
SceneSet sceneSet;
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
osgViewer::View* view = vitr->get();
if (view->getScene() && (!onlyValid || view->getScene()->getSceneData()))
{
if (sceneSet.count(view->getScene())==0)
{
sceneSet.insert(view->getScene());
scenes.push_back(view->getScene());
}
}
}
}
示例8: getCameras
void CompositeViewer::getCameras(Cameras& cameras, bool onlyActive)
{
cameras.clear();
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
View* view = vitr->get();
if (view->getCamera() &&
(!onlyActive || (view->getCamera()->getGraphicsContext() && view->getCamera()->getGraphicsContext()->valid())) ) cameras.push_back(view->getCamera());
for(View::Slaves::iterator itr = view->_slaves.begin();
itr != view->_slaves.end();
++itr)
{
if (itr->_camera.valid() &&
(!onlyActive || (itr->_camera->getGraphicsContext() && itr->_camera->getGraphicsContext()->valid())) ) cameras.push_back(itr->_camera.get());
}
}
}
示例9: getContexts
void CompositeViewer::getContexts(Contexts& contexts, bool onlyValid)
{
typedef std::set<osg::GraphicsContext*> ContextSet;
ContextSet contextSet;
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
osgViewer::View* view = vitr->get();
if (view->getCamera() &&
view->getCamera()->getGraphicsContext() &&
(view->getCamera()->getGraphicsContext()->valid() || !onlyValid))
{
contextSet.insert(view->getCamera()->getGraphicsContext());
}
for(unsigned int i=0; i<view->getNumSlaves(); ++i)
{
View::Slave& slave = view->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));
}
}
示例10: getScenes
void CompositeViewer::getScenes(Scenes& scenes, bool onlyValid)
{
typedef std::set<osgViewer::Scene*> SceneSet;
SceneSet sceneSet;
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
osgViewer::View* view = vitr->get();
if (view->getScene() && (!onlyValid || view->getScene()->getSceneData()))
{
sceneSet.insert(view->getScene());
}
}
for(SceneSet::iterator sitr = sceneSet.begin();
sitr != sceneSet.end();
++sitr)
{
scenes.push_back(const_cast<osgViewer::Scene*>(*sitr));
}
}
示例11: getContexts
void CompositeViewer::getContexts(Contexts& contexts, bool onlyValid)
{
typedef std::set<osg::GraphicsContext*> ContextSet;
ContextSet contextSet;
contexts.clear();
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
osgViewer::View* view = vitr->get();
osg::GraphicsContext* gc = view->getCamera() ? view->getCamera()->getGraphicsContext() : 0;
if (gc && (gc->valid() || !onlyValid))
{
if (contextSet.count(gc)==0)
{
contextSet.insert(gc);
contexts.push_back(gc);
}
}
for(unsigned int i=0; i<view->getNumSlaves(); ++i)
{
View::Slave& slave = view->getSlave(i);
osg::GraphicsContext* sgc = slave._camera.valid() ? slave._camera->getGraphicsContext() : 0;
if (sgc && (sgc->valid() || !onlyValid))
{
if (contextSet.count(sgc)==0)
{
contextSet.insert(sgc);
contexts.push_back(sgc);
}
}
}
}
}
示例12: checkEvents
bool CompositeViewer::checkEvents()
{
for(RefViews::iterator itr = _views.begin();
itr != _views.end();
++itr)
{
osgViewer::View* view = itr->get();
if (view)
{
// check events from any attached sources
for(View::Devices::iterator eitr = view->getDevices().begin();
eitr != view->getDevices().end();
++eitr)
{
osgGA::Device* es = eitr->get();
if (es->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)
{
if (es->checkEvents()) return true;
}
}
}
}
// get events from all windows attached to Viewer.
Windows windows;
getWindows(windows);
for(Windows::iterator witr = windows.begin();
witr != windows.end();
++witr)
{
if ((*witr)->checkEvents()) return true;
}
return false;
}
示例13: checkNeedToDoFrame
bool CompositeViewer::checkNeedToDoFrame()
{
// check if any event handler has prompted a redraw
if (_requestRedraw) return true;
if (_requestContinousUpdate) return true;
// check if any view needs to update the scene graph
for(RefViews::iterator itr = _views.begin();
itr != _views.end();
++itr)
{
osgViewer::View* view = itr->get();
if (view && view->requiresUpdateSceneGraph()) return true;
}
// check if events are available and need processing
if (checkEvents()) return true;
// and check again if any event handler has prompted a redraw
if (_requestRedraw) return true;
if (_requestContinousUpdate) return true;
return false;
}
示例14: eventTraversal
void CompositeViewer::eventTraversal()
{
if (_done) return;
if (_views.empty()) return;
double beginEventTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
// OSG_NOTICE<<"CompositeViewer::frameEventTraversal()."<<std::endl;
// need to copy events from the GraphicsWindow's into local EventQueue;
typedef std::map<osgViewer::View*, osgGA::EventQueue::Events> ViewEventsMap;
ViewEventsMap viewEventsMap;
Contexts contexts;
getContexts(contexts);
Scenes scenes;
getScenes(scenes);
osgViewer::View* masterView = getViewWithFocus() ? getViewWithFocus() : _views[0].get();
osg::Camera* masterCamera = masterView->getCamera();
osgGA::GUIEventAdapter* eventState = masterView->getEventQueue()->getCurrentEventState();
osg::Matrix masterCameraVPW = masterCamera->getViewMatrix() * masterCamera->getProjectionMatrix();
if (masterCamera->getViewport())
{
osg::Viewport* viewport = masterCamera->getViewport();
masterCameraVPW *= viewport->computeWindowMatrix();
}
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*citr);
if (gw)
{
gw->checkEvents();
osgGA::EventQueue::Events gw_events;
gw->getEventQueue()->takeEvents(gw_events);
osgGA::EventQueue::Events::iterator itr;
for(itr = gw_events.begin();
itr != gw_events.end();
++itr)
{
osgGA::GUIEventAdapter* event = itr->get();
//OSG_NOTICE<<"event->getGraphicsContext()="<<event->getGraphicsContext()<<std::endl;
bool pointerEvent = false;
float x = event->getX();
float y = event->getY();
bool invert_y = event->getMouseYOrientation()==osgGA::GUIEventAdapter::Y_INCREASING_DOWNWARDS;
if (invert_y && gw->getTraits()) y = gw->getTraits()->height - y;
switch(event->getEventType())
{
case(osgGA::GUIEventAdapter::RESIZE):
setCameraWithFocus(0);
break;
case(osgGA::GUIEventAdapter::PUSH):
case(osgGA::GUIEventAdapter::RELEASE):
case(osgGA::GUIEventAdapter::DOUBLECLICK):
case(osgGA::GUIEventAdapter::DRAG):
case(osgGA::GUIEventAdapter::MOVE):
{
pointerEvent = true;
if (event->getEventType()!=osgGA::GUIEventAdapter::DRAG || !getCameraWithFocus())
{
osg::GraphicsContext::Cameras& cameras = gw->getCameras();
for(osg::GraphicsContext::Cameras::iterator citr = cameras.begin();
citr != cameras.end();
++citr)
{
osg::Camera* camera = *citr;
if (camera->getView() &&
camera->getAllowEventFocus() &&
camera->getRenderTargetImplementation()==osg::Camera::FRAME_BUFFER)
{
osg::Viewport* viewport = camera ? camera->getViewport() : 0;
if (viewport &&
x >= viewport->x() && y >= viewport->y() &&
x <= (viewport->x()+viewport->width()) && y <= (viewport->y()+viewport->height()) )
{
setCameraWithFocus(camera);
// If this camera is not a slave camera
if (camera->getView()->getCamera() == camera)
{
eventState->setGraphicsContext(gw);
eventState->setInputRange( viewport->x(), viewport->y(),
viewport->x()+viewport->width(),
viewport->y()+viewport->height());
//.........这里部分代码省略.........
示例15: updateTraversal
void CompositeViewer::updateTraversal()
{
if (_done) return;
double beginUpdateTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
_updateVisitor->reset();
_updateVisitor->setFrameStamp(getFrameStamp());
_updateVisitor->setTraversalNumber(getFrameStamp()->getFrameNumber());
Scenes scenes;
getScenes(scenes);
for(Scenes::iterator sitr = scenes.begin();
sitr != scenes.end();
++sitr)
{
Scene* scene = *sitr;
if (scene->getSceneData())
{
_updateVisitor->setImageRequestHandler(scene->getImagePager());
scene->getSceneData()->accept(*_updateVisitor);
}
if (scene->getDatabasePager())
{
// synchronize changes required by the DatabasePager thread to the scene graph
scene->getDatabasePager()->updateSceneGraph(*_frameStamp);
}
if (scene->getImagePager())
{
// synchronize changes required by the DatabasePager thread to the scene graph
scene->getImagePager()->updateSceneGraph(*_frameStamp);
}
}
if (_updateOperations.valid())
{
_updateOperations->runOperations(this);
}
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
View* view = vitr->get();
Scene* scene = view->getScene();
{
// call any camera update callbacks, but only traverse that callback, don't traverse its subgraph
// leave that to the scene update traversal.
osg::NodeVisitor::TraversalMode tm = _updateVisitor->getTraversalMode();
_updateVisitor->setTraversalMode(osg::NodeVisitor::TRAVERSE_NONE);
if (view->getCamera() && view->getCamera()->getUpdateCallback()) view->getCamera()->accept(*_updateVisitor);
for(unsigned int i=0; i<view->getNumSlaves(); ++i)
{
osg::Camera* camera = view->getSlave(i)._camera.get();
if (camera && camera->getUpdateCallback()) camera->accept(*_updateVisitor);
}
_updateVisitor->setTraversalMode(tm);
}
if (view->getCameraManipulator())
{
view->setFusionDistance( view->getCameraManipulator()->getFusionDistanceMode(),
view->getCameraManipulator()->getFusionDistanceValue() );
view->getCamera()->setViewMatrix( view->getCameraManipulator()->getInverseMatrix());
}
view->updateSlaves();
}
if (getStats() && getStats()->collectStats("update"))
{
double endUpdateTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
// update current frames stats
getStats()->setAttribute(_frameStamp->getFrameNumber(), "Update traversal begin time", beginUpdateTraversal);
getStats()->setAttribute(_frameStamp->getFrameNumber(), "Update traversal end time", endUpdateTraversal);
getStats()->setAttribute(_frameStamp->getFrameNumber(), "Update traversal time taken", endUpdateTraversal-beginUpdateTraversal);
}
}