"0021179: EDF 1654 SMESH GEOM: better look'n'feel" issue.

Material Properties.
This commit is contained in:
ana 2012-05-03 13:53:12 +00:00
parent 0f1c42a84c
commit 29505882a3
2 changed files with 32 additions and 27 deletions

View File

@ -147,6 +147,18 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape,
myVIsoNumber = -1; myVIsoNumber = -1;
myTopLevel = Standard_False; myTopLevel = Standard_False;
Graphic3d_MaterialAspect aMatAspect;
if ( !HasMaterial() ) {
aMatAspect.SetAmbient( 0.5 );
aMatAspect.SetDiffuse( 0.5 );
aMatAspect.SetEmissive( 0.5 );
aMatAspect.SetShininess(0.5 );
aMatAspect.SetSpecular( 0.5 );
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(aMatAspect);
}
myCurrentMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
} }
void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){ void GEOM_AISShape::setIO(const Handle(SALOME_InteractiveObject)& io){
@ -198,7 +210,6 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent
if(isTopLevel()) { if(isTopLevel()) {
SetColor(topLevelColor()); SetColor(topLevelColor());
Handle(Prs3d_LineAspect) anAspect = Attributes()->WireAspect(); Handle(Prs3d_LineAspect) anAspect = Attributes()->WireAspect();
anAspect->SetColor( topLevelColor() ); anAspect->SetColor( topLevelColor() );
Attributes()->SetWireAspect( anAspect ); Attributes()->SetWireAspect( anAspect );
@ -316,10 +327,10 @@ void GEOM_AISShape::SetTransparency(const Standard_Real aValue)
} }
Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); FMat.SetTransparency(aValue);
FMat.SetTransparency(aValue); BMat.SetTransparency(aValue);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat); myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat); myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(FMat);
myCurrentMaterial = FMat;
myTransparency = aValue; myTransparency = aValue;
} }
@ -375,33 +386,24 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre
{ {
myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn(); myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn();
Graphic3d_MaterialAspect aMatAspect; Graphic3d_MaterialAspect aMatAspect(Graphic3d_NOM_PLASTIC);
if ( !HasMaterial() ) { aMatAspect.SetTransparency(myTransparency);
aMatAspect.SetAmbient( 0.5 ); myCurrentMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
aMatAspect.SetDiffuse( 0.5 ); myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : myCurrentMaterial );
aMatAspect.SetEmissive( 0.5 ); myDrawer->ShadingAspect()->Aspect()->SetBackMaterial( isTopLevel() ? aMatAspect : myCurrentMaterial );
aMatAspect.SetShininess(0.5 );
aMatAspect.SetSpecular( 0.5 );
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(aMatAspect);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(Graphic3d_NOM_JADE);
}
Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial();
FMat.SetTransparency(myTransparency); BMat.SetTransparency(myTransparency);
myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat);
myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat);
//Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
// P->SetPrimitivesAspect(a4bis); // P->SetPrimitivesAspect(a4bis);
// G->SetGroupPrimitivesAspect(a4bis); // G->SetGroupPrimitivesAspect(a4bis);
//a4bis->SetInteriorColor(myShadingColor); //a4bis->SetInteriorColor(myShadingColor);
myDrawer->ShadingAspect()->SetColor(isTopLevel() ? topLevelColor() : myShadingColor); if( isTopLevel() )
myDrawer->ShadingAspect()->SetColor( topLevelColor() );
else if(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().MaterialType( Graphic3d_MATERIAL_ASPECT ))
myDrawer->ShadingAspect()->SetColor(myShadingColor);
// PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces
//StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer); //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
AIS_Shape::Compute(aPresentationManager, aPrs, aMode); AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
} }
void GEOM_AISShape::storeIsoNumbers() void GEOM_AISShape::storeIsoNumbers()

View File

@ -58,6 +58,7 @@
#include <TCollection_AsciiString.hxx> #include <TCollection_AsciiString.hxx>
#include <AIS_DisplayMode.hxx> #include <AIS_DisplayMode.hxx>
#include <Graphic3d_MaterialAspect.hxx>
class PrsMgr_PresentationManager3d; class PrsMgr_PresentationManager3d;
class Prs3d_Presentation; class Prs3d_Presentation;
@ -149,8 +150,10 @@ protected:
private: private:
TCollection_AsciiString myName; TCollection_AsciiString myName;
bool myDisplayVectors; bool myDisplayVectors;
Standard_Boolean myTopLevel; Standard_Boolean myTopLevel;
Graphic3d_MaterialAspect myCurrentMaterial;
}; };