0022776: XCAFPrs_AISObject does not support transparency
authorSZV <>
Fri, 27 Jan 2012 13:34:50 +0000 (13:34 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:32:05 +0000 (19:32 +0400)
src/AIS/AIS_Shape.cdl
src/AIS/AIS_Shape.cxx
src/ViewerTest/ViewerTest.cxx
src/XCAFPrs/XCAFPrs.cdl
src/XCAFPrs/XCAFPrs_AISObject.cdl
src/XCAFPrs/XCAFPrs_AISObject.cxx
src/XDEDRAW/XDEDRAW.cxx

index 34a66f5..336cf28 100755 (executable)
@@ -1,7 +1,6 @@
 -- File:       AIS_Shape.cdl
 -- Created:    Fri Dec 20 15:18:05 1996
 -- Author:     Robert COUBLANC
---             <rob@robox.paris1.matra-dtv.fr>
 --   GG  :  GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
 --                                    the restricted NameOfColor.
 --          Redefines the Color(),Material(),Transparency() methods 
@@ -272,7 +271,7 @@ uses
        -- -   mode 7 - Compsolid
        -- -   mode 8 - Compound
 
-   LoadRecomputable(me:mutable;TheMode : Integer from Standard) is static private;
+   LoadRecomputable(me:mutable;TheMode : Integer from Standard) is static protected;
 
     Compute(me                   : mutable;
            aProjector           : Projector from Prs3d;
index 4c62c9b..e52dfc0 100755 (executable)
@@ -1,7 +1,6 @@
 // File:       AIS_Shape.cxx
 // Created:    Fri Dec 20 17:18:37 1996
 // Author:     Robert COUBLANC
-//             <rob@robox.paris1.matra-dtv.fr>
 
 #define BUC60577       //GG_191099 Draw correct bounding box and Menage ...
 
@@ -543,44 +542,27 @@ Standard_Real AIS_Shape::Transparency() const {
 //=======================================================================
 
 void AIS_Shape::SetColor(const Quantity_NameOfColor aCol)
-#ifdef GER61351
 {
   SetColor(Quantity_Color(aCol));
 }
 
+//=======================================================================
+//function : SetColor
+//purpose  : 
+//=======================================================================
+
 void AIS_Shape::SetColor(const Quantity_Color &aCol)
-#endif
 {
-  hasOwnColor = Standard_True;
-#ifdef GER61351
   if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
     myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
-#else
-  myOwnColor  = aCol; 
-  if(!myDrawer->HasShadingAspect()){
-    Handle(Prs3d_ShadingAspect) asp = new Prs3d_ShadingAspect();
-// retrieve the reference materials...
-    if(myDrawer->HasLink()){
-      const Handle(Prs3d_Drawer)& refdr = myDrawer->Link();
-      Graphic3d_MaterialAspect theRefMat = 
-       refdr->ShadingAspect()->Aspect()->FrontMaterial();
-      theRefMat.SetTransparency(myTransparency);
-      asp->SetMaterial(theRefMat);
-    }   
-    
-    myDrawer->SetShadingAspect(asp);
-  } 
-#endif
+  hasOwnColor = Standard_True;
 
-#ifdef GER61351
   myDrawer->ShadingAspect()->SetColor(aCol,myCurrentFacingModel);
-#else
-  myDrawer->ShadingAspect()->SetColor(aCol);
-#endif
+  myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
   myDrawer->SetShadingAspectGlobal(Standard_False);
-    
-  Standard_Real WW = HasWidth()? Width():AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
+
+  const Standard_Real WW = HasWidth()? Width():AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
 
   myDrawer->SetLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
   myDrawer->SetWireAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
@@ -609,6 +591,7 @@ void AIS_Shape::SetColor(const Quantity_Color &aCol)
   LoadRecomputable(0);
   LoadRecomputable(2); 
 }
+
 //=======================================================================
 //function : UnsetColor
 //purpose  : 
@@ -616,23 +599,24 @@ void AIS_Shape::SetColor(const Quantity_Color &aCol)
 
 void AIS_Shape::UnsetColor()
 {
-  if(!HasColor() ){  myToRecomputeModes.Clear();
-                    return;}
-  
+  if ( !HasColor() )
+  {
+    myToRecomputeModes.Clear();
+    return;
+  }
   hasOwnColor = Standard_False;
 
   Handle(Prs3d_LineAspect) NullAsp;
   Handle(Prs3d_ShadingAspect) NullShA;
   
-  if(!HasWidth()){
+  if(!HasWidth()) {
     myDrawer->SetLineAspect(NullAsp);
     myDrawer->SetWireAspect(NullAsp);
     myDrawer->SetFreeBoundaryAspect(NullAsp);
     myDrawer->SetUnFreeBoundaryAspect(NullAsp);
     myDrawer->SetSeenLineAspect(NullAsp);
   }
-  else{
-#ifdef GER61351
+  else {
     Quantity_Color CC;
     AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
     myDrawer->LineAspect()->SetColor(CC);
@@ -644,43 +628,37 @@ void AIS_Shape::UnsetColor()
     myDrawer->UnFreeBoundaryAspect()->SetColor(CC);
     AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC);
     myDrawer->SeenLineAspect()->SetColor(CC);
-#else
-    myDrawer->LineAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line));
-    myDrawer->WireAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire));
-    myDrawer->FreeBoundaryAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free));
-    myDrawer->UnFreeBoundaryAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree));
-    myDrawer->SeenLineAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen));
-#endif
   }
