]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/CurveCreator/CurveCreator_Diff.cxx
Salome HOME
updated copyright message
[modules/geom.git] / src / CurveCreator / CurveCreator_Diff.cxx
index d1a7dc3222e43426504b79b637fea80197b35ce0..1445652404591bceef50a93a7b96414566101c97 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2013-2023  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -22,6 +22,8 @@
 
 #include "CurveCreator_Diff.hxx"
 #include "CurveCreator_Curve.hxx"
+#include "CurveCreator_Section.hxx"
+#include "CurveCreator_Utils.hxx"
 
 #include <list>
 
@@ -103,7 +105,7 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
     if (myPRedo->init(theType, theIntParam)) {
       // Construct undo for RemoveSection command.
       // If the last section is removed, one AddSection command is enough.
-      // If not last section is removed, two commands are requred: AddSection
+      // If not last section is removed, two commands are required: AddSection
       // and MoveSection.
       const int aLastIndex = theCurve->getNbSections() - 1;
 
@@ -171,6 +173,36 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
   return isOK;
 }
 
+bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
+                             const CurveCreator_Operation::Type theType,
+                             const int theIntParam1,
+                             const int theIntParam2[3])
+{
+  bool isOK = false;
+
+  if (theCurve != NULL)
+  {
+    clear();
+    myPRedo = new CurveCreator_Operation;
+
+    if (myPRedo->init(theType, theIntParam1, theIntParam2))
+    {
+      Quantity_Color aColor =  theCurve->getColorSection(theIntParam1);
+
+      setNbUndos(1);
+      QColor aQColor = CurveCreator_Utils::colorConv(aColor);
+      int colorArr[3] = {aQColor.red(),aQColor.green(), aQColor.blue()};
+
+      isOK = myPUndo[0].init(theType, theIntParam1, colorArr);
+    }
+
+    if (!isOK)
+      clear();
+  }
+
+  return isOK;
+}
+
 //=======================================================================
 // function: init
 // purpose:
@@ -275,6 +307,8 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
             setNbUndos(1);
             isOK = myPUndo[0].init(CurveCreator_Operation::RemoveSection, -1);
             break;
+        default:
+          break;
         }
       }
     }
@@ -299,6 +333,8 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
         isOK = myPUndo[0].init(CurveCreator_Operation::RenameSection,
                                theCurve->getSectionName(theIntParam1), theIntParam1);
         break;
+      default:
+        break;
     }
   }
   if( !isOK ){
@@ -336,10 +372,10 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
               aSectionId = anIt->first;
               aPointId = anIt->second;
               const CurveCreator::Coordinates &aPoints =
-                      theCurve->getPoints(aSectionId);
+                      theCurve->getCoords(aSectionId);
               CurveCreator::Coordinates::const_iterator anIterBegin =
                   aPoints.begin() + (aDim*aPointId);
-              CurveCreator::Coordinates::const_iterator anIterEnd = 
+              CurveCreator::Coordinates::const_iterator anIterEnd =
                 anIterBegin + aDim;
               aPointsToAdd.insert(aPointsToAdd.end(), anIterBegin, anIterEnd);
               aSectionToPointCoords.push_back(std::make_pair(*anIt, aPointsToAdd));
@@ -431,7 +467,7 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
 
     // Construct redo for SetCoordinates command.
     CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointActualCoords;
-    CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = 
+    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);
@@ -526,7 +562,7 @@ bool CurveCreator_Diff::addSectionToUndo
                        CurveCreator_Operation &theOperation) const
 {
   const std::string aName = theCurve->getSectionName(theIndex);
-  const CurveCreator::Coordinates &aPnts = theCurve->getPoints(theIndex);
+  const CurveCreator::Coordinates &aPnts = theCurve->getCoords(theIndex);
   const CurveCreator::SectionType aType = theCurve->getSectionType(theIndex);
   const bool isClosed = theCurve->isClosed(theIndex);