]> OCCT Git - occt-copy.git/commitdiff
0030737: Visualization - implementing new selection schemes in context
authornds <nds@opencascade.com>
Fri, 18 Sep 2020 18:36:05 +0000 (21:36 +0300)
committernds <nds@opencascade.com>
Tue, 27 Oct 2020 12:21:04 +0000 (15:21 +0300)
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)

(cherry picked from commit 8b392af6ba0dd45465de2ac640db37095f99dc3c)

24 files changed:
dox/user_guides/visualization/images/visualization_selection_scheme_XOR.svg [new file with mode: 0644]
dox/user_guides/visualization/images/visualization_selection_scheme_add.svg [new file with mode: 0644]
dox/user_guides/visualization/images/visualization_selection_scheme_clear.svg [new file with mode: 0644]
dox/user_guides/visualization/images/visualization_selection_scheme_remove.svg [new file with mode: 0644]
dox/user_guides/visualization/images/visualization_selection_scheme_replace.svg [new file with mode: 0644]
dox/user_guides/visualization/visualization.md
samples/CSharp/OCCTProxy/OCCTProxy.cpp
samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp
samples/mfc/standard/01_Geometry/src/GeometryDoc.cpp
samples/mfc/standard/02_Modeling/src/ModelingDoc.cpp
samples/mfc/standard/04_Viewer3d/src/Viewer3dDoc.cpp
samples/mfc/standard/08_HLR/src/HLRView3D.cpp
samples/mfc/standard/Common/OCC_3dBaseDoc.cpp
src/AIS/AIS_InteractiveContext.hxx
src/AIS/AIS_InteractiveContext_1.cxx
src/AIS/AIS_Selection.cxx
src/AIS/AIS_Selection.hxx
src/AIS/AIS_SelectionScheme.hxx [new file with mode: 0644]
src/AIS/AIS_ViewController.cxx
src/AIS/FILES
src/QABugs/QABugs_16.cxx
src/QABugs/QABugs_19.cxx
src/ViewerTest/ViewerTest_EventManager.hxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx

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 (file)
index 0000000..c4b0325
--- /dev/null
@@ -0,0 +1,27 @@
+<svg width="188" height="90" viewBox="0 0 188 90" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="188" height="90" fill="white"/>
+<rect x="6.5" y="6.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 8V16H13V26H21V16H26V8H8Z" fill="#DDDDDD"/>
+<path d="M42 15H41V16V25H35V9H51V15H42Z" fill="#DDDDDD" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 18V8H63V18H60V26H80V18H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="34.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 36V44H13V54H21V44H26V36H8Z" fill="#DDDDDD"/>
+<path d="M42 43H41V44V53H35V37H51V43H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 46V36H63V46H60V54H80V46H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="62.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 64V72H13V82H21V72H26V64H8Z" fill="#3D3ACF"/>
+<path d="M42 71H41V72V81H35V65H51V71H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 74V64H63V74H60V82H80V74H71Z" fill="#3D3ACF"/>
+<path d="M93 10L100 17L93 24V20H84V14H93V10Z" fill="#7C97DE"/>
+<path d="M93 38L100 45L93 52V48H84V42H93V38Z" fill="#7C97DE"/>
+<path d="M93 66L100 73L93 80V76H84V70H93V66Z" fill="#7C97DE"/>
+<path d="M108 8V16H113V26H121V16H126V8H108Z" fill="#DDDDDD"/>
+<path d="M108 36V44H113V54H121V44H126V36H108Z" fill="#DDDDDD"/>
+<path d="M108 64V72H113V82H121V72H126V64H108Z" fill="#3D3ACF"/>
+<path d="M152 8H134V26H142V16H152V8Z" fill="#3D3ACF"/>
+<path d="M152 36H134V54H142V44H152V36Z" fill="#DDDDDD"/>
+<path d="M152 64H134V82H142V72H152V64Z" fill="#DDDDDD"/>
+<path d="M171 18V8H163V18H160V26H180V18H171Z" fill="#DDDDDD"/>
+<path d="M171 46V36H163V46H160V54H180V46H171Z" fill="#DDDDDD"/>
+<path d="M171 74V64H163V74H160V82H180V74H171Z" fill="#3D3ACF"/>
+</svg>
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 (file)
index 0000000..62ce81e
--- /dev/null
@@ -0,0 +1,27 @@
+<svg width="188" height="90" viewBox="0 0 188 90" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="188" height="90" fill="white"/>
+<rect x="6.5" y="6.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 8V16H13V26H21V16H26V8H8Z" fill="#DDDDDD"/>
+<path d="M42 15H41V16V25H35V9H51V15H42Z" fill="#DDDDDD" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 18V8H63V18H60V26H80V18H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="34.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 36V44H13V54H21V44H26V36H8Z" fill="#DDDDDD"/>
+<path d="M42 43H41V44V53H35V37H51V43H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 46V36H63V46H60V54H80V46H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="62.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 64V72H13V82H21V72H26V64H8Z" fill="#3D3ACF"/>
+<path d="M42 71H41V72V81H35V65H51V71H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 74V64H63V74H60V82H80V74H71Z" fill="#3D3ACF"/>
+<path d="M93 10L100 17L93 24V20H84V14H93V10Z" fill="#7C97DE"/>
+<path d="M93 38L100 45L93 52V48H84V42H93V38Z" fill="#7C97DE"/>
+<path d="M93 66L100 73L93 80V76H84V70H93V66Z" fill="#7C97DE"/>
+<path d="M108 8V16H113V26H121V16H126V8H108Z" fill="#DDDDDD"/>
+<path d="M108 36V44H113V54H121V44H126V36H108Z" fill="#DDDDDD"/>
+<path d="M108 64V72H113V82H121V72H126V64H108Z" fill="#3D3ACF"/>
+<path d="M152 8H134V26H142V16H152V8Z" fill="#3D3ACF"/>
+<path d="M152 36H134V54H142V44H152V36Z" fill="#3D3ACF"/>
+<path d="M152 64H134V82H142V72H152V64Z" fill="#3D3ACF"/>
+<path d="M171 18V8H163V18H160V26H180V18H171Z" fill="#DDDDDD"/>
+<path d="M171 46V36H163V46H160V54H180V46H171Z" fill="#DDDDDD"/>
+<path d="M171 74V64H163V74H160V82H180V74H171Z" fill="#3D3ACF"/>
+</svg>
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 (file)
index 0000000..e3b149c
--- /dev/null
@@ -0,0 +1,27 @@
+<svg width="188" height="90" viewBox="0 0 188 90" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="188" height="90" fill="white"/>
+<rect x="6.5" y="6.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 8V16H13V26H21V16H26V8H8Z" fill="#DDDDDD"/>
+<path d="M42 15H41V16V25H35V9H51V15H42Z" fill="#DDDDDD" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 18V8H63V18H60V26H80V18H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="34.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 36V44H13V54H21V44H26V36H8Z" fill="#DDDDDD"/>
+<path d="M42 43H41V44V53H35V37H51V43H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 46V36H63V46H60V54H80V46H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="62.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 64V72H13V82H21V72H26V64H8Z" fill="#3D3ACF"/>
+<path d="M42 71H41V72V81H35V65H51V71H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 74V64H63V74H60V82H80V74H71Z" fill="#3D3ACF"/>
+<path d="M93 10L100 17L93 24V20H84V14H93V10Z" fill="#7C97DE"/>
+<path d="M93 38L100 45L93 52V48H84V42H93V38Z" fill="#7C97DE"/>
+<path d="M93 66L100 73L93 80V76H84V70H93V66Z" fill="#7C97DE"/>
+<path d="M108 8V16H113V26H121V16H126V8H108Z" fill="#DDDDDD"/>
+<path d="M108 36V44H113V54H121V44H126V36H108Z" fill="#DDDDDD"/>
+<path d="M108 64V72H113V82H121V72H126V64H108Z" fill="#DDDDDD"/>
+<path d="M152 8H134V26H142V16H152V8Z" fill="#DDDDDD"/>
+<path d="M152 36H134V54H142V44H152V36Z" fill="#DDDDDD"/>
+<path d="M152 64H134V82H142V72H152V64Z" fill="#DDDDDD"/>
+<path d="M171 18V8H163V18H160V26H180V18H171Z" fill="#DDDDDD"/>
+<path d="M171 46V36H163V46H160V54H180V46H171Z" fill="#DDDDDD"/>
+<path d="M171 74V64H163V74H160V82H180V74H171Z" fill="#DDDDDD"/>
+</svg>
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 (file)
index 0000000..f3ec7fb
--- /dev/null
@@ -0,0 +1,27 @@
+<svg width="188" height="90" viewBox="0 0 188 90" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="188" height="90" fill="white"/>
+<rect x="6.5" y="6.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 8V16H13V26H21V16H26V8H8Z" fill="#DDDDDD"/>
+<path d="M42 15H41V16V25H35V9H51V15H42Z" fill="#DDDDDD" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 18V8H63V18H60V26H80V18H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="34.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 36V44H13V54H21V44H26V36H8Z" fill="#DDDDDD"/>
+<path d="M42 43H41V44V53H35V37H51V43H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 46V36H63V46H60V54H80V46H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="62.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 64V72H13V82H21V72H26V64H8Z" fill="#3D3ACF"/>
+<path d="M42 71H41V72V81H35V65H51V71H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 74V64H63V74H60V82H80V74H71Z" fill="#3D3ACF"/>
+<path d="M93 10L100 17L93 24V20H84V14H93V10Z" fill="#7C97DE"/>
+<path d="M93 38L100 45L93 52V48H84V42H93V38Z" fill="#7C97DE"/>
+<path d="M93 66L100 73L93 80V76H84V70H93V66Z" fill="#7C97DE"/>
+<path d="M108 8V16H113V26H121V16H126V8H108Z" fill="#DDDDDD"/>
+<path d="M108 36V44H113V54H121V44H126V36H108Z" fill="#DDDDDD"/>
+<path d="M108 64V72H113V82H121V72H126V64H108Z" fill="#3D3ACF"/>
+<path d="M152 8H134V26H142V16H152V8Z" fill="#DDDDDD"/>
+<path d="M152 36H134V54H142V44H152V36Z" fill="#DDDDDD"/>
+<path d="M152 64H134V82H142V72H152V64Z" fill="#DDDDDD"/>
+<path d="M171 18V8H163V18H160V26H180V18H171Z" fill="#DDDDDD"/>
+<path d="M171 46V36H163V46H160V54H180V46H171Z" fill="#DDDDDD"/>
+<path d="M171 74V64H163V74H160V82H180V74H171Z" fill="#3D3ACF"/>
+</svg>
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 (file)
index 0000000..4721c3a
--- /dev/null
@@ -0,0 +1,27 @@
+<svg width="188" height="90" viewBox="0 0 188 90" fill="none" xmlns="http://www.w3.org/2000/svg">
+<rect width="188" height="90" fill="white"/>
+<rect x="6.5" y="6.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 8V16H13V26H21V16H26V8H8Z" fill="#DDDDDD"/>
+<path d="M42 15H41V16V25H35V9H51V15H42Z" fill="#DDDDDD" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 18V8H63V18H60V26H80V18H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="34.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 36V44H13V54H21V44H26V36H8Z" fill="#DDDDDD"/>
+<path d="M42 43H41V44V53H35V37H51V43H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 46V36H63V46H60V54H80V46H71Z" fill="#DDDDDD"/>
+<rect x="6.5" y="62.5" width="75" height="21" stroke="#7C97DE"/>
+<path d="M8 64V72H13V82H21V72H26V64H8Z" fill="#3D3ACF"/>
+<path d="M42 71H41V72V81H35V65H51V71H42Z" fill="#3D3ACF" stroke="#5BD6B8" stroke-width="2"/>
+<path d="M71 74V64H63V74H60V82H80V74H71Z" fill="#3D3ACF"/>
+<path d="M93 10L100 17L93 24V20H84V14H93V10Z" fill="#7C97DE"/>
+<path d="M93 38L100 45L93 52V48H84V42H93V38Z" fill="#7C97DE"/>
+<path d="M93 66L100 73L93 80V76H84V70H93V66Z" fill="#7C97DE"/>
+<path d="M108 8V16H113V26H121V16H126V8H108Z" fill="#DDDDDD"/>
+<path d="M108 36V44H113V54H121V44H126V36H108Z" fill="#DDDDDD"/>
+<path d="M108 64V72H113V82H121V72H126V64H108Z" fill="#DDDDDD"/>
+<path d="M152 8H134V26H142V16H152V8Z" fill="#3D3ACF"/>
+<path d="M152 36H134V54H142V44H152V36Z" fill="#3D3ACF"/>
+<path d="M152 64H134V82H142V72H152V64Z" fill="#3D3ACF"/>
+<path d="M171 18V8H163V18H160V26H180V18H171Z" fill="#DDDDDD"/>
+<path d="M171 46V36H163V46H160V54H180V46H171Z" fill="#DDDDDD"/>
+<path d="M171 74V64H163V74H160V82H180V74H171Z" fill="#DDDDDD"/>
+</svg>
index b557ed2763f15b33b084ac06a8af16451ef50c6c..403749d53ef92929ecf0341e1ff82366f4d90738 100644 (file)
@@ -989,13 +989,10 @@ myContext->MoveTo (thePixelX, thePixelY, myView, true);
 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:
