From 602d83a486888f8ab4a67bbbf87fd7c0a60f042c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 3 May 2009 18:51:13 +0000 Subject: [PATCH] Warning fixes --- applications/present3D/Cluster.cpp | 6 +-- applications/present3D/SlideEventHandler.cpp | 43 +++++++++++++++++--- applications/present3D/SlideEventHandler.h | 11 +++-- src/osgPlugins/p3d/SlideEventHandler.cpp | 10 ++--- src/osgPlugins/p3d/SlideEventHandler.h | 16 ++++---- 5 files changed, 61 insertions(+), 25 deletions(-) diff --git a/applications/present3D/Cluster.cpp b/applications/present3D/Cluster.cpp index d151e4f82..251cf7902 100644 --- a/applications/present3D/Cluster.cpp +++ b/applications/present3D/Cluster.cpp @@ -214,7 +214,7 @@ void DataConverter::read(CameraPacket& cameraPacket) _swapBytes = !_swapBytes; } - cameraPacket._masterKilled = bool(readUInt()); + cameraPacket._masterKilled = readUInt()!=0; read(cameraPacket._matrix); read(cameraPacket._frameStamp); @@ -355,8 +355,8 @@ void Receiver::sync( void ) // saddr.sin_port = htons( _port ); recvfrom( _so, (char *)_buffer, _buffer_size, 0, (sockaddr*)&saddr, &size ); // recvfrom(sock_Receive, szMessage, 256, 0, (sockaddr*)&addr_Cli, &clilen) - int err = WSAGetLastError (); - int *dum = (int*) _buffer; + //int err = WSAGetLastError (); + //int *dum = (int*) _buffer; while( select( _so+1, &fdset, 0L, 0L, &tv ) ) { diff --git a/applications/present3D/SlideEventHandler.cpp b/applications/present3D/SlideEventHandler.cpp index c29c030cb..20b13369f 100644 --- a/applications/present3D/SlideEventHandler.cpp +++ b/applications/present3D/SlideEventHandler.cpp @@ -656,7 +656,7 @@ SlideEventHandler::SlideEventHandler(osgViewer::Viewer* viewer): _updateOpacityActive(false), _previousX(0), _previousY(0), _cursorOn(true), - _releaseAndCompileOnEachNewSlide(true), + _releaseAndCompileOnEachNewSlide(false), _firstSlideOrLayerChange(true), _tickAtFirstSlideOrLayerChange(0), _tickAtLastSlideOrLayerChange(0), @@ -701,7 +701,7 @@ void SlideEventHandler::set(osg::Node* model) _timePerSlide = duration; } - selectSlide(0); + //selectSlide(0); } else { @@ -718,7 +718,7 @@ void SlideEventHandler::set(osg::Node* model) osg::notify(osg::INFO)<<"Found presentation slide"<getName()<(nv); + if (ev) + { + if (node->getNumChildrenRequiringEventTraversal()>0) traverse(node,nv); + + if (ev->getActionAdapter() && !ev->getEvents().empty()) + { + for(osgGA::EventQueue::Events::iterator itr = ev->getEvents().begin(); + itr != ev->getEvents().end(); + ++itr) + { + handleWithCheckAgainstIgnoreHandledEventsMask(*(*itr), *(ev->getActionAdapter()), node, nv); + } + } + } +} + bool SlideEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) { + + if (!_viewer) + { + _viewer = dynamic_cast(&aa); + selectSlide(0); + home(); + osg::notify(osg::NOTICE)<<"Assigned viewer. to SlideEventHandler"<getCamera()->getViewMatrix(),0.0f,0.0f); - _viewer->getSceneData()->accept(uav); + if (_viewer.valid()) + { + UpdateLightVisitor uav(_viewer->getCamera()->getViewMatrix(),0.0f,0.0f); + _viewer->getSceneData()->accept(uav); + } } bool SlideEventHandler::home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) diff --git a/applications/present3D/SlideEventHandler.h b/applications/present3D/SlideEventHandler.h index e70b8caeb..6db0a5059 100644 --- a/applications/present3D/SlideEventHandler.h +++ b/applications/present3D/SlideEventHandler.h @@ -205,6 +205,9 @@ public: virtual void accept(osgGA::GUIEventHandlerVisitor& v) { v.visit(*this); } + /** Event traversal node callback method.*/ + virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); + virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&); virtual void getUsage(osg::ApplicationUsage& usage) const; @@ -280,13 +283,13 @@ protected: osg::observer_ptr _viewer; - osg::ref_ptr _showSwitch; - unsigned int _activePresentation; + osg::observer_ptr _showSwitch; + int _activePresentation; - osg::ref_ptr _presentationSwitch; + osg::observer_ptr _presentationSwitch; int _activeSlide; - osg::ref_ptr _slideSwitch; + osg::observer_ptr _slideSwitch; int _activeLayer; bool _firstTraversal; diff --git a/src/osgPlugins/p3d/SlideEventHandler.cpp b/src/osgPlugins/p3d/SlideEventHandler.cpp index 66b09f7a8..20b13369f 100644 --- a/src/osgPlugins/p3d/SlideEventHandler.cpp +++ b/src/osgPlugins/p3d/SlideEventHandler.cpp @@ -733,7 +733,7 @@ double SlideEventHandler::getCurrentTimeDelayBetweenSlides() const if (_slideSwitch.valid()) { double duration = -1.0; - if (_activeLayer<_slideSwitch->getNumChildren()) + if (_activeLayer(_slideSwitch->getNumChildren())) { duration = getDuration(_slideSwitch->getChild(_activeLayer)); } @@ -1021,7 +1021,7 @@ unsigned int SlideEventHandler::getNumSlides() } -bool SlideEventHandler::selectSlide(unsigned int slideNum,unsigned int layerNum) +bool SlideEventHandler::selectSlide(int slideNum,int layerNum) { if (!_presentationSwitch) return false; @@ -1032,7 +1032,7 @@ bool SlideEventHandler::selectSlide(unsigned int slideNum,unsigned int layerNum) slideNum = _presentationSwitch->getNumChildren()-1; } - if (slideNum>=_presentationSwitch->getNumChildren()) return false; + if (slideNum>=static_cast(_presentationSwitch->getNumChildren())) return false; osg::Timer_t tick = osg::Timer::instance()->tick(); @@ -1110,7 +1110,7 @@ bool SlideEventHandler::selectSlide(unsigned int slideNum,unsigned int layerNum) } -bool SlideEventHandler::selectLayer(unsigned int layerNum) +bool SlideEventHandler::selectLayer(int layerNum) { if (!_slideSwitch) return false; @@ -1119,7 +1119,7 @@ bool SlideEventHandler::selectLayer(unsigned int layerNum) layerNum = _slideSwitch->getNumChildren()-1; } - if (layerNum>=_slideSwitch->getNumChildren()) return false; + if (layerNum>=static_cast(_slideSwitch->getNumChildren())) return false; _activeLayer = layerNum; _slideSwitch->setSingleChildOn(_activeLayer); diff --git a/src/osgPlugins/p3d/SlideEventHandler.h b/src/osgPlugins/p3d/SlideEventHandler.h index 9e8f75325..6db0a5059 100644 --- a/src/osgPlugins/p3d/SlideEventHandler.h +++ b/src/osgPlugins/p3d/SlideEventHandler.h @@ -217,7 +217,7 @@ public: enum WhichPosition { FIRST_POSITION = 0, - LAST_POSITION = 0xffffffff + LAST_POSITION = -1 }; void compileSlide(unsigned int slideNum); @@ -225,11 +225,11 @@ public: unsigned int getNumSlides(); - unsigned int getActiveSlide() const { return _activeSlide; } - unsigned int getActiveLayer() const { return _activeLayer; } + int getActiveSlide() const { return _activeSlide; } + int getActiveLayer() const { return _activeLayer; } - bool selectSlide(unsigned int slideNum,unsigned int layerNum=FIRST_POSITION); - bool selectLayer(unsigned int layerNum); + bool selectSlide(int slideNum,int layerNum=FIRST_POSITION); + bool selectLayer(int layerNum); bool nextLayerOrSlide(); bool previousLayerOrSlide(); @@ -284,13 +284,13 @@ protected: osg::observer_ptr _viewer; osg::observer_ptr _showSwitch; - unsigned int _activePresentation; + int _activePresentation; osg::observer_ptr _presentationSwitch; - unsigned int _activeSlide; + int _activeSlide; osg::observer_ptr _slideSwitch; - unsigned int _activeLayer; + int _activeLayer; bool _firstTraversal; double _previousTime;