From 0d439750a2533cb9d8dc5e3f92b0340fc00b7be3 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sun, 14 Aug 2016 15:20:52 +0200 Subject: [PATCH] Clang warning fix --- extern/osgQt/GraphicsWindowQt | 10 --- extern/osgQt/GraphicsWindowQt.cpp | 123 ------------------------------ 2 files changed, 133 deletions(-) diff --git a/extern/osgQt/GraphicsWindowQt b/extern/osgQt/GraphicsWindowQt index 3be1da0515..1e34fc9db6 100644 --- a/extern/osgQt/GraphicsWindowQt +++ b/extern/osgQt/GraphicsWindowQt @@ -37,16 +37,6 @@ namespace osgQt // forward declarations class GraphicsWindowQt; -/** The function sets the viewer that will be used after entering - * the Qt main loop (QCoreApplication::exec()). - * - * The function also initializes internal structures required for proper - * scene rendering. - * - * The method must be called from main thread. */ -void setViewer( osgViewer::ViewerBase *viewer ); - - class GLWidget : public QGLWidget { typedef QGLWidget inherited; diff --git a/extern/osgQt/GraphicsWindowQt.cpp b/extern/osgQt/GraphicsWindowQt.cpp index 17150bed4b..9e5f6e55ea 100644 --- a/extern/osgQt/GraphicsWindowQt.cpp +++ b/extern/osgQt/GraphicsWindowQt.cpp @@ -26,28 +26,6 @@ using namespace osgQt; -/// The object responsible for the scene re-rendering. -class HeartBeat : public QObject { -public: - int _timerId; - osg::Timer _lastFrameStartTime; - osg::observer_ptr< osgViewer::ViewerBase > _viewer; - - virtual ~HeartBeat(); - - void init( osgViewer::ViewerBase *viewer ); - void stopTimer(); - void timerEvent( QTimerEvent *event ); - - static HeartBeat* instance(); -private: - HeartBeat(); - - static QPointer heartBeat; -}; - -QPointer HeartBeat::heartBeat; - #if (QT_VERSION < QT_VERSION_CHECK(5, 2, 0)) #define GETDEVICEPIXELRATIO() 1.0 #else @@ -637,104 +615,3 @@ private: QtWindowingSystem& operator=( const QtWindowingSystem& ); }; - -void osgQt::setViewer( osgViewer::ViewerBase *viewer ) -{ - HeartBeat::instance()->init( viewer ); -} - - -/// Constructor. Must be called from main thread. -HeartBeat::HeartBeat() : _timerId( 0 ) -{ -} - - -/// Destructor. Must be called from main thread. -HeartBeat::~HeartBeat() -{ - stopTimer(); -} - -HeartBeat* HeartBeat::instance() -{ - if (!heartBeat) - { - heartBeat = new HeartBeat(); - } - return heartBeat; -} - -void HeartBeat::stopTimer() -{ - if ( _timerId != 0 ) - { - killTimer( _timerId ); - _timerId = 0; - } -} - - -/// Initializes the loop for viewer. Must be called from main thread. -void HeartBeat::init( osgViewer::ViewerBase *viewer ) -{ - if( _viewer == viewer ) - return; - - stopTimer(); - - _viewer = viewer; - - if( viewer ) - { - _timerId = startTimer( 0 ); - _lastFrameStartTime.setStartTick( 0 ); - } -} - - -void HeartBeat::timerEvent( QTimerEvent * /*event*/ ) -{ - osg::ref_ptr< osgViewer::ViewerBase > viewer; - if( !_viewer.lock( viewer ) ) - { - // viewer has been deleted -> stop timer - stopTimer(); - return; - } - - // limit the frame rate - if( viewer->getRunMaxFrameRate() > 0.0) - { - double dt = _lastFrameStartTime.time_s(); - double minFrameTime = 1.0 / viewer->getRunMaxFrameRate(); - if (dt < minFrameTime) - OpenThreads::Thread::microSleep(static_cast(1000000.0*(minFrameTime-dt))); - } - else - { - // avoid excessive CPU loading when no frame is required in ON_DEMAND mode - if( viewer->getRunFrameScheme() == osgViewer::ViewerBase::ON_DEMAND ) - { - double dt = _lastFrameStartTime.time_s(); - if (dt < 0.01) - OpenThreads::Thread::microSleep(static_cast(1000000.0*(0.01-dt))); - } - - // record start frame time - _lastFrameStartTime.setStartTick(); - - // make frame - if( viewer->getRunFrameScheme() == osgViewer::ViewerBase::ON_DEMAND ) - { - if( viewer->checkNeedToDoFrame() ) - { - viewer->frame(); - } - } - else - { - viewer->frame(); - } - } -}