From: caremoli Date: Thu, 1 Jul 2010 08:25:34 +0000 (+0000) Subject: CCAR: various optimisations : object browser and display X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6568c4419f0b12bbf3b85d41b9a18bd76f149766;p=modules%2Fgui.git CCAR: various optimisations : object browser and display --- diff --git a/doc/salome/gui/doxyfile.in b/doc/salome/gui/doxyfile.in index 84772c776..4d4cd2fda 100755 --- a/doc/salome/gui/doxyfile.in +++ b/doc/salome/gui/doxyfile.in @@ -62,4 +62,9 @@ GENERATE_LATEX = NO #--------------------------------------------------------------------------- #RTF related options #--------------------------------------------------------------------------- -GENERATE_RTF = NO \ No newline at end of file +GENERATE_RTF = NO + +#--------------------------------------------------------------------------- +#Search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/doc/salome/gui/images/pref15.png b/doc/salome/gui/images/pref15.png index 9f1195e5c..f90b58532 100755 Binary files a/doc/salome/gui/images/pref15.png and b/doc/salome/gui/images/pref15.png differ diff --git a/doc/salome/gui/input/geometry_preferences.doc b/doc/salome/gui/input/geometry_preferences.doc index 81161225c..e0db1a1f9 100644 --- a/doc/salome/gui/input/geometry_preferences.doc +++ b/doc/salome/gui/input/geometry_preferences.doc @@ -63,4 +63,15 @@ points (cross, asterisk, etc.). + + */ diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 2de22f06c..1c2be69d3 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1211,10 +1211,8 @@ PyConsole_Console* LightApp_Application::pythonConsole() Updates object browser and maybe data models \param updateModels - if it is true, then data models are updated */ -#include "utilities.h" void LightApp_Application::updateObjectBrowser( const bool updateModels ) { - MESSAGE("Update from LightApp_Application"); /* // update existing data models if ( updateModels ) diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index db9af4287..7fa22775f 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -145,11 +145,9 @@ void LightApp_Module::contextMenuPopup( const QString& client, QMenu* menu, QStr /*!Update object browser. * For updating model or whole object browser use update() method can be used. */ -#include "utilities.h" void LightApp_Module::updateObjBrowser( bool theIsUpdateDataModel, SUIT_DataObject* theDataObject ) { - MESSAGE("Update from LightApp_Module"); /* bool upd = getApp()->objectBrowser()->autoUpdate(); getApp()->objectBrowser()->setAutoUpdate( false ); diff --git a/src/Prs/SALOME_Prs.h b/src/Prs/SALOME_Prs.h index 3ce235a4c..e9ca97d72 100755 --- a/src/Prs/SALOME_Prs.h +++ b/src/Prs/SALOME_Prs.h @@ -199,6 +199,8 @@ public: //! \retval Return false. virtual bool isVisible( const Handle_SALOME_InteractiveObject& ){ return false; } virtual void Repaint() {} //!< Null body here. + + virtual void updateViewer(SALOME_Prs* prs){}; }; /*! diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx index 8a6b27c99..55cf9fb0d 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.cxx +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.cxx @@ -173,14 +173,12 @@ 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/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 260bed36e..ba3aa631f 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -61,6 +61,15 @@ #include +#include +static long tcount=0; +static long cumul; +#define START_TIMING long tt0; 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; } + + // in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study. // SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from // SALOMEDS::StudyManager - no linkage with SalomeApp. @@ -321,6 +330,7 @@ void SOCC_Viewer::rename( const Handle(SALOME_InteractiveObject)& obj, */ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) { + //std::cerr << "SOCC_Viewer::Display" << std::endl; // try do downcast object const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); if ( !anOCCPrs || anOCCPrs->IsNull() ) @@ -335,12 +345,14 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) // get context Handle (AIS_InteractiveContext) ic = getAISContext(); + /* // get all displayed objects AIS_ListOfInteractive List; ic->DisplayedObjects( List ); // get objects in the collector AIS_ListOfInteractive ListCollector; ic->ObjectsInCollector( ListCollector ); + */ // get objects to be displayed AIS_ListOfInteractive anAISObjects; @@ -354,6 +366,7 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) { // try to find presentation in the viewer bool bDisplayed = false; + /* AIS_ListIteratorOfListOfInteractive ite( List ); for ( ; ite.More(); ite.Next() ) { @@ -361,6 +374,7 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) // if the object is already displayed - nothing to do more if ( ite.Value() == anAIS ) { +std::cerr << "ais found in displayed objects" << std::endl; // Deactivate object if necessary if ( !anOCCPrs->ToActivate() ) ic->Deactivate( anAIS ); @@ -368,12 +382,33 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) break; } } +*/ + AIS_DisplayStatus status = ic->DisplayStatus(anAIS); + if(status == AIS_DS_Displayed) + { +//std::cerr << "ais found in displayed objects" << std::endl; + // Deactivate object if necessary + if ( !anOCCPrs->ToActivate() ) + ic->Deactivate( anAIS ); + bDisplayed = true; + } if ( bDisplayed ) continue; // then try to find presentation in the collector bDisplayed = false; + if(status == AIS_DS_Erased) + { +//std::cerr << "ais found in collector" << std::endl; + ic->DisplayFromCollector( anAIS, false ); + + // Deactivate object if necessary + if ( !anOCCPrs->ToActivate() ) + ic->Deactivate( anAIS ); + bDisplayed = true; + } + /* ite.Initialize( ListCollector ); for ( ; ite.More(); ite.Next() ) { @@ -381,6 +416,7 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) // if the object is in collector - display it if ( ite.Value() == anAIS ) { +std::cerr << "ais found in collector" << std::endl; ic->DisplayFromCollector( anAIS, false ); // Deactivate object if necessary @@ -402,9 +438,12 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) break; } } + */ if ( bDisplayed ) continue; + //std::cerr << "ais not found in context. Display it" << std::endl; + // if object is not displayed and not found in the collector - display it if ( anAIS->IsKind( STANDARD_TYPE(AIS_Trihedron) ) ) { @@ -414,7 +453,9 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) aTrh->SetSize( aTrh == getTrihedron() ? aNewSize : 0.5 * aNewSize ); } + START_TIMING; ic->Display( anAIS, false ); + END_TIMING(100); // Set visibility flag // Temporarily commented to avoid awful dependecy on SALOMEDS @@ -443,6 +484,7 @@ void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) */ void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) { + //std::cerr << "SOCC_Viewer::Erase " << forced << std::endl; // try do downcast object const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); if ( !anOCCPrs || anOCCPrs->IsNull() ) @@ -510,8 +552,8 @@ void SOCC_Viewer::EraseAll( const bool forced ) ic->DisplayedObjects( aList ); AIS_ListIteratorOfListOfInteractive anIter( aList ); for ( ; anIter.More(); anIter.Next() ) { - if ( isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) || - anIter.Value()->DynamicType() == STANDARD_TYPE( OCCViewer_Trihedron )) + if ( (isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) )|| + (anIter.Value()->DynamicType() == STANDARD_TYPE( OCCViewer_Trihedron )) ) continue; // erase an object @@ -542,12 +584,26 @@ void SOCC_Viewer::EraseAll( const bool forced ) */ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) { + //std::cerr << "SOCC_Viewer::CreatePrs " << entry << std::endl; SOCC_Prs* prs = new SOCC_Prs(); if ( entry ) { // get context Handle(AIS_InteractiveContext) ic = getAISContext(); + if(entry2aisobject.count(entry)>0) + { + //ais object exists + Handle(AIS_InteractiveObject) anAIS = entry2aisobject[entry]; + AIS_DisplayStatus status = ic->DisplayStatus(anAIS); + if((status == AIS_DS_Displayed) || (status == AIS_DS_Erased)) + { + //std::cerr << "ais found in context: add it in prs " << entry << std::endl; + prs->AddObject( anAIS ); + } + } + + /* // get displayed objects AIS_ListOfInteractive List; ic->DisplayedObjects( List ); @@ -563,8 +619,12 @@ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); if ( !anObj.IsNull() && anObj->hasEntry() && strcmp( anObj->getEntry(), entry ) == 0 ) - prs->AddObject( ite.Value() ); + { + std::cerr << "ais found in context: add it in prs " << entry << std::endl; + prs->AddObject( ite.Value() ); + } } +*/ } return prs; } @@ -702,6 +762,40 @@ void SOCC_Viewer::Repaint() getViewer3d()->Update(); } +void SOCC_Viewer::updateViewer(SALOME_Prs* prs) +{ + //std::cerr << "SOCC_Viewer::updateViewer" << std::endl; + // try do downcast object + const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); + if ( !anOCCPrs || anOCCPrs->IsNull() ) + return; + + AIS_ListOfInteractive anAISObjects; + anOCCPrs->GetObjects( anAISObjects ); + + AIS_ListIteratorOfListOfInteractive aIter( anAISObjects ); + for ( ; aIter.More(); aIter.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast( aIter.Value()->GetOwner() ); + if ( !anObj.IsNull() && anObj->hasEntry() ) + { + //std::cerr << "add ais in map entry2aisobject" << anObj->getEntry() << std::endl; + if(entry2aisobject.count(anObj->getEntry())>0) + { + if(entry2aisobject[anObj->getEntry()] == aIter.Value()) + { + //std::cerr << "ais already in map entry2aisobject and the same" << std::endl; + continue; + } + else + { + //std::cerr << "ais already in map entry2aisobject but not the same" << std::endl; + } + } + entry2aisobject[anObj->getEntry()] = aIter.Value(); + } + } +} /*! create SOCC_ViewWindow diff --git a/src/SOCC/SOCC_ViewModel.h b/src/SOCC/SOCC_ViewModel.h index 7a5b10ef4..8bdd29ef9 100755 --- a/src/SOCC/SOCC_ViewModel.h +++ b/src/SOCC/SOCC_ViewModel.h @@ -68,6 +68,9 @@ public: // a utility function, used by SALOME_View_s methods bool getTrihedronSize( double& theNewSize, double& theSize ); + //a map to store AIS objects associated to a SALOME entry + std::map< std::string , Handle(AIS_InteractiveObject) > entry2aisobject; + virtual void updateViewer(SALOME_Prs* prs); }; #ifdef WIN32 diff --git a/src/SUIT/SUIT_DataObject.cxx b/src/SUIT/SUIT_DataObject.cxx index 89d899a60..db8e980c5 100755 --- a/src/SUIT/SUIT_DataObject.cxx +++ b/src/SUIT/SUIT_DataObject.cxx @@ -283,7 +283,6 @@ void SUIT_DataObject::appendChild( SUIT_DataObject* obj ) */ void SUIT_DataObject::insertChild( SUIT_DataObject* obj, int position ) { - START_TIMING; if ( !obj || myChildren.contains( obj ) ) return; @@ -296,7 +295,6 @@ void SUIT_DataObject::insertChild( SUIT_DataObject* obj, int position ) else signal()->emitInserted( obj, this ,myChildren.at(pos-1)); */ - END_TIMING(100); } /*! diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx index f1222c2a7..69b9cfa95 100755 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -1311,7 +1311,7 @@ void SUIT_TreeModel::removeItem( SUIT_TreeModel::TreeItem* item ) QModelIndex parentIdx = index( parentObj, 0 ); int row = item->position(); - beginRemoveRows( parentIdx, row, row ); + //beginRemoveRows( parentIdx, row, row ); myItems.remove( obj ); if ( obj == root() ) @@ -1321,7 +1321,7 @@ void SUIT_TreeModel::removeItem( SUIT_TreeModel::TreeItem* item ) delete item; - endRemoveRows(); + //endRemoveRows(); } void SUIT_TreeModel::onUpdated( SUIT_DataObject* object) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 215abb344..8dc5250f3 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -1246,8 +1246,6 @@ 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"); - // update "non-existing" (not loaded yet) data models SalomeApp_Study* study = dynamic_cast(activeStudy()); /* diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 9dcea194a..a1a8f02d9 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -296,7 +296,6 @@ bool SalomeApp_DataModel::create( CAM_Study* theStudy ) */ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) { - std::cerr << "in update" << std::endl; SalomeApp_Study* aSStudy = dynamic_cast(study); LightApp_RootObject* studyRoot = 0; _PTR(SComponent) sobj; @@ -333,8 +332,6 @@ void SalomeApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study ) */ SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SComponent )& sobj, SalomeApp_Study* study ) { - - std::cerr << "in synchronize" << std::endl; if( !study || !study->root() || !sobj ) return 0; @@ -364,7 +361,6 @@ SUIT_DataObject* SalomeApp_DataModel::synchronize( const _PTR( SComponent )& sob */ void SalomeApp_DataModel::updateTree( const _PTR( SComponent )& comp, SalomeApp_Study* study ) { - std::cerr << "in updatetree" << std::endl; SalomeApp_ModuleObject* aNewRoot = dynamic_cast( synchronize( comp, study ) ); if( aNewRoot ) { diff --git a/src/SalomeApp/SalomeApp_DataObject.cxx b/src/SalomeApp/SalomeApp_DataObject.cxx index 0d0a5048a..987af4c46 100644 --- a/src/SalomeApp/SalomeApp_DataObject.cxx +++ b/src/SalomeApp/SalomeApp_DataObject.cxx @@ -176,7 +176,6 @@ QPixmap SalomeApp_DataObject::icon( const int id ) const if ( id == NameId ) { _PTR(GenericAttribute) anAttr; if ( myObject && myObject->FindAttribute( anAttr, "AttributePixMap" ) ){ - // MESSAGE("SalomeApp_DataObject::icon : found attributePixmap") _PTR(AttributePixMap) aPixAttr ( anAttr ); if ( aPixAttr->HasPixMap() ) { QString componentType = componentDataType(); @@ -189,11 +188,8 @@ 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") 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() << " )"); return mgr->loadPixmap( componentType, pixmapName, false ); } } diff --git a/src/SalomeApp/SalomeApp_Study.h b/src/SalomeApp/SalomeApp_Study.h index 47e941685..ec9ed0a60 100644 --- a/src/SalomeApp/SalomeApp_Study.h +++ b/src/SalomeApp/SalomeApp_Study.h @@ -35,7 +35,7 @@ #include #include CORBA_SERVER_HEADER(SALOME_Observer) -class SALOMEAPP_EXPORT SalomeApp_Study : public LightApp_Study +class SALOMEAPP_EXPORT SalomeApp_Study : public LightApp_Study { Q_OBJECT