1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-24 13:50:49 +03:00

0030784: Visualization - check if selectable of owner in internal container in AIS_InteractiveContext before using

This commit is contained in:
nds
2019-10-18 15:32:30 +03:00
parent 460abf4e0f
commit b4baade508

View File

@@ -123,8 +123,12 @@ void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject
return; return;
} }
const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj); Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (theObj);
const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, aStatus->DisplayMode()); if (!aStatusPtr)
{
return;
}
const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, (*aStatusPtr)->DisplayMode());
const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner(); const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
if (aGlobOwner.IsNull()) if (aGlobOwner.IsNull())
@@ -173,16 +177,16 @@ void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& th
{ {
const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value(); const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anInteractive); Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anInteractive);
if (anOwner->IsAutoHilight()) if (anOwner->IsAutoHilight())
{ {
anOwner->Unhilight (myMainPM); anOwner->Unhilight (myMainPM);
if (theIsToHilightSubIntensity) if (theIsToHilightSubIntensity)
{ {
if (!aStatus.IsNull() && 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); highlightWithSubintensity (anOwner, aHiMode);
} }
} }
@@ -191,9 +195,9 @@ void AIS_InteractiveContext::unhighlightOwners (const AIS_NListOfEntityOwner& th
{ {
anObjToClear.Add (anInteractive); anObjToClear.Add (anInteractive);
} }
if (!aStatus.IsNull() && anOwner == anInteractive->GlobalSelOwner()) if (aStatusPtr && anOwner == anInteractive->GlobalSelOwner())
{ {
aStatus->SetHilightStatus (Standard_False); (*aStatusPtr)->SetHilightStatus (Standard_False);
} }
} }
for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next()) for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
@@ -714,11 +718,13 @@ void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theO
continue; continue;
const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner); 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 (theToUseObjectDisplayMode && anOwner == anObj->GlobalSelOwner()) if (theToUseObjectDisplayMode && anOwner == anObj->GlobalSelOwner())
{ {
aState->SetHilightStatus (Standard_True); (*aStatusPtr)->SetHilightStatus (Standard_True);
aState->SetHilightStyle (anObjSelStyle); (*aStatusPtr)->SetHilightStyle (anObjSelStyle);
} }
if (!anOwner->IsAutoHilight()) if (!anOwner->IsAutoHilight())
{ {
@@ -736,7 +742,7 @@ void AIS_InteractiveContext::highlightOwners (const AIS_NListOfEntityOwner& theO
} }
else else
{ {
const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, theToUseObjectDisplayMode ? aState->DisplayMode() : -1); const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, theToUseObjectDisplayMode ? (*aStatusPtr)->DisplayMode() : -1);
anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode); anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
} }
} }
@@ -840,7 +846,9 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
} }
if (aSelOwner == aSelectable->GlobalSelOwner()) if (aSelOwner == aSelectable->GlobalSelOwner())
{ {
myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False); Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (aSelectable);
if (aStatusPtr)
(*aStatusPtr)->SetHilightStatus (Standard_False);
} }
} }
@@ -960,7 +968,11 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
if (!myObjects.IsBound(anObj)) // e.g. AIS_ViewCubeFlat is not displayed if (!myObjects.IsBound(anObj)) // e.g. AIS_ViewCubeFlat is not displayed
return; return;
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (anObj);
if (!aStatusPtr)
return;
if (theOwner->IsSelected()) if (theOwner->IsSelected())
{ {
highlightSelected (theOwner); highlightSelected (theOwner);
@@ -971,7 +983,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
anOwners.Append (theOwner); anOwners.Append (theOwner);
unhighlightOwners (anOwners); unhighlightOwners (anOwners);
aStatus->SetHilightStyle (Handle(Prs3d_Drawer)()); (*aStatusPtr)->SetHilightStyle (Handle(Prs3d_Drawer)());
} }
} }