]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ModuleBase/ModuleBase_ViewerFilters.cpp
Salome HOME
Issue #236: Provide filtering of selected objects for extrusion
[modules/shaper.git] / src / ModuleBase / ModuleBase_ViewerFilters.cpp
index b10437101a851b008480626dab1abd86a57e9dae..c18fd0eaee48ff5041442082755b10f51ea28e5f 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <AIS_InteractiveObject.hxx>
 #include <AIS_Shape.hxx>
@@ -81,3 +82,32 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti
   }
   return Standard_False;
 }
+
+
+IMPLEMENT_STANDARD_HANDLE(ModuleBase_ObjectTypesFilter, SelectMgr_Filter);
+IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ObjectTypesFilter, SelectMgr_Filter);
+
+
+//TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340)
+Standard_Boolean ModuleBase_ObjectTypesFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
+{
+  Standard_Boolean isOk = ModuleBase_ShapeDocumentFilter::IsOk(theOwner);
+  if (isOk && theOwner->HasSelectable()) {
+    Handle(AIS_InteractiveObject) aAisObj = 
+      Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+    if (!aAisObj.IsNull()) {
+      boost::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+      aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+      ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+
+      foreach (QString aType, myTypes) {
+        if (aType.toLower() == "construction") {
+          ResultConstructionPtr aConstr = 
+            boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+          return (aConstr != NULL);
+        } // ToDo: Process other types of objects
+      }
+    }
+  }
+  return Standard_False;
+}