]> OCCT Git - occt-copy.git/commitdiff
0030737: Visualization - implementing new selection schemes in context
authornds <nds@opencascade.com>
Fri, 31 May 2019 17:43:18 +0000 (20:43 +0300)
committernds <nds@opencascade.com>
Fri, 31 May 2019 17:45:25 +0000 (20:45 +0300)
#apply selection scheme to container of owners

(cherry picked from commit 40c33142278a094947c906637cc84e6c67addd46)

src/AIS/AIS_InteractiveContext.hxx
src/AIS/AIS_InteractiveContext_1.cxx
src/AIS/AIS_SelectionScheme.hxx

index 626fc93bf650411ade41c18b971260fa2d4b42f5..1ca09491d1b18fe1ad9f1dffe109d819caca421c 100644 (file)
@@ -501,6 +501,13 @@ public: //! @name Selection management
                                                 const Handle(V3d_View)& theView,
                                                 const Standard_Boolean  theToUpdateViewer);
 
+  //! Sets list of owner selected/deselected using selection scheme
+  //! It is possible that selection of other objects is changed relatively selection scheme   .
+  //! \param theOwner owners to change selection state
+  //! \param theSelScheme selection scheme
+  Standard_EXPORT AIS_StatusOfPick Select (const AIS_NListOfEntityOwner& theOwners,
+                                           const AIS_SelectionScheme theSelScheme);
+
   //! Fits the view correspondingly to the bounds of selected objects.
   //! Infinite objects are ignored if infinite state of AIS_InteractiveObject is set to true.
   Standard_EXPORT void FitSelected (const Handle(V3d_View)& theView,
index 0c13bdd20c0f4548263bb1b395b62b794b5548ac..89ecf91a0b2d288d6d1eb9dbcf18a0092fe64aa4 100644 (file)
@@ -418,15 +418,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer  theXPMi
     throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
   }
 
-  // all objects detected by the selector are taken, previous current objects are emptied,
-  // new objects are put...
-  if (myAutoHilight)
-  {
-    clearDynamicHighlight();
-    UnhilightSelected (Standard_False);
-  }
-  myWasLastMain = Standard_True;
-
   myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
 
   AIS_NListOfEntityOwner aPickedOwners;
@@ -434,19 +425,8 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer  theXPMi
   {
     aPickedOwners.Append (myMainSel->Picked (aPickIter));
   }
-  mySelection->SelectOwners (aPickedOwners, theSelScheme, myFilters);
 
-  if (myAutoHilight)
-  {
-    HilightSelected (Standard_False);
-  }
-
-  Standard_Integer aSelNum = NbSelected();
-
-  return (aSelNum == 0) ? AIS_SOP_NothingSelected
-                        : (aSelNum == 1) ? AIS_SOP_OneSelected
-                                         : AIS_SOP_SeveralSelected;
-  
+  return Select (aPickedOwners, theSelScheme);
 }
 
 //=======================================================================
@@ -462,15 +442,6 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
     throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument");
   }
 
-  // all objects detected by the selector are taken, previous current objects are emptied,
-  // new objects are put...
-  if (myAutoHilight)
-  {
-    clearDynamicHighlight();
-    UnhilightSelected (Standard_False);
-  }
-
-  myWasLastMain = Standard_True;
   myMainSel->Pick (thePolyline, theView);
 
   AIS_NListOfEntityOwner aPickedOwners;
@@ -478,19 +449,8 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& the
   {
     aPickedOwners.Append (myMainSel->Picked (aPickIter));
   }
-  mySelection->SelectOwners (aPickedOwners, theSelScheme, myFilters);
-
-  if (myAutoHilight)
-  {
-    HilightSelected (Standard_False);
-  }
 
-  Standard_Integer aSelNum = NbSelected();
-
-  return (aSelNum == 0) ? AIS_SOP_NothingSelected
-                        : (aSelNum == 1) ? AIS_SOP_OneSelected
-                                         : AIS_SOP_SeveralSelected;
-  
+  return Select (aPickedOwners, theSelScheme);
 }
 
 //=======================================================================
@@ -509,26 +469,10 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_SelectionScheme theSe
     return getStatusOfPick (NbSelected());
   }*/
 
-  if (myAutoHilight)
-  {
-    clearDynamicHighlight();
-    UnhilightSelected (Standard_False);
-  }
-
   AIS_NListOfEntityOwner aPickedOwners;
   aPickedOwners.Append (myLastinMain);
-  mySelection->SelectOwners (aPickedOwners, theSelScheme, myFilters);
 
-  if (myAutoHilight)
-  {
-    HilightSelected (Standard_False);
-  }
-
-  Standard_Integer aSelNum = NbSelected();
-
-  return (aSelNum == 0) ? AIS_SOP_NothingSelected
-                        : (aSelNum == 1) ? AIS_SOP_OneSelected
-                                         : AIS_SOP_SeveralSelected;
+  return Select (aPickedOwners, theSelScheme);
 }
 
 //=======================================================================
@@ -599,6 +543,36 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d
   return Select (thePolyline, theView, AIS_SelectionScheme_Switch);
 }
 
+//=======================================================================
+//function : Select
+//purpose  :
+//=======================================================================
+AIS_StatusOfPick AIS_InteractiveContext::Select (const AIS_NListOfEntityOwner& theOwners,
+                                                 const AIS_SelectionScheme theSelScheme)
+{
+  // all objects detected by the selector are taken, previous current objects are emptied,
+  // new objects are put...
+  if (myAutoHilight)
+  {
+    clearDynamicHighlight();
+    UnhilightSelected (Standard_False);
+  }
+  myWasLastMain = Standard_True;
+
+  mySelection->SelectOwners (theOwners, theSelScheme, myFilters);
+
+  if (myAutoHilight)
+  {
+    HilightSelected (Standard_False);
+  }
+
+  Standard_Integer aSelNum = NbSelected();
+
+  return (aSelNum == 0) ? AIS_SOP_NothingSelected
+                        : (aSelNum == 1) ? AIS_SOP_OneSelected
+                                         : AIS_SOP_SeveralSelected;
+}
+
 //=======================================================================
 //function : HilightSelected
 //purpose  :
index d34c3f40c3503b2bd7f7daf70c53f2038394aceb..0dc03a367c6853ddc3fbd5ebbfc8dd08fadce9f6 100644 (file)
 //! It is possible to use combination of schemes.
 enum AIS_SelectionScheme
 {
+  AIS_SelectionScheme_Empty         = 0x0000, // do nothing
   AIS_SelectionScheme_Clear         = 0x0001, // clears current selection
   AIS_SelectionScheme_Add           = 0x0002, // add detected object to current selection
   AIS_SelectionScheme_Switch        = 0x0004, // switch selection state in values selected/deselected
   AIS_SelectionScheme_PickedIfEmpty = 0x0008, // if after switch, result selection is empty, select picked objects
   AIS_SelectionScheme_ClearAndSwitch = AIS_SelectionScheme_Clear | AIS_SelectionScheme_Switch,
-  AIS_SelectionScheme_ClearAndAdd = AIS_SelectionScheme_Clear | AIS_SelectionScheme_Add
+  AIS_SelectionScheme_ClearAndAdd = AIS_SelectionScheme_Clear | AIS_SelectionScheme_Add,
+  AIS_SelectionScheme_ClearAndSwitchAndPicked = AIS_SelectionScheme_ClearAndSwitch | AIS_SelectionScheme_PickedIfEmpty,
+  AIS_SelectionScheme_Custom // reserved item for custom selection scheme
 };
 
 #endif // _AIS_SelectionScheme_HeaderFile