From 40c33142278a094947c906637cc84e6c67addd46 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 31 May 2019 20:43:18 +0300 Subject: [PATCH] 0030737: Visualization - implementing new selection schemes in context #apply selection scheme to container of owners --- src/AIS/AIS_InteractiveContext.hxx | 7 +++ src/AIS/AIS_InteractiveContext_1.cxx | 92 ++++++++++------------------ src/AIS/AIS_SelectionScheme.hxx | 5 +- 3 files changed, 44 insertions(+), 60 deletions(-) diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index 626fc93bf6..1ca09491d1 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -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, diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index e02c852ee3..d1f517fa98 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -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 : diff --git a/src/AIS/AIS_SelectionScheme.hxx b/src/AIS/AIS_SelectionScheme.hxx index d34c3f40c3..0dc03a367c 100644 --- a/src/AIS/AIS_SelectionScheme.hxx +++ b/src/AIS/AIS_SelectionScheme.hxx @@ -20,12 +20,15 @@ //! 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 -- 2.39.5