From: nds Date: Fri, 29 May 2015 09:23:39 +0000 (+0300) Subject: Issue #578 color for hidden object: the color from AIS object should not be used... X-Git-Tag: V_1.2.0~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b6ec94fb365b2e63057f78ae0e63fe9a72ecb829;p=modules%2Fshaper.git Issue #578 color for hidden object: the color from AIS object should not be used in this method at all. It should be removed later. --- diff --git a/src/XGUI/XGUI_CustomPrs.cpp b/src/XGUI/XGUI_CustomPrs.cpp index 171baa846..10125e574 100644 --- a/src/XGUI/XGUI_CustomPrs.cpp +++ b/src/XGUI/XGUI_CustomPrs.cpp @@ -30,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 @@ -49,14 +49,19 @@ void getDefaultColor(ResultPtr theResult, AISObjectPtr thePrs, std::vector& } } +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, std::shared_ptr theCustomPrs) { 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()) { diff --git a/src/XGUI/XGUI_CustomPrs.h b/src/XGUI/XGUI_CustomPrs.h index 97bc89133..a1e636a5c 100644 --- a/src/XGUI/XGUI_CustomPrs.h +++ b/src/XGUI/XGUI_CustomPrs.h @@ -24,6 +24,8 @@ public: /// Modifies the given presentation in the custom way. virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, std::shared_ptr theCustomPrs); + + static void getResultColor(ResultPtr theResult, std::vector& theColor); }; #endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 40d623a8b..e56e696f5 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -18,6 +18,7 @@ #include "XGUI_ModuleConnector.h" #include #include +#include #include #include @@ -1511,20 +1512,25 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects) ObjectPtr aObject = aPartDoc->object(ModelAPI_ResultBody::group(), 0); ResultBodyPtr aBody = std::dynamic_pointer_cast(aObject); if (aBody.get()) { - std::string aSection, aName, aDefault; - aBody->colorConfigInfo(aSection, aName, aDefault); - if (!aSection.empty() && !aName.empty()) { - aColor = Config_PropManager::color(aSection, aName, aDefault); - } + XGUI_CustomPrs::getResultColor(aBody, aColor); } } } } else { - AISObjectPtr anAISObj = myDisplayer->getAISObject(anObject); - if (anAISObj.get()) { - aColor.resize(3); - anAISObj->getColor(aColor[0], aColor[1], aColor[2]); + ResultPtr aResult = std::dynamic_pointer_cast(anObject); + if (aResult.get()) + XGUI_CustomPrs::getResultColor(aResult, aColor); + else { + // TODO: remove the obtaining a color from the AIS object + // this does not happen never because: + // 1. The color can be changed only on results + // 2. The result can be not visualized in the viewer(e.g. Origin Construction) + AISObjectPtr anAISObj = myDisplayer->getAISObject(anObject); + if (anAISObj.get()) { + aColor.resize(3); + anAISObj->getColor(aColor[0], aColor[1], aColor[2]); + } } } if (!aColor.empty())