From 74618acf3df160fa1b95bfb43bc16c019a99717d Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 10 Jul 2014 14:43:56 +0400 Subject: [PATCH] 0025010: Use AIS_ColoredShape for display of XCAF documents Added methods HasUIsoAspect and HasVIsoAspect to AIS_Drawer XCAFPrs_AISObject has been converted to non-cdl class XCAFPrs_AISObject now inherits from AIS_ColoredShape XCAFPrs_AISObject::Compute method has been rewritten in accordance with the new inheritance. Regression fix --- src/AIS/AIS_Drawer.cdl | 24 +- src/AIS/AIS_Drawer.lxx | 20 ++ src/XCAFPrs/FILES | 2 + src/XCAFPrs/XCAFPrs.cdl | 2 +- src/XCAFPrs/XCAFPrs_AISObject.cdl | 74 ----- src/XCAFPrs/XCAFPrs_AISObject.cxx | 494 ++++++++---------------------- src/XCAFPrs/XCAFPrs_AISObject.hxx | 60 ++++ 7 files changed, 226 insertions(+), 450 deletions(-) create mode 100644 src/XCAFPrs/FILES delete mode 100644 src/XCAFPrs/XCAFPrs_AISObject.cdl create mode 100644 src/XCAFPrs/XCAFPrs_AISObject.hxx diff --git a/src/AIS/AIS_Drawer.cdl b/src/AIS/AIS_Drawer.cdl index bb17178866..e04b215297 100644 --- a/src/AIS/AIS_Drawer.cdl +++ b/src/AIS/AIS_Drawer.cdl @@ -264,6 +264,10 @@ is is redefined static; + HasUIsoAspect (me) returns Boolean from Standard + ---Purpose: Returns true if the Drawer has a UIso aspect setting active. + ---C++: inline + is static; -- Attributes for the V Isoparametric line of patches. @@ -282,7 +286,11 @@ is -- Prs3d_WFDeflectionSurface -- Prs3d_WFDeflectionRestrictedFace is redefined static; - + + HasVIsoAspect (me) returns Boolean from Standard + ---Purpose: Returns true if the Drawer has a VIso aspect setting active. + ---C++: inline + is static; -- Attributes for the free boundaries @@ -296,8 +304,12 @@ is -- Type of line: Aspect_TOL_SOLID Width: 1. -- These attributes are used by Prs3d_WFShape. is redefined static; - - + + HasFreeBoundaryAspect (me) returns Boolean from Standard + ---Purpose: Returns true if the Drawer has a free boundary aspect setting active. + ---C++: inline + is static; + FreeBoundaryDraw(me) returns Boolean from Standard ---Purpose: returns True if the drawing of the free boundaries is enabled. is redefined static; @@ -349,7 +361,11 @@ is -- Prs3d_WFShape is redefined static; - + HasUnFreeBoundaryAspect (me) returns Boolean from Standard + ---Purpose: Returns true if the Drawer has an unfree boundary aspect setting active. + ---C++: inline + is static; + UnFreeBoundaryDraw(me) returns Boolean from Standard ---Purpose: Returns True if the drawing of the shared boundaries -- is enabled. True is the default setting. diff --git a/src/AIS/AIS_Drawer.lxx b/src/AIS/AIS_Drawer.lxx index fab6a2f019..aab6b9bd23 100644 --- a/src/AIS/AIS_Drawer.lxx +++ b/src/AIS/AIS_Drawer.lxx @@ -129,6 +129,26 @@ inline Standard_Boolean AIS_Drawer::HasPlaneAspect() const return !myPlaneAspect.IsNull(); } +inline Standard_Boolean AIS_Drawer::HasUIsoAspect() const +{ + return !myUIsoAspect.IsNull(); +} + +inline Standard_Boolean AIS_Drawer::HasVIsoAspect() const +{ + return !myVIsoAspect.IsNull(); +} + +inline Standard_Boolean AIS_Drawer::HasFreeBoundaryAspect() const +{ + return !myFreeBoundaryAspect.IsNull(); +} + +inline Standard_Boolean AIS_Drawer::HasUnFreeBoundaryAspect() const +{ + return !myUnFreeBoundaryAspect.IsNull(); +} + inline Standard_Boolean AIS_Drawer::IsOwnFaceBoundaryDraw() const { return myHasOwnFaceBoundaryDraw; diff --git a/src/XCAFPrs/FILES b/src/XCAFPrs/FILES new file mode 100644 index 0000000000..8416032261 --- /dev/null +++ b/src/XCAFPrs/FILES @@ -0,0 +1,2 @@ +XCAFPrs_AISObject.hxx +XCAFPrs_AISObject.cxx diff --git a/src/XCAFPrs/XCAFPrs.cdl b/src/XCAFPrs/XCAFPrs.cdl index 5871cfd0be..f5c2c8802e 100644 --- a/src/XCAFPrs/XCAFPrs.cdl +++ b/src/XCAFPrs/XCAFPrs.cdl @@ -37,7 +37,7 @@ is class Driver; - class AISObject; + imported AISObject; class Style; diff --git a/src/XCAFPrs/XCAFPrs_AISObject.cdl b/src/XCAFPrs/XCAFPrs_AISObject.cdl deleted file mode 100644 index debf2c7ff1..0000000000 --- a/src/XCAFPrs/XCAFPrs_AISObject.cdl +++ /dev/null @@ -1,74 +0,0 @@ --- 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. - -class AISObject from XCAFPrs inherits Shape from AIS - - ---Purpose: Implements AIS_InteractiveObject functionality - -- for shape in DECAF document - -uses - Shape from TopoDS, - PresentationManager3d from PrsMgr, - Presentation from Prs3d, - Label from TDF, - Color from Quantity, - NameOfMaterial from Graphic3d, - MaterialAspect from Graphic3d, - Style from XCAFPrs - -is - - Create (lab: Label from TDF); - ---Purpose: Creates an object to visualise the shape label - - SetColor(me:mutable;aColor:Color from Quantity) is redefined virtual; - - UnsetColor(me:mutable) is redefined virtual; - - SetMaterial(me:mutable;aName:NameOfMaterial from Graphic3d) is redefined virtual; - - SetMaterial(me:mutable;aName:MaterialAspect from Graphic3d) is redefined virtual; - - UnsetMaterial(me:mutable) is redefined virtual; - - SetTransparency(me:mutable;aValue : Real from Standard=0.6) is redefined virtual; - - UnsetTransparency(me:mutable) is redefined virtual; - - AddStyledItem (me: mutable; style: Style from XCAFPrs; - shape: Shape from TopoDS; - aPresentationManager : PresentationManager3d from PrsMgr; - aPresentation : Presentation from Prs3d; - aMode : Integer from Standard = 0) - is private; - - Compute (me : mutable; - aPresentationManager : PresentationManager3d from PrsMgr; - aPresentation : Presentation from Prs3d; - aMode : Integer from Standard = 0) - is redefined virtual protected; - ---Purpose: Redefined method to compute presentation - - DefaultStyle (me; - aStyle: out Style from XCAFPrs) - is virtual protected; - ---Purpose: Fills out a default style object which is used when styles are - -- not explicitly defined in the document. - -- By default, the style uses white color for curves and surfaces. - -fields - myLabel : Label from TDF; - -end AISObject; diff --git a/src/XCAFPrs/XCAFPrs_AISObject.cxx b/src/XCAFPrs/XCAFPrs_AISObject.cxx index 0204f15cb8..7848c231f2 100644 --- a/src/XCAFPrs/XCAFPrs_AISObject.cxx +++ b/src/XCAFPrs/XCAFPrs_AISObject.cxx @@ -13,311 +13,40 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include -#include -#include -#include -#include -#include +#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include +#include #include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include -#ifdef DEBUG -#include -#endif - +IMPLEMENT_STANDARD_HANDLE (XCAFPrs_AISObject, AIS_ColoredShape) +IMPLEMENT_STANDARD_RTTIEXT(XCAFPrs_AISObject, AIS_ColoredShape) //======================================================================= //function : XCAFPrs_AISObject //purpose : //======================================================================= -XCAFPrs_AISObject::XCAFPrs_AISObject (const TDF_Label &lab) : AIS_Shape(TopoDS_Shape()) +XCAFPrs_AISObject::XCAFPrs_AISObject (const TDF_Label& theLabel) +: AIS_ColoredShape(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) -{ - AIS_Shape::SetMaterial(aMat); - LoadRecomputable(1); -} - -//======================================================================= -//function : SetMaterial -//purpose : -//======================================================================= - -void XCAFPrs_AISObject::SetMaterial(const Graphic3d_MaterialAspect& aMat) -{ - AIS_Shape::SetMaterial(aMat); - LoadRecomputable(1); -} - -//======================================================================= -//function : UnsetMaterial -//purpose : -//======================================================================= - -void XCAFPrs_AISObject::UnsetMaterial() -{ - if (HasMaterial()) - { - AIS_Shape::UnsetMaterial(); - LoadRecomputable(1); - } - else - { - myToRecomputeModes.Clear(); - } -} - -//======================================================================= -//function : SetTransparency -//purpose : -//======================================================================= - -void XCAFPrs_AISObject::SetTransparency(const Standard_Real AValue) -{ - AIS_Shape::SetTransparency(AValue); - LoadRecomputable(1); -} - -//======================================================================= -//function : UnsetTransparency -//purpose : -//======================================================================= - -void XCAFPrs_AISObject::UnsetTransparency() -{ - AIS_Shape::UnsetTransparency(); - LoadRecomputable(1); -} - -//======================================================================= -//function : 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 ; - - Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle(newangle,prevangle); - Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(newcoeff,prevcoeff); - if (((Abs (newangle - prevangle) > Precision::Angular()) && isOwnDeviationAngle) || - ((Abs (newcoeff - prevcoeff) > Precision::Confusion()) && isOwnDeviationCoefficient)) { -#ifdef DEB - cout << "AIS_Shape : compute"<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; } //======================================================================= @@ -377,104 +106,127 @@ static void DisplayText (const TDF_Label& aLabel, } } } - + //======================================================================= //function : Compute //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(); +void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePrs, + const Standard_Integer theMode) +{ + thePrs->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 ); + Handle(TPrsStd_AISPresentation) aPrs = Handle(TPrsStd_AISPresentation)::DownCast (GetOwner()); + if (aPrs.IsNull() || !aPrs->HasOwnMaterial()) SetMaterial (Graphic3d_NOM_PLASTIC); - TopoDS_Shape shape; - if ( ! XCAFDoc_ShapeTool::GetShape ( myLabel, shape ) || shape.IsNull() ) return; + TopoDS_Shape aShape; + if (!XCAFDoc_ShapeTool::GetShape (myLabel, aShape) || aShape.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); - } // Shape vide -> Assemblage vide. - if (shape.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator anExplor (shape); - if (!anExplor.More()) { + if (aShape.ShapeType() == TopAbs_COMPOUND) + { + TopoDS_Iterator anExplor (aShape); + if (!anExplor.More()) + { 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; - DefaultStyle (DefStyle); - XCAFPrs::DispatchStyles ( shape, settings, items, DefStyle ); -#ifdef DEB - //cout << "Dispatch done" << endl; -#endif + Set (aShape); + ClearCustomAspects(); - // 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() ? "" : " " ) << endl; - //i++; -#endif - if (! s.IsVisible() ) continue; - Prs3d_Root::NewGroup(aPrs); - AddStyledItem ( s, it.Value(), aPresentationManager, aPrs, aMode ); + // Collecting information on colored subshapes + TopLoc_Location aLoc; + XCAFPrs_DataMapOfShapeStyle aSettings; + XCAFPrs::CollectStyleSettings ( myLabel, aLoc, aSettings ); + + // Getting default colors + XCAFPrs_Style aDefStyle; + DefaultStyle (aDefStyle); + Quantity_Color aColorCurv = aDefStyle.GetColorCurv(); + Quantity_Color aColorSurf = aDefStyle.GetColorSurf(); + + SetColors (myDrawer, aColorCurv, aColorSurf); + + // Set colors etc. for current shape according to style + for (XCAFPrs_DataMapIteratorOfDataMapOfShapeStyle anIter( aSettings ); anIter.More(); anIter.Next()) + { + Handle(AIS_ColoredDrawer) aDrawer = CustomAspects (anIter.Key()); + const XCAFPrs_Style& aStyle = anIter.Value(); + + aColorCurv = aStyle.IsSetColorCurv() ? aStyle.GetColorCurv() : aDefStyle.GetColorCurv(); + aColorSurf = aStyle.IsSetColorSurf() ? aStyle.GetColorSurf() : aDefStyle.GetColorSurf(); + + SetColors (aDrawer, aColorCurv, aColorSurf); } - - if ( XCAFPrs::GetViewNameMode() ) { - // Displaying Name attributes -#ifdef DEB - //cout << "Now display name of shapes" << endl; -#endif - aPrs->SetDisplayPriority(10); - DisplayText (myLabel, aPrs, Attributes()->DimensionAspect()->TextAspect(), TopLoc_Location());//no location + + 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 } -#ifdef DEB - //cout << "Compute finished" << endl; -#endif - - aPrs->ReCompute(); // for hidden line recomputation if necessary... +} + +//======================================================================= +//function : SetColors +//purpose : +//======================================================================= +void XCAFPrs_AISObject::SetColors (const Handle(AIS_Drawer)& theDrawer, + const Quantity_Color& theColorCurv, + const Quantity_Color& theColorSurf) +{ + if (!theDrawer->HasShadingAspect()) + { + theDrawer->SetShadingAspect (new Prs3d_ShadingAspect()); + } + if (!theDrawer->HasLineAspect()) + { + theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); + } + if (!theDrawer->HasWireAspect()) + { + theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); + } + if (!theDrawer->HasUIsoAspect()) + { + theDrawer->SetUIsoAspect (new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5, 1)); + } + if (!theDrawer->HasVIsoAspect()) + { + theDrawer->SetVIsoAspect (new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5, 1)); + } + if (!theDrawer->HasFreeBoundaryAspect()) + { + theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); + } + if (!theDrawer->HasUnFreeBoundaryAspect()) + { + theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); + } + + theDrawer->UnFreeBoundaryAspect()->SetColor (theColorCurv); + theDrawer->FreeBoundaryAspect()->SetColor (theColorCurv); + theDrawer->WireAspect()->SetColor (theColorCurv); + + Graphic3d_MaterialAspect aMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial(); + aMaterial.SetColor (theColorSurf); + theDrawer->ShadingAspect()->Aspect()->SetInteriorColor (theColorSurf); + theDrawer->ShadingAspect()->Aspect()->SetFrontMaterial (aMaterial); + theDrawer->UIsoAspect()->SetColor (theColorSurf); + theDrawer->VIsoAspect()->SetColor (theColorSurf); } //======================================================================= //function : DefaultStyle //purpose : DefaultStyle() can be redefined by subclasses in order to set custom default style //======================================================================= -void XCAFPrs_AISObject::DefaultStyle (XCAFPrs_Style& aStyle) const +void XCAFPrs_AISObject::DefaultStyle (XCAFPrs_Style& theStyle) const { - static const Quantity_Color White ( Quantity_NOC_WHITE ); - aStyle.SetColorSurf ( White ); - aStyle.SetColorCurv ( White ); + theStyle.SetColorSurf (Quantity_NOC_WHITE); + theStyle.SetColorCurv (Quantity_NOC_WHITE); } diff --git a/src/XCAFPrs/XCAFPrs_AISObject.hxx b/src/XCAFPrs/XCAFPrs_AISObject.hxx new file mode 100644 index 0000000000..de5e5e09a5 --- /dev/null +++ b/src/XCAFPrs/XCAFPrs_AISObject.hxx @@ -0,0 +1,60 @@ +// Copyright (c) 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. + +#ifndef _XCAFPrs_AISObject_HeaderFile +#define _XCAFPrs_AISObject_HeaderFile + +#include + +#include + +class XCAFPrs_Style; + +//! Implements AIS_InteractiveObject functionality for shape in DECAF document. +class XCAFPrs_AISObject : public AIS_ColoredShape +{ +public: + + //! Creates an object to visualise the shape label. + Standard_EXPORT XCAFPrs_AISObject (const TDF_Label& theLabel); + +protected: + + //! Redefined method to compute presentation. + Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, + const Handle(Prs3d_Presentation)& thePresentation, + const Standard_Integer theMode); + + //! Set colors to drawer + Standard_EXPORT void SetColors (const Handle(AIS_Drawer)& theDrawer, + const Quantity_Color& theColorCurv, + const Quantity_Color& theColorSurf); + + //! Fills out a default style object which is used when styles are + //! not explicitly defined in the document. + //! By default, the style uses white color for curves and surfaces. + Standard_EXPORT virtual void DefaultStyle (XCAFPrs_Style& theStyle) const; + +private: + + TDF_Label myLabel; + +public: + + DEFINE_STANDARD_RTTI(XCAFPrs_AISObject) + +}; + +DEFINE_STANDARD_HANDLE(XCAFPrs_AISObject, AIS_ColoredShape) + +#endif // _XCAFPrs_AISObject_HeaderFile