From 13c556d9dea7ee1e91276f619e233f83057701e2 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 6 Jun 2019 16:40:52 +0300 Subject: [PATCH] 0030725: Visualization - remove Display calling from SetSelected methods of context AIS_InteractiveContext::Load/ClearGlobal is modified for correct processing SetSelected for child objects. As Display/Erase of object with children displays/erases these children, then the children status inside context should also be updated. --- src/AIS/AIS_InteractiveContext.cxx | 34 ++++++++++++++++++++++++---- src/AIS/AIS_InteractiveContext.hxx | 8 +++++++ src/AIS/AIS_InteractiveContext_1.cxx | 4 ++-- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 2d2d2d5f0a..af2d09bdc9 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -424,8 +424,7 @@ void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIO setContextToObject (theIObj); if (!myObjects.IsBound (theIObj)) { - Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode); - myObjects.Bind (theIObj, aStatus); + setObjectStatus (theIObj, AIS_DS_Displayed, theDispMode, theSelectionMode); myMainVwr->StructureManager()->RegisterObject (theIObj); myMainPM->Display(theIObj, theDispMode); if (theSelectionMode != -1) @@ -502,8 +501,7 @@ void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj, { Standard_Integer aDispMode, aHiMod, aSelModeDef; GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef); - Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef); - myObjects.Bind (theIObj, aStatus); + setObjectStatus (theIObj, AIS_DS_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef); myMainVwr->StructureManager()->RegisterObject (theIObj); } @@ -2056,7 +2054,7 @@ void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& t const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity mgrSelector->Remove (anObj); - myObjects.UnBind (theIObj); + setObjectStatus (theIObj, AIS_DS_None, -1, -1); myMainVwr->StructureManager()->UnregisterObject (theIObj); for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next()) @@ -2533,3 +2531,29 @@ gp_Pnt AIS_InteractiveContext::GravityPoint (const Handle(V3d_View)& theView) co { return theView->GravityPoint(); } +//======================================================================= +//function : setObjectStatus +//purpose : +//======================================================================= +void AIS_InteractiveContext::setObjectStatus (const Handle(AIS_InteractiveObject)& theIObj, + const AIS_DisplayStatus theStatus, + const Standard_Integer theDispMode, + const Standard_Integer theSelectionMode) +{ + if (theStatus != AIS_DS_None) + { + Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode); + myObjects.Bind (theIObj, aStatus); + } + else + myObjects.UnBind (theIObj); + + for (PrsMgr_ListOfPresentableObjectsIter aPrsIter (theIObj->Children()); aPrsIter.More(); aPrsIter.Next()) + { + Handle(AIS_InteractiveObject) aChild (Handle(AIS_InteractiveObject)::DownCast (aPrsIter.Value())); + if (aChild.IsNull()) + continue; + + setObjectStatus (aChild, theStatus, theDispMode, theSelectionMode); + } +} diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index 659fb5500f..fd1a1f68d9 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -1364,6 +1364,14 @@ protected: //! @name internal methods } } + //! Bind/Unbind status to object and its children + //! @param theObj [in] the object to change status + //! @param theStatus status, if NULL, unbind object + Standard_EXPORT void setObjectStatus (const Handle(AIS_InteractiveObject)& theIObj, + const AIS_DisplayStatus theStatus, + const Standard_Integer theDispyMode, + const Standard_Integer theSelectionMode); + protected: //! @name internal fields AIS_DataMapOfIOStatus myObjects; diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index caeee2d41f..f63ee3bbf9 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -811,7 +811,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t if (!myObjects.IsBound (theObject)) { - Display (theObject, Standard_False); + return; } Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner(); @@ -903,7 +903,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t } if (!myObjects.IsBound (anObject)) - Display (anObject, Standard_False); + return; if (myAutoHilight) {