@@ -1009,7 +1006,7 @@ The following functions can be used:
   * *AIS_InteractiveContext::HasDetected* -- checks if there is a detected entity;
   * *AIS_InteractiveContext::DetectedOwner* -- returns the (currently highlighted) detected entity.
 
-After using the *Select* and *ShiftSelect* functions, you can explore the list of selections.
+After using the *Select* function, you can explore the list of selections.
 The following functions can be used:
   * *AIS_InteractiveContext::InitSelected* -- initializes an iterator;
   * *AIS_InteractiveContext::MoreSelected* -- checks if the iterator is valid;
@@ -1035,6 +1032,17 @@ for (myAISCtx->InitSelected(); myAISCtx->MoreSelected(); myAISCtx->NextSelected(
 }
 ~~~~~
 
+@subsubsection occt_visu_3_4_7 Selection schemes
+
+Select* methods of AIS_InteractiveContext accept some selection scheme as parameter. The table below describes available selection schemes.
+
+| Type | Reaction on click |  | Type | Reaction on click |
+| :----- | :----- | :----- | :----- | :----- |
+| AIS_SelectionScheme_Replace | @figure{visualization_selection_scheme_replace.svg, ""} |  | AIS_SelectionScheme_XOR | @figure{visualization_selection_scheme_XOR.svg, ""} |
+| AIS_SelectionScheme_Add | @figure{visualization_selection_scheme_add.svg, ""} |  | AIS_SelectionScheme_Clear | @figure{visualization_selection_scheme_clear.svg, ""} |
+| AIS_SelectionScheme_Remove | @figure{visualization_selection_scheme_remove.svg, ""} |  |  |  |
+
+
 @subsection occt_visu_3_5 Standard Interactive Object Classes
 
 Interactive Objects are selectable and viewable objects connecting graphic representation and the underlying reference geometry.
index f1702659e8179025c653ee202c50c03d93ff2ac0..d20a4f6b9b664561332e63b8b1bbcd33e117767d 100644 (file)
@@ -246,7 +246,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();
     }
   }
 
