Salome HOME
Merge remote-tracking branch 'origin/CEA_2019'
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_SketchEntity.h
index ac263e38ca0dfe92a0e52ec26c404f700c257532..eb50851fa4b2552de343f896214801e0163c321a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -12,9 +12,9 @@
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #ifndef SketchPlugin_SketchEntity_H_
 #include "SketchPlugin_Feature.h"
 
 #include <ModelAPI_CompositeFeature.h>
+#include <ModelAPI_Session.h>
 #include <GeomAPI_Shape.h>
 #include <GeomAPI_AISObject.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_AttributeSelection.h>
 #include <ModelAPI_AttributeBoolean.h>
+#include <ModelAPI_AttributeIntArray.h>
 #include <GeomAPI_ICustomPrs.h>
 
 #include <Config_PropManager.h>
@@ -109,6 +111,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     return false;
   }
 
+// LCOV_EXCL_START
   /// Customize presentation of the feature
   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
@@ -150,6 +153,13 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
       aColor = Config_PropManager::color("Visualization", "sketch_entity_color");
     }
     if (!aColor.empty()) {
+      if (theResult.get() && ModelAPI_Session::get()->isOperation()) {
+        AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+        aColorAttr->setSize(3);
+        // Set the color attribute in order do not use default colors in the presentation object
+        for (int i = 0; i < 3; i++)
+          aColorAttr->setValue(i, aColor[i]);
+      }
       thePrs->setColor(aColor[0], aColor[1], aColor[2]);
       for (int i = 0; i < 3 && !isCustomized; i++)
         isCustomized = aColor[i] != aPrevColor[i];
@@ -182,6 +192,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     }
     return isCustomized;
   }
+// LCOV_EXCL_STOP
 
 protected:
   /// initializes mySketch