From: vpa Date: Fri, 20 Nov 2015 11:10:52 +0000 (+0300) Subject: 0026905: Visualization - cosmetic fixes in selection methods of AIS_InteractiveContext X-Git-Tag: V7_0_0_beta~98 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=95081657f1e2fb3568242eaa59e4ee6e62fc34d3;p=occt-copy.git 0026905: Visualization - cosmetic fixes in selection methods of AIS_InteractiveContext - selection mode in AIS_InteractiveContext::AddOrRemoveSelected is corrected; - AIS_InteractiveContext::IsSelected returns object's state instead of global status. --- diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index 901448c382..894dfe250e 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -1023,16 +1023,20 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject, const Standard_Boolean theToUpdateViewer) { - if (!theObject->HasInteractiveContext()) - theObject->SetContext (this); + if (theObject.IsNull()) + return; if (HasOpenedContext()) return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer); - if (theObject.IsNull() || !myObjects.IsBound (theObject) || !theObject->HasSelection (0)) + const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode(); + if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode)) return; - const Handle(SelectMgr_Selection)& aSel = theObject->Selection (0); + if (!theObject->HasInteractiveContext()) + theObject->SetContext (this); + + const Handle(SelectMgr_Selection)& aSel = theObject->Selection (aGlobalSelMode); if (aSel->IsEmpty()) return; @@ -1139,10 +1143,10 @@ Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_Interactiv break; } } - if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated) + if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull()) return Standard_False; - return myObjects (theObj)->IsHilighted(); + return theObj->GlobalSelOwner()->State() == 1; } //=======================================================================