Changeset 13172

Show
Ignore:
Timestamp:
05/23/13 14:29:55 (62 minutes ago)
Author:
robert
Message:

Refactored the idle mechanism to fix problems with the vnc thread going idle when it shouldn't have.

Location:
OpenSceneGraph/trunk
Files:
7 added
8 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgDB/ReadFile

    r13041 r13172  
    4444inline osg::Object* readObjectFile(const std::string& filename) 
    4545{ 
    46     return readObjectFile(filename,Registry::instance()->getOptions()); 
    47 } 
     46    return readObjectFile(filename, Registry::instance()->getOptions()); 
     47} 
     48 
     49template<typename T> 
     50inline T* readFile(const std::string& filename, const Options* options) 
     51{ 
     52    osg::ref_ptr<osg::Object> object = readObjectFile(filename, options); 
     53    osg::ref_ptr<T> t = dynamic_cast<T*>(object.get()); 
     54    object = 0;     
     55    return t.release(); 
     56} 
     57 
     58template<typename T> 
     59inline T* readFile(const std::string& filename) 
     60{ 
     61    return readFile<T>(filename, Registry::instance()->getOptions()); 
     62} 
     63 
    4864 
    4965/** Read an osg::Image from file. 
  • OpenSceneGraph/trunk/include/osgViewer/View

    r13053 r13172  
    2525#include <osgGA/EventVisitor> 
    2626#include <osgGA/EventQueue> 
     27#include <osgGA/Device> 
    2728 
    2829#include <osgViewer/Scene> 
     
    109110        const osgDB::ImagePager* getImagePager() const; 
    110111 
     112        
     113        /** Add a Device. 
     114         * The Device is polled on each new frame via it's Device::checkEvents() method and any events generated then collected via Device::getEventQueue()*/ 
     115        void addDevice(osgGA::Device* eventSource); 
     116 
     117        /** Remove a Device. /*/ 
     118        void removeDevice(osgGA::Device* eventSource); 
     119 
     120        typedef std::vector< osg::ref_ptr<osgGA::Device> > Devices; 
     121 
     122        Devices& getDevices() { return _eventSources; } 
     123        const Devices& getDevices() const { return _eventSources; } 
     124 
    111125 
    112126        /* Set the EventQueue that the View uses to integrate external non window related events.*/ 
     
    251265        osg::Timer_t                            _startTick; 
    252266 
     267        Devices                            _eventSources; 
     268 
    253269        osg::ref_ptr<osgViewer::Scene>          _scene; 
    254270        osg::ref_ptr<osgGA::EventQueue>         _eventQueue; 
  • OpenSceneGraph/trunk/include/osgViewer/ViewerBase

    r13041 r13172  
    118118 
    119119 
    120  
    121120        /** Set the done flag to signal the viewer's work is done and should exit the frame loop.*/ 
    122121        void setDone(bool done) { _done = done; } 
  • OpenSceneGraph/trunk/src/osgGA/CMakeLists.txt

    r12208 r13172  
    1111    ${HEADER_PATH}/AnimationPathManipulator 
    1212    ${HEADER_PATH}/DriveManipulator 
     13    ${HEADER_PATH}/Device 
    1314    ${HEADER_PATH}/EventQueue 
    1415    ${HEADER_PATH}/EventVisitor 
     
    3738    AnimationPathManipulator.cpp 
    3839    DriveManipulator.cpp 
     40    Device.cpp 
    3941    EventQueue.cpp 
    4042    EventVisitor.cpp 
  • OpenSceneGraph/trunk/src/osgPlugins/CMakeLists.txt

    r13161 r13172  
    257257ADD_SUBDIRECTORY(pvr) 
    258258 
     259#################################################### 
     260# 
     261# Device integration plugins 
     262# 
     263IF   (SDL_FOUND) 
     264    ADD_SUBDIRECTORY(sdl) 
     265ENDIF(SDL_FOUND) 
     266 
     267 
    259268##########to get all the variables of Cmake 
    260269#GET_CMAKE_PROPERTY(MYVARS VARIABLES) 
  • OpenSceneGraph/trunk/src/osgViewer/CompositeViewer.cpp

    r13111 r13172  
    736736    } 
    737737 
     738    // get events from all windows attached to Viewer. 
    738739    for(Contexts::iterator citr = contexts.begin(); 
    739740        citr != contexts.end(); 
     
    926927    { 
    927928        View* view = vitr->get(); 
     929 
     930        // get events from user Devices attached to Viewer. 
     931        for(osgViewer::View::Devices::iterator eitr = view->getDevices().begin(); 
     932            eitr != view->getDevices().end(); 
     933            ++eitr) 
     934        { 
     935            osgGA::Device* es = eitr->get(); 
     936            es->checkEvents(); 
     937 
     938            // open question, will we need to reproject mouse coordinates into current view's coordinate frame as is down for GraphicsWindow provided events? 
     939            // for now assume now and just get the events directly without any reprojection. 
     940            es->getEventQueue()->takeEvents(viewEventsMap[view], cutOffTime); 
     941        } 
     942 
    928943        view->getEventQueue()->takeEvents(viewEventsMap[view], cutOffTime); 
    929944    } 
  • OpenSceneGraph/trunk/src/osgViewer/View.cpp

    r13041 r13172  
    22182218 
    22192219 
     2220void View::addDevice(osgGA::Device* eventSource) 
     2221{ 
     2222    Devices::iterator itr = std::find( _eventSources.begin(), _eventSources.end(), eventSource ); 
     2223    if (itr==_eventSources.end()) 
     2224    { 
     2225        _eventSources.push_back(eventSource); 
     2226    } 
     2227} 
     2228 
     2229void View::removeDevice(osgGA::Device* eventSource) 
     2230{ 
     2231    Devices::iterator itr = std::find( _eventSources.begin(), _eventSources.end(), eventSource ); 
     2232    if (itr!=_eventSources.end()) 
     2233    { 
     2234        _eventSources.erase(itr); 
     2235    } 
     2236} 
  • OpenSceneGraph/trunk/src/osgViewer/Viewer.cpp

    r13136 r13172  
    646646 
    647647 
     648    // get events from user Devices attached to Viewer. 
     649    for(Devices::iterator eitr = _eventSources.begin(); 
     650        eitr != _eventSources.end(); 
     651        ++eitr) 
     652    { 
     653        osgGA::Device* es = eitr->get(); 
     654        es->checkEvents(); 
     655 
     656        // open question, will we need to reproject mouse coordinates into current view's coordinate frame as is down for GraphicsWindow provided events? 
     657        // for now assume now and just get the events directly without any reprojection. 
     658        es->getEventQueue()->takeEvents(events, cutOffTime); 
     659    } 
     660 
     661    // get events from all windows attached to Viewer. 
    648662    for(Contexts::iterator citr = contexts.begin(); 
    649663        citr != contexts.end();