Salome HOME
2.10. Show thicker edges in Projection feature "included into sketch results"
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_SketchEntity.h
index 1af4d28bbc9541abccb51ad2672cbaded7bc3f6b..b915d8540e92b53c074e379a8eb96ea269647c53 100644 (file)
@@ -1,8 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        SketchPlugin_SketchEntity.h
-// Created:     05 Mar 2015
-// Author:      Natalia ERMOLAEVA
+// 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
+// License as published by the Free Software Foundation; either
+// 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #ifndef SketchPlugin_SketchEntity_H_
 #define 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>
@@ -59,7 +74,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
   /// Width of the line
   inline static const double SKETCH_LINE_WIDTH()
   {
-    return 3;
+    return Config_PropManager::integer("Visualization", "sketch_line_width");
   }
 
   /// Style of the auxiliary line
@@ -96,6 +111,25 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     return false;
   }
 
+  virtual bool isIncludeToResult() const
+  {
+    AttributeBooleanPtr anAttr;
+    std::set<AttributePtr> aRefsToMe = data()->refsToMe();
+    std::set<AttributePtr>::const_iterator aIt;
+    for (aIt = aRefsToMe.cbegin(); aIt != aRefsToMe.cend(); ++aIt) {
+      if ((*aIt)->id() == "ProjectedFeature") {
+        FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aIt)->owner());
+        if (aFeature.get()) {
+          anAttr = aFeature->data()->boolean("IncludeToResult");
+          if (anAttr.get())
+            return anAttr->value();
+        }
+      }
+    }
+    return true;
+  }
+
+// LCOV_EXCL_START
   /// Customize presentation of the feature
   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs)
@@ -137,6 +171,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];
@@ -158,7 +199,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
       thePrs->setWidth(17);
     //  thePrs->setPointMarker(1, 1.); // Set point as a '+' symbol
     }
-    if(isCopy()) {
+    if(isCopy() && !isIncludeToResult()) {
       double aWidth = thePrs->width();
       isCustomized = thePrs->setWidth(aWidth / 2.5) || isCustomized;
     }
@@ -169,6 +210,7 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC
     }
     return isCustomized;
   }
+// LCOV_EXCL_STOP
 
 protected:
   /// initializes mySketch