+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments) const
+{
+ bool isSketchEntities = true;
+ std::set<std::string> anEntityKinds;
+ std::list<std::string>::const_iterator anIt = theArguments.begin(), aLast = theArguments.end();
+ for (; anIt != aLast; anIt++) {
+ anEntityKinds.insert(*anIt);
+ }
+
+ std::string anAttributeType = theAttribute->attributeType();
+ if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) {
+ AttributeSelectionListPtr aSelectionListAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ // it filters only selection list attributes
+ std::string aType = aSelectionListAttr->selectionType().c_str();
+ // all context objects should be sketch entities
+ int aSize = aSelectionListAttr->size();
+ for (int i = 0; i < aSelectionListAttr->size() && isSketchEntities; i++) {
+ AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i);
+ ObjectPtr anObject = aSelectAttr->context();
+ // a context of the selection attribute is a feature result. It can be a case when the result
+ // of the feature is null, e.g. the feature is modified and has not been executed yet.
+ // The validator returns an invalid result here. The case is an extrusion built on a sketch
+ // feature. A new sketch element creation leads to an empty result.
+ if (!anObject.get())
+ isSketchEntities = false;
+ else {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end();