-// File: XCAFPrs_AISObject.cxx
-// Created: Fri Aug 11 16:49:09 2000
-// Author: Andrey BETENEV
-
-#include <XCAFPrs_AISObject.ixx>
-#include <TCollection_ExtendedString.hxx>
-#include <gp_Pnt.hxx>
-#include <Prs3d_Text.hxx>
-#include <Prs3d_LengthAspect.hxx>
-#include <XCAFDoc_ShapeTool.hxx>
-
-#include <Standard_ErrorHandler.hxx>
-#include <Standard_Failure.hxx>
-
-#include <Precision.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <BRepTools.hxx>
-
-#include <StdPrs_WFDeflectionShape.hxx>
-#include <StdPrs_ShadedShape.hxx>
-#include <StdPrs_WFShape.hxx>
-#include <AIS_Drawer.hxx>
-#include <Graphic3d_Array1OfVertex.hxx>
-#include <Graphic3d_Group.hxx>
-#include <Quantity_Color.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Graphic3d_AspectLine3d.hxx>
+// Created on: 2000-08-11
+// Created by: Andrey BETENEV
+// Copyright (c) 2000-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 <XCAFPrs_AISObject.hxx>
+
+#include <AIS_DisplayMode.hxx>
#include <BRep_Builder.hxx>
-#include <TopoDS_Compound.hxx>
-#include <XCAFPrs_Style.hxx>
-#include <TopoDS_Shape.hxx>
-#include <XCAFPrs_DataMapOfShapeStyle.hxx>
-#include <TDF_LabelSequence.hxx>
-#include <XCAFPrs_DataMapOfStyleShape.hxx>
-#include <TopoDS.hxx>
-#include <XCAFPrs_DataMapIteratorOfDataMapOfStyleShape.hxx>
+#include <BRepBndLib.hxx>
+#include <gp_Pnt.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Aspect_InteriorStyle.hxx>
-#include <Aspect_TypeOfLine.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_DimensionAspect.hxx>
#include <Prs3d_IsoAspect.hxx>
-#include <XCAFPrs.hxx>
-
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_Text.hxx>
#include <TDataStd_Name.hxx>
-#include <BRepBndLib.hxx>
-
+#include <TDF_LabelSequence.hxx>
#include <TPrsStd_AISPresentation.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFPrs.hxx>
+#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
+#include <XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle.hxx>
+#include <XCAFPrs_Style.hxx>
-#ifdef DEBUG
-#include <DBRep.hxx>
-#endif
+IMPLEMENT_STANDARD_RTTIEXT(XCAFPrs_AISObject,AIS_ColoredShape)
//=======================================================================
//function : XCAFPrs_AISObject
//purpose :
//=======================================================================
-XCAFPrs_AISObject::XCAFPrs_AISObject (const TDF_Label &lab) : AIS_Shape(TopoDS_Shape())
-{
- myLabel = lab;
-
- TopoDS_Shape shape;
- if ( XCAFDoc_ShapeTool::GetShape ( myLabel, shape ) && ! shape.IsNull() )
- Set ( shape );
-}
-
-//=======================================================================
-//function : SetColor
-//purpose :
-//=======================================================================
-
-void XCAFPrs_AISObject::SetColor(const Quantity_Color &aCol)
-{
- AIS_Shape::SetColor(aCol);
- LoadRecomputable(1);
-}
-
-//=======================================================================
-//function : UnsetColor
-//purpose :
-//=======================================================================
-
-void XCAFPrs_AISObject::UnsetColor()
-{
- if (HasColor())
- {
- AIS_Shape::UnsetColor();
- LoadRecomputable(1);
- }
- else
- {
- myToRecomputeModes.Clear();
- }
-}
-
-//=======================================================================
-//function : SetMaterial
-//purpose :
-//=======================================================================
-
-void XCAFPrs_AISObject::SetMaterial(const Graphic3d_NameOfMaterial aMat)
+XCAFPrs_AISObject::XCAFPrs_AISObject (const TDF_Label& theLabel)
+: AIS_ColoredShape(TopoDS_Shape()),
+ myToSyncStyles (Standard_True)
{
- 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 :
-//=======================================================================
+ // define plastic material by default for proper color reproduction
+ setMaterial (myDrawer, Graphic3d_NOM_PLASTIC, Standard_False, Standard_False);
+ hasOwnMaterial = Standard_True;
-void XCAFPrs_AISObject::UnsetTransparency()
-{
- AIS_Shape::UnsetTransparency();
- LoadRecomputable(1);
-}
-
-//=======================================================================
-//function : DisplayBox
-//purpose :
-//=======================================================================
-
-static void DisplayBox(const Handle(Prs3d_Presentation)& aPrs,
- const Bnd_Box& B,
- const Handle(Prs3d_Drawer)& aDrawer)
-{
- Standard_Real X[2],Y[2],Z[2];
- Standard_Integer Indx [16] ;
- if ( B.IsVoid() )
- return;
-
-#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();
-}
-
-//=======================================================================
-//function : AddStyledItem
-//purpose :
-//=======================================================================
-
-void XCAFPrs_AISObject::AddStyledItem (const XCAFPrs_Style &style,
- const TopoDS_Shape &shape,
- const Handle(PrsMgr_PresentationManager3d)&, // aPresentationManager,
- const Handle(Prs3d_Presentation)& aPrs,
- const Standard_Integer aMode)
-{
- // remember current color settings
- Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect();
- Aspect_InteriorStyle aStyle;
- Quantity_Color aIntColor, aEdgeColor;
- Aspect_TypeOfLine aType;
- Standard_Real aWidth;
- a4bis->Values(aStyle,aIntColor,aEdgeColor,aType,aWidth);
- Graphic3d_MaterialAspect FMAT = a4bis->FrontMaterial();
- Quantity_Color aFColor = FMAT.Color();
-
- Quantity_Color aColor1, aColor2;
- Aspect_TypeOfLine aLine1, aLine2;
- Standard_Real aWigth1, aWigth2;
- Handle(Prs3d_LineAspect) waUFB = myDrawer->UnFreeBoundaryAspect();
- waUFB->Aspect()->Values(aColor1,aLine1,aWigth1);
- Handle(Prs3d_LineAspect) waFB = myDrawer->FreeBoundaryAspect();
- waFB->Aspect()->Values(aColor2,aLine2,aWigth2);
-
- Quantity_Color aColor;
- Aspect_TypeOfLine aLine;
- Standard_Real aWigth;
- Handle(Prs3d_LineAspect) wa = myDrawer->WireAspect();
- wa->Aspect()->Values(aColor,aLine,aWigth);
-
- Quantity_Color aColorU, aColorV;
- Aspect_TypeOfLine aLineU, aLineV;
- Standard_Real aWigthU, aWigthV;
- Handle(Prs3d_IsoAspect) UIso = myDrawer->UIsoAspect();
- Handle(Prs3d_IsoAspect) VIso = myDrawer->VIsoAspect();
- UIso->Aspect()->Values(aColorU,aLineU,aWigthU);
- VIso->Aspect()->Values(aColorV,aLineV,aWigthV);
-
- // Set colors etc. for current shape according to style
- if ( style.IsSetColorCurv() ) {
- Quantity_Color Color = style.GetColorCurv();
- waUFB->SetColor ( Color.Name() );
- waFB->SetColor ( Color.Name() );
- wa->SetColor ( Color.Name() );
- }
- if ( style.IsSetColorSurf() ) {
- Quantity_Color Color = style.GetColorSurf();
- a4bis->SetInteriorColor(Color);
- FMAT.SetColor(Color);
- a4bis->SetFrontMaterial(FMAT);
- UIso->SetColor ( Color.Name() );
- VIso->SetColor ( Color.Name() );
- }
-
- // force drawing isos on planes
- Standard_Boolean drawIsosPln = myDrawer->IsoOnPlane();
- myDrawer->SetIsoOnPlane (Standard_True);
-
- // add shape to presentation
- switch (aMode) {
- case 0:{
- try { OCC_CATCH_SIGNALS StdPrs_WFDeflectionShape::Add(aPrs,shape,myDrawer); }
- catch (Standard_Failure) {
-#ifdef DEB
- cout << "AIS_Shape::Compute() failed: exception " <<
- Standard_Failure::Caught()->DynamicType()->Name() << ": " <<
- Standard_Failure::Caught()->GetMessageString() << endl;
-#endif
-// cout << "a Shape should be incorrect: No Compute can be maked on it "<< endl;
-// on calcule une presentation de la boite englobante
-// Compute(aPresentationManager,aPrs,2);
- }
- break;
- }
- 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(shape);
- }
-
- //shading seulement a partir de face...
- try {
- OCC_CATCH_SIGNALS
- if ((Standard_Integer) shape.ShapeType()>4)
- StdPrs_WFDeflectionShape::Add(aPrs,shape,myDrawer);
- else {
- myDrawer->SetShadingAspectGlobal(Standard_False);
- if (IsInfinite())
- StdPrs_WFDeflectionShape::Add(aPrs,shape,myDrawer);
- else
- StdPrs_ShadedShape::Add(aPrs,shape,myDrawer);
- }
- }
- catch (Standard_Failure) {
-#ifdef DEB
- cout << "AIS_Shape::Compute() in ShadingMode failed: exception " <<
- Standard_Failure::Caught()->DynamicType()->Name() << ": " <<
- Standard_Failure::Caught()->GetMessageString() << endl;
-#endif
- // last resort: try to display as wireframe
- try {
- OCC_CATCH_SIGNALS
- StdPrs_WFShape::Add(aPrs,shape,myDrawer);
- }
- catch (Standard_Failure) {
- }
- }
- break;
- }
- case 2:
- {
- // boite englobante
- if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,shape,myDrawer);
- else DisplayBox(aPrs,BoundingBox(),myDrawer);
- }
- }
-
- // Restore initial settings
- if ( style.IsSetColorCurv() ) {
- waUFB->SetColor ( aColor1.Name() );
- waFB->SetColor ( aColor2.Name() );
- wa->SetColor ( aColor.Name() );
- }
- if ( style.IsSetColorSurf() ) {
- a4bis->SetInteriorColor(aIntColor);
- FMAT.SetColor(aFColor);
- a4bis->SetFrontMaterial(FMAT);
- UIso->SetColor ( aColorU );
- VIso->SetColor ( aColorV );
- }
- myDrawer->SetIsoOnPlane (drawIsosPln);
+ myLabel = theLabel;
}
//=======================================================================
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
aBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
gp_Pnt aPnt (0.5 * (aXmin + aXmax), 0.5 * (aYmin + aYmax), 0.5 * (aZmin + aZmax));
- Prs3d_Text::Draw( aPrs, anAspect, aName->Get(), aPnt);
+ Prs3d_Text::Draw (Prs3d_Root::CurrentGroup (aPrs), anAspect, aName->Get(), aPnt);
}
}
}
}
}
}
-
+
+//=======================================================================
+//function : DispatchStyles
+//purpose :
+//=======================================================================
+void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
+{
+ myToSyncStyles = theToSyncStyles;
+ myShapeColors.Clear();
+
+ TopoDS_Shape aShape;
+ if (!XCAFDoc_ShapeTool::GetShape (myLabel, aShape) || aShape.IsNull())
+ {
+ Set (TopoDS_Shape());
+ return;
+ }
+ Set (aShape);
+
+ // Collecting information on colored subshapes
+ TopLoc_Location aLoc;
+ XCAFPrs_IndexedDataMapOfShapeStyle aSettings;
+ XCAFPrs::CollectStyleSettings (myLabel, aLoc, aSettings);
+
+ // Getting default colors
+ XCAFPrs_Style aDefStyle;
+ DefaultStyle (aDefStyle);
+ Quantity_Color aColorCurv = aDefStyle.GetColorCurv();
+ Quantity_ColorRGBA aColorSurf = aDefStyle.GetColorSurfRGBA();
+
+ SetColors (myDrawer, aColorCurv, aColorSurf);
+
+ // collect sub-shapes with the same style into compounds
+ BRep_Builder aBuilder;
+ NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style> aStyleGroups;
+ for (XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle aStyledShapeIter (aSettings);
+ aStyledShapeIter.More(); aStyledShapeIter.Next())
+ {
+ TopoDS_Compound aComp;
+ if (aStyleGroups.FindFromKey (aStyledShapeIter.Value(), aComp))
+ {
+ aBuilder.Add (aComp, aStyledShapeIter.Key());
+ continue;
+ }
+
+ aBuilder.MakeCompound (aComp);
+ aBuilder.Add (aComp, aStyledShapeIter.Key());
+ TopoDS_Compound* aMapShape = aStyleGroups.ChangeSeek (aStyledShapeIter.Value());
+ if (aMapShape == NULL)
+ aStyleGroups.Add (aStyledShapeIter.Value(), aComp);
+ else
+ *aMapShape = aComp;
+ }
+ aSettings.Clear();
+
+ // assign custom aspects
+ for (NCollection_IndexedDataMap<XCAFPrs_Style, TopoDS_Compound, XCAFPrs_Style>::Iterator aStyleGroupIter (aStyleGroups);
+ aStyleGroupIter.More(); aStyleGroupIter.Next())
+ {
+ const TopoDS_Compound& aComp = aStyleGroupIter.Value();
+ TopoDS_Iterator aShapeIter (aComp);
+ TopoDS_Shape aShapeCur = aShapeIter.Value();
+ aShapeIter.Next();
+ if (aShapeIter.More())
+ {
+ aShapeCur = aComp;
+ }
+
+ Handle(AIS_ColoredDrawer) aDrawer = new AIS_ColoredDrawer (myDrawer);
+ myShapeColors.Bind (aShapeCur, aDrawer);
+ const XCAFPrs_Style& aStyle = aStyleGroupIter.Key();
+ aDrawer->SetHidden (!aStyle.IsVisible());
+
+ aColorCurv = aStyle.IsSetColorCurv() ? aStyle.GetColorCurv() : aDefStyle.GetColorCurv();
+ aColorSurf = aStyle.IsSetColorSurf() ? aStyle.GetColorSurfRGBA() : aDefStyle.GetColorSurfRGBA();
+
+ SetColors (aDrawer, aColorCurv, aColorSurf);
+ }
+ aStyleGroups.Clear();
+}
+
//=======================================================================
//function : Compute
-//purpose :
+//purpose :
//=======================================================================
-// The Compute() method is copied from AIS_Shape::Compute and enhanced to
-// support different color settings for different subshapes of a single shape
-
-void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
- const Handle(Prs3d_Presentation)& aPrs,
- const Standard_Integer aMode)
-{
-#ifdef DEB
- //cout << "XCAFPrs_AISObject: Update called" << endl;
-#endif
- aPrs->Clear();
-
- // abv: 06 Mar 00: to have good colors
- Handle(TPrsStd_AISPresentation) prs = Handle(TPrsStd_AISPresentation)::DownCast ( GetOwner() );
- if ( prs.IsNull() || !prs->HasOwnMaterial() )
- AIS_Shape::SetMaterial ( Graphic3d_NOM_PLASTIC );
-
- TopoDS_Shape shape;
- if ( ! XCAFDoc_ShapeTool::GetShape ( myLabel, shape ) || shape.IsNull() ) return;
-
- // wire,edge,vertex -> pas de HLR + priorite display superieure
- Standard_Integer TheType = (Standard_Integer)shape.ShapeType();
- if(TheType>4 && TheType<8) {
- aPrs->SetVisual(Graphic3d_TOS_ALL);
- aPrs->SetDisplayPriority(TheType+2);
+void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePrs,
+ const Standard_Integer theMode)
+{
+ // update shape and sub-shapes styles only on first compute, or on first recompute
+ if (myToSyncStyles)
+ {
+ Standard_Boolean toMapStyles = myToSyncStyles;
+ for (PrsMgr_Presentations::Iterator aPrsIter (myPresentations); aPrsIter.More(); aPrsIter.Next())
+ {
+ if (aPrsIter.Value() != thePrs
+ && !aPrsIter.Value()->MustBeUpdated())
+ {
+ toMapStyles = Standard_False;
+ break;
+ }
+ }
+ if (toMapStyles)
+ {
+ DispatchStyles (Standard_True);
+ }
+ }
+ if (myshape.IsNull())
+ {
+ return;
}
- // Shape vide -> Assemblage vide.
- if (shape.ShapeType() == TopAbs_COMPOUND) {
- TopoDS_Iterator anExplor (shape);
- if (!anExplor.More()) {
+
+ if (myshape.ShapeType() == TopAbs_COMPOUND)
+ {
+ if (myshape.NbChildren() == 0)
+ {
return;
}
}
- if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL
-
- // collect information on colored subshapes
- TopLoc_Location L;
- XCAFPrs_DataMapOfShapeStyle settings;
- XCAFPrs::CollectStyleSettings ( myLabel, L, settings );
-#ifdef DEB
- //cout << "Styles collected" << endl;
-#endif
-
- // dispatch (sub)shapes by their styles
- XCAFPrs_DataMapOfStyleShape items;
- XCAFPrs_Style DefStyle;
- Quantity_Color White ( Quantity_NOC_WHITE );
- DefStyle.SetColorSurf ( White );
- DefStyle.SetColorCurv ( White );
- XCAFPrs::DispatchStyles ( shape, settings, items, DefStyle );
-#ifdef DEB
- //cout << "Dispatch done" << endl;
-#endif
-
- // add subshapes to presentation (one shape per style)
- XCAFPrs_DataMapIteratorOfDataMapOfStyleShape it ( items );
-#ifdef DEB
- //Standard_Integer i=1;
-#endif
- for ( ; it.More(); it.Next() ) {
- XCAFPrs_Style s = it.Key();
-#ifdef DEB
- //cout << "Style " << i << ": [" <<
- // ( s.IsSetColorSurf() ? Quantity_Color::StringName ( s.GetColorSurf().Name() ) : "" ) << ", " <<
- // ( s.IsSetColorCurv() ? Quantity_Color::StringName ( s.GetColorCurv().Name() ) : "" ) << "]" <<
- //" --> si_" << i << ( s.IsVisible() ? "" : " <invisible>" ) << endl;
- //i++;
-#endif
- if (! s.IsVisible() ) continue;
- AddStyledItem ( s, it.Value(), aPresentationManager, aPrs, aMode );
+
+ AIS_ColoredShape::Compute (thePresentationManager, thePrs, theMode);
+
+ if (XCAFPrs::GetViewNameMode())
+ {
+ // Displaying Name attributes
+ thePrs->SetDisplayPriority (10);
+ DisplayText (myLabel, thePrs, Attributes()->DimensionAspect()->TextAspect(), TopLoc_Location());//no location
}
-
- if ( XCAFPrs::GetViewNameMode() ) {
- // Displaying Name attributes
-#ifdef DEB
- //cout << "Now display name of shapes" << endl;
-#endif
- aPrs->SetDisplayPriority(10);
- DisplayText (myLabel, aPrs, Attributes()->LengthAspect()->TextAspect(), TopLoc_Location());//no location
+}
+
+//=======================================================================
+//function : SetColors
+//purpose :
+//=======================================================================
+void XCAFPrs_AISObject::SetColors (const Handle(Prs3d_Drawer)& theDrawer,
+ const Quantity_Color& theColorCurv,
+ const Quantity_ColorRGBA& theColorSurf)
+{
+ if (!theDrawer->HasOwnShadingAspect())
+ {
+ theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
+ }
}
-#ifdef DEB
- //cout << "Compute finished" << endl;
-#endif
-
- aPrs->ReCompute(); // for hidden line recomputation if necessary...
+ 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->HasOwnUIsoAspect())
+ {
+ theDrawer->SetUIsoAspect (new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5, 1));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->UIsoAspect()->Aspect() = *theDrawer->Link()->UIsoAspect()->Aspect();
+ theDrawer->UIsoAspect()->SetNumber (theDrawer->Link()->UIsoAspect()->Number());
+ }
+ }
+ if (!theDrawer->HasOwnVIsoAspect())
+ {
+ theDrawer->SetVIsoAspect (new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5, 1));
+ if (theDrawer->HasLink())
+ {
+ *theDrawer->VIsoAspect()->Aspect() = *theDrawer->Link()->VIsoAspect()->Aspect();
+ theDrawer->VIsoAspect()->SetNumber (theDrawer->Link()->VIsoAspect()->Number());
+ }
+ }
+ 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();
+ }
+ }
+
+ theDrawer->UnFreeBoundaryAspect()->SetColor (theColorCurv);
+ theDrawer->FreeBoundaryAspect()->SetColor (theColorCurv);
+ theDrawer->WireAspect()->SetColor (theColorCurv);
+
+ Graphic3d_MaterialAspect aMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
+ aMaterial.SetColor (theColorSurf.GetRGB());
+ aMaterial.SetAlpha (theColorSurf.Alpha());
+ theDrawer->ShadingAspect()->Aspect()->SetInteriorColor (theColorSurf);
+ theDrawer->ShadingAspect()->Aspect()->SetFrontMaterial (aMaterial);
+ theDrawer->UIsoAspect()->SetColor (theColorSurf.GetRGB());
+ theDrawer->VIsoAspect()->SetColor (theColorSurf.GetRGB());
+}
+
+//=======================================================================
+//function : DefaultStyle
+//purpose : DefaultStyle() can be redefined by subclasses in order to set custom default style
+//=======================================================================
+void XCAFPrs_AISObject::DefaultStyle (XCAFPrs_Style& theStyle) const
+{
+ theStyle.SetColorSurf (Quantity_NOC_WHITE);
+ theStyle.SetColorCurv (Quantity_NOC_WHITE);
+}
+
+// =======================================================================
+// function : SetMaterial
+// purpose :
+// =======================================================================
+void XCAFPrs_AISObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
+{
+ XCAFPrs_Style aDefStyle;
+ DefaultStyle (aDefStyle);
+ setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
+ SetColors (myDrawer, aDefStyle.GetColorCurv(), aDefStyle.GetColorSurf());
+ for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
+ {
+ const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
+
+ // take current color
+ const Quantity_Color aColorCurv = aDrawer->WireAspect()->Aspect()->Color();
+ const Quantity_ColorRGBA aSurfColor = aDrawer->ShadingAspect()->Aspect()->InteriorColorRGBA();
+
+ // SetColors() will take the material from myDrawer
+ SetColors (aDrawer, aColorCurv, aSurfColor);
+ }
+ SynchronizeAspects();
}