X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_CustomPrs.cpp;h=f3bd68300687122be19c59e1401ffa328eb69b85;hb=c7d72b1e9c2bf38f8cb27f9251c7a332401dc2fe;hp=cc12b80903cb17464d15ce58e17164f45946a333;hpb=87b6a30a3afb8fb32e7e43ade8d9c947d9eb1684;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_CustomPrs.cpp b/src/XGUI/XGUI_CustomPrs.cpp index cc12b8090..f3bd68300 100644 --- a/src/XGUI/XGUI_CustomPrs.cpp +++ b/src/XGUI/XGUI_CustomPrs.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include @@ -42,7 +41,7 @@ double getDeflection(const ResultPtr& theResult) { double aDeflection = -1; - // get color from the attribute of the result + // get deflection from the attribute of the result if (theResult.get() != NULL && theResult->data()->attribute(ModelAPI_Result::DEFLECTION_ID()).get() != NULL) { AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID()); @@ -118,6 +117,25 @@ double XGUI_CustomPrs::getDefaultDeflection(const ObjectPtr& theObject) return aDeflection; } +double getTransparency(const ResultPtr& theResult) +{ + double aTransparency = -1; + // get transparency from the attribute of the result + if (theResult.get() != NULL && + theResult->data()->attribute(ModelAPI_Result::TRANSPARENCY_ID()).get() != NULL) { + AttributeDoublePtr aDoubleAttr = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID()); + if (aDoubleAttr.get() && aDoubleAttr->isInitialized()) { + aTransparency = aDoubleAttr->value(); + } + } + return aTransparency; +} + +double getDefaultTransparency(const ResultPtr& theResult) +{ + return Config_PropManager::integer("Visualization", "shaper_default_transparency") / 100.; +} + XGUI_CustomPrs::XGUI_CustomPrs(XGUI_Workshop* theWorkshop) : myWorkshop(theWorkshop) { @@ -138,6 +156,14 @@ double XGUI_CustomPrs::getResultDeflection(const ResultPtr& theResult) return aDeflection; } +double XGUI_CustomPrs::getResultTransparency(const ResultPtr& theResult) +{ + double aTransparency = getTransparency(theResult); + if (aTransparency < 0) + aTransparency = getDefaultTransparency(theResult); + return aTransparency; +} + bool XGUI_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr thePrs, std::shared_ptr theCustomPrs) { @@ -158,6 +184,8 @@ bool XGUI_CustomPrs::customisePresentation(ResultPtr theResult, AISObjectPtr the aCustomized = !aColor.empty() && thePrs->setColor(aColor[0], aColor[1], aColor[2]); aCustomized = thePrs->setDeflection(getResultDeflection(theResult)) | aCustomized; + + aCustomized = thePrs->setTransparency(getResultTransparency(theResult)) | aCustomized; } ModuleBase_IModule* aModule = myWorkshop->module(); aCustomized = aModule->customisePresentation(theResult, thePrs, theCustomPrs) || aCustomized;