X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_CustomPrs.cpp;h=10125e574301d1c8d8cb228a97bb071bd20721f2;hb=75708cdfd8653e625bfb7aee667a7bb31867f292;hp=8584bc554ca1d3f2a6ae8daf7a7759a352bbc13a;hpb=247fc0bd6c6e04ce1f7a6e67f8d3c80ce17acab0;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_CustomPrs.cpp b/src/XGUI/XGUI_CustomPrs.cpp index 8584bc554..10125e574 100644 --- a/src/XGUI/XGUI_CustomPrs.cpp +++ b/src/XGUI/XGUI_CustomPrs.cpp @@ -7,9 +7,13 @@ #include #include +#include #include +#include + #include +#include void getColor(ResultPtr theResult, std::vector& theColor) @@ -26,7 +30,7 @@ void getColor(ResultPtr theResult, std::vector& theColor) } } -void getDefaultColor(ResultPtr theResult, AISObjectPtr thePrs, std::vector& theColor) +void getDefaultColor(ResultPtr theResult, std::vector& theColor) { theColor.clear(); // get default color from the preferences manager for the given result @@ -37,9 +41,19 @@ void getDefaultColor(ResultPtr theResult, AISObjectPtr thePrs, std::vector& 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"); + } +} + +void XGUI_CustomPrs::getResultColor(ResultPtr theResult, std::vector& theColor) +{ + getColor(theResult, theColor); + if (theColor.empty()) + getDefaultColor(theResult, theColor); } bool XGUI_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, @@ -47,9 +61,15 @@ bool XGUI_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr the { std::vector aColor; - getColor(theResult, aColor); - if (aColor.empty()) - getDefaultColor(theResult, thePrs, aColor); + getResultColor(theResult, 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]); }