Salome HOME
766077e1ef24bde31c30ab60cb41754fe1cd9e56
[modules/hydro.git] / src / HYDROData / HYDROData_Calculation.cxx
1
2 #include "HYDROData_Calculation.h"
3
4 #include "HYDROData_Document.h"
5 #include "HYDROData_Iterator.h"
6 #include "HYDROData_Polyline.h"
7 #include "HYDROData_Zone.h"
8
9 #include <TDataStd_ReferenceList.hxx>
10
11 #include <QStringList>
12
13 #define PYTHON_CALCULATION_ID "KIND_CALCULATION"
14
15 IMPLEMENT_STANDARD_HANDLE(HYDROData_Calculation, HYDROData_Object)
16 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Calculation, HYDROData_Object)
17
18 HYDROData_Calculation::HYDROData_Calculation()
19 {
20 }
21
22 HYDROData_Calculation::~HYDROData_Calculation()
23 {
24 }
25
26 QStringList HYDROData_Calculation::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
27 {
28   QStringList aResList;
29
30   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
31   if ( aDocument.IsNull() )
32     return aResList;
33                              
34   QString aDocName = aDocument->GetDocPyName();
35   QString aCalculName = GetName();
36
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( "" );
42
43   Handle(HYDROData_Polyline) aBoundaryPolyline = GetBoundaryPolyline();
44   setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
45   aResList << QString( "" );
46
47   HYDROData_SequenceOfObjects aZones = GetZones();
48   HYDROData_SequenceOfObjects::Iterator anIter( aZones );
49   for ( ; anIter.More(); anIter.Next() )
50   {
51     Handle(HYDROData_Zone) aRefZone =
52       Handle(HYDROData_Zone)::DownCast( anIter.Value() );
53     if ( !aRefZone.IsNull() )
54       setPythonReferenceObject( theTreatedObjects, aResList, aRefZone, "AddZone" );
55   }
56   aResList << QString( "" );
57
58   aZones = GetSplittedZones();
59   anIter.Init( aZones );
60   for ( ; anIter.More(); anIter.Next() )
61   {
62     Handle(HYDROData_Zone) aSplittedZone =
63       Handle(HYDROData_Zone)::DownCast( anIter.Value() );
64     if ( !aSplittedZone.IsNull() )
65       setPythonReferenceObject( theTreatedObjects, aResList, aSplittedZone, "AddSplittedZone" );
66   }
67
68   return aResList;
69 }
70
71 void HYDROData_Calculation::SetBoundaryPolyline( const Handle(HYDROData_Polyline)& thePolyline )
72 {
73   SetReferenceObject( thePolyline, DataTag_BoundaryPolyline );
74 }
75
76 Handle(HYDROData_Polyline) HYDROData_Calculation::GetBoundaryPolyline() const
77 {
78   return Handle(HYDROData_Polyline)::DownCast( 
79            GetReferenceObject( DataTag_BoundaryPolyline ) );
80 }
81
82 void HYDROData_Calculation::RemoveBoundaryPolyline()
83 {
84   ClearReferenceObjects( DataTag_BoundaryPolyline );
85 }
86
87 int HYDROData_Calculation::NbZones() const
88 {
89   return NbReferenceObjects( DataTag_Zone );
90 }
91
92 void HYDROData_Calculation::AddZone( const Handle(HYDROData_Zone)& theZone )
93 {
94   AddReferenceObject( theZone, DataTag_Zone );
95 }
96
97 void HYDROData_Calculation::SetZone( const int                     theIndex,
98                                      const Handle(HYDROData_Zone)& theZone )
99 {
100   SetReferenceObject( theZone, DataTag_Zone, theIndex );
101 }
102
103 void HYDROData_Calculation::SetZones( const HYDROData_SequenceOfObjects& theZones )
104 {
105   SetReferenceObjects( theZones, DataTag_Zone );
106 }
107
108 Handle(HYDROData_Zone) HYDROData_Calculation::GetZone( const int theIndex ) const
109 {
110   return Handle(HYDROData_Zone)::DownCast( 
111            GetReferenceObject( DataTag_Zone, theIndex ) );
112 }
113
114 HYDROData_SequenceOfObjects HYDROData_Calculation::GetZones() const
115 {
116   return GetReferenceObjects( DataTag_Zone );
117 }
118
119 void HYDROData_Calculation::RemoveZones()
120 {
121   ClearReferenceObjects( DataTag_Zone );
122 }
123
124 int HYDROData_Calculation::NbSplittedZones() const
125 {
126   return NbReferenceObjects( DataTag_SplittedZone );
127 }
128
129 void HYDROData_Calculation::AddSplittedZone( const Handle(HYDROData_Zone)& theZone )
130 {
131   AddReferenceObject( theZone, DataTag_SplittedZone );
132 }
133
134 void HYDROData_Calculation::SetSplittedZone( const int                     theIndex,
135                                              const Handle(HYDROData_Zone)& theZone )
136 {
137   SetReferenceObject( theZone, DataTag_SplittedZone, theIndex );
138 }
139
140 void HYDROData_Calculation::SetSplittedZones( const HYDROData_SequenceOfObjects& theZones )
141 {
142   SetReferenceObjects( theZones, DataTag_SplittedZone );
143 }
144
145 Handle(HYDROData_Zone) HYDROData_Calculation::GetSplittedZone( const int theIndex ) const
146 {
147   return Handle(HYDROData_Zone)::DownCast( 
148            GetReferenceObject( DataTag_SplittedZone, theIndex ) );
149 }
150
151 HYDROData_SequenceOfObjects HYDROData_Calculation::GetSplittedZones() const
152 {
153   return GetReferenceObjects( DataTag_SplittedZone );
154 }
155
156 void HYDROData_Calculation::RemoveSplittedZones()
157 {
158   ClearReferenceObjects( DataTag_SplittedZone );
159 }
160