From fef85548e799ffa1473195e4ded1c9aa4c3dda03 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 20 Feb 2015 14:14:52 +0300 Subject: [PATCH] Color preferences for the imported feature. --- src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp | 10 ++++++++++ src/ExchangePlugin/ExchangePlugin_ImportFeature.h | 11 +++++++++-- src/ExchangePlugin/ExchangePlugin_Plugin.cpp | 6 ++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index 85a025f68..11d45e785 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -13,6 +13,8 @@ #include #include +#include + #include #include #include @@ -68,6 +70,14 @@ void ExchangePlugin_ImportFeature::execute() importFile(aFilePath); } +void ExchangePlugin_ImportFeature::customisePresentation(AISObjectPtr thePrs) +{ + std::vector aRGB = Config_PropManager::color("Visualization", "import_feature_color", + IMPORTED_FEATURE_COLOR); + thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]); + thePrs->redisplay(); +} + bool ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) { // retrieve the file and plugin library names diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.h b/src/ExchangePlugin/ExchangePlugin_ImportFeature.h index 24bd6964f..54ed71521 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.h +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.h @@ -6,15 +6,19 @@ #include #include +#include + #include -/**\class ExchangePlugin_ImportFeature +#define IMPORTED_FEATURE_COLOR "#E0A01B" + + /**\class ExchangePlugin_ImportFeature * \ingroup Plugins * \brief Feature for import shapes from the external files in CAD formats. * * The set of supported formats is defined in the configuration file. */ -class ExchangePlugin_ImportFeature : public ModelAPI_Feature +class ExchangePlugin_ImportFeature : public ModelAPI_Feature, public GeomAPI_ICustomPrs { public: /// Extrusion kind @@ -48,6 +52,9 @@ class ExchangePlugin_ImportFeature : public ModelAPI_Feature return true; } + /// Modifies the given presentation in the custom way. + virtual void customisePresentation(AISObjectPtr thePrs); + protected: /// POerforms the import of the file EXCHANGEPLUGIN_EXPORT bool importFile(const std::string& theFileName); diff --git a/src/ExchangePlugin/ExchangePlugin_Plugin.cpp b/src/ExchangePlugin/ExchangePlugin_Plugin.cpp index 6386d8a2a..cf3201685 100644 --- a/src/ExchangePlugin/ExchangePlugin_Plugin.cpp +++ b/src/ExchangePlugin/ExchangePlugin_Plugin.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include #include @@ -26,6 +28,10 @@ ExchangePlugin_Plugin::ExchangePlugin_Plugin() ModelAPI_ValidatorsFactory* aFactory = aSession->validators(); aFactory->registerValidator("ExchangePlugin_ImportFormat", new ExchangePlugin_ImportFormatValidator); + + // register construction properties + Config_PropManager::registerProp("Visualization", "import_feature_color", "Imported feature color", + Config_Prop::Color, IMPORTED_FEATURE_COLOR); } FeaturePtr ExchangePlugin_Plugin::createFeature(string theFeatureID) -- 2.39.2