Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom into Dev_1.2.0
[modules/shaper.git] / src / XGUI / XGUI_CustomPrs.cpp
index 8584bc554ca1d3f2a6ae8daf7a7759a352bbc13a..171baa8465bb73e8b61291b7743a9eb0a7558db5 100644 (file)
@@ -7,9 +7,13 @@
 #include <XGUI_CustomPrs.h>
 
 #include <ModelAPI_AttributeIntArray.h>
+#include <ModelAPI_Session.h>
 #include <Config_PropManager.h>
 
+#include <Events_Error.h>
+
 #include <vector>
+#include <QColor>
 
 
 void getColor(ResultPtr theResult, std::vector<int>& theColor)
@@ -37,9 +41,12 @@ void getDefaultColor(ResultPtr theResult, AISObjectPtr thePrs, std::vector<int>&
       theColor = Config_PropManager::color(aSection, aName, aDefault);
     }
   }
-  if (theColor.empty()) // all AIS objects, where the color is not set, a white.
+  if (theColor.empty()) {
+    // all AIS objects, where the color is not set, are in black.
     // The color should be defined in XML or set in the attribute
-    theColor = Config_PropManager::color("Visualization", "object_default_color", "#ffffff");
+    theColor = Config_PropManager::color("Visualization", "object_default_color", "#000000");
+    Events_Error::send("A default color is not defined in the preferences for this kind of result");
+  }
 }
 
 bool XGUI_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
@@ -51,5 +58,13 @@ bool XGUI_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr the
   if (aColor.empty())
     getDefaultColor(theResult, thePrs, aColor);
 
+  SessionPtr aMgr = ModelAPI_Session::get();
+  if (aMgr->activeDocument() != theResult->document()) {
+    QColor aQColor(aColor[0], aColor[1], aColor[2]);
+    QColor aNewColor = QColor::fromHsvF(aQColor.hueF(), aQColor.saturationF()/3., aQColor.valueF());
+    aColor[0] = aNewColor.red();
+    aColor[1] = aNewColor.green();
+    aColor[2] = aNewColor.blue();
+  }
   return !aColor.empty() && thePrs->setColor(aColor[0], aColor[1], aColor[2]);
 }