From: caremoli Date: Mon, 21 Jun 2010 15:05:36 +0000 (+0000) Subject: CCAR: change autoupdate mode to false and add a _modified flag to DataObject X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cc2532c70ee589a5399fbad49b0d96999fd87efd;p=modules%2Fgui.git CCAR: change autoupdate mode to false and add a _modified flag to DataObject to known if DataObject has been modified when doing synchronize between DataObject and TreeItem --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index a429da373..2de22f06c 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1239,11 +1239,11 @@ void LightApp_Application::updateObjectBrowser( const bool updateModels ) objectBrowser()->setAutoUpdate( isAutoUpdate ); } + */ if ( objectBrowser() ) { objectBrowser()->updateGeometry(); objectBrowser()->updateTree( 0, false ); } - */ } /*! diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index 1702acc3f..db9af4287 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -169,8 +169,8 @@ void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel, } getApp()->objectBrowser()->setAutoUpdate( upd ); - getApp()->objectBrowser()->updateTree( 0, false ); */ + getApp()->objectBrowser()->updateTree( 0, false ); } /*!NOT IMPLEMENTED*/ diff --git a/src/SUIT/SUIT_DataObject.cxx b/src/SUIT/SUIT_DataObject.cxx index 0e86e46ac..93afce809 100755 --- a/src/SUIT/SUIT_DataObject.cxx +++ b/src/SUIT/SUIT_DataObject.cxx @@ -887,6 +887,7 @@ void SUIT_DataObject::Signal::deleteLater( SUIT_DataObject* object ) void SUIT_DataObject::updateItem() { + setModified(true); signal()->emitUpdated(this); } diff --git a/src/SUIT/SUIT_DataObject.h b/src/SUIT/SUIT_DataObject.h index 7066b8686..263692542 100755 --- a/src/SUIT/SUIT_DataObject.h +++ b/src/SUIT/SUIT_DataObject.h @@ -124,6 +124,9 @@ public: virtual bool customSorting( const int = NameId ) const; virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const; + bool modified(){return _modified;}; + void setModified(bool modified){_modified = modified;}; + virtual SUIT_DataObjectKey* key() const; virtual int groupId() const; @@ -141,6 +144,7 @@ private: bool myCheck; bool myAutoDel; DataObjectList myChildren; + bool _modified; static Signal* mySignal; diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx index b0c56c498..6d318774f 100755 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -28,6 +28,17 @@ #include #include +#include +static long tt0; +static long tcount=0; +static long cumul; +static timeval tv; +#define START_TIMING gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr <modified(); // 1. check text /* update = ( item->text( 0 ) != obj->name() ) || myBrowser->needToUpdateTexts( item ); @@ -1091,6 +1103,9 @@ void SUIT_TreeModel::updateTree( const QModelIndex& index ) */ void SUIT_TreeModel::updateTree( SUIT_DataObject* obj ) { + if(myAutoUpdate) + return; + if ( !obj ) obj = root(); @@ -1207,6 +1222,8 @@ SUIT_TreeModel::TreeItem* SUIT_TreeModel::createItem( SUIT_DataObject* obj, endInsertRows(); + obj->setModified(false); + return myItems[ obj ]; } @@ -1236,6 +1253,7 @@ void SUIT_TreeModel::updateItem( SUIT_TreeModel::TreeItem* item ) QModelIndex firstIdx = index( obj, 0 ); QModelIndex lastIdx = index( obj, columnCount() - 1 ); emit dataChanged( firstIdx, lastIdx ); + obj->setModified(false); } /*! @@ -1252,6 +1270,7 @@ void SUIT_TreeModel::updateItem( SUIT_DataObject* obj) QModelIndex firstIdx = index( obj, 0 ); QModelIndex lastIdx = index( obj, columnCount() - 1 ); emit dataChanged( firstIdx, lastIdx ); + obj->setModified(false); } diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 8ffd6a93b..215abb344 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -832,6 +832,8 @@ QWidget* SalomeApp_Application::createWindow( const int flag ) // temporary commented //ob->setUpdater( new SalomeApp_Updater() ); + ob->setAutoUpdate(false); + connect( ob, SIGNAL( doubleClicked( SUIT_DataObject* ) ), this, SLOT( onDblClick( SUIT_DataObject* ) ) ); QString @@ -1245,11 +1247,10 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePop void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) { //MESSAGE("UpdateObjBrowser"); - return; - // update "non-existing" (not loaded yet) data models SalomeApp_Study* study = dynamic_cast(activeStudy()); +/* if ( study ) { _PTR(Study) stdDS = study->studyDS(); @@ -1271,7 +1272,7 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) } } } - +*/ // create data objects that correspond to GUI state save points if ( study ) updateSavePointDataObjects( study ); diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index a72b72cde..0d0a5048a 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -39,6 +39,17 @@ #include #include +#include +static long tt0; +static long tcount=0; +static long cumul; +static timeval tv; +#define START_TIMING gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; +#define END_TIMING(NUMBER) \ + tcount=tcount+1;gettimeofday(&tv,0);cumul=cumul+tv.tv_usec+tv.tv_sec*1000000 -tt0; \ + if(tcount==NUMBER){ std::cerr << __FILE__ << __LINE__ << " temps CPU(mus): " << cumul << std::endl; tcount=0;cumul=0; } + + /*! \class SalomeApp_DataObject \brief Implementation of the data object for use in CORBA-based diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 14270610c..9fc945d61 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -69,7 +69,7 @@ class Observer_i : public virtual POA_SALOME::Observer virtual void notifyObserver(const char* theID, const char* event) { - START_TIMING; + //START_TIMING; //MESSAGE("I'm notified of " << event << " of ID = " << theID); _PTR(SObject) obj = myStudyDS->FindObjectID( theID ); @@ -169,7 +169,7 @@ class Observer_i : public virtual POA_SALOME::Observer MESSAGE("Want to modify an unknown object" << theID); } } - END_TIMING(200); + //END_TIMING(10); } private: