1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROData_IPolyline.h"
27 #include <TDataStd_BooleanList.hxx>
28 #include <TDataStd_ExtStringList.hxx>
29 #include <TDataStd_IntegerList.hxx>
30 #include <TDataStd_RealList.hxx>
32 #include <TopoDS_Shape.hxx>
34 #include <TNaming_Builder.hxx>
35 #include <TNaming_NamedShape.hxx>
39 IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
40 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
42 HYDROData_IPolyline::HYDROData_IPolyline()
47 HYDROData_IPolyline::~HYDROData_IPolyline()
51 void HYDROData_IPolyline::SetWireColor( const QColor& theColor )
53 SetColor( theColor, DataTag_WireColor );
56 QColor HYDROData_IPolyline::GetWireColor() const
58 return GetColor( DefaultWireColor(), DataTag_WireColor );
61 QColor HYDROData_IPolyline::DefaultWireColor()
63 return QColor( Qt::black );
66 int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const
68 return GetPoints( theSectionIndex ).Length();
71 TopoDS_Shape HYDROData_IPolyline::getPolylineShape() const
73 TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false );
74 if ( !aShapeLabel.IsNull() )
76 Handle(TNaming_NamedShape) aNamedShape;
77 if ( aShapeLabel.FindAttribute( TNaming_NamedShape::GetID(), aNamedShape ) )
78 return aNamedShape->Get();
80 return TopoDS_Shape();
83 void HYDROData_IPolyline::setPolylineShape( const TopoDS_Shape& theShape )
85 TNaming_Builder aBuilder( myLab.FindChild( DataTag_PolylineShape ) );
86 aBuilder.Generated( theShape );
89 void HYDROData_IPolyline::removePolylineShape()
91 TDF_Label aShapeLabel = myLab.FindChild( DataTag_PolylineShape, false );
92 if ( !aShapeLabel.IsNull() )
93 aShapeLabel.ForgetAllAttributes();
96 void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
97 Handle(TDataStd_IntegerList)& theTypesList,
98 Handle(TDataStd_BooleanList)& theClosuresList,
99 const bool theIsCreate ) const
101 theNamesList.Nullify();
102 theTypesList.Nullify();
103 theClosuresList.Nullify();
105 TDF_Label aSectLabel = myLab.FindChild( DataTag_Sections, theIsCreate );
106 if ( aSectLabel.IsNull() )
109 if ( !aSectLabel.FindAttribute( TDataStd_ExtStringList::GetID(), theNamesList ) && theIsCreate )
110 theNamesList = TDataStd_ExtStringList::Set( aSectLabel );
112 if ( !aSectLabel.FindAttribute( TDataStd_IntegerList::GetID(), theTypesList ) && theIsCreate )
113 theTypesList = TDataStd_IntegerList::Set( aSectLabel );
115 if ( !aSectLabel.FindAttribute( TDataStd_BooleanList::GetID(), theClosuresList ) && theIsCreate )
116 theClosuresList = TDataStd_BooleanList::Set( aSectLabel );
119 void HYDROData_IPolyline::removeSectionsLists()
121 TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, false );
122 if ( !aSectsLabel.IsNull() )
123 aSectsLabel.ForgetAllAttributes();
126 void HYDROData_IPolyline::getPointsLists( const int theSectionIndex,
127 Handle(TDataStd_RealList)& theListX,
128 Handle(TDataStd_RealList)& theListY,
129 const bool theIsCreate ) const
134 TDF_Label aLabel = myLab.FindChild( DataTag_Points, theIsCreate );
135 if ( aLabel.IsNull() )
138 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, theIsCreate );
139 if ( aSectLabel.IsNull() )
142 TDF_Label aLabelX = aSectLabel.FindChild( 0, theIsCreate );
143 if ( !aLabelX.IsNull() )
145 if ( !aLabelX.FindAttribute( TDataStd_RealList::GetID(), theListX ) && theIsCreate )
146 theListX = TDataStd_RealList::Set( aLabelX );
149 TDF_Label aLabelY = aSectLabel.FindChild( 1, theIsCreate );
150 if ( !aLabelY.IsNull() )
152 if ( !aLabelY.FindAttribute( TDataStd_RealList::GetID(), theListY ) && theIsCreate )
153 theListY = TDataStd_RealList::Set( aLabelY );
157 void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const
159 TDF_Label aLabel = myLab.FindChild( DataTag_Points, false );
160 if ( aLabel.IsNull() )
163 if ( theSectionIndex < 0 )
165 aLabel.ForgetAllAttributes();
169 TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
170 if ( !aSectLabel.IsNull() )
171 aSectLabel.ForgetAllAttributes();