2 #include "HYDROData_Calculation.h"
4 #include "HYDROData_Document.h"
5 #include "HYDROData_Iterator.h"
6 #include "HYDROData_Polyline.h"
7 #include "HYDROData_Zone.h"
9 #include <TDataStd_ReferenceList.hxx>
11 #include <QStringList>
13 #define PYTHON_CALCULATION_ID "KIND_CALCULATION"
15 IMPLEMENT_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object)
16 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Calculation, HYDROData_Object)
18 HYDROData_Calculation::HYDROData_Calculation()
22 HYDROData_Calculation::~HYDROData_Calculation()
26 QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
30 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
31 if ( aDocument.IsNull() )
34 QString aDocName = aDocument->GetDocPyName();
35 QString aCalculName = GetName();
37 aResList << QString( "%1 = %2.CreateObject( %3 );" )
38 .arg( aCalculName ).arg( aDocName ).arg( PYTHON_CALCULATION_ID );
39 aResList << QString( "%1.SetName( \"%2\" );" )
40 .arg( aCalculName ).arg( aCalculName );
41 aResList << QString( "" );
43 Handle(HYDROData_Polyline) aBoundaryPolyline = GetBoundaryPolyline();
44 setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
45 aResList << QString( "" );
47 HYDROData_SequenceOfObjects aZones = GetZones();
48 HYDROData_SequenceOfObjects::Iterator anIter( aZones );
49 for ( ; anIter.More(); anIter.Next() )
51 Handle(HYDROData_Zone) aRefZone =
52 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
53 if ( !aRefZone.IsNull() )
54 setPythonReferenceObject( theTreatedObjects, aResList, aRefZone, "AddZone" );
56 aResList << QString( "" );
58 aZones = GetSplittedZones();
59 anIter.Init( aZones );
60 for ( ; anIter.More(); anIter.Next() )
62 Handle(HYDROData_Zone) aSplittedZone =
63 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
64 if ( !aSplittedZone.IsNull() )
65 setPythonReferenceObject( theTreatedObjects, aResList, aSplittedZone, "AddSplittedZone" );
71 void HYDROData_Calculation::SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline )
73 SetReferenceObject( thePolyline, DataTag_BoundaryPolyline );
76 Handle(HYDROData_Polyline) HYDROData_Calculation::GetBoundaryPolyline() const
78 return Handle(HYDROData_Polyline)::DownCast(
79 GetReferenceObject( DataTag_BoundaryPolyline ) );
82 void HYDROData_Calculation::RemoveBoundaryPolyline()
84 ClearReferenceObjects( DataTag_BoundaryPolyline );
87 int HYDROData_Calculation::NbZones() const
89 return NbReferenceObjects( DataTag_Zone );
92 void HYDROData_Calculation::AddZone( const Handle(HYDROData_Zone)& theZone )
94 AddReferenceObject( theZone, DataTag_Zone );
97 void HYDROData_Calculation::SetZone( const int theIndex,
98 const Handle(HYDROData_Zone)& theZone )
100 SetReferenceObject( theZone, DataTag_Zone, theIndex );
103 void HYDROData_Calculation::SetZones( const HYDROData_SequenceOfObjects& theZones )
105 SetReferenceObjects( theZones, DataTag_Zone );
108 Handle(HYDROData_Zone) HYDROData_Calculation::GetZone( const int theIndex ) const
110 return Handle(HYDROData_Zone)::DownCast(
111 GetReferenceObject( DataTag_Zone, theIndex ) );
114 HYDROData_SequenceOfObjects HYDROData_Calculation::GetZones() const
116 return GetReferenceObjects( DataTag_Zone );
119 void HYDROData_Calculation::RemoveZones()
121 ClearReferenceObjects( DataTag_Zone );
124 int HYDROData_Calculation::NbSplittedZones() const
126 return NbReferenceObjects( DataTag_SplittedZone );
129 void HYDROData_Calculation::AddSplittedZone( const Handle(HYDROData_Zone)& theZone )
131 AddReferenceObject( theZone, DataTag_SplittedZone );
134 void HYDROData_Calculation::SetSplittedZone( const int theIndex,
135 const Handle(HYDROData_Zone)& theZone )
137 SetReferenceObject( theZone, DataTag_SplittedZone, theIndex );
140 void HYDROData_Calculation::SetSplittedZones( const HYDROData_SequenceOfObjects& theZones )
142 SetReferenceObjects( theZones, DataTag_SplittedZone );
145 Handle(HYDROData_Zone) HYDROData_Calculation::GetSplittedZone( const int theIndex ) const
147 return Handle(HYDROData_Zone)::DownCast(
148 GetReferenceObject( DataTag_SplittedZone, theIndex ) );
151 HYDROData_SequenceOfObjects HYDROData_Calculation::GetSplittedZones() const
153 return GetReferenceObjects( DataTag_SplittedZone );
156 void HYDROData_Calculation::RemoveSplittedZones()
158 ClearReferenceObjects( DataTag_SplittedZone );