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"
8 #include "HYDROData_Region.h"
10 #include <TDataStd_ReferenceList.hxx>
12 #include <QStringList>
14 #define PYTHON_CALCULATION_ID "KIND_CALCULATION"
16 IMPLEMENT_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object)
17 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Calculation, HYDROData_Object)
19 HYDROData_Calculation::HYDROData_Calculation()
23 HYDROData_Calculation::~HYDROData_Calculation()
27 QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
31 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
32 if ( aDocument.IsNull() )
35 QString aDocName = aDocument->GetDocPyName();
36 QString aCalculName = GetName();
38 aResList << QString( "%1 = %2.CreateObject( %3 );" )
39 .arg( aCalculName ).arg( aDocName ).arg( PYTHON_CALCULATION_ID );
40 aResList << QString( "%1.SetName( \"%2\" );" )
41 .arg( aCalculName ).arg( aCalculName );
42 aResList << QString( "" );
44 Handle(HYDROData_Polyline) aBoundaryPolyline = GetBoundaryPolyline();
45 setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
46 aResList << QString( "" );
48 HYDROData_SequenceOfObjects aZones = GetZones();
49 HYDROData_SequenceOfObjects::Iterator anIter( aZones );
50 for ( ; anIter.More(); anIter.Next() )
52 Handle(HYDROData_Zone) aRefZone =
53 Handle(HYDROData_Zone)::DownCast( anIter.Value() );
54 if ( !aRefZone.IsNull() )
55 setPythonReferenceObject( theTreatedObjects, aResList, aRefZone, "AddZone" );
57 aResList << QString( "" );
59 aZones = GetRegions();
60 anIter.Init( aZones );
61 for ( ; anIter.More(); anIter.Next() )
63 Handle(HYDROData_Region) aRegion =
64 Handle(HYDROData_Region)::DownCast( anIter.Value() );
65 if ( !aRegion.IsNull() )
66 setPythonReferenceObject( theTreatedObjects, aResList, aRegion, "AddRegion" );
72 void HYDROData_Calculation::SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline )
74 SetReferenceObject( thePolyline, DataTag_BoundaryPolyline );
77 Handle(HYDROData_Polyline) HYDROData_Calculation::GetBoundaryPolyline() const
79 return Handle(HYDROData_Polyline)::DownCast(
80 GetReferenceObject( DataTag_BoundaryPolyline ) );
83 void HYDROData_Calculation::RemoveBoundaryPolyline()
85 ClearReferenceObjects( DataTag_BoundaryPolyline );
88 int HYDROData_Calculation::NbZones() const
90 return NbReferenceObjects( DataTag_Zone );
93 void HYDROData_Calculation::AddZone( const Handle(HYDROData_Zone)& theZone )
95 AddReferenceObject( theZone, DataTag_Zone );
98 void HYDROData_Calculation::SetZone( const int theIndex,
99 const Handle(HYDROData_Zone)& theZone )
101 SetReferenceObject( theZone, DataTag_Zone, theIndex );
104 void HYDROData_Calculation::SetZones( const HYDROData_SequenceOfObjects& theZones )
106 SetReferenceObjects( theZones, DataTag_Zone );
109 Handle(HYDROData_Zone) HYDROData_Calculation::GetZone( const int theIndex ) const
111 return Handle(HYDROData_Zone)::DownCast(
112 GetReferenceObject( DataTag_Zone, theIndex ) );
115 HYDROData_SequenceOfObjects HYDROData_Calculation::GetZones() const
117 return GetReferenceObjects( DataTag_Zone );
120 void HYDROData_Calculation::RemoveZones()
122 ClearReferenceObjects( DataTag_Zone );
125 int HYDROData_Calculation::NbRegions() const
127 return NbReferenceObjects( DataTag_Region );
130 void HYDROData_Calculation::AddRegion( const Handle(HYDROData_Region)& theRegion )
132 AddReferenceObject( theRegion, DataTag_Region );
135 void HYDROData_Calculation::SetRegion( const int theIndex,
136 const Handle(HYDROData_Region)& theRegion )
138 SetReferenceObject( theRegion, DataTag_Region, theIndex );
141 void HYDROData_Calculation::SetRegions( const HYDROData_SequenceOfObjects& theRegions )
143 SetReferenceObjects( theRegions, DataTag_Region );
146 Handle(HYDROData_Region) HYDROData_Calculation::GetRegion( const int theIndex ) const
148 return Handle(HYDROData_Region)::DownCast(
149 GetReferenceObject( DataTag_Region, theIndex ) );
152 HYDROData_SequenceOfObjects HYDROData_Calculation::GetRegions() const
154 return GetReferenceObjects( DataTag_Region );
157 void HYDROData_Calculation::RemoveRegions()
159 ClearReferenceObjects( DataTag_Region );