Salome HOME
Ignore selection of groups for operations
[modules/shaper.git] / src / PartSet / PartSet_Filters.cpp
index d5df8871ceed90efe5702c36f73a1641c7ee58f1..d82447430e3757d240e7dacbef36fce48ec17ca5 100644 (file)
@@ -7,6 +7,7 @@
 #include "PartSet_Filters.h"
 
 #include <ModuleBase_IWorkshop.h>
+#include "ModuleBase_IModule.h"
 
 #include <ModelAPI_Feature.h>
 #include <FeaturesPlugin_Group.h>
@@ -20,25 +21,35 @@ IMPLEMENT_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter)
 
 Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
-  if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
-    if (theOwner->HasSelectable()) {
-      Handle(AIS_InteractiveObject) aAisObj = 
-        Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
-      if (!aAisObj.IsNull()) {
-        std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
-        aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
-        ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
-        if (aObj) {
-          FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
-          if (aFeature) {
-            return aFeature->getKind() != FeaturesPlugin_Group::ID();
-          } else 
-            return Standard_True;
-        } else
-          // This is not object controlled by the filter
-          return Standard_True;
+  bool aValid = true;
+  ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
+  // the shapes from different documents should be provided if there is no started operation
+  // in order to show/hide results
+  if (anOperation) {
+    aValid = false;
+    if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
+      std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+      if (theOwner->HasSelectable()) {
+        Handle(AIS_InteractiveObject) aAisObj = 
+          Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+        if (!aAisObj.IsNull()) {
+          aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+        }
       }
+      ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+      if (aObj) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+        if (aFeature) {
+          aValid = aFeature->getKind() != FeaturesPlugin_Group::ID();
+        } else 
+          aValid = Standard_True;
+      } else
+        // This is not object controlled by the filter
+        aValid = Standard_True;
     }
   }
-  return Standard_False;
+#ifdef DEBUG_FILTERS
+  qDebug(QString("PartSet_GlobalFilter::IsOk = %1").arg(aValid).toStdString().c_str());
+#endif
+  return aValid;
 }