Salome HOME
Add a new 'moveSection' operation to change position of section in the list.
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Operation.cxx
index 073d8ec798dc08406dd85e4df4b5fdd4e77e2bc2..ce73d1ccfe4abe52c9b046c0952a2aa2da5c8a15 100644 (file)
@@ -97,6 +97,7 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
   if (theType == CurveCreator_Operation::SetType     ||
       theType == CurveCreator_Operation::SetClosed   ||
       theType == CurveCreator_Operation::MoveSection ||
+      theType == CurveCreator_Operation::RemovePoints ||
       theType == CurveCreator_Operation::Join) {
     int *pData = (int *)allocate(2*sizeof(int));
 
@@ -280,53 +281,54 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
 
     switch (myType) {
       case CurveCreator_Operation::AddPoints:
+      case CurveCreator_Operation::InsertPoints:
         {
           CurveCreator::Coordinates aCoords;
 
-          getCoords(&pInt[1], aCoords);
-          theCurve->addPoints(aCoords, pInt[0]);
+          getCoords(&pInt[2], aCoords);
+          std::vector<int> anISections, anIPnts;
+          anISections.push_back( pInt[0] );
+          anIPnts.push_back( pInt[1] );
+          theCurve->addPointsInternal(aCoords, anISections, anIPnts);
         }
         break;
       case CurveCreator_Operation::RemovePoints:
-//AKL: TODO Undo/Redo support         theCurve->removePoints(pInt[0], pInt[1], pInt[2]);
-        break;
-      case CurveCreator_Operation::InsertPoints:
         {
-          CurveCreator::Coordinates aCoords;
-
-          getCoords(&pInt[2], aCoords);
-          theCurve->addPoints(aCoords, pInt[0], pInt[1]);
+          std::vector<int> anISections, anIPnts;
+          anISections.push_back( pInt[0] );
+          anIPnts.push_back( pInt[1] );
+          theCurve->removePointsInternal(anISections, anIPnts);
         }
         break;
       case CurveCreator_Operation::SetType:
         {
           const CurveCreator::SectionType aType = (CurveCreator::SectionType) pInt[0];
 
-          theCurve->setSectionType( pInt[1], aType );
+          theCurve->setSectionTypeInternal( pInt[1], aType );
         }
         break;
       case CurveCreator_Operation::Clear:
-        theCurve->clear();
+        theCurve->clearInternal();
         break;
       case CurveCreator_Operation::SetCoordinates:
         {
           CurveCreator::Coordinates aCoords;
 
           getCoords(&pInt[2], aCoords);
-          theCurve->setPoint(pInt[0], pInt[1], aCoords);
+          theCurve->setPointInternal(pInt[0], pInt[1], aCoords);
         }
         break;
       case CurveCreator_Operation::SetClosed:
-        theCurve->setClosed((pInt[0] != 0), pInt[1]);
+        theCurve->setClosedInternal((pInt[0] != 0), pInt[1]);
+        break;
+      case CurveCreator_Operation::MoveSection:
+        theCurve->moveSectionInternal(pInt[0], pInt[1]);
         break;
-/*      case CurveCreator_Operation::MoveSection:
-        theCurve->moveSection(pInt[0], pInt[1]);
-        break;*/
       case CurveCreator_Operation::Join:
         if (myPData == NULL) {
-          theCurve->join();
+          theCurve->joinInternal();
         } else {
-          theCurve->join(pInt[0], pInt[1]);
+          theCurve->joinInternal(pInt[0], pInt[1]);
         }
         break;
       case CurveCreator_Operation::AddSection:
@@ -340,16 +342,16 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
           char* aPtr =  ((char*)&pInt[2]);
           aPtr += (aName.length()) + 1;
           getCoords((int*)aPtr, aCoords);
-          theCurve->addSection(aName, aType, (pInt[1] != 0), aCoords);
+          theCurve->addSectionInternal(aName, aType, (pInt[1] != 0), aCoords);
         }
         break;
       case CurveCreator_Operation::RemoveSection:
-        theCurve->removeSection(pInt[0]);
+        theCurve->removeSectionInternal(pInt[0]);
         break;
       case CurveCreator_Operation::RenameSection:
         {
             std::string aName = std::string((char*)&pInt[1]);
-            theCurve->setSectionName(pInt[0], aName);
+            theCurve->setSectionNameInternal(pInt[0], aName);
         }
         break;
       default: