+//********************************************************************
+ObjectPtr ModuleBase_WidgetValidated::findPresentedObject(const AISObjectPtr& theAIS) const
+{
+ return myPresentedObject;
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::storeAttributeValue()
+{
+ myIsInValidate = true;
+}
+
+//********************************************************************
+void ModuleBase_WidgetValidated::restoreAttributeValue(const bool theValid)
+{
+ myIsInValidate = false;
+}
+
+//********************************************************************
+bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& thePrs)
+{
+ bool aValid = true;
+ Handle(SelectMgr_EntityOwner) anOwner = thePrs.owner();
+
+ // if an owner is null, the selection happens in the Object browser.
+ // creates a selection owner on the base of object shape and the object AIS object
+ if (anOwner.IsNull() && thePrs.owner().IsNull() && thePrs.object().get()) {
+ ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+ if (aResult.get() && aResult->shape().get()) {
+ // some results have no shape, e.g. the parameter one. So, they should not be validated
+ GeomShapePtr aShape = aResult->shape();
+ const TopoDS_Shape aTDShape = aShape->impl<TopoDS_Shape>();
+ Handle(AIS_InteractiveObject) anIO = myWorkshop->selection()->getIO(thePrs);
+ anOwner = new StdSelect_BRepOwner(aTDShape, anIO);
+ myPresentedObject = aResult;
+ }
+ else
+ aValid = false; // only results with a shape can be filtered
+ }
+ // checks the owner by the AIS context activated filters
+ if (!anOwner.IsNull()) {
+ // the widget validator filter should be active, but during check by preselection
+ // it is not yet activated, so we need to activate/deactivate it manually
+ bool isActivated = isFilterActivated();
+ if (!isActivated)
+ activateFilters(true);
+
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ if (!aContext.IsNull()) {
+ const SelectMgr_ListOfFilter& aFilters = aContext->Filters();
+ SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
+ for (; anIt.More() && aValid; anIt.Next()) {
+ Handle(SelectMgr_Filter) aFilter = anIt.Value();
+ aValid = aFilter->IsOk(anOwner);
+ }
+ }
+ if (!isActivated)
+ activateFilters(false);
+ }
+
+ // removes created owner
+ if (!anOwner.IsNull() && anOwner != thePrs.owner()) {
+ anOwner.Nullify();
+ myPresentedObject = ObjectPtr();
+ }
+ return aValid;
+}
+