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_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
31 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
33 HYDROData_IPolyline::HYDROData_IPolyline()
34 : HYDROData_Entity( Geom_2d )
38 HYDROData_IPolyline::~HYDROData_IPolyline()
42 void HYDROData_IPolyline::SetWireColor( const QColor& theColor )
44 SetColor( theColor, DataTag_WireColor );
47 QColor HYDROData_IPolyline::GetWireColor() const
49 return GetColor( DefaultWireColor(), DataTag_WireColor );
52 QColor HYDROData_IPolyline::DefaultWireColor()
54 return QColor( Qt::black );
57 int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const
59 return GetPoints( theSectionIndex ).Length();
62 TopoDS_Shape HYDROData_IPolyline::GetShape() const
64 return HYDROData_Entity::GetShape( DataTag_PolylineShape );
67 void HYDROData_IPolyline::SetShape( const TopoDS_Shape& theShape )
69 HYDROData_Entity::SetShape( DataTag_PolylineShape, theShape );
72 void HYDROData_IPolyline::RemovePolylineShape()
74 SetShape( TopoDS_Shape() );
77 void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
78 Handle(TDataStd_IntegerList)& theTypesList,
79 Handle(TDataStd_BooleanList)& theClosuresList,
80 const bool theIsCreate ) const
82 theNamesList.Nullify();
83 theTypesList.Nullify();
84 theClosuresList.Nullify();
86 TDF_Label aSectLabel = myLab.FindChild( DataTag_Sections, theIsCreate );
87 if ( aSectLabel.IsNull() )
90 if ( !aSectLabel.FindAttribute( TDataStd_ExtStringList::GetID(), theNamesList ) && theIsCreate )
91 theNamesList = TDataStd_ExtStringList::Set( aSectLabel );
93 if ( !aSectLabel.FindAttribute( TDataStd_IntegerList::GetID(), theTypesList ) && theIsCreate )
94 theTypesList = TDataStd_IntegerList::Set( aSectLabel );
96 if ( !aSectLabel.FindAttribute( TDataStd_BooleanList::GetID(), theClosuresList ) && theIsCreate )
97 theClosuresList = TDataStd_BooleanList::Set( aSectLabel );
100 void HYDROData_IPolyline::removeSectionsLists()
102 TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, false );
103 if ( !aSectsLabel.IsNull() )
104 aSectsLabel.ForgetAllAttributes();
107 void HYDROData_IPolyline::getPointsLists( const int theSectionIndex,
108 Handle(TDataStd_RealList)& theListX,
109 Handle(TDataStd_RealList)& theListY,
110 const bool theIsCreate ) const
115 TDF_Label aLabel = myLab.FindChild( DataTag_Points, theIsCreate );
116 if ( aLabel.IsNull() )
119 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, theIsCreate );
120 if ( aSectLabel.IsNull() )
123 TDF_Label aLabelX = aSectLabel.FindChild( 0, theIsCreate );
124 if ( !aLabelX.IsNull() )
126 if ( !aLabelX.FindAttribute( TDataStd_RealList::GetID(), theListX ) && theIsCreate )
127 theListX = TDataStd_RealList::Set( aLabelX );
130 TDF_Label aLabelY = aSectLabel.FindChild( 1, theIsCreate );
131 if ( !aLabelY.IsNull() )
133 if ( !aLabelY.FindAttribute( TDataStd_RealList::GetID(), theListY ) && theIsCreate )
134 theListY = TDataStd_RealList::Set( aLabelY );
138 void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const
140 TDF_Label aLabel = myLab.FindChild( DataTag_Points, false );
141 if ( aLabel.IsNull() )
144 if ( theSectionIndex < 0 )
146 aLabel.ForgetAllAttributes();
150 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
151 if ( !aSectLabel.IsNull() )
152 aSectLabel.ForgetAllAttributes();