From 181c5a321c5ad5c64ca1466d884192ec140756ea Mon Sep 17 00:00:00 2001 From: rraphael Date: Fri, 27 Nov 2020 10:39:33 +0100 Subject: [PATCH] add custom configuration for construction point color --- .../ConstructionPlugin_Point.cpp | 4 +- src/Model/Model_ResultConstruction.cpp | 4 +- src/ModelAPI/ModelAPI_ResultConstruction.cpp | 3 ++ src/ModelAPI/ModelAPI_ResultConstruction.h | 52 +++++++++++++++++++ src/PartSet/PartSet_Module.cpp | 14 +++-- 5 files changed, 70 insertions(+), 7 deletions(-) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index 9b1744d32..0129d391e 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -144,7 +144,9 @@ void ConstructionPlugin_Point::execute() removeResults(1); // for case the point type was switched from multi-results type std::shared_ptr 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); } diff --git a/src/Model/Model_ResultConstruction.cpp b/src/Model/Model_ResultConstruction.cpp index e6a88069b..ff2689cb3 100644 --- a/src/Model/Model_ResultConstruction.cpp +++ b/src/Model/Model_ResultConstruction.cpp @@ -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 theShape) diff --git a/src/ModelAPI/ModelAPI_ResultConstruction.cpp b/src/ModelAPI/ModelAPI_ResultConstruction.cpp index 5fe93abc3..773e71db3 100644 --- a/src/ModelAPI/ModelAPI_ResultConstruction.cpp +++ b/src/ModelAPI/ModelAPI_ResultConstruction.cpp @@ -25,3 +25,6 @@ std::string ModelAPI_ResultConstruction::groupName() return group(); } +ModelAPI_ResultConstruction::ModelAPI_ResultConstruction(){ + setColor(DEFAULT_COLOR(), DEFAULT_COLOR_CONFIG_NAME()); +} diff --git a/src/ModelAPI/ModelAPI_ResultConstruction.h b/src/ModelAPI/ModelAPI_ResultConstruction.h index ec89005c8..117a8090c 100644 --- a/src/ModelAPI/ModelAPI_ResultConstruction.h +++ b/src/ModelAPI/ModelAPI_ResultConstruction.h @@ -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 diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index c6a6197c3..d9648b56e 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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()); -- 2.39.2