Salome HOME
Issue #2644: Set not valid state if a feature is not accepted by attribute
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetValidated.cpp
index f55678ade0a81b34e4ffea4d06b6ec550eeae85a..308e14770edb8d0017fd96ef3200c0d52554cb87 100644 (file)
@@ -123,6 +123,7 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr&
         myPresentedObject = aFeature;
         AttributePtr anAttr = attribute();
         std::string aType = anAttr->attributeType();
+
         // Check that results of Feature is acceptable by filters for selection attribute
         if (aType == ModelAPI_AttributeSelection::typeId()) {
           AttributeSelectionPtr aSelectAttr =
@@ -134,8 +135,22 @@ bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrsPtr&
             Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs);
             anOwner = new StdSelect_BRepOwner(aTDShape, anIO);
           }
+          else
+            aValid = false;
           aSelectAttr->setValue(ObjectPtr(), GeomShapePtr(), true);
         }
+        else {
+          ResultPtr aResult = aFeature->firstResult();
+          if (aResult.get()) {
+            GeomShapePtr aShapePtr = ModelAPI_Tools::shape(aResult);
+            if (aShapePtr.get()) {
+              const TopoDS_Shape aTDShape = aShapePtr->impl<TopoDS_Shape>();
+              Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs);
+              anOwner = new StdSelect_BRepOwner(aTDShape, anIO);
+            }
+          }
+          aValid = !anOwner.IsNull(); // only results with a shape can be filtered
+        }
       } else
         aValid = false; // only results with a shape can be filtered
     }