+
+bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ if (theAttribute->attributeType() != ModelAPI_AttributeRefList::typeId()) {
+ theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
+ return false;
+ }
+
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ AttributeRefListPtr aSelAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
+
+ AttributeRefListPtr aRefListOfInitial = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
+ aFeature->attribute(SketchPlugin_Constraint::ENTITY_A()));
+ AttributeRefListPtr aRefListOfCopied = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(
+ aFeature->attribute(SketchPlugin_Constraint::ENTITY_B()));
+ std::list<ObjectPtr> anInitialObjects = aRefListOfInitial->list();
+ std::list<ObjectPtr> aCopiedObjects = aRefListOfCopied->list();
+
+ std::list<ObjectPtr>::iterator anObjIter;
+ for(int anInd = 0; anInd < aSelAttr->size(); anInd++) {
+ ObjectPtr aSelObject = aSelAttr->object(anInd);
+ anObjIter = anInitialObjects.begin();
+ for (; anObjIter != anInitialObjects.end(); anObjIter++)
+ if (aSelObject == *anObjIter)
+ break;
+ if (anObjIter != anInitialObjects.end())
+ continue;
+ anObjIter = aCopiedObjects.begin();
+ for (; anObjIter != aCopiedObjects.end(); anObjIter++)
+ if (aSelObject == *anObjIter) {
+ std::string aName = aSelObject.get() ? aSelObject->data()->name() : "";
+ theError = "The object " + aName + " is a result of copy";
+ return false;
+ }
+ }
+ return true;
+}
+
+bool SketchPlugin_SolverErrorValidator::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<std::string>& theArguments,
+ std::string& theError) const
+{
+ AttributeStringPtr aAttributeString = theFeature->string(SketchPlugin_Sketch::SOLVER_ERROR());
+
+ if (!aAttributeString->value().empty()) {
+ theError = aAttributeString->value();
+ return false;
+ }
+
+ return true;
+}
+
+bool SketchPlugin_SolverErrorValidator::isNotObligatory(std::string theFeature, std::string theAttribute)
+{
+ return true;
+}
+