From 79ae8fb8957606438374f5ff9367483ac86fd108 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 18 Sep 2020 21:36:05 +0300 Subject: [PATCH] 0030737: Visualization - implementing new selection schemes in context AIS_SelectionScheme enumeration is defined to set which selection behaviour is used in Select of context AIS_InteractiveContext is corrected to use single Select method instead of combination of Select/ShiftSelect methods with a selection scheme parameter. Upgrade: Select() -> SelectDetected/Rectangle/Polygon(AIS_SelectionScheme_Replace), ShiftSelect -> SelectDetected/Rectangle/Polygon(AIS_SelectionScheme_XOR) --- .../visualization_selection_scheme_XOR.svg | 27 ++ .../visualization_selection_scheme_add.svg | 27 ++ .../visualization_selection_scheme_clear.svg | 27 ++ .../visualization_selection_scheme_remove.svg | 27 ++ ...visualization_selection_scheme_replace.svg | 27 ++ .../visualization/visualization.md | 6 +- samples/CSharp/OCCTProxy/OCCTProxy.cpp | 17 +- samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp | 17 +- .../standard/01_Geometry/src/GeometryDoc.cpp | 6 +- .../standard/02_Modeling/src/ModelingDoc.cpp | 4 +- .../standard/04_Viewer3d/src/Viewer3dDoc.cpp | 2 +- samples/mfc/standard/08_HLR/src/HLRView3D.cpp | 13 +- samples/mfc/standard/Common/OCC_3dBaseDoc.cpp | 20 +- src/AIS/AIS_InteractiveContext.hxx | 55 ++++ src/AIS/AIS_InteractiveContext_1.cxx | 269 +++++++++--------- src/AIS/AIS_Selection.cxx | 86 ++++++ src/AIS/AIS_Selection.hxx | 22 +- src/AIS/AIS_SelectionScheme.hxx | 28 ++ src/AIS/AIS_ViewController.cxx | 28 +- src/AIS/FILES | 1 + src/QABugs/QABugs_16.cxx | 13 +- src/QABugs/QABugs_19.cxx | 11 +- src/ViewerTest/ViewerTest_EventManager.hxx | 2 +- src/ViewerTest/ViewerTest_ViewerCommands.cxx | 21 +- 24 files changed, 560 insertions(+), 196 deletions(-) create mode 100644 dox/user_guides/visualization/images/visualization_selection_scheme_XOR.svg create mode 100644 dox/user_guides/visualization/images/visualization_selection_scheme_add.svg create mode 100644 dox/user_guides/visualization/images/visualization_selection_scheme_clear.svg create mode 100644 dox/user_guides/visualization/images/visualization_selection_scheme_remove.svg create mode 100644 dox/user_guides/visualization/images/visualization_selection_scheme_replace.svg create mode 100644 src/AIS/AIS_SelectionScheme.hxx diff --git a/dox/user_guides/visualization/images/visualization_selection_scheme_XOR.svg b/dox/user_guides/visualization/images/visualization_selection_scheme_XOR.svg new file mode 100644 index 0000000000..c4b0325a5b --- /dev/null +++ b/dox/user_guides/visualization/images/visualization_selection_scheme_XOR.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dox/user_guides/visualization/images/visualization_selection_scheme_add.svg b/dox/user_guides/visualization/images/visualization_selection_scheme_add.svg new file mode 100644 index 0000000000..62ce81ef6e --- /dev/null +++ b/dox/user_guides/visualization/images/visualization_selection_scheme_add.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dox/user_guides/visualization/images/visualization_selection_scheme_clear.svg b/dox/user_guides/visualization/images/visualization_selection_scheme_clear.svg new file mode 100644 index 0000000000..e3b149c341 --- /dev/null +++ b/dox/user_guides/visualization/images/visualization_selection_scheme_clear.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dox/user_guides/visualization/images/visualization_selection_scheme_remove.svg b/dox/user_guides/visualization/images/visualization_selection_scheme_remove.svg new file mode 100644 index 0000000000..f3ec7fbfe0 --- /dev/null +++ b/dox/user_guides/visualization/images/visualization_selection_scheme_remove.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dox/user_guides/visualization/images/visualization_selection_scheme_replace.svg b/dox/user_guides/visualization/images/visualization_selection_scheme_replace.svg new file mode 100644 index 0000000000..4721c3a71e --- /dev/null +++ b/dox/user_guides/visualization/images/visualization_selection_scheme_replace.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dox/user_guides/visualization/visualization.md b/dox/user_guides/visualization/visualization.md index 56221469ee..7507359b9b 100644 --- a/dox/user_guides/visualization/visualization.md +++ b/dox/user_guides/visualization/visualization.md @@ -822,10 +822,8 @@ myContext->MoveTo (thePixelX, thePixelY, myView); Dynamic detection and selection are put into effect in a straightforward way. There are only a few conventions and functions to be familiar with: * *AIS_InteractiveContext::MoveTo* -- passes mouse position to Interactive Context selectors. - * *AIS_InteractiveContext::Select* -- stores what has been detected at the last *MoveTo*. Replaces the previously selected object. Empties the stack if nothing has been detected at the last move. - * *AIS_InteractiveContext::ShiftSelect* -- if the object detected at the last move was not already selected, it is added to the list of the selected objects. If not, it is withdrawn. Nothing happens if you click on an empty area. - * *AIS_InteractiveContext::Select* -- selects everything found in the surrounding area. - * *AIS_InteractiveContext::ShiftSelect* -- selects what was not previously in the list of selected, deselects those already present. + * *AIS_InteractiveContext::SelectDetected* -- stores what has been detected at the last *MoveTo*. Changes the previously selected object. Depending on the selection scheme, the selection is enriched, replaced or other. + * *AIS_InteractiveContext::SelectPoint/SelectRectangle/SelectPolygon* -- Applies selection to point, rectangular or surrounding area. Changes the previously selected object. Depending on the selection scheme, the selection is enriched, replaced or other. Highlighting of detected and selected entities is automatically managed by the Interactive Context. The Highlight colors are those dealt with above. You can nonetheless disconnect this automatic mode if you want to manage this part yourself: ~~~~~ diff --git a/samples/CSharp/OCCTProxy/OCCTProxy.cpp b/samples/CSharp/OCCTProxy/OCCTProxy.cpp index d333aa649c..3f3f24a9cf 100644 --- a/samples/CSharp/OCCTProxy/OCCTProxy.cpp +++ b/samples/CSharp/OCCTProxy/OCCTProxy.cpp @@ -245,7 +245,10 @@ public: { if (!myAISContext().IsNull()) { - myAISContext()->Select (theX1, theY1, theX2, theY2, myView(), Standard_True); + myAISContext()->SelectRectangle (Graphic3d_Vec2i (theX1, theY1), + Graphic3d_Vec2i (theX2, theY2), + myView()); + myAISContext()->UpdateCurrentViewer(); } } @@ -256,7 +259,8 @@ public: { if (!myAISContext().IsNull()) { - myAISContext()->Select (Standard_True); + myAISContext()->SelectDetected(); + myAISContext()->UpdateCurrentViewer(); } } @@ -278,7 +282,11 @@ public: { if ((!myAISContext().IsNull()) && (!myView().IsNull())) { - myAISContext()->ShiftSelect (theX1, theY1, theX2, theY2, myView(), Standard_True); + myAISContext()->SelectRectangle (Graphic3d_Vec2i (theX1, theY1), + Graphic3d_Vec2i (theX2, theY2), + myView(), + AIS_SelectionScheme_XOR); + myAISContext()->UpdateCurrentViewer(); } } @@ -289,7 +297,8 @@ public: { if (!myAISContext().IsNull()) { - myAISContext()->ShiftSelect (Standard_True); + myAISContext()->SelectDetected (AIS_SelectionScheme_XOR); + myAISContext()->UpdateCurrentViewer(); } } diff --git a/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp b/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp index e79cc4acaa..244f880349 100644 --- a/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp +++ b/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp @@ -262,7 +262,10 @@ public: { if (!myAISContext().IsNull()) { - myAISContext()->Select (theX1, theY1, theX2, theY2, myView(), Standard_True); + myAISContext()->SelectRectangle (Graphic3d_Vec2i (theX1, theY1), + Graphic3d_Vec2i (theX2, theY2), + myView()); + myAISContext()->UpdateCurrentViewer(); } } @@ -273,7 +276,8 @@ public: { if (!myAISContext().IsNull()) { - myAISContext()->Select (Standard_True); + myAISContext()->SelectDetected(); + myAISContext()->UpdateCurrentViewer(); } } @@ -295,7 +299,11 @@ public: { if (!myAISContext().IsNull() && !myView().IsNull()) { - myAISContext()->ShiftSelect (theX1, theY1, theX2, theY2, myView(), Standard_True); + myAISContext()->SelectRectangle (Graphic3d_Vec2i (theX1, theY1), + Graphic3d_Vec2i (theX2, theY2), + myView(), + AIS_SelectionScheme_XOR); + myAISContext()->UpdateCurrentViewer(); } } @@ -306,7 +314,8 @@ public: { if (!myAISContext().IsNull()) { - myAISContext()->ShiftSelect (Standard_True); + myAISContext()->SelectDetected (AIS_SelectionScheme_XOR); + myAISContext()->UpdateCurrentViewer(); } } diff --git a/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp b/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp index 16933e46ac..e32b94ce55 100755 --- a/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp +++ b/samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp @@ -244,7 +244,8 @@ void CGeometryDoc::InputEvent2D(const Standard_Integer /*x*/, const Standard_Integer /*y*/, const Handle(V3d_View)& /*aView*/) { - myAISContext2D->Select(Standard_True); + myAISContext2D->SelectDetected(); + myAISContext2D->UpdateCurrentViewer(); } //----------------------------------------------------------------------------------------- @@ -352,7 +353,8 @@ void CGeometryDoc::InputEvent (const Standard_Integer /*theMouseX*/, const Standard_Integer /*theMouseY*/, const Handle(V3d_View)& /*theView*/) { - myAISContext->Select (Standard_True); + myAISContext->SelectDetected(); + myAISContext2D->UpdateCurrentViewer(); } //----------------------------------------------------------------------------------------- diff --git a/samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp b/samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp index 4481c82a7b..0ce9e37db7 100755 --- a/samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp +++ b/samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp @@ -4816,7 +4816,9 @@ void CModelingDoc::InputEvent(const Standard_Integer /*x*/, const Standard_Integer /*y*/, const Handle(V3d_View)& /*aView*/) { - myAISContext->Select (Standard_True); + myAISContext->SelectDetected(); + myAISContext->UpdateCurrentViewer(); + if (myState == SELECT_EDGE_PLATE_TGTES_1) { myAISContext->InitSelected(); if (myAISContext->MoreSelected()) { diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp b/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp index 03b667f934..a263b69a9c 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp @@ -506,7 +506,7 @@ void CViewer3dDoc::InputEvent(const Standard_Integer /*x*/, Quantity_Color CSFColor; COLORREF MSColor; - myAISContext->Select (Standard_True); + myAISContext->SelectDetected(); // Change the color of a selected face in a user cylinder if (myState == FACE_COLOR) diff --git a/samples/mfc/standard/08_HLR/src/HLRView3D.cpp b/samples/mfc/standard/08_HLR/src/HLRView3D.cpp index 3d9bbb6e65..79dec617fa 100755 --- a/samples/mfc/standard/08_HLR/src/HLRView3D.cpp +++ b/samples/mfc/standard/08_HLR/src/HLRView3D.cpp @@ -328,7 +328,9 @@ void CHLRView3D::DragEvent(const Standard_Integer x , } if (TheState == 0) - GetDocument()->GetAISContext()->Select(theButtonDownX,theButtonDownY,x,y,myView); + GetDocument()->GetAISContext()->SelectRectangle(Graphic3d_Vec2i (theButtonDownX,theButtonDownY), + Graphic3d_Vec2i (x,y), + myView); } //----------------------------------------------------------------------------------------- @@ -337,7 +339,7 @@ void CHLRView3D::DragEvent(const Standard_Integer x , void CHLRView3D::InputEvent(const Standard_Integer x , const Standard_Integer y ) { - GetDocument()->GetAISContext()->Select(); + GetDocument()->GetAISContext()->SelectDetected(); } //----------------------------------------------------------------------------------------- @@ -375,7 +377,10 @@ void CHLRView3D::MultiDragEvent(const Standard_Integer x , } if (TheState == 0) - GetDocument()->GetAISContext()->ShiftSelect(theButtonDownX,theButtonDownY,x,y,myView); + GetDocument()->GetAISContext()->SelectRectangle(Graphic3d_Vec2i (theButtonDownX,theButtonDownY), + Graphic3d_Vec2i (x,y), + myView, + AIS_SelectionScheme_XOR); } @@ -385,6 +390,6 @@ void CHLRView3D::MultiDragEvent(const Standard_Integer x , void CHLRView3D::MultiInputEvent(const Standard_Integer x , const Standard_Integer y ) { - GetDocument()->GetAISContext()->ShiftSelect(); + GetDocument()->GetAISContext()->SelectDetected(AIS_SelectionScheme_XOR); } diff --git a/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp b/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp index 7578112cb0..389d9eaec3 100755 --- a/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp +++ b/samples/mfc/standard/Common/OCC_3dBaseDoc.cpp @@ -111,9 +111,10 @@ void OCC_3dBaseDoc::DragEvent (const Standard_Integer theMouseX, } case 1: { - myAISContext->Select (aStartDragX, aStartDragY, - theMouseX, theMouseY, - theView, Standard_True); + myAISContext->SelectRectangle (Graphic3d_Vec2i (aStartDragX, aStartDragY), + Graphic3d_Vec2i (theMouseX, theMouseY), + theView); + myAISContext->UpdateCurrentViewer(); break; } }; @@ -127,7 +128,8 @@ void OCC_3dBaseDoc::InputEvent (const Standard_Integer theMouseX, const Handle(V3d_View)& theView) { myAISContext->MoveTo (theMouseX, theMouseY, theView, Standard_False); - myAISContext->Select (Standard_True); + myAISContext->SelectDetected(); + myAISContext->UpdateCurrentViewer(); } //----------------------------------------------------------------------------------------- @@ -175,9 +177,10 @@ void OCC_3dBaseDoc::ShiftDragEvent (const Standard_Integer theMouseX, if (theState == 0) { // button up - myAISContext->ShiftSelect (aStartDragX, aStartDragY, - theMouseX, theMouseY, - theView, Standard_True); + myAISContext->SelectRectangle (Graphic3d_Vec2i (aStartDragX, aStartDragY), + Graphic3d_Vec2i (theMouseX, theMouseY), + theView, AIS_SelectionScheme_XOR); + myAISContext->UpdateCurrentViewer(); } } @@ -188,7 +191,8 @@ void OCC_3dBaseDoc::ShiftInputEvent (const Standard_Integer /*theMouseX*/, const Standard_Integer /*theMouseY*/, const Handle(V3d_View)& /*theView*/) { - myAISContext->ShiftSelect (Standard_True); + myAISContext->SelectDetected (AIS_SelectionScheme_XOR); + myAISContext->UpdateCurrentViewer(); } //----------------------------------------------------------------------------------------- diff --git a/src/AIS/AIS_InteractiveContext.hxx b/src/AIS/AIS_InteractiveContext.hxx index 6bfd1944bd..da3a5b59d1 100644 --- a/src/AIS/AIS_InteractiveContext.hxx +++ b/src/AIS/AIS_InteractiveContext.hxx @@ -25,10 +25,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -475,8 +477,49 @@ public: //! @name Selection management return AddSelect (theObject->GlobalSelOwner()); } + //! Selects objects within the bounding rectangle. + //! Viewer should be explicitly redrawn after selection. + //! @param thePntMin [in] rectangle lower point (in pixels) + //! @param thePntMax [in] rectangle upper point (in pixels) + //! @param theView [in] active view where rectangle is defined + //! @param theSelScheme [in] selection scheme + //! @return picking status + //! @sa StdSelect_ViewerSelector3d::AllowOverlapDetection() + Standard_EXPORT AIS_StatusOfPick SelectRectangle (const Graphic3d_Vec2i& thePntMin, + const Graphic3d_Vec2i& thePntMax, + const Handle(V3d_View)& theView, + const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace); + + //! Select everything found in the polygon defined by bounding polyline. + //! Viewer should be explicitly redrawn after selection. + //! @param thePolyline [in] polyline defining polygon bounds (in pixels) + //! @param theView [in] active view where polyline is defined + //! @param theSelScheme [in] selection scheme + //! @return picking status + Standard_EXPORT AIS_StatusOfPick SelectPolygon (const TColgp_Array1OfPnt2d& thePolyline, + const Handle(V3d_View)& theView, + const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace); + + //! Selects the topmost object picked by the point in the view, + //! Viewer should be explicitly redrawn after selection. + //! @param thePnt [in] point pixel coordinates within the view + //! @param theView [in] active view where point is defined + //! @param theSelScheme [in] selection scheme + //! @return picking status + Standard_EXPORT AIS_StatusOfPick SelectPoint (const Graphic3d_Vec2i& thePnt, + const Handle(V3d_View)& theView, + const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace); + + //! Select and hilights the previous detected via AIS_InteractiveContext::MoveTo() method; + //! unhilights the previous picked. + //! Viewer should be explicitly redrawn after selection. + //! @param theSelScheme [in] selection scheme + //! @return picking status + Standard_EXPORT AIS_StatusOfPick SelectDetected (const AIS_SelectionScheme theSelScheme = AIS_SelectionScheme_Replace); + //! Selects everything found in the bounding rectangle defined by the pixel minima and maxima, XPMin, YPMin, XPMax, and YPMax in the view. //! The objects detected are passed to the main viewer, which is then updated. + Standard_DEPRECATED("This method is deprecated - SelectRectangle() taking AIS_SelectionScheme_Replace should be called instead") Standard_EXPORT AIS_StatusOfPick Select (const Standard_Integer theXPMin, const Standard_Integer theYPMin, const Standard_Integer theXPMax, @@ -485,27 +528,32 @@ public: //! @name Selection management const Standard_Boolean theToUpdateViewer); //! polyline selection; clears the previous picked list + Standard_DEPRECATED("This method is deprecated - SelectPolygon() taking AIS_SelectionScheme_Replace should be called instead") Standard_EXPORT AIS_StatusOfPick Select (const TColgp_Array1OfPnt2d& thePolyline, const Handle(V3d_View)& theView, const Standard_Boolean theToUpdateViewer); //! Stores and hilights the previous detected; Unhilights the previous picked. //! @sa MoveTo(). + Standard_DEPRECATED("This method is deprecated - SelectDetected() taking AIS_SelectionScheme_Replace should be called instead") Standard_EXPORT AIS_StatusOfPick Select (const Standard_Boolean theToUpdateViewer); //! Adds the last detected to the list of previous picked. //! If the last detected was already declared as picked, removes it from the Picked List. //! @sa MoveTo(). + Standard_DEPRECATED("This method is deprecated - SelectDetected() taking AIS_SelectionScheme_XOR should be called instead") Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Boolean theToUpdateViewer); //! Adds the last detected to the list of previous picked. //! If the last detected was already declared as picked, removes it from the Picked List. + Standard_DEPRECATED("This method is deprecated - SelectPolygon() taking AIS_SelectionScheme_XOR should be called instead") Standard_EXPORT AIS_StatusOfPick ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline, const Handle(V3d_View)& theView, const Standard_Boolean theToUpdateViewer); //! Rectangle of selection; adds new detected entities into the picked list, //! removes the detected entities that were already stored. + Standard_DEPRECATED("This method is deprecated - SelectRectangle() taking AIS_SelectionScheme_XOR should be called instead") Standard_EXPORT AIS_StatusOfPick ShiftSelect (const Standard_Integer theXPMin, const Standard_Integer theYPMin, const Standard_Integer theXPMax, @@ -516,6 +564,13 @@ public: //! @name Selection management //! Returns bounding box of selected objects. Standard_EXPORT Bnd_Box BoundingBoxOfSelection() const; + //! Sets list of owner selected/deselected using specified selection scheme. + //! @param theOwners owners to change selection state + //! @param theSelScheme selection scheme + //! @return picking status + 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 e572a86791..4c535c3cfc 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -487,95 +487,101 @@ AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_Entit } //======================================================================= -//function : Select -//purpose : +//function : SelectRectangle +//purpose : //======================================================================= -AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin, - const Standard_Integer theYPMin, - const Standard_Integer theXPMax, - const Standard_Integer theYPMax, - const Handle(V3d_View)& theView, - const Standard_Boolean toUpdateViewer) +AIS_StatusOfPick AIS_InteractiveContext::SelectRectangle (const Graphic3d_Vec2i& thePntMin, + const Graphic3d_Vec2i& thePntMax, + const Handle(V3d_View)& theView, + const AIS_SelectionScheme theSelScheme) { if (theView->Viewer() != myMainVwr) { - throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument"); + throw Standard_ProgramError ("AIS_InteractiveContext::SelectRectangle() - invalid argument"); } - // all objects detected by the selector are taken, previous current objects are emptied, - // new objects are put... - ClearSelected (Standard_False); myLastActiveView = theView.get(); - myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); - for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) + if (myAutoHilight) { - const Handle(SelectMgr_EntityOwner)& aCurOwner = myMainSel->Picked (aPickIter); - if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner)) - continue; - - mySelection->Select (aCurOwner); + UnhilightSelected (Standard_False); } + myMainSel->Pick (thePntMin.x(), thePntMin.y(), thePntMax.x(), thePntMax.y(), theView); - if (myAutoHilight) + AIS_NListOfEntityOwner aPickedOwners; + for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) { - HilightSelected (toUpdateViewer); + aPickedOwners.Append (myMainSel->Picked (aPickIter)); } - Standard_Integer aSelNum = NbSelected(); - - return (aSelNum == 0) ? AIS_SOP_NothingSelected - : (aSelNum == 1) ? AIS_SOP_OneSelected - : AIS_SOP_SeveralSelected; - + return Select (aPickedOwners, theSelScheme); } //======================================================================= -//function : Select -//purpose : Selection by polyline +//function : SelectPolygon +//purpose : //======================================================================= -AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline, - const Handle(V3d_View)& theView, - const Standard_Boolean toUpdateViewer) +AIS_StatusOfPick AIS_InteractiveContext::SelectPolygon (const TColgp_Array1OfPnt2d& thePolyline, + const Handle(V3d_View)& theView, + const AIS_SelectionScheme theSelScheme) { if (theView->Viewer() != myMainVwr) { - throw Standard_ProgramError ("AIS_InteractiveContext::Select() - invalid argument"); + throw Standard_ProgramError ("AIS_InteractiveContext::SelectPolygon() - invalid argument"); } - // all objects detected by the selector are taken, previous current objects are emptied, - // new objects are put... - ClearSelected (Standard_False); myLastActiveView = theView.get(); + if (myAutoHilight) + { + UnhilightSelected (Standard_False); + } myMainSel->Pick (thePolyline, theView); + + AIS_NListOfEntityOwner aPickedOwners; for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) { - const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter); - if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) - continue; + aPickedOwners.Append (myMainSel->Picked (aPickIter)); + } + + return Select (aPickedOwners, theSelScheme); +} - mySelection->Select (anOwner); +//======================================================================= +//function : SelectPoint +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_InteractiveContext::SelectPoint (const Graphic3d_Vec2i& thePnt, + const Handle(V3d_View)& theView, + const AIS_SelectionScheme theSelScheme) +{ + if (theView->Viewer() != myMainVwr) + { + throw Standard_ProgramError ("AIS_InteractiveContext::SelectPoint() - invalid argument"); } if (myAutoHilight) { - HilightSelected (toUpdateViewer); + UnhilightSelected (Standard_False); } - Standard_Integer aSelNum = NbSelected(); + myLastActiveView = theView.get(); + myMainSel->Pick (thePnt.x(), thePnt.y(), theView); - return (aSelNum == 0) ? AIS_SOP_NothingSelected - : (aSelNum == 1) ? AIS_SOP_OneSelected - : AIS_SOP_SeveralSelected; - + AIS_NListOfEntityOwner aPickedOwners; + for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) + { + aPickedOwners.Append (myMainSel->Picked (aPickIter)); + } + + return Select (aPickedOwners, theSelScheme); } //======================================================================= -//function : Select -//purpose : +//function : SelectDetected +//purpose : //======================================================================= -AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer) +AIS_StatusOfPick AIS_InteractiveContext::SelectDetected (const AIS_SelectionScheme theSelScheme) { - if (!myLastPicked.IsNull()) + if (theSelScheme == AIS_SelectionScheme_Replace && !myLastPicked.IsNull()) { Graphic3d_Vec2i aMousePos (-1, -1); if (myMainSel->GetManager().GetActiveSelectionType() == SelectBasics_SelectingVolumeManager::Point) @@ -587,54 +593,81 @@ AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdate { return AIS_SOP_NothingSelected; } - - if (myAutoHilight) - { - clearDynamicHighlight(); - } - if (!myLastPicked->IsSelected() - || myLastPicked->IsForcedHilight() - || NbSelected() > 1) - { - SetSelected (myLastPicked, Standard_False); - if(toUpdateViewer) - { - UpdateCurrentViewer(); - } - } } - else + + if (myAutoHilight && theSelScheme != AIS_SelectionScheme_XOR) { - ClearSelected (toUpdateViewer); + UnhilightSelected (Standard_False); } - Standard_Integer aSelNum = NbSelected(); - - return (aSelNum == 0) ? AIS_SOP_NothingSelected - : (aSelNum == 1) ? AIS_SOP_OneSelected - : AIS_SOP_SeveralSelected; + AIS_NListOfEntityOwner aPickedOwners; + aPickedOwners.Append (myLastPicked); + return Select (aPickedOwners, theSelScheme); } //======================================================================= -//function : ShiftSelect -//purpose : +//function : Select +//purpose : //======================================================================= -AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer) +AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin, + const Standard_Integer theYPMin, + const Standard_Integer theXPMax, + const Standard_Integer theYPMax, + const Handle(V3d_View)& theView, + const Standard_Boolean theToUpdateViewer) { - if (myAutoHilight) + AIS_StatusOfPick aStatus = SelectRectangle (Graphic3d_Vec2i (theXPMin, theYPMin), + Graphic3d_Vec2i (theXPMax, theYPMax), + theView); + if (theToUpdateViewer) { - clearDynamicHighlight(); + UpdateCurrentViewer(); } - if (!myLastPicked.IsNull()) + return aStatus; +} + +//======================================================================= +//function : Select +//purpose : Selection by polyline +//======================================================================= +AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline, + const Handle(V3d_View)& theView, + const Standard_Boolean theToUpdateViewer) +{ + AIS_StatusOfPick aStatus = SelectPolygon (thePolyline, theView); + if (theToUpdateViewer) { - AddOrRemoveSelected (myLastPicked, toUpdateViewer); + UpdateCurrentViewer(); } + return aStatus; +} - Standard_Integer aSelNum = NbSelected(); +//======================================================================= +//function : Select +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean theToUpdateViewer) +{ + AIS_StatusOfPick aStatus = SelectDetected(); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } + return aStatus; +} - return (aSelNum == 0) ? AIS_SOP_NothingSelected - : (aSelNum == 1) ? AIS_SOP_OneSelected - : AIS_SOP_SeveralSelected; +//======================================================================= +//function : ShiftSelect +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean theToUpdateViewer) +{ + AIS_StatusOfPick aStatus = SelectDetected (AIS_SelectionScheme_XOR); + if (theToUpdateViewer) + { + UpdateCurrentViewer(); + } + return aStatus; } //======================================================================= @@ -646,39 +679,17 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the const Standard_Integer theXPMax, const Standard_Integer theYPMax, const Handle(V3d_View)& theView, - const Standard_Boolean toUpdateViewer) + const Standard_Boolean theToUpdateViewer) { - if (theView->Viewer() != myMainVwr) - { - throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument"); - } - - myLastActiveView = theView.get(); - if (myAutoHilight) - { - UnhilightSelected (Standard_False); - } - myMainSel->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); - for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) - { - const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter); - if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) - continue; - - mySelection->Select (anOwner); - } - - if (myAutoHilight) + AIS_StatusOfPick aStatus = SelectRectangle (Graphic3d_Vec2i (theXPMin, theYPMin), + Graphic3d_Vec2i (theXPMax, theYPMax), + theView, + AIS_SelectionScheme_XOR); + if (theToUpdateViewer) { - HilightSelected (toUpdateViewer); + UpdateCurrentViewer(); } - - Standard_Integer aSelNum = NbSelected(); - - return (aSelNum == 0) ? AIS_SOP_NothingSelected - : (aSelNum == 1) ? AIS_SOP_OneSelected - : AIS_SOP_SeveralSelected; - + return aStatus; } //======================================================================= @@ -687,31 +698,35 @@ AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer the //======================================================================= AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline, const Handle(V3d_View)& theView, - const Standard_Boolean toUpdateViewer) + const Standard_Boolean theToUpdateViewer) { - if (theView->Viewer() != myMainVwr) + AIS_StatusOfPick aStatus = SelectPolygon (thePolyline, theView, AIS_SelectionScheme_XOR); + if (theToUpdateViewer) { - throw Standard_ProgramError ("AIS_InteractiveContext::ShiftSelect() - invalid argument"); + UpdateCurrentViewer(); } + return aStatus; +} - myLastActiveView = theView.get(); +//======================================================================= +//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) { - UnhilightSelected (Standard_False); + clearDynamicHighlight(); } - myMainSel->Pick (thePolyline, theView); - for (Standard_Integer aPickIter = 1; aPickIter <= myMainSel->NbPicked(); ++aPickIter) - { - const Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aPickIter); - if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner)) - continue; - mySelection->Select (anOwner); - } + mySelection->SelectOwners (theOwners, theSelScheme, myFilters); if (myAutoHilight) { - HilightSelected (toUpdateViewer); + HilightSelected (Standard_False); } Standard_Integer aSelNum = NbSelected(); diff --git a/src/AIS/AIS_Selection.cxx b/src/AIS/AIS_Selection.cxx index e26bddf828..c914031b06 100644 --- a/src/AIS/AIS_Selection.cxx +++ b/src/AIS/AIS_Selection.cxx @@ -15,6 +15,8 @@ #include #include +#include +#include IMPLEMENT_STANDARD_RTTIEXT(AIS_Selection, Standard_Transient) @@ -130,3 +132,87 @@ AIS_SelectStatus AIS_Selection::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject->SetSelected (Standard_True); return AIS_SS_Added; } + +//======================================================================= +//function : SelectOwners +//purpose : +//======================================================================= +void AIS_Selection::SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners, + const AIS_SelectionScheme theSelScheme, + const Handle(SelectMgr_Filter)& theFilter) +{ + switch (theSelScheme) + { + case AIS_SelectionScheme_UNKNOWN: + { + return; + } + case AIS_SelectionScheme_Replace: + { + Clear(); + for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next()) + { + appendOwner (aSelIter.Value(), theFilter); + } + + return; + } + case AIS_SelectionScheme_Add: + { + for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next()) + { + appendOwner (aSelIter.Value(), theFilter); + } + return; + } + case AIS_SelectionScheme_Remove: + { + for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next()) + { + if (myResultMap.IsBound (aSelIter.Value())) + { + Select (aSelIter.Value()); + } + } + return; + } + case AIS_SelectionScheme_XOR: + { + for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next()) + { + const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value(); + if (anOwner.IsNull() + || !anOwner->HasSelectable() + || !theFilter->IsOk (anOwner)) + { + continue; + } + + Select (anOwner); + } + return; + } + case AIS_SelectionScheme_Clear: + { + Clear(); + return; + } + } +} + +//======================================================================= +//function : appendOwner +//purpose : +//======================================================================= +AIS_SelectStatus AIS_Selection::appendOwner (const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(SelectMgr_Filter)& theFilter) +{ + if (theOwner.IsNull() + || !theOwner->HasSelectable() + || !theFilter->IsOk (theOwner)) + { + return AIS_SS_NotDone; + } + + return AddSelect (theOwner); +} diff --git a/src/AIS/AIS_Selection.hxx b/src/AIS/AIS_Selection.hxx index 8e7cf50e91..d3163ce154 100644 --- a/src/AIS/AIS_Selection.hxx +++ b/src/AIS/AIS_Selection.hxx @@ -18,10 +18,13 @@ #define _AIS_Selection_HeaderFile #include +#include #include #include #include +class SelectMgr_Filter; + //! Class holding the list of selected owners. class AIS_Selection : public Standard_Transient { @@ -75,7 +78,24 @@ public: //! Return selected object at iterator position. const Handle(SelectMgr_EntityOwner)& Value() const { return myIterator.Value(); } -private: + //! Select or deselect owners depending on the selection scheme. + //! @param theOwners [in] elements to change selection state + //! @param theSelScheme [in] selection scheme, defines how owner is selected + //! @param theFilter [in] context filter to skip not acceptable owners + Standard_EXPORT virtual void SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners, + const AIS_SelectionScheme theSelScheme, + const Handle(SelectMgr_Filter)& theFilter); + +protected: + + //! Append the owner into the current selection if filter is Ok. + //! @param theOwner [in] element to change selection state + //! @param theFilter [in] context filter to skip not acceptable owners + //! @return result of selection + Standard_EXPORT virtual AIS_SelectStatus appendOwner (const Handle(SelectMgr_EntityOwner)& theOwner, + const Handle(SelectMgr_Filter)& theFilter); + +protected: AIS_NListOfEntityOwner myresult; AIS_NListOfEntityOwner::Iterator myIterator; diff --git a/src/AIS/AIS_SelectionScheme.hxx b/src/AIS/AIS_SelectionScheme.hxx new file mode 100644 index 0000000000..ef5da37a7e --- /dev/null +++ b/src/AIS/AIS_SelectionScheme.hxx @@ -0,0 +1,28 @@ +// Copyright (c) 2019 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _AIS_SelectionScheme_HeaderFile +#define _AIS_SelectionScheme_HeaderFile + +//! Sets selection schemes for interactive contexts. +enum AIS_SelectionScheme +{ + AIS_SelectionScheme_UNKNOWN = -1, //!< undefined scheme + AIS_SelectionScheme_Replace = 0, //!< clears current selection and select detected objects + AIS_SelectionScheme_Add, //!< adds detected object to current selection + AIS_SelectionScheme_Remove, //!< removes detected object from the current selection + AIS_SelectionScheme_XOR, //!< performs XOR for detected objects, other selected not touched + AIS_SelectionScheme_Clear //!< clears current selection +}; + +#endif // _AIS_SelectionScheme_HeaderFile diff --git a/src/AIS/AIS_ViewController.cxx b/src/AIS/AIS_ViewController.cxx index 0e2ce3a0a9..4f3d19e0b2 100644 --- a/src/AIS/AIS_ViewController.cxx +++ b/src/AIS/AIS_ViewController.cxx @@ -2067,14 +2067,7 @@ void AIS_ViewController::handleSelectionPick (const Handle(AIS_InteractiveContex ResetPreviousMoveTo(); } - if (myGL.Selection.IsXOR) - { - theCtx->ShiftSelect (false); - } - else - { - theCtx->Select (false); - } + theCtx->SelectDetected (myGL.Selection.IsXOR ? AIS_SelectionScheme_XOR : AIS_SelectionScheme_Replace); // selection affects all Views theView->Viewer()->Invalidate(); @@ -2175,9 +2168,12 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex } else { - theCtx->Select (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()), - Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()), - theView, false); + theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y())); + theCtx->SelectRectangle (Graphic3d_Vec2i (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y())), + Graphic3d_Vec2i (Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y())), + theView, + myGL.Selection.IsXOR ? AIS_SelectionScheme_XOR : AIS_SelectionScheme_Replace); + theCtx->MainSelector()->AllowOverlapDetection (false); } theCtx->MainSelector()->AllowOverlapDetection (false); } @@ -2193,14 +2189,8 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex } theCtx->MainSelector()->AllowOverlapDetection (false); - if (myGL.Selection.IsXOR) - { - theCtx->ShiftSelect (aPolyline, theView, false); - } - else - { - theCtx->Select (aPolyline, theView, false); - } + theCtx->SelectPolygon (aPolyline, theView, + myGL.Selection.IsXOR ? AIS_SelectionScheme_XOR : AIS_SelectionScheme_Replace); } } diff --git a/src/AIS/FILES b/src/AIS/FILES index 6aae413328..e26ea6ae8b 100644 --- a/src/AIS/FILES +++ b/src/AIS/FILES @@ -145,6 +145,7 @@ AIS_Selection.cxx AIS_Selection.hxx AIS_SelectStatus.hxx AIS_SelectionModesConcurrency.hxx +AIS_SelectionScheme.hxx AIS_SequenceOfDimension.hxx AIS_SequenceOfInteractive.hxx AIS_Shape.cxx diff --git a/src/QABugs/QABugs_16.cxx b/src/QABugs/QABugs_16.cxx index 5409cdcffe..f0fbf53fbb 100644 --- a/src/QABugs/QABugs_16.cxx +++ b/src/QABugs/QABugs_16.cxx @@ -188,7 +188,9 @@ static Standard_Integer BUC60774 (Draw_Interpretor& theDi, Standard_Integer aXPixMax = aWinWidth; Standard_Integer aYPixMax = aWinHeight; - AIS_StatusOfPick aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView, Standard_False); + AIS_StatusOfPick aPickStatus = anAISContext->SelectRectangle (Graphic3d_Vec2i (aXPixMin, aYPixMin), + Graphic3d_Vec2i (aXPixMax, aYPixMax), + aV3dView); theDi << (aPickStatus == AIS_SOP_NothingSelected ? "status = AIS_SOP_NothingSelected : OK" : "status = AIS_SOP_NothingSelected : bugged - Faulty "); @@ -197,7 +199,9 @@ static Standard_Integer BUC60774 (Draw_Interpretor& theDi, theDi.Eval ("box b 10 10 10"); theDi.Eval (" vdisplay b"); - aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView, Standard_False); + aPickStatus = anAISContext->SelectRectangle (Graphic3d_Vec2i (aXPixMin, aYPixMin), + Graphic3d_Vec2i (aXPixMax, aYPixMax), + aV3dView); theDi << (aPickStatus == AIS_SOP_OneSelected ? "status = AIS_SOP_OneSelected : OK" : "status = AIS_SOP_OneSelected : bugged - Faulty "); @@ -206,7 +210,10 @@ static Standard_Integer BUC60774 (Draw_Interpretor& theDi, theDi.Eval ("box w 20 20 20 20 20 20"); theDi.Eval (" vdisplay w"); - aPickStatus = anAISContext->Select (aXPixMin, aYPixMin, aXPixMax, aYPixMax, aV3dView, Standard_True); + aPickStatus = anAISContext->SelectRectangle (Graphic3d_Vec2i (aXPixMin, aYPixMin), + Graphic3d_Vec2i (aXPixMax, aYPixMax), + aV3dView); + anAISContext->UpdateCurrentViewer(); theDi << (aPickStatus == AIS_SOP_SeveralSelected ? "status = AIS_SOP_SeveralSelected : OK" : "status = AIS_SOP_SeveralSelected : bugged - Faulty "); diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index dfce9c34fe..0854083c7a 100644 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -4217,9 +4217,9 @@ static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*th aCtx->SetWidth (aBox2, 3, Standard_False); aCtx->MoveTo (305, 322, ViewerTest::CurrentView(), Standard_False); - aCtx->ShiftSelect (Standard_False); + aCtx->SelectDetected (AIS_SelectionScheme_XOR); aCtx->MoveTo (103, 322, ViewerTest::CurrentView(), Standard_False); - aCtx->ShiftSelect (Standard_False); + aCtx->SelectDetected (AIS_SelectionScheme_XOR); if (aCtx->NbSelected() != 0) { theDI << "ERROR: no boxes must be selected!\n"; @@ -4229,14 +4229,14 @@ static Standard_Integer OCC26462 (Draw_Interpretor& theDI, Standard_Integer /*th aCtx->SetSelectionSensitivity (aBox1, 2, 5); aCtx->MoveTo (305, 322, ViewerTest::CurrentView(), Standard_False); - aCtx->ShiftSelect (Standard_False); + aCtx->SelectDetected (AIS_SelectionScheme_XOR); if (aCtx->NbSelected() != 1) { theDI << "ERROR: b1 was not selected\n"; return 1; } aCtx->MoveTo (103, 322, ViewerTest::CurrentView(), Standard_False); - aCtx->ShiftSelect (Standard_True); + aCtx->SelectDetected (AIS_SelectionScheme_XOR); if (aCtx->NbSelected() != 1) { theDI << "ERROR: b2 is selected after b1's tolerance increased\n"; @@ -5170,7 +5170,8 @@ static Standard_Integer OCC28310 (Draw_Interpretor& /*theDI*/, Standard_Integer aCtx->Display (aBoxObj, AIS_Shaded, 0, Standard_False); ViewerTest::CurrentView()->FitAll(); aCtx->MoveTo (200, 200, ViewerTest::CurrentView(), Standard_True); - aCtx->Select(Standard_True); + aCtx->SelectDetected(); + aCtx->UpdateCurrentViewer(); aCtx->Remove (aBoxObj, Standard_True); // nullify the object explicitly to simulate situation in project, diff --git a/src/ViewerTest/ViewerTest_EventManager.hxx b/src/ViewerTest/ViewerTest_EventManager.hxx index 6d2fed7caf..eb21701637 100644 --- a/src/ViewerTest/ViewerTest_EventManager.hxx +++ b/src/ViewerTest/ViewerTest_EventManager.hxx @@ -26,7 +26,7 @@ class V3d_View; DEFINE_STANDARD_HANDLE(ViewerTest_EventManager, Standard_Transient) -//! used to manage mouse event (move,select,shiftselect) +//! used to manage mouse event (move,select) //! By default the events are transmitted to interactive context. class ViewerTest_EventManager : public Standard_Transient, public AIS_ViewController { diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 8398f55a85..0fe7bdd54f 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -7556,7 +7556,8 @@ static Standard_Integer VSelect (Draw_Interpretor& , } NCollection_Sequence aPnts; - bool isShiftSelection = false, toAllowOverlap = false; + bool toAllowOverlap = false; + AIS_SelectionScheme aSelScheme = AIS_SelectionScheme_Replace; for (Standard_Integer anArgIter = 1; anArgIter < theNbArgs; ++anArgIter) { TCollection_AsciiString anArg (theArgVec[anArgIter]); @@ -7580,7 +7581,10 @@ static Standard_Integer VSelect (Draw_Interpretor& , else if (anArgIter + 1 == theNbArgs && anArg.IsIntegerValue()) { - isShiftSelection = anArg.IntegerValue() == 1; + if (anArg.IntegerValue() == 1) + { + aSelScheme = AIS_SelectionScheme_XOR; + } } else { @@ -7602,14 +7606,7 @@ static Standard_Integer VSelect (Draw_Interpretor& , Handle(ViewerTest_EventManager) aCurrentEventManager = ViewerTest::CurrentEventManager(); if (aPnts.IsEmpty()) { - if (isShiftSelection) - { - aCtx->ShiftSelect (false); - } - else - { - aCtx->Select (false); - } + aCtx->SelectDetected (aSelScheme); aCtx->CurrentViewer()->Invalidate(); } else if (aPnts.Length() == 2) @@ -7624,11 +7621,11 @@ static Standard_Integer VSelect (Draw_Interpretor& , { std::swap (aPnts.ChangeFirst(), aPnts.ChangeLast()); } - aCurrentEventManager->SelectInViewer (aPnts, isShiftSelection); + aCurrentEventManager->SelectInViewer (aPnts, aSelScheme == AIS_SelectionScheme_XOR); } else { - aCurrentEventManager->SelectInViewer (aPnts, isShiftSelection); + aCurrentEventManager->SelectInViewer (aPnts, aSelScheme == AIS_SelectionScheme_XOR); } aCurrentEventManager->FlushViewEvents (aCtx, ViewerTest::CurrentView(), true); return 0; -- 2.39.5