1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0022776: XCAFPrs_AISObject does not support transparency

This commit is contained in:
SZV 2012-01-27 13:34:50 +00:00 committed by bugmaster
parent c7c00e81bc
commit 5cbef0feb7
7 changed files with 351 additions and 306 deletions

View File

@ -1,7 +1,6 @@
-- File: AIS_Shape.cdl -- File: AIS_Shape.cdl
-- Created: Fri Dec 20 15:18:05 1996 -- Created: Fri Dec 20 15:18:05 1996
-- Author: Robert COUBLANC -- Author: Robert COUBLANC
-- <rob@robox.paris1.matra-dtv.fr>
-- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead -- GG : GER61351 17/11/1999 Change SetColor() with a compatible Quantity_Color instead
-- the restricted NameOfColor. -- the restricted NameOfColor.
-- Redefines the Color(),Material(),Transparency() methods -- Redefines the Color(),Material(),Transparency() methods
@ -272,7 +271,7 @@ uses
-- - mode 7 - Compsolid -- - mode 7 - Compsolid
-- - mode 8 - Compound -- - 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; Compute(me : mutable;
aProjector : Projector from Prs3d; aProjector : Projector from Prs3d;

View File

@ -1,7 +1,6 @@
// File: AIS_Shape.cxx // File: AIS_Shape.cxx
// Created: Fri Dec 20 17:18:37 1996 // Created: Fri Dec 20 17:18:37 1996
// Author: Robert COUBLANC // Author: Robert COUBLANC
// <rob@robox.paris1.matra-dtv.fr>
#define BUC60577 //GG_191099 Draw correct bounding box and Menage ... #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) void AIS_Shape::SetColor(const Quantity_NameOfColor aCol)
#ifdef GER61351
{ {
SetColor(Quantity_Color(aCol)); SetColor(Quantity_Color(aCol));
} }
//=======================================================================
//function : SetColor
//purpose :
//=======================================================================
void AIS_Shape::SetColor(const Quantity_Color &aCol) void AIS_Shape::SetColor(const Quantity_Color &aCol)
#endif
{ {
hasOwnColor = Standard_True;
#ifdef GER61351
if( !HasColor() && !IsTransparent() && !HasMaterial() ) { if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
} }
#else hasOwnColor = Standard_True;
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
#ifdef GER61351
myDrawer->ShadingAspect()->SetColor(aCol,myCurrentFacingModel); myDrawer->ShadingAspect()->SetColor(aCol,myCurrentFacingModel);
#else myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
myDrawer->ShadingAspect()->SetColor(aCol);
#endif
myDrawer->SetShadingAspectGlobal(Standard_False); 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->SetLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
myDrawer->SetWireAspect(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(0);
LoadRecomputable(2); LoadRecomputable(2);
} }
//======================================================================= //=======================================================================
//function : UnsetColor //function : UnsetColor
//purpose : //purpose :
@ -616,23 +599,24 @@ void AIS_Shape::SetColor(const Quantity_Color &aCol)
void AIS_Shape::UnsetColor() void AIS_Shape::UnsetColor()
{ {
if(!HasColor() ){ myToRecomputeModes.Clear(); if ( !HasColor() )
return;} {
myToRecomputeModes.Clear();
return;
}
hasOwnColor = Standard_False; hasOwnColor = Standard_False;
Handle(Prs3d_LineAspect) NullAsp; Handle(Prs3d_LineAspect) NullAsp;
Handle(Prs3d_ShadingAspect) NullShA; Handle(Prs3d_ShadingAspect) NullShA;
if(!HasWidth()){ if(!HasWidth()) {
myDrawer->SetLineAspect(NullAsp); myDrawer->SetLineAspect(NullAsp);
myDrawer->SetWireAspect(NullAsp); myDrawer->SetWireAspect(NullAsp);
myDrawer->SetFreeBoundaryAspect(NullAsp); myDrawer->SetFreeBoundaryAspect(NullAsp);
myDrawer->SetUnFreeBoundaryAspect(NullAsp); myDrawer->SetUnFreeBoundaryAspect(NullAsp);
myDrawer->SetSeenLineAspect(NullAsp); myDrawer->SetSeenLineAspect(NullAsp);
} }
else{ else {
#ifdef GER61351
Quantity_Color CC; Quantity_Color CC;
AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
myDrawer->LineAspect()->SetColor(CC); myDrawer->LineAspect()->SetColor(CC);
@ -644,43 +628,37 @@ void AIS_Shape::UnsetColor()
myDrawer->UnFreeBoundaryAspect()->SetColor(CC); myDrawer->UnFreeBoundaryAspect()->SetColor(CC);
AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC); AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC);
myDrawer->SeenLineAspect()->SetColor(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); myDrawer->SetShadingAspect(NullShA);
} }
if(!GetContext().IsNull()){ if(!GetContext().IsNull()){
if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
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
P->SetPrimitivesAspect(a4bis); P->SetPrimitivesAspect(a4bis);
G->SetGroupPrimitivesAspect(a4bis); G->SetGroupPrimitivesAspect(a4bis);
} }
} }
LoadRecomputable(0); LoadRecomputable(0);
LoadRecomputable(2); LoadRecomputable(2);
} }
//======================================================================= //=======================================================================
//function : SetWidth //function : SetWidth
//purpose : //purpose :
@ -688,7 +666,7 @@ void AIS_Shape::UnsetColor()
void AIS_Shape::SetWidth(const Standard_Real W) void AIS_Shape::SetWidth(const Standard_Real W)
{ {
if(HasColor() || HasWidth()){ if(HasColor() || HasWidth()){
myDrawer->LineAspect()->SetWidth(W); myDrawer->LineAspect()->SetWidth(W);
myDrawer->WireAspect()->SetWidth(W); myDrawer->WireAspect()->SetWidth(W);
myDrawer->FreeBoundaryAspect()->SetWidth(W); myDrawer->FreeBoundaryAspect()->SetWidth(W);
@ -696,7 +674,6 @@ void AIS_Shape::SetWidth(const Standard_Real W)
myDrawer->SeenLineAspect()->SetWidth(W); myDrawer->SeenLineAspect()->SetWidth(W);
} }
else{ else{
#ifdef GER61351
Quantity_Color CC; Quantity_Color CC;
AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
myDrawer->SetLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W)); 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)); myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC); AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC);
myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W)); 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; myOwnWidth = W;
LoadRecomputable(0); // means that it is necessary to recompute only the wireframe.... LoadRecomputable(0); // means that it is necessary to recompute only the wireframe....
LoadRecomputable(2); // and the bounding box... LoadRecomputable(2); // and the bounding box...
} }
//======================================================================= //=======================================================================
@ -738,11 +698,15 @@ void AIS_Shape::SetWidth(const Standard_Real W)
void AIS_Shape::UnsetWidth() void AIS_Shape::UnsetWidth()
{ {
if(myOwnWidth== 0.0){ myToRecomputeModes.Clear(); if(myOwnWidth == 0.0)
return;} {
myToRecomputeModes.Clear();
return;
}
myOwnWidth=0.0; myOwnWidth=0.0;
Handle(Prs3d_LineAspect) NullAsp; Handle(Prs3d_LineAspect) NullAsp;
if(!HasColor()){ if(!HasColor()){
myDrawer->SetLineAspect(NullAsp); myDrawer->SetLineAspect(NullAsp);
myDrawer->SetWireAspect(NullAsp); myDrawer->SetWireAspect(NullAsp);
@ -760,60 +724,58 @@ void AIS_Shape::UnsetWidth()
LoadRecomputable(0); LoadRecomputable(0);
} }
//======================================================================= //=======================================================================
//function : SetMaterial //function : SetMaterial
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat) void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
{ {
#ifdef GER61351
if( !HasColor() && !IsTransparent() && !HasMaterial() ) { if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
} }
myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
hasOwnMaterial = Standard_True; hasOwnMaterial = Standard_True;
#else
AIS_InteractiveObject::SetMaterial(aMat); myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
#endif myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
if(!GetContext().IsNull()){ if(!GetContext().IsNull()){
if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
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);
} }
} }
myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear(); myToRecomputeModes.Clear();
} }
//======================================================================= //=======================================================================
//function : SetMaterial //function : SetMaterial
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat) void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat)
{ {
#ifdef GER61351
if( !HasColor() && !IsTransparent() && !HasMaterial() ) { if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
} }
myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
hasOwnMaterial = Standard_True; hasOwnMaterial = Standard_True;
#else
AIS_InteractiveObject::SetMaterial(aMat); myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
#endif myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
if(!GetContext().IsNull()){ if(!GetContext().IsNull()){
if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
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); }
} }
}
myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear(); myToRecomputeModes.Clear();
} }
@ -822,10 +784,11 @@ void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat)
//function : UnsetMaterial //function : UnsetMaterial
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_Shape::UnsetMaterial() void AIS_Shape::UnsetMaterial()
{ {
#ifdef GER61351
if( !HasMaterial() ) return; if( !HasMaterial() ) return;
if( HasColor() || IsTransparent()) { if( HasColor() || IsTransparent()) {
Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link()); Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link());
if( HasColor() ) { if( HasColor() ) {
@ -842,15 +805,11 @@ void AIS_Shape::UnsetMaterial()
myDrawer->SetShadingAspect(SA); myDrawer->SetShadingAspect(SA);
} }
hasOwnMaterial = Standard_False; hasOwnMaterial = Standard_False;
#else
AIS_InteractiveObject::UnsetMaterial();
#endif
if(!GetContext().IsNull()){
if(!GetContext().IsNull()){
if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
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);
@ -858,8 +817,8 @@ void AIS_Shape::UnsetMaterial()
} }
myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear(); myToRecomputeModes.Clear();
} }
//======================================================================= //=======================================================================
//function : SetTransparency //function : SetTransparency
//purpose : //purpose :
@ -867,20 +826,16 @@ void AIS_Shape::UnsetMaterial()
void AIS_Shape::SetTransparency(const Standard_Real AValue) void AIS_Shape::SetTransparency(const Standard_Real AValue)
{ {
#ifdef GER61351 if ( !HasColor() && !HasMaterial() ) {
if(!HasColor() && !HasMaterial() ) { myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
} }
myDrawer->ShadingAspect()->SetTransparency(AValue,myCurrentFacingModel); myDrawer->ShadingAspect()->SetTransparency(AValue,myCurrentFacingModel);
myTransparency = AValue; myTransparency = AValue;
#else
AIS_InteractiveObject::SetTransparency(AValue);
#endif
if(!GetContext().IsNull()){ if(!GetContext().IsNull()){
if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
P->SetPrimitivesAspect(a4bis); P->SetPrimitivesAspect(a4bis);
#ifdef BUC60918 //force highest priority for transparent objects #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 myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear(); myToRecomputeModes.Clear();
} }
//======================================================================= //=======================================================================
//function : UnsetTransparency //function : UnsetTransparency
//purpose : //purpose :
//======================================================================= //=======================================================================
void AIS_Shape::UnsetTransparency() void AIS_Shape::UnsetTransparency()
{ {
#ifdef GER61351 if( HasColor() || HasMaterial() ) {
if(HasColor() || HasMaterial() ) {
myDrawer->ShadingAspect()->SetTransparency(0.0,myCurrentFacingModel); myDrawer->ShadingAspect()->SetTransparency(0.0,myCurrentFacingModel);
} else { } else {
Handle(Prs3d_ShadingAspect) SA; Handle(Prs3d_ShadingAspect) SA;
myDrawer->SetShadingAspect(SA); myDrawer->SetShadingAspect(SA);
} }
myTransparency = 0.0; myTransparency = 0.0;
#else
AIS_InteractiveObject::UnsetTransparency();
#endif
if(!GetContext().IsNull()){ if(!GetContext().IsNull()){
if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
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);
@ -926,19 +876,21 @@ void AIS_Shape::UnsetTransparency()
} }
} }
myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update 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) void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
{ {
myRecomputeEveryPrs =Standard_False; myRecomputeEveryPrs = Standard_False;
if(!IsInList(myToRecomputeModes,TheMode)) if(!IsInList(myToRecomputeModes,TheMode))
myToRecomputeModes.Append(TheMode); myToRecomputeModes.Append(TheMode);
} }
//======================================================================= //=======================================================================
//function : BoundingBox //function : BoundingBox
//purpose : //purpose :

View File

@ -1,7 +1,6 @@
// File: ViewerTest.cxx // File: ViewerTest.cxx
// Created: Wed Jul 23 14:14:01 1997 // Created: Wed Jul 23 14:14:01 1997
// Author: Henri JEANNIN // Author: Henri JEANNIN
// <bbl@entrax.paris3.matra-dtv.fr>
// Modified by Eric Gouthiere [sep-oct 98] -> add commands for display... // Modified by Eric Gouthiere [sep-oct 98] -> add commands for display...
// //
// Modified by Robert Coublanc [nov 16-17-18 1998] // 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 ThereIsCurrent;
Standard_Boolean ThereIsArgument; Standard_Boolean ThereIsArgument;
Standard_Boolean IsBound = Standard_False ; Standard_Boolean IsBound = Standard_False ;
Standard_Boolean HaveToSet;
if (!strcasecmp( argv[0],"vsetcolor")) HaveToSet=Standard_True; const Standard_Boolean HaveToSet=(strcasecmp( argv[0],"vsetcolor") == 0);
else HaveToSet=Standard_False;
if (HaveToSet) { if (HaveToSet) {
if ( argc<2 || argc > 3 ) { di << argv[0] << " syntax error: Passez 2 ou 3 arguments" << "\n"; return 1; } if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error: Give 2 or 3 arguments" << "\n"; return 1; }
if ( argc == 2 ) {ThereIsArgument=Standard_False;} ThereIsArgument = (argc != 2);
else ThereIsArgument=Standard_True;
} }
else { else {
if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; } if ( argc > 2 ) { di << argv[0] << " syntax error: Given too many arguments" << "\n"; return 1; }
if(argc==2) ThereIsArgument=Standard_True; ThereIsArgument = (argc == 2);
else ThereIsArgument=Standard_False;
} }
if ( !a3DView().IsNull() ) { 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) ashape =
Handle(AIS_InteractiveObject)::DownCast (anObj); Handle(AIS_InteractiveObject)::DownCast (anObj);
#ifdef DEB #ifdef DEB
//cout << "HaveToSet "<<HaveToSet <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << endl;
if (HaveToSet) if (HaveToSet)
di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n"; di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
else else
di << "HaveToSet "<< "0" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n"; di << "HaveToSet 0\n";
#endif #endif
if(HaveToSet) { if(HaveToSet)
TheAISContext()->SetColor(ashape,GetColorFromName(argv[2]) ); TheAISContext()->SetColor(ashape,GetColorFromName(argv[2]) );
}
else else
TheAISContext()->UnsetColor(ashape); TheAISContext()->UnsetColor(ashape);
} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) { } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
Handle(NIS_Triangulated) ashape = Handle(NIS_Triangulated) ashape =
Handle(NIS_Triangulated)::DownCast (anObj); Handle(NIS_Triangulated)::DownCast (anObj);
if (ashape.IsNull() == Standard_False) if (!ashape.IsNull())
ashape->SetColor (GetColorFromName(argv[2])); ashape->SetColor (GetColorFromName(argv[2]));
} }
} }
@ -1048,20 +1040,19 @@ static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** ar
TheAISContext() -> MoreCurrent() ; TheAISContext() -> MoreCurrent() ;
TheAISContext() ->NextCurrent() ) TheAISContext() ->NextCurrent() )
{ {
const Handle(AIS_InteractiveObject) ashape= TheAISContext()->Current(); const Handle(AIS_InteractiveObject) ashape= TheAISContext()->Current();
if (ashape.IsNull()) if (ashape.IsNull())
continue; continue;
#ifdef DEB #ifdef DEB
//cout << "HaveToSet "<<HaveToSet <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << endl; if (HaveToSet)
if (HaveToSet) di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
di << "HaveToSet "<< "1" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n"; else
else di << "HaveToSet 0\n";
di << "HaveToSet "<< "0" <<" Color Given "<< argv[2] << " Color returned "<< GetColorFromName(argv[2]) << "\n";
#endif #endif
if(HaveToSet) if(HaveToSet)
TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),Standard_False); TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),Standard_False);
else else
TheAISContext()->UnsetColor(ashape,Standard_False); TheAISContext()->UnsetColor(ashape,Standard_False);
} }
TheAISContext()->UpdateCurrentViewer(); TheAISContext()->UpdateCurrentViewer();
@ -1074,15 +1065,14 @@ static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** ar
else if (!ThereIsCurrent && !ThereIsArgument){ else if (!ThereIsCurrent && !ThereIsArgument){
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS()); ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName it(GetMapOfAIS());
while ( it.More() ) { while ( it.More() ) {
const Handle(AIS_InteractiveObject) ashape = const Handle(AIS_InteractiveObject) ashape =
Handle(AIS_InteractiveObject)::DownCast(it.Key1()); Handle(AIS_InteractiveObject)::DownCast(it.Key1());
if (!ashape.IsNull()) if (!ashape.IsNull())
if(HaveToSet) if(HaveToSet)
TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]), TheAISContext()->SetColor(ashape,GetColorFromName(argv[1]),Standard_False);
Standard_False);
else else
TheAISContext()->UnsetColor(ashape,Standard_False); TheAISContext()->UnsetColor(ashape,Standard_False);
it.Next(); it.Next();
} }
TheAISContext()->UpdateCurrentViewer(); TheAISContext()->UpdateCurrentViewer();
} }
@ -1097,28 +1087,21 @@ static int VColor2 (Draw_Interpretor& di, Standard_Integer argc, const char** ar
//Draw arg : vtransparency [name] TransparencyCoeficient //Draw arg : vtransparency [name] TransparencyCoeficient
//============================================================================== //==============================================================================
static int VTransparency (Draw_Interpretor& di, Standard_Integer argc, static int VTransparency (Draw_Interpretor& di, Standard_Integer argc,
const char** argv) const char** argv)
{ {
Standard_Boolean ThereIsCurrent; Standard_Boolean ThereIsCurrent;
Standard_Boolean ThereIsArgument; Standard_Boolean ThereIsArgument;
Standard_Boolean IsBound = Standard_False ; 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 (HaveToSet) {
if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; } if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
if ( argc == 2 ) {ThereIsArgument=Standard_False;} ThereIsArgument = (argc != 2);
else ThereIsArgument=Standard_True;
} }
else{ else{
if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; } if ( argc > 2 ) { di << argv[0] << " syntax error: Passez au plus un argument" << "\n"; return 1; }
if(argc==2) ThereIsArgument=Standard_True; ThereIsArgument = (argc == 2);
else ThereIsArgument=Standard_False;
} }
if ( !a3DView().IsNull() ) { if ( !a3DView().IsNull() ) {
@ -1145,7 +1128,7 @@ static int VTransparency (Draw_Interpretor& di, Standard_Integer argc,
TheAISContext()->SetTransparency(ashape,atof(argv[2]) ); TheAISContext()->SetTransparency(ashape,atof(argv[2]) );
else else
TheAISContext()->UnsetTransparency(ashape); TheAISContext()->UnsetTransparency(ashape);
} else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) { } else if (anObj->IsKind(STANDARD_TYPE(NIS_InteractiveObject))) {
const Handle(NIS_InteractiveObject) ashape = const Handle(NIS_InteractiveObject) ashape =
Handle(NIS_InteractiveObject)::DownCast(anObj); Handle(NIS_InteractiveObject)::DownCast(anObj);
if(HaveToSet) if(HaveToSet)
@ -1163,12 +1146,11 @@ static int VTransparency (Draw_Interpretor& di, Standard_Integer argc,
TheAISContext() -> MoreCurrent() ; TheAISContext() -> MoreCurrent() ;
TheAISContext() ->NextCurrent() ) TheAISContext() ->NextCurrent() )
{ {
Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current(); Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
if(HaveToSet) { if(HaveToSet)
TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False); TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False);
} else
else TheAISContext()->UnsetTransparency(ashape,Standard_False);
TheAISContext()->UnsetTransparency(ashape,Standard_False);
} }
TheAISContext()->UpdateCurrentViewer(); TheAISContext()->UpdateCurrentViewer();
@ -1180,15 +1162,14 @@ static int VTransparency (Draw_Interpretor& di, Standard_Integer argc,
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
it(GetMapOfAIS()); it(GetMapOfAIS());
while ( it.More() ) { while ( it.More() ) {
Handle(AIS_InteractiveObject) ashape = Handle(AIS_InteractiveObject) ashape =
Handle(AIS_InteractiveObject)::DownCast(it.Key1()); Handle(AIS_InteractiveObject)::DownCast(it.Key1());
if (!ashape.IsNull()) if (!ashape.IsNull())
if(HaveToSet) if(HaveToSet)
TheAISContext()->SetTransparency(ashape,atof(argv[1]), TheAISContext()->SetTransparency(ashape,atof(argv[1]),Standard_False);
Standard_False);
else else
TheAISContext()->UnsetTransparency(ashape,Standard_False); TheAISContext()->UnsetTransparency(ashape,Standard_False);
it.Next(); it.Next();
} }
TheAISContext()->UpdateCurrentViewer(); TheAISContext()->UpdateCurrentViewer();
} }
@ -1210,19 +1191,14 @@ static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char**
Standard_Boolean ThereIsName; Standard_Boolean ThereIsName;
Standard_Boolean IsBound = Standard_False ; Standard_Boolean IsBound = Standard_False ;
Standard_Boolean HaveToSet; const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetmaterial") == 0);
if (!strcasecmp( argv[0],"vsetmaterial")) HaveToSet=Standard_True;
else HaveToSet=Standard_False;
if (HaveToSet) { if (HaveToSet) {
if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; } if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
if ( argc == 2 ) {ThereIsName=Standard_False;} ThereIsName = (argc != 2);
else ThereIsName=Standard_True;
} }
else { else {
if ( argc>2 ) { di << argv[0] << " syntax error passez au plus un argument" << "\n"; return 1; } if ( argc>2 ) { di << argv[0] << " syntax error passez au plus un argument" << "\n"; return 1; }
if (argc==2) ThereIsName=Standard_True; ThereIsName = (argc == 2);
else ThereIsName=Standard_False;
} }
if ( !a3DView().IsNull() ) { 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)); Handle(AIS_InteractiveObject)::DownCast (GetMapOfAIS().Find2(name));
if (!ashape.IsNull()) if (!ashape.IsNull())
if (HaveToSet) if (HaveToSet)
TheAISContext()->SetMaterial (ashape, TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[2]));
GetMaterialFromName (argv[2]) );
else else
TheAISContext()->UnsetMaterial(ashape); TheAISContext()->UnsetMaterial(ashape);
} }
@ -1260,12 +1235,11 @@ static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char**
TheAISContext() -> MoreCurrent() ; TheAISContext() -> MoreCurrent() ;
TheAISContext() ->NextCurrent() ) TheAISContext() ->NextCurrent() )
{ {
Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current(); Handle(AIS_InteractiveObject) ashape = TheAISContext()->Current();
if (HaveToSet) if (HaveToSet)
TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]), TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
Standard_False); else
else TheAISContext()->UnsetMaterial(ashape,Standard_False);
TheAISContext()->UnsetMaterial(ashape,Standard_False);
} }
TheAISContext()->UpdateCurrentViewer(); TheAISContext()->UpdateCurrentViewer();
} }
@ -1278,15 +1252,14 @@ static int VMaterial (Draw_Interpretor& di, Standard_Integer argc, const char**
ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName ViewerTest_DoubleMapIteratorOfDoubleMapOfInteractiveAndName
it(GetMapOfAIS()); it(GetMapOfAIS());
while ( it.More() ) { while ( it.More() ) {
Handle(AIS_InteractiveObject) ashape = Handle(AIS_InteractiveObject) ashape =
Handle(AIS_InteractiveObject)::DownCast (it.Key1()); Handle(AIS_InteractiveObject)::DownCast (it.Key1());
if (!ashape.IsNull()) if (!ashape.IsNull())
if (HaveToSet) if (HaveToSet)
TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]), TheAISContext()->SetMaterial(ashape,GetMaterialFromName(argv[1]),Standard_False);
Standard_False );
else else
TheAISContext()->UnsetMaterial(ashape,Standard_False); TheAISContext()->UnsetMaterial(ashape,Standard_False);
it.Next(); it.Next();
} }
TheAISContext()->UpdateCurrentViewer(); TheAISContext()->UpdateCurrentViewer();
} }
@ -1309,18 +1282,14 @@ static int VWidth (Draw_Interpretor& di, Standard_Integer argc, const char** arg
Standard_Boolean ThereIsArgument; Standard_Boolean ThereIsArgument;
Standard_Boolean IsBound = Standard_False ; Standard_Boolean IsBound = Standard_False ;
Standard_Boolean HaveToSet; const Standard_Boolean HaveToSet = (strcasecmp( argv[0],"vsetwidth") == 0);
if (!strcasecmp( argv[0],"vsetwidth")) HaveToSet=Standard_True;
else HaveToSet=Standard_False;
if (HaveToSet) { if (HaveToSet) {
if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; } if ( argc < 2 || argc > 3 ) { di << argv[0] << " syntax error passez 1 ou 2 arguments" << "\n"; return 1; }
if ( argc == 2 ) {ThereIsArgument=Standard_False;} ThereIsArgument = (argc != 2);
else ThereIsArgument=Standard_True;
} }
else { else {
if ( argc>2 ) { di << argv[0] << " syntax error passez au plus 1 argument" << "\n"; return 1; } if ( argc>2 ) { di << argv[0] << " syntax error passez au plus 1 argument" << "\n"; return 1; }
if (argc==2) ThereIsArgument=Standard_True; ThereIsArgument = (argc == 2);
else ThereIsArgument=Standard_False;
} }
if ( !a3DView().IsNull() ) { if ( !a3DView().IsNull() ) {
TCollection_AsciiString name; TCollection_AsciiString name;
@ -1362,12 +1331,11 @@ static int VWidth (Draw_Interpretor& di, Standard_Integer argc, const char** arg
TheAISContext() -> MoreCurrent() ; TheAISContext() -> MoreCurrent() ;
TheAISContext() ->NextCurrent() ) TheAISContext() ->NextCurrent() )
{ {
Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current(); Handle(AIS_InteractiveObject) ashape = TheAISContext() -> Current();
if (HaveToSet) if (HaveToSet)
TheAISContext()->SetWidth(ashape,atof (argv[1]),Standard_False); TheAISContext()->SetWidth(ashape,atof(argv[1]),Standard_False);
else else
TheAISContext()->UnsetWidth (ashape,Standard_False); TheAISContext()->UnsetWidth(ashape,Standard_False);
} }
TheAISContext()->UpdateCurrentViewer(); TheAISContext()->UpdateCurrentViewer();
} }
@ -1382,9 +1350,9 @@ static int VWidth (Draw_Interpretor& di, Standard_Integer argc, const char** arg
Handle(AIS_InteractiveObject)::DownCast (it.Key1()); Handle(AIS_InteractiveObject)::DownCast (it.Key1());
if (!ashape.IsNull()) if (!ashape.IsNull())
if (HaveToSet) if (HaveToSet)
TheAISContext()->SetWidth(ashape,atof (argv[1]),Standard_False ); TheAISContext()->SetWidth(ashape,atof(argv[1]),Standard_False);
else else
TheAISContext()->UnsetWidth (ashape,Standard_False); TheAISContext()->UnsetWidth(ashape,Standard_False);
it.Next(); it.Next();
} }
TheAISContext()->UpdateCurrentViewer(); 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 //purpose : Sharpen or roughten the quality of the shading
//Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg //Draw arg : vshading ShapeName 0.1->0.00001 1 deg-> 30 deg
//============================================================================== //==============================================================================
static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv) { static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
Standard_Boolean HaveToSet; {
// Standard_Real myDevAngle;
Standard_Real myDevCoef; Standard_Real myDevCoef;
Handle(AIS_InteractiveObject) TheAisIO; Handle(AIS_InteractiveObject) TheAisIO;
// Verifications // Verifications
if (!strcasecmp(argv[0],"vsetshading") ) HaveToSet=Standard_True; const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetshading") == 0);
else HaveToSet=Standard_False;
if (TheAISContext()->HasOpenedContext()) if (TheAISContext()->HasOpenedContext())
TheAISContext()->CloseLocalContext(); TheAISContext()->CloseLocalContext();
@ -2249,23 +2216,17 @@ static int VShading(Draw_Interpretor& ,Standard_Integer argc, const char** argv)
myDevCoef =atof(argv[2]); myDevCoef =atof(argv[2]);
} }
TCollection_AsciiString name=argv[1]; TCollection_AsciiString name=argv[1];
if (GetMapOfAIS().IsBound2(name )) if (GetMapOfAIS().IsBound2(name ))
TheAisIO = TheAisIO = Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
Handle(AIS_InteractiveObject)::DownCast(GetMapOfAIS().Find2(name));
if (TheAisIO.IsNull()) if (TheAisIO.IsNull())
TheAisIO=GetAISShapeFromName((const char *)name.ToCString()); TheAisIO=GetAISShapeFromName((const char *)name.ToCString());
if (HaveToSet) { if (HaveToSet)
TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True); TheAISContext()->SetDeviationCoefficient(TheAisIO,myDevCoef,Standard_True);
} else
else {
TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True); TheAISContext()->SetDeviationCoefficient(TheAisIO,0.0008,Standard_True);
}
TheAISContext()->Redisplay(TheAisIO); TheAISContext()->Redisplay(TheAisIO);
return 0; 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) static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{ {
Standard_Boolean HaveToSet;
Standard_Boolean ThereIsName = Standard_False ; Standard_Boolean ThereIsName = Standard_False ;
if(!a3DView().IsNull()){ if(!a3DView().IsNull()){
if (!strcasecmp(argv[0],"vsetam")) HaveToSet=Standard_True; const Standard_Boolean HaveToSet = (strcasecmp(argv[0],"vsetam") == 0);
else HaveToSet=Standard_False;
// verification des arguments // verification des arguments
if (HaveToSet) { if (HaveToSet) {
if (argc<2||argc>3) { di<<" Syntaxe error"<<"\n";return 1;} if (argc<2||argc>3) { di<<" Syntaxe error"<<"\n";return 1;}
if (argc==3) ThereIsName=Standard_True; ThereIsName = (argc == 3);
else ThereIsName=Standard_False;
} }
else { else {
// vunsetam // vunsetam
if (argc>1) {di<<" Syntaxe error"<<"\n";return 1;} if (argc>1) {di<<" Syntaxe error"<<"\n";return 1;}
else { else {
di<<" R.A.Z de tous les modes de selecion"<<"\n"; di<<" R.A.Z de tous les modes de selecion"<<"\n";
di<<" Fermeture du Context local"<<"\n"; di<<" Fermeture du Context local"<<"\n";
if (TheAISContext()->HasOpenedContext()) if (TheAISContext()->HasOpenedContext())
TheAISContext()->CloseLocalContext(); TheAISContext()->CloseLocalContext();
} }
} }
// IL n'y a aps de nom de shape passe en argument // IL n'y a aps de nom de shape passe en argument
if (HaveToSet && !ThereIsName){ if (HaveToSet && !ThereIsName){
Standard_Integer aMode=atoi(argv [1]); Standard_Integer aMode=atoi(argv [1]);
const char *cmode="???"; const char *cmode="???";
switch (aMode) { switch (aMode) {
case 0: cmode = "Shape"; break; case 0: cmode = "Shape"; break;
case 1: cmode = "Vertex"; break; case 1: cmode = "Vertex"; break;
@ -2349,17 +2303,16 @@ static int VActivatedMode (Draw_Interpretor& di, Standard_Integer argc, const ch
} }
if( !TheAISContext()->HasOpenedContext() ) { if( !TheAISContext()->HasOpenedContext() ) {
// il n'y a pas de Context local d'ouvert // il n'y a pas de Context local d'ouvert
// on en ouvre un et on charge toutes les shapes displayees // 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 // on load tous les objets displayees et on Activate les objets de la liste
AIS_ListOfInteractive ListOfIO; AIS_ListOfInteractive ListOfIO;
// on sauve dans une AISListOfInteractive tous les objets currents // on sauve dans une AISListOfInteractive tous les objets currents
if (TheAISContext()->NbCurrents()>0 ){ if (TheAISContext()->NbCurrents()>0 ){
TheAISContext()->UnhilightCurrents(Standard_False); TheAISContext()->UnhilightCurrents(Standard_False);
for (TheAISContext()->InitCurrent(); TheAISContext()->MoreCurrent(); TheAISContext()->NextCurrent() ){
ListOfIO.Append(TheAISContext()->Current() );
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) static int VState(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{ {
Standard_Boolean ThereIsCurrent=Standard_False;
Standard_Boolean ThereIsArguments=Standard_False;
TheAISContext()->CloseAllContexts(); TheAISContext()->CloseAllContexts();
if (argc>=2 ) { const Standard_Boolean ThereIsArguments=(argc>=2);
ThereIsArguments=Standard_True; const Standard_Boolean ThereIsCurrent=(TheAISContext()->NbCurrents()>0);
}
if (TheAISContext()->NbCurrents()>0 ) {
ThereIsCurrent=Standard_True;
}
// Debut... // Debut...
// ================== // ==================
// Il y a un argument // Il y a un argument
// ================== // ==================
if (ThereIsArguments ) { if (ThereIsArguments) {
for (int cpt=1;cpt<argc;cpt++) { for (int cpt=1;cpt<argc;cpt++) {
// Verification que lq piece est bien bindee. // Verification que lq piece est bien bindee.
if (GetMapOfAIS().IsBound2(argv[cpt]) ) { if (GetMapOfAIS().IsBound2(argv[cpt]) ) {

View File

@ -1,8 +1,7 @@
-- File: XCAFPrs.cdl -- File: XCAFPrs.cdl
-- Created: Fri Aug 11 16:28:46 2000 -- Created: Fri Aug 11 16:28:46 2000
-- Author: Andrey BETENEV -- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr> ---Copyright: Matra Datavision 2000
---Copyright: Matra Datavision 2000
package XCAFPrs package XCAFPrs
@ -17,6 +16,7 @@ uses
TopLoc, TopLoc,
TopoDS, TopoDS,
TopTools, TopTools,
Graphic3d,
Prs3d, Prs3d,
PrsMgr, PrsMgr,
TPrsStd, TPrsStd,

View File

@ -1,8 +1,7 @@
-- File: XCAFPrs_AISObject.cdl -- File: XCAFPrs_AISObject.cdl
-- Created: Fri Aug 11 16:37:11 2000 -- Created: Fri Aug 11 16:37:11 2000
-- Author: Andrey BETENEV -- Author: Andrey BETENEV
-- <abv@doomox.nnov.matra-dtv.fr> ---Copyright: Matra Datavision 2000
---Copyright: Matra Datavision 2000
class AISObject from XCAFPrs inherits Shape from AIS class AISObject from XCAFPrs inherits Shape from AIS
@ -15,6 +14,9 @@ uses
PresentationManager3d from PrsMgr, PresentationManager3d from PrsMgr,
Presentation from Prs3d, Presentation from Prs3d,
Label from TDF, Label from TDF,
Color from Quantity,
NameOfMaterial from Graphic3d,
MaterialAspect from Graphic3d,
Style from XCAFPrs Style from XCAFPrs
is is
@ -22,6 +24,20 @@ is
Create (lab: Label from TDF); Create (lab: Label from TDF);
---Purpose: Creates an object to visualise the shape label ---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; AddStyledItem (me: mutable; style: Style from XCAFPrs;
shape: Shape from TopoDS; shape: Shape from TopoDS;
aPresentationManager : PresentationManager3d from PrsMgr; aPresentationManager : PresentationManager3d from PrsMgr;

View File

@ -1,7 +1,6 @@
// File: XCAFPrs_AISObject.cxx // File: XCAFPrs_AISObject.cxx
// Created: Fri Aug 11 16:49:09 2000 // Created: Fri Aug 11 16:49:09 2000
// Author: Andrey BETENEV // Author: Andrey BETENEV
// <abv@doomox.nnov.matra-dtv.fr>
#include <XCAFPrs_AISObject.ixx> #include <XCAFPrs_AISObject.ixx>
#include <TCollection_ExtendedString.hxx> #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 : //purpose :
//======================================================================= //=======================================================================
void DisplayBox(const Handle(Prs3d_Presentation)& aPrs, void XCAFPrs_AISObject::SetColor(const Quantity_Color &aCol)
const Bnd_Box& B, {
const Handle(Prs3d_Drawer)& aDrawer) 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 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_Real X[2],Y[2],Z[2];
Standard_Integer Indx [16] ; Standard_Integer Indx [16] ;
@ -125,6 +215,11 @@ void DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
G->EndPrimitives(); G->EndPrimitives();
} }
//=======================================================================
//function : AddStyledItem
//purpose :
//=======================================================================
void XCAFPrs_AISObject::AddStyledItem (const XCAFPrs_Style &style, void XCAFPrs_AISObject::AddStyledItem (const XCAFPrs_Style &style,
const TopoDS_Shape &shape, const TopoDS_Shape &shape,
const Handle(PrsMgr_PresentationManager3d)&, // aPresentationManager, 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 // support different color settings for different subshapes of a single shape
void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPrs, const Handle(Prs3d_Presentation)& aPrs,
const Standard_Integer aMode) const Standard_Integer aMode)
{ {
#ifdef DEB #ifdef DEB
cout << "XCAFPrs_AISObject: Update called" << endl; //cout << "XCAFPrs_AISObject: Update called" << endl;
#endif #endif
aPrs->Clear(); aPrs->Clear();
// abv: 06 Mar 00: to have good colors // abv: 06 Mar 00: to have good colors
Handle(TPrsStd_AISPresentation) prs = Handle(TPrsStd_AISPresentation)::DownCast ( GetOwner() ); Handle(TPrsStd_AISPresentation) prs = Handle(TPrsStd_AISPresentation)::DownCast ( GetOwner() );
Graphic3d_NameOfMaterial material = ( prs.IsNull() ? Graphic3d_NOM_PLASTIC : prs->Material() ); if ( prs.IsNull() || !prs->HasOwnMaterial() )
// Graphic3d_NameOfMaterial material = Material(); AIS_Shape::SetMaterial ( Graphic3d_NOM_PLASTIC );
SetMaterial ( material );
// SetMaterial ( Graphic3d_NOM_PLASTIC );
TopoDS_Shape shape; TopoDS_Shape shape;
if ( ! XCAFDoc_ShapeTool::GetShape ( myLabel, shape ) || shape.IsNull() ) return; 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_DataMapOfShapeStyle settings;
XCAFPrs::CollectStyleSettings ( myLabel, L, settings ); XCAFPrs::CollectStyleSettings ( myLabel, L, settings );
#ifdef DEB #ifdef DEB
cout << "Styles collected" << endl; //cout << "Styles collected" << endl;
#endif #endif
// dispatch (sub)shapes by their styles // dispatch (sub)shapes by their styles
@ -388,32 +479,22 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr
DefStyle.SetColorCurv ( White ); DefStyle.SetColorCurv ( White );
XCAFPrs::DispatchStyles ( shape, settings, items, DefStyle ); XCAFPrs::DispatchStyles ( shape, settings, items, DefStyle );
#ifdef DEB #ifdef DEB
cout << "Dispatch done" << endl; //cout << "Dispatch done" << endl;
#endif #endif
// add subshapes to presentation (one shape per style) // add subshapes to presentation (one shape per style)
XCAFPrs_DataMapIteratorOfDataMapOfStyleShape it ( items ); XCAFPrs_DataMapIteratorOfDataMapOfStyleShape it ( items );
#ifdef DEB #ifdef DEB
Standard_Integer i=1; //Standard_Integer i=1;
#endif #endif
for ( ; it.More(); it.Next() ) { for ( ; it.More(); it.Next() ) {
XCAFPrs_Style s = it.Key(); XCAFPrs_Style s = it.Key();
#ifdef DEB #ifdef DEB
cout << "Style " << i << ": [" << //cout << "Style " << i << ": [" <<
( s.IsSetColorSurf() ? Quantity_Color::StringName ( s.GetColorSurf().Name() ) : "" ) << ", " << // ( s.IsSetColorSurf() ? Quantity_Color::StringName ( s.GetColorSurf().Name() ) : "" ) << ", " <<
( s.IsSetColorCurv() ? Quantity_Color::StringName ( s.GetColorCurv().Name() ) : "" ) << "]" << // ( s.IsSetColorCurv() ? Quantity_Color::StringName ( s.GetColorCurv().Name() ) : "" ) << "]" <<
" --> si_" << i << ( s.IsVisible() ? "" : " <invisible>" ) << endl; //" --> si_" << i << ( s.IsVisible() ? "" : " <invisible>" ) << endl;
#ifdef DEBUG //i++;
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++;
#endif #endif
if (! s.IsVisible() ) continue; if (! s.IsVisible() ) continue;
AddStyledItem ( s, it.Value(), aPresentationManager, aPrs, aMode ); AddStyledItem ( s, it.Value(), aPresentationManager, aPrs, aMode );
@ -422,13 +503,13 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPr
if ( XCAFPrs::GetViewNameMode() ) { if ( XCAFPrs::GetViewNameMode() ) {
// Displaying Name attributes // Displaying Name attributes
#ifdef DEB #ifdef DEB
cout << "Now display name of shapes" << endl; //cout << "Now display name of shapes" << endl;
#endif #endif
aPrs->SetDisplayPriority(10); aPrs->SetDisplayPriority(10);
DisplayText (myLabel, aPrs, Attributes()->LengthAspect()->TextAspect(), TopLoc_Location());//no location DisplayText (myLabel, aPrs, Attributes()->LengthAspect()->TextAspect(), TopLoc_Location());//no location
} }
#ifdef DEB #ifdef DEB
cout << "Compute finished" << endl; //cout << "Compute finished" << endl;
#endif #endif
aPrs->ReCompute(); // for hidden line recomputation if necessary... aPrs->ReCompute(); // for hidden line recomputation if necessary...

View File

@ -1,8 +1,6 @@
// File: XDEDRAW.cxx // File: XDEDRAW.cxx
// Created: Fri Aug 4 14:38:55 2000 // Created: Fri Aug 4 14:38:55 2000
// Author: Pavel TELKOV // Author: Pavel TELKOV
// <ptv@zamox.nnov.matra-dtv.fr>
#include <XDEDRAW.ixx> #include <XDEDRAW.ixx>
#include <stdio.h> #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 //function : Init
//purpose : //purpose :
@ -792,6 +839,9 @@ void XDEDRAW::Init(Draw_Interpretor& di)
di.Add ("XGetViewNameMode", "\t: Print if mode of displaying names is turn on.", di.Add ("XGetViewNameMode", "\t: Print if mode of displaying names is turn on.",
__FILE__, getviewName, g); __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 // Specialized commands
XDEDRAW_Shapes::InitCommands ( di ); XDEDRAW_Shapes::InitCommands ( di );
XDEDRAW_Colors::InitCommands ( di ); XDEDRAW_Colors::InitCommands ( di );