]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
add custom configuration for construction point color
authorrraphael <raphael.raphael@c-s.fr>
Fri, 27 Nov 2020 09:39:33 +0000 (10:39 +0100)
committerrraphael <raphael.raphael@c-s.fr>
Fri, 15 Jan 2021 11:00:49 +0000 (12:00 +0100)
src/ConstructionPlugin/ConstructionPlugin_Point.cpp
src/Model/Model_ResultConstruction.cpp
src/ModelAPI/ModelAPI_ResultConstruction.cpp
src/ModelAPI/ModelAPI_ResultConstruction.h
src/PartSet/PartSet_Module.cpp

index 9b1744d325f2f3c66fc1c06994a6cadd938772b9..0129d391e1b784d3172c3f97709018f9261b4192 100644 (file)
@@ -144,7 +144,9 @@ void ConstructionPlugin_Point::execute()
   removeResults(1); // for case the point type was switched from multi-results type
   std::shared_ptr<ModelAPI_ResultConstruction> aConstr = document()->createConstruction(data());
   aConstr->setInfinite(true);
-  aConstr->setShape(aShape);
+  aConstr->setShape(aShape);  
+  aConstr->setColor(ModelAPI_ResultConstruction::ModelApi_PointColor::DEFAULT_COLOR(),
+                    ModelAPI_ResultConstruction::ModelApi_PointColor::COLOR_CONFIG_NAME()); /// set point color
   setResult(aConstr);
 }
 
index e6a88069b47ed45de44474826caa59e36953ab07..ff2689cb321ca21a3724798afb12092f8c591f61 100644 (file)
@@ -100,8 +100,8 @@ void Model_ResultConstruction::colorConfigInfo(std::string& theSection, std::str
                                        std::string& theDefault)
 {
   theSection = "Visualization";
-  theName = "result_construction_color";
-  theDefault = DEFAULT_COLOR();
+  theName =  getColorConfigName();
+  theDefault = getColor();
 }
 
 void Model_ResultConstruction::setShape(std::shared_ptr<GeomAPI_Shape> theShape)
index 5fe93abc355f1845502e6351451683df158b6a11..773e71db368ea9fdc17e93a5ce87ec88e4cf4e28 100644 (file)
@@ -25,3 +25,6 @@ std::string ModelAPI_ResultConstruction::groupName()
   return group();
 }
 
+ModelAPI_ResultConstruction::ModelAPI_ResultConstruction(){
+  setColor(DEFAULT_COLOR(), DEFAULT_COLOR_CONFIG_NAME());
+}
index ec89005c8ded3c1a09d55bf4cb2170ff021cdf7c..117a8090cf97001637076e31ea3ae8f1d78e122d 100644 (file)
@@ -36,6 +36,8 @@
 class ModelAPI_ResultConstruction : public ModelAPI_Result
 {
  public:
+  ModelAPI_ResultConstruction();
+
   /// Returns the group identifier of this result
   MODELAPI_EXPORT virtual std::string groupName();
 
@@ -81,6 +83,56 @@ class ModelAPI_ResultConstruction : public ModelAPI_Result
   virtual bool isInfinite() = 0;
   /// Sets the flag that it is infinite
   virtual void setInfinite(const bool theInfinite) = 0;
+
+  /*************************************************************************/
+  /// Changes for custom point color
+
+  inline static const std::string& DEFAULT_COLOR_CONFIG_NAME()
+  {
+    static const std::string RESULT_CONSTRUCTION_COLOR_CONFIG_NAME("result_construction_color");
+    return RESULT_CONSTRUCTION_COLOR_CONFIG_NAME;
+  }
+
+  inline void setColor(const std::string myColor, const std::string & myColorConfigName)
+  {
+    color = myColor;
+    colorConfigName = myColorConfigName;
+  }
+
+  inline const std::string & getColor() const
+  {
+    return color;
+  }
+
+  inline const std::string & getColorConfigName() const
+  {
+    return  colorConfigName;
+  }
+
+private:
+  std::string color;
+  std::string colorConfigName;
+
+public:
+
+  /// Specific properties for point
+  class ModelApi_PointColor
+  {
+  public:
+    /// default color for a point construction
+    inline static const std::string& DEFAULT_COLOR()
+    {
+      static const std::string POINT_CONSTRUCTION_COLOR("85,85,0");
+      return POINT_CONSTRUCTION_COLOR;
+    }
+
+    inline static const std::string COLOR_CONFIG_NAME()
+    {
+      static const std::string POINT_CONFIG_COLOR_NAME("result_point_color");
+      return POINT_CONFIG_COLOR_NAME;
+    }
+  };
+  /*************************************************************************/
 };
 
 //! Pointer on feature object
index c6a6197c32ea0b6acd1827407f4f8c86f95fbfce..d9648b56e5c585b514c19a3813ed039fcaf2b2fa 100644 (file)
@@ -202,10 +202,16 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
     Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR());
 
-  Config_PropManager::registerProp("Visualization", "result_construction_color",
-    "Construction color",
-    Config_Prop::Color,
-    ModelAPI_ResultConstruction::DEFAULT_COLOR());
+  Config_PropManager::registerProp("Visualization",
+                                   ModelAPI_ResultConstruction::DEFAULT_COLOR_CONFIG_NAME(),
+                                   "Construction color",  Config_Prop::Color,
+                                   ModelAPI_ResultConstruction::DEFAULT_COLOR());
+
+  Config_PropManager::registerProp("Visualization",
+                                   ModelAPI_ResultConstruction::ModelApi_PointColor::COLOR_CONFIG_NAME(),
+                                   "Construction point color", Config_Prop::Color,
+                                   ModelAPI_ResultConstruction::ModelApi_PointColor::DEFAULT_COLOR());
+
 
   Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
     Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());