@@ -257,7 +260,8 @@ public:
   {
     if (!myAISContext().IsNull())
     {
-      myAISContext()->Select (Standard_True);
+      myAISContext()->SelectDetected();
+      myAISContext()->UpdateCurrentViewer();
     }
   }
 
@@ -279,7 +283,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();
     }
   }
 
@@ -290,7 +298,8 @@ public:
   {
     if (!myAISContext().IsNull())
     {
-      myAISContext()->ShiftSelect (Standard_True);
+      myAISContext()->SelectDetected (AIS_SelectionScheme_XOR);
+      myAISContext()->UpdateCurrentViewer();
     }
   }
 
index 3ea7ef9c549362562d1c24c8d9ddcc1443eca124..51bf0a56ba81dcf281d6fa9c5590fc5665320785 100644 (file)
@@ -263,7 +263,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();
     }
   }
 
@@ -274,7 +277,8 @@ public:
   {
     if (!myAISContext().IsNull())
     {
-      myAISContext()->Select (Standard_True);
+      myAISContext()->SelectDetected();
+      myAISContext()->UpdateCurrentViewer();
     }
   }
 
@@ -296,7 +300,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();
     }
   }
 
@@ -307,7 +315,8 @@ public:
   {
     if (!myAISContext().IsNull())
     {
-      myAISContext()->ShiftSelect (Standard_True);
+      myAISContext()->SelectDetected (AIS_SelectionScheme_XOR);
+      myAISContext()->UpdateCurrentViewer();
     }
   }
 
