From: kgv Date: Sun, 10 Sep 2017 18:24:56 +0000 (+0300) Subject: 0028987: Visualization, SelectMgr_SelectableObject - move out iterator from object X-Git-Tag: V7_3_0_beta~249 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=b5cce1ab238944d3c3181cb99671310c1a06f1b4 0028987: Visualization, SelectMgr_SelectableObject - move out iterator from object Added method SelectMgr_SelectableObject::Selections() and depreacted methods Init(), More(), Next() and CurrentSelection(). Added method SelectMgr_Selection::Entities() and depreacted methods Init(), More(), Next() and Sensitivity(). SelectMgr_SelectableObject::myAssemblyOwner has been moved to AIS_MultipleConnectedInteractive. SelectMgr_SelectableObject::Selection() now returns NULL handle for not found selection. SelectMgr_SelectableObject::HasSelection() is no more virtual and just retuns !Selection().IsNull(). SelectMgr_SelectionManager::mySelectors map is now declared using proper key type Handle(SelectMgr_ViewerSelector) instead of Handle(Standard_Transient). --- diff --git a/src/AIS/AIS_ColoredShape.cxx b/src/AIS/AIS_ColoredShape.cxx index f3396308d0..7119e874b3 100644 --- a/src/AIS/AIS_ColoredShape.cxx +++ b/src/AIS/AIS_ColoredShape.cxx @@ -495,9 +495,9 @@ void AIS_ColoredShape::ComputeSelection (const Handle(SelectMgr_Selection)& theS aTypOfSel, aPriority, aDeflection, aDeviationAngle); Handle(SelectMgr_SelectableObject) aThis (this); - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (theSelection->Sensitive()->BaseSensitive()->OwnerId()); + Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelEntIter.Value()->BaseSensitive()->OwnerId()); anOwner->Set (aThis); } diff --git a/src/AIS/AIS_ConnectedInteractive.cxx b/src/AIS/AIS_ConnectedInteractive.cxx index 5f3d4883e0..8958a55655 100644 --- a/src/AIS/AIS_ConnectedInteractive.cxx +++ b/src/AIS/AIS_ConnectedInteractive.cxx @@ -233,9 +233,9 @@ void AIS_ConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selectio myReference->RecomputePrimitives (theMode); } - for (TheRefSel->Init(); TheRefSel->More(); TheRefSel->Next()) + for (NCollection_Vector::Iterator aSelEntIter (TheRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (TheRefSel->Sensitive()->BaseSensitive()); + aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (aSelEntIter.Value()->BaseSensitive()); if (!aSensitive.IsNull()) { // Get the copy of SE3D @@ -260,38 +260,28 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_ Shapes2EntitiesMap; if (!myReference->HasSelection (theMode)) + { myReference->RecomputePrimitives (theMode); - - const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode); + } + const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode); if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full) { myReference->RecomputePrimitives (theMode); } - - Handle(StdSelect_BRepOwner) anOwner; - TopLoc_Location aDummyLoc; - Handle(Select3D_SensitiveEntity) aSE, aNewSE; + // Fill in the map of subshapes and corresponding sensitive entities associated with aMode Shapes2EntitiesMap aShapes2EntitiesMap; - - SensitiveList aSEList; - TopoDS_Shape aSubShape; - - // Fill in the map of subshapes and corresponding - // sensitive entities associated with aMode - for (aRefSel->Init(); aRefSel->More(); aRefSel->Next()) + for (NCollection_Vector::Iterator aSelEntIter (aRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - aSE = Handle(Select3D_SensitiveEntity)::DownCast (aRefSel->Sensitive()->BaseSensitive()); - if(!aSE.IsNull()) + if (Handle(Select3D_SensitiveEntity) aSE = Handle(Select3D_SensitiveEntity)::DownCast (aSelEntIter.Value()->BaseSensitive())) { - anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId()); - if(!anOwner.IsNull()) + if (Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId())) { - aSubShape = anOwner->Shape(); + const TopoDS_Shape& aSubShape = anOwner->Shape(); if(!aShapes2EntitiesMap.IsBound (aSubShape)) { - aShapes2EntitiesMap.Bind (aSubShape, aSEList); + aShapes2EntitiesMap.Bind (aSubShape, SensitiveList()); } aShapes2EntitiesMap (aSubShape).Append (aSE); } @@ -301,20 +291,14 @@ void AIS_ConnectedInteractive::computeSubShapeSelection (const Handle(SelectMgr_ // Fill in selection from aShapes2EntitiesMap for (Shapes2EntitiesMap::Iterator aMapIt (aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next()) { - aSEList = aMapIt.Value(); - anOwner = new StdSelect_BRepOwner (aMapIt.Key(), - this, - aSEList.First()->OwnerId()->Priority(), - Standard_True); + const SensitiveList& aSEList = aMapIt.Value(); + Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner (aMapIt.Key(), this, aSEList.First()->OwnerId()->Priority(), Standard_True); anOwner->SetLocation (Transformation()); - for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next()) { - aSE = aListIt.Value(); - - aNewSE = aSE->GetConnected(); + Handle(Select3D_SensitiveEntity) aSE = aListIt.Value(); + Handle(Select3D_SensitiveEntity) aNewSE = aSE->GetConnected(); aNewSE->Set (anOwner); - theSelection->Add (aNewSE); } } diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index ebde0742e9..12c3077367 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -186,11 +186,11 @@ AIS_InteractiveContext::~AIS_InteractiveContext() Handle(AIS_InteractiveContext) aNullContext; for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) { - Handle(AIS_InteractiveObject) anObj = anObjIter.Key(); + const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key(); anObj->SetContext (aNullContext); - for (anObj->Init(); anObj->More(); anObj->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) { - anObj->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Renew); + aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Renew); } } } @@ -692,15 +692,13 @@ void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdate return; } - Standard_Boolean isFound = Standard_False; - for (mySelection->Init(); mySelection->More(); mySelection->Next()) + for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) { - Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable()); + Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); Display (anObj, Standard_False); - isFound = Standard_True; } - if (isFound && theToUpdateViewer) + if (theToUpdateViewer && !mySelection->Objects().IsEmpty()) { myMainVwr->Update(); } @@ -717,17 +715,12 @@ void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateVi return; } - Standard_Boolean isFound = Standard_False; - mySelection->Init(); - while (mySelection->More()) + Standard_Boolean isFound = Standard_False; + for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Init (mySelection->Objects())) { - Handle(SelectMgr_EntityOwner) anOwner = mySelection->Value(); - Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); - + Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); Erase (anObj, Standard_False); isFound = Standard_True; - - mySelection->Init(); } if (isFound && theToUpdateViewer) @@ -2858,15 +2851,14 @@ void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView, const Standard_Real theMargin, const Standard_Boolean theToUpdate) { - const Handle(AIS_Selection)& aSelection = HasOpenedContext() ? - myLocalContexts(myCurLocalIndex)->Selection() : mySelection; - + const Handle(AIS_Selection)& aSelection = HasOpenedContext() + ? myLocalContexts(myCurLocalIndex)->Selection() + : mySelection; Bnd_Box aBndSelected; - AIS_MapOfObjectOwners anObjectOwnerMap; - for (aSelection->Init(); aSelection->More(); aSelection->Next()) + for (AIS_NListOfEntityOwner::Iterator aSelIter (aSelection->Objects()); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_EntityOwner)& anOwner = aSelection->Value(); + const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value(); Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); if (anObj->IsInfinite()) { diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 1e7ac281e1..2fa619a635 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -1015,10 +1015,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t { Display (theObject, Standard_False); } - if (!theObject->HasSelection (theObject->GlobalSelectionMode())) - { - return; - } + Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner(); if (anOwner.IsNull()) { @@ -1039,9 +1036,9 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t return; } - for (mySelection->Init(); mySelection->More(); mySelection->Next()) + for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_EntityOwner) aSelOwner = mySelection->Value(); + const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value(); if (!myFilters->IsOk (aSelOwner)) { continue; @@ -1139,22 +1136,26 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveOb const Standard_Boolean theToUpdateViewer) { if (theObject.IsNull()) + { return; + } if (HasOpenedContext()) + { return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer); + } - const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode(); - if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode)) + if (!myObjects.IsBound (theObject)) + { return; + } - setContextToObject (theObject); const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner(); - - if (anOwner.IsNull() || !anOwner->HasSelectable()) - return; - - AddOrRemoveSelected (anOwner, theToUpdateViewer); + if (!anOwner.IsNull() + && anOwner->HasSelectable()) + { + AddOrRemoveSelected (anOwner, theToUpdateViewer); + } } //======================================================================= //function : AddOrRemoveSelected @@ -1195,8 +1196,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO AIS_SelectStatus aSelStat = mySelection->Select (theOwner); theOwner->SetSelected (aSelStat == AIS_SS_Added); - const Handle(AIS_InteractiveObject) anObj = - Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); + const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner; Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj); if (theOwner->IsSelected()) @@ -1241,19 +1241,18 @@ Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_Interactiv const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode(); const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes(); - Standard_Boolean isGlobalModeActivated = Standard_False; for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next()) { if (aModeIter.Value() == aGlobalSelMode) { - isGlobalModeActivated = Standard_True; - break; + if (Handle(SelectMgr_EntityOwner) aGlobOwner = theObj->GlobalSelOwner()) + { + return aGlobOwner->IsSelected(); + } + return Standard_False; } } - if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull()) - return Standard_False; - - return theObj->GlobalSelOwner()->IsSelected(); + return Standard_False; } //======================================================================= @@ -1263,12 +1262,11 @@ Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_Interactiv Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const { if (HasOpenedContext()) + { return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner); - - if (theOwner.IsNull()) - return Standard_False; - - return theOwner->IsSelected(); + } + return !theOwner.IsNull() + && theOwner->IsSelected(); } //======================================================================= @@ -1392,37 +1390,44 @@ void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& t const Handle(AIS_InteractiveObject)& theIObj, const Standard_Integer theMode) const { - if ( theIObj.IsNull() ) - return; + if (theIObj.IsNull()) + { + return; + } TColStd_ListOfInteger aModes; - if ( theMode == -1 ) - ActivatedModes( theIObj, aModes ); + if (theMode == -1) + { + ActivatedModes (theIObj, aModes); + } else - aModes.Append( theMode ); + { + aModes.Append (theMode); + } if (theOwners.IsNull()) + { theOwners = new SelectMgr_IndexedMapOfOwner(); + } - TColStd_ListIteratorOfListOfInteger anItr( aModes ); - for (; anItr.More(); anItr.Next() ) + for (TColStd_ListIteratorOfListOfInteger anItr (aModes); anItr.More(); anItr.Next()) { - int aMode = anItr.Value(); - if ( !theIObj->HasSelection( aMode ) ) + const int aMode = anItr.Value(); + const Handle(SelectMgr_Selection)& aSel = theIObj->Selection (aMode); + if (aSel.IsNull()) + { continue; + } - Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode); - - for ( aSel->Init(); aSel->More(); aSel->Next() ) + for (NCollection_Vector::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive(); - if ( aEntity.IsNull() ) - continue; - - Handle(SelectMgr_EntityOwner) aOwner = - Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId()); - if ( !aOwner.IsNull() ) - theOwners->Add( aOwner ); + if (Handle(SelectBasics_SensitiveEntity) aEntity = aSelEntIter.Value()->BaseSensitive()) + { + if (Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId())) + { + theOwners->Add (aOwner); + } + } } } } diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index 1886cb872f..cbe5936fa5 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -202,9 +202,8 @@ Load(const Handle(AIS_InteractiveObject)& anInteractive, { if (myActiveObjects.IsBound (anInteractive)) { - if (anInteractive->HasSelection (ActivationMode)) + if (const Handle(SelectMgr_Selection)& aSel = anInteractive->Selection (ActivationMode)) { - const Handle(SelectMgr_Selection)& aSel = anInteractive->Selection (ActivationMode); if (aSel->GetSelectionState() != SelectMgr_SOS_Activated) { if (!myMainVS->Contains (anInteractive)) @@ -864,24 +863,26 @@ const Handle(AIS_LocalStatus)& AIS_LocalContext::Status(const Handle(AIS_Interac void AIS_LocalContext::LoadContextObjects() { - AIS_ListIteratorOfListOfInteractive It; - if(myLoadDisplayed) { - AIS_ListOfInteractive LL; - myCTX->DisplayedObjects(LL,Standard_True); - Handle(AIS_LocalStatus) Att; - for (It.Initialize(LL);It.More();It.Next()){ - const Handle(AIS_InteractiveObject)& anObj = It.Value(); - Att= new AIS_LocalStatus(); - Att->SetDecomposition((anObj->AcceptShapeDecomposition() && myAcceptStdMode)); - Att->SetTemporary(Standard_False); - Att->SetHilightMode(anObj->HasHilightMode()? anObj->HilightMode(): 0); - for (anObj->Init(); anObj->More(); anObj->Next()) - { - const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection(); - aSel->SetSelectionState (SelectMgr_SOS_Deactivated); - } - myActiveObjects.Bind(anObj,Att); + if (!myLoadDisplayed) + { + return; + } + + AIS_ListOfInteractive LL; + myCTX->DisplayedObjects(LL,Standard_True); + for (AIS_ListIteratorOfListOfInteractive It (LL); It.More(); It.Next()) + { + const Handle(AIS_InteractiveObject)& anObj = It.Value(); + Handle(AIS_LocalStatus) Att = new AIS_LocalStatus(); + Att->SetDecomposition((anObj->AcceptShapeDecomposition() && myAcceptStdMode)); + Att->SetTemporary(Standard_False); + Att->SetHilightMode(anObj->HasHilightMode()? anObj->HilightMode(): 0); + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) + { + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + aSel->SetSelectionState (SelectMgr_SOS_Deactivated); } + myActiveObjects.Bind(anObj,Att); } } diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index dd39b7d70f..d6855909c9 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -804,13 +804,10 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec { // 1. Collect selectable entities SelectMgr_IndexedMapOfOwner aValidOwners; - const TColStd_ListOfInteger& aModes = SelectionModes (theIO); - - TColStd_ListIteratorOfListOfInteger aModeIter (aModes); - for (; aModeIter.More(); aModeIter.Next()) + for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next()) { - int aMode = aModeIter.Value(); + const int aMode = aModeIter.Value(); if (!theIO->HasSelection(aMode)) { continue; @@ -821,24 +818,16 @@ void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObjec continue; } - Handle(SelectMgr_Selection) aSelection = theIO->Selection(aMode); - for (aSelection->Init(); aSelection->More(); aSelection->Next()) + const Handle(SelectMgr_Selection)& aSelection = theIO->Selection (aMode); + for (NCollection_Vector::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive(); - if (anEntity.IsNull()) + if (Handle(SelectBasics_SensitiveEntity) anEntity = aSelEntIter.Value()->BaseSensitive()) { - continue; - } - - Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId()); - - if (anOwner.IsNull()) - { - continue; + if (Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId())) + { + aValidOwners.Add (anOwner); + } } - - aValidOwners.Add(anOwner); } } diff --git a/src/AIS/AIS_MultipleConnectedInteractive.cxx b/src/AIS/AIS_MultipleConnectedInteractive.cxx index bef045834f..bd749ce522 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.cxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.cxx @@ -30,14 +30,13 @@ IMPLEMENT_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObjec //======================================================================= //function : AIS_MultipleConnectedInteractive -//purpose : +//purpose : //======================================================================= AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive() - : AIS_InteractiveObject (PrsMgr_TOP_AllView) +: AIS_InteractiveObject (PrsMgr_TOP_AllView) { myHasOwnPresentations = Standard_False; - myAssemblyOwner = NULL; } //======================================================================= @@ -213,53 +212,27 @@ Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() co void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/, const Standard_Integer theMode) { - if (theMode != 0) + if (theMode == 0) { - for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) - { - Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); - if (aChild.IsNull()) - { - continue; - } - - if (!aChild->HasSelection (theMode)) - { - aChild->RecomputePrimitives (theMode); - } - - Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode); - aChild->ComputeSelection (aSelection, theMode); - } + return; } -} - -//======================================================================= -//function : GlobalSelOwner -//purpose : -//======================================================================= -Handle(SelectMgr_EntityOwner) AIS_MultipleConnectedInteractive::GlobalSelOwner() const -{ - return myAssemblyOwner; -} -//======================================================================= -//function : HasSelection -//purpose : -//======================================================================= -Standard_Boolean AIS_MultipleConnectedInteractive::HasSelection (const Standard_Integer theMode) const -{ for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) { Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); if (aChild.IsNull()) + { continue; + } if (!aChild->HasSelection (theMode)) - return Standard_False; - } + { + aChild->RecomputePrimitives (theMode); + } - return Standard_True; + Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode); + aChild->ComputeSelection (aSelection, theMode); + } } //======================================================================= diff --git a/src/AIS/AIS_MultipleConnectedInteractive.hxx b/src/AIS/AIS_MultipleConnectedInteractive.hxx index 97d060d4d9..fc5f3a676f 100644 --- a/src/AIS/AIS_MultipleConnectedInteractive.hxx +++ b/src/AIS/AIS_MultipleConnectedInteractive.hxx @@ -72,12 +72,11 @@ public: //! may be decomposed into sub-shapes for dynamic selection. Standard_EXPORT virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE; - //! Returns the owner of mode for selection of object as a whole - Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE; + //! Returns common entity owner if the object is an assembly + virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const Standard_OVERRIDE { return myAssemblyOwner; } - //! Returns true if a selection corresponding to the selection mode theMode was computed for all - //! children of multiple connected interactive object. - Standard_EXPORT virtual Standard_Boolean HasSelection (const Standard_Integer theMode) const Standard_OVERRIDE; + //! Returns the owner of mode for selection of object as a whole + virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return myAssemblyOwner; } //! Assigns interactive context. Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& theCtx) Standard_OVERRIDE; @@ -142,6 +141,10 @@ private: //! Computes the selection for whole subtree in scene hierarchy. Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE; +protected: + + Handle(SelectMgr_EntityOwner) myAssemblyOwner; + }; DEFINE_STANDARD_HANDLE(AIS_MultipleConnectedInteractive, AIS_InteractiveObject) diff --git a/src/AIS/AIS_Selection.cxx b/src/AIS/AIS_Selection.cxx index b03e76eb31..1af6833a9a 100644 --- a/src/AIS/AIS_Selection.cxx +++ b/src/AIS/AIS_Selection.cxx @@ -41,6 +41,7 @@ void AIS_Selection::Clear() { myresult.Clear(); myResultMap.Clear(); + myIterator = AIS_NListOfEntityOwner::Iterator(); } //======================================================================= diff --git a/src/IVtkOCC/IVtkOCC_ViewerSelector.cxx b/src/IVtkOCC/IVtkOCC_ViewerSelector.cxx index 76f115910f..94804ac517 100644 --- a/src/IVtkOCC/IVtkOCC_ViewerSelector.cxx +++ b/src/IVtkOCC/IVtkOCC_ViewerSelector.cxx @@ -188,9 +188,9 @@ void IVtkOCC_ViewerSelector::Pick (double** thePoly, //============================================================================ void IVtkOCC_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSelection) { - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - theSelection->Sensitive()->SetActiveForSelection(); + aSelEntIter.Value()->SetActiveForSelection(); } theSelection->SetSelectionState (SelectMgr_SOS_Activated); @@ -205,9 +205,9 @@ void IVtkOCC_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSel //============================================================================ void IVtkOCC_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theSelection) { - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - theSelection->Sensitive()->ResetSelectionActiveStatus(); + aSelEntIter.Value()->ResetSelectionActiveStatus(); } theSelection->SetSelectionState (SelectMgr_SOS_Deactivated); diff --git a/src/PrsMgr/PrsMgr_PresentableObject.hxx b/src/PrsMgr/PrsMgr_PresentableObject.hxx index d89f008039..a45fbb2c91 100644 --- a/src/PrsMgr/PrsMgr_PresentableObject.hxx +++ b/src/PrsMgr/PrsMgr_PresentableObject.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/src/QABugs/QABugs_9.cxx b/src/QABugs/QABugs_9.cxx index 59ee17229f..31afefb9de 100644 --- a/src/QABugs/QABugs_9.cxx +++ b/src/QABugs/QABugs_9.cxx @@ -115,9 +115,11 @@ static Standard_Integer OCC137 (Draw_Interpretor& di, Standard_Integer argc, con if(AISObj->HasSelection(4)) { //Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4); const Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4); - if(!aSelection.IsNull()) { - for(aSelection->Init();aSelection->More();aSelection->Next()) { - Handle(StdSelect_BRepOwner) aO = Handle(StdSelect_BRepOwner)::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId()); + if(!aSelection.IsNull()) + { + for (NCollection_Vector::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) + { + Handle(StdSelect_BRepOwner) aO = Handle(StdSelect_BRepOwner)::DownCast(aSelEntIter.Value()->BaseSensitive()->OwnerId()); aO->SetHilightMode(Draw::Atoi(argv[1])); } } diff --git a/src/SelectMgr/FILES b/src/SelectMgr/FILES index 943b815c84..8c8d19f498 100755 --- a/src/SelectMgr/FILES +++ b/src/SelectMgr/FILES @@ -32,7 +32,6 @@ SelectMgr_SelectingVolumeManager.cxx SelectMgr_SelectingVolumeManager.hxx SelectMgr_Selection.cxx SelectMgr_Selection.hxx -SelectMgr_Selection.lxx SelectMgr_SelectionManager.cxx SelectMgr_SelectionManager.hxx SelectMgr_SensitiveEntity.cxx diff --git a/src/SelectMgr/SelectMgr_SelectableObject.cxx b/src/SelectMgr/SelectMgr_SelectableObject.cxx index 504ca4a64c..dc3126d601 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.cxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.cxx @@ -41,14 +41,11 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectableObject,PrsMgr_PresentableObject) -static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq, - const Handle (SelectMgr_Selection)& theSel) +namespace { - Standard_Integer ifound=0; - for (Standard_Integer i=1;i<=seq.Length()&& ifound==0;i++) - {if(theSel == seq.Value(i)) ifound=i;} - return ifound; -} + Handle(SelectMgr_Selection) THE_NULL_SELECTION; + Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER; +} //================================================== // Function: SelectMgr_SelectableObject @@ -57,8 +54,8 @@ static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq, SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d) : PrsMgr_PresentableObject (aTypeOfPresentation3d), - myAssemblyOwner (NULL), myAutoHilight (Standard_True), + mycurrent (0), myGlobalSelMode (0) { // @@ -70,24 +67,10 @@ SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPrese //================================================== SelectMgr_SelectableObject::~SelectMgr_SelectableObject() { - for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); ++aSelIdx) - { - myselections.Value (aSelIdx)->Clear(); - } -} - -//================================================== -// Function: HasSelection -// Purpose : -//================================================== -Standard_Boolean SelectMgr_SelectableObject::HasSelection (const Standard_Integer theMode) const -{ - for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); ++aSelIdx) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - if (((myselections.Value (aSelIdx))->Mode()) == theMode) - return Standard_True; + aSelIter.Value()->Clear(); } - return Standard_False; } //================================================== @@ -102,10 +85,10 @@ Standard_Boolean SelectMgr_SelectableObject::HasSelection (const Standard_Intege //================================================== void SelectMgr_SelectableObject::RecomputePrimitives() { - for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); aSelIdx++) - { - RecomputePrimitives (myselections.ChangeValue (aSelIdx)->Mode()); - } + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) + { + RecomputePrimitives (aSelIter.Value()->Mode()); + } } //================================================== @@ -120,20 +103,22 @@ void SelectMgr_SelectableObject::RecomputePrimitives() //================================================== void SelectMgr_SelectableObject::RecomputePrimitives (const Standard_Integer theMode) { - Handle(PrsMgr_PresentableObject) aPrsParent (Parent()); - Handle(SelectMgr_SelectableObject) aSelParent = Handle(SelectMgr_SelectableObject)::DownCast (aPrsParent); - - for (Standard_Integer aSelIdx =1; aSelIdx <= myselections.Length(); aSelIdx++ ) + SelectMgr_SelectableObject* aSelParent = dynamic_cast (Parent()); + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - if (myselections.Value (aSelIdx)->Mode() == theMode) + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + if (aSel->Mode() == theMode) { - myselections (aSelIdx)->Clear(); - ComputeSelection (myselections (aSelIdx), theMode); - myselections (aSelIdx)->UpdateStatus (SelectMgr_TOU_Partial); - myselections (aSelIdx)->UpdateBVHStatus (SelectMgr_TBU_Renew); - if (theMode == 0 && ! aSelParent.IsNull() && ! aSelParent->GetAssemblyOwner().IsNull()) + aSel->Clear(); + ComputeSelection (aSel, theMode); + aSel->UpdateStatus (SelectMgr_TOU_Partial); + aSel->UpdateBVHStatus (SelectMgr_TBU_Renew); + if (theMode == 0 && aSelParent != NULL) { - SetAssemblyOwner (aSelParent->GetAssemblyOwner(), theMode); + if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner()) + { + SetAssemblyOwner (anAsmOwner, theMode); + } } return; } @@ -142,9 +127,12 @@ void SelectMgr_SelectableObject::RecomputePrimitives (const Standard_Integer the Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode); ComputeSelection (aNewSel, theMode); - if (theMode == 0 && ! aSelParent.IsNull() && ! aSelParent->GetAssemblyOwner().IsNull()) + if (theMode == 0 && aSelParent != NULL) { - SetAssemblyOwner (aSelParent->GetAssemblyOwner(), theMode); + if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner()) + { + SetAssemblyOwner (anAsmOwner, theMode); + } } aNewSel->UpdateStatus (SelectMgr_TOU_Partial); @@ -157,14 +145,16 @@ void SelectMgr_SelectableObject::RecomputePrimitives (const Standard_Integer the // Function: ClearSelections // Purpose : //================================================== -void SelectMgr_SelectableObject::ClearSelections(const Standard_Boolean update) +void SelectMgr_SelectableObject::ClearSelections (const Standard_Boolean theToUpdate) { - for (Standard_Integer i =1; i<= myselections.Length(); i++ ) { - myselections.Value(i)->Clear(); - myselections.Value (i)->UpdateBVHStatus (SelectMgr_TBU_Remove); - if(update) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) + { + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + aSel->Clear(); + aSel->UpdateBVHStatus (SelectMgr_TBU_Remove); + if (theToUpdate) { - myselections.Value(i)->UpdateStatus(SelectMgr_TOU_Full); + aSel->UpdateStatus (SelectMgr_TOU_Full); } } } @@ -175,79 +165,80 @@ void SelectMgr_SelectableObject::ClearSelections(const Standard_Boolean update) // Purpose : //================================================== -const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject -::Selection(const Standard_Integer aMode) const +const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject::Selection (const Standard_Integer theMode) const { - Standard_Boolean Found = Standard_False; - Standard_Integer Rank=0; - for (Standard_Integer i=1;i<=myselections.Length() && !Found;i++) + if (theMode == -1) + { + return THE_NULL_SELECTION; + } + + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) + { + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + if (aSel->Mode() == theMode) { - if((myselections.Value(i))->Mode()==aMode){ Found = Standard_True; - Rank=i;}} - return myselections.Value(Rank); + return aSel; + } + } + return THE_NULL_SELECTION; } - //================================================== // Function: AddSelection // Purpose : //================================================== -void SelectMgr_SelectableObject -::AddSelection(const Handle(SelectMgr_Selection)& aSel, - const Standard_Integer aMode) +void SelectMgr_SelectableObject::AddSelection (const Handle(SelectMgr_Selection)& theSel, + const Standard_Integer theMode) { - Standard_Boolean isReplaced = Standard_False; - if(aSel->IsEmpty()) + if(theSel->IsEmpty()) { - ComputeSelection(aSel, aMode); - aSel->UpdateStatus(SelectMgr_TOU_Partial); - aSel->UpdateBVHStatus (SelectMgr_TBU_Add); + ComputeSelection(theSel, theMode); + theSel->UpdateStatus(SelectMgr_TOU_Partial); + theSel->UpdateBVHStatus (SelectMgr_TBU_Add); } - if (HasSelection(aMode)) + + Standard_Boolean isReplaced = Standard_False; + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& temp= Selection(aMode); - Standard_Integer I = Search(myselections,temp); - if(I!=0) + if (aSelIter.Value()->Mode() == theMode) { - myselections.Remove(I); isReplaced = Standard_True; + myselections.Remove (aSelIter); + break; } } - myselections.Append(aSel); + myselections.Append (theSel); if (isReplaced) { myselections.Last()->UpdateBVHStatus (SelectMgr_TBU_Renew); } - if (aMode == 0) + if (theMode == 0) { - Handle(PrsMgr_PresentableObject) aPrsParent (Parent()); - Handle(SelectMgr_SelectableObject) aSelParent = Handle(SelectMgr_SelectableObject)::DownCast (aPrsParent); - if (! aSelParent.IsNull() && ! aSelParent->GetAssemblyOwner().IsNull()) + SelectMgr_SelectableObject* aSelParent = dynamic_cast (Parent()); + if (aSelParent != NULL) { - SetAssemblyOwner (aSelParent->GetAssemblyOwner(), aMode); + if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner()) + { + SetAssemblyOwner (anAsmOwner, theMode); + } } } } - - //======================================================================= //function : ReSetTransformation -//purpose : +//purpose : //======================================================================= void SelectMgr_SelectableObject::ResetTransformation() { - for (Init(); More(); Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection) & aSel = CurrentSelection(); - for (aSel->Init(); aSel->More(); aSel->Next()) - { - aSel->UpdateStatus(SelectMgr_TOU_Partial); - aSel->UpdateBVHStatus (SelectMgr_TBU_None); - } + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + aSel->UpdateStatus (SelectMgr_TOU_Partial); + aSel->UpdateBVHStatus (SelectMgr_TBU_None); } PrsMgr_PresentableObject::ResetTransformation(); @@ -255,13 +246,13 @@ void SelectMgr_SelectableObject::ResetTransformation() //======================================================================= //function : UpdateTransformation -//purpose : +//purpose : //======================================================================= void SelectMgr_SelectableObject::UpdateTransformation() { - for (Init(); More(); Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - CurrentSelection()->UpdateStatus (SelectMgr_TOU_Partial); + aSelIter.Value()->UpdateStatus (SelectMgr_TOU_Partial); } PrsMgr_PresentableObject::UpdateTransformation(); @@ -269,44 +260,49 @@ void SelectMgr_SelectableObject::UpdateTransformation() //======================================================================= //function : UpdateTransformation -//purpose : +//purpose : //======================================================================= -void SelectMgr_SelectableObject::UpdateTransformations(const Handle(SelectMgr_Selection)& Sel) +void SelectMgr_SelectableObject::UpdateTransformations (const Handle(SelectMgr_Selection)& theSel) { - TopLoc_Location aSelfLocation (Transformation()); - Handle(Select3D_SensitiveEntity) SE; - if(aSelfLocation.IsIdentity()) return; - for(Sel->Init();Sel->More();Sel->Next()){ - SE = Handle(Select3D_SensitiveEntity)::DownCast (Sel->Sensitive()->BaseSensitive()); - if(!SE.IsNull()){ - const Handle(SelectBasics_EntityOwner)& aEOwner = SE->OwnerId(); - Handle(SelectMgr_EntityOwner) aMgrEO = - Handle(SelectMgr_EntityOwner)::DownCast (aEOwner); - if (!aMgrEO.IsNull()) + const TopLoc_Location aSelfLocation (Transformation()); + if (aSelfLocation.IsIdentity()) + { + return; + } + + for (NCollection_Vector::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) + { + if (Handle(Select3D_SensitiveEntity) aSensEntity = Handle(Select3D_SensitiveEntity)::DownCast (aSelEntIter.Value()->BaseSensitive())) + { + const Handle(SelectBasics_EntityOwner)& aEOwner = aSensEntity->OwnerId(); + if (Handle(SelectMgr_EntityOwner) aMgrEO = Handle(SelectMgr_EntityOwner)::DownCast (aEOwner)) + { aMgrEO->SetLocation (aSelfLocation); + } } } } //======================================================================= //function : HilightSelected -//purpose : +//purpose : //======================================================================= -void SelectMgr_SelectableObject::HilightSelected - ( const Handle(PrsMgr_PresentationManager3d)&, - const SelectMgr_SequenceOfOwner&) +void SelectMgr_SelectableObject::HilightSelected (const Handle(PrsMgr_PresentationManager3d)&, + const SelectMgr_SequenceOfOwner&) { throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightSelected"); } //======================================================================= //function : ClearSelected -//purpose : +//purpose : //======================================================================= -void SelectMgr_SelectableObject::ClearSelected () +void SelectMgr_SelectableObject::ClearSelected() { - if( !mySelectionPrs.IsNull() ) + if(!mySelectionPrs.IsNull()) + { mySelectionPrs->Clear(); + } } //======================================================================= @@ -320,7 +316,7 @@ void SelectMgr_SelectableObject::ClearDynamicHighlight (const Handle(PrsMgr_Pres //======================================================================= //function : HilightOwnerWithColor -//purpose : +//purpose : //======================================================================= void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)&, const Handle(Prs3d_Drawer)&, @@ -330,17 +326,17 @@ void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_Pres } //======================================================================= -//function : MaxFaceNodes -//purpose : +//function : IsAutoHilight +//purpose : //======================================================================= -Standard_Boolean SelectMgr_SelectableObject::IsAutoHilight () const +Standard_Boolean SelectMgr_SelectableObject::IsAutoHilight() const { return myAutoHilight; } //======================================================================= -//function : MaxFaceNodes -//purpose : +//function : SetAutoHilight +//purpose : //======================================================================= void SelectMgr_SelectableObject::SetAutoHilight ( const Standard_Boolean newAutoHilight ) { @@ -349,7 +345,7 @@ void SelectMgr_SelectableObject::SetAutoHilight ( const Standard_Boolean newAuto //======================================================================= //function : GetHilightPresentation -//purpose : +//purpose : //======================================================================= Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr) { @@ -365,7 +361,7 @@ Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (c //======================================================================= //function : GetSelectPresentation -//purpose : +//purpose : //======================================================================= Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr) { @@ -421,19 +417,17 @@ void SelectMgr_SelectableObject::SetZLayer (const Graphic3d_ZLayerId theLayerId) myHilightPrs->SetZLayer (theLayerId); // update all entity owner presentations - for (Init (); More () ;Next ()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSel = CurrentSelection(); - for (aSel->Init (); aSel->More (); aSel->Next ()) + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + for (NCollection_Vector::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - Handle(Select3D_SensitiveEntity) aEntity = - Handle(Select3D_SensitiveEntity)::DownCast (aSel->Sensitive()->BaseSensitive()); - if (!aEntity.IsNull()) + if (Handle(Select3D_SensitiveEntity) aEntity = Handle(Select3D_SensitiveEntity)::DownCast (aSelEntIter.Value()->BaseSensitive())) { - Handle(SelectMgr_EntityOwner) aOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aEntity->OwnerId()); - if (!aOwner.IsNull()) + if (Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast (aEntity->OwnerId())) + { aOwner->SetZLayer (theLayerId); + } } } } @@ -449,20 +443,20 @@ void SelectMgr_SelectableObject::updateSelection (const Standard_Integer theMode { if (theMode == -1) { - for (Init(); More(); Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSel = CurrentSelection(); + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); aSel->UpdateStatus (SelectMgr_TOU_Full); } - return; } - for (Init(); More(); Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - if (CurrentSelection()->Mode() == theMode) + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + if (aSel->Mode() == theMode) { - CurrentSelection()->UpdateStatus (SelectMgr_TOU_Full); + aSel->UpdateStatus (SelectMgr_TOU_Full); return; } } @@ -477,44 +471,31 @@ void SelectMgr_SelectableObject::SetAssemblyOwner (const Handle(SelectMgr_Entity { if (theMode == -1) { - for (Standard_Integer aModeIter = 1; aModeIter <= myselections.Length(); ++aModeIter) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - Handle(SelectMgr_Selection)& aSel = myselections.ChangeValue (aModeIter); - for (aSel->Init(); aSel->More(); aSel->Next()) + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + for (NCollection_Vector::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - aSel->Sensitive()->BaseSensitive()->Set (theOwner); + aSelEntIter.Value()->BaseSensitive()->Set (theOwner); } } - return; } - if (!HasSelection (theMode)) - return; - - for (Standard_Integer aModeIter = 1; aModeIter <= myselections.Length(); ++aModeIter) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - if (myselections.Value (aModeIter)->Mode() == theMode) + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + if (aSel->Mode() == theMode) { - Handle(SelectMgr_Selection)& aSel = myselections.ChangeValue (aModeIter); - for (aSel->Init(); aSel->More(); aSel->Next()) + for (NCollection_Vector::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - aSel->Sensitive()->BaseSensitive()->Set (theOwner); + aSelEntIter.Value()->BaseSensitive()->Set (theOwner); } return; } } } -//======================================================================= -//function : GetAssemblyOwner -//purpose : Returns common entity owner if it is an assembly -//======================================================================= -const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwner() const -{ - return myAssemblyOwner; -} - //======================================================================= //function : BndBoxOfSelected //purpose : @@ -525,19 +506,18 @@ Bnd_Box SelectMgr_SelectableObject::BndBoxOfSelected (const Handle(SelectMgr_Ind return Bnd_Box(); Bnd_Box aBnd; - for (Init(); More(); Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSel = CurrentSelection(); + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); if (aSel->GetSelectionState() != SelectMgr_SOS_Activated) continue; - for (aSel->Init(); aSel->More(); aSel->Next()) + for (NCollection_Vector::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - const Handle(SelectMgr_EntityOwner) anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId()); + const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelEntIter.Value()->BaseSensitive()->OwnerId()); if (theOwners->Contains (anOwner)) { - Select3D_BndBox3d aBox = aSel->Sensitive()->BaseSensitive()->BoundingBox(); + Select3D_BndBox3d aBox = aSelEntIter.Value()->BaseSensitive()->BoundingBox(); aBnd.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(), aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z()); } @@ -553,18 +533,20 @@ Bnd_Box SelectMgr_SelectableObject::BndBoxOfSelected (const Handle(SelectMgr_Ind //======================================================================= Handle(SelectMgr_EntityOwner) SelectMgr_SelectableObject::GlobalSelOwner() const { - Handle(SelectMgr_EntityOwner) anOwner; - - if (!HasSelection (myGlobalSelMode)) - return anOwner; - const Handle(SelectMgr_Selection)& aGlobalSel = Selection (myGlobalSelMode); - if (aGlobalSel->IsEmpty()) - return anOwner; - - aGlobalSel->Init(); - anOwner = - Handle(SelectMgr_EntityOwner)::DownCast (aGlobalSel->Sensitive()->BaseSensitive()->OwnerId()); + if (!aGlobalSel.IsNull() + && !aGlobalSel->IsEmpty()) + { + return Handle(SelectMgr_EntityOwner)::DownCast (aGlobalSel->Entities().First()->BaseSensitive()->OwnerId()); + } + return THE_NULL_ENTITYOWNER; +} - return anOwner; +//======================================================================= +//function : GetAssemblyOwner +//purpose : +//======================================================================= +const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwner() const +{ + return THE_NULL_ENTITYOWNER; } diff --git a/src/SelectMgr/SelectMgr_SelectableObject.hxx b/src/SelectMgr/SelectMgr_SelectableObject.hxx index 412ac68c0d..0ac59a910b 100644 --- a/src/SelectMgr/SelectMgr_SelectableObject.hxx +++ b/src/SelectMgr/SelectMgr_SelectableObject.hxx @@ -17,30 +17,18 @@ #ifndef _SelectMgr_SelectableObject_HeaderFile #define _SelectMgr_SelectableObject_HeaderFile -#include -#include - -#include -#include -#include -#include #include +#include #include +#include +#include #include -#include #include -#include -#include -#include + class SelectMgr_EntityOwner; class Prs3d_Presentation; class Standard_NotImplemented; class SelectMgr_SelectionManager; -class Bnd_Box; - - -class SelectMgr_SelectableObject; -DEFINE_STANDARD_HANDLE(SelectMgr_SelectableObject, PrsMgr_PresentableObject) //! A framework to supply the structure of the object to be //! selected. At the first pick, this structure is created by @@ -94,36 +82,30 @@ public: //! completely) when some selection mode is activated not for the first time. Standard_EXPORT void ClearSelections (const Standard_Boolean update = Standard_False); - //! Returns the selection Selection having the selection mode aMode. - Standard_EXPORT const Handle(SelectMgr_Selection)& Selection (const Standard_Integer aMode) const; - - //! Returns true if a selection corresponding to the - //! selection mode theMode was computed for this object. - Standard_EXPORT virtual Standard_Boolean HasSelection (const Standard_Integer theMode) const; - + //! Returns the selection having specified selection mode or NULL. + Standard_EXPORT const Handle(SelectMgr_Selection)& Selection (const Standard_Integer theMode) const; + + //! Returns true if a selection corresponding to the selection mode theMode was computed for this object. + Standard_Boolean HasSelection (const Standard_Integer theMode) const { return !Selection (theMode).IsNull(); } + + //! Return the sequence of selections. + const SelectMgr_SequenceOfSelection& Selections() const { return myselections; } + //! Begins the iteration scanning for sensitive primitives. - void Init() - { - mycurrent = 1; - } + Standard_DEPRECATED("Deprecated method, Selections() should be used instead") + void Init() { mycurrent = 1; } //! Continues the iteration scanning for sensitive primitives. - Standard_Boolean More() const - { - return mycurrent <= myselections.Length(); - } + Standard_DEPRECATED("Deprecated method, Selections() should be used instead") + Standard_Boolean More() const { return mycurrent <= myselections.Length(); } //! Continues the iteration scanning for sensitive primitives. - void Next() - { - mycurrent++; - } + Standard_DEPRECATED("Deprecated method, Selections() should be used instead") + void Next() { ++mycurrent; } //! Returns the current selection in this framework. - const Handle(SelectMgr_Selection)& CurrentSelection() const - { - return myselections (mycurrent); - } + Standard_DEPRECATED("Deprecated method, Selections() should be used instead") + const Handle(SelectMgr_Selection)& CurrentSelection() const { return myselections (mycurrent); } Standard_EXPORT void ResetTransformation() Standard_OVERRIDE; @@ -190,10 +172,7 @@ public: //! Sets common entity owner for assembly sensitive object entities Standard_EXPORT void SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer theMode = -1); - - //! Returns common entity owner if the object is an assembly - Standard_EXPORT const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const; - + //! Returns a bounding box of sensitive entities with the owners given //! if they are a part of activated selection Standard_EXPORT Bnd_Box BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners); @@ -207,6 +186,9 @@ public: //! Returns the owner of mode for selection of object as a whole Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const; + //! Returns common entity owner if the object is an assembly + Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const; + protected: Standard_EXPORT SelectMgr_SelectableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); @@ -221,7 +203,6 @@ protected: protected: SelectMgr_SequenceOfSelection myselections; - Handle(SelectMgr_EntityOwner) myAssemblyOwner; Handle(Prs3d_Presentation) mySelectionPrs; Handle(Prs3d_Presentation) myHilightPrs; Standard_Boolean myAutoHilight; @@ -233,4 +214,6 @@ private: }; +DEFINE_STANDARD_HANDLE(SelectMgr_SelectableObject, PrsMgr_PresentableObject) + #endif // _SelectMgr_SelectableObject_HeaderFile diff --git a/src/SelectMgr/SelectMgr_Selection.cxx b/src/SelectMgr/SelectMgr_Selection.cxx index 6fa60aa870..1c757abc64 100644 --- a/src/SelectMgr/SelectMgr_Selection.cxx +++ b/src/SelectMgr/SelectMgr_Selection.cxx @@ -14,10 +14,10 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include - #include + #include +#include IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Selection,Standard_Transient) @@ -26,7 +26,8 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Selection,Standard_Transient) // Purpose : //================================================== SelectMgr_Selection::SelectMgr_Selection (const Standard_Integer theModeIdx) -: myMode (theModeIdx), +: myEntityIter (0), + myMode (theModeIdx), mySelectionState (SelectMgr_SOS_Unknown), myBVHUpdateStatus (SelectMgr_TBU_None), mySensFactor (2), @@ -58,31 +59,29 @@ void SelectMgr_Selection::Destroy() //================================================== void SelectMgr_Selection::Add (const Handle(SelectBasics_SensitiveEntity)& theSensitive) { - // if input is null: - // in debug mode raise exception - Standard_NullObject_Raise_if - (theSensitive.IsNull(), "Null sensitive entity is added to the selection"); + // if input is null: in debug mode raise exception + Standard_NullObject_Raise_if (theSensitive.IsNull(), "Null sensitive entity is added to the selection"); + if (theSensitive.IsNull()) + { + // in release mode do not add + return; + } - // in release mode do not add - if (!theSensitive.IsNull()) + Handle(SelectMgr_SensitiveEntity) anEntity = new SelectMgr_SensitiveEntity (theSensitive); + myEntities.Append (anEntity); + if (mySelectionState == SelectMgr_SOS_Activated + && !anEntity->IsActiveForSelection()) { - Handle(SelectMgr_SensitiveEntity) anEntity = new SelectMgr_SensitiveEntity (theSensitive); - myEntities.Append (anEntity); - if (mySelectionState == SelectMgr_SOS_Activated && - !anEntity->IsActiveForSelection()) - { - anEntity->SetActiveForSelection(); - } + anEntity->SetActiveForSelection(); + } - if (myIsCustomSens) - { - anEntity->BaseSensitive()->SetSensitivityFactor (mySensFactor); - } - else - { - mySensFactor = Max (mySensFactor, - anEntity->BaseSensitive()->SensitivityFactor()); - } + if (myIsCustomSens) + { + anEntity->BaseSensitive()->SetSensitivityFactor (mySensFactor); + } + else + { + mySensFactor = Max (mySensFactor, anEntity->BaseSensitive()->SensitivityFactor()); } } @@ -101,52 +100,6 @@ void SelectMgr_Selection::Clear() myEntities.Clear(); } -//================================================== -// Function: IsEmpty -// Purpose : -//================================================== -Standard_Boolean SelectMgr_Selection::IsEmpty() const -{ - return myEntities.IsEmpty(); -} - -//================================================== -// function: GetEntityById -// purpose : Returns sensitive entity stored by -// index theIdx in entites vector -//================================================== -Handle(SelectMgr_SensitiveEntity)& SelectMgr_Selection::GetEntityById (const Standard_Integer theIdx) -{ - return myEntities.ChangeValue (theIdx); -} - -//================================================== -// function: GetSelectionState -// purpose : Returns status of selection -//================================================== -SelectMgr_StateOfSelection SelectMgr_Selection::GetSelectionState() const -{ - return mySelectionState; -} - -//================================================== -// function: SetSelectionState -// purpose : Sets status of selection -//================================================== -void SelectMgr_Selection::SetSelectionState (const SelectMgr_StateOfSelection theState) const -{ - mySelectionState = theState; -} - -//================================================== -// function: Sensitivity -// purpose : Returns sensitivity of the selection -//================================================== -Standard_Integer SelectMgr_Selection::Sensitivity() const -{ - return mySensFactor; -} - //================================================== // function: SetSensitivity // purpose : Changes sensitivity of the selection and all its entities to the given value. diff --git a/src/SelectMgr/SelectMgr_Selection.hxx b/src/SelectMgr/SelectMgr_Selection.hxx index be08967d39..956d9877bc 100644 --- a/src/SelectMgr/SelectMgr_Selection.hxx +++ b/src/SelectMgr/SelectMgr_Selection.hxx @@ -18,18 +18,11 @@ #define _SelectMgr_Selection_HeaderFile #include - -#include -#include -#include - -#include -#include #include #include #include +#include -class Standard_NullObject; class SelectBasics_SensitiveEntity; //! Represents the state of a given selection mode for a @@ -69,7 +62,7 @@ class SelectBasics_SensitiveEntity; //! - mode 6 : selection of the constituent solids. class SelectMgr_Selection : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection, Standard_Transient) public: //! Constructs a selection object defined by the selection mode IdMode. @@ -80,8 +73,7 @@ public: Standard_EXPORT void Destroy(); - //! Adds the sensitive primitive aprimitive to the list of - //! stored entities in this object. + //! Adds the sensitive primitive to the list of stored entities in this object. //! Raises NullObject if the primitive is a null handle. Standard_EXPORT void Add (const Handle(SelectBasics_SensitiveEntity)& theSensitive); @@ -89,25 +81,35 @@ public: Standard_EXPORT void Clear(); //! returns true if no sensitive entity is stored. - Standard_EXPORT Standard_Boolean IsEmpty() const; + Standard_Boolean IsEmpty() const { return myEntities.IsEmpty(); } //! returns the selection mode represented by this selection - Standard_Integer Mode() const; + Standard_Integer Mode() const { return myMode; } + + //! Return entities. + const NCollection_Vector& Entities() const { return myEntities; } + + //! Return entities. + NCollection_Vector& ChangeEntities() { return myEntities; } //! Begins an iteration scanning for sensitive primitives. - void Init(); + Standard_DEPRECATED("Deprecated method, Entities() should be used instead") + void Init() { myEntityIter = myEntities.Lower(); } //! Continues the iteration scanning for sensitive //! primitives with the mode defined in this framework. - Standard_Boolean More() const; + Standard_DEPRECATED("Deprecated method, Entities() should be used instead") + Standard_Boolean More() const { return myEntityIter <= myEntities.Upper(); } //! Returns the next sensitive primitive found in the //! iteration. This is a scan for entities with the mode //! defined in this framework. - void Next(); + Standard_DEPRECATED("Deprecated method, Entities() should be used instead") + void Next() { ++myEntityIter; } //! Returns any sensitive primitive in this framework. - const Handle(SelectMgr_SensitiveEntity)& Sensitive() const; + Standard_DEPRECATED("Deprecated method, Entities() should be used instead") + const Handle(SelectMgr_SensitiveEntity)& Sensitive() const { return myEntities.Value (myEntityIter); } //! Returns the flag UpdateFlag. //! This flage gives the update status of this framework @@ -115,49 +117,40 @@ public: //! - full //! - partial, or //! - none. - SelectMgr_TypeOfUpdate UpdateStatus() const; + SelectMgr_TypeOfUpdate UpdateStatus() const { return myUpdateStatus; } - void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus); + void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; } - void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus); + void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; } - SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const; + SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const { return myBVHUpdateStatus; } //! Returns status of selection - Standard_EXPORT SelectMgr_StateOfSelection GetSelectionState() const; + SelectMgr_StateOfSelection GetSelectionState() const { return mySelectionState; } //! Sets status of selection - Standard_EXPORT void SetSelectionState (const SelectMgr_StateOfSelection theState) const; + void SetSelectionState (const SelectMgr_StateOfSelection theState) const { mySelectionState = theState; } //! Returns sensitivity of the selection - Standard_EXPORT Standard_Integer Sensitivity() const; + Standard_Integer Sensitivity() const { return mySensFactor; } //! Changes sensitivity of the selection and all its entities to the given value. //! IMPORTANT: This method does not update any outer selection structures, so for //! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method. Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens); - DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection,Standard_Transient) - -protected: - - //! Returns sensitive entity stored by index theIdx in entites vector - Standard_EXPORT Handle(SelectMgr_SensitiveEntity)& GetEntityById (const Standard_Integer theIdx); - private: - NCollection_Vector myEntities; - NCollection_Vector::Iterator myEntityIter; - Standard_Integer myMode; - SelectMgr_TypeOfUpdate myUpdateStatus; - mutable SelectMgr_StateOfSelection mySelectionState; - mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus; - Standard_Integer mySensFactor; - Standard_Boolean myIsCustomSens; + NCollection_Vector myEntities; + Standard_Integer myEntityIter; + Standard_Integer myMode; + SelectMgr_TypeOfUpdate myUpdateStatus; + mutable SelectMgr_StateOfSelection mySelectionState; + mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus; + Standard_Integer mySensFactor; + Standard_Boolean myIsCustomSens; }; DEFINE_STANDARD_HANDLE(SelectMgr_Selection, Standard_Transient) -#include - #endif diff --git a/src/SelectMgr/SelectMgr_Selection.lxx b/src/SelectMgr/SelectMgr_Selection.lxx deleted file mode 100644 index 5b030709c0..0000000000 --- a/src/SelectMgr/SelectMgr_Selection.lxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) 1998-1999 Matra Datavision -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// ======================================================================= -// function : Mode -// purpose : -// ======================================================================= -inline Standard_Integer SelectMgr_Selection::Mode() const -{ - return myMode; -} - -// ======================================================================= -// function : Init -// purpose : -// ======================================================================= -inline void SelectMgr_Selection::Init() -{ - myEntityIter.Init (myEntities); -} - -// ======================================================================= -// function : More -// purpose : -// ======================================================================= -inline Standard_Boolean SelectMgr_Selection::More() const -{ - return myEntityIter.More(); -} - -// ======================================================================= -// function : Next -// purpose : -// ======================================================================= -inline void SelectMgr_Selection::Next() -{ - myEntityIter.Next(); -} - -// ======================================================================= -// function : Sensitive -// purpose : -// ======================================================================= -inline const Handle(SelectMgr_SensitiveEntity)& SelectMgr_Selection::Sensitive() const -{ - return myEntityIter.Value(); -} - -// ======================================================================= -// function : UpdateStatus -// purpose : -// ======================================================================= -inline void SelectMgr_Selection::UpdateStatus(const SelectMgr_TypeOfUpdate theStatus) -{ - myUpdateStatus = theStatus; -} - -// ======================================================================= -// function : UpdateStatus -// purpose : -// ======================================================================= -inline SelectMgr_TypeOfUpdate SelectMgr_Selection::UpdateStatus() const -{ - return myUpdateStatus; -} - -// ======================================================================= -// function : UpdateBVHStatus -// purpose : -// ======================================================================= -inline void SelectMgr_Selection::UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus) -{ - myBVHUpdateStatus = theStatus; -} - -// ======================================================================= -// function : BVHUpdateStatus -// purpose : -// ======================================================================= -inline SelectMgr_TypeOfBVHUpdate SelectMgr_Selection::BVHUpdateStatus() const -{ - return myBVHUpdateStatus; -} diff --git a/src/SelectMgr/SelectMgr_SelectionManager.cxx b/src/SelectMgr/SelectMgr_SelectionManager.cxx index eb36f0343a..9d8d0c876a 100644 --- a/src/SelectMgr/SelectMgr_SelectionManager.cxx +++ b/src/SelectMgr/SelectMgr_SelectionManager.cxx @@ -14,12 +14,12 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include #include #include #include -#include #include #include #include @@ -30,25 +30,30 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectionManager,Standard_Transient) -static Standard_Integer FindIndex (const SelectMgr_SequenceOfSelector& theSelectorsSeq, - const Handle(SelectMgr_ViewerSelector)& theSelector) +namespace { - Standard_Integer aFoundIdx = 0; - - for (Standard_Integer anIdx = 1; anIdx <= theSelectorsSeq.Length() && aFoundIdx==0; anIdx++) + static bool containsSelector (const SelectMgr_SequenceOfSelector& theSelectorsSeq, + const Handle(SelectMgr_ViewerSelector)& theSelector) { - if (theSelector == theSelectorsSeq.Value (anIdx)) - aFoundIdx = anIdx; + for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (theSelectorsSeq); aSelectorIter.More(); aSelectorIter.Next()) + { + if (aSelectorIter.Value() == theSelector) + { + return true; + } + } + return false; } - - return aFoundIdx; } //================================================== // Function: Create // Purpose : //================================================== -SelectMgr_SelectionManager::SelectMgr_SelectionManager() {} +SelectMgr_SelectionManager::SelectMgr_SelectionManager() +{ + // +} //================================================== // Function: Add @@ -68,13 +73,17 @@ void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_ViewerSelector)& for (SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors aSelIter (myLocal); aSelIter.More(); aSelIter.Next()) { SelectMgr_SequenceOfSelector& theSelectors = myLocal.ChangeFind (aSelIter.Key()); - Standard_Integer aRank = FindIndex (theSelectors, theSelector); - if (aRank != 0 && aRank <= theSelectors.Length()) - theSelectors.Remove (aRank); + for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (theSelectors); aSelectorIter.More(); aSelectorIter.Next()) + { + if (aSelectorIter.Value() == theSelector) + { + theSelectors.Remove (aSelectorIter); + break; + } + } } - if (mySelectors.Contains (theSelector)) - mySelectors.Remove (theSelector); + mySelectors.Remove (theSelector); } //================================================== @@ -92,13 +101,8 @@ Standard_Boolean SelectMgr_SelectionManager::Contains (const Handle(SelectMgr_Vi //================================================== Standard_Boolean SelectMgr_SelectionManager::Contains (const Handle(SelectMgr_SelectableObject)& theObject) const { - if (myGlobal.Contains (theObject)) - return Standard_True; - - if (myLocal.IsBound (theObject)) - return Standard_True; - - return Standard_False; + return myGlobal.Contains (theObject) + || myLocal.IsBound (theObject); } //================================================== @@ -120,10 +124,9 @@ void SelectMgr_SelectionManager::Load (const Handle(SelectMgr_SelectableObject)& return; myGlobal.Add(theObject); - for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) + for (NCollection_Map::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) { - Handle(SelectMgr_ViewerSelector) aSelector = - Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key()); + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key(); if (!aSelector->Contains (theObject) && theObject->HasOwnPresentations()) { aSelector->AddSelectableObject (theObject); @@ -142,23 +145,22 @@ void SelectMgr_SelectionManager::Load (const Handle(SelectMgr_SelectableObject)& const Handle(SelectMgr_ViewerSelector)& theSelector, const Standard_Integer theMode) { - if (!mySelectors.Contains (theSelector)) - { - mySelectors.Add (theSelector); - } - + mySelectors.Add (theSelector); if (theMode != -1) + { loadMode (theObject, theMode, theSelector); + } if (theObject->HasOwnPresentations()) + { theSelector->AddSelectableObject (theObject); + } - if (myLocal.IsBound (theObject)) + if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject)) { - SelectMgr_SequenceOfSelector& aSelectors = myLocal.ChangeFind (theObject); - if (FindIndex (aSelectors, theSelector) == 0) + if (!containsSelector (*aSelectors, theSelector)) { - aSelectors.Append (theSelector); + aSelectors->Append (theSelector); } } else @@ -172,14 +174,13 @@ void SelectMgr_SelectionManager::Load (const Handle(SelectMgr_SelectableObject)& if (!theObject->HasOwnPresentations()) return; - SelectMgr_SequenceOfSelector aSelectors; - aSelectors.Append (theSelector); - myLocal.Bind (theObject, aSelectors); + SelectMgr_SequenceOfSelector aGlobSelectors; + aGlobSelectors.Append (theSelector); + myLocal.Bind (theObject, aGlobSelectors); } } } - //================================================== // Function: Remove // Purpose : @@ -196,37 +197,36 @@ void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject if (myGlobal.Contains (theObject)) { - for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) + for (NCollection_Map::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) { - Handle(SelectMgr_ViewerSelector) aCurSelector = - Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key()); - + const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorsIter.Key(); if (!aCurSelector->Contains (theObject)) + { continue; + } - for (theObject->Init(); theObject->More(); theObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - aCurSelector->RemoveSelectionOfObject (theObject, theObject->CurrentSelection()); - theObject->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Remove); + aCurSelector->RemoveSelectionOfObject (theObject, aSelIter.Value()); + aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove); } aCurSelector->RemoveSelectableObject (theObject); } myGlobal.Remove (theObject); } - else if (myLocal.IsBound (theObject)) + else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject)) { - SelectMgr_SequenceOfSelector& aSelectors = myLocal.ChangeFind (theObject); - for (Standard_Integer aSelectorsIdx = 1; aSelectorsIdx <= aSelectors.Length(); aSelectorsIdx++) + for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next()) { - Handle(SelectMgr_ViewerSelector) aCurSelector = aSelectors (aSelectorsIdx); + const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorIter.Value(); if (!aCurSelector->Contains (theObject)) continue; - for (theObject->Init(); theObject->More(); theObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - aCurSelector->RemoveSelectionOfObject (theObject, theObject->CurrentSelection()); - theObject->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Remove); + aCurSelector->RemoveSelectionOfObject (theObject, aSelIter.Value()); + aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove); } aCurSelector->RemoveSelectableObject (theObject); } @@ -251,31 +251,28 @@ void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject { Remove (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theSelector); } - if (!theObject->HasOwnPresentations()) return; - for (theObject->Init(); theObject->More(); theObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - theSelector->RemoveSelectionOfObject (theObject, theObject->CurrentSelection()); - theObject->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Remove); + theSelector->RemoveSelectionOfObject (theObject, aSelIter.Value()); + aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove); } - theSelector->RemoveSelectableObject (theObject); - if (myLocal.IsBound (theObject)) + if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject)) { - SelectMgr_SequenceOfSelector& aSelectors = myLocal.ChangeFind (theObject); - for (Standard_Integer aSelectorIdx = 1; aSelectorIdx <= aSelectors.Length(); aSelectorIdx++) + for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next()) { - if (aSelectors (aSelectorIdx) == theSelector) + if (aSelectorIter.Value() == theSelector) { - aSelectors.Remove (aSelectorIdx); + aSelectors->Remove (aSelectorIter); break; } } - if (aSelectors.IsEmpty()) + if (aSelectors->IsEmpty()) { myLocal.UnBind (theObject); } @@ -300,78 +297,91 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje { Activate (Handle(SelectMgr_SelectableObject)::DownCast (anChildIter.Value()), theMode, theSelector); } - if (!theObject->HasOwnPresentations()) return; Standard_Boolean isComputed = Standard_False; - if (theObject->HasSelection (theMode)) + if (const Handle(SelectMgr_Selection)& aSelOld = theObject->Selection (theMode)) { - isComputed = theObject->Selection (theMode)->IsEmpty() ? 0 : 1; + isComputed = !aSelOld->IsEmpty(); } - if (!isComputed) + { loadMode (theObject, theMode); + } if (theSelector.IsNull()) { if (myGlobal.Contains (theObject)) { - for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) + for (NCollection_Map::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) { - Handle(SelectMgr_ViewerSelector) aCurSelector = - Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key()); + const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorsIter.Key(); Activate (theObject, theMode, aCurSelector); } } - else if (myLocal.IsBound (theObject)) + else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject)) { - SelectMgr_SequenceOfSelector& theSelectors = myLocal.ChangeFind (theObject); - for (Standard_Integer aSelectorIdx = 1; aSelectorIdx <= theSelectors.Length(); aSelectorIdx++) + for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next()) { - Handle(SelectMgr_ViewerSelector) aCurSelector = theSelectors (aSelectorIdx); + Handle(SelectMgr_ViewerSelector) aCurSelector = aSelectorIter.Value(); Activate (theObject, theMode, aCurSelector); } } } const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode); - switch (aSelection->UpdateStatus()) { - case SelectMgr_TOU_Full: - if (theObject->HasSelection (theMode)) - theSelector->RemoveSelectionOfObject (theObject, aSelection); - theObject->RecomputePrimitives (theMode); - case SelectMgr_TOU_Partial: - if(theObject->HasTransformation()) - theObject->UpdateTransformations (aSelection); - theSelector->RebuildObjectsTree(); - break; - default: - break; + case SelectMgr_TOU_Full: + { + if (theObject->HasSelection (theMode)) + { + theSelector->RemoveSelectionOfObject (theObject, aSelection); + } + theObject->RecomputePrimitives (theMode); + // pass through SelectMgr_TOU_Partial + } + case SelectMgr_TOU_Partial: + { + if(theObject->HasTransformation()) + { + theObject->UpdateTransformations (aSelection); + } + theSelector->RebuildObjectsTree(); + break; + } + default: + break; } aSelection->UpdateStatus(SelectMgr_TOU_None); switch (aSelection->BVHUpdateStatus()) { - case SelectMgr_TBU_Add: - case SelectMgr_TBU_Renew: - theSelector->AddSelectionToObject (theObject, aSelection); - break; - case SelectMgr_TBU_Remove: - if (aSelection->GetSelectionState() == SelectMgr_SOS_Deactivated) + case SelectMgr_TBU_Add: + case SelectMgr_TBU_Renew: + { theSelector->AddSelectionToObject (theObject, aSelection); - break; - default: - break; + break; + } + case SelectMgr_TBU_Remove: + { + if (aSelection->GetSelectionState() == SelectMgr_SOS_Deactivated) + { + theSelector->AddSelectionToObject (theObject, aSelection); + } + break; + } + default: + break; } aSelection->UpdateBVHStatus (SelectMgr_TBU_None); if (myGlobal.Contains (theObject)) { const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode(); - if (theMode != aGlobalSelMode && theSelector->IsActive (theObject, aGlobalSelMode)) + if (theMode != aGlobalSelMode + && theSelector->IsActive (theObject, aGlobalSelMode)) { theSelector->Deactivate (theObject->Selection (aGlobalSelMode)); } @@ -379,10 +389,12 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje } else { - if (myLocal.IsBound (theObject)) + if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject)) { - if (FindIndex (myLocal.Find (theObject), theSelector) == 0) - (myLocal.ChangeFind (theObject)).Append (theSelector); + if (!containsSelector (*aSelectors, theSelector)) + { + aSelectors->Append (theSelector); + } theSelector->Activate (theObject->Selection (theMode)); } } @@ -400,48 +412,47 @@ void SelectMgr_SelectionManager::Deactivate (const Handle(SelectMgr_SelectableOb { Deactivate (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector); } - if (!theObject->HasOwnPresentations()) + { return; + } + if (!myGlobal.Contains(theObject) + && !myLocal.IsBound (theObject)) + { + return; + } - Standard_Boolean isInGlobal = myGlobal.Contains (theObject); - Standard_Boolean hasSelection = theMode == -1 ? Standard_True : theObject->HasSelection (theMode); - - if (theSelector.IsNull()) + const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode); + if (!theSelector.IsNull()) { - Handle(SelectMgr_ViewerSelector) aSelector; - for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) + if (theMode == -1) { - aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key()); - if (isInGlobal || myLocal.IsBound (theObject)) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - if (theMode == -1) - { - for (theObject->Init(); theObject->More(); theObject->Next()) - { - aSelector->Deactivate (theObject->CurrentSelection()); - } - } - else - { - if (hasSelection) - aSelector->Deactivate (theObject->Selection (theMode)); - } + theSelector->Deactivate (aSelIter.Value()); } } + else if (!aSel.IsNull()) + { + theSelector->Deactivate (aSel); + } + return; } - else + + for (NCollection_Map::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) { + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key(); if (theMode == -1) { - for (theObject->Init(); theObject->More(); theObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - theSelector->Deactivate (theObject->CurrentSelection()); + aSelector->Deactivate (aSelIter.Value()); } } - else - if (hasSelection) - theSelector->Deactivate (theObject->Selection (theMode)); + else if (!aSel.IsNull()) + { + aSelector->Deactivate (aSel); + } } } @@ -458,42 +469,47 @@ Standard_Boolean SelectMgr_SelectionManager::IsActivated (const Handle(SelectMgr if (IsActivated (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector)) return Standard_True; } - if (!theObject->HasOwnPresentations()) + { return Standard_False; - - if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject))) + } + if (!myGlobal.Contains(theObject) + && !myLocal.IsBound (theObject)) + { return Standard_False; + } if (theMode == -1 && theSelector.IsNull()) { - for (theObject->Init(); theObject->More(); theObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - if (IsActivated (theObject, theObject->CurrentSelection()->Mode())) + if (IsActivated (theObject, aSelIter.Value()->Mode())) + { return Standard_True; + } } - return Standard_False; } - if (!theObject->HasSelection (theMode)) - return Standard_False; - const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode); - if (theSelector.IsNull()) + if (aSelection.IsNull()) { - for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) - { - Handle(SelectMgr_ViewerSelector) aSelector (Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key())); - if (aSelector->Status (aSelection) == SelectMgr_SOS_Activated) - return Standard_True; - } + return Standard_False; } - else + + if (!theSelector.IsNull()) { return theSelector->Status (aSelection) == SelectMgr_SOS_Activated; } + for (NCollection_Map::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) + { + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key(); + if (aSelector->Status (aSelection) == SelectMgr_SOS_Activated) + { + return Standard_True; + } + } return Standard_False; } @@ -513,49 +529,43 @@ void SelectMgr_SelectionManager::ClearSelectionStructures (const Handle(SelectMg } if (!theObj->HasOwnPresentations()) + { + return; + } + if (!myGlobal.Contains(theObj) + && !myLocal.IsBound (theObj)) + { return; + } if (theSelector.IsNull()) { - if (!(myGlobal.Contains (theObj) || myLocal.IsBound(theObj))) - return; - - TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); - Handle(SelectMgr_ViewerSelector) aSelector; - for( ; aSelectorsIter.More(); aSelectorsIter.Next()) + for (NCollection_Map::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) { - aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key()); + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key(); ClearSelectionStructures (theObj, theMode, aSelector); } + return; } - else - { - if (!(myGlobal.Contains (theObj) || myLocal.IsBound (theObj))) - return; - if (theMode != -1) + if (theMode != -1) + { + if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode)) { - if (theObj->HasSelection (theMode)) - { - const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode); - if (theObj->HasSelection (theMode)) - { - theSelector->RemoveSelectionOfObject (theObj, aSelection); - aSelection->UpdateBVHStatus (SelectMgr_TBU_Add); - } - } + theSelector->RemoveSelectionOfObject (theObj, aSelection); + aSelection->UpdateBVHStatus (SelectMgr_TBU_Add); } - else + } + else + { + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObj->Selections()); aSelIter.More(); aSelIter.Next()) { - for (theObj->Init(); theObj->More(); theObj->Next()) - { - const Handle(SelectMgr_Selection)& aSelection = theObj->CurrentSelection(); - theSelector->RemoveSelectionOfObject (theObj, aSelection); - aSelection->UpdateBVHStatus (SelectMgr_TBU_Add); - } + const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value(); + theSelector->RemoveSelectionOfObject (theObj, aSelection); + aSelection->UpdateBVHStatus (SelectMgr_TBU_Add); } - theSelector->RebuildObjectsTree(); } + theSelector->RebuildObjectsTree(); } //======================================================================= @@ -571,51 +581,44 @@ void SelectMgr_SelectionManager::RestoreSelectionStructures (const Handle(Select { RestoreSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector); } - if (!theObj->HasOwnPresentations()) + { + return; + } + if (!myGlobal.Contains(theObj) + && !myLocal.IsBound (theObj)) + { return; + } if (theSelector.IsNull()) { - if (!(myGlobal.Contains (theObj) || myLocal.IsBound(theObj))) - return; - - TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); - Handle(SelectMgr_ViewerSelector) aSelector; - for( ; aSelectorsIter.More(); aSelectorsIter.Next()) + for (NCollection_Map::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) { - aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key()); + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key(); RestoreSelectionStructures (theObj, theMode, aSelector); } + return; } - else - { - if (!(myGlobal.Contains (theObj) || myLocal.IsBound (theObj))) - return; - if (theMode != -1) + if (theMode != -1) + { + if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode)) { - if (theObj->HasSelection (theMode)) - { - const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode); - if (theObj->HasSelection (theMode)) - { - theSelector->AddSelectionToObject (theObj, aSelection); - aSelection->UpdateBVHStatus (SelectMgr_TBU_None); - } - } + theSelector->AddSelectionToObject (theObj, aSelection); + aSelection->UpdateBVHStatus (SelectMgr_TBU_None); } - else + } + else + { + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObj->Selections()); aSelIter.More(); aSelIter.Next()) { - for (theObj->Init(); theObj->More(); theObj->Next()) - { - const Handle(SelectMgr_Selection)& aSelection = theObj->CurrentSelection(); - theSelector->AddSelectionToObject (theObj, aSelection); - aSelection->UpdateBVHStatus (SelectMgr_TBU_None); - } + const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value(); + theSelector->AddSelectionToObject (theObj, aSelection); + aSelection->UpdateBVHStatus (SelectMgr_TBU_None); } - theSelector->RebuildObjectsTree(); } + theSelector->RebuildObjectsTree(); } //======================================================================= @@ -625,18 +628,16 @@ void SelectMgr_SelectionManager::RestoreSelectionStructures (const Handle(Select //======================================================================= void SelectMgr_SelectionManager::rebuildSelectionStructures (const Handle(SelectMgr_ViewerSelector)& theSelector) { - if (theSelector.IsNull()) + if (!theSelector.IsNull()) { - Handle(SelectMgr_ViewerSelector) aSelector; - for(TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) - { - aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key()); - rebuildSelectionStructures (aSelector); - } + theSelector->RebuildObjectsTree(); + return; } - else + + for (NCollection_Map::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) { - theSelector->RebuildObjectsTree(); + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key(); + rebuildSelectionStructures (aSelector); } } @@ -650,9 +651,9 @@ void SelectMgr_SelectionManager::recomputeSelectionMode (const Handle(SelectMgr_ { theSelection->UpdateStatus (SelectMgr_TOU_Full); - for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) + for (NCollection_Map::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) { - Handle(SelectMgr_ViewerSelector) aCurSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key()); + const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorIter.Key(); ClearSelectionStructures (theObject, theMode, aCurSelector); theObject->RecomputePrimitives (theMode); @@ -693,29 +694,31 @@ void SelectMgr_SelectionManager::RecomputeSelection (const Handle(SelectMgr_Sele { RecomputeSelection (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theIsForce, theMode); } - if (!theObject->HasOwnPresentations()) + { return; - - if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject))) + } + if (!myGlobal.Contains (theObject) + && !myLocal.IsBound (theObject)) + { return; + } if (theMode == -1) { - for (theObject->Init(); theObject->More(); theObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection(); - Standard_Integer aSelMode = aSelection->Mode(); + const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value(); + const Standard_Integer aSelMode = aSelection->Mode(); recomputeSelectionMode (theObject, aSelection, aSelMode); } } else { - if (!theObject->HasSelection (theMode)) - return; - - const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode); - recomputeSelectionMode (theObject, aSelection, theMode); + if (const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode)) + { + recomputeSelectionMode (theObject, aSelection, theMode); + } } } @@ -733,35 +736,41 @@ void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject { Update (Handle(SelectMgr_SelectableObject)::DownCast (aChildIter.Value()), theIsForce); } - if (!theObject->HasOwnPresentations()) + { return; + } - for (theObject->Init(); theObject->More(); theObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection(); + const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value(); if (theIsForce) { switch (aSelection->UpdateStatus()) { - case SelectMgr_TOU_Full: - ClearSelectionStructures (theObject, aSelection->Mode()); - theObject->RecomputePrimitives (aSelection->Mode()); // no break on purpose... - RestoreSelectionStructures (theObject, aSelection->Mode()); - case SelectMgr_TOU_Partial: - theObject->UpdateTransformations (aSelection); - rebuildSelectionStructures(); - break; - default: - break; + case SelectMgr_TOU_Full: + { + ClearSelectionStructures (theObject, aSelection->Mode()); + theObject->RecomputePrimitives (aSelection->Mode()); // no break on purpose... + RestoreSelectionStructures (theObject, aSelection->Mode()); + // pass through SelectMgr_TOU_Partial + } + case SelectMgr_TOU_Partial: + { + theObject->UpdateTransformations (aSelection); + rebuildSelectionStructures(); + break; + } + default: + break; } aSelection->UpdateStatus (SelectMgr_TOU_None); aSelection->UpdateBVHStatus (SelectMgr_TBU_None); } - for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) + for (NCollection_Map::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) { - Handle(SelectMgr_ViewerSelector) aSelector (Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key())); + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key(); Update (theObject, aSelector, Standard_False); } } @@ -776,39 +785,51 @@ void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject const Standard_Boolean theIsForce) { if (!mySelectors.Contains (theSelector)) + { return; + } - Standard_Boolean isKnown = myGlobal.Contains (theObject); - if (!isKnown) - isKnown = (myLocal.IsBound (theObject) && (FindIndex (myLocal.Find (theObject), theSelector) != 0)); - if (!isKnown) - return; + if (!myGlobal.Contains (theObject)) + { + const SelectMgr_SequenceOfSelector* aSelectors = myLocal.Seek (theObject); + if (aSelectors == NULL + || !containsSelector (*aSelectors, theSelector)) + { + return; + } + } for (PrsMgr_ListOfPresentableObjectsIter aChildIter (theObject->Children()); aChildIter.More(); aChildIter.Next()) { Update (Handle(SelectMgr_SelectableObject)::DownCast (aChildIter.Value()), theSelector, theIsForce); } - if (!theObject->HasOwnPresentations()) + { return; + } - for (theObject->Init(); theObject->More(); theObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection(); + const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value(); if (theIsForce) { switch (aSelection->UpdateStatus()) { - case SelectMgr_TOU_Full: - ClearSelectionStructures (theObject, aSelection->Mode()); - theObject->RecomputePrimitives (aSelection->Mode()); - RestoreSelectionStructures (theObject, aSelection->Mode()); - case SelectMgr_TOU_Partial: - theObject->UpdateTransformations (aSelection); - rebuildSelectionStructures(); - break; - default: - break; + case SelectMgr_TOU_Full: + { + ClearSelectionStructures (theObject, aSelection->Mode()); + theObject->RecomputePrimitives (aSelection->Mode()); + RestoreSelectionStructures (theObject, aSelection->Mode()); + // pass through SelectMgr_TOU_Partial + } + case SelectMgr_TOU_Partial: + { + theObject->UpdateTransformations (aSelection); + rebuildSelectionStructures(); + break; + } + default: + break; } aSelection->UpdateStatus (SelectMgr_TOU_None); aSelection->UpdateBVHStatus (SelectMgr_TBU_None); @@ -818,22 +839,27 @@ void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject { switch (aSelection->UpdateStatus()) { - case SelectMgr_TOU_Full: - ClearSelectionStructures (theObject, aSelection->Mode(), theSelector); - theObject->RecomputePrimitives (aSelection->Mode()); - RestoreSelectionStructures (theObject, aSelection->Mode(), theSelector); - case SelectMgr_TOU_Partial: - if (theObject->HasTransformation()) + case SelectMgr_TOU_Full: { - theObject->UpdateTransformations (aSelection); - theSelector->RebuildObjectsTree(); + ClearSelectionStructures (theObject, aSelection->Mode(), theSelector); + theObject->RecomputePrimitives (aSelection->Mode()); + RestoreSelectionStructures (theObject, aSelection->Mode(), theSelector); + // pass through SelectMgr_TOU_Partial } - break; - default: - break; + case SelectMgr_TOU_Partial: + { + if (theObject->HasTransformation()) + { + theObject->UpdateTransformations (aSelection); + theSelector->RebuildObjectsTree(); + } + break; + } + default: + break; } - aSelection->UpdateStatus(SelectMgr_TOU_None); + aSelection->UpdateStatus (SelectMgr_TOU_None); aSelection->UpdateBVHStatus (SelectMgr_TBU_None); } } @@ -848,49 +874,49 @@ void SelectMgr_SelectionManager::loadMode (const Handle(SelectMgr_SelectableObje const Handle(SelectMgr_ViewerSelector)& theSelector) { if (theMode == -1) + { return; + } - if (!theObject->HasSelection (theMode)) + if (const Handle(SelectMgr_Selection)& aSelOld = theObject->Selection (theMode)) { - Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode); - theObject->AddSelection (aNewSel, theMode); - if (theSelector.IsNull()) + if (aSelOld->IsEmpty()) { - if (myGlobal.Contains (theObject)) - { - TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); - for ( ; aSelectorIter.More(); aSelectorIter.Next()) - { - Handle(SelectMgr_ViewerSelector) aSelector = - Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key()); - aSelector->AddSelectionToObject (theObject, aNewSel); - aNewSel->UpdateBVHStatus (SelectMgr_TBU_None); - } - } - else if (myLocal.IsBound (theObject)) + if (aSelOld->BVHUpdateStatus() == SelectMgr_TBU_Remove) { - const SelectMgr_SequenceOfSelector& aSelectors = myLocal (theObject); - for (Standard_Integer aSelectorIdx = 1; aSelectorIdx <= aSelectors.Length(); ++aSelectorIdx) - { - aSelectors (aSelectorIdx)->AddSelectionToObject (theObject, aNewSel); - aNewSel->UpdateBVHStatus (SelectMgr_TBU_None); - } + Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode); + theObject->AddSelection (aNewSel, theMode); + aNewSel->UpdateBVHStatus (SelectMgr_TBU_Remove); + aNewSel->SetSelectionState (SelectMgr_SOS_Deactivated); } } - else + return; + } + + Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode); + theObject->AddSelection (aNewSel, theMode); + if (!theSelector.IsNull()) + { + theSelector->AddSelectionToObject (theObject, aNewSel); + aNewSel->UpdateBVHStatus (SelectMgr_TBU_None); + return; + } + + if (myGlobal.Contains (theObject)) + { + for (NCollection_Map::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next()) { - theSelector->AddSelectionToObject (theObject, aNewSel); + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key(); + aSelector->AddSelectionToObject (theObject, aNewSel); aNewSel->UpdateBVHStatus (SelectMgr_TBU_None); } } - else if (theObject->Selection (theMode)->IsEmpty()) + else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject)) { - if (theObject->Selection (theMode)->BVHUpdateStatus() == SelectMgr_TBU_Remove) + for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next()) { - Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode); - theObject->AddSelection (aNewSel, theMode); - theObject->Selection (theMode)->UpdateBVHStatus (SelectMgr_TBU_Remove); - theObject->Selection (theMode)->SetSelectionState (SelectMgr_SOS_Deactivated); + aSelectorIter.Value()->AddSelectionToObject (theObject, aNewSel); + aNewSel->UpdateBVHStatus (SelectMgr_TBU_None); } } } @@ -902,8 +928,10 @@ void SelectMgr_SelectionManager::loadMode (const Handle(SelectMgr_SelectableObje void SelectMgr_SelectionManager::SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject, const SelectMgr_TypeOfUpdate theType) { - for (theObject->Init(); theObject->More(); theObject->Next()) - theObject->CurrentSelection()->UpdateStatus (theType); + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next()) + { + aSelIter.Value()->UpdateStatus (theType); + } } //======================================================================= @@ -914,8 +942,10 @@ void SelectMgr_SelectionManager::SetUpdateMode (const Handle(SelectMgr_Selectabl const Standard_Integer theMode, const SelectMgr_TypeOfUpdate theType) { - if (theObject->HasSelection (theMode)) - theObject->Selection (theMode)->UpdateStatus (theType); + if (const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode)) + { + aSel->UpdateStatus (theType); + } } //======================================================================= @@ -928,24 +958,25 @@ void SelectMgr_SelectionManager::SetSelectionSensitivity (const Handle(SelectMgr const Standard_Integer theMode, const Standard_Integer theNewSens) { - Standard_ASSERT_RAISE (theNewSens > 0, - "Error! Selection sensitivity have positive value."); + Standard_ASSERT_RAISE (theNewSens > 0, "Error! Selection sensitivity have positive value."); + if (theObject.IsNull()) + { + return; + } - if (theObject.IsNull() || !theObject->HasSelection (theMode)) + const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode); + if (theObject.IsNull()) + { return; + } - Handle(SelectMgr_Selection) aSel = theObject->Selection (theMode); const Standard_Integer aPrevSens = aSel->Sensitivity(); aSel->SetSensitivity (theNewSens); - - if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject))) - return; - if (myGlobal.Contains (theObject)) { - for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) + for (NCollection_Map::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) { - Handle(SelectMgr_ViewerSelector) aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key()); + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key(); if (aSelector->Contains (theObject)) { aSelector->myTolerances.Decrement (aPrevSens); @@ -975,9 +1006,9 @@ void SelectMgr_SelectionManager::UpdateSelection (const Handle(SelectMgr_Selecta { if (myGlobal.Contains (theObject)) { - for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) + for (NCollection_Map::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next()) { - Handle(SelectMgr_ViewerSelector) aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key()); + const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key(); if (aSelector->Contains (theObject)) { aSelector->MoveSelectableObject (theObject); diff --git a/src/SelectMgr/SelectMgr_SelectionManager.hxx b/src/SelectMgr/SelectMgr_SelectionManager.hxx index e3e4854e18..8c9ed2248d 100644 --- a/src/SelectMgr/SelectMgr_SelectionManager.hxx +++ b/src/SelectMgr/SelectMgr_SelectionManager.hxx @@ -17,33 +17,21 @@ #ifndef _SelectMgr_SelectionManager_HeaderFile #define _SelectMgr_SelectionManager_HeaderFile -#include -#include - -#include #include -#include #include -#include -#include #include -class SelectMgr_SelectableObject; - +#include -class SelectMgr_SelectionManager; -DEFINE_STANDARD_HANDLE(SelectMgr_SelectionManager, Standard_Transient) +class SelectMgr_SelectableObject; -//! A framework to manage selection from the point of -//! view of viewer selectors. These can be added and -//! removed, and selection modes can be activated and -//! deactivated. In addition, objects may be known to all -//! selectors or only to some. +//! A framework to manage selection from the point of view of viewer selectors. +//! These can be added and removed, and selection modes can be activated and deactivated. +//! In addition, objects may be known to all selectors or only to some. class SelectMgr_SelectionManager : public Standard_Transient { - + DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectionManager, Standard_Transient) public: - //! Constructs an empty selection manager object. Standard_EXPORT SelectMgr_SelectionManager(); @@ -65,7 +53,7 @@ public: Standard_EXPORT void Load (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = -1); //! Loads and computes selection mode theMode (if it is not equal to -1) and adds selectable object to BVH tree. - //! Does not perform check of existance of theObject in global context before addition, but adds theSelector to local context. + //! Does not perform check of existence of theObject in global context before addition, but adds theSelector to local context. Standard_EXPORT void Load (const Handle(SelectMgr_SelectableObject)& theObject, const Handle(SelectMgr_ViewerSelector)& theSelector, const Standard_Integer theMode = -1); //! Removes selectable object theObject from all viewer selectors it was added to previously, removes it from all contexts @@ -78,26 +66,36 @@ public: //! Activates the selection mode theMode in the selector theSelector for the selectable object anObject. //! By default, theMode is equal to 0. If theSelector is set to default (NULL), the selection with the mode theMode //! will be activated in all the viewers available. - Standard_EXPORT void Activate (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = 0, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL); + Standard_EXPORT void Activate (const Handle(SelectMgr_SelectableObject)& theObject, + const Standard_Integer theMode = 0, + const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()); //! Deactivates mode theMode of theObject in theSelector. If theMode value is set to default (-1), all - //! avtive selection modes will be deactivated. Likewise, if theSelector value is set to default (NULL), theMode + //! active selection modes will be deactivated. Likewise, if theSelector value is set to default (NULL), theMode //! will be deactivated in all viewer selectors. - Standard_EXPORT void Deactivate (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = -1, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL); + Standard_EXPORT void Deactivate (const Handle(SelectMgr_SelectableObject)& theObject, + const Standard_Integer theMode = -1, + const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()); //! Returns true if the selection with theMode is active for the selectable object theObject and selector theSelector. //! If all parameters are set to default values, it returns it there is any active selection in any known viewer selector for //! object theObject. - Standard_EXPORT Standard_Boolean IsActivated (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = -1, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL) const; + Standard_EXPORT Standard_Boolean IsActivated (const Handle(SelectMgr_SelectableObject)& theObject, + const Standard_Integer theMode = -1, + const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()) const; //! Removes sensitive entities from all viewer selectors //! after method Clear() was called to the selection they belonged to //! or it was recomputed somehow. - Standard_EXPORT void ClearSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj, const Standard_Integer theMode = -1, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL); + Standard_EXPORT void ClearSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj, + const Standard_Integer theMode = -1, + const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()); - //! Re-adds newely calculated sensitive entities of recomputed selection + //! Re-adds newly calculated sensitive entities of recomputed selection //! defined by mode theMode to all viewer selectors contained that selection. - Standard_EXPORT void RestoreSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj, const Standard_Integer theMode = -1, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL); + Standard_EXPORT void RestoreSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj, + const Standard_Integer theMode = -1, + const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()); //! Recomputes activated selections of theObject for all known viewer selectors according to theMode specified. //! If theMode is set to default (-1), then all activated selections will be recomputed. If theIsForce is set to true, @@ -128,8 +126,6 @@ public: //! Re-adds selectable object in BVHs in all viewer selectors. Standard_EXPORT void UpdateSelection (const Handle(SelectMgr_SelectableObject)& theObj); - DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectionManager,Standard_Transient) - protected: //! Recomputes given selection mode and updates BVHs in all viewer selectors @@ -137,30 +133,27 @@ protected: const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode); - private: - //! Loads and creates selection structures for object theObject with mode theMode in specified //! viewer selector theSelector. If theSelector is set to default value (NULL), the selection mode //! created will be added to all known viewer selectors. - Standard_EXPORT void loadMode (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode, const Handle(SelectMgr_ViewerSelector)& theSelector = NULL); + Standard_EXPORT void loadMode (const Handle(SelectMgr_SelectableObject)& theObject, + const Standard_Integer theMode, + const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()); //! Internal function that marks 1st level BVH of the object theObj as //! outdated. - Standard_EXPORT void rebuildSelectionStructures (const Handle(SelectMgr_ViewerSelector)& theSelector = NULL); + Standard_EXPORT void rebuildSelectionStructures (const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()); - TColStd_MapOfTransient mySelectors; - TColStd_MapOfTransient myGlobal; - SelectMgr_DataMapOfObjectSelectors myLocal; +private: + NCollection_Map mySelectors; + NCollection_Map myGlobal; + SelectMgr_DataMapOfObjectSelectors myLocal; }; - - - - - +DEFINE_STANDARD_HANDLE(SelectMgr_SelectionManager, Standard_Transient) #endif // _SelectMgr_SelectionManager_HeaderFile diff --git a/src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx b/src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx index 7bb41a6d98..f66fe87a8c 100644 --- a/src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx +++ b/src/SelectMgr/SelectMgr_SensitiveEntitySet.cxx @@ -52,14 +52,14 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_SensitiveEntit //======================================================================= void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_Selection)& theSelection) { - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - if (!theSelection->Sensitive()->BaseSensitive()->IsKind (STANDARD_TYPE(Select3D_SensitiveEntity))) + if (!aSelEntIter.Value()->BaseSensitive()->IsKind (STANDARD_TYPE(Select3D_SensitiveEntity))) { - theSelection->Sensitive()->ResetSelectionActiveStatus(); + aSelEntIter.Value()->ResetSelectionActiveStatus(); continue; } - mySensitives.Add (theSelection->Sensitive()); + mySensitives.Add (aSelEntIter.Value()); } MarkDirty(); } @@ -71,11 +71,13 @@ void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_Selection)& th //======================================================================= void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& theSelection) { - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - Standard_Integer anEntIdx = mySensitives.FindIndex (theSelection->Sensitive()); - if (!anEntIdx) + const Standard_Integer anEntIdx = mySensitives.FindIndex (aSelEntIter.Value()); + if (anEntIdx == 0) + { continue; + } if (anEntIdx != mySensitives.Size()) { diff --git a/src/SelectMgr/SelectMgr_ViewerSelector.cxx b/src/SelectMgr/SelectMgr_ViewerSelector.cxx index e29538c8d6..2d3cabfbb2 100644 --- a/src/SelectMgr/SelectMgr_ViewerSelector.cxx +++ b/src/SelectMgr/SelectMgr_ViewerSelector.cxx @@ -104,9 +104,9 @@ myEntityIdx (0) //================================================== void SelectMgr_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSelection) { - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - theSelection->Sensitive()->SetActiveForSelection(); + aSelEntIter.Value()->SetActiveForSelection(); } theSelection->SetSelectionState (SelectMgr_SOS_Activated); @@ -121,9 +121,9 @@ void SelectMgr_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theS //================================================== void SelectMgr_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theSelection) { - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - theSelection->Sensitive()->ResetSelectionActiveStatus(); + aSelEntIter.Value()->ResetSelectionActiveStatus(); } theSelection->SetSelectionState (SelectMgr_SOS_Deactivated); @@ -670,15 +670,15 @@ Standard_Boolean SelectMgr_ViewerSelector::Modes (const Handle(SelectMgr_Selecta const SelectMgr_StateOfSelection theWantedState) const { Standard_Boolean hasActivatedStates = Contains (theSelectableObject); - for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theSelectableObject->Selections()); aSelIter.More(); aSelIter.Next()) { if (theWantedState == SelectMgr_SOS_Any) { - theModeList.Append (theSelectableObject->CurrentSelection()->Mode()); + theModeList.Append (aSelIter.Value()->Mode()); } - else if (theWantedState == theSelectableObject->CurrentSelection()->GetSelectionState()) + else if (theWantedState == aSelIter.Value()->GetSelectionState()) { - theModeList.Append (theSelectableObject->CurrentSelection()->Mode()); + theModeList.Append (aSelIter.Value()->Mode()); } } @@ -695,15 +695,9 @@ Standard_Boolean SelectMgr_ViewerSelector::IsActive (const Handle(SelectMgr_Sele if (!Contains (theSelectableObject)) return Standard_False; - for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next()) - { - if (theMode == theSelectableObject->CurrentSelection()->Mode()) - { - return theSelectableObject->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated; - } - } - - return Standard_False; + const Handle(SelectMgr_Selection)& aSel = theSelectableObject->Selection (theMode); + return !aSel.IsNull() + && aSel->GetSelectionState() == SelectMgr_SOS_Activated; } //================================================== @@ -716,15 +710,9 @@ Standard_Boolean SelectMgr_ViewerSelector::IsInside (const Handle(SelectMgr_Sele if (!Contains (theSelectableObject)) return Standard_False; - for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next()) - { - if (theMode == theSelectableObject->CurrentSelection()->Mode()) - { - return theSelectableObject->CurrentSelection()->GetSelectionState() != SelectMgr_SOS_Unknown; - } - } - - return Standard_False; + const Handle(SelectMgr_Selection)& aSel = theSelectableObject->Selection (theMode); + return !aSel.IsNull() + && aSel->GetSelectionState() != SelectMgr_SOS_Unknown; } @@ -746,22 +734,12 @@ SelectMgr_StateOfSelection SelectMgr_ViewerSelector::Status (const Handle(Select TCollection_AsciiString SelectMgr_ViewerSelector::Status (const Handle(SelectMgr_SelectableObject)& theSelectableObject) const { TCollection_AsciiString aStatus ("Status Object :\n\t"); - - for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theSelectableObject->Selections()); aSelIter.More(); aSelIter.Next()) { - if (theSelectableObject->CurrentSelection()->GetSelectionState() != SelectMgr_SOS_Unknown) + if (aSelIter.Value()->GetSelectionState() != SelectMgr_SOS_Unknown) { - aStatus = aStatus + "Mode " + - TCollection_AsciiString (theSelectableObject->CurrentSelection()->Mode()) + - " present - "; - if (theSelectableObject->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated) - { - aStatus = aStatus + " Active \n\t"; - } - else - { - aStatus = aStatus + " Inactive \n\t"; - } + aStatus = aStatus + "Mode " + TCollection_AsciiString (aSelIter.Value()->Mode()) + " present - " + + (aSelIter.Value()->GetSelectionState() == SelectMgr_SOS_Activated ? " Active \n\t" : " Inactive \n\t"); } } diff --git a/src/StdSelect/StdSelect_BRepSelectionTool.cxx b/src/StdSelect/StdSelect_BRepSelectionTool.cxx index 5a69d1846e..d7f619598b 100644 --- a/src/StdSelect/StdSelect_BRepSelectionTool.cxx +++ b/src/StdSelect/StdSelect_BRepSelectionTool.cxx @@ -73,9 +73,9 @@ //================================================== void StdSelect_BRepSelectionTool::PreBuildBVH (const Handle(SelectMgr_Selection)& theSelection) { - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - const Handle(SelectBasics_SensitiveEntity)& aSensitive = theSelection->Sensitive()->BaseSensitive(); + const Handle(SelectBasics_SensitiveEntity)& aSensitive = aSelEntIter.Value()->BaseSensitive(); if (aSensitive->NbSubElements() >= BVH_PRIMITIVE_LIMIT) { aSensitive->BVH(); @@ -188,10 +188,9 @@ void StdSelect_BRepSelectionTool::Load (const Handle(SelectMgr_Selection)& theSe theMaxParam); // loading of selectables... - for (theSelection->Init(); theSelection->More(); theSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - Handle(SelectMgr_EntityOwner) anOwner - = Handle(SelectMgr_EntityOwner)::DownCast (theSelection->Sensitive()->BaseSensitive()->OwnerId()); + Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelEntIter.Value()->BaseSensitive()->OwnerId()); anOwner->Set (theSelectableObj); } diff --git a/src/StdSelect/StdSelect_ViewerSelector3d.cxx b/src/StdSelect/StdSelect_ViewerSelector3d.cxx index e6663530bb..b39c6005a2 100644 --- a/src/StdSelect/StdSelect_ViewerSelector3d.cxx +++ b/src/StdSelect/StdSelect_ViewerSelector3d.cxx @@ -187,28 +187,24 @@ void StdSelect_ViewerSelector3d::Pick (const TColgp_Array1OfPnt2d& thePolyline, //======================================================================= void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theView) { - SelectMgr_SelectableObjectSet::Iterator aSelectableIt (mySelectableObjects); - - for (; aSelectableIt.More(); aSelectableIt.Next()) + for (SelectMgr_SelectableObjectSet::Iterator aSelectableIt (mySelectableObjects); aSelectableIt.More(); aSelectableIt.Next()) { - const Handle (SelectMgr_SelectableObject)& anObj = aSelectableIt.Value(); - Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (theView->Viewer()->StructureManager()); - - for (anObj->Init(); anObj->More(); anObj->Next()) + const Handle (SelectMgr_SelectableObject)& anObj = aSelectableIt.Value(); + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) { - if (anObj->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated) + if (aSelIter.Value()->GetSelectionState() == SelectMgr_SOS_Activated) { - computeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), Handle(Graphic3d_TransformPers)()); + computeSensitivePrs (aStruct, aSelIter.Value(), anObj->Transformation(), Handle(Graphic3d_TransformPers)()); } } myStructs.Append (aStruct); } - for (Standard_Integer aStructIdx = 1; aStructIdx <= myStructs.Length(); ++aStructIdx) + for (Graphic3d_SequenceOfStructure::Iterator aStructIter (myStructs); aStructIter.More(); aStructIter.Next()) { - Handle(Graphic3d_Structure)& aStruct = myStructs.ChangeValue (aStructIdx); + Handle(Graphic3d_Structure)& aStruct = aStructIter.ChangeValue(); aStruct->SetDisplayPriority (10); aStruct->Display(); } @@ -222,11 +218,10 @@ void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theVi //======================================================================= void StdSelect_ViewerSelector3d::ClearSensitive (const Handle(V3d_View)& theView) { - for (Standard_Integer aStructIdx = 1; aStructIdx <= myStructs.Length(); ++aStructIdx) + for (Graphic3d_SequenceOfStructure::Iterator aStructIter (myStructs); aStructIter.More(); aStructIter.Next()) { - myStructs.Value (aStructIdx)->Remove(); + aStructIter.ChangeValue()->Remove(); } - myStructs.Clear(); if (!theView.IsNull()) @@ -274,25 +269,20 @@ void StdSelect_ViewerSelector3d::computeSensitivePrs (const Handle(Graphic3d_Str Handle(Graphic3d_Group) aSensGroup = theStructure->NewGroup(); Quantity_Color aColor (Quantity_NOC_INDIANRED3); - Handle(Graphic3d_AspectMarker3d) aMarkerAspect = - new Graphic3d_AspectMarker3d (Aspect_TOM_O_PLUS, aColor, 2.0); + Handle(Graphic3d_AspectMarker3d) aMarkerAspect =new Graphic3d_AspectMarker3d (Aspect_TOM_O_PLUS, aColor, 2.0); aSensGroup->SetPrimitivesAspect (aMarkerAspect); - aSensGroup->SetPrimitivesAspect ( - new Graphic3d_AspectLine3d (Quantity_NOC_GRAY40, Aspect_TOL_SOLID, 2.0)); + aSensGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_GRAY40, Aspect_TOL_SOLID, 2.0)); Handle(Graphic3d_Group) anAreaGroup = theStructure->NewGroup(); - anAreaGroup->SetPrimitivesAspect ( - new Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0)); + anAreaGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0)); TColgp_SequenceOfPnt aSeqLines, aSeqFree; TColStd_SequenceOfInteger aSeqBnds; - - for (theSel->Init(); theSel->More(); theSel->Next()) + for (NCollection_Vector::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - Handle(Select3D_SensitiveEntity) Ent = - Handle(Select3D_SensitiveEntity)::DownCast(theSel->Sensitive()->BaseSensitive()); + Handle(Select3D_SensitiveEntity) Ent = Handle(Select3D_SensitiveEntity)::DownCast(aSelEntIter.Value()->BaseSensitive()); const Standard_Boolean hasloc = theLoc.Form() != gp_Identity; //============== @@ -741,12 +731,12 @@ namespace for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelObjects); anObjIter.More(); anObjIter.Next()) { const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value(); - for (anObj->Init(); anObj->More(); anObj->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection(); - for (aSel->Init(); aSel->More(); aSel->Next()) + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + for (NCollection_Vector::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - const Handle(SelectMgr_SensitiveEntity)& aSens = aSel->Sensitive(); + const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value(); if (!myMapEntityColors.IsBound (aSens->BaseSensitive())) { Quantity_Color aColor; @@ -902,12 +892,12 @@ namespace for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelObjects); anObjIter.More(); anObjIter.Next()) { const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value(); - for (anObj->Init(); anObj->More(); anObj->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection(); - for (aSel->Init(); aSel->More(); aSel->Next()) + const Handle(SelectMgr_Selection)& aSel = aSelIter.Value(); + for (NCollection_Vector::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - const Handle(SelectMgr_SensitiveEntity)& aSens = aSel->Sensitive(); + const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value(); const Handle(SelectBasics_EntityOwner)& anOwner = aSens->BaseSensitive()->OwnerId(); if (!myMapOwnerColors.IsBound (anOwner)) { @@ -980,12 +970,12 @@ namespace Standard_Integer aSelectionMode = -1; const Handle(SelectMgr_SelectableObject)& aSelectable = myMainSel->Picked (thePicked)->Selectable(); const Handle(SelectBasics_SensitiveEntity)& anEntity = myMainSel->PickedEntity (thePicked); - for (aSelectable->Init(); aSelectable->More(); aSelectable->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (aSelectable->Selections()); aSelIter.More(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSelection = aSelectable->CurrentSelection(); - for (aSelection->Init(); aSelection->More(); aSelection->Next()) + const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value(); + for (NCollection_Vector::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - if (aSelection->Sensitive()->BaseSensitive() == anEntity) + if (aSelEntIter.Value()->BaseSensitive() == anEntity) { aSelectionMode = aSelection->Mode(); break; diff --git a/tests/bugs/vis/bug24966 b/tests/bugs/vis/bug24966 index 786db06438..1a398ef581 100644 --- a/tests/bugs/vis/bug24966 +++ b/tests/bugs/vis/bug24966 @@ -1,17 +1,12 @@ puts "============" -puts "OCC24966" +puts "0024966: Visualization - Problem in local selection mode with selected objects staying in the viewer after erase" +puts "Selected entity owners coming from decomposition are not erased in local selection context" puts "============" puts "" -#################################################################################### -# Visualization - Problem in local selection mode with selected objects staying -# in the viewer after erase -# Selected entity owners coming from decomposition are not erased in local selection -# context -#################################################################################### +pload MODELING VISUALIZATION +vclear vinit View1 -pload ALL -vinit vertex p1 100 100 0 vertex p2 150 300 0 @@ -23,8 +18,6 @@ vselmode e1 1 1 -local vselect 0 0 2500 2500 verase -local -if { "[vreadpixel 261 204 rgb name]" != "BLACK" } { - puts "Error : Selection is not erased." -} +if { "[vreadpixel 261 204 rgb name]" != "BLACK" } { puts "Error : Selection is not erased." } vdump ${imagedir}/${casename}.png diff --git a/tests/bugs/vis/bug24996 b/tests/bugs/vis/bug24996 index 95635f7b43..90f150b875 100644 --- a/tests/bugs/vis/bug24996 +++ b/tests/bugs/vis/bug24996 @@ -1,23 +1,18 @@ puts "============" -puts "CR24996" +puts "0024996: Visualization - newly displayed objects are clipped until first camera movement" puts "============" puts "" -####################################################################### -# Visualization - newly displayed objects are clipped until first camera movement -####################################################################### box b1 0 0 0 1 2 3 box b2 3 2 1 1 2 3 box b3 5 -4 0 1 2 3 -vinit vclear +vinit View1 vaxo -vsetdispmode 0 -vdisplay b1 +vdisplay -dispMode 0 b1 vfit vzoom 0.25 -vdisplay b2 b3 +vdisplay -dispMode 0 b2 b3 -set anImage ${imagedir}/${casename}.png -vdump ${anImage} +vdump ${imagedir}/${casename}.png diff --git a/tools/VInspector/VInspector_ItemEntityOwner.cxx b/tools/VInspector/VInspector_ItemEntityOwner.cxx index 2201a72705..b2ea7a4e3e 100644 --- a/tools/VInspector/VInspector_ItemEntityOwner.cxx +++ b/tools/VInspector/VInspector_ItemEntityOwner.cxx @@ -146,12 +146,12 @@ void VInspector_ItemEntityOwner::Init() int aRowId = Row(); int aCurrentIndex = 0; - for (anIO->Init(); anIO->More() && anOwner.IsNull(); anIO->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More() && anOwner.IsNull(); aSelIter.Next()) { - const Handle(SelectMgr_Selection)& aSelection = anIO->CurrentSelection(); - for (aSelection->Init(); aSelection->More() && anOwner.IsNull(); aSelection->Next()) + const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value(); + for (NCollection_Vector::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More() && anOwner.IsNull(); aSelEntIter.Next()) { - Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive(); + Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value(); const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive(); if (!aBase.IsNull()) { diff --git a/tools/VInspector/VInspector_ItemPresentableObject.cxx b/tools/VInspector/VInspector_ItemPresentableObject.cxx index 47664b1ad7..f5df73350a 100644 --- a/tools/VInspector/VInspector_ItemPresentableObject.cxx +++ b/tools/VInspector/VInspector_ItemPresentableObject.cxx @@ -152,15 +152,10 @@ QVariant VInspector_ItemPresentableObject::initValue (int theItemRole) const // ======================================================================= int VInspector_ItemPresentableObject::initRowCount() const { - int aRows = 0; Handle(AIS_InteractiveObject) anIO = GetInteractiveObject(); - if (anIO.IsNull()) - return aRows; - // iteration through sensitive privitives - for (anIO->Init(); anIO->More(); anIO->Next()) - aRows++; - - return aRows; + return !anIO.IsNull() + ? anIO->Selections().Size() + : 0; } // ======================================================================= diff --git a/tools/VInspector/VInspector_ItemSelection.cxx b/tools/VInspector/VInspector_ItemSelection.cxx index faaa5b14f6..4a4f79fed5 100644 --- a/tools/VInspector/VInspector_ItemSelection.cxx +++ b/tools/VInspector/VInspector_ItemSelection.cxx @@ -44,12 +44,8 @@ Handle(SelectMgr_Selection) VInspector_ItemSelection::getSelection() const // ======================================================================= int VInspector_ItemSelection::initRowCount() const { - int aRows = 0; Handle(SelectMgr_Selection) aSelection = getSelection(); - for (aSelection->Init(); aSelection->More(); aSelection->Next()) - aRows++; - - return aRows; + return aSelection->Entities().Size(); } // ======================================================================= @@ -88,9 +84,9 @@ QVariant VInspector_ItemSelection::initValue (int theItemRole) const if (aState == SelectMgr_SOS_Activated || aState == SelectMgr_SOS_Any) { Handle(AIS_InteractiveContext) aContext = GetContext(); - for (mySelection->Init(); mySelection->More(); mySelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (mySelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - const Handle(SelectBasics_EntityOwner)& anOwner = mySelection->Sensitive()->BaseSensitive()->OwnerId(); + const Handle(SelectBasics_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId(); if (VInspector_Tools::IsOwnerSelected(aContext, anOwner)) aNbSelected++; } @@ -145,11 +141,11 @@ void VInspector_ItemSelection::Init() int aRowId = Row(); int aCurrentId = 0; - for (anIO->Init(); anIO->More(); anIO->Next(), aCurrentId++) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next(), aCurrentId++) { if (aCurrentId != aRowId) continue; - mySelection = anIO->CurrentSelection(); + mySelection = aSelIter.Value(); break; } TreeModel_ItemBase::Init(); diff --git a/tools/VInspector/VInspector_ItemSensitiveEntity.cxx b/tools/VInspector/VInspector_ItemSensitiveEntity.cxx index 49044062e8..c3ecbac90f 100644 --- a/tools/VInspector/VInspector_ItemSensitiveEntity.cxx +++ b/tools/VInspector/VInspector_ItemSensitiveEntity.cxx @@ -155,11 +155,11 @@ void VInspector_ItemSensitiveEntity::Init() int aRowId = Row(); int aCurrentId = 0; - for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++) + for (NCollection_Vector::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++) { if (aCurrentId != aRowId) continue; - myEntity = aSelection->Sensitive(); + myEntity = aSelEntIter.Value(); break; } TreeModel_ItemBase::Init(); diff --git a/tools/VInspector/VInspector_Tools.cxx b/tools/VInspector/VInspector_Tools.cxx index 414f349eb3..3166d9c929 100644 --- a/tools/VInspector/VInspector_Tools.cxx +++ b/tools/VInspector/VInspector_Tools.cxx @@ -144,14 +144,14 @@ NCollection_List VInspector_Tools::ContextOwne Handle(AIS_InteractiveObject) anIO = aIt.Value(); if (anIO.IsNull()) continue; - for (anIO->Init(); anIO->More(); anIO->Next()) + for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next()) { - Handle(SelectMgr_Selection) aSelection = anIO->CurrentSelection(); + Handle(SelectMgr_Selection) aSelection = aSelIter.Value(); if (aSelection.IsNull()) continue; - for (aSelection->Init(); aSelection->More(); aSelection->Next()) + for (NCollection_Vector::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next()) { - Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive(); + Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value(); if (anEntity.IsNull()) continue; const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();