From b86d75c21e63c7060d25686309c763ee05a16489 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 17 Oct 2007 12:15:47 +0000 Subject: [PATCH] NPAL17269: Performance pb. when creating a group with GUI. --- src/LightApp/LightApp_OCCSelector.h | 2 +- src/LightApp/LightApp_SelectionMgr.cxx | 46 +++++++++++++++++--------- src/LightApp/LightApp_SelectionMgr.h | 3 +- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/LightApp/LightApp_OCCSelector.h b/src/LightApp/LightApp_OCCSelector.h index f0da3b251..d4a159098 100644 --- a/src/LightApp/LightApp_OCCSelector.h +++ b/src/LightApp/LightApp_OCCSelector.h @@ -52,7 +52,7 @@ protected: virtual void getSelection( SUIT_DataOwnerPtrList& ) const; virtual void setSelection( const SUIT_DataOwnerPtrList& ); - QString entry( const Handle_AIS_InteractiveObject& ) const; + inline QString entry( const Handle_AIS_InteractiveObject& ) const; SUIT_DataOwnerPtrList mySelectedExternals; diff --git a/src/LightApp/LightApp_SelectionMgr.cxx b/src/LightApp/LightApp_SelectionMgr.cxx index ca18b5759..1c9e38b86 100644 --- a/src/LightApp/LightApp_SelectionMgr.cxx +++ b/src/LightApp/LightApp_SelectionMgr.cxx @@ -212,23 +212,26 @@ void LightApp_SelectionMgr::GetIndexes( const QString& theEntry, TColStd_Indexed /*! Add or remove interactive objects from selection manager. */ -bool LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, - const TColStd_MapOfInteger& theIndexes, - bool modeShift) +//bool LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, +void LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, + const TColStd_MapOfInteger& theIndexes, + bool modeShift) { SUIT_DataOwnerPtrList remainsOwners; - + SUIT_DataOwnerPtrList aList; selected( aList ); + QString ioEntry (IObject->getEntry()); + if ( !modeShift ) { for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr ) { const LightApp_DataOwner* owner = dynamic_cast( (*itr).operator->() ); - if ( owner ) + if ( owner ) { - if ( owner->entry() != QString(IObject->getEntry()) ) - { + if ( owner->entry() != ioEntry ) + { const LightApp_DataSubOwner* subOwner = dynamic_cast( owner ); if ( subOwner ) remainsOwners.append( new LightApp_DataSubOwner( subOwner->entry(), subOwner->index() ) ); @@ -244,17 +247,17 @@ bool LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObj TColStd_MapIteratorOfMapOfInteger It; It.Initialize(theIndexes); for(;It.More();It.Next()) - remainsOwners.append( new LightApp_DataSubOwner( QString(IObject->getEntry()), It.Key() ) ); - + remainsOwners.append( new LightApp_DataSubOwner( ioEntry, It.Key() ) ); + bool append = false; setSelected( remainsOwners, append ); emit currentSelectionChanged(); - TColStd_IndexedMapOfInteger anIndexes; - GetIndexes( IObject, anIndexes ); - return !anIndexes.IsEmpty(); - + // Bug 17269: To avoid calling of selected(aList) + //TColStd_IndexedMapOfInteger anIndexes; + //GetIndexes( IObject, anIndexes ); + //return !anIndexes.IsEmpty(); } /*! @@ -316,14 +319,25 @@ void LightApp_SelectionMgr::selectedSubOwners( MapEntryOfMapOfInteger& theMap ) for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr ) { - const LightApp_DataSubOwner* subOwner = dynamic_cast( (*itr).operator->() ); + const LightApp_DataSubOwner* subOwner = + dynamic_cast( (*itr).operator->() ); if ( subOwner ) { if ( !theMap.contains( subOwner->entry() ) ) { anIndexes.Clear(); - GetIndexes( subOwner->entry(), anIndexes ); - theMap.insert( subOwner->entry(), anIndexes ); + //Bug 17269: GetIndexes( subOwner->entry(), anIndexes ); + //Bug 17269: To avoid multiple calling of selected(aList) + for ( SUIT_DataOwnerPtrList::const_iterator itr2 = itr; itr2 != aList.end(); ++itr2 ) + { + const LightApp_DataSubOwner* subOwner2 = + dynamic_cast( (*itr2).operator->() ); + if ( subOwner2 ) + if ( subOwner2->entry() == subOwner->entry() ) + anIndexes.Add( subOwner2->index() ); + } + // + theMap.insert( subOwner->entry(), anIndexes ); } } } diff --git a/src/LightApp/LightApp_SelectionMgr.h b/src/LightApp/LightApp_SelectionMgr.h index be758e079..d865cac15 100644 --- a/src/LightApp/LightApp_SelectionMgr.h +++ b/src/LightApp/LightApp_SelectionMgr.h @@ -62,7 +62,8 @@ public: void GetIndexes( const QString& theEntry, TColStd_IndexedMapOfInteger& theIndex ); - bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, + //bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, + void AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, const TColStd_MapOfInteger& theIndices, bool modeShift ); -- 2.39.2