index 968d34666a85ba6c4210898e12b3d6720119dd32..964dc232c1a7954b1c458ae3bd1c2faffd590b5c 100755 (executable)
@@ -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();
 }
 
 //-----------------------------------------------------------------------------------------
index 4481c82a7b4735a4a5e22d224eef8f271935627a..0ce9e37db7b7ab73e6c99815f4bf4c54b822e11e 100755 (executable)
@@ -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()) {
index 7e36e17153736988cd6ed1dcf9402021269ecf18..9c43ac150439917dfb75502729660c2114dfec8b 100755 (executable)
@@ -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)
index 3d9bbb6e65a626a2c7398c20d23ddf3ff6b1c432..79dec617fae26331edab157731b187fedef33aa6 100755 (executable)
@@ -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);
 }
 
index 247be698508c3857e3554c724ec51c9e53d180a2..271176a173dc17997c3649cfda8725f72bee6972 100755 (executable)
@@ -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();
 }
 
 //-----------------------------------------------------------------------------------------
index 2e4d57b5a0c805bab6f637473d2c563e7575a7d1..c3d83448d8b9972f45e762bd09322152ede996ba 100644 (file)
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_Selection.hxx>
 #include <AIS_SelectionModesConcurrency.hxx>
+#include <AIS_SelectionScheme.hxx>
 #include <AIS_StatusOfDetection.hxx>
 #include <AIS_StatusOfPick.hxx>
 #include <AIS_TypeOfIso.hxx>
 #include <Aspect_TypeOfFacingModel.hxx>
