Salome HOME
Fix Undo/Redo of removing of middle point.
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Curve.cxx
index 69b0c38d4fc207f525c5bbc4949f1ba4c95cdfd8..f27cfb2ef807efd86750ec8da738cab674fd5be5 100644 (file)
@@ -347,6 +347,48 @@ void CurveCreator_Curve::redisplayCurve()
   }
 }
 
+//! For internal use only! Undo/Redo are not used here.
+bool CurveCreator_Curve::moveSectionInternal(const int theISection,
+                                             const int theNewIndex)
+{
+  bool res = false;
+  if (theISection != theNewIndex) {
+    CurveCreator_Section *aSection = mySections.at(theISection);
+
+    // Remove section
+    CurveCreator::Sections::iterator anIter = mySections.begin() + theISection;
+
+    mySections.erase(anIter);
+
+    // Insert section.
+    anIter = mySections.begin() + theNewIndex;
+    mySections.insert(anIter, aSection);
+    res = true;
+  }
+  return res;
+}
+
+//=======================================================================
+// function: moveSection
+// purpose:
+//=======================================================================
+bool CurveCreator_Curve::moveSection(const int theISection,
+                                     const int theNewIndex)
+{
+  bool res = false;
+  // Set the difference.
+  startOperation();
+  if (addEmptyDiff()) {
+    myListDiffs.back().init(this, CurveCreator_Operation::MoveSection,
+                            theISection, theNewIndex);
+  }
+
+  // Update the curve.
+  res = moveSectionInternal(theISection, theNewIndex);
+  finishOperation();
+  return res;
+}
+
 /************   Implementation of INTERFACE methods   ************/
 
 /***********************************************/