From: caremoli Date: Thu, 17 Jun 2010 17:27:00 +0000 (+0000) Subject: CCAR: remove second synchronize between DataObject and TreeItem : X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f71c8f375ae119dd9e9cd0e5f89d1aca674bc8a4;p=modules%2Fgui.git CCAR: remove second synchronize between DataObject and TreeItem : insert, remove, update directly the item --- diff --git a/Makefile.am b/Makefile.am index 78e039f59..83bcd4b2e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,8 +27,7 @@ # include $(top_srcdir)/adm_local/unix/make_common_starter.am -ACLOCAL_AMFLAGS = -I adm_local/unix/config_files \ - -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files +ACLOCAL_AMFLAGS = -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files if GUI_ENABLE_CORBA IDLDIR = idl diff --git a/adm_local/unix/config_files/check_vtk.m4 b/adm_local/unix/config_files/check_vtk.m4 index 219e549ac..1da864219 100644 --- a/adm_local/unix/config_files/check_vtk.m4 +++ b/adm_local/unix/config_files/check_vtk.m4 @@ -87,7 +87,7 @@ then LXLIB="" fi -LOCAL_INCLUDES="$OGL_INCLUDES" +LOCAL_INCLUDES="$OGL_INCLUDES -DVTK_EXCLUDE_STRSTREAM_HEADERS" LOCAL_LIBS="-lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets $LXLIB -lX11 -lXt" TRY_LINK_LIBS="-lvtkCommon $LXLIB -lX11 -lXt" diff --git a/src/LightApp/Makefile.am b/src/LightApp/Makefile.am index 7f682eec1..c1d8006d2 100755 --- a/src/LightApp/Makefile.am +++ b/src/LightApp/Makefile.am @@ -240,7 +240,7 @@ libLightApp_la_LIBADD = ../SUIT/libsuit.la ../STD/libstd.la ../CAM/libCAM.la \ ../LogWindow/libLogWindow.la $(CAS_KERNEL) \ ../Prs/libSalomePrs.la ../ObjBrowser/libObjBrowser.la ../Style/libSalomeStyle.la \ ../Event/libEvent.la \ - $(HDF5_LIBS) $(KERNEL_LDFLAGS) -lSalomeHDFPersist -lSALOMELocalTrace + $(KERNEL_LDFLAGS) -lSalomeHDFPersist -lSALOMELocalTrace if ENABLE_SALOMEOBJECT libLightApp_la_LIBADD += ../OBJECT/libSalomeObject.la diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx index 2a33e342f..8a6b27c99 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx @@ -50,6 +50,16 @@ #include #include +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; 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; } + +timeval tv; /*! \class SALOMEGUI_Swig \brief Python interface module for SALOME GUI. @@ -163,12 +173,14 @@ bool SALOMEGUI_Swig::hasDesktop() */ void SALOMEGUI_Swig::updateObjBrowser( bool /*updateSelection*/ ) { + gettimeofday(&tv,0);tt0=tv.tv_usec+tv.tv_sec*1000000; class TEvent: public SALOME_Event { public: TEvent() {} virtual void Execute() { + END_TIMING(1); if ( LightApp_Application* anApp = getApplication() ) { anApp->updateObjectBrowser(); anApp->updateActions(); //SRN: added in order to update the toolbar diff --git a/src/SUIT/SUIT_DataBrowser.cxx b/src/SUIT/SUIT_DataBrowser.cxx index c88808ba3..3a974b4b3 100644 --- a/src/SUIT/SUIT_DataBrowser.cxx +++ b/src/SUIT/SUIT_DataBrowser.cxx @@ -125,7 +125,7 @@ void SUIT_DataBrowser::setAutoUpdate( const bool on ) */ void SUIT_DataBrowser::updateTree( SUIT_DataObject* obj, const bool autoOpen ) { - std::cerr << " updateTree from SUIT_DataBrowser" << std::endl; + //std::cerr << " updateTree from SUIT_DataBrowser" << std::endl; SUIT_ProxyModel* m = qobject_cast( model() ); if ( m ) { m->updateTree( obj ); diff --git a/src/SUIT/SUIT_DataObject.cxx b/src/SUIT/SUIT_DataObject.cxx index 96f91e7d7..0e86e46ac 100755 --- a/src/SUIT/SUIT_DataObject.cxx +++ b/src/SUIT/SUIT_DataObject.cxx @@ -26,6 +26,7 @@ #include "SUIT_DataObject.h" #include "SUIT_DataObjectKey.h" #include +#include SUIT_DataObject::Signal* SUIT_DataObject::mySignal = 0; @@ -279,7 +280,10 @@ void SUIT_DataObject::insertChild( SUIT_DataObject* obj, int position ) int pos = position < 0 ? myChildren.count() : position; myChildren.insert( qMin( pos, (int)myChildren.count() ), obj ); obj->setParent( this ); - signal()->emitInserted( obj, this ); + if(pos == 0) + signal()->emitInserted( obj, this ,0); + else + signal()->emitInserted( obj, this ,myChildren.at(pos-1)); } /*! @@ -289,6 +293,7 @@ void SUIT_DataObject::insertChild( SUIT_DataObject* obj, int position ) */ void SUIT_DataObject::removeChild( SUIT_DataObject* obj, const bool del ) { + //std::cerr << "removeChild " << del << std::endl; if ( !obj ) return; @@ -843,14 +848,19 @@ void SUIT_DataObject::Signal::emitDestroyed( SUIT_DataObject* object ) } } +void SUIT_DataObject::Signal::emitUpdated( SUIT_DataObject* object ) +{ + emit( updated( object) ); +} + /*! \brief Emit signal about data object adding to the parent data object. \param object data object being added \param parent parent data object */ -void SUIT_DataObject::Signal::emitInserted( SUIT_DataObject* object, SUIT_DataObject* parent ) +void SUIT_DataObject::Signal::emitInserted( SUIT_DataObject* object, SUIT_DataObject* parent,SUIT_DataObject* after ) { - emit( inserted( object, parent ) ); + emit( inserted( object, parent ,after) ); } /*! @@ -875,6 +885,11 @@ void SUIT_DataObject::Signal::deleteLater( SUIT_DataObject* object ) } } +void SUIT_DataObject::updateItem() +{ + signal()->emitUpdated(this); +} + /*! \brief Updates necessary internal fields of data object */ diff --git a/src/SUIT/SUIT_DataObject.h b/src/SUIT/SUIT_DataObject.h index 796620248..7066b8686 100755 --- a/src/SUIT/SUIT_DataObject.h +++ b/src/SUIT/SUIT_DataObject.h @@ -119,6 +119,7 @@ public: virtual bool isOpen() const; virtual void setOpen( const bool ); + virtual void updateItem(); virtual void update(); virtual bool customSorting( const int = NameId ) const; virtual bool compare( const QVariant&, const QVariant&, const int = NameId ) const; @@ -158,7 +159,8 @@ public: private: void emitCreated( SUIT_DataObject* ); void emitDestroyed( SUIT_DataObject* ); - void emitInserted( SUIT_DataObject*, SUIT_DataObject* ); + void emitInserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ); + void emitUpdated( SUIT_DataObject*); void emitRemoved( SUIT_DataObject*, SUIT_DataObject* ); void deleteLater( SUIT_DataObject* ); @@ -166,7 +168,8 @@ private: signals: void created( SUIT_DataObject* ); void destroyed( SUIT_DataObject* ); - void inserted( SUIT_DataObject*, SUIT_DataObject* ); + void updated( SUIT_DataObject* ); + void inserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ); void removed( SUIT_DataObject*, SUIT_DataObject* ); friend class SUIT_DataObject; diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx index a3110feea..0a46c9073 100755 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -23,6 +23,7 @@ #include "SUIT_TreeModel.h" #include "SUIT_TreeSync.h" #include "SUIT_DataObject.h" +#include #include #include @@ -465,10 +466,11 @@ SUIT_TreeModel::SUIT_TreeModel( SUIT_DataObject* root, QObject* parent ) SUIT_TreeModel::~SUIT_TreeModel() { if ( autoDeleteTree() ) { - SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ), - this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ), + this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ) ); SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ), this, SLOT( onUpdated( SUIT_DataObject* ) ) ); delete myRoot; } @@ -630,10 +632,11 @@ void SUIT_TreeModel::setRoot( SUIT_DataObject* r ) return; if ( autoDeleteTree() ) { - SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ), - this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ,SUIT_DataObject*) ), + this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ) ); SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ), this, SLOT( onUpdated( SUIT_DataObject* ) ) ); delete myRoot; } @@ -653,6 +656,7 @@ void SUIT_TreeModel::setRoot( SUIT_DataObject* r ) */ QVariant SUIT_TreeModel::data( const QModelIndex& index, int role ) const { +// std::cerr << "SUIT_TreeModel::data " << role << std::endl; if ( !index.isValid() ) return QVariant(); @@ -1003,17 +1007,19 @@ void SUIT_TreeModel::setAutoUpdate( const bool on ) if ( myAutoUpdate == on ) return; - SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ), - this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ), + this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ) ); SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ), this, SLOT( onUpdated( SUIT_DataObject* ) ) ); myAutoUpdate = on; if ( myAutoUpdate ) { - SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ), - this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ), + this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ,SUIT_DataObject*) ) ); SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::connect( SIGNAL( updated( SUIT_DataObject* ) ), this, SLOT( onUpdated( SUIT_DataObject* ) ) ); updateTree(); } @@ -1102,15 +1108,17 @@ void SUIT_TreeModel::updateTree( SUIT_DataObject* obj ) */ void SUIT_TreeModel::initialize() { - SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ), - this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ,SUIT_DataObject*) ), + this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ) ); SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( updated( SUIT_DataObject* ) ), this, SLOT( onUpdated( SUIT_DataObject* ) ) ); if ( autoUpdate() ) { - SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ), - this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ), + this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject* ) ) ); SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::connect( SIGNAL( updated( SUIT_DataObject* ) ), this, SLOT( onUpdated( SUIT_DataObject* ) ) ); } myItems.clear(); // ????? is it really necessary @@ -1184,7 +1192,7 @@ SUIT_TreeModel::TreeItem* SUIT_TreeModel::createItem( SUIT_DataObject* obj, SUIT_TreeModel::TreeItem* parent, SUIT_TreeModel::TreeItem* after ) { - std::cerr << " SUIT_TreeModel::createItem " << std::endl; + //std::cerr << " SUIT_TreeModel::createItem " << pthread_self() << std::endl; if ( !obj ) return 0; @@ -1203,6 +1211,13 @@ SUIT_TreeModel::TreeItem* SUIT_TreeModel::createItem( SUIT_DataObject* obj, return myItems[ obj ]; } +void SUIT_TreeModel::createItem( SUIT_DataObject* obj, SUIT_DataObject* parent, SUIT_DataObject* after ) +{ + if ( !treeItem(parent)) + return; + createItem(obj,treeItem(parent),treeItem(after)); +} + /*! \brief Update tree item. \param item tree item to be updated @@ -1210,7 +1225,7 @@ SUIT_TreeModel::TreeItem* SUIT_TreeModel::createItem( SUIT_DataObject* obj, void SUIT_TreeModel::updateItem( SUIT_TreeModel::TreeItem* item ) { - std::cerr << " SUIT_TreeModel::updateItem " << std::endl; + //std::cerr << " SUIT_TreeModel::updateItem " << std::endl; if ( !item ) return; @@ -1230,7 +1245,7 @@ void SUIT_TreeModel::updateItem( SUIT_TreeModel::TreeItem* item ) */ void SUIT_TreeModel::updateItem( SUIT_DataObject* obj) { - std::cerr << " SUIT_TreeModel::updateItem from SuitObj " << std::endl; + //std::cerr << " SUIT_TreeModel::updateItem from SuitObj " << std::endl; if ( !treeItem(obj)) return; @@ -1247,7 +1262,7 @@ void SUIT_TreeModel::updateItem( SUIT_DataObject* obj) */ void SUIT_TreeModel::removeItem( SUIT_TreeModel::TreeItem* item ) { - std::cerr << " SUIT_TreeModel::removeItem " << std::endl; + //std::cerr << " SUIT_TreeModel::removeItem " << std::endl; if ( !item ) return; @@ -1278,15 +1293,25 @@ void SUIT_TreeModel::removeItem( SUIT_TreeModel::TreeItem* item ) endRemoveRows(); } +void SUIT_TreeModel::onUpdated( SUIT_DataObject* object) +{ + updateItem(object); +} + /*! \brief Called when the data object is inserted to the tree. \param object data object being inserted \param parent parent data object */ -void SUIT_TreeModel::onInserted( SUIT_DataObject* /*object*/, SUIT_DataObject* parent ) +void SUIT_TreeModel::onInserted( SUIT_DataObject* object, SUIT_DataObject* parent,SUIT_DataObject* after ) { + //std::cerr << "SUIT_TreeModel::onInserted" << std::endl; + createItem(object,parent,after); + emit modelUpdated(); + /* if ( autoUpdate() ) updateTree( parent ); + */ } /*! @@ -1294,10 +1319,15 @@ void SUIT_TreeModel::onInserted( SUIT_DataObject* /*object*/, SUIT_DataObject* p \param object data object being removed \param parent parent data object */ -void SUIT_TreeModel::onRemoved( SUIT_DataObject* /*object*/, SUIT_DataObject* parent ) +void SUIT_TreeModel::onRemoved( SUIT_DataObject* object, SUIT_DataObject* parent ) { + //std::cerr << "onRemoved" << std::endl; + removeItem( treeItem(object) ); + emit modelUpdated(); + /* if ( autoUpdate() ) updateTree( parent ); + */ } /*! @@ -1481,7 +1511,7 @@ QAbstractItemDelegate* SUIT_ProxyModel::delegate() const #include void SUIT_ProxyModel::updateTree( const QModelIndex& index ) { - std::cerr << "updateTree with QModelIndex from SUIT_ProxyModel" << std::endl; + //std::cerr << "updateTree with QModelIndex from SUIT_ProxyModel" << std::endl; if ( treeModel() ) treeModel()->updateTree( mapToSource( index ) ); } @@ -1498,14 +1528,21 @@ void SUIT_ProxyModel::updateTree( const QModelIndex& index ) */ void SUIT_ProxyModel::updateTree( SUIT_DataObject* obj ) { - std::cerr << "updateTree with SUIT_DataObj from SUIT_ProxyModel" << std::endl; + //std::cerr << "updateTree with SUIT_DataObj from SUIT_ProxyModel" << std::endl; if ( treeModel() ) treeModel()->updateTree( obj ); } +void SUIT_ProxyModel::createItem( SUIT_DataObject* obj ,SUIT_DataObject* parent, SUIT_DataObject* after) +{ + //std::cerr << "createItem with SUIT_DataObj from SUIT_ProxyModel" << std::endl; + if ( treeModel() ) + treeModel()->createItem( obj , parent, after); +} + void SUIT_ProxyModel::updateItem( SUIT_DataObject* obj ) { - std::cerr << "updateItem with SUIT_DataObj from SUIT_ProxyModel" << std::endl; + //std::cerr << "updateItem with SUIT_DataObj from SUIT_ProxyModel" << std::endl; if ( treeModel() ) treeModel()->updateItem( obj ); } diff --git a/src/SUIT/SUIT_TreeModel.h b/src/SUIT/SUIT_TreeModel.h index 967b83a6f..31c424351 100755 --- a/src/SUIT/SUIT_TreeModel.h +++ b/src/SUIT/SUIT_TreeModel.h @@ -64,6 +64,7 @@ public: virtual void updateTree( const QModelIndex& ) = 0; virtual void updateTree( SUIT_DataObject* = 0 ) = 0; virtual void updateItem( SUIT_DataObject* ) = 0; + virtual void createItem( SUIT_DataObject*,SUIT_DataObject*,SUIT_DataObject* ) = 0; virtual void registerColumn( const int group_id, const QString& name, const int custom_id ) = 0; virtual void unregisterColumn( const int group_id, const QString& name ) = 0; @@ -148,6 +149,7 @@ public slots: virtual void updateTree( const QModelIndex& ); virtual void updateTree( SUIT_DataObject* = 0 ); virtual void updateItem( SUIT_DataObject* ); + virtual void createItem( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject*); signals: void modelUpdated(); @@ -165,7 +167,8 @@ private: void removeItem( TreeItem* ); private slots: - void onInserted( SUIT_DataObject*, SUIT_DataObject* ); + void onUpdated( SUIT_DataObject*); + void onInserted( SUIT_DataObject*, SUIT_DataObject* ,SUIT_DataObject*); void onRemoved( SUIT_DataObject*, SUIT_DataObject* ); private: @@ -228,6 +231,7 @@ public slots: virtual void updateTree( const QModelIndex& ); virtual void updateTree( SUIT_DataObject* = 0 ); virtual void updateItem( SUIT_DataObject* ); + virtual void createItem( SUIT_DataObject*, SUIT_DataObject*,SUIT_DataObject*); void setSortingEnabled( bool ); signals: diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 3721f758c..8ffd6a93b 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -1244,8 +1244,10 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QMenu* thePop 3. update object browser if it exists */ void SalomeApp_Application::updateObjectBrowser( const bool updateModels ) { - MESSAGE("UpdateObjBrowser"); + //MESSAGE("UpdateObjBrowser"); return; + + // update "non-existing" (not loaded yet) data models SalomeApp_Study* study = dynamic_cast(activeStudy()); if ( study ) diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 1a2f2a82d..a72b72cde 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -160,11 +160,12 @@ QString SalomeApp_DataObject::text( const int id ) const */ QPixmap SalomeApp_DataObject::icon( const int id ) const { + //std::cerr << "SalomeApp_DataObject::icon " << pthread_self() << std::endl; // we display icon only for the first (NameId ) column if ( id == NameId ) { _PTR(GenericAttribute) anAttr; if ( myObject && myObject->FindAttribute( anAttr, "AttributePixMap" ) ){ - MESSAGE("SalomeApp_DataObject::icon : found attributePixmap") + // MESSAGE("SalomeApp_DataObject::icon : found attributePixmap") _PTR(AttributePixMap) aPixAttr ( anAttr ); if ( aPixAttr->HasPixMap() ) { QString componentType = componentDataType(); @@ -177,11 +178,11 @@ QPixmap SalomeApp_DataObject::icon( const int id ) const } QString pixmapName = QObject::tr( pixmapID.toLatin1().constData() ); LightApp_RootObject* aRoot = dynamic_cast( root() ); - MESSAGE("SalomeApp_DataObject::icon : after dynamic cast") + //MESSAGE("SalomeApp_DataObject::icon : after dynamic cast") if ( aRoot && aRoot->study() ) { SUIT_ResourceMgr* mgr = aRoot->study()->application()->resourceMgr(); - MESSAGE("SalomeApp_DataObject::icon : Call to mgr mgr == " << mgr ); - MESSAGE("SalomeApp_DataObject::icon : Call to mgr loadPixmap ( " << componentType.toStdString() << " , " << pixmapName.toStdString() << " )"); + //MESSAGE("SalomeApp_DataObject::icon : Call to mgr mgr == " << mgr ); + //MESSAGE("SalomeApp_DataObject::icon : Call to mgr loadPixmap ( " << componentType.toStdString() << " , " << pixmapName.toStdString() << " )"); return mgr->loadPixmap( componentType, pixmapName, false ); } } diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 8df6c633f..ada147aa1 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -45,6 +45,15 @@ #include #include CORBA_SERVER_HEADER(SALOME_Exception) +#include +static long tt0; +static long tcount=0; +static long cumul; +#define START_TIMING timeval tv; 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; } + using namespace std; @@ -60,9 +69,11 @@ class Observer_i : public virtual POA_SALOME::Observer virtual void notifyObserver(const char* theID, const char* event) { - MESSAGE("I'm notified of " << event << " of ID = " << theID); + START_TIMING; + + //MESSAGE("I'm notified of " << event << " of ID = " << theID); _PTR(SObject) obj = myStudyDS->FindObjectID( theID ); - MESSAGE("Checking the ID from the sObj : " << obj->GetID()); + //MESSAGE("Checking the ID from the sObj : " << obj->GetID()); std::string entry_str = theID; int last2Pnt_pos = entry_str.rfind(":"); @@ -70,90 +81,97 @@ class Observer_i : public virtual POA_SALOME::Observer std::string pos_in_parent=entry_str.substr(last2Pnt_pos+1); - MESSAGE("Parent id " << parent_id << " with position " << pos_in_parent); + //MESSAGE("Parent id " << parent_id << " with position " << pos_in_parent); _PTR(SObject) obj_parent = myStudyDS->FindObjectID( parent_id ); - MESSAGE("Checking the ID from the sObj_parent : " << obj_parent->GetID()); + //MESSAGE("Checking the ID from the sObj_parent : " << obj_parent->GetID()); SUIT_DataObject* suit_obj; if (std::string(event) == "ADD") { - MESSAGE("ADDING"); + //MESSAGE("ADDING"); _PTR(SComponent) aSComp(obj); - if( aSComp ){ - MESSAGE("This is a module"); - suit_obj=new SalomeApp_ModuleObject(aSComp,0); + if( aSComp ) + { + //MESSAGE("This is a module"); + suit_obj=new SalomeApp_ModuleObject(aSComp,0); } - else{ - MESSAGE("This is not a module "); - suit_obj=new SalomeApp_DataObject(obj,0); + else + { + //MESSAGE("This is not a module "); + suit_obj=new SalomeApp_DataObject(obj,0); } - if (entry2SuitObject.count(parent_id)>0){ - SUIT_DataObject* father=entry2SuitObject[parent_id]; - SUIT_DataObject* after; - std::string after_id; - std::stringstream ss; - for (int i=atoi(pos_in_parent.c_str());i>0;i--){ - ss << parent_id << ":" << i ; - after_id = ss.str(); - ss.str(""); - if (entry2SuitObject.count(after_id)>0){ - after=entry2SuitObject[after_id]; - MESSAGE("after_id " << after_id); - break; - } - } - int pos = after ? father->childPos( after ) : 0; - father->insertChild(suit_obj,pos+1); - } - else{ - MESSAGE("This should be for a module"); - myStudy->root()->appendChild(suit_obj); - } - entry2SuitObject[theID]=suit_obj; + if (entry2SuitObject.count(parent_id)>0) + { + SUIT_DataObject* father=entry2SuitObject[parent_id]; + SUIT_DataObject* after=0; + std::string after_id; + std::stringstream ss; + for (int i=atoi(pos_in_parent.c_str());i>0;i--) + { + ss << parent_id << ":" << i ; + after_id = ss.str(); + ss.str(""); + if (entry2SuitObject.count(after_id)>0) + { + after=entry2SuitObject[after_id]; + //MESSAGE("after_id " << after_id); + break; + } + } + int pos = after ? father->childPos( after ) : 0; + father->insertChild(suit_obj,pos+1); + } + else + { + //MESSAGE("This should be for a module"); + SUIT_DataObject* father=myStudy->root(); + father->appendChild(suit_obj); + } + entry2SuitObject[theID]=suit_obj; } - else if (std::string(event) == "REMOVE"){ - MESSAGE("REMOVING"); - - if (entry2SuitObject.count(theID)>0){ - suit_obj= entry2SuitObject[theID]; - if (entry2SuitObject.count(parent_id)>0){ - SUIT_DataObject* father=entry2SuitObject[parent_id]; - father->removeChild(suit_obj); - } - else{ - MESSAGE("This should be for a module"); - myStudy->root()->removeChild(suit_obj); - } - entry2SuitObject.erase(theID); - } - else{ - MESSAGE("Want to remove an unknown object"); - } + else if (std::string(event) == "REMOVE") + { + //MESSAGE("REMOVING"); + + if (entry2SuitObject.count(theID)>0) + { + suit_obj= entry2SuitObject[theID]; + if (entry2SuitObject.count(parent_id)>0) + { + SUIT_DataObject* father=entry2SuitObject[parent_id]; + father->removeChild(suit_obj); + } + else + { + //MESSAGE("This should be for a module"); + myStudy->root()->removeChild(suit_obj); + } + entry2SuitObject.erase(theID); + } + else + { + MESSAGE("Want to remove an unknown object" << theID); + } } - else if (std::string(event) == "MODIFY"){ - MESSAGE("MODIFYING"); - if (entry2SuitObject.count(theID)>0){ - suit_obj= entry2SuitObject[theID]; - LightApp_Application* myApp=dynamic_cast(myStudy->application()); - if (myApp){ - SUIT_ProxyModel* myModel=dynamic_cast(myApp->objectBrowser()->model()); - if (myModel){ - MESSAGE("Call to SUIT_ProxyModel::myModel->updateItem"); - myModel->updateItem(suit_obj); - } - } - } - else{ - MESSAGE("Want to modify an unknown object"); - } + else if (std::string(event) == "MODIFY") + { + //MESSAGE("MODIFYING"); + if (entry2SuitObject.count(theID)>0) + { + suit_obj= entry2SuitObject[theID]; + suit_obj->updateItem(); + } + else + { + MESSAGE("Want to modify an unknown object" << theID); + } } + END_TIMING(200); } - - private: _PTR(Study) myStudyDS;