-// File: AIS_Shape.cxx
-// Created: Fri Dec 20 17:18:37 1996
-// Author: Robert COUBLANC
-
-#define BUC60577 //GG_191099 Draw correct bounding box and Menage ...
-
-#define BUC60547 //GG_091299 Enable to show a Shape of type COMPOUND
-
-#define GER61351 //GG_171199 Enable to set an object RGB color
-// instead a restricted object NameOfColor.
-// Redefines the Color(),Material(),Transparency() methods .
-// enable to get separately the shape attributes.
-
-#define IMP040200 //GG Enable to compute selection after transformation
-
-#define BUC60918 //GG 31/05/01 To avoid transparency bug between
-// transparent and non transparent objects,
-// increase display priority for transparent objects
+// Created on: 1996-12-20
+// Created by: Robert COUBLANC
+// Copyright (c) 1996-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
#include <AIS_Shape.ixx>
#include <Graphic3d_AspectText3d.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
-#include <Graphic3d_ArrayOfPrimitives.hxx>
+#include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_MaterialAspect.hxx>
+#include <Graphic3d_SequenceOfGroup.hxx>
+#include <Prs3d.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_IsoAspect.hxx>
-//#include <StdPrs_WFSectionShape.hxx>
#include <StdPrs_WFShape.hxx>
#include <StdPrs_WFDeflectionShape.hxx>
#include <StdPrs_ShadedShape.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>
-#ifdef BUC60547
#include <TopoDS_Iterator.hxx>
-#endif
static Standard_Boolean myFirstCompute;
-Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape,
- const Handle(Prs3d_Drawer)& aDrawer)
-{
- // WARNING: this same piece of code appears several times in Prs3d classes
- Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
- if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
- Bnd_Box B;
- BRepBndLib::Add(aShape, B, Standard_False);
- if ( ! B.IsVoid() )
- {
- Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
- B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
- aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) *
- aDrawer->DeviationCoefficient() * 4;
- }
- }
- return aDeflection;
-}
-
-void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
- const Bnd_Box& B,
- const Handle(Prs3d_Drawer)& aDrawer)
-{
- Standard_Real X[2],Y[2],Z[2];
- Standard_Integer Indx [16] ;
- if ( B.IsVoid() )
- return; // nothing to show
-
-#ifdef BUC60577
- Indx [0]=1;Indx [1]=2;Indx [2]=4;Indx [3]=3;
- Indx [4]=5;Indx [5]=6;Indx [6]=8;Indx [7]=7;
- Indx [8]=1;Indx [9]=3;Indx [10]=7;Indx [11]=5;
- Indx [12]=2;Indx [13]=4;Indx [14]=8;Indx [15]=6;
- B.Get(X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
-#else
- Indx [0]=1;Indx [1]=2;Indx [2]=3;Indx [3]=4;Indx [4]=5;Indx [5]=6;Indx [6]=7;
- Indx [7]=8;Indx [8]=1;Indx [9]=2;Indx [10]=6;Indx [10]=5;Indx [10]=3;
- Indx [10]=4;Indx [10]=8;Indx [10]=7;
- B.Get(X[1], Y[1], Z[1], X[2], Y[2], Z[2]);
-#endif
-
- Graphic3d_Array1OfVertex V(1,8);
- Standard_Integer Rank(0);
- for(Standard_Integer k=0;k<=1;k++)
- for(Standard_Integer j=0;j<=1;j++)
- for(Standard_Integer i=0;i<=1;i++)
- V(++Rank) = Graphic3d_Vertex(X[i],Y[j],Z[k]);
-
-
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPrs);
- Quantity_Color Q;
- Aspect_TypeOfLine A;
- Standard_Real W;
- aDrawer->LineAspect()->Aspect()->Values(Q,A,W);
-
-
- G->SetGroupPrimitivesAspect(new Graphic3d_AspectLine3d(Q,Aspect_TOL_DOTDASH,W));
-
- G->BeginPrimitives();Standard_Integer I,J;
- Graphic3d_Array1OfVertex VVV (1,5);
- for(I=1;I<=4;I++){
- for(J=1;J<=4;J++){
- VVV.SetValue(J,V(Indx[J+4*I-5]));
- }
- VVV.SetValue(5,VVV(1));
- G->Polyline(VVV);
- }
- G->EndPrimitives();
-}
-
static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
{
TColStd_ListIteratorOfListOfInteger It(LL);
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);
}
// Shape vide -> Assemblage vide.
if (myshape.ShapeType() == TopAbs_COMPOUND) {
-#ifdef BUC60547
TopoDS_Iterator anExplor (myshape);
-#else
- TopExp_Explorer anExplor (myshape, TopAbs_VERTEX);
-#endif
+
if (!anExplor.More()) {
return;
}
}
-
-
+
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
+#ifdef OCCT_DEBUG
cout << "AIS_Shape::Compute() failed"<< endl;
-#endif
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);
}
}
case 1:
{
- Standard_Real prevangle ;
- Standard_Real newangle ;
- Standard_Real prevcoeff ;
- Standard_Real newcoeff ;
-
-
- if (OwnDeviationAngle(newangle,prevangle) ||
- OwnDeviationCoefficient(newcoeff,prevcoeff))
- if (Abs (newangle - prevangle) > Precision::Angular() ||
- Abs (newcoeff - prevcoeff) > Precision::Confusion() ) {
-#ifdef DEB
- cout << "AIS_Shape : compute"<<endl;
- cout << "newangl : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl;
- cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl;
-#endif
- BRepTools::Clean(myshape);
+ if (myDrawer->IsAutoTriangulation())
+ {
+ 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()))
+ {
+ BRepTools::Clean (myshape);
}
-
+ }
+
//shading only on face...
if ((Standard_Integer) myshape.ShapeType()>4)
StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
}
catch (Standard_Failure) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
#endif
StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
}
}
}
-#ifdef BUC60918
Standard_Real value = Transparency() ;
if( value > 0. ) {
SetTransparency( value );
}
-#endif
break;
}
case 2:
{
// bounding box
if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
- else DisplayBox(aPrs,BoundingBox(),myDrawer);
+ else StdPrs_WFDeflectionRestrictedFace::AddBox (aPrs, BoundingBox(), myDrawer);
}
-
-
} // end switch
aPrs->ReCompute(); // for hidden line recomputation if necessary...
-
-}
-
-//=======================================================================
-//function : Compute
-//purpose :
-//=======================================================================
-
-void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager*/,
- const Handle(Graphic2d_GraphicObject)& /*aGRO*/,
- const Standard_Integer /*aMode*/)
-{
}
//=======================================================================
const TopoDS_Shape& SH)
{
if (SH.ShapeType() == TopAbs_COMPOUND) {
-#ifdef BUC60547
TopoDS_Iterator anExplor (SH);
-#else
- TopExp_Explorer anExplor (SH, TopAbs_VERTEX);
-#endif
+
if (!anExplor.More()) // Shape vide -> Assemblage vide.
return;
}
-
+
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 ;
- if (OwnHLRDeviationAngle(newangle,prevangle) || OwnHLRDeviationCoefficient(newcoeff, prevcoeff))
-
- if (Abs (newangle - prevangle) > Precision::Angular() ||
- Abs (newcoeff - prevcoeff) > Precision::Confusion() ) {
-#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 {
OCC_CATCH_SIGNALS
- StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector);
+ switch (TypeOfHLR()) {
+ case Prs3d_TOH_Algo:
+ StdPrs_HLRShape::Add (aPresentation, SH, myDrawer, aProjector);
+ break;
+ case Prs3d_TOH_PolyAlgo:
+ default:
+ StdPrs_HLRPolyShape::Add (aPresentation, SH, myDrawer, aProjector);
+ break;
+ }
}
catch (Standard_Failure) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl;
#endif
StdPrs_WFShape::Add(aPresentation,SH,myDrawer);
}
}
-
defdrawer->SetTypeOfDeflection (prevdef);
}
{
if(myshape.IsNull()) return;
if (myshape.ShapeType() == TopAbs_COMPOUND) {
-#ifdef BUC60547
TopoDS_Iterator anExplor (myshape);
-#else
- TopExp_Explorer anExplor (myshape, TopAbs_VERTEX);
-#endif
+
if (!anExplor.More()) // empty Shape -> empty Assembly.
return;
}
static TopAbs_ShapeEnum TypOfSel;
TypOfSel = AIS_Shape::SelectionType(aMode);
TopoDS_Shape shape = myshape;
-#ifdef IMP040200
- if( HasTransformation() ) {
- Handle(Geom_Transformation) trsf = Transformation();
- shape = shape.Located(TopLoc_Location(trsf->Trsf())*shape.Location());
- }
-#endif
// POP protection against crash in low layers
- Standard_Real aDeflection = GetDeflection(shape, myDrawer);
- Standard_Boolean autoTriangulation = Standard_True;
+ Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
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);
}
-#ifdef GER61351
Quantity_NameOfColor AIS_Shape::Color() const {
Quantity_Color aColor;
Color(aColor);
Standard_Real AIS_Shape::Transparency() const {
return myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
}
-#endif
//=======================================================================
//function : SetColor
}
//=======================================================================
-//function : SetColor
-//purpose :
+//function : setColor
+//purpose :
//=======================================================================
-void AIS_Shape::SetColor(const Quantity_Color &aCol)
+void AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
+ const Quantity_Color& theColor) const
{
- if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
- myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+ if (!theDrawer->HasOwnShadingAspect())
+ {
+ theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
+ }
+ }
+ if (!theDrawer->HasOwnLineAspect())
+ {
+ theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
+ }
+ }
+ if (!theDrawer->HasOwnWireAspect())
+ {
+ theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
+ }
+ }
+ if (!theDrawer->HasOwnPointAspect())
+ {
+ theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, 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();
+ }
+ }
+
+ // 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);
+}
+
+//=======================================================================
+//function : SetColor
+//purpose :
+//=======================================================================
+
+void AIS_Shape::SetColor (const Quantity_Color& theColor)
+{
+ setColor (myDrawer, theColor);
+ myOwnColor = theColor;
hasOwnColor = Standard_True;
- myDrawer->ShadingAspect()->SetColor(aCol,myCurrentFacingModel);
- myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
- myDrawer->SetShadingAspectGlobal(Standard_False);
+ // modify shading presentation without re-computation
+ const PrsMgr_Presentations& aPrsList = Presentations();
+ Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
+ Handle(Graphic3d_AspectLine3d) aLineAspect = myDrawer->LineAspect()->Aspect();
+ Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
+ for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ {
+ const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
+ if (aPrsModed.Mode() != AIS_Shaded)
+ {
+ continue;
+ }
- const Standard_Real WW = HasWidth()? Width():AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line);
-
- myDrawer->SetLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
- myDrawer->SetWireAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
- myDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
- myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
- myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW));
-
- // fast shading modification...
- if(!GetContext().IsNull()){
- if( GetContext()->MainPrsMgr()->HasPresentation(this,1)){
- Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
- Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
-#ifdef BUC60577
- P->SetPrimitivesAspect(a4bis);
- G->SetGroupPrimitivesAspect(a4bis);
-#else
- a4bis->SetInteriorColor(Quantity_Color(aCol)); // Already done above in SetColor(...)
-
- P->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
- G->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect());
-#endif
- }
+ 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();
+
+ // Check if aspect of given type is set for the group,
+ // because setting aspect for group with no already set aspect
+ // can lead to loss of presentation data
+ if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ {
+ aGroup->SetGroupPrimitivesAspect (anAreaAspect);
+ }
+ if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
+ {
+ aGroup->SetGroupPrimitivesAspect (aLineAspect);
+ }
+ if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
+ {
+ aGroup->SetGroupPrimitivesAspect (aPointAspect);
+ }
+ }
}
- LoadRecomputable(0);
- LoadRecomputable(2);
+ LoadRecomputable (AIS_WireFrame);
+ LoadRecomputable (2);
}
//=======================================================================
//function : UnsetColor
-//purpose :
+//purpose :
//=======================================================================
void AIS_Shape::UnsetColor()
{
- if ( !HasColor() )
+ if (!HasColor())
{
myToRecomputeModes.Clear();
return;
}
hasOwnColor = Standard_False;
- Handle(Prs3d_LineAspect) NullAsp;
- Handle(Prs3d_ShadingAspect) NullShA;
-
- if(!HasWidth()) {
- myDrawer->SetLineAspect(NullAsp);
- myDrawer->SetWireAspect(NullAsp);
- myDrawer->SetFreeBoundaryAspect(NullAsp);
- myDrawer->SetUnFreeBoundaryAspect(NullAsp);
- myDrawer->SetSeenLineAspect(NullAsp);
+ if (!HasWidth())
+ {
+ Handle(Prs3d_LineAspect) anEmptyAsp;
+ myDrawer->SetLineAspect (anEmptyAsp);
+ myDrawer->SetWireAspect (anEmptyAsp);
+ myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
+ myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
+ myDrawer->SetSeenLineAspect (anEmptyAsp);
}
- else {
- Quantity_Color CC;
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
- myDrawer->LineAspect()->SetColor(CC);
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire,CC);
- myDrawer->WireAspect()->SetColor(CC);
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free,CC);
- myDrawer->FreeBoundaryAspect()->SetColor(CC);
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree,CC);
- myDrawer->UnFreeBoundaryAspect()->SetColor(CC);
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC);
- myDrawer->SeenLineAspect()->SetColor(CC);
+ else
+ {
+ Quantity_Color aColor = Quantity_NOC_YELLOW;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
+ }
+ myDrawer->LineAspect()->SetColor (aColor);
+ aColor = Quantity_NOC_RED;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
+ }
+ myDrawer->WireAspect()->SetColor (aColor);
+ aColor = Quantity_NOC_GREEN;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
+ }
+ myDrawer->FreeBoundaryAspect()->SetColor (aColor);
+ aColor = Quantity_NOC_YELLOW;
+ if (myDrawer->HasLink())
+ {
+ AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
+ }
+ myDrawer->UnFreeBoundaryAspect()->SetColor (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());
- if( HasMaterial() ) {
- Quantity_Color color = myDrawer->Link()->ShadingAspect()->Color(myCurrentFacingModel);
- mat.SetColor(color);
+ if (HasMaterial()
+ || IsTransparent())
+ {
+ 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 = aDefaultMat.AmbientColor();
+ if (myDrawer->HasLink())
+ {
+ aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
+ }
+ mat.SetColor (aColor);
}
- if( IsTransparent() ) {
- Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
- mat.SetTransparency(trans);
+ if (IsTransparent())
+ {
+ Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
+ mat.SetTransparency (aTransp);
}
- myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel);
+ myDrawer->ShadingAspect()->SetMaterial (mat ,myCurrentFacingModel);
}
- else {
- myDrawer->SetShadingAspect(NullShA);
+ else
+ {
+ myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
+ myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
- if(!GetContext().IsNull()){
- if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
- Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
- Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
- P->SetPrimitivesAspect(a4bis);
- G->SetGroupPrimitivesAspect(a4bis);
+ // modify shading presentation without re-computation
+ const PrsMgr_Presentations& aPrsList = Presentations();
+ Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
+ Handle(Graphic3d_AspectLine3d) aLineAsp = myDrawer->Link()->LineAspect()->Aspect();
+ for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ {
+ const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
+ if (aPrsModed.Mode() != AIS_Shaded)
+ {
+ continue;
+ }
+
+ 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();
+
+ // Check if aspect of given type is set for the group,
+ // because setting aspect for group with no already set aspect
+ // can lead to loss of presentation data
+ if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ {
+ aGroup->SetGroupPrimitivesAspect (anAreaAsp);
+ }
+ if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
+ {
+ aGroup->SetGroupPrimitivesAspect (aLineAsp);
+ }
}
}
- LoadRecomputable(0);
- LoadRecomputable(2);
+
+ LoadRecomputable (AIS_WireFrame);
+ LoadRecomputable (2);
}
//=======================================================================
-//function : SetWidth
-//purpose :
+//function : setWidth
+//purpose :
//=======================================================================
-void AIS_Shape::SetWidth(const Standard_Real W)
+void AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
+ const Standard_Real theLineWidth) const
{
- if(HasColor() || HasWidth()){
- myDrawer->LineAspect()->SetWidth(W);
- myDrawer->WireAspect()->SetWidth(W);
- myDrawer->FreeBoundaryAspect()->SetWidth(W);
- myDrawer->UnFreeBoundaryAspect()->SetWidth(W);
- myDrawer->SeenLineAspect()->SetWidth(W);
+ if (!theDrawer->HasOwnLineAspect())
+ {
+ theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
+ }
}
- else{
- Quantity_Color CC;
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC);
- myDrawer->SetLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire,CC);
- myDrawer->SetWireAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free,CC);
- myDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree,CC);
- myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
- AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC);
- myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W));
+ if (!theDrawer->HasOwnWireAspect())
+ {
+ theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
+ 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();
+ }
}
- myOwnWidth = W;
- LoadRecomputable(0); // means that it is necessary to recompute only the wireframe....
- LoadRecomputable(2); // and the bounding box...
+
+ // override width
+ theDrawer->LineAspect()->SetWidth (theLineWidth);
+ theDrawer->WireAspect()->SetWidth (theLineWidth);
+ theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
+ theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
+ theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
}
//=======================================================================
-//function : UnsetWidth
+//function : SetWidth
//purpose :
//=======================================================================
+void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
+{
+ setWidth (myDrawer, theLineWidth);
+ myOwnWidth = theLineWidth;
+ LoadRecomputable (AIS_WireFrame); // means that it is necessary to recompute only the wireframe....
+ LoadRecomputable (2); // and the bounding box...
+}
+
+//=======================================================================
+//function : UnsetWidth
+//purpose :
+//=======================================================================
+
void AIS_Shape::UnsetWidth()
{
- if(myOwnWidth == 0.0)
+ if (myOwnWidth == 0.0)
{
myToRecomputeModes.Clear();
return;
}
- myOwnWidth=0.0;
- Handle(Prs3d_LineAspect) NullAsp;
+ myOwnWidth = 0.0;
- if(!HasColor()){
- myDrawer->SetLineAspect(NullAsp);
- myDrawer->SetWireAspect(NullAsp);
- myDrawer->SetFreeBoundaryAspect(NullAsp);
- myDrawer->SetUnFreeBoundaryAspect(NullAsp);
- myDrawer->SetSeenLineAspect(NullAsp);
+ Handle(Prs3d_LineAspect) anEmptyAsp;
+
+ if (!HasColor())
+ {
+ myDrawer->SetLineAspect (anEmptyAsp);
+ myDrawer->SetWireAspect (anEmptyAsp);
+ myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
+ myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
+ myDrawer->SetSeenLineAspect (anEmptyAsp);
}
- 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));
+ else
+ {
+ 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(0);
+ 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
{
- if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
- myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+ 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();
+ }
}
- hasOwnMaterial = Standard_True;
+ theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
- myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
- myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
-
- if(!GetContext().IsNull()){
- if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
- Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
- Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
- P->SetPrimitivesAspect(a4bis);
- G->SetGroupPrimitivesAspect(a4bis);
- }
+ if (theToKeepColor)
+ {
+ theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
+ }
+ if (theToKeepTransp)
+ {
+ theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
}
- myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
- myToRecomputeModes.Clear();
}
//=======================================================================
//purpose :
//=======================================================================
-void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat)
+void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
{
- if( !HasColor() && !IsTransparent() && !HasMaterial() ) {
- myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
- }
+ SetMaterial(Graphic3d_MaterialAspect(aMat));
+}
+
+//=======================================================================
+//function : SetMaterial
+//purpose :
+//=======================================================================
+
+void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
+{
+ setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
hasOwnMaterial = Standard_True;
- myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel);
- myDrawer->ShadingAspect()->SetTransparency(myTransparency,myCurrentFacingModel);
+ // modify shading presentation without re-computation
+ const PrsMgr_Presentations& aPrsList = Presentations();
+ Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
+ for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ {
+ const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
+ if (aPrsModed.Mode() != AIS_Shaded)
+ {
+ continue;
+ }
- if(!GetContext().IsNull()){
- if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
- Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
- Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
- P->SetPrimitivesAspect(a4bis);
- G->SetGroupPrimitivesAspect(a4bis);
+ 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();
+
+ // Check if aspect of given type is set for the group,
+ // because setting aspect for group with no already set aspect
+ // can lead to loss of presentation data
+ if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ {
+ aGroup->SetGroupPrimitivesAspect (anAreaAsp);
+ }
}
}
- myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
- myToRecomputeModes.Clear();
+
+ myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
+ myToRecomputeModes.Clear();
}
//=======================================================================
//function : UnsetMaterial
-//purpose :
+//purpose :
//=======================================================================
void AIS_Shape::UnsetMaterial()
{
- if( !HasMaterial() ) return;
+ if (!HasMaterial())
+ {
+ return;
+ }
- if( HasColor() || IsTransparent()) {
- Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link());
- if( HasColor() ) {
- Quantity_Color color = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
- mat.SetColor(color);
+ if (HasColor()
+ || IsTransparent())
+ {
+ if(myDrawer->HasLink())
+ {
+ myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
+ myCurrentFacingModel);
}
- if( IsTransparent() ) {
- Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
- mat.SetTransparency(trans);
+ if (HasColor())
+ {
+ myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
+ myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
}
- myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel);
- } else {
- Handle(Prs3d_ShadingAspect) SA;
- myDrawer->SetShadingAspect(SA);
+ }
+ else
+ {
+ myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
}
hasOwnMaterial = Standard_False;
- if(!GetContext().IsNull()){
- if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
- Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
- Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
- P->SetPrimitivesAspect(a4bis);
- G->SetGroupPrimitivesAspect(a4bis);
+ // modify shading presentation without re-computation
+ const PrsMgr_Presentations& aPrsList = Presentations();
+ Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
+ for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ {
+ const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
+ if (aPrsModed.Mode() != AIS_Shaded)
+ {
+ continue;
+ }
+
+ 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 (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ {
+ aGroup->SetGroupPrimitivesAspect (anAreaAsp);
+ }
}
}
- myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
+
+ myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear();
}
//=======================================================================
-//function : SetTransparency
-//purpose :
+//function : setTransparency
+//purpose :
//=======================================================================
-void AIS_Shape::SetTransparency(const Standard_Real AValue)
+void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
+ const Standard_Real theValue) const
{
- if ( !HasColor() && !HasMaterial() ) {
- myDrawer->SetShadingAspect(new Prs3d_ShadingAspect());
+ if (!theDrawer->HasOwnShadingAspect())
+ {
+ theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
+ }
}
- myDrawer->ShadingAspect()->SetTransparency(AValue,myCurrentFacingModel);
- myTransparency = AValue;
-
- if(!GetContext().IsNull()){
- if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
- Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
- Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
- P->SetPrimitivesAspect(a4bis);
-#ifdef BUC60918 //force highest priority for transparent objects
- P->SetDisplayPriority(10);
-#endif
- G->SetGroupPrimitivesAspect(a4bis);
+
+ // override transparency
+ theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
+}
+
+//=======================================================================
+//function : SetTransparency
+//purpose :
+//=======================================================================
+
+void AIS_Shape::SetTransparency (const Standard_Real theValue)
+{
+ setTransparency (myDrawer, theValue);
+ myTransparency = theValue;
+
+ // modify shading presentation without re-computation
+ const PrsMgr_Presentations& aPrsList = Presentations();
+ Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
+ for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ {
+ const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
+ if (aPrsModed.Mode() != AIS_Shaded)
+ {
+ continue;
+ }
+
+ 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();
+ if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ {
+ aGroup->SetGroupPrimitivesAspect (anAreaAsp);
+ }
}
}
- myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
+
+ myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
myToRecomputeModes.Clear();
}
//=======================================================================
//function : UnsetTransparency
-//purpose :
+//purpose :
//=======================================================================
void AIS_Shape::UnsetTransparency()
{
- if( HasColor() || HasMaterial() ) {
- myDrawer->ShadingAspect()->SetTransparency(0.0,myCurrentFacingModel);
- } else {
- Handle(Prs3d_ShadingAspect) SA;
- myDrawer->SetShadingAspect(SA);
- }
myTransparency = 0.0;
+ if (!myDrawer->HasOwnShadingAspect())
+ {
+ return;
+ }
+ else if (HasColor() || HasMaterial())
+ {
+ myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
+ }
+ else
+ {
+ myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
+ }
- if(!GetContext().IsNull()){
- if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){
- Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation();
- Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P);
- Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
- P->SetPrimitivesAspect(a4bis);
- G->SetGroupPrimitivesAspect(a4bis);
-#ifdef BUC60918
- P->ResetDisplayPriority();
-#endif
+ // modify shading presentation without re-computation
+ const PrsMgr_Presentations& aPrsList = Presentations();
+ Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
+ for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+ {
+ const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
+ if (aPrsModed.Mode() != AIS_Shaded)
+ {
+ continue;
+ }
+
+ 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 (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
+ {
+ aGroup->SetGroupPrimitivesAspect (anAreaAsp);
+ }
}
+ aPrs->ResetDisplayPriority();
}
- myRecomputeEveryPrs =Standard_False; // no mode to recalculate :only viewer update
+
+ myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
myToRecomputeModes.Clear();
}
const Bnd_Box& AIS_Shape::BoundingBox()
{
if (myshape.ShapeType() == TopAbs_COMPOUND) {
-#ifdef BUC60547
TopoDS_Iterator anExplor (myshape);
-#else
- TopExp_Explorer anExplor (myshape, TopAbs_VERTEX);
-#endif
+
if (!anExplor.More()) { // empty Shape -> empty Assembly.
- myBB.SetVoid();
+ myBB.SetVoid();
return myBB;
}
}
if(myCompBB) {
BRepBndLib::AddClose(myshape, myBB);
- myCompBB = Standard_False;
+ myCompBB = Standard_False;
}
return myBB;
}
Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
{
- Standard_Boolean itSet = myDrawer->IsOwnDeviationCoefficient();
+ Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
if(itSet) myDrawer->SetDeviationCoefficient();
return itSet;
-
}
-
//=======================================================================
//function : SetHLROwnDeviationCoefficient
//purpose : resets myhasOwnHLRDeviationCoefficient to Standard_False and
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;
Standard_Real OutAngl,OutDefl;
HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
SetOwnDeviationAngle(anAngle) ;
-// SetOwnDeviationAngle(OutAngl) ;
SetOwnDeviationCoefficient(OutDefl) ;
myInitAng = anAngle;
SetToUpdate(0);
{
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();
}