]> 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)
committerage <age@opencascade.com>
Tue, 24 Nov 2020 08:17:09 +0000 (11:17 +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)

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 56221469eef8364642ec007c6cd75be928c331de..7507359b9bd3799ebc6ff31671e0d09689af4448 100644 (file)
@@ -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:
 ~~~~~
index d333aa649cde96083be090abb67051a4f8db3b8b..3f3f24a9cfb8aba707501c4e7b94536e741be3ac 100644 (file)
@@ -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();
     }
   }
 
index e79cc4acaae4230c075207421f3ada7387f2a6ab..244f8803491afcc1c168f9b2c4487df23427ab1d 100644 (file)
@@ -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();
     }
   }
 
index 16933e46ac52fc387c37e8aa234d316e3793c95e..e32b94ce55ef7b6ff0317079c52d291823e6ce4e 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 03b667f934e0a290a6c5e96ca5651c49adf9ba39..a263b69a9cb78349667f7feaa66e6760329138c7 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 7578112cb0ff55a3aaf59643ad3f4a0655a4fe82..389d9eaec3fb50359b66b1754b57163a77f77709 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 6bfd1944bdd92b142960d1df85d9c6859dc7b6ba..da3a5b59d1ffb456fc1b372233e918c2b301fe53 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>
@@ -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,
index e572a867910bfe08248d147a5aac0706a3211de1..4c535c3cfc04177b489bba763729af173b891dff 100644 (file)
@@ -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();
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 0e2ce3a0a9d1445f52cbe163d1c09b353572a85e..4f3d19e0b2c960209a10285fadc1446ed6e6020b 100644 (file)
@@ -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);
         }
       }
 
index 6aae4133282f4d5e77fc3c28c6d16c3be5a63873..e26ea6ae8b29766afe12a5270efc6d066901866d 100644 (file)
@@ -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
index 5409cdcffe8acc6d59130fe90a19cac6ab8aa43d..f0fbf53fbbb819583a8364778e67aea5badaa93c 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 dfce9c34fe33f95f2789e14595915fc072ea9cc2..0854083c7aac60c0ff277557f88e3cc0aae76c94 100644 (file)
@@ -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,
index 6d2fed7caf120ae4b6856a790c92fd00290c1d5d..eb21701637d51f0280498608d21ebd521d6ed24c 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 8398f55a85fa29999651450590d086e191b0d06a..0fe7bdd54fa5e6e0a6d9df6873c74f7434c38d65 100644 (file)
@@ -7556,7 +7556,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]);
@@ -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;