Salome HOME
updated copyright message
[modules/geom.git] / src / CurveCreator / CurveCreator_Operation.cxx
index d5c535a60d89a032363768d7ea5328942a75d2db..fb346fee9ef31cc69d8e3254b984ee3bd65187ae 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2019  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2013-2023  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -23,6 +23,9 @@
 #include "CurveCreator_Operation.hxx"
 #include "CurveCreator_Curve.hxx"
 #include "CurveCreator.hxx"
+#include "CurveCreator_Section.hxx"
+#include "CurveCreator_Utils.hxx"
+#include <QColor>
 
 #include <string>
 #include <stdlib.h>
@@ -114,6 +117,28 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
   return isOK;
 }
 
+bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
+                                  const int theIntParam1,
+                                  const int theIntParam2[3])
+{
+  bool isOK = false;
+
+  if (theType == CurveCreator_Operation::SetColorSection)
+  {
+    int *pData = (int *)allocate(4*sizeof(int));
+
+    pData[0] = theIntParam1;
+    pData[1] = theIntParam2[0];
+    pData[2] = theIntParam2[1];
+    pData[3] = theIntParam2[2];
+    myType   = theType;
+    isOK     = true;
+  }
+
+  return isOK;
+}
+
+
 //=======================================================================
 // function: Constructor
 // purpose:
@@ -252,12 +277,12 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
 
     const int aNbPoints = theParamList1.size();
 
-    CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = 
+    CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
       theParamList1.begin();
     const int aNbCoords = anIt->second.size();
 
     const size_t aSize =
-      sizeof(aNbPoints) + sizeof(aNbCoords) + 
+      sizeof(aNbPoints) + sizeof(aNbCoords) +
       aNbPoints * (3*sizeof(int) + aNbCoords*sizeof(CurveCreator::TypeCoord));
     int *pIntData = (int *)allocate(aSize);
 
@@ -295,7 +320,7 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
   if (theType == CurveCreator_Operation::RemovePoints) {
     const int aNbPoints = theParamList1.size();
 
-    CurveCreator_ICurve::SectionToPointList::const_iterator anIt = 
+    CurveCreator_ICurve::SectionToPointList::const_iterator anIt =
       theParamList1.begin();
 
     const size_t aSize =
@@ -363,6 +388,8 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
             case CurveCreator_Operation::SetCoordinates:
               theCurve->setPointInternal( aSectionsMap );
               break;
+            default:
+              break;
           }
         }
         break;
@@ -414,7 +441,9 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
           char* aPtr =  ((char*)&pInt[2]);
           aPtr += (aName.length()) + 1;
           getCoords((int*)aPtr, aCoords);
-          theCurve->addSectionInternal(aName, aType, (pInt[1] != 0), aCoords);
+          Quantity_Color aLastColor = theCurve->getLastRemovedColor();
+          theCurve->popLastRemovedColor();
+          theCurve->addSectionInternal(aName, aType, (pInt[1] != 0), aCoords, aLastColor);
         }
         break;
       case CurveCreator_Operation::RemoveSection:
@@ -426,6 +455,13 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
             theCurve->setSectionNameInternal(pInt[0], aName);
         }
         break;
+      case CurveCreator_Operation::SetColorSection:
+        {
+          Quantity_Color aColor = CurveCreator_Utils::colorConv(QColor(pInt[1], pInt[2], pInt[3]));
+          theCurve->setColorSectionInternal(pInt[0], aColor);
+          //theCurve->redisplayCurve(false);
+        }
+        break;
       default:
         break;
     }