X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_CustomPrs.cpp;h=fe9fbfcdcca1d35c1e1f0cc282f3f7c7fe78fa0c;hb=b303db5dadecd329d1b9749110dd08ebff2294ab;hp=c14f9932529cd5a939a710a6132906ed609414d5;hpb=2532fb2df83ee1ddd9ff3e8b381d3788eaa15b69;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_CustomPrs.cpp b/src/XGUI/XGUI_CustomPrs.cpp index c14f99325..fe9fbfcdc 100644 --- a/src/XGUI/XGUI_CustomPrs.cpp +++ b/src/XGUI/XGUI_CustomPrs.cpp @@ -14,7 +14,8 @@ // License along with this library; if not, write to the Free Software // 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 @@ -41,7 +42,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()); @@ -117,6 +118,27 @@ double XGUI_CustomPrs::getDefaultDeflection(const ObjectPtr& theObject) return aDeflection; } +double getTransparency(const ResultPtr& theResult) +{ + double aDeflection = -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()) { + double aValue = aDoubleAttr->value(); + if (aValue > 0) /// zero value should not be used as a transparency(previous studies) + aDeflection = aDoubleAttr->value(); + } + } + return aDeflection; +} + +double getDefaultTransparency(const ResultPtr& theResult) +{ + return 0; +} + XGUI_CustomPrs::XGUI_CustomPrs(XGUI_Workshop* theWorkshop) : myWorkshop(theWorkshop) { @@ -137,6 +159,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) { @@ -157,6 +187,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;