1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025459: Visualization - AIS_ColoredShape::SetMaterial() should not reset custom colors

This commit is contained in:
kgv
2014-11-14 12:55:57 +03:00
committed by bugmaster
parent e83c01bfc0
commit e0608a8d27
7 changed files with 101 additions and 82 deletions

View File

@@ -710,6 +710,35 @@ void AIS_Shape::UnsetWidth()
LoadRecomputable (AIS_WireFrame);
}
//=======================================================================
//function : setMaterial
//purpose :
//=======================================================================
void AIS_Shape::setMaterial (const Handle(AIS_Drawer)& theDrawer,
const Graphic3d_MaterialAspect& theMaterial,
const Standard_Boolean theToKeepColor,
const Standard_Boolean theToKeepTransp) const
{
const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
if (!theDrawer->HasShadingAspect())
{
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
}
theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
if (theToKeepColor)
{
theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
}
if (theToKeepTransp)
{
theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
}
}
//=======================================================================
//function : SetMaterial
//purpose :
@@ -727,20 +756,9 @@ void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
if (!myDrawer->HasShadingAspect())
{
myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
*myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
}
setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
if (HasColor())
{
myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
}
myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();