Salome HOME
Task #3231: Sketcher Offset of a curve
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Validators.cpp
index 50d14b6a45f878e61735c8ab58cc5e3b9993f52b..883c0cbb13e9e0acde7c67cfea610eafc3be9256 100644 (file)
@@ -36,6 +36,7 @@
 #include "SketchPlugin_MacroArc.h"
 #include "SketchPlugin_MacroCircle.h"
 #include "SketchPlugin_MultiRotation.h"
+#include "SketchPlugin_Offset.h"
 #include "SketchPlugin_Point.h"
 #include "SketchPlugin_Sketch.h"
 #include "SketchPlugin_Trim.h"
@@ -535,20 +536,32 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute,
 
     // B-splines are not supported in Copying features
     FeaturePtr aSelFeature = ModelAPI_Feature::feature(aSelObject);
-    if (aSelFeature && (aSelFeature->getKind() == SketchPlugin_BSpline::ID() ||
+    if (aFeature->getKind() != SketchPlugin_Offset::ID() &&
+        aSelFeature && (aSelFeature->getKind() == SketchPlugin_BSpline::ID() ||
         aSelFeature->getKind() == SketchPlugin_BSplinePeriodic::ID())) {
       theError = "Not supported";
       return false;
     }
 
     anObjIter = aCopiedObjects.begin();
-    for (; anObjIter != aCopiedObjects.end(); anObjIter++)
-      if (aSelObject == *anObjIter) {
+    for (; anObjIter != aCopiedObjects.end(); anObjIter++) {
+      bool isFound = aSelObject == *anObjIter;
+      if (!isFound) {
+        // check in the results of the feature
+        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(*anObjIter);
+        const std::list<ResultPtr>& aResults = aFeature->results();
+        for (std::list<ResultPtr>::const_iterator aResIt = aResults.begin();
+             aResIt != aResults.end() && !isFound; ++aResIt) {
+          isFound = aSelObject == *aResIt;
+        }
+      }
+      if (isFound) {
         std::wstring aName = aSelObject.get() ? aSelObject->data()->name() : L"";
         theError = "The object %1 is a result of copy";
         theError.arg(aName);
         return false;
       }
+    }
   }
   return true;
 }