]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
CCAR: remove second synchronize between DataObject and TreeItem :
authorcaremoli <caremoli>
Thu, 17 Jun 2010 17:27:00 +0000 (17:27 +0000)
committercaremoli <caremoli>
Thu, 17 Jun 2010 17:27:00 +0000 (17:27 +0000)
insert, remove, update directly the item

12 files changed:
Makefile.am
adm_local/unix/config_files/check_vtk.m4
src/LightApp/Makefile.am
src/SALOME_SWIG/SALOMEGUI_Swig.cxx
src/SUIT/SUIT_DataBrowser.cxx
src/SUIT/SUIT_DataObject.cxx
src/SUIT/SUIT_DataObject.h
src/SUIT/SUIT_TreeModel.cxx
src/SUIT/SUIT_TreeModel.h
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_DataObject.cxx
src/SalomeApp/SalomeApp_Study.cxx

index 78e039f5960fe90eaa084da760b171467f34109f..83bcd4b2e88a54e1369dbd5988f49a390e61af73 100644 (file)
@@ -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
index 219e549ac3b4d473d4940f04a45cec9f27e62ceb..1da864219169067ac21330d43ca44ab299de53c4 100644 (file)
@@ -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"
 
index 7f682eec1dda2a739dd244146a500f1be4b34e74..c1d8006d2b7f3b595ed729f3367f3729d87c6ee7 100755 (executable)
@@ -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
index 2a33e342f2f7291e59f78009cd3586a78dc980ca..8a6b27c99bcb5e6b726b1f94c52a3dc43f924b70 100644 (file)
 #include <SALOME_InteractiveObject.hxx>
 #include <SALOME_ListIteratorOfListIO.hxx>
 
+#include <sys/time.h>
+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
index c88808ba3706781959551c13b15642f25ada40ad..3a974b4b313ec4e37253183f618738fa1b432749 100644 (file)
@@ -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<SUIT_ProxyModel*>( model() );
   if ( m ) {
     m->updateTree( obj );
index 96f91e7d7ade73f71e8cb8ee7c5786b90c31976d..0e86e46ac0aee15a12b01b407927590d8477246f 100755 (executable)
@@ -26,6 +26,7 @@
 #include "SUIT_DataObject.h"
 #include "SUIT_DataObjectKey.h"
 #include <cstdio>
+#include <iostream>
 
 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
 */
index 7966202486e6c90c067788bb6debc29a3e8e40be..7066b8686e160281e5fabbb1b72d593fdbd7164a 100755 (executable)
@@ -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;
index a3110feea74d3c63724274d5b4720ef25f1f3124..0a46c90730cb8f7dbd5fa4504482bc3119f8a3fc 100755 (executable)
@@ -23,6 +23,7 @@
 #include "SUIT_TreeModel.h"
 #include "SUIT_TreeSync.h"
 #include "SUIT_DataObject.h"
+#include <iostream>
 
 #include <QApplication>
 #include <QHash>
@@ -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 <iostream>
 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 );
 }
index 967b83a6f295cbccfabb60275c80e903e5f1e7fa..31c42435178f6283691d9ee19888f8b8f1857ea2 100755 (executable)
@@ -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:
index 3721f758c49c0f61ae50943afbbfaa5a2f6c331f..8ffd6a93b6562111dce3ec3240e1baaee319e0fc 100644 (file)
@@ -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<SalomeApp_Study*>(activeStudy());
   if ( study )
index 1a2f2a82ddf2383097459b0f8b0a62c93a9b4184..a72b72cdec7b1da5e50af980082a34955791b3f2 100644 (file)
@@ -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<LightApp_RootObject*>( 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 ); 
         }
       }
index 8df6c633f87116d834f9437ad2b5df4b4db669e2..ada147aa1ea45716275c5a7fb18341249120349b 100644 (file)
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOME_Exception)
 
+#include <sys/time.h>
+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<LightApp_Application*>(myStudy->application());
-         if (myApp){
-           SUIT_ProxyModel* myModel=dynamic_cast<SUIT_ProxyModel*>(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;