const Config_WidgetAPI* theData,
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId),
- myWorkshop(theWorkshop)
+ myWorkshop(theWorkshop), myIsInValidate(false)
{
}
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)
{
// 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()) {
+ 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);
myPresentedObject = aResult;
}
else
- aValid = false; // only results can be filtered
+ aValid = false; // only results with a shape can be filtered
}
// checks the owner by the AIS context activated filters
if (!anOwner.IsNull()) {
if (!isActivated)
activateFilters(true);
- const SelectMgr_ListOfFilter& aFilters = myWorkshop->viewer()->AISContext()->Filters();
- SelectMgr_ListIteratorOfListOfFilter anIt(aFilters);
- for (; anIt.More() && aValid; anIt.Next()) {
- Handle(SelectMgr_Filter) aFilter = anIt.Value();
- aValid = aFilter->IsOk(anOwner);
+ 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);
{
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- std::list<ModelAPI_Validator*> aValidators;
- std::list<std::list<std::string> > anArguments;
- aFactory->validators(myFeature->getKind(), attributeID(), aValidators, anArguments);
-
- DataPtr aData = myFeature->data();
AttributePtr anAttribute = myFeature->attribute(attributeID());
-
- std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
- std::list<std::list<std::string> >::iterator aArgs = anArguments.begin();
- bool aValid = true;
- for (; aValidator != aValidators.end() && aValid; aValidator++, aArgs++) {
- const ModelAPI_AttributeValidator* aAttrValidator =
- dynamic_cast<const ModelAPI_AttributeValidator*>(*aValidator);
- if (aAttrValidator) {
- aValid = aAttrValidator->isValid(anAttribute, *aArgs);
- }
- }
- return aValid;
+ std::string aValidatorID, anError;
+ return aFactory->validate(anAttribute, aValidatorID, anError);
}
bool ModuleBase_WidgetValidated::isFilterActivated() const