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_LandCover.h"
21 #include "HYDROData_PolylineXY.h"
23 #include <TDataStd_AsciiString.hxx>
24 #include <TNaming_Builder.hxx>
25 #include <TopoDS_Shape.hxx>
27 #include <QStringList>
29 IMPLEMENT_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity )
30 IMPLEMENT_STANDARD_RTTIEXT( HYDROData_LandCover, HYDROData_Entity )
32 HYDROData_LandCover::HYDROData_LandCover()
36 HYDROData_LandCover::~HYDROData_LandCover()
40 const ObjectKind HYDROData_LandCover::GetKind() const
42 return KIND_LAND_COVER;
45 QStringList HYDROData_LandCover::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
47 QStringList aResList = dumpObjectCreation( theTreatedObjects );
48 QString aName = GetObjPyName();
51 QString aType = GetStricklerType();
52 if ( !aType.isEmpty() ) {
53 aResList << QString( "" );
54 ///< \TODO to be implemented:
55 // aResList << QString( "%1.SetStricklerType( \"%2\" );" ).arg( aName ).arg( aType );
56 aResList << QString( "" );
60 ///< \TODO to be implemented:
62 aResList << QString( "" );
63 aResList << QString( "%1.Update();" ).arg( aName );
64 aResList << QString( "" );
69 HYDROData_SequenceOfObjects HYDROData_LandCover::GetAllReferenceObjects() const
71 HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects();
73 HYDROData_SequenceOfObjects aSeqOfPolylines = GetPolylines();
74 aResSeq.Append( aSeqOfPolylines );
79 bool HYDROData_LandCover::IsHas2dPrs() const
84 void HYDROData_LandCover::SetStricklerType( const QString& theType )
86 TCollection_AsciiString anAsciiStr( theType.toStdString().c_str() );
87 TDataStd_AsciiString::Set( myLab.FindChild( DataTag_StricklerType ), anAsciiStr );
90 QString HYDROData_LandCover::GetStricklerType() const
94 TDF_Label aLabel = myLab.FindChild( DataTag_StricklerType, false );
95 if ( !aLabel.IsNull() ) {
96 Handle(TDataStd_AsciiString) anAsciiStr;
97 if ( aLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) {
98 aType = QString( anAsciiStr->Get().ToCString() );
105 void HYDROData_LandCover::Update()
107 HYDROData_Entity::Update();
111 TopoDS_Shape aResShape = buildShape();
113 setShape( aResShape );
116 void HYDROData_LandCover::SetPolylines( const HYDROData_SequenceOfObjects& thePolylines )
118 SetReferenceObjects( thePolylines, DataTag_Polylines );
122 HYDROData_SequenceOfObjects HYDROData_LandCover::GetPolylines() const
124 return GetReferenceObjects( DataTag_Polylines );
127 void HYDROData_LandCover::setShape( const TopoDS_Shape& theShape )
129 TNaming_Builder aBuilder( myLab.FindChild( DataTag_Shape ) );
130 aBuilder.Generated( theShape );
133 void HYDROData_LandCover::removeShape()
135 TDF_Label aLabel = myLab.FindChild( DataTag_Shape, false );
136 if ( !aLabel.IsNull() ) {
137 aLabel.ForgetAllAttributes();
141 TopoDS_Shape HYDROData_LandCover::buildShape() const
143 TopoDS_Shape aResShape;
145 ///< \TODO to be reimplemented
146 HYDROData_SequenceOfObjects aRefPolylines = GetPolylines();
147 for ( int i = 1, n = aRefPolylines.Length(); i <= n; ++i ) {
148 Handle(HYDROData_PolylineXY) aPolyline =
149 Handle(HYDROData_PolylineXY)::DownCast( aRefPolylines.Value( i ) );
151 if ( aPolyline.IsNull() ) {
155 if ( aPolyline->IsClosed() ) {
156 aResShape = aPolyline->GetShape();