1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROData_IPolyline.h"
23 #include <TDataStd_BooleanList.hxx>
24 #include <TDataStd_ExtStringList.hxx>
25 #include <TDataStd_IntegerList.hxx>
26 #include <TDataStd_RealList.hxx>
27 #include <TopoDS_Shape.hxx>
30 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
32 HYDROData_IPolyline::HYDROData_IPolyline()
33 : HYDROData_Entity( Geom_2d )
37 HYDROData_IPolyline::~HYDROData_IPolyline()
41 void HYDROData_IPolyline::SetWireColor( const QColor& theColor )
43 SetColor( theColor, DataTag_WireColor );
46 QColor HYDROData_IPolyline::GetWireColor() const
48 return GetColor( DefaultWireColor(), DataTag_WireColor );
51 QColor HYDROData_IPolyline::DefaultWireColor()
53 return QColor( Qt::black );
56 int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const
58 return GetPoints( theSectionIndex ).Length();
61 TopoDS_Shape HYDROData_IPolyline::GetShape() const
63 return HYDROData_Entity::GetShape( DataTag_PolylineShape );
66 void HYDROData_IPolyline::SetShape( const TopoDS_Shape& theShape )
68 HYDROData_Entity::SetShape( DataTag_PolylineShape, theShape );
71 void HYDROData_IPolyline::RemovePolylineShape()
73 SetShape( TopoDS_Shape() );
76 void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
77 Handle(TDataStd_IntegerList)& theTypesList,
78 Handle(TDataStd_BooleanList)& theClosuresList,
79 const bool theIsCreate ) const
81 theNamesList.Nullify();
82 theTypesList.Nullify();
83 theClosuresList.Nullify();
85 TDF_Label aSectLabel = myLab.FindChild( DataTag_Sections, theIsCreate );
86 if ( aSectLabel.IsNull() )
89 if ( !aSectLabel.FindAttribute( TDataStd_ExtStringList::GetID(), theNamesList ) && theIsCreate )
91 theNamesList = TDataStd_ExtStringList::Set( aSectLabel );
92 theNamesList->SetID(TDataStd_ExtStringList::GetID());
95 if ( !aSectLabel.FindAttribute( TDataStd_IntegerList::GetID(), theTypesList ) && theIsCreate )
97 theTypesList = TDataStd_IntegerList::Set( aSectLabel );
98 theTypesList->SetID(TDataStd_IntegerList::GetID());
101 if ( !aSectLabel.FindAttribute( TDataStd_BooleanList::GetID(), theClosuresList ) && theIsCreate )
103 theClosuresList = TDataStd_BooleanList::Set( aSectLabel );
104 theClosuresList->SetID(TDataStd_BooleanList::GetID());
108 void HYDROData_IPolyline::removeSectionsLists()
110 TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, false );
111 if ( !aSectsLabel.IsNull() )
112 aSectsLabel.ForgetAllAttributes();
115 void HYDROData_IPolyline::getPointsLists( const int theSectionIndex,
116 Handle(TDataStd_RealList)& theListX,
117 Handle(TDataStd_RealList)& theListY,
118 const bool theIsCreate ) const
123 TDF_Label aLabel = myLab.FindChild( DataTag_Points, theIsCreate );
124 if ( aLabel.IsNull() )
127 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, theIsCreate );
128 if ( aSectLabel.IsNull() )
131 TDF_Label aLabelX = aSectLabel.FindChild( 0, theIsCreate );
132 if ( !aLabelX.IsNull() )
134 if ( !aLabelX.FindAttribute( TDataStd_RealList::GetID(), theListX ) && theIsCreate )
136 theListX = TDataStd_RealList::Set( aLabelX );
137 theListX->SetID(TDataStd_RealList::GetID());
141 TDF_Label aLabelY = aSectLabel.FindChild( 1, theIsCreate );
142 if ( !aLabelY.IsNull() )
144 if ( !aLabelY.FindAttribute( TDataStd_RealList::GetID(), theListY ) && theIsCreate )
146 theListY = TDataStd_RealList::Set( aLabelY );
147 theListY->SetID(TDataStd_RealList::GetID());
152 void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const
154 TDF_Label aLabel = myLab.FindChild( DataTag_Points, false );
155 if ( aLabel.IsNull() )
158 if ( theSectionIndex < 0 )
160 aLabel.ForgetAllAttributes();
164 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
165 if ( !aSectLabel.IsNull() )
166 aSectLabel.ForgetAllAttributes();