Salome HOME
Fix pipe to avoid moving of the path, if it is passed through the first face.
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Split.cpp
index 7da9ca15fb04e393536d58e2369ddf0f01bbedbe..d9e0cc2527b5b0814f4d5ab6cc42468d4ebade37 100644 (file)
@@ -371,7 +371,7 @@ void SketchPlugin_Split::execute()
       //}
       //aBaseShape = aShape;
 
-#ifdef DEBUG_TRIM_METHODS
+#ifdef DEBUG_SPLIT
       if (!aSelectedShape.get())
         std::cout << "Set empty selected object" << std::endl;
       else
@@ -423,8 +423,8 @@ void SketchPlugin_Split::execute()
 
 std::string SketchPlugin_Split::processEvent(const std::shared_ptr<Events_Message>& theMessage)
 {
-#ifdef DEBUG_TRIM_METHODS
-  std::cout << "SketchPlugin_Trim::processEvent:" << data()->name() << std::endl;
+#ifdef DEBUG_SPLIT
+  std::cout << "SketchPlugin_Split::processEvent:" << data()->name() << std::endl;
 #endif
   std::string aFilledAttributeName;
 
@@ -462,13 +462,23 @@ std::string SketchPlugin_Split::processEvent(const std::shared_ptr<Events_Messag
         Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
 
         GeomShapePtr aSelectedShape = getSubShape(SELECTED_OBJECT(), SELECTED_POINT());
-  #ifdef DEBUG_TRIM_METHODS
+        if (aSelectedShape.get()) {
+          aFilledAttributeName = SELECTED_OBJECT();
+        }
+        else {
+          // #2480 - sub shape is not initialized when split sketch
+          // If restarted operation use some selection on the shape that is split and
+          // result selectiona can not participate in new split(checked shape above is null),
+          // reset filled values of selection set in this method above
+          aRefSelectedAttr->setValue(ResultPtr());
+          aRefPreviewAttr->setValue(ResultPtr());
+        }
+  #ifdef DEBUG_SPLIT
         if (!aSelectedShape.get())
           std::cout << "Set empty selected object" << std::endl;
         else
           std::cout << "Set shape with ShapeType: " << aSelectedShape->shapeTypeStr() << std::endl;
   #endif
-        aFilledAttributeName = SELECTED_OBJECT();
       }
     }
   }
@@ -537,8 +547,8 @@ AISObjectPtr SketchPlugin_Split::getAISObject(AISObjectPtr thePrevious)
     return anAIS;
   }
   return AISObjectPtr();*/
-#ifdef DEBUG_TRIM_METHODS
-  std::cout << "SketchPlugin_Trim::getAISObject: " << data()->name() << std::endl;
+#ifdef DEBUG_SPLIT
+  std::cout << "SketchPlugin_Split::getAISObject: " << data()->name() << std::endl;
 #endif
 
   AISObjectPtr anAIS = thePrevious;
@@ -914,7 +924,7 @@ void SketchPlugin_Split::updateCoincidenceConstraintsToFeature(
     }
     if (aFeaturePointAttribute.get()) {
       // create new constraint and remove the current
-      aCoincFeature = SketchPlugin_Tools::createConstraint(sketch(),
+      aCoincFeature = SketchPlugin_Tools::createConstraintAttrAttr(sketch(),
           SketchPlugin_ConstraintCoincidence::ID(),
           aFeaturePointAttribute, aCoincFeature->refattr(aSecondAttribute)->attr());
       theFeaturesToDelete.insert(aCIt->first);
@@ -924,7 +934,8 @@ void SketchPlugin_Split::updateCoincidenceConstraintsToFeature(
       for (; aSFIt != aSFLast; aSFIt++) {
         AttributePoint2DPtr aSFAttribute = *aSFIt;
         if (aCoincPnt->isEqual(aSFAttribute->pnt())) {
-          SketchPlugin_Tools::createConstraint(sketch(), SketchPlugin_ConstraintCoincidence::ID(),
+          SketchPlugin_Tools::createConstraintAttrAttr(sketch(),
+                           SketchPlugin_ConstraintCoincidence::ID(),
                            aSFAttribute, aCoincFeature->refattr(aSecondAttribute)->attr());
         }
       }
@@ -1082,7 +1093,7 @@ FeaturePtr SketchPlugin_Split::splitLine(FeaturePtr& theSplitFeature,
                                              aFeature->attribute(SketchPlugin_Line::END_ID())));
       anNewFeature = aFeature;
     }
-    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+    aConstraintFeature = SketchPlugin_Tools::createConstraintAttrAttr(sketch(),
                      SketchPlugin_ConstraintCoincidence::ID(),
                      theSplitFeature->attribute(SketchPlugin_Line::END_ID()),
                      aFeature->attribute(SketchPlugin_Line::START_ID()));
@@ -1112,7 +1123,7 @@ FeaturePtr SketchPlugin_Split::splitLine(FeaturePtr& theSplitFeature,
     fillAttribute(theBaseFeatureModified->attribute(SketchPlugin_Line::END_ID()),
                                                     aFirstPointAttrOfSplit);
     theBaseFeatureModified->execute(); // to update result
-    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+    aConstraintFeature = SketchPlugin_Tools::createConstraintAttrAttr(sketch(),
                      SketchPlugin_ConstraintCoincidence::ID(),
                      theBaseFeatureModified->attribute(SketchPlugin_Line::END_ID()),
                      theSplitFeature->attribute(SketchPlugin_Line::START_ID()));
@@ -1225,7 +1236,7 @@ FeaturePtr SketchPlugin_Split::splitArc(FeaturePtr& theSplitFeature,
                                                   aFeature->attribute(SketchPlugin_Arc::END_ID())));
       anNewFeature = aFeature;
     }
-    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+    aConstraintFeature = SketchPlugin_Tools::createConstraintAttrAttr(sketch(),
                      SketchPlugin_ConstraintCoincidence::ID(),
                      theSplitFeature->attribute(SketchPlugin_Arc::END_ID()),
                      aFeature->attribute(SketchPlugin_Arc::START_ID()));
@@ -1255,7 +1266,7 @@ FeaturePtr SketchPlugin_Split::splitArc(FeaturePtr& theSplitFeature,
     fillAttribute(theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()),
                                                     aFirstPointAttrOfSplit);
     theBaseFeatureModified->execute(); // to update result
-    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+    aConstraintFeature = SketchPlugin_Tools::createConstraintAttrAttr(sketch(),
                      SketchPlugin_ConstraintCoincidence::ID(),
                      theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()),
                      theSplitFeature->attribute(SketchPlugin_Arc::START_ID()));
@@ -1355,12 +1366,12 @@ FeaturePtr SketchPlugin_Split::splitCircle(FeaturePtr& theSplitFeature,
                              (theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID())));
 
   // additional constraints between split and base features
-  aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+  aConstraintFeature = SketchPlugin_Tools::createConstraintAttrAttr(sketch(),
                      SketchPlugin_ConstraintCoincidence::ID(),
                      theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()),
                      theSplitFeature->attribute(SketchPlugin_Arc::END_ID()));
   theCreatedFeatures.insert(aConstraintFeature);
-  aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+  aConstraintFeature = SketchPlugin_Tools::createConstraintAttrAttr(sketch(),
                      SketchPlugin_ConstraintCoincidence::ID(),
                      theBaseFeatureModified->attribute(SketchPlugin_Arc::START_ID()),
                      theSplitFeature->attribute(SketchPlugin_Arc::START_ID()));