// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <AIS_Shape.ixx>
+#include <AIS_Shape.hxx>
-
-#include <Standard_ErrorHandler.hxx>
-#include <OSD_Timer.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-
-#include <Quantity_Color.hxx>
-
-#include <gp_Pnt.hxx>
+#include <AIS_GraphicTool.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <Aspect_TypeOfLine.hxx>
#include <Bnd_Box.hxx>
#include <BRep_Builder.hxx>
-#include <BRepTools_ShapeSet.hxx>
-#include <BRepTools.hxx>
#include <BRepBndLib.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-
-#include <Aspect_TypeOfLine.hxx>
-#include <Graphic3d_Structure.hxx>
-#include <Graphic3d_Group.hxx>
+#include <BRepTools.hxx>
+#include <BRepTools_ShapeSet.hxx>
+#include <Geom_Transformation.hxx>
+#include <gp_Pnt.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
#include <Graphic3d_AspectLine3d.hxx>
-#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_AspectText3d.hxx>
+#include <Graphic3d_Group.hxx>
#include <Graphic3d_MaterialAspect.hxx>
#include <Graphic3d_SequenceOfGroup.hxx>
-
+#include <Graphic3d_Structure.hxx>
+#include <HLRBRep.hxx>
+#include <OSD_Timer.hxx>
+#include <Precision.hxx>
#include <Prs3d.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_Presentation.hxx>
+#include <Prs3d_Projector.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_IsoAspect.hxx>
-
-#include <StdPrs_WFShape.hxx>
-#include <StdPrs_WFDeflectionShape.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_HLRShape.hxx>
-#include <StdPrs_HLRPolyShape.hxx>
-
+#include <StdPrs_BndBox.hxx>
+#include <StdPrs_ToolTriangulatedShape.hxx>
#include <PrsMgr_ModedPresentation.hxx>
-
+#include <Quantity_Color.hxx>
+#include <Select3D_SensitiveBox.hxx>
#include <Select3D_SensitiveEntity.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_Failure.hxx>
+#include <Standard_Type.hxx>
+#include <StdPrs_HLRPolyShape.hxx>
+#include <StdPrs_HLRShape.hxx>
+#include <StdPrs_ShadedShape.hxx>
+#include <StdPrs_WFShape.hxx>
#include <StdSelect.hxx>
-#include <StdSelect_BRepSelectionTool.hxx>
#include <StdSelect_BRepOwner.hxx>
+#include <StdSelect_BRepSelectionTool.hxx>
#include <StdSelect_DisplayMode.hxx>
-
-#include <AIS_GraphicTool.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Drawer.hxx>
-#include <HLRBRep.hxx>
-#include <Precision.hxx>
-
-#include <Standard_Failure.hxx>
-#include <Standard_ErrorHandler.hxx>
-#include <Select3D_SensitiveBox.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
#include <TopoDS_Iterator.hxx>
+#include <TopoDS_Shape.hxx>
-static Standard_Boolean myFirstCompute;
+IMPLEMENT_STANDARD_RTTIEXT(AIS_Shape,AIS_InteractiveObject)
static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
{
AIS_Shape::
AIS_Shape(const TopoDS_Shape& shap):
AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant),
-myshape(shap),
-myCompBB(Standard_True),
myInitAng(0.)
{
- myFirstCompute = Standard_True;
- SetHilightMode(0);
- myDrawer->SetShadingAspectGlobal(Standard_False);
+ Set (shap);
}
//=======================================================================
//=======================================================================
void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPrs,
- const Standard_Integer aMode)
+ const Standard_Integer theMode)
{
- aPrs->Clear();
if(myshape.IsNull()) return;
// wire,edge,vertex -> pas de HLR + priorite display superieure
}
}
- if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //not taken in account duting FITALL
- switch (aMode) {
- case 0:{
- try { OCC_CATCH_SIGNALS StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); }
- catch (Standard_Failure) {
-#ifdef DEB
- cout << "AIS_Shape::Compute() failed"<< endl;
-#endif
- cout << "a Shape should be incorrect : No Compute can be maked on it "<< endl;
-// presentation of the bounding box is calculated
-// Compute(aPresentationManager,aPrs,2);
- }
- break;
+ if (IsInfinite())
+ {
+ aPrs->SetInfiniteState (Standard_True); //not taken in account during FITALL
}
- case 1:
+
+ switch (theMode)
+ {
+ case AIS_WireFrame:
{
- Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
- Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
- Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
- if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
- || (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
+ StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
+ try
{
- BRepTools::Clean (myshape);
+ OCC_CATCH_SIGNALS
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
}
-
- //shading only on face...
- if ((Standard_Integer) myshape.ShapeType()>4)
- StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else {
- myDrawer->SetShadingAspectGlobal(Standard_False);
- if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else {
+ catch (Standard_Failure)
+ {
+ #ifdef OCCT_DEBUG
+ cout << "AIS_Shape::Compute() failed" << endl;
+ cout << "a Shape should be incorrect : No Compute can be maked on it " << endl;
+ #endif
+ // presentation of the bounding box is calculated
+ // Compute(aPresentationManager,aPrs,2);
+ }
+ break;
+ }
+ case AIS_Shaded:
+ {
+ StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (myshape, myDrawer, Standard_True);
+ if ((Standard_Integer) myshape.ShapeType() > 4)
+ {
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+ }
+ else
+ {
+ if (IsInfinite())
+ {
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+ }
+ else
+ {
+ try
{
- try {
- OCC_CATCH_SIGNALS
- StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
- }
- catch (Standard_Failure) {
-#ifdef DEB
- cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
-#endif
- StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
- }
+ OCC_CATCH_SIGNALS
+ StdPrs_ShadedShape::Add (aPrs, myshape, myDrawer);
+ }
+ catch (Standard_Failure)
+ {
+ #ifdef OCCT_DEBUG
+ cout << "AIS_Shape::Compute() in ShadingMode failed" << endl;
+ #endif
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
}
}
}
- Standard_Real value = Transparency() ;
- if( value > 0. ) {
- SetTransparency( value );
+ Standard_Real aTransparency = Transparency() ;
+ if (aTransparency > 0.0)
+ {
+ SetTransparency (aTransparency);
}
break;
}
- case 2:
+
+ // Bounding box.
+ case 2:
{
- // bounding box
- if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else StdPrs_WFDeflectionRestrictedFace::AddBox (aPrs, BoundingBox(), myDrawer);
+ if (IsInfinite())
+ {
+ StdPrs_WFShape::Add (aPrs, myshape, myDrawer);
+ }
+ else
+ {
+ StdPrs_BndBox::Add (aPrs, BoundingBox(), myDrawer);
+ }
}
- } // end switch
- aPrs->ReCompute(); // for hidden line recomputation if necessary...
+ }
+
+ // Recompute hidden line presentation (if necessary).
+ aPrs->ReCompute();
}
//=======================================================================
}
Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
- if (defdrawer->DrawHiddenLine())
+ if (defdrawer->DrawHiddenLine())
{myDrawer->EnableDrawHiddenLine();}
else {myDrawer->DisableDrawHiddenLine();}
Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
-// coefficients for calculation
-
- Standard_Real prevangle, newangle ,prevcoeff,newcoeff ;
- Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle(newangle,prevangle);
- Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient(newcoeff,prevcoeff);
- if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
- ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient)) {
-#ifdef DEB
- cout << "AIS_Shape : compute"<<endl;
- cout << "newangle : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
- cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
-#endif
+ if (myDrawer->IsAutoTriangulation())
+ {
+ // coefficients for calculation
+ Standard_Real aPrevAngle, aNewAngle, aPrevCoeff, aNewCoeff;
+ Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle (aNewAngle, aPrevAngle);
+ Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient (aNewCoeff, aPrevCoeff);
+ if (((Abs (aNewAngle - aPrevAngle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
+ ((Abs (aNewCoeff - aPrevCoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient))
+ {
BRepTools::Clean(SH);
}
+ }
{
try {
}
}
catch (Standard_Failure) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl;
#endif
StdPrs_WFShape::Add(aPresentation,SH,myDrawer);
return;
}
- static TopAbs_ShapeEnum TypOfSel;
- TypOfSel = AIS_Shape::SelectionType(aMode);
+ TopAbs_ShapeEnum TypOfSel = AIS_Shape::SelectionType(aMode);
TopoDS_Shape shape = myshape;
- if( HasTransformation() ) {
- gp_Trsf trsf = Transformation();
- shape = shape.Located(TopLoc_Location(trsf)*shape.Location());
- }
// POP protection against crash in low layers
Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
- Standard_Boolean autoTriangulation = Standard_True;
try {
OCC_CATCH_SIGNALS
StdSelect_BRepSelectionTool::Load(aSelection,
TypOfSel,
aDeflection,
myDrawer->HLRAngle(),
- autoTriangulation);
+ myDrawer->IsAutoTriangulation());
} catch ( Standard_Failure ) {
// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl;
if ( aMode == 0 ) {
+ aSelection->Clear();
Bnd_Box B = BoundingBox();
Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this);
Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B);
StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
}
-Quantity_NameOfColor AIS_Shape::Color() const {
-Quantity_Color aColor;
- Color(aColor);
- return aColor.Name();
-}
-
void AIS_Shape::Color( Quantity_Color& aColor ) const {
aColor = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
}
return myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
}
-//=======================================================================
-//function : SetColor
-//purpose :
-//=======================================================================
-
-void AIS_Shape::SetColor(const Quantity_NameOfColor aCol)
-{
- SetColor(Quantity_Color(aCol));
-}
-
//=======================================================================
//function : setColor
//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();
+ theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_BLACK, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
+ }
+ }
+ if (!theDrawer->HasOwnFreeBoundaryAspect())
+ {
+ theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
+ }
+ }
+ if (!theDrawer->HasOwnUnFreeBoundaryAspect())
+ {
+ theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
+ }
+ }
+ if (!theDrawer->HasOwnSeenLineAspect())
+ {
+ theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
+ }
}
- // disable dedicated line aspects
- theDrawer->SetFreeBoundaryAspect (theDrawer->LineAspect());
- theDrawer->SetUnFreeBoundaryAspect(theDrawer->LineAspect());
- theDrawer->SetSeenLineAspect (theDrawer->LineAspect());
// override color
theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
- theDrawer->SetShadingAspectGlobal (Standard_False);
theDrawer->LineAspect()->SetColor (theColor);
theDrawer->WireAspect()->SetColor (theColor);
theDrawer->PointAspect()->SetColor (theColor);
+ theDrawer->FreeBoundaryAspect()->SetColor (theColor);
+ theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
+ theDrawer->SeenLineAspect()->SetColor (theColor);
}
//=======================================================================
void AIS_Shape::SetColor (const Quantity_Color& theColor)
{
setColor (myDrawer, theColor);
- myOwnColor = theColor;
+ myDrawer->SetColor (theColor);
hasOwnColor = Standard_True;
// modify shading presentation without re-computation
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
-
- // Set aspects for presentation
- aPrs->SetPrimitivesAspect (anAreaAspect);
- aPrs->SetPrimitivesAspect (aLineAspect);
- aPrs->SetPrimitivesAspect (aPointAspect);
-
- // Go through all groups to change color for all primitives
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
}
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())
+ {
+ aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
+ }
mat.SetColor (aColor);
}
if (IsTransparent())
{
Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
- mat.SetTransparency (aTransp);
+ mat.SetTransparency (Standard_ShortReal(aTransp));
}
myDrawer->ShadingAspect()->SetMaterial (mat ,myCurrentFacingModel);
}
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
-
- aPrs->SetPrimitivesAspect (anAreaAsp);
- aPrs->SetPrimitivesAspect (aLineAsp);
-
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
//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();
+ }
+ }
+ if (!theDrawer->HasOwnFreeBoundaryAspect())
+ {
+ theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
+ }
+ }
+ if (!theDrawer->HasOwnUnFreeBoundaryAspect())
+ {
+ theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
+ }
+ }
+ if (!theDrawer->HasOwnSeenLineAspect())
+ {
+ theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
+ }
}
- // disable dedicated line aspects
- theDrawer->SetFreeBoundaryAspect (theDrawer->LineAspect());
- theDrawer->SetUnFreeBoundaryAspect(theDrawer->LineAspect());
- theDrawer->SetSeenLineAspect (theDrawer->LineAspect());
// override width
theDrawer->LineAspect()->SetWidth (theLineWidth);
theDrawer->WireAspect()->SetWidth (theLineWidth);
+ theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
+ theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
+ theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
}
//=======================================================================
}
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);
}
//=======================================================================
-//function : SetMaterial
-//purpose :
+//function : setMaterial
+//purpose :
//=======================================================================
-void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
+void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
+ const Graphic3d_MaterialAspect& theMaterial,
+ const Standard_Boolean theToKeepColor,
+ const Standard_Boolean theToKeepTransp) const
{
- SetMaterial(Graphic3d_MaterialAspect(aMat));
+ const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
+ const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
+ if (!theDrawer->HasOwnShadingAspect())
+ {
+ theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
+ }
+ }
+ theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
+
+ if (theToKeepColor)
+ {
+ theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
+ }
+ if (theToKeepTransp)
+ {
+ theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
+ }
}
//=======================================================================
void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
{
- if (!myDrawer->HasShadingAspect())
- {
- myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
- *myDrawer->ShadingAspect()->Aspect() = *myDrawer->Link()->ShadingAspect()->Aspect();
- }
+ setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
- myDrawer->ShadingAspect()->SetMaterial (theMat, myCurrentFacingModel);
- if (HasColor())
- {
- myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
- }
- myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
-
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- aPrs->SetPrimitivesAspect (anAreaAsp);
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
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);
- myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
+ myDrawer->ShadingAspect()->SetColor (myDrawer->Color(), myCurrentFacingModel);
+ myDrawer->ShadingAspect()->SetTransparency (myDrawer->Transparency(), myCurrentFacingModel);
}
}
else
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- aPrs->SetPrimitivesAspect (anAreaAsp);
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
//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
void AIS_Shape::SetTransparency (const Standard_Real theValue)
{
setTransparency (myDrawer, theValue);
- myTransparency = theValue;
+ myDrawer->SetTransparency ((Standard_ShortReal )theValue);
// modify shading presentation without re-computation
const PrsMgr_Presentations& aPrsList = Presentations();
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- aPrs->SetPrimitivesAspect (anAreaAsp);
- aPrs->SetDisplayPriority (10); // force highest priority for translucent objects
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
void AIS_Shape::UnsetTransparency()
{
- myTransparency = 0.0;
- if (!myDrawer->HasShadingAspect())
+ myDrawer->SetTransparency (0.0f);
+ if (!myDrawer->HasOwnShadingAspect())
{
return;
}
}
const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
- aPrs->SetPrimitivesAspect (anAreaAsp);
for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
{
const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
aGroup->SetGroupPrimitivesAspect (anAreaAsp);
}
}
- aPrs->ResetDisplayPriority();
}
myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
{
- Standard_Boolean itSet = myDrawer->IsOwnDeviationCoefficient();
+ Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
if(itSet) myDrawer->SetDeviationCoefficient();
return itSet;
}
Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient ()
{
- Standard_Boolean itSet = myDrawer->IsOwnHLRDeviationCoefficient();
+ Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationCoefficient();
if(itSet) myDrawer->SetHLRDeviationCoefficient();
return itSet;
Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
{
- Standard_Boolean itSet = myDrawer->IsOwnDeviationAngle();
+ Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
if(itSet) myDrawer->SetDeviationAngle();
return itSet;
Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle ()
{
- Standard_Boolean itSet = myDrawer->IsOwnHLRDeviationAngle();
+ Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationAngle();
if(itSet) myDrawer->SetHLRAngle();
return itSet;
{
aCoefficient = myDrawer->DeviationCoefficient();
aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
- return myDrawer->IsOwnDeviationCoefficient() ;
+ return myDrawer->HasOwnDeviationCoefficient() ;
}
//=======================================================================
{
aCoefficient = myDrawer->HLRDeviationCoefficient();
aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
- return myDrawer->IsOwnHLRDeviationCoefficient();
+ return myDrawer->HasOwnHLRDeviationCoefficient();
}
{
anAngle = myDrawer->DeviationAngle();
aPreviousAngle = myDrawer->PreviousDeviationAngle ();
- return myDrawer->IsOwnDeviationAngle();
+ return myDrawer->HasOwnDeviationAngle();
}
//=======================================================================
{
anAngle = myDrawer->HLRAngle();
aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
- return myDrawer->IsOwnHLRDeviationAngle();
+ return myDrawer->HasOwnHLRDeviationAngle();
}