]> OCCT Git - occt-copy.git/commitdiff
0031221: Visualization - selection filter in context
authorsshutina <sshutina@opencascade.com>
Fri, 13 Dec 2019 13:27:51 +0000 (16:27 +0300)
committersshutina <sshutina@opencascade.com>
Fri, 13 Dec 2019 14:33:33 +0000 (17:33 +0300)
src/AIS/AIS_InteractiveContext_1.cxx
src/SelectMgr/FILES
src/SelectMgr/SelectMgr_AndFilter.cxx
src/SelectMgr/SelectMgr_AndFilter.hxx
src/SelectMgr/SelectMgr_Filter.hxx
src/SelectMgr/SelectMgr_FilterReaction.hxx [new file with mode: 0644]

index 6252c69fd5a2b7305119749af115c5a83fbde803..bdf4d9852f148dd9180647a98da5c8508179e5fe 100644 (file)
@@ -35,6 +35,7 @@
 #include <SelectMgr_DisabledObjectsFilter.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <SelectMgr_Filter.hxx>
+#include <SelectMgr_FilterReaction.hxx>
 #include <SelectMgr_OrFilter.hxx>
 #include <SelectMgr_Selection.hxx>
 #include <SelectMgr_SelectionManager.hxx>
@@ -351,7 +352,7 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer  th
   {
     Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
     if (anOwner.IsNull()
-     || !myFilters->IsOk (anOwner))
+     || !myFilters->IsOk (anOwner, SelectMgr_FilterReaction_Highlight))
     {
       if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost)
       {
@@ -837,7 +838,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
   for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
   {
     const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value();
-    if (!myFilters->IsOk (aSelOwner))
+    if (!myFilters->IsOk (aSelOwner, SelectMgr_FilterReaction_Select))
     {
       continue;
     }
@@ -885,7 +886,7 @@ void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& t
 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
                                           const Standard_Boolean theToUpdateViewer)
 {
-  if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
+  if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner, SelectMgr_FilterReaction_Select))
     return;
 
   const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
@@ -961,7 +962,7 @@ void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityO
   if (theOwner.IsNull() || !theOwner->HasSelectable())
     return;
 
-  if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
+  if (!myFilters->IsOk(theOwner, SelectMgr_FilterReaction_Select) && !theOwner->IsSelected())
     return;
 
   mySelection->Select (theOwner);
index a51f8d0eb1f289c475ed14559a532be4e5bf3732..3c05be68b88f2351cb1e1fe48be4bbc263bfdd05 100755 (executable)
@@ -11,6 +11,7 @@ SelectMgr_EntityOwner.cxx
 SelectMgr_EntityOwner.hxx
 SelectMgr_Filter.cxx
 SelectMgr_Filter.hxx
+SelectMgr_FilterReaction.hxx
 SelectMgr_Frustum.hxx
 SelectMgr_Frustum.lxx
 SelectMgr_FrustumBuilder.cxx
index 15425280b5a6b55d35e9a4a59ee0ce1da6abe660..03f9530e6b7821c2b4abb7dd57eb75ad7987c4e8 100644 (file)
@@ -24,11 +24,12 @@ IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_AndFilter,SelectMgr_CompositionFilter)
 SelectMgr_AndFilter::SelectMgr_AndFilter()
 {
 }
-Standard_Boolean SelectMgr_AndFilter::IsOk(const Handle(SelectMgr_EntityOwner)& anobj) const 
+Standard_Boolean SelectMgr_AndFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theObj,
+                                           const SelectMgr_FilterReaction& theReaction) const
 {
   SelectMgr_ListIteratorOfListOfFilter it(myFilters);
-  for ( ; it.More();it.Next()) 
-    if(!it.Value()->IsOk(anobj)) 
+  for ( ; it.More();it.Next())
+    if(!it.Value()->IsOk(theObj, theReaction))
       return Standard_False;
   return Standard_True;
 }
index 9b76728b4bc67ede1bd4277d1a2c47c2ed3894a1..540605673879711da75d8791e933c619b666b11a 100644 (file)
@@ -40,9 +40,11 @@ public:
   //! more types of entity.
   Standard_EXPORT SelectMgr_AndFilter();
   
-  Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE;
-
+  Standard_EXPORT Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anobj) const Standard_OVERRIDE 
+  { return Standard_False; }
 
+  Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& theObj,
+                                                 const SelectMgr_FilterReaction& theReaction) const;
 
 
   DEFINE_STANDARD_RTTIEXT(SelectMgr_AndFilter,SelectMgr_CompositionFilter)
index af9cf7e8b394776df8230d9af5e59c446f10df97..be2a82bf0d3a143aa7d7ad8377072053e227f0b7 100644 (file)
@@ -20,6 +20,7 @@
 #include <Standard.hxx>
 #include <Standard_Type.hxx>
 
+#include <SelectMgr_FilterReaction.hxx>
 #include <Standard_Transient.hxx>
 #include <Standard_Boolean.hxx>
 #include <TopAbs_ShapeEnum.hxx>
@@ -60,6 +61,24 @@ public:
   //! virtual function ActsOn.
   Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const = 0;
   
+  //! Indicates that the selected Interactive Object
+  //! passes the filter. The owner, anObj, can be either
+  //! direct or user. A direct owner is the corresponding
+  //! construction element, whereas a user is the
+  //! compound shape of which the entity forms a part.
+  //! When an object is detected by the mouse - in AIS,
+  //! this is done through a context selector - its owner
+  //! is passed to the filter as an argument.
+  //! If the object returns Standard_True, it is kept; if
+  //! not, it is rejected.
+  //! If you are creating a filter class inheriting this
+  //! framework, and the daughter class is to be used in
+  //! an AIS local context, you will need to implement the
+  //! virtual function ActsOn.
+  Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& theObj,
+                                                 const SelectMgr_FilterReaction& theReaction) 
+  { return IsOk (theObj); }
+
   //! Returns true in an AIS local context, if this filter
   //! operates on a type of subshape defined in a filter
   //! class inheriting this framework.
diff --git a/src/SelectMgr/SelectMgr_FilterReaction.hxx b/src/SelectMgr/SelectMgr_FilterReaction.hxx
new file mode 100644 (file)
index 0000000..939adb1
--- /dev/null
@@ -0,0 +1,26 @@
+// 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 _SelectMgr_FilterReaction_HeaderFile
+#define _SelectMgr_FilterReaction_HeaderFile
+
+//! Enumeration defines picking reaction - which action causes the filter check
+enum SelectMgr_FilterReaction
+{
+  SelectMgr_FilterReaction_Empty = 0x0000, //!< do nothing
+  SelectMgr_FilterReaction_Highlight = 0x0001, //!< the reaction to highlght presentation (MoveTo)
+  SelectMgr_FilterReaction_Select = 0x0002, //!< the reaction to highlght presentation (Select)
+  SelectMgr_FilterReaction_SelectAndHighlight = SelectMgr_FilterReaction_Highlight | SelectMgr_FilterReaction_Select
+};
+
+#endif // _SelectMgr_FilterReaction_HeaderFile