From: nds Date: Wed, 12 Feb 2020 22:55:17 +0000 (+0300) Subject: 0030784: Visualization - check if selectable of owner in internal container in AIS_In... X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=6d713d5264bbfec0b5fa8322f1502e964a0e9855;p=occt-copy.git 0030784: Visualization - check if selectable of owner in internal container in AIS_InteractiveContext before using --- diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 4134d1022c..da07cab1fe 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -126,7 +126,12 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject return; } - const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode); + Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (theObj); + if (!aStatusPtr) + { + return; + } + const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, (*aStatusPtr)->DisplayMode()); const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); if (aGlobOwner.IsNull()) @@ -175,20 +180,16 @@ void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& th { const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value(); const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); - Handle(AIS_GlobalStatus) aStatus; - if (!myObjects.Find (anInteractive, aStatus)) - { - continue; - } + Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anInteractive); if (anOwner->IsAutoHilight()) { anOwner->Unhilight (myMainPM); if (theIsToHilightSubIntensity) { - if (aStatus->IsSubIntensityOn()) + if (aStatusPtr && (*aStatusPtr)->IsSubIntensityOn()) { - const Standard_Integer aHiMode = getHilightMode (anInteractive, aStatus->HilightStyle(), aStatus->DisplayMode()); + const Standard_Integer aHiMode = getHilightMode (anInteractive, (*aStatusPtr)->HilightStyle(), (*aStatusPtr)->DisplayMode()); highlightWithSubintensity (anOwner, aHiMode); } } @@ -197,9 +198,9 @@ void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& th { anObjToClear.Add (anInteractive); } - if (anOwner == anInteractive->GlobalSelOwner()) + if (aStatusPtr && anOwner == anInteractive->GlobalSelOwner()) { - aStatus->SetHilightStatus (Standard_False); + (*aStatusPtr)->SetHilightStatus (Standard_False); } } for (NCollection_IndexedMap::Iterator anIter (anObjToClear); anIter.More(); anIter.Next()) @@ -579,7 +580,16 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_SelectionScheme theSe }*/ AIS_NListOfEntityOwner aPickedOwners; - aPickedOwners.Append (myLastPicked); + if (!myLastPicked.IsNull() && + myLastPicked->HasSelectable()) + { + Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(myLastPicked->Selectable()); + if (!anIO.IsNull() && + myObjects.IsBound(anIO)) + { + aPickedOwners.Append (myLastPicked); + } + } return Select (aPickedOwners, theSelScheme); } @@ -711,11 +721,13 @@ void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theO continue; const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner); - Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj); + Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj); + if (!aStatusPtr) + continue; if (anOwner == anObj->GlobalSelOwner()) { - aState->SetHilightStatus (Standard_True); - aState->SetHilightStyle (anObjSelStyle); + (*aStatusPtr)->SetHilightStatus (Standard_True); + (*aStatusPtr)->SetHilightStyle (anObjSelStyle); } if (!anOwner->IsAutoHilight()) { @@ -733,7 +745,7 @@ void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theO } else { - const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, aState->DisplayMode()); + const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, (*aStatusPtr)->DisplayMode()); anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode); } } @@ -837,7 +849,9 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t } if (aSelOwner == aSelectable->GlobalSelOwner()) { - myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False); + Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (aSelectable); + if (aStatusPtr) + (*aStatusPtr)->SetHilightStatus (Standard_False); } } @@ -955,7 +969,13 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO if (myAutoHilight) { const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); - Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj); + if (!myObjects.IsBound(anObj)) // e.g. AIS_ViewCubeFlat is not displayed + return; + + Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj); + if (!aStatusPtr) + return; + if (theOwner->IsSelected()) { highlightSelected (theOwner); @@ -966,7 +986,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO anOwners.Append (theOwner); unhighlightOwners (anOwners); - aStatus->SetHilightStyle (Handle(Prs3d_Drawer)()); + (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)()); } }