From b6ec94fb365b2e63057f78ae0e63fe9a72ecb829 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 29 May 2015 12:23:39 +0300 Subject: [PATCH] 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. --- src/XGUI/XGUI_CustomPrs.cpp | 13 +++++++++---- src/XGUI/XGUI_CustomPrs.h | 2 ++ src/XGUI/XGUI_Workshop.cpp | 24 +++++++++++++++--------- 3 files changed, 26 insertions(+), 13 deletions(-) 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()) -- 2.39.2