]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
"0021179: EDF 1654 SMESH GEOM: better look'n'feel" issue.
authorana <ana@opencascade.com>
Thu, 3 May 2012 13:53:12 +0000 (13:53 +0000)
committerana <ana@opencascade.com>
Thu, 3 May 2012 13:53:12 +0000 (13:53 +0000)
Material Properties.

src/OBJECT/GEOM_AISShape.cxx
src/OBJECT/GEOM_AISShape.hxx

index dc79dd8aa95c9a5572d61672e2bedbd4fd005535..5d4422acb2038710a7c08969bb76fd224fc36c50 100644 (file)
@@ -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()
index f4fea03c15aa64303176f837bb60ebae1b983b87..4dfe2c9a199ce23a9a41d221f0b491a7eee2a6f1 100644 (file)
@@ -58,6 +58,7 @@
 #include <TCollection_AsciiString.hxx>
 
 #include <AIS_DisplayMode.hxx>
+#include <Graphic3d_MaterialAspect.hxx>
 
 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;
+
 };