Commit ab3ceb2a authored by Jan Möbius's avatar Jan Möbius

Dennis : Check Scenegraph for dirty flag in core and control number of redraws

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4326 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 06defb14
......@@ -46,6 +46,7 @@
#include "Core.hh"
// -------------------- ACG
#include <ACG/Scenegraph/DrawModes.hh>
#include <ACG/Scenegraph/SceneGraph.hh>
#include <ACG/QtWidgets/QtFileDialog.hh>
// -------------------- Qt
......@@ -157,6 +158,14 @@ Core::init() {
redrawTimer_->setSingleShot(true);
connect(redrawTimer_, SIGNAL(timeout()), this, SLOT(updateView()),Qt::DirectConnection);
// Initialice scenegraph check timer. Will be used to check for changes in the scenegraph
scenegraphCheckTimer_ = new QTimer();
scenegraphCheckTimer_->setSingleShot(false);
connect(scenegraphCheckTimer_, SIGNAL(timeout()), this, SLOT(checkScenegraphDirty()),Qt::DirectConnection);
// Will measure the time between redraws
redrawTime_ = new QTime();
redrawTime_->start ();
if ( OpenFlipper::Options::splash() ) {
QPixmap splashPixmap(OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator() + "splash.png");
......@@ -452,6 +461,9 @@ Core::init() {
splash_->finish(coreWidget_);
}
// start checking for scenegraph changes
scenegraphCheckTimer_->setInterval (1000 / OpenFlipper::Options::maxFrameRate());
scenegraphCheckTimer_->start ();
}
}
......@@ -601,6 +613,10 @@ void Core::updateView() {
if ( OpenFlipper::Options::restrictFrameRate() ) {
int elapsed = redrawTime_->elapsed ();
if ( elapsed < 1000 / OpenFlipper::Options::maxFrameRate() )
{
// redraw time not reached ... waiting for timer event for next redraw
if ( redrawTimer_->isActive() ) {
if ( OpenFlipper::Options::doSlotDebugging() )
......@@ -608,15 +624,16 @@ void Core::updateView() {
return;
}
// std::cerr << "Redraw" << std::endl;
// Start the timer if we are not called by the timer
if ( sender() != redrawTimer_ ) {
redrawTimer_->start( 1000 / OpenFlipper::Options::maxFrameRate() );
// Start the timer
redrawTimer_->start( (1000 / OpenFlipper::Options::maxFrameRate()) - elapsed);
return;
}
else if ( redrawTimer_->isActive() )
redrawTimer_->stop ();
}
redrawTime_->restart ();
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() && !OpenFlipper::Options::redrawDisabled() ) {
......@@ -628,6 +645,20 @@ void Core::updateView() {
}
}
//-----------------------------------------------------------------------------
/** Check if scenegraph is dirty and initiate redraw
*/
void Core::checkScenegraphDirty() {
if ( true )
{
ACG::SceneGraph::CheckDirtyAction action;
ACG::SceneGraph::traverse( root_node_scenegraph_, action );
if ( action.isDirty () )
emit updateView ();
}
}
//-----------------------------------------------------------------------------
void Core::restrictFrameRate( bool _enable ) {
......@@ -639,6 +670,9 @@ void Core::restrictFrameRate( bool _enable ) {
void Core::setMaxFrameRate( int _rate ) {
OpenFlipper::Options::maxFrameRate( _rate );
OpenFlipper::Options::restrictFrameRate( true );
// update Timer to new framerate
scenegraphCheckTimer_->setInterval (1000 / OpenFlipper::Options::maxFrameRate());
}
//-----------------------------------------------------------------------------
......
......@@ -674,6 +674,26 @@ private:
/** @} */
//===========================================================================
/** @name Scenegraph redraw handling
* @{ */
//===========================================================================
private slots:
/// Called to check if the scenegraph needs to be redrawn
void checkScenegraphDirty();
private:
/// Timer that starts scenegraph check
QTimer *scenegraphCheckTimer_;
/// Holds the time since last redraw
QTime *redrawTime_;
/** @} */
private :
/// Id for the next backup
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment