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:
@@ -269,6 +269,28 @@ void AIS_ColoredShape::SetTransparency (const Standard_Real theValue)
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
|
||||
{
|
||||
setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
|
||||
//myOwnMaterial = theMaterial;
|
||||
hasOwnMaterial = Standard_True;
|
||||
LoadRecomputable (AIS_Shaded);
|
||||
for (DataMapOfShapeColor::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
|
||||
//if (aDrawer->HasOwnMaterial()) continue;
|
||||
if (aDrawer->HasShadingAspect())
|
||||
{
|
||||
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), Standard_False); // aDrawer->IsTransparent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Compute
|
||||
//purpose :
|
||||
|
@@ -104,6 +104,9 @@ public: //! @name global aspects
|
||||
//! Sets transparency value.
|
||||
Standard_EXPORT virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE;
|
||||
|
||||
//! Sets the material aspect.
|
||||
Standard_EXPORT virtual void SetMaterial (const Graphic3d_MaterialAspect& theAspect) Standard_OVERRIDE;
|
||||
|
||||
protected: //! @name override presentation computation
|
||||
|
||||
Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
|
||||
|
@@ -306,6 +306,13 @@ uses
|
||||
theValue : Real from Standard)
|
||||
is protected;
|
||||
|
||||
setMaterial (me;
|
||||
theDrawer : Drawer from AIS;
|
||||
theMaterial : MaterialAspect from Graphic3d;
|
||||
theToKeepColor : Boolean from Standard;
|
||||
theToKeepTransp : Boolean from Standard)
|
||||
is protected;
|
||||
|
||||
fields
|
||||
myshape : Shape from TopoDS is protected;
|
||||
myBB : Box from Bnd is protected;
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user