-  
-  if(myDrawer->HasShadingAspect()){
+
+  if( HasMaterial() || IsTransparent()) {
+    Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(HasMaterial()? myDrawer : myDrawer->Link());
+    if( HasMaterial() ) {
+      Quantity_Color color = myDrawer->Link()->ShadingAspect()->Color(myCurrentFacingModel);
+      mat.SetColor(color);
+    }
+    if( IsTransparent() ) {
+      Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
+      mat.SetTransparency(trans);
+    }
+    myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel);
+  }
+  else {
     myDrawer->SetShadingAspect(NullShA);
-  }    
-  
+  }
+
   if(!GetContext().IsNull()){
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
       Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
       Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
-      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->Link()->ShadingAspect()->Aspect();
-#ifdef GER61351
-      Quantity_Color CC;
-      AIS_GraphicTool::GetInteriorColor(myDrawer->Link(),CC);
-      a4bis->SetInteriorColor(CC);
-#else
-      Quantity_NameOfColor KOL = AIS_GraphicTool::GetInteriorColor(myDrawer->Link());
-      a4bis->SetInteriorColor(Quantity_Color(KOL));
-#endif
+      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
       P->SetPrimitivesAspect(a4bis);
       G->SetGroupPrimitivesAspect(a4bis);
     }
-}
+  }
   LoadRecomputable(0);
   LoadRecomputable(2);
-  
 }
 
-
 //=======================================================================
 //function : SetWidth
 //purpose  : 
@@ -688,7 +666,7 @@ void AIS_Shape::UnsetColor()
 
 void AIS_Shape::SetWidth(const Standard_Real W)
 {
-  if(HasColor() || HasWidth()){ 
+  if(HasColor() || HasWidth()){
     myDrawer->LineAspect()->SetWidth(W);
     myDrawer->WireAspect()->SetWidth(W);
     myDrawer->FreeBoundaryAspect()->SetWidth(W);
@@ -696,7 +674,6 @@ void AIS_Shape::SetWidth(const Standard_Real W)
     myDrawer->SeenLineAspect()->SetWidth(W);
   }
   else{
-#ifdef GER61351
     Quantity_Color CC;
     AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
     myDrawer->SetLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
@@ -708,27 +685,10 @@ void AIS_Shape::SetWidth(const Standard_Real W)
     myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
     AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC);
     myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
-#else
-    Quantity_NameOfColor KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line);
-    myDrawer->SetLineAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-
-    KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire);
-    myDrawer->SetWireAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-
-    KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free);
-    myDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-
-    KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree);
-    myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-
-    KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen);
-    myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W));
-#endif    
   }
   myOwnWidth = W;
   LoadRecomputable(0); // means that it is necessary to recompute only the wireframe....
   LoadRecomputable(2); // and the bounding box...
-  
 }
 
 //=======================================================================
@@ -738,11 +698,15 @@ void AIS_Shape::SetWidth(const Standard_Real W)
 
 void AIS_Shape::UnsetWidth()
 {
-  if(myOwnWidth== 0.0){  myToRecomputeModes.Clear();
-                     return;}
+  if(myOwnWidth == 0.0)
+  {
+    myToRecomputeModes.Clear();
+    return;
+  }
   myOwnWidth=0.0;
+
   Handle(Prs3d_LineAspect) NullAsp;
-  
+
   if(!HasColor()){
     myDrawer->SetLineAspect(NullAsp);
     myDrawer->SetWireAspect(NullAsp);
@@ -760,60 +724,58 @@ void AIS_Shape::UnsetWidth()
   LoadRecomputable(0);
 }
 
-
 //=======================================================================
 //function : SetMaterial
 //purpose  : 
 //=======================================================================
+
 void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
 {
-#ifdef GER61351
   if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
     myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
-  myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
   hasOwnMaterial = Standard_True;
-#else
-  AIS_InteractiveObject::SetMaterial(aMat);
-#endif
+
+  myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
+  myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
+
   if(!GetContext().IsNull()){
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
       Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
       Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
       Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
       P->SetPrimitivesAspect(a4bis);
       G->SetGroupPrimitivesAspect(a4bis);
     }
   }
   myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
-  myToRecomputeModes.Clear();  
+  myToRecomputeModes.Clear();
 }
+
 //=======================================================================
 //function : SetMaterial
 //purpose  : 
 //=======================================================================
+
 void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat)
 {
-#ifdef GER61351
   if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
     myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
-  myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
   hasOwnMaterial = Standard_True;
-#else
-  AIS_InteractiveObject::SetMaterial(aMat);
-#endif  
+
+  myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
+  myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
+
   if(!GetContext().IsNull()){
-  if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
-    Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
-    Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-    
-    Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-    P->SetPrimitivesAspect(a4bis);
-    G->SetGroupPrimitivesAspect(a4bis);
+    if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
+      Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
+      Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
+      Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
+      P->SetPrimitivesAspect(a4bis);
+      G->SetGroupPrimitivesAspect(a4bis);
+    }
   }
-}
   myRecomputeEveryPrs =Standard_False; // no mode to recalculate  :only viewer update
   myToRecomputeModes.Clear();  
 }
@@ -822,10 +784,11 @@ void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat)
 //function : UnsetMaterial
 //purpose  : 
 //=======================================================================
