]> OCCT Git - occt.git/commitdiff
0032205: Visualization - implementing new selection scheme in context - replace extra
authornds <nds@opencascade.com>
Wed, 28 Oct 2020 18:16:27 +0000 (21:16 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 15 Apr 2021 16:05:56 +0000 (19:05 +0300)
- implementation of additional selection scheme, mainly to deselect single selected object.

dox/user_guides/visualization/images/visualization_selection_scheme_replaceExtra.svg [new file with mode: 0644]
dox/user_guides/visualization/visualization.md
src/AIS/AIS_Selection.cxx
src/AIS/AIS_SelectionScheme.hxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/vselect/bugs/bug32205 [new file with mode: 0644]

diff --git a/dox/user_guides/visualization/images/visualization_selection_scheme_replaceExtra.svg b/dox/user_guides/visualization/images/visualization_selection_scheme_replaceExtra.svg
new file mode 100644 (file)
index 0000000..7e82fec
--- /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="#DDDDDD"/>
+<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 be6016258d00d2204aa7002d635291028199c294..0b88dc1f87b0da5c2386a0c4cc0328b8c5fe64ea 100644 (file)
@@ -1040,7 +1040,7 @@ Select* methods of AIS_InteractiveContext accept some selection scheme as parame
 | :----- | :----- | :----- | :----- | :----- |
 | 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, ""} |  |  |  |
+| AIS_SelectionScheme_Remove | @figure{visualization_selection_scheme_remove.svg, ""} |  | AIS_SelectionScheme_ReplaceExtra | @figure{visualization_selection_scheme_replaceExtra.svg, ""} |
 
 
 @subsection occt_visu_3_5 Standard Interactive Object Classes
index 67d8266e91da7a18668de7ef65f23272f4f01c75..2b55208576e20048a19dca76ce64b5947cfdef83 100644 (file)
@@ -149,6 +149,29 @@ void AIS_Selection::SelectOwners (const AIS_NArray1OfEntityOwner& thePickedOwner
     {
       return;
     }
+    case AIS_SelectionScheme_ReplaceExtra:
+    {
+      // If picked owners is equivalent to the selected then just clear selected
+      // Else go to AIS_SelectionScheme_Replace
+      if (thePickedOwners.Size() == myresult.Size())
+      {
+        Standard_Boolean isTheSame = Standard_True;
+        for (AIS_NArray1OfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
+        {
+          if (!myResultMap.IsBound (aSelIter.Value()))
+          {
+            isTheSame = Standard_False;
+            break;
+          }
+        }
+        if (isTheSame)
+        {
+          Clear();
+          return;
+        }
+      }
+    }
+    Standard_FALLTHROUGH
     case AIS_SelectionScheme_Replace:
     {
       Clear();
index ef5da37a7e0fe893b67a6e4940b0f355fdd8aeb8..a5de1f3e0f7db5e20962c13b8bca87214a6937f3 100644 (file)
@@ -22,7 +22,9 @@ enum AIS_SelectionScheme
   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
+  AIS_SelectionScheme_Clear,        //!< clears current selection
+  AIS_SelectionScheme_ReplaceExtra, //!< replace with one difference: if result of replace is an empty,
+                                    //!< and current selection contains detected element, it will be selected
 };
 
 #endif // _AIS_SelectionScheme_HeaderFile
index 32d0d0c9a910e82f3ee8ce45b419c2b109cb4b9f..0bad61bb812ba3a38d82164155ed51820fc9afb6 100644 (file)
@@ -7264,6 +7264,10 @@ static Standard_Integer VSelect (Draw_Interpretor& ,
     {
       aSelScheme = AIS_SelectionScheme_Replace;
     }
+    else if (anArg == "-replaceextra")
+    {
+      aSelScheme = AIS_SelectionScheme_ReplaceExtra;
+    }
     else if (anArg == "-xor"
           || anArg == "-shift")
     {
@@ -14846,7 +14850,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "\n\t\t: When -closeOnEscape is specified, view will be closed on pressing Escape.",
     __FILE__, VDiffImage, group);
   theCommands.Add ("vselect",
-    "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [-replace|-xor|-add|-remove]\n"
+    "vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [-replace|-replaceextra|-xor|-add|-remove]\n"
     "- emulates different types of selection:\n"
     "- 1) single click selection\n"
     "- 2) selection with rectangle having corners at pixel positions (x1,y1) and (x2,y2)\n"
@@ -14855,7 +14859,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "     If the flag is set to 1, both sensitives that were included completely and overlapped partially by defined \n"
     "     rectangle or polygon will be detected, otherwise algorithm will chose only fully included sensitives.\n"
     "     Default behavior is to detect only full inclusion. (partial inclusion - overlap - is not allowed by default)\n"
-    "- 5) selection scheme replace, xor, add or remove (replace by default)",
+    "- 5) selection scheme replace, replaceextra, xor, add or remove (replace by default)",
     __FILE__, VSelect, group);
   theCommands.Add ("vmoveto",
     "vmoveto [x y] [-reset]"
diff --git a/tests/vselect/bugs/bug32205 b/tests/vselect/bugs/bug32205
new file mode 100644 (file)
index 0000000..7a5ee19
--- /dev/null
@@ -0,0 +1,28 @@
+puts "========"
+puts "0032205:  Visualization - implementing new selection scheme in context - replace extra"
+puts "========"
+puts ""
+
+pload MODELING VISUALIZATION
+box b1  0  0  0 10 10 10
+box b2 20 20 20 30 30 30
+vclear
+vinit View1
+vaxo
+vdisplay -dispMode 1 b1 b2
+vfit
+vselprops selHighlight -dispMode -1
+vselect 0 0 400 400 -xor
+if { ![string match "*Selected*" [vstate b1]] } { puts "Error: b1 should be selected."}
+if { ![string match "*Selected*" [vstate b2]] } { puts "Error: b2 should be selected."}
+vselect 200 200 -replaceExtra
+if {  [string match "*Selected*" [vstate b1]] } { puts "Error: b1 should not be selected."}
+if { ![string match "*Selected*" [vstate b2]] } { puts "Error: b2 should be selected."}
+vselect 200 200 -replaceExtra
+if {  [string match "*Selected*" [vstate b1]] } { puts "Error: b1 should not be selected."}
+if {  [string match "*Selected*" [vstate b2]] } { puts "Error: b2 should not be selected."}
+vselect 200 200 -replaceExtra
+if {  [string match "*Selected*" [vstate b1]] } { puts "Error: b1 should not be selected."}
+if { ![string match "*Selected*" [vstate b2]] } { puts "Error: b2 should be selected."}
+
+vdump $imagedir/${casename}.png