]> OCCT Git - occt-copy.git/commitdiff
0030737: Visualization - implementing new selection schemes in context
authornds <nds@opencascade.com>
Wed, 28 Oct 2020 18:16:27 +0000 (21:16 +0300)
committerage <age@opencascade.com>
Tue, 24 Nov 2020 11:39:18 +0000 (14:39 +0300)
AIS_SelectionScheme_ReplaceExtra introduce

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_Selection.hxx
src/AIS/AIS_SelectionScheme.hxx

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 7507359b9bd3799ebc6ff31671e0d09689af4448..9543610e1292cbdfa8271c7280f0b4f77f0c9b91 100644 (file)
@@ -859,6 +859,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, ""} |  | AIS_SelectionScheme_ReplaceExtra | @figure{visualization_selection_scheme_replaceExtra.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.
@@ -1430,7 +1441,7 @@ aView->Update();
 
 @subsubsection occt_visu_4_4_5 Perspective Projection
 
-**Field of view (FOVy)** -- defines the field of camera view by y axis in degrees (45° is default).
+**Field of view (FOVy)** -- defines the field of camera view by y axis in degrees (45° is default).
 
 @figure{camera_perspective.png,"Perspective frustum",420}
 
@@ -1452,7 +1463,7 @@ There are two types of IOD:
 * _IODType_Absolute_ : Intraocular distance is defined as an absolute value.
 * _IODType_Relative_ : Intraocular distance is defined relative to the camera focal length (as its coefficient).
 
-**Field of view (FOV)** -- defines the field of camera view by y axis in degrees (45° is default).
+**Field of view (FOV)** -- defines the field of camera view by y axis in degrees (45° is default).
 
 **ZFocus** -- defines the distance to the point of stereographic focus.
 
index c914031b06f01c7e71da2c71b293d53f57456b6d..10b14103674fa073fea50236a89ec46aedc09e75 100644 (file)
@@ -197,6 +197,35 @@ void AIS_Selection::SelectOwners (const AIS_NListOfEntityOwner& thePickedOwners,
       Clear();
       return;
     }
+    case AIS_SelectionScheme_ReplaceExtra:
+    {
+      AIS_NListOfEntityOwner aPrevSelected = Objects();
+      Clear();
+
+      Standard_Boolean toAppend = false;
+      if (thePickedOwners.Size() < aPrevSelected.Size())
+      {
+        // check if all picked objects are in previous selected list, if so, all objects will be deselected,
+        // but in mode AIS_SelectionScheme_PickedIfEmpty new picked objects should be selected, here, after Clear, Add
+        Standard_Boolean anOtherFound = Standard_False;
+        for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
+        {
+          anOtherFound = !aPrevSelected.Contains (aSelIter.Value());
+          if (anOtherFound)
+            break;
+        }
+        if (!anOtherFound)
+          toAppend = Standard_True;
+      }
+      for (AIS_NListOfEntityOwner::Iterator aSelIter (thePickedOwners); aSelIter.More(); aSelIter.Next())
+      {
+        if (toAppend)
+          appendOwner (aSelIter.Value(), theFilter);
+        else
+          XOROwner(aSelIter.Value(), aPrevSelected, theFilter);
+      }
+      return;
+    }
   }
 }
 
@@ -216,3 +245,26 @@ AIS_SelectStatus AIS_Selection::appendOwner (const Handle(SelectMgr_EntityOwner)
 
   return AddSelect (theOwner);
 }
+
+//=======================================================================
+//function : XOROwner
+//purpose  : 
+//=======================================================================
+AIS_SelectStatus AIS_Selection::XOROwner (const Handle(SelectMgr_EntityOwner)& theOwner,
+                                          const AIS_NListOfEntityOwner& thePreviousSelected,
+                                          const Handle(SelectMgr_Filter)& theFilter)
+{
+  if (theOwner.IsNull() || !theOwner->HasSelectable() || !theFilter->IsOk (theOwner))
+    return AIS_SS_NotDone;
+
+  if (thePreviousSelected.Contains (theOwner)) // was selected, should not be now
+  {
+    if (theOwner->IsSelected())
+      return Select (theOwner); // deselect
+  }
+  else
+  {
+    return AddSelect (theOwner); // was not selected, should be now
+  }
+  return AIS_SS_NotDone;
+}
index d3163ce1545587931ca677f656c143521caef58c..2e0bca838090a2dded2c180fa8d7826657324fb6 100644 (file)
@@ -95,6 +95,15 @@ protected:
   Standard_EXPORT virtual AIS_SelectStatus appendOwner (const Handle(SelectMgr_EntityOwner)& theOwner,
                                                         const Handle(SelectMgr_Filter)& theFilter);
 
+  //! XOR the owner to the current selection if filter is Ok.
+  //! \param theOwner element to change selection state
+  //! \param thePreviousSelected previous selected objects
+  //! \param theFilter context filter to skip not acceptable owners
+  //! \return result of selection
+  Standard_EXPORT virtual AIS_SelectStatus XOROwner (const Handle(SelectMgr_EntityOwner)& theOwner,
+                                                     const AIS_NListOfEntityOwner& thePreviousSelected,
+                                                     const Handle(SelectMgr_Filter)& theFilter);
+
 protected:
 
   AIS_NListOfEntityOwner myresult;
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