+
 void AIS_Shape::UnsetMaterial()
 {
-#ifdef GER61351
   if( !HasMaterial() ) return;
+
   if( HasColor() || IsTransparent()) {
     Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link()); 
     if( HasColor() ) {
@@ -842,15 +805,11 @@ void AIS_Shape::UnsetMaterial()
     myDrawer->SetShadingAspect(SA);
   }
   hasOwnMaterial = Standard_False;
-#else
-  AIS_InteractiveObject::UnsetMaterial();
-#endif
-  if(!GetContext().IsNull()){
 
+  if(!GetContext().IsNull()){
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
       Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
       Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
       Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
       P->SetPrimitivesAspect(a4bis);
       G->SetGroupPrimitivesAspect(a4bis);
@@ -858,8 +817,8 @@ void AIS_Shape::UnsetMaterial()
   }
   myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
   myToRecomputeModes.Clear();  
-  
 }
+
 //=======================================================================
 //function : SetTransparency
 //purpose  : 
@@ -867,20 +826,16 @@ void AIS_Shape::UnsetMaterial()
 
 void AIS_Shape::SetTransparency(const Standard_Real AValue)
 {
-#ifdef GER61351
-  if(!HasColor() && !HasMaterial() ) {
-        myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+  if ( !HasColor() && !HasMaterial() ) {
+    myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
   }
   myDrawer->ShadingAspect()->SetTransparency(AValue,myCurrentFacingModel);
   myTransparency = AValue;
-#else
-  AIS_InteractiveObject::SetTransparency(AValue);
-#endif  
+
   if(!GetContext().IsNull()){
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
       Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
       Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
       Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
       P->SetPrimitivesAspect(a4bis);
 #ifdef BUC60918   //force highest priority for transparent objects
@@ -890,33 +845,28 @@ void AIS_Shape::SetTransparency(const Standard_Real AValue)
     }
   }
   myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
-  myToRecomputeModes.Clear();  
-  
+  myToRecomputeModes.Clear();
 }
 
 //=======================================================================
 //function : UnsetTransparency
 //purpose  : 
 //=======================================================================
+
 void AIS_Shape::UnsetTransparency()
 {
-#ifdef GER61351
-  if(HasColor() || HasMaterial() ) {
+  if( HasColor() || HasMaterial() ) {
     myDrawer->ShadingAspect()->SetTransparency(0.0,myCurrentFacingModel);
   } else {
     Handle(Prs3d_ShadingAspect) SA;
     myDrawer->SetShadingAspect(SA);
   }
   myTransparency = 0.0;
-#else
-  AIS_InteractiveObject::UnsetTransparency();
-#endif
+
   if(!GetContext().IsNull()){
-    
     if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
       Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
       Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
-      
       Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
       P->SetPrimitivesAspect(a4bis);
       G->SetGroupPrimitivesAspect(a4bis);
@@ -926,19 +876,21 @@ void AIS_Shape::UnsetTransparency()
     }
   }
   myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
-  myToRecomputeModes.Clear();  
+  myToRecomputeModes.Clear();
 }
 
+//=======================================================================
+//function : LoadRecomputable
+//purpose  : 
+//=======================================================================
 
 void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
 {
-  myRecomputeEveryPrs =Standard_False;
+  myRecomputeEveryPrs = Standard_False;
   if(!IsInList(myToRecomputeModes,TheMode))
     myToRecomputeModes.Append(TheMode);
 }
 
-
-
 //=======================================================================
 //function : BoundingBox
 //purpose  : 
index 7db57af..f518baa 100755 (executable)
@@ -1,7 +1,6 @@
 // File:       ViewerTest.cxx
 // Created:    Wed Jul 23 14:14:01 1997
 // Author:     Henri JEANNIN
-//             <bbl@entrax.paris3.matra-dtv.fr>
 // Modified by  Eric Gouthiere [sep-oct 98] -> add commands for display...
 //
 // Modified by  Robert Coublanc [nov 16-17-18 1998]
@@ -980,20 +979,15 @@ static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** ar
   Standard_Boolean    ThereIsCurrent;
   Standard_Boolean    ThereIsArgument;
   Standard_Boolean    IsBound = Standard_False ;
-  Standard_Boolean    HaveToSet;
 
-  if (!strcasecmp( argv[0],"vsetcolor")) HaveToSet=Standard_True;
-  else HaveToSet=Standard_False;
+  const Standard_Boolean HaveToSet=(strcasecmp( argv[0],"vsetcolor") == 0);
   if (HaveToSet) {
-    if ( argc<2 || argc > 3 ) { di << argv[0] << " syntax error: Passez 2 ou 3 arguments" << "\n"; return 1; }
-    if ( argc == 2 ) {ThereIsArgument=Standard_False;}
-    else ThereIsArgument=Standard_True;
-
+    if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error: Give 2 or 3 arguments" << "\n"; return 1; }
+    ThereIsArgument = (argc != 2);
   }
   else {
-    if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; }
-    if(argc==2) ThereIsArgument=Standard_True;
-    else ThereIsArgument=Standard_False;
+    if ( argc > 2 ) { di << argv[0] << " syntax error: Given too many arguments" << "\n"; return 1; }
+    ThereIsArgument = (argc == 2);
   }
 
   if ( !a3DView().IsNull() ) {
@@ -1018,22 +1012,20 @@ static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** ar
         Handle(AIS_InteractiveObject) ashape =
           Handle(AIS_InteractiveObject)::DownCast (anObj);
 #ifdef DEB
-          //cout  << "HaveToSet "<<HaveToSet <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << endl;
           if (HaveToSet)
             di  << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
           else
-            di  << "HaveToSet "<< "0" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
+            di  << "HaveToSet 0\n";
 #endif
 
-        if(HaveToSet) {
+        if(HaveToSet)
           TheAISContext()->SetColor(ashape,GetColorFromName(argv[2]) );
-        }
         else
           TheAISContext()->UnsetColor(ashape);
       } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
         Handle(NIS_Triangulated) ashape =
           Handle(NIS_Triangulated)::DownCast (anObj);
-        if (ashape.IsNull() == Standard_False)
+        if (!ashape.IsNull())
           ashape->SetColor (GetColorFromName(argv[2]));
       }
     }
@@ -1048,20 +1040,19 @@ static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** ar
            TheAISContext() -> MoreCurrent() ;
            TheAISContext() ->NextCurrent() )
       {
-       const Handle(AIS_InteractiveObject) ashape= TheAISContext()->Current();
+        const Handle(AIS_InteractiveObject) ashape= TheAISContext()->Current();
         if (ashape.IsNull())
           continue;
 #ifdef DEB
-       //cout  << "HaveToSet "<<HaveToSet <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << endl;
-       if (HaveToSet)
-         di  << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
-       else
-         di  << "HaveToSet "<< "0" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
+        if (HaveToSet)
+          di  << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
+        else
+          di  << "HaveToSet 0\n";
 #endif
-       if(HaveToSet)
-         TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),Standard_False);
-       else
-         TheAISContext()->UnsetColor(ashape,Standard_False);
+        if(HaveToSet)
+          TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),Standard_False);
+        else
+          TheAISContext()->UnsetColor(ashape,Standard_False);
       }
 
       TheAISContext()->UpdateCurrentViewer();
