]> OCCT Git - occt-copy.git/commitdiff
0030726: Visualization - change Selected state of owner in AIS_Selection
authornds <nds@opencascade.com>
Wed, 22 May 2019 10:13:33 +0000 (13:13 +0300)
committernds <nds@opencascade.com>
Wed, 22 May 2019 10:28:58 +0000 (13:28 +0300)
(cherry picked from commit de3dec2077b7d4d14fd6a6d5b72b4d290a4b88d6)

src/AIS/AIS_InteractiveContext_1.cxx
src/AIS/AIS_Selection.cxx

index 6ba03a7b8d2e98a86b3b9a4c5196354ee484865c..d143c3b7ea4e062edadf08a6a1675d8e1dc42955 100644 (file)
@@ -184,7 +184,6 @@ void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsTo
     {
       anObjToClear.Add (anInteractive);
     }
-    anOwner->SetSelected (Standard_False);
     if (anOwner == anInteractive->GlobalSelOwner())
     {
       myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
@@ -464,7 +463,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer  theXPMi
       continue;
 
     mySelection->Select (aCurOwner);
-    aCurOwner->SetSelected (Standard_True);
   }
 
   if (myAutoHilight)
@@ -505,7 +503,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
       continue;
 
     mySelection->Select (anOwner);
-    anOwner->SetSelected (Standard_True);
   }
 
   if (myAutoHilight)
@@ -606,8 +603,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the
     if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
       continue;
 
-    AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
-    anOwner->SetSelected (aSelStatus == AIS_SS_Added);
+    mySelection->Select (anOwner);
   }
 
   if (myAutoHilight)
@@ -648,8 +644,7 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d
     if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
       continue;
 
-    AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
-    anOwner->SetSelected (aSelStatus == AIS_SS_Added);
+    mySelection->Select (anOwner);
   }
 
   if (myAutoHilight)
@@ -684,7 +679,6 @@ void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdate
       aState->SetHilightStatus (Standard_True);
       aState->SetHilightStyle (anObjSelStyle);
     }
-    anOwner->SetSelected (Standard_True);
     if (!anOwner->IsAutoHilight())
     {
       NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
@@ -734,7 +728,6 @@ void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpda
       myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
     }
 
-    anOwner->SetSelected (Standard_False);
     anOwner->Unhilight (myMainPM);
   }
 
@@ -756,13 +749,6 @@ void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateVi
   {
     unhighlightSelected();
   }
-  else
-  {
-    for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
-    {
-      aSelIter.Value()->SetSelected (Standard_False);
-    }
-  }
 
   mySelection->Clear();
   if (myAutoHilight)
@@ -824,7 +810,6 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
     {
       Unhilight (aSelectable, Standard_False);
     }
-    aSelOwner->SetSelected (Standard_False);
     if (aSelOwner == aSelectable->GlobalSelOwner())
     {
       myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
@@ -849,7 +834,6 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
       HilightWithColor (theObject, anObjSelStyle, Standard_False);
     }
   }
-  anOwner->SetSelected (Standard_True);
 
   if (theToUpdateViewer)
     UpdateCurrentViewer();
@@ -896,12 +880,10 @@ void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& t
     if (!HighlightStyle (theOwner, aCustomStyle) ||
       (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
     {
-      theOwner->SetSelected (Standard_True);
       highlightSelected (theOwner);
     }
   }
 
-  theOwner->SetSelected (Standard_True);
   if (myAutoHilight && theOwner == anObject->GlobalSelOwner())
   {
     Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
@@ -950,8 +932,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
   if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
     return;
 
-  AIS_SelectStatus aSelStat = mySelection->Select (theOwner);
-  theOwner->SetSelected (aSelStat == AIS_SS_Added);
+  mySelection->Select (theOwner);
 
   if (myAutoHilight)
   {
index 1af6833a9a59386d4e1bd1b84cfaee8d4e79e409..e26bddf82834634843ed256bffbbe47d3c2665f7 100644 (file)
@@ -39,6 +39,11 @@ AIS_Selection::AIS_Selection()
 //=======================================================================
 void AIS_Selection::Clear()
 {
+  for (AIS_NListOfEntityOwner::Iterator aSelIter (Objects()); aSelIter.More(); aSelIter.Next())
+  {
+    const Handle(SelectMgr_EntityOwner) anObject = aSelIter.Value();
+    anObject->SetSelected (Standard_False);
+  }
   myresult.Clear();
   myResultMap.Clear();
   myIterator = AIS_NListOfEntityOwner::Iterator();
@@ -61,6 +66,7 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
     AIS_NListOfEntityOwner::Iterator aListIter;
     myresult.Append  (theObject, aListIter);
     myResultMap.Bind (theObject, aListIter);
+    theObject->SetSelected (Standard_True);
     return AIS_SS_Added;
   }
 
@@ -87,6 +93,7 @@ AIS_SelectStatus AIS_Selection::Select (const Handle(SelectMgr_EntityOwner)& the
 
   myresult.Remove (aListIter);
   myResultMap.UnBind (theObject);
+  theObject->SetSelected (Standard_False);
 
   // update list iterator for next object in <myresult> list if any
   if (aListIter.More())
@@ -120,5 +127,6 @@ AIS_SelectStatus AIS_Selection::AddSelect (const Handle(SelectMgr_EntityOwner)&
   AIS_NListOfEntityOwner::Iterator aListIter;
   myresult.Append  (theObject, aListIter);
   myResultMap.Bind (theObject, aListIter);
+  theObject->SetSelected (Standard_True);
   return AIS_SS_Added;
 }