Commit 3ee44f5c authored by Jan Möbius's avatar Jan Möbius

Renamed and extended functions to block scenegraph updates.

OpenFlipper::Options::loadingSettings 

replaced by 

sceneGraphUpdatesBlocked()
blockSceneGraphUpdates()
unblockSceneGraphUpdates()


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15114 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 711ef5b9
......@@ -865,7 +865,7 @@ void Core::updateView()
redrawTime_->restart();
if (!OpenFlipper::Options::loadingSettings() && !OpenFlipper::Options::redrawDisabled()) {
if (!OpenFlipper::Options::sceneGraphUpdatesBlocked() && !OpenFlipper::Options::redrawDisabled()) {
for (unsigned int i = 0; i < OpenFlipper::Options::examinerWidgets(); ++i)
coreWidget_->examiner_widgets_[i]->updateGL();
......
......@@ -420,7 +420,7 @@ void Core::openIniFile( QString _filename,
}
// Tell plugins that we are currently reading an ini file
OpenFlipper::Options::loadingSettings(true);
OpenFlipper::Options::blockSceneGraphUpdates();
// Load Core settings only if requested
if ( _coreSettings )
......@@ -525,7 +525,7 @@ void Core::openIniFile( QString _filename,
ini.disconnect();
// As the reading has been completed, tell plugins that we do not read an ini file anymore.
OpenFlipper::Options::loadingSettings(false);
OpenFlipper::Options::unblockSceneGraphUpdates();
// Reset scenegraph and reset trackball center
// This will also recompute the bounding boxes as well as the near and far plane
......
......@@ -63,7 +63,7 @@
void Core::resetScenegraph( bool _resetTrackBall ) {
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() ) {
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::sceneGraphUpdatesBlocked() ) {
unsigned int maxPases = 1;
ACG::Vec3d bbmin,bbmax;
......@@ -161,7 +161,7 @@ void Core::slotExecuteAfterStartup() {
slotCall( "scripting" ,"clearEditor()",ok);
}
OpenFlipper::Options::loadingSettings(true);
OpenFlipper::Options::blockSceneGraphUpdates();
// Open all files given at the commandline
for ( uint i = 0 ; i < commandLineFileNames_.size() ; ++i ) {
......@@ -181,7 +181,7 @@ void Core::slotExecuteAfterStartup() {
}
}
OpenFlipper::Options::loadingSettings(false);
OpenFlipper::Options::unblockSceneGraphUpdates();
// Reset the scenegraph once to make sure everything is fine
resetScenegraph( true );
......@@ -258,7 +258,7 @@ int Core::loadObject ( QString _filename ) {
if ( OpenFlipper::Options::gui() ) {
coreWidget_->statusMessage( tr("Loading %1 ... ").arg(_filename));
if ( !OpenFlipper::Options::loadingSettings() )
if ( !OpenFlipper::Options::sceneGraphUpdatesBlocked() )
coreWidget_->setStatus(ApplicationStatus::PROCESSING );
}
......@@ -286,7 +286,7 @@ int Core::loadObject ( QString _filename ) {
} else
coreWidget_->statusMessage( tr("Loading %1 ... failed!").arg(_filename), 4000 );
if ( !OpenFlipper::Options::loadingSettings() )
if ( !OpenFlipper::Options::sceneGraphUpdatesBlocked() )
coreWidget_->setStatus(ApplicationStatus::READY );
}
......@@ -347,7 +347,7 @@ int Core::loadObject( DataType _type, QString _filename) {
if ( OpenFlipper::Options::gui() ) {
coreWidget_->statusMessage( tr("Loading %1 ... ").arg(_filename));
if ( !OpenFlipper::Options::loadingSettings() )
if ( !OpenFlipper::Options::sceneGraphUpdatesBlocked() )
coreWidget_->setStatus(ApplicationStatus::PROCESSING );
}
......@@ -374,7 +374,7 @@ int Core::loadObject( DataType _type, QString _filename) {
} else
coreWidget_->statusMessage( tr("Loading %1 ... failed!").arg(_filename), 4000 );
if ( !OpenFlipper::Options::loadingSettings() )
if ( !OpenFlipper::Options::sceneGraphUpdatesBlocked() )
coreWidget_->setStatus(ApplicationStatus::READY );
}
......@@ -469,7 +469,7 @@ void Core::slotLoad(QString _filename, int _pluginID) {
if ( OpenFlipper::Options::gui() ) {
coreWidget_->statusMessage( tr("Loading %1 ... ").arg(_filename));
if ( !OpenFlipper::Options::loadingSettings() )
if ( !OpenFlipper::Options::sceneGraphUpdatesBlocked() )
coreWidget_->setStatus(ApplicationStatus::PROCESSING );
}
......@@ -482,7 +482,7 @@ void Core::slotLoad(QString _filename, int _pluginID) {
else
coreWidget_->statusMessage( tr("Loading %1 ... failed!").arg(_filename), 4000 );
if ( !OpenFlipper::Options::loadingSettings() )
if ( !OpenFlipper::Options::sceneGraphUpdatesBlocked() )
coreWidget_->setStatus(ApplicationStatus::READY );
}
......@@ -592,7 +592,7 @@ void Core::slotFileOpened ( int _id ) {
// ================================================================================
// if this is the first object opend, reset the global view
// ================================================================================
if ( PluginFunctions::objectCount() == 1 && OpenFlipper::Options::gui() && !OpenFlipper::Options::loadingSettings() )
if ( PluginFunctions::objectCount() == 1 && OpenFlipper::Options::gui() && !OpenFlipper::Options::sceneGraphUpdatesBlocked() )
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
coreWidget_->examiner_widgets_[i]->viewAll();
}
......
......@@ -189,8 +189,8 @@ static QString lastDataType_ = "Triangle Mesh";
/// Should backups be enabled
static bool enableBackup_ = true;
/// Currently loading Settings?
static bool loadingSettings_ = false;
/// Updates currently blocked?
static int sceneGraphUpdatesBlocked_ = 0;
/// Currently loading recent file?
static bool loadingRecentFile_ = false;
......@@ -665,12 +665,22 @@ void enableBackup(bool _enableBackup ) {
enableBackup_ = _enableBackup;
}
bool loadingSettings( ) {
return loadingSettings_;
void blockSceneGraphUpdates( ) {
++sceneGraphUpdatesBlocked_;
}
void loadingSettings(bool _loadingSettings ) {
loadingSettings_ = _loadingSettings;
void unblockSceneGraphUpdates() {
if ( sceneGraphUpdatesBlocked_ <= 0)
std::cerr << "Error: More unblocks than blocks! Ignoring this request" << std::endl;
else
--sceneGraphUpdatesBlocked_;
}
bool sceneGraphUpdatesBlocked( ) {
if ( sceneGraphUpdatesBlocked_ < 0)
std::cerr << "Error: updates blocked < 0 ... more unblocks than blocks" << std::endl;
return (sceneGraphUpdatesBlocked_ > 0);
}
bool savingSettings( ) {
......
......@@ -638,18 +638,32 @@ QString helpDirStr();
/** @} */
//===========================================================================
/** @name Settings
* @{ */
//===========================================================================
//===========================================================================
/** @name Update blocking
*
* Used to speedup system when creating/removing a lot of objects.
* This disables the analysis of the scenegraph used for rendering.
* @{ */
//===========================================================================
/// currently loading Settings ?
/// Block updates
DLLEXPORT
bool loadingSettings( );
void blockSceneGraphUpdates( );
/// currently loading Settings ?
/// unblockUpdates
DLLEXPORT
void loadingSettings(bool _loadingSettings );
void unblockSceneGraphUpdates();
/// Updates currently blocked?
DLLEXPORT
bool sceneGraphUpdatesBlocked( );
/** @} */
//===========================================================================
/** @name Settings
* @{ */
//===========================================================================
/// currently saving Settings ?
DLLEXPORT
......
......@@ -833,7 +833,7 @@ void
CoreWidget::addRecent(QString _filename, DataType _type)
{
//dont add objects to recentMenu while loadind Settings
if ( OpenFlipper::Options::loadingSettings() ) return;
if ( OpenFlipper::Options::sceneGraphUpdatesBlocked() ) return;
OpenFlipper::Options::addRecentFile(_filename, _type);
......
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