@@ -1074,15 +1065,14 @@ static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** ar
     else if (!ThereIsCurrent && !ThereIsArgument){
       ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
       while ( it.More() ) {
-       const Handle(AIS_InteractiveObject) ashape =
+        const Handle(AIS_InteractiveObject) ashape =
           Handle(AIS_InteractiveObject)::DownCast(it.Key1());
         if (!ashape.IsNull())
           if(HaveToSet)
-            TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),
-                                      Standard_False);
+            TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),Standard_False);
           else
             TheAISContext()->UnsetColor(ashape,Standard_False);
-       it.Next();
+        it.Next();
       }
       TheAISContext()->UpdateCurrentViewer();
     }
@@ -1097,28 +1087,21 @@ static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** ar
 //Draw arg : vtransparency [name] TransparencyCoeficient
 //==============================================================================
 
-
 static int VTransparency  (Draw_Interpretor& di, Standard_Integer argc,
                            const char** argv)
 {
   Standard_Boolean    ThereIsCurrent;
   Standard_Boolean    ThereIsArgument;
   Standard_Boolean    IsBound = Standard_False ;
-  Standard_Boolean    HaveToSet;
-  if (!strcasecmp( argv[0],"vsettransparency"))
-    HaveToSet=Standard_True;
-  else
-    HaveToSet=Standard_False;
 
+  const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsettransparency") == 0);
   if (HaveToSet) {
     if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
-    if ( argc == 2 ) {ThereIsArgument=Standard_False;}
-    else ThereIsArgument=Standard_True;
+    ThereIsArgument = (argc != 2);
   }
   else{
     if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; }
-    if(argc==2) ThereIsArgument=Standard_True;
-    else ThereIsArgument=Standard_False;
+    ThereIsArgument = (argc == 2);
   }
 
   if ( !a3DView().IsNull() ) {
@@ -1145,7 +1128,7 @@ static int VTransparency  (Draw_Interpretor& di, Standard_Integer argc,
           TheAISContext()->SetTransparency(ashape,atof(argv[2]) );
         else
           TheAISContext()->UnsetTransparency(ashape);
-} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
+      } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
         const Handle(NIS_InteractiveObject) ashape =
           Handle(NIS_InteractiveObject)::DownCast(anObj);
         if(HaveToSet)
@@ -1163,12 +1146,11 @@ static int VTransparency  (Draw_Interpretor& di, Standard_Integer argc,
            TheAISContext() -> MoreCurrent() ;
            TheAISContext() ->NextCurrent() )
       {
-       Handle(AIS_InteractiveObject) ashape =  TheAISContext() -> Current();
-       if(HaveToSet) {
-         TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False);
-       }
-       else
-         TheAISContext()->UnsetTransparency(ashape,Standard_False);
+        Handle(AIS_InteractiveObject) ashape =  TheAISContext() -> Current();
+        if(HaveToSet)
+          TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False);
+        else
+          TheAISContext()->UnsetTransparency(ashape,Standard_False);
       }
 
       TheAISContext()->UpdateCurrentViewer();
@@ -1180,15 +1162,14 @@ static int VTransparency  (Draw_Interpretor& di, Standard_Integer argc,
       ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
         it(GetMapOfAIS());
       while ( it.More() ) {
-       Handle(AIS_InteractiveObject) ashape =
+        Handle(AIS_InteractiveObject) ashape =
           Handle(AIS_InteractiveObject)::DownCast(it.Key1());
         if (!ashape.IsNull())
           if(HaveToSet)
-            TheAISContext()->SetTransparency(ashape,atof(argv[1]),
-                                             Standard_False);
+            TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False);
           else
             TheAISContext()->UnsetTransparency(ashape,Standard_False);
-       it.Next();
+        it.Next();
       }
       TheAISContext()->UpdateCurrentViewer();
     }
@@ -1210,19 +1191,14 @@ static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char**
   Standard_Boolean    ThereIsName;
   Standard_Boolean    IsBound = Standard_False ;
 
-  Standard_Boolean    HaveToSet;
-  if (!strcasecmp( argv[0],"vsetmaterial")) HaveToSet=Standard_True;
-  else HaveToSet=Standard_False;
+  const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetmaterial") == 0);
   if (HaveToSet) {
     if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
-    if ( argc == 2 ) {ThereIsName=Standard_False;}
-    else ThereIsName=Standard_True;
+    ThereIsName = (argc != 2);
   }
   else {
     if ( argc>2 ) { di << argv[0] << " syntax error passez au plus un argument" << "\n"; return 1; }
-    if (argc==2) ThereIsName=Standard_True;
-    else ThereIsName=Standard_False;
-
+    ThereIsName = (argc == 2);
   }
 
   if ( !a3DView().IsNull() ) {
@@ -1246,8 +1222,7 @@ static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char**
         Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(name));
       if (!ashape.IsNull())
         if (HaveToSet)
-          TheAISContext()->SetMaterial (ashape,
-                                        GetMaterialFromName (argv[2]) );
+          TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[2]));
         else
           TheAISContext()->UnsetMaterial(ashape);
     }
