Salome HOME
bug #63: join of sections
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Diff.cxx
index 128deb7c10727e90b85192a5af5a90df032d2232..b2cecfd8c5c12cf66a2fdf0802407d0c16fda75b 100644 (file)
@@ -416,7 +416,6 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
             // Construct undo for RemovePoints command.
             CurveCreator_ICurve::SectionToPointList aSectionToPointList;
             CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end();
-            int aSectionId, aPointId;
             for ( ; anIt != aLast; anIt++ ) {
               aSectionToPointList.push_back(anIt->first);
             }
@@ -453,6 +452,41 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
   return isOK;
 }
 
+bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
+                             const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList)
+{
+  bool isOK = false;
+
+  if (theCurve != NULL && theOldParamList.size() > 0) {
+    clear();
+
+    // Set redo.
+    myPRedo = new CurveCreator_Operation;
+
+    // Construct redo for SetCoordinates command.
+    CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointActualCoords;
+    CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = 
+      theOldParamList.begin(), aLast = theOldParamList.end();
+    for ( ; anIt != aLast; anIt++ ) {
+      CurveCreator::Coordinates anActualCoords = theCurve->getPoint(anIt->first.first, anIt->first.second);
+      aSectionToPointActualCoords.push_back(std::make_pair(anIt->first, anActualCoords));
+    }
+
+    if (myPRedo->init(CurveCreator_Operation::SetCoordinates, aSectionToPointActualCoords)) {
+      // Undo for SetCoordinates command.
+      setNbUndos(1);
+      isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates,
+                             theOldParamList);
+    }
+
+    if (!isOK) {
+      clear();
+    }
+  }
+
+  return isOK;
+}
+
 //=======================================================================
 // function: applyUndo
 // purpose: