1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025773: Visualization - remove AIS_Drawer class and transfer its Link() logic to Prs3d_Drawer

This commit is contained in:
osa
2015-03-02 16:17:29 +03:00
committed by bugmaster
parent 44b47a9a7e
commit 6262338c4b
104 changed files with 2698 additions and 2843 deletions

View File

@@ -66,7 +66,6 @@
#include <AIS_GraphicTool.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_Drawer.hxx>
#include <HLRBRep.hxx>
#include <Precision.hxx>
@@ -94,10 +93,9 @@ static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard
AIS_Shape::
AIS_Shape(const TopoDS_Shape& shap):
AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant),
myshape(shap),
myCompBB(Standard_True),
myInitAng(0.)
{
Set (shap);
myFirstCompute = Standard_True;
SetHilightMode(0);
myDrawer->SetShadingAspectGlobal(Standard_False);
@@ -254,7 +252,7 @@ void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
}
Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
if (defdrawer->DrawHiddenLine())
if (defdrawer->DrawHiddenLine())
{myDrawer->EnableDrawHiddenLine();}
else {myDrawer->DisableDrawHiddenLine();}
@@ -440,28 +438,40 @@ void AIS_Shape::SetColor(const Quantity_NameOfColor aCol)
//purpose :
//=======================================================================
void AIS_Shape::setColor (const Handle(AIS_Drawer)& theDrawer,
const Quantity_Color& theColor) const
void AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
const Quantity_Color& theColor) const
{
if (!theDrawer->HasShadingAspect())
if (!theDrawer->HasOwnShadingAspect())
{
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
if (theDrawer->HasLink())
{
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
}
}
if (!theDrawer->HasLineAspect())
if (!theDrawer->HasOwnLineAspect())
{
theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
if (theDrawer->HasLink())
{
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
}
}
if (!theDrawer->HasWireAspect())
if (!theDrawer->HasOwnWireAspect())
{
theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
if (theDrawer->HasLink())
{
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
}
}
if (!theDrawer->HasPointAspect())
if (!theDrawer->HasOwnPointAspect())
{
theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0));
*theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
if (theDrawer->HasLink())
{
*theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
}
}
// disable dedicated line aspects
theDrawer->SetFreeBoundaryAspect (theDrawer->LineAspect());
@@ -559,26 +569,53 @@ void AIS_Shape::UnsetColor()
}
else
{
Quantity_Color aColor;
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
Quantity_Color aColor = Quantity_NOC_YELLOW;
if (myDrawer->HasLink())
{
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
}
myDrawer->LineAspect()->SetColor (aColor);
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
aColor = Quantity_NOC_RED;
if (myDrawer->HasLink())
{
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
}
myDrawer->WireAspect()->SetColor (aColor);
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
aColor = Quantity_NOC_GREEN;
if (myDrawer->HasLink())
{
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
}
myDrawer->FreeBoundaryAspect()->SetColor (aColor);
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
aColor = Quantity_NOC_YELLOW;
if (myDrawer->HasLink())
{
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
}
myDrawer->UnFreeBoundaryAspect()->SetColor (aColor);
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen, aColor);
if (myDrawer->HasLink())
{
AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen, aColor);
}
myDrawer->SeenLineAspect()->SetColor (aColor);
}
if (HasMaterial()
|| IsTransparent())
{
Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(HasMaterial()? myDrawer : myDrawer->Link());
Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
Graphic3d_MaterialAspect mat = aDefaultMat;
if (HasMaterial() || myDrawer->HasLink())
{
mat = AIS_GraphicTool::GetMaterial(HasMaterial()? myDrawer : myDrawer->Link());
}
if (HasMaterial())
{
Quantity_Color aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
Quantity_Color aColor = aDefaultMat.AmbientColor();
if (myDrawer->HasLink())
{
Quantity_Color aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
}
mat.SetColor (aColor);
}
if (IsTransparent())
@@ -638,18 +675,24 @@ void AIS_Shape::UnsetColor()
//purpose :
//=======================================================================
void AIS_Shape::setWidth (const Handle(AIS_Drawer)& theDrawer,
const Standard_Real theLineWidth) const
void AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theLineWidth) const
{
if (!theDrawer->HasLineAspect())
if (!theDrawer->HasOwnLineAspect())
{
theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
if (theDrawer->HasLink())
{
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
}
}
if (!theDrawer->HasWireAspect())
if (!theDrawer->HasOwnWireAspect())
{
theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
if (theDrawer->HasLink())
{
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
}
}
// disable dedicated line aspects
theDrawer->SetFreeBoundaryAspect (theDrawer->LineAspect());
@@ -701,11 +744,16 @@ void AIS_Shape::UnsetWidth()
}
else
{
myDrawer->LineAspect() ->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line));
myDrawer->WireAspect() ->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire));
myDrawer->FreeBoundaryAspect() ->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free));
myDrawer->UnFreeBoundaryAspect()->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree));
myDrawer->SeenLineAspect() ->SetWidth (AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen));
myDrawer->LineAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.);
myDrawer->WireAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire) : 1.);
myDrawer->FreeBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free) : 1.);
myDrawer->UnFreeBoundaryAspect()->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree) : 1.);
myDrawer->SeenLineAspect() ->SetWidth (myDrawer->HasLink() ?
AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen) : 1.);
}
LoadRecomputable (AIS_WireFrame);
}
@@ -715,17 +763,20 @@ void AIS_Shape::UnsetWidth()
//purpose :
//=======================================================================
void AIS_Shape::setMaterial (const Handle(AIS_Drawer)& theDrawer,
void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
const Graphic3d_MaterialAspect& theMaterial,
const Standard_Boolean theToKeepColor,
const Standard_Boolean theToKeepTransp) const
{
const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
if (!theDrawer->HasShadingAspect())
if (!theDrawer->HasOwnShadingAspect())
{
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
if (theDrawer->HasLink())
{
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
}
}
theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
@@ -805,8 +856,11 @@ void AIS_Shape::UnsetMaterial()
if (HasColor()
|| IsTransparent())
{
myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
myCurrentFacingModel);
if(myDrawer->HasLink())
{
myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
myCurrentFacingModel);
}
if (HasColor())
{
myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
@@ -851,13 +905,16 @@ void AIS_Shape::UnsetMaterial()
//purpose :
//=======================================================================
void AIS_Shape::setTransparency (const Handle(AIS_Drawer)& theDrawer,
const Standard_Real theValue) const
void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
const Standard_Real theValue) const
{
if (!theDrawer->HasShadingAspect())
if (!theDrawer->HasOwnShadingAspect())
{
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
if (theDrawer->HasLink())
{
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
}
}
// override transparency
@@ -910,7 +967,7 @@ void AIS_Shape::SetTransparency (const Standard_Real theValue)
void AIS_Shape::UnsetTransparency()
{
myTransparency = 0.0;
if (!myDrawer->HasShadingAspect())
if (!myDrawer->HasOwnShadingAspect())
{
return;
}
@@ -996,7 +1053,7 @@ const Bnd_Box& AIS_Shape::BoundingBox()
Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
{
Standard_Boolean itSet = myDrawer->IsOwnDeviationCoefficient();
Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
if(itSet) myDrawer->SetDeviationCoefficient();
return itSet;
}
@@ -1009,7 +1066,7 @@ Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient ()
{
Standard_Boolean itSet = myDrawer->IsOwnHLRDeviationCoefficient();
Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationCoefficient();
if(itSet) myDrawer->SetHLRDeviationCoefficient();
return itSet;
@@ -1023,7 +1080,7 @@ Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient ()
Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
{
Standard_Boolean itSet = myDrawer->IsOwnDeviationAngle();
Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
if(itSet) myDrawer->SetDeviationAngle();
return itSet;
@@ -1037,7 +1094,7 @@ Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle ()
{
Standard_Boolean itSet = myDrawer->IsOwnHLRDeviationAngle();
Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationAngle();
if(itSet) myDrawer->SetHLRAngle();
return itSet;
@@ -1138,7 +1195,7 @@ Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoeffici
{
aCoefficient = myDrawer->DeviationCoefficient();
aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
return myDrawer->IsOwnDeviationCoefficient() ;
return myDrawer->HasOwnDeviationCoefficient() ;
}
//=======================================================================
@@ -1151,7 +1208,7 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoeffi
{
aCoefficient = myDrawer->HLRDeviationCoefficient();
aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
return myDrawer->IsOwnHLRDeviationCoefficient();
return myDrawer->HasOwnHLRDeviationCoefficient();
}
@@ -1165,7 +1222,7 @@ Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
{
anAngle = myDrawer->DeviationAngle();
aPreviousAngle = myDrawer->PreviousDeviationAngle ();
return myDrawer->IsOwnDeviationAngle();
return myDrawer->HasOwnDeviationAngle();
}
//=======================================================================
@@ -1178,5 +1235,5 @@ Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
{
anAngle = myDrawer->HLRAngle();
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
return myDrawer->IsOwnHLRDeviationAngle();
return myDrawer->HasOwnHLRDeviationAngle();
}