From: ana Date: Thu, 3 May 2012 13:53:12 +0000 (+0000) Subject: "0021179: EDF 1654 SMESH GEOM: better look'n'feel" issue. X-Git-Tag: V6_5_0b1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=29505882a3ee01db9b5d49b44a1edf56d16a00e0;p=modules%2Fgeom.git "0021179: EDF 1654 SMESH GEOM: better look'n'feel" issue. Material Properties. --- diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index dc79dd8aa..5d4422acb 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -147,6 +147,18 @@ GEOM_AISShape::GEOM_AISShape(const TopoDS_Shape& shape, myVIsoNumber = -1; 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){ @@ -198,7 +210,6 @@ void GEOM_AISShape::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresent if(isTopLevel()) { SetColor(topLevelColor()); - Handle(Prs3d_LineAspect) anAspect = Attributes()->WireAspect(); anAspect->SetColor( topLevelColor() ); Attributes()->SetWireAspect( anAspect ); @@ -316,10 +327,10 @@ void GEOM_AISShape::SetTransparency(const Standard_Real aValue) } Graphic3d_MaterialAspect FMat = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); - Graphic3d_MaterialAspect BMat = myDrawer->ShadingAspect()->Aspect()->BackMaterial(); - FMat.SetTransparency(aValue); BMat.SetTransparency(aValue); + FMat.SetTransparency(aValue); myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial(FMat); - myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(BMat); + myDrawer->ShadingAspect()->Aspect()->SetBackMaterial(FMat); + myCurrentMaterial = FMat; myTransparency = aValue; } @@ -375,33 +386,24 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre { myDrawer->ShadingAspect()->Aspect()->SetDistinguishOn(); - 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(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); + Graphic3d_MaterialAspect aMatAspect(Graphic3d_NOM_PLASTIC); + aMatAspect.SetTransparency(myTransparency); + myCurrentMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); + myDrawer->ShadingAspect()->Aspect()->SetFrontMaterial( isTopLevel() ? aMatAspect : myCurrentMaterial ); + myDrawer->ShadingAspect()->Aspect()->SetBackMaterial( isTopLevel() ? aMatAspect : myCurrentMaterial ); //Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); // P->SetPrimitivesAspect(a4bis); // G->SetGroupPrimitivesAspect(a4bis); //a4bis->SetInteriorColor(myShadingColor); - myDrawer->ShadingAspect()->SetColor(isTopLevel() ? topLevelColor() : myShadingColor); - - // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces - //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer); - AIS_Shape::Compute(aPresentationManager, aPrs, aMode); + 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 + //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer); + AIS_Shape::Compute(aPresentationManager, aPrs, aMode); } void GEOM_AISShape::storeIsoNumbers() diff --git a/src/OBJECT/GEOM_AISShape.hxx b/src/OBJECT/GEOM_AISShape.hxx index f4fea03c1..4dfe2c9a1 100644 --- a/src/OBJECT/GEOM_AISShape.hxx +++ b/src/OBJECT/GEOM_AISShape.hxx @@ -58,6 +58,7 @@ #include #include +#include class PrsMgr_PresentationManager3d; class Prs3d_Presentation; @@ -149,8 +150,10 @@ protected: private: TCollection_AsciiString myName; - bool myDisplayVectors; - Standard_Boolean myTopLevel; + bool myDisplayVectors; + Standard_Boolean myTopLevel; + Graphic3d_MaterialAspect myCurrentMaterial; + };