本文整理汇总了C++中Contexts::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Contexts::begin方法的具体用法?C++ Contexts::begin怎么用?C++ Contexts::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contexts
的用法示例。
在下文中一共展示了Contexts::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setStartTick
void CompositeViewer::setStartTick(osg::Timer_t tick)
{
_startTick = tick;
for(RefViews::iterator vitr = _views.begin();
vitr != _views.end();
++vitr)
{
(*vitr)->setStartTick(tick);
}
Contexts contexts;
getContexts(contexts,false);
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*citr);
if (gw)
{
gw->getEventQueue()->setStartTick(_startTick);
}
}
}
示例2: stopThreading
CompositeViewer::~CompositeViewer()
{
OSG_INFO<<"CompositeViewer::~CompositeViewer()"<<std::endl;
stopThreading();
Scenes scenes;
getScenes(scenes);
for(Scenes::iterator sitr = scenes.begin();
sitr != scenes.end();
++sitr)
{
Scene* scene = *sitr;
if (scene->getDatabasePager())
{
scene->getDatabasePager()->cancel();
scene->setDatabasePager(0);
}
}
Contexts contexts;
getContexts(contexts);
// clear out all the previously assigned operations
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
(*citr)->close();
}
OSG_INFO<<"finished CompositeViewer::~CompositeViewer()"<<std::endl;
}
示例3: getOperationThreads
void CompositeViewer::getOperationThreads(OperationThreads& threads, bool onlyActive)
{
threads.clear();
Contexts contexts;
getContexts(contexts);
for(Contexts::iterator gcitr = contexts.begin();
gcitr != contexts.end();
++gcitr)
{
osg::GraphicsContext* gc = *gcitr;
if (gc->getGraphicsThread() &&
(!onlyActive || gc->getGraphicsThread()->isRunning()) )
{
threads.push_back(gc->getGraphicsThread());
}
}
Cameras cameras;
getCameras(cameras);
for(Cameras::iterator citr = cameras.begin();
citr != cameras.end();
++citr)
{
osg::Camera* camera = *citr;
if (camera->getCameraThread() &&
(!onlyActive || camera->getCameraThread()->isRunning()) )
{
threads.push_back(camera->getCameraThread());
}
}
}
示例4: getAllThreads
Viewer::~Viewer()
{
//OSG_NOTICE<<"Viewer::~Viewer()"<<std::endl;
Threads threads;
getAllThreads(threads);
OSG_INFO<<"Viewer::~Viewer():: start destructor getThreads = "<<threads.size()<<std::endl;
stopThreading();
if (_scene.valid() && _scene->getDatabasePager())
{
_scene->getDatabasePager()->cancel();
_scene->setDatabasePager(0);
}
Contexts contexts;
getContexts(contexts);
// clear out all the previously assigned operations
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
(*citr)->close();
}
//OSG_NOTICE<<"finish Viewer::~Viewer()"<<std::endl;
getAllThreads(threads);
OSG_INFO<<"Viewer::~Viewer() end destructor getThreads = "<<threads.size()<<std::endl;
}
示例5: addView
void CompositeViewer::addView(osgViewer::View* view)
{
if (!view) return;
bool alreadyRealized = isRealized();
bool threadsWereRunning = _threadsRunning;
if (threadsWereRunning) stopThreading();
_views.push_back(view);
view->_viewerBase = this;
if (view->getSceneData())
{
// make sure that existing scene graph objects are allocated with thread safe ref/unref
if (getThreadingModel()!=ViewerBase::SingleThreaded)
{
view->getSceneData()->setThreadSafeRefUnref(true);
}
// update the scene graph so that it has enough GL object buffer memory for the graphics contexts that will be using it.
view->getSceneData()->resizeGLObjectBuffers(osg::DisplaySettings::instance()->getMaxNumberOfGraphicsContexts());
}
view->setFrameStamp(_frameStamp.get());
if (alreadyRealized)
{
Contexts contexts;
if (view->getCamera()->getGraphicsContext())
{
contexts.push_back(view->getCamera()->getGraphicsContext());
}
for(unsigned int i=0; i<view->getNumSlaves(); ++i)
{
if (view->getSlave(i)._camera->getGraphicsContext())
{
contexts.push_back(view->getSlave(i)._camera->getGraphicsContext());
}
}
for(Contexts::iterator itr = contexts.begin();
itr != contexts.end();
++itr)
{
if (!((*itr)->isRealized()))
{
(*itr)->realize();
}
}
}
if (threadsWereRunning) startThreading();
}
示例6: execute
void ExecutableOpHolder::execute( const Contexts &contexts ) const
{
for ( Contexts::const_iterator cit = contexts.begin(); cit != contexts.end(); cit++ )
{
// \todo Implement a way to get the CompoundObject for a given context without modifying the Op's parameter
// and passing it explicitly in the operate call. Than multi-thread this loop.
Context::Scope scope( *cit );
constPointerCast<CompoundParameterHandler>( parameterHandler() )->setParameterValue();
constPointerCast<Op>( getOp() )->operate();
}
}
示例7: getWindows
void ViewerBase::getWindows(Windows& windows, bool onlyValid)
{
windows.clear();
Contexts contexts;
getContexts(contexts, onlyValid);
for(Contexts::iterator itr = contexts.begin();
itr != contexts.end();
++itr)
{
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*itr);
if (gw) windows.push_back(gw);
}
}
示例8: execute
void ExecutableRender::execute( const Contexts &contexts ) const
{
const ScenePlug *scene = inPlug()->getInput<ScenePlug>();
if( !scene )
{
throw IECore::Exception( "No input scene" );
}
/// \todo This doesn't belong here. It'll be the responsibility of the Despatchers
/// to save the script if necessary, and to save it to an alternate location than
/// the current one.
scriptNode()->save();
for( Contexts::const_iterator it = contexts.begin(), eIt = contexts.end(); it != eIt; it++ )
{
Context::Scope scopedContext( it->get() );
ConstCompoundObjectPtr globals = scene->globalsPlug()->getValue();
createDisplayDirectories( globals );
IECore::RendererPtr renderer = createRenderer();
outputOptions( globals, renderer );
outputCamera( scene, globals, renderer );
{
WorldBlock world( renderer );
outputLights( scene, globals, renderer );
outputWorldProcedural( scene, renderer );
}
std::string systemCommand = command();
if( systemCommand.size() )
{
const ApplicationRoot *applicationRoot = scene->ancestor<ApplicationRoot>();
if( applicationRoot && applicationRoot->getName() == "gui" )
{
/// \todo We need this weird background execution behaviour because we
/// don't want to block the ui while rendering, but really the LocalDespatcher
/// should be responsible for launching a separate process to do the execution
/// from anyway.
systemCommand += "&";
}
system( systemCommand.c_str() );
}
}
}
示例9: getAllThreads
Viewer::~Viewer()
{
//OSG_NOTICE<<"Viewer::~Viewer()"<<std::endl;
Threads threads;
getAllThreads(threads);
OSG_INFO<<"Viewer::~Viewer():: start destructor getThreads = "<<threads.size()<<std::endl;
stopThreading();
if (_scene.valid() && _scene->getDatabasePager())
{
_scene->getDatabasePager()->cancel();
_scene->setDatabasePager(0);
}
Contexts contexts;
getContexts(contexts);
// clear out all the previously assigned operations
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
osg::GraphicsContext* gc = *citr;
// Run destroy operation on each context before closing it
if (_cleanUpOperation.valid() && gc->valid())
{
gc->makeCurrent();
(*_cleanUpOperation)(gc);
gc->releaseContext();
}
gc->close();
}
//OSG_NOTICE<<"finish Viewer::~Viewer()"<<std::endl;
getAllThreads(threads);
OSG_INFO<<"Viewer::~Viewer() end destructor getThreads = "<<threads.size()<<std::endl;
}
示例10: isRealized
bool CompositeViewer::isRealized() const
{
Contexts contexts;
const_cast<CompositeViewer*>(this)->getContexts(contexts);
unsigned int numRealizedWindows = 0;
// clear out all the previously assigned operations
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
if ((*citr)->isRealized()) ++numRealizedWindows;
}
return numRealizedWindows > 0;
}
示例11: setStartTick
void Viewer::setStartTick(osg::Timer_t tick)
{
View::setStartTick(tick);
Contexts contexts;
getContexts(contexts,false);
getEventQueue()->setStartTick(_startTick);
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*citr);
if (gw)
{
gw->getEventQueue()->setStartTick(_startTick);
}
}
}
示例12: addView
void CompositeViewer::addView(osgViewer::View* view)
{
bool alreadyRealized = isRealized();
bool threadsWereRuinning = _threadsRunning;
if (threadsWereRuinning) stopThreading();
_views.push_back(view);
view->_viewerBase = this;
view->setFrameStamp(_frameStamp.get());
if (alreadyRealized)
{
Contexts contexts;
if (view->getCamera()->getGraphicsContext())
{
contexts.push_back(view->getCamera()->getGraphicsContext());
}
for(unsigned int i=0; i<view->getNumSlaves(); ++i)
{
if (view->getSlave(i)._camera->getGraphicsContext())
{
contexts.push_back(view->getSlave(i)._camera->getGraphicsContext());
}
}
for(Contexts::iterator itr = contexts.begin();
itr != contexts.end();
++itr)
{
if (!((*itr)->isRealized()))
{
(*itr)->realize();
}
}
}
if (threadsWereRuinning) startThreading();
}
示例13: renderingTraversals
void CompositeViewer::renderingTraversals( bool needMakeCurrentInThisThread )
{
Contexts contexts;
getContexts( contexts );
bool doneMakeCurrentInThisThread = false;
for( Contexts::iterator itr = contexts.begin( );
itr != contexts.end( ); ++itr )
{
if(( *itr )->valid( ))
{
if( needMakeCurrentInThisThread )
{
doneMakeCurrentInThisThread = true;
makeCurrent( *itr );
}
( *itr )->runOperations( );
}
}
if( doneMakeCurrentInThisThread )
releaseContext( );
}
示例14: eventTraversal
void CompositeViewer::eventTraversal()
{
if (_done) return;
if (_views.empty()) return;
double cutOffTime = _frameStamp->getReferenceTime();
double beginEventTraversal = osg::Timer::instance()->delta_s(_startTick, osg::Timer::instance()->tick());
// need to copy events from the GraphicsWindow's into local EventQueue for each view;
typedef std::map<osgViewer::View*, osgGA::EventQueue::Events> ViewEventsMap;
ViewEventsMap viewEventsMap;
Contexts contexts;
getContexts(contexts);
// set done if there are no windows
checkWindowStatus(contexts);
if (_done) return;
osgGA::EventQueue::Events all_events;
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, cutOffTime);
for(osgGA::EventQueue::Events::iterator itr = gw_events.begin();
itr != gw_events.end();
++itr)
{
(*itr)->setGraphicsContext(gw);
}
all_events.insert(all_events.end(), gw_events.begin(), gw_events.end());
}
}
// sort all the events in time order so we can make sure we pass them all on in the correct order.
all_events.sort(SortEvents());
// pass on pointer data onto non mouse events to keep the position data usable by all recipients of all events.
for(osgGA::EventQueue::Events::iterator itr = all_events.begin();
itr != all_events.end();
++itr)
{
osgGA::GUIEventAdapter* event = itr->get();
switch(event->getEventType())
{
case(osgGA::GUIEventAdapter::PUSH):
case(osgGA::GUIEventAdapter::RELEASE):
case(osgGA::GUIEventAdapter::DOUBLECLICK):
case(osgGA::GUIEventAdapter::MOVE):
case(osgGA::GUIEventAdapter::DRAG):
{
if ((event->getEventType()!=osgGA::GUIEventAdapter::DRAG && event->getEventType()!=osgGA::GUIEventAdapter::RELEASE) ||
!_previousEvent ||
_previousEvent->getGraphicsContext()!=event->getGraphicsContext() ||
_previousEvent->getNumPointerData()<2)
{
generatePointerData(*event);
}
else
{
reprojectPointerData(*_previousEvent, *event);
}
#if 0
// assign topmost PointeData settings as the events X,Y and InputRange
osgGA::PointerData* pd = event->getPointerData(event->getNumPointerData()-1);
event->setX(pd->x);
event->setY(pd->y);
event->setInputRange(pd->xMin, pd->yMin, pd->xMax, pd->yMax);
event->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS);
#else
if (event->getMouseYOrientation()!=osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS)
{
event->setY((event->getYmax()-event->getY())+event->getYmin());
event->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS);
}
#endif
_previousEvent = event;
break;
}
default:
if (_previousEvent.valid()) event->copyPointerDataFrom(*_previousEvent);
break;
}
//.........这里部分代码省略.........
示例15: realize
void CompositeViewer::realize()
{
//OSG_INFO<<"CompositeViewer::realize()"<<std::endl;
setCameraWithFocus(0);
if (_views.empty())
{
OSG_NOTICE<<"CompositeViewer::realize() - No views to realize."<<std::endl;
_done = true;
return;
}
Contexts contexts;
getContexts(contexts);
if (contexts.empty())
{
OSG_INFO<<"CompositeViewer::realize() - No valid contexts found, setting up view across all screens."<<std::endl;
// no windows are already set up so set up a default view
_views[0]->setUpViewAcrossAllScreens();
getContexts(contexts);
}
if (contexts.empty())
{
OSG_NOTICE<<"CompositeViewer::realize() - failed to set up any windows"<<std::endl;
_done = true;
return;
}
unsigned int maxTexturePoolSize = osg::DisplaySettings::instance()->getMaxTexturePoolSize();
unsigned int maxBufferObjectPoolSize = osg::DisplaySettings::instance()->getMaxBufferObjectPoolSize();
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
osg::GraphicsContext* gc = *citr;
// set the pool sizes, 0 the default will result in no GL object pools.
gc->getState()->setMaxTexturePoolSize(maxTexturePoolSize);
gc->getState()->setMaxBufferObjectPoolSize(maxBufferObjectPoolSize);
gc->realize();
if (_realizeOperation.valid() && gc->valid())
{
gc->makeCurrent();
(*_realizeOperation)(gc);
gc->releaseContext();
}
}
// attach contexts to _incrementalCompileOperation if attached.
if (_incrementalCompileOperation) _incrementalCompileOperation->assignContexts(contexts);
bool grabFocus = true;
if (grabFocus)
{
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*citr);
if (gw)
{
gw->grabFocusIfPointerInWindow();
}
}
}
startThreading();
// initialize the global timer to be relative to the current time.
osg::Timer::instance()->setStartTick();
// pass on the start tick to all the associated eventqueues
setStartTick(osg::Timer::instance()->getStartTick());
if (osg::DisplaySettings::instance()->getCompileContextsHint())
{
int numProcessors = OpenThreads::GetNumberOfProcessors();
int processNum = 0;
for(unsigned int i=0; i<= osg::GraphicsContext::getMaxContextID(); ++i)
{
osg::GraphicsContext* gc = osg::GraphicsContext::getOrCreateCompileContext(i);
if (gc)
{
gc->createGraphicsThread();
gc->getGraphicsThread()->setProcessorAffinity(processNum % numProcessors);
gc->getGraphicsThread()->startThread();
//.........这里部分代码省略.........