]> OCCT Git - occt-copy.git/commitdiff
0030726: Visualization - change Selected state of owner in AIS_Selection
authornds <nds@opencascade.com>
Thu, 6 Jun 2019 08:50:21 +0000 (11:50 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 7 Jun 2019 12:02:39 +0000 (15:02 +0300)
AIS_InteractiveContext::IsHilighted() behavior has been changed.
It should use the same logic for owner processing like when it is highlighted. IsSelected of owner is used for selection state, not highlight.

 Without this correction, object is never shown as selected by click (Select(bool)):
 if (!HighlightStyle (theOwner, aCustomStyle) ||
    (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))

 IsSelected is already true, so the highlight style is equal to selection style, nothing to do.

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

index 9783f07982fac55aedd345642af82f833b26d95a..3ce8af6c0e0c19acd09ad6d2493d62327710af0b 100644 (file)
@@ -754,7 +754,9 @@ Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_Ent
     return myObjects (anObj)->IsHilighted();
   }
 
-  return theOwner->IsSelected();
+  const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner);
+  const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
+  return theOwner->IsHilighted (myMainPM, aHiMode);
 }
 
 //=======================================================================
index 5d73dbf143e1a141e69b4ab72f466ecfc936f5b1..2d6b9d99c724ea61e56e004dad07c2e5469eab19 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);
@@ -504,7 +503,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer  theXPMi
       continue;
 
     mySelection->Select (aCurOwner);
-    aCurOwner->SetSelected (Standard_True);
   }
 
   if (myAutoHilight)
@@ -544,7 +542,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
       continue;
 
     mySelection->Select (anOwner);
-    anOwner->SetSelected (Standard_True);
   }
 
   if (myAutoHilight)
@@ -644,8 +641,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)
@@ -685,8 +681,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)
@@ -721,7 +716,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;
@@ -771,7 +765,6 @@ void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpda
       myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
     }
 
-    anOwner->SetSelected (Standard_False);
     anOwner->Unhilight (myMainPM);
   }
 
@@ -793,13 +786,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)
@@ -861,7 +847,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);
@@ -886,7 +871,6 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
       HilightWithColor (theObject, anObjSelStyle, Standard_False);
     }
   }
-  anOwner->SetSelected (Standard_True);
 
   if (theToUpdateViewer)
     UpdateCurrentViewer();
@@ -933,12 +917,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);
@@ -987,8 +969,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;
 }