+#include <Graphic3d_Vec2.hxx>
 #include <Prs3d_Drawer.hxx>
 #include <Prs3d_TypeOfHighlight.hxx>
 #include <PrsMgr_PresentationManager3d.hxx>
@@ -470,8 +472,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,
@@ -480,27 +523,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,
@@ -511,6 +559,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,
index 7c9b44caab04557a34cd47a75593bdb8788629a4..2d536d2f9ab303a69a217dcd922a3d3698a096b2 100644 (file)
@@ -482,95 +482,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)
@@ -582,54 +588,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;
 }
 
 //=======================================================================
@@ -641,39 +674,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;
 }
 
 //=======================================================================
@@ -682,31 +693,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();
index e26bddf82834634843ed256bffbbe47d3c2665f7..c914031b06f01c7e71da2c71b293d53f57456b6d 100644 (file)
@@ -15,6 +15,8 @@
 #include <AIS_Selection.hxx>
 
 #include <AIS_InteractiveObject.hxx>
+#include <AIS_SelectionScheme.hxx>
+#include <SelectMgr_Filter.hxx>
 
 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);
+}
index 8e7cf50e91dd39aa26c7571670340a74175016b2..d3163ce1545587931ca677f656c143521caef58c 100644 (file)
 #define _AIS_Selection_HeaderFile
 
 #include <AIS_NListOfEntityOwner.hxx>
