]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Color preferences for the imported feature.
authornds <natalia.donis@opencascade.com>
Fri, 20 Feb 2015 11:14:52 +0000 (14:14 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 20 Feb 2015 11:14:52 +0000 (14:14 +0300)
src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp
src/ExchangePlugin/ExchangePlugin_ImportFeature.h
src/ExchangePlugin/ExchangePlugin_Plugin.cpp

index 85a025f6832ec3b9861f70cd949803cc3ba0ec2a..11d45e7854aa0fecba09c74b3645e17e67816963 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <GeomAPI_Shape.h>
 #include <Config_Common.h>
+#include <Config_PropManager.h>
+
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
@@ -68,6 +70,14 @@ void ExchangePlugin_ImportFeature::execute()
   importFile(aFilePath);
 }
 
+void ExchangePlugin_ImportFeature::customisePresentation(AISObjectPtr thePrs)
+{
+  std::vector<int> 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
index 24bd6964f503b3fdb5d0b6a5db912082f10f52b3..54ed715213ce7c2ea7c4800e7a95e8a3afed1904 100644 (file)
@@ -6,15 +6,19 @@
 #include <ExchangePlugin.h>
 #include <ModelAPI_Feature.h>
 
+#include <GeomAPI_ICustomPrs.h>
+
 #include <map>
 
-/**\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);
index 6386d8a2a98b9562032cfcfb9bb60e1af6587e3b..cf32016859c4088cd15224867e8eddfc2122478b 100644 (file)
@@ -8,6 +8,8 @@
 #include <ExchangePlugin_ImportFeature.h>
 #include <ExchangePlugin_Validators.h>
 
+#include <Config_PropManager.h>
+
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Validator.h>
 
@@ -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)