+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttrA->object());
+ if (!aFeature.get()) {
+ theError = aParamA + " attribute has an empty feature";
+ return false;
+ }
+
+ if (aFeature->getKind() == SketchPlugin_Point::ID())
+ return true;
+ }
+
+ // second attribute is a point, it may coincide with any object
+ if (!aRefAttrB->isObject())
+ return true;
+ else {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttrB->object());
+ if (!aFeature) {
+ theError = theAttribute->id() + " attribute has an empty object";
+ return false;
+ }
+ if (aFeature->getKind() == SketchPlugin_Point::ID())
+ return true;
+ }
+ theError = "There is no an attribute filled by a point";
+ return false;
+}
+
+
+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;
+ }