2 #include "HYDROData_IPolyline.h"
6 #include <TDataStd_BooleanList.hxx>
7 #include <TDataStd_ExtStringList.hxx>
8 #include <TDataStd_IntegerList.hxx>
9 #include <TDataStd_RealList.hxx>
11 #include <TopoDS_Shape.hxx>
13 #include <TNaming_Builder.hxx>
14 #include <TNaming_NamedShape.hxx>
18 IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
19 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
21 HYDROData_IPolyline::HYDROData_IPolyline()
26 HYDROData_IPolyline::~HYDROData_IPolyline()
30 void HYDROData_IPolyline::SetWireColor( const QColor& theColor )
32 SetColor( theColor, DataTag_WireColor );
35 QColor HYDROData_IPolyline::GetWireColor() const
37 return GetColor( DefaultWireColor(), DataTag_WireColor );
40 QColor HYDROData_IPolyline::DefaultWireColor()
42 return QColor( Qt::black );
45 int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const
47 return GetPoints( theSectionIndex ).Length();
50 TopoDS_Shape HYDROData_IPolyline::getPolylineShape() const
52 TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false );
53 if ( !aShapeLabel.IsNull() )
55 Handle(TNaming_NamedShape) aNamedShape;
56 if ( aShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
57 return aNamedShape->Get();
59 return TopoDS_Shape();
62 void HYDROData_IPolyline::setPolylineShape( const TopoDS_Shape& theShape )
64 TNaming_Builder aBuilder( myLab.FindChild( DataTag_PolylineShape ) );
65 aBuilder.Generated( theShape );
68 void HYDROData_IPolyline::removePolylineShape()
70 TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false );
71 if ( !aShapeLabel.IsNull() )
72 aShapeLabel.ForgetAllAttributes();
75 void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
76 Handle(TDataStd_IntegerList)& theTypesList,
77 Handle(TDataStd_BooleanList)& theClosuresList,
78 const bool theIsCreate ) const
80 theNamesList.Nullify();
81 theTypesList.Nullify();
82 theClosuresList.Nullify();
84 TDF_Label aSectLabel = myLab.FindChild( DataTag_Sections, theIsCreate );
85 if ( aSectLabel.IsNull() )
88 if ( !aSectLabel.FindAttribute( TDataStd_ExtStringList::GetID(), theNamesList ) && theIsCreate )
89 theNamesList = TDataStd_ExtStringList::Set( aSectLabel );
91 if ( !aSectLabel.FindAttribute( TDataStd_IntegerList::GetID(), theTypesList ) && theIsCreate )
92 theTypesList = TDataStd_IntegerList::Set( aSectLabel );
94 if ( !aSectLabel.FindAttribute( TDataStd_BooleanList::GetID(), theClosuresList ) && theIsCreate )
95 theClosuresList = TDataStd_BooleanList::Set( aSectLabel );
98 void HYDROData_IPolyline::removeSectionsLists()
100 TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, false );
101 if ( !aSectsLabel.IsNull() )
102 aSectsLabel.ForgetAllAttributes();
105 void HYDROData_IPolyline::getPointsLists( const int theSectionIndex,
106 Handle(TDataStd_RealList)& theListX,
107 Handle(TDataStd_RealList)& theListY,
108 const bool theIsCreate ) const
113 TDF_Label aLabel = myLab.FindChild( DataTag_Points, theIsCreate );
114 if ( aLabel.IsNull() )
117 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, theIsCreate );
118 if ( aSectLabel.IsNull() )
121 TDF_Label aLabelX = aSectLabel.FindChild( 0, theIsCreate );
122 if ( !aLabelX.IsNull() )
124 if ( !aLabelX.FindAttribute( TDataStd_RealList::GetID(), theListX ) && theIsCreate )
125 theListX = TDataStd_RealList::Set( aLabelX );
128 TDF_Label aLabelY = aSectLabel.FindChild( 1, theIsCreate );
129 if ( !aLabelY.IsNull() )
131 if ( !aLabelY.FindAttribute( TDataStd_RealList::GetID(), theListY ) && theIsCreate )
132 theListY = TDataStd_RealList::Set( aLabelY );
136 void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const
138 TDF_Label aLabel = myLab.FindChild( DataTag_Points, false );
139 if ( aLabel.IsNull() )
142 if ( theSectionIndex < 0 )
144 aLabel.ForgetAllAttributes();
148 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
149 if ( !aSectLabel.IsNull() )
150 aSectLabel.ForgetAllAttributes();