+#include <AIS_SelectionScheme.hxx>
 #include <AIS_SelectStatus.hxx>
 #include <Standard.hxx>
 #include <Standard_Type.hxx>
 
+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 (file)
index 0000000..ef5da37
--- /dev/null
@@ -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
index 4823afed83cb46f2013b601219fee79f220705c6..9ffec5abb6173d4310acb1e9fb99de5523f17198 100644 (file)
@@ -2571,7 +2571,7 @@ void AIS_ViewController::handleXRPicking (const Handle(AIS_InteractiveContext)&
        && aTrigClick.IsPressed
        && aTrigClick.IsChanged)
       {
-        theCtx->Select (false);
+        theCtx->SelectDetected();
         OnSelectionChanged (theCtx, theView);
         if (const Handle(Aspect_XRAction)& aHaptic = theView->View()->XRSession()->GenericAction (myXRLastPickingHand, Aspect_XRGenericAction_OutputHaptic))
         {
@@ -2755,14 +2755,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();
@@ -2864,18 +2857,10 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
           else
           {
             theCtx->MainSelector()->AllowOverlapDetection (aPnt1.y() != Min (aPnt1.y(), aPnt2.y()));
-            if (myGL.Selection.IsXOR)
-            {
-              theCtx->ShiftSelect (Min (aPnt1.x(), aPnt2.x()), Min (aPnt1.y(), aPnt2.y()),
-                                   Max (aPnt1.x(), aPnt2.x()), Max (aPnt1.y(), aPnt2.y()),
-                                   theView, false);
-            }
-            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->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);
           }
         }
@@ -2890,14 +2875,8 @@ void AIS_ViewController::handleSelectionPoly (const Handle(AIS_InteractiveContex
             aPolyIter.ChangeValue() = gp_Pnt2d (aNewPnt.x(), -aNewPnt.y());
           }
 
-          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);
           theCtx->MainSelector()->AllowOverlapDetection (false);
         }
       }
index e5bebe3142a8653c69f8b55747d4456e3e08e982..1f9b18b48f1553902a9696f087deec197e037678 100644 (file)
@@ -88,6 +88,7 @@ AIS_Selection.cxx
 AIS_Selection.hxx
 AIS_SelectStatus.hxx
 AIS_SelectionModesConcurrency.hxx
+AIS_SelectionScheme.hxx
 AIS_SequenceOfInteractive.hxx
 AIS_Shape.cxx
 AIS_Shape.hxx
index bdecc0cd749d45df26338160e17b13a188322fef..751bccf2fb81fc7e4ec8ab2cb1474fcdd566272c 100644 (file)
@@ -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 ");
index 80ac0b3d144f0c5b8c8649d14bd8f2df3468eeaf..319bb6dda860e3a87573299cae95207186e46683 100644 (file)
@@ -4250,9 +4250,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";
@@ -4262,14 +4262,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";
@@ -5203,7 +5203,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,
index d28de8d6c56cde2659f218b895c4e673cd5982ba..2f1fc87d8c7be97fe88ed1d56a1acccba08990e5 100644 (file)
@@ -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
 {
index ffac6b827acf6962d17aa9e5b8dfcb8dfdb80f30..32c24d1aaaced8467f74eb7a7eae717b098d8f1e 100644 (file)
@@ -7547,7 +7547,8 @@ static Standard_Integer VSelect (Draw_Interpretor& ,
   }
 
   NCollection_Sequence<Graphic3d_Vec2i> 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]);
@@ -7571,7 +7572,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
     {
@@ -7588,14 +7592,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)
@@ -7610,11 +7607,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;