@@ -1260,12 +1235,11 @@ static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char**
            TheAISContext() -> MoreCurrent() ;
            TheAISContext() ->NextCurrent() )
       {
-       Handle(AIS_InteractiveObject) ashape =  TheAISContext() -> Current();
-       if (HaveToSet)
-         TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),
-                                       Standard_False);
-       else
-         TheAISContext()->UnsetMaterial(ashape,Standard_False);
+        Handle(AIS_InteractiveObject) ashape = TheAISContext()->Current();
+        if (HaveToSet)
+          TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
+        else
+          TheAISContext()->UnsetMaterial(ashape,Standard_False);
       }
       TheAISContext()->UpdateCurrentViewer();
     }
@@ -1278,15 +1252,14 @@ static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char**
       ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
         it(GetMapOfAIS());
       while ( it.More() ) {
-       Handle(AIS_InteractiveObject) ashape =
+        Handle(AIS_InteractiveObject) ashape =
           Handle(AIS_InteractiveObject)::DownCast (it.Key1());
-       if (!ashape.IsNull())
+        if (!ashape.IsNull())
           if (HaveToSet)
-         TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),
-                                       Standard_False );
+            TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
           else
             TheAISContext()->UnsetMaterial(ashape,Standard_False);
-       it.Next();
+        it.Next();
       }
       TheAISContext()->UpdateCurrentViewer();
     }
@@ -1309,18 +1282,14 @@ static int VWidth (Draw_Interpretor& di, Standard_Integer argc, const char** arg
   Standard_Boolean    ThereIsArgument;
   Standard_Boolean    IsBound = Standard_False ;
 
-  Standard_Boolean    HaveToSet;
-  if (!strcasecmp( argv[0],"vsetwidth")) HaveToSet=Standard_True;
-  else HaveToSet=Standard_False;
+  const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetwidth") == 0);
   if (HaveToSet) {
     if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
-    if ( argc == 2 ) {ThereIsArgument=Standard_False;}
-    else ThereIsArgument=Standard_True;
+    ThereIsArgument = (argc != 2);
   }
   else {
     if ( argc>2 ) { di << argv[0] << " syntax error passez au plus 1  argument" << "\n"; return 1; }
-   if (argc==2) ThereIsArgument=Standard_True;
-    else ThereIsArgument=Standard_False;
+    ThereIsArgument = (argc == 2);
   }
   if ( !a3DView().IsNull() ) {
     TCollection_AsciiString name;
@@ -1362,12 +1331,11 @@ static int VWidth (Draw_Interpretor& di, Standard_Integer argc, const char** arg
            TheAISContext() -> MoreCurrent() ;
            TheAISContext() ->NextCurrent() )
       {
-       Handle(AIS_InteractiveObject) ashape =  TheAISContext() -> Current();
-       if (HaveToSet)
-         TheAISContext()->SetWidth(ashape,atof (argv[1]),Standard_False);
-       else
-         TheAISContext()->UnsetWidth (ashape,Standard_False);
-
+        Handle(AIS_InteractiveObject) ashape =  TheAISContext() -> Current();
+        if (HaveToSet)
+          TheAISContext()->SetWidth(ashape,atof(argv[1]),Standard_False);
+        else
+          TheAISContext()->UnsetWidth(ashape,Standard_False);
       }
       TheAISContext()->UpdateCurrentViewer();
     }
@@ -1382,9 +1350,9 @@ static int VWidth (Draw_Interpretor& di, Standard_Integer argc, const char** arg
          Handle(AIS_InteractiveObject)::DownCast (it.Key1());
        if (!ashape.IsNull())
          if (HaveToSet)
-           TheAISContext()->SetWidth(ashape,atof (argv[1]),Standard_False );
+           TheAISContext()->SetWidth(ashape,atof(argv[1]),Standard_False);
          else
-           TheAISContext()->UnsetWidth (ashape,Standard_False);
+           TheAISContext()->UnsetWidth(ashape,Standard_False);
        it.Next();
      }
      TheAISContext()->UpdateCurrentViewer();
@@ -2231,15 +2199,14 @@ static int VAnimation (Draw_Interpretor& di, Standard_Integer argc, const char**
 //purpose  : Sharpen or roughten the quality of the shading
 //Draw arg : vshading ShapeName 0.1->0.00001  1 deg-> 30 deg
 //==============================================================================
-static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv) {
-  Standard_Boolean HaveToSet;
-//  Standard_Real    myDevAngle;
+static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
+{
   Standard_Real    myDevCoef;
   Handle(AIS_InteractiveObject) TheAisIO;
 
   // Verifications
-  if (!strcasecmp(argv[0],"vsetshading") ) HaveToSet=Standard_True;
-  else HaveToSet=Standard_False;
+  const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
+
   if (TheAISContext()->HasOpenedContext())
     TheAISContext()->CloseLocalContext();
 
@@ -2249,23 +2216,17 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
     myDevCoef  =atof(argv[2]);
   }
 
-
   TCollection_AsciiString name=argv[1];
   if (GetMapOfAIS().IsBound2(name ))
-    TheAisIO =
-      Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
+    TheAisIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
   if (TheAisIO.IsNull())
     TheAisIO=GetAISShapeFromName((const char *)name.ToCString());
 
-  if (HaveToSet) {
+  if (HaveToSet)
     TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
-  }
-
-  else {
+  else
     TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True);
 
-  }
-
   TheAISContext()->Redisplay(TheAisIO);
   return 0;
 }
@@ -2304,39 +2265,32 @@ Standard_Boolean  HaveMode(const Handle(AIS_InteractiveObject)& TheAisIO,const S
 static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
 
 {
-  Standard_Boolean HaveToSet;
   Standard_Boolean ThereIsName = Standard_False ;
 
   if(!a3DView().IsNull()){
 
-    if (!strcasecmp(argv[0],"vsetam")) HaveToSet=Standard_True;
-    else HaveToSet=Standard_False;
-
+    const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0);
     // verification des arguments
     if (HaveToSet) {
       if (argc<2||argc>3) { di<<" Syntaxe error"<<"\n";return 1;}
-      if (argc==3) ThereIsName=Standard_True;
-      else ThereIsName=Standard_False;
+      ThereIsName = (argc == 3);
     }
     else {
       // vunsetam
       if (argc>1) {di<<" Syntaxe error"<<"\n";return 1;}
       else {
-       di<<" R.A.Z de tous les modes de selecion"<<"\n";
-       di<<" Fermeture du Context local"<<"\n";
+        di<<" R.A.Z de tous les modes de selecion"<<"\n";
+        di<<" Fermeture du Context local"<<"\n";
         if (TheAISContext()->HasOpenedContext())
           TheAISContext()->CloseLocalContext();
       }
-
     }
 
-
     // IL n'y a aps de nom de shape passe en argument
     if (HaveToSet && !ThereIsName){
       Standard_Integer aMode=atoi(argv [1]);
 
       const char *cmode="???";
-
       switch (aMode) {
       case 0: cmode = "Shape"; break;
       case 1: cmode = "Vertex"; break;
@@ -2349,17 +2303,16 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
       }
 
       if( !TheAISContext()->HasOpenedContext() ) {
-       // il n'y a pas de Context local d'ouvert
-       // on en ouvre un et on charge toutes les shapes displayees
-       // on load tous les objets displayees et on Activate les objets de la liste
-       AIS_ListOfInteractive ListOfIO;
-       // on sauve dans une AISListOfInteractive tous les objets currents
-       if (TheAISContext()->NbCurrents()>0 ){
-         TheAISContext()->UnhilightCurrents(Standard_False);
-
-         for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){
-           ListOfIO.Append(TheAISContext()->Current() );
-
+        // il n'y a pas de Context local d'ouvert
+        // on en ouvre un et on charge toutes les shapes displayees
+        // on load tous les objets displayees et on Activate les objets de la liste
+        AIS_ListOfInteractive ListOfIO;
+        // on sauve dans une AISListOfInteractive tous les objets currents
+        if (TheAISContext()->NbCurrents()>0 ){
+          TheAISContext()->UnhilightCurrents(Standard_False);
+
+          for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){
+            ListOfIO.Append(TheAISContext()->Current() );
          }
        }
 
@@ -2543,20 +2496,14 @@ void WhoAmI (const Handle(AIS_InteractiveObject )& theShape ,Draw_Interpretor& d
 //==============================================================================
 static int VState(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
 {
-  Standard_Boolean ThereIsCurrent=Standard_False;
-  Standard_Boolean ThereIsArguments=Standard_False;
   TheAISContext()->CloseAllContexts();
-  if (argc>=2 ) {
-    ThereIsArguments=Standard_True;
-  }
-  if (TheAISContext()->NbCurrents()>0 ) {
-    ThereIsCurrent=Standard_True;
-  }
+  const Standard_Boolean ThereIsArguments=(argc>=2);
+  const Standard_Boolean ThereIsCurrent=(TheAISContext()->NbCurrents()>0);
   // Debut...
   // ==================
   // Il y a un argument
   // ==================
-  if (ThereIsArguments ) {
+  if (ThereIsArguments) {
     for (int cpt=1;cpt<argc;cpt++) {
       // Verification que lq piece est bien bindee.
       if (GetMapOfAIS().IsBound2(argv[cpt]) ) {
index ac5db8e..2d0a93a 100755 (executable)
@@ -1,8 +1,7 @@
--- File:       XCAFPrs.cdl
--- Created:    Fri Aug 11 16:28:46 2000
--- Author:     Andrey BETENEV
---             <abv@doomox.nnov.matra-dtv.fr>
----Copyright:   Matra Datavision 2000
+-- File:         XCAFPrs.cdl
+-- Created:      Fri Aug 11 16:28:46 2000
+-- Author:       Andrey BETENEV
+---Copyright: Matra Datavision 2000
 
 
 package XCAFPrs 
@@ -17,6 +16,7 @@ uses
     TopLoc,
     TopoDS,
     TopTools,
+    Graphic3d,
     Prs3d,
     PrsMgr,
     TPrsStd,
index 6bcefb2..791a116 100755 (executable)
@@ -1,8 +1,7 @@
--- File:       XCAFPrs_AISObject.cdl
--- Created:    Fri Aug 11 16:37:11 2000
--- Author:     Andrey BETENEV
---             <abv@doomox.nnov.matra-dtv.fr>
----Copyright:   Matra Datavision 2000
+-- File:         XCAFPrs_AISObject.cdl
+-- Created:      Fri Aug 11 16:37:11 2000
+-- Author:       Andrey BETENEV
+---Copyright: Matra Datavision 2000
 
 
 class AISObject from XCAFPrs inherits Shape from AIS
@@ -15,6 +14,9 @@ uses
     PresentationManager3d from PrsMgr,
     Presentation from Prs3d,
     Label from TDF,
+    Color from Quantity,
+    NameOfMaterial from Graphic3d,
+    MaterialAspect from Graphic3d,
     Style from XCAFPrs
     
 is
@@ -22,6 +24,20 @@ is
     Create (lab: Label from TDF);
        ---Purpose: Creates an object to visualise the shape label
 
+    SetColor(me:mutable;aColor:Color from Quantity) is redefined virtual;
+
+    UnsetColor(me:mutable) is redefined virtual;
+        
+    SetMaterial(me:mutable;aName:NameOfMaterial from Graphic3d) is redefined virtual;
+
+    SetMaterial(me:mutable;aName:MaterialAspect from Graphic3d) is redefined virtual;
+        
+    UnsetMaterial(me:mutable) is redefined virtual;
+        
+    SetTransparency(me:mutable;aValue : Real from Standard=0.6) is redefined virtual;  
+    
+    UnsetTransparency(me:mutable) is redefined virtual;
     AddStyledItem (me: mutable; style: Style from XCAFPrs;
                    shape: Shape from TopoDS;
                    aPresentationManager : PresentationManager3d from PrsMgr;
index 99e100f..dd46138 100755 (executable)
@@ -1,7 +1,6 @@
 // File:       XCAFPrs_AISObject.cxx
 // Created:    Fri Aug 11 16:49:09 2000
 // Author:     Andrey BETENEV
-//             <abv@doomox.nnov.matra-dtv.fr>
 
 #include <XCAFPrs_AISObject.ixx>
 #include <TCollection_ExtendedString.hxx>
@@ -70,13 +69,104 @@ XCAFPrs_AISObject::XCAFPrs_AISObject (const TDF_Label &lab) : AIS_Shape(TopoDS_S
 }
 
 //=======================================================================
-//function : Compute
+//function : SetColor
+//purpose  : 
+//=======================================================================
+
+void XCAFPrs_AISObject::SetColor(const Quantity_Color &aCol)
+{
+  AIS_Shape::SetColor(aCol);
+  LoadRecomputable(1);
+}
+
+//=======================================================================
+//function : UnsetColor
+//purpose  : 
+//=======================================================================
+
+void XCAFPrs_AISObject::UnsetColor()
+{
+  if (HasColor())
+  {
+    AIS_Shape::UnsetColor();
+    LoadRecomputable(1);
+  }
+  else
+  {
+    myToRecomputeModes.Clear();
+  }
+}
+
+//=======================================================================
+//function : SetMaterial
+//purpose  : 
+//=======================================================================
+
+void XCAFPrs_AISObject::SetMaterial(const Graphic3d_NameOfMaterial aMat)
+{
+  AIS_Shape::SetMaterial(aMat);
+  LoadRecomputable(1);
+}
+
+//=======================================================================
+//function : SetMaterial
 //purpose  : 
 //=======================================================================
 
-void DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
-                      const Bnd_Box& B,
-                      const Handle(Prs3d_Drawer)& aDrawer)
+void XCAFPrs_AISObject::SetMaterial(const Graphic3d_MaterialAspect& aMat)
+{
+  AIS_Shape::SetMaterial(aMat);
+  LoadRecomputable(1);
+}
+
+//=======================================================================
+//function : UnsetMaterial
+//purpose  : 
+//=======================================================================
+
+void XCAFPrs_AISObject::UnsetMaterial()
+{
+  if (HasMaterial())
+  {
+    AIS_Shape::UnsetMaterial();
+    LoadRecomputable(1);
+  }
+  else
+  {
+    myToRecomputeModes.Clear();
+  }
+}
+
+//=======================================================================
+//function : SetTransparency
+//purpose  : 
+//=======================================================================
+
+void XCAFPrs_AISObject::SetTransparency(const Standard_Real AValue)
+{
+  AIS_Shape::SetTransparency(AValue);
+  LoadRecomputable(1);
+}
+
+//=======================================================================
+//function : UnsetTransparency
+//purpose  : 
+//=======================================================================
+
+void XCAFPrs_AISObject::UnsetTransparency()
+{
+  AIS_Shape::UnsetTransparency();
+  LoadRecomputable(1);
+}
+
+//=======================================================================
+//function : DisplayBox
+//purpose  : 
+//=======================================================================
+
+static void DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
+                       const Bnd_Box& B,
+                       const Handle(Prs3d_Drawer)& aDrawer)
 {
   Standard_Real X[2],Y[2],Z[2];
   Standard_Integer Indx [16] ;
@@ -125,6 +215,11 @@ void DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
   G->EndPrimitives();
 }
 
+//=======================================================================
+//function : AddStyledItem
+//purpose  : 
+//=======================================================================
+
 void XCAFPrs_AISObject::AddStyledItem (const XCAFPrs_Style &style, 
                                        const TopoDS_Shape &shape, 
                                        const Handle(PrsMgr_PresentationManager3d)&, // aPresentationManager,
@@ -327,7 +422,6 @@ static void DisplayText (const TDF_Label& aLabel,
       }
     }
   }
-  
 }
                         
 //=======================================================================
@@ -338,21 +432,18 @@ static void DisplayText (const TDF_Label& aLabel,
 // support different color settings for different subshapes of a single shape
   
 void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
-                                const Handle(Prs3d_Presentation)& aPrs,
-                                const Standard_Integer aMode)
+                                 const Handle(Prs3d_Presentation)& aPrs,
+                                 const Standard_Integer aMode)
 {  
 #ifdef DEB
-  cout << "XCAFPrs_AISObject: Update called" << endl;
+  //cout << "XCAFPrs_AISObject: Update called" << endl;
 #endif
   aPrs->Clear();
 
   // abv: 06 Mar 00: to have good colors
   Handle(TPrsStd_AISPresentation) prs = Handle(TPrsStd_AISPresentation)::DownCast ( GetOwner() );
-  Graphic3d_NameOfMaterial material = ( prs.IsNull() ? Graphic3d_NOM_PLASTIC : prs->Material() );
-//  Graphic3d_NameOfMaterial material = Material();
-  SetMaterial ( material );
-  
-//  SetMaterial ( Graphic3d_NOM_PLASTIC );
+  if ( prs.IsNull() || !prs->HasOwnMaterial() )
+    AIS_Shape::SetMaterial ( Graphic3d_NOM_PLASTIC );
 
   TopoDS_Shape shape;
   if ( ! XCAFDoc_ShapeTool::GetShape ( myLabel, shape ) || shape.IsNull() ) return;
@@ -377,7 +468,7 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr
   XCAFPrs_DataMapOfShapeStyle settings;
   XCAFPrs::CollectStyleSettings ( myLabel, L, settings );
 #ifdef DEB
-  cout << "Styles collected" << endl;
+  //cout << "Styles collected" << endl;
 #endif
 
   // dispatch (sub)shapes by their styles
@@ -388,32 +479,22 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr
   DefStyle.SetColorCurv ( White );
   XCAFPrs::DispatchStyles ( shape, settings, items, DefStyle );
 #ifdef DEB
-  cout << "Dispatch done" << endl;
+  //cout << "Dispatch done" << endl;
 #endif
 
   // add subshapes to presentation (one shape per style)
   XCAFPrs_DataMapIteratorOfDataMapOfStyleShape it ( items );
 #ifdef DEB
-  Standard_Integer i=1;
+  //Standard_Integer i=1;
 #endif
   for ( ; it.More(); it.Next() ) {
     XCAFPrs_Style s = it.Key();
 #ifdef DEB
-    cout << "Style " << i << ": [" << 
-      ( s.IsSetColorSurf() ? Quantity_Color::StringName ( s.GetColorSurf().Name() ) : "" ) << ", " <<
-      ( s.IsSetColorCurv() ? Quantity_Color::StringName ( s.GetColorCurv().Name() ) : "" ) << "]" <<
-       " --> si_" << i << ( s.IsVisible() ? "" : " <invisible>" ) << endl;
-#ifdef DEBUG
-    char str[200];
-    sprintf ( str, "si_%d", i );
-    DBRep::Set ( str, it.Value() );
-    try { OCC_CATCH_SIGNALS  ; } // to handle all till the end of for
-    catch (Standard_Failure) {
-      cout << "Exception in AddStyledItem!" << endl;
-      continue;
-    }
-#endif
-    i++;
+    //cout << "Style " << i << ": [" << 
+    //  ( s.IsSetColorSurf() ? Quantity_Color::StringName ( s.GetColorSurf().Name() ) : "" ) << ", " <<
+    //  ( s.IsSetColorCurv() ? Quantity_Color::StringName ( s.GetColorCurv().Name() ) : "" ) << "]" <<
+       //" --> si_" << i << ( s.IsVisible() ? "" : " <invisible>" ) << endl;
+    //i++;
 #endif
     if (! s.IsVisible() ) continue;
     AddStyledItem ( s, it.Value(), aPresentationManager, aPrs, aMode );
@@ -422,13 +503,13 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr
   if ( XCAFPrs::GetViewNameMode() ) {
   // Displaying Name attributes
 #ifdef DEB
-    cout << "Now display name of shapes" << endl;
+    //cout << "Now display name of shapes" << endl;
 #endif
     aPrs->SetDisplayPriority(10);
     DisplayText (myLabel, aPrs, Attributes()->LengthAspect()->TextAspect(), TopLoc_Location());//no location
   }
 #ifdef DEB
-  cout << "Compute finished" << endl;
+  //cout << "Compute finished" << endl;
 #endif
   
   aPrs->ReCompute(); // for hidden line recomputation if necessary...
index d480b01..f46d2f1 100755 (executable)
@@ -1,8 +1,6 @@
 // File:       XDEDRAW.cxx
 // Created:    Fri Aug  4 14:38:55 2000
 // Author:     Pavel TELKOV
-//             <ptv@zamox.nnov.matra-dtv.fr>
-
 
 #include <XDEDRAW.ixx>
 #include <stdio.h>
@@ -731,6 +729,55 @@ static Standard_Integer getviewName (Draw_Interpretor&  di, Standard_Integer /*a
 }
 
 
+//=======================================================================
+//function : XSetTransparency
+//purpose  :
+//=======================================================================
+static Standard_Integer XSetTransparency (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  if (argc < 3) {
+    di<<"Use: "<<argv[0]<<" Doc Transparency [label1 label2 ...] "<<"\n";
+    return 1;
+  }
+
+  Handle(TDocStd_Document) Doc;
+  DDocStd::GetDocument(argv[1], Doc);
+  if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
+
+  const Standard_Real aTransparency = atof(argv[2]);
+
+  // collect sequence of labels
+  Handle(XCAFDoc_ShapeTool) shapes = XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
+  TDF_LabelSequence seq;
+  if ( argc > 3 ) {
+    for ( Standard_Integer i=3; i < argc; i++ ) {
+      TDF_Label aLabel;
+      TDF_Tool::Label(Doc->GetData(), argv[i], aLabel);
+      if ( aLabel.IsNull() || ! shapes->IsShape ( aLabel ) ) {
+        di << argv[i] << " is not a valid shape label!";
+        continue;
+      }
+      seq.Append ( aLabel );
+    }
+  }
+  else {
+    shapes->GetFreeShapes ( seq );
+  }
+
+  // find presentations and set transparency
+  for ( Standard_Integer i=1; i <= seq.Length(); i++ ) {
+    Handle(TPrsStd_AISPresentation) prs;
+    if ( ! seq.Value(i).FindAttribute ( TPrsStd_AISPresentation::GetID(), prs ) ) {
+      prs = TPrsStd_AISPresentation::Set(seq.Value(i),XCAFPrs_Driver::GetID());
+      prs->SetMaterial ( Graphic3d_NOM_PLASTIC );
+    }
+    prs->SetTransparency( aTransparency );
+  }
+  TPrsStd_AISViewer::Update(Doc->GetData()->Root());
+  return 0;
+}
+
+
 //=======================================================================
 //function : Init
 //purpose  :
@@ -792,6 +839,9 @@ void XDEDRAW::Init(Draw_Interpretor& di)
   di.Add ("XGetViewNameMode", "\t: Print if  mode of displaying names is turn on.",
                   __FILE__, getviewName, g);
 
+  di.Add ("XSetTransparency", "Doc Transparency [label1 label2 ...]\t: Set transparency for given label(s) or whole doc",
+                  __FILE__, XSetTransparency, g);
+
   // Specialized commands
   XDEDRAW_Shapes::InitCommands ( di );
   XDEDRAW_Colors::InitCommands ( di );