Salome HOME
#571 - Land Cover: calculation of Strickler coefficient
[modules/hydro.git] / src / HYDROPy / HYDROData_Document.sip
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 %ExportedHeaderCode
20 #include <HYDROData_Document.h>
21 %End
22
23 %ModuleHeaderCode
24 HYDROData_Entity* copyObject( HYDROData_Entity* theObject );
25 Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject );
26 HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& theObject );
27 %End
28
29 enum Data_DocError {
30   DocError_OK = 0, ///< success
31   DocError_ResourcesProblem, ///< resources files are invalid or not found
32   DocError_CanNotOpen, ///< can not open file for reading or writing
33   DocError_InvalidVersion, ///< version of document is different than expected
34   DocError_InvalidFormat, ///< format of the document is bad
35   DocError_UnknownProblem ///< problem has unknown nature
36 };
37
38 class HYDROData_Document 
39 {
40 %TypeHeaderCode
41 #include <HYDROData_Document.h>
42 %End
43
44 %ConvertToSubClassCode
45     if ( !Handle(HYDROData_Document)::DownCast( sipCpp ).IsNull() )
46       sipClass = sipClass_HYDROData_Document;
47     else
48       sipClass = NULL;
49 %End
50
51 %TypeCode
52
53   HYDROData_Entity* copyObject( HYDROData_Entity* theObject )
54   {
55     HYDROData_Entity* aRes = NULL;
56     if ( theObject == NULL )
57       return aRes;
58
59     switch( theObject->GetKind() )
60     {
61       case KIND_IMAGE:
62       {
63         aRes = new HYDROData_Image( *dynamic_cast<HYDROData_Image*>( theObject ) );
64         break;
65       }
66       case KIND_POLYLINE:
67       {
68         aRes = new HYDROData_Polyline3D( *dynamic_cast<HYDROData_Polyline3D*>( theObject ) );
69         break;
70       }
71       case KIND_BATHYMETRY:
72       {
73         aRes = new HYDROData_Bathymetry( *dynamic_cast<HYDROData_Bathymetry*>( theObject ) );
74         break;
75       }
76       case KIND_ALTITUDE:
77       {
78         aRes = new HYDROData_AltitudeObject( *dynamic_cast<HYDROData_AltitudeObject*>( theObject ) );
79         break;
80       }
81       case KIND_IMMERSIBLE_ZONE:
82       {
83         aRes = new HYDROData_ImmersibleZone( *dynamic_cast<HYDROData_ImmersibleZone*>( theObject ) );
84         break;
85       }
86       case KIND_RIVER:
87       {
88         aRes = new HYDROData_River( *dynamic_cast<HYDROData_River*>( theObject ) );
89         break;
90       }
91       case KIND_STREAM:
92       {
93         aRes = new HYDROData_Stream( *dynamic_cast<HYDROData_Stream*>( theObject ) );
94         break;
95       }
96       case KIND_CONFLUENCE:
97       {
98         aRes = new HYDROData_Confluence( *dynamic_cast<HYDROData_Confluence*>( theObject ) );
99         break;
100       }
101       case KIND_CHANNEL:
102       {
103         aRes = new HYDROData_Channel( *dynamic_cast<HYDROData_Channel*>( theObject ) );
104         break;
105       }
106       case KIND_OBSTACLE:
107       {
108         aRes = new HYDROData_Obstacle( *dynamic_cast<HYDROData_Obstacle*>( theObject ) );
109         break;
110       }
111       case KIND_DIGUE:
112       {
113         aRes = new HYDROData_Digue( *dynamic_cast<HYDROData_Digue*>( theObject ) );
114         break;
115       }
116       case KIND_PROFILE:
117       {
118         aRes = new HYDROData_Profile( *dynamic_cast<HYDROData_Profile*>( theObject ) );
119         break;
120       }
121       case KIND_PROFILEUZ:
122       {
123         aRes = new HYDROData_ProfileUZ( *dynamic_cast<HYDROData_ProfileUZ*>( theObject ) );
124         break;
125       }
126       case KIND_POLYLINEXY:
127       {
128         aRes = new HYDROData_PolylineXY( *dynamic_cast<HYDROData_PolylineXY*>( theObject ) );
129         break;
130       }
131       case KIND_CALCULATION:
132       {
133         aRes = new HYDROData_CalculationCase( *dynamic_cast<HYDROData_CalculationCase*>( theObject ) );
134         break;
135       }
136       case KIND_REGION:
137       {
138         aRes = new HYDROData_Region( *dynamic_cast<HYDROData_Region*>( theObject ) );
139         break;
140       }
141       case KIND_ZONE:
142       {
143         aRes = new HYDROData_Zone( *dynamic_cast<HYDROData_Zone*>( theObject ) );
144         break;
145       }
146       case KIND_SHAPES_GROUP:
147       {
148         aRes = new HYDROData_ShapesGroup( *dynamic_cast<HYDROData_ShapesGroup*>( theObject ) );
149         break;
150       }
151       case KIND_SPLITTED_GROUP:
152       {
153         aRes = new HYDROData_SplittedShapesGroup( *dynamic_cast<HYDROData_SplittedShapesGroup*>( theObject ) );
154         break;
155       }
156       case KIND_OBSTACLE_ALTITUDE:
157       {
158         aRes = new HYDROData_ObstacleAltitude( *dynamic_cast<HYDROData_ObstacleAltitude*>( theObject ) );
159         break;
160       }
161       case KIND_STREAM_ALTITUDE:
162       {
163         aRes = new HYDROData_StreamAltitude( *dynamic_cast<HYDROData_StreamAltitude*>( theObject ) );
164         break;
165       }
166       case KIND_STRICKLER_TABLE:
167       {
168         aRes = new HYDROData_StricklerTable( *dynamic_cast<HYDROData_StricklerTable*>( theObject ) );
169         break;
170       }
171     }
172     
173     return aRes;
174   }
175   
176   Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject )
177   {
178     Handle(HYDROData_Entity) aRes = copyObject( theObject );
179     return aRes;
180   }
181   
182   HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& theObject )
183   {
184     HYDROData_Entity* aRes = NULL;
185     
186     if ( !theObject.IsNull() )
187       aRes = copyObject( theObject.operator->() );
188     
189     return aRes;
190   }
191
192 %End
193
194 public:
195
196   //! Returns the existing document or creates new if it is not exist
197   static HYDROData_Document Document( const int theStudyID ) [Handle_HYDROData_Document (const int)] ;
198   %MethodCode
199
200     Handle(HYDROData_Document) aDocument;
201
202     Py_BEGIN_ALLOW_THREADS
203     aDocument = HYDROData_Document::Document( a0 );
204     Py_END_ALLOW_THREADS
205
206     if ( !aDocument.IsNull() )
207       sipRes = aDocument.operator->();
208
209   %End
210
211   //! Returns true if data model contains document for this study
212   static bool HasDocument( const int theStudyID );
213
214   //! Loads the OCAF document from the file.
215   //! \param theFileName full name of the file to load
216   //! \param theStudyID identifier of the SALOME study to associate with loaded file
217   //! \returns error status (OK in case of success)
218   static Data_DocError Load( const char* theFileName, const int theStudyID );
219
220   //! Saves the OCAF document to the file.
221   //! \param theFileName full name of the file to store
222   //! \returns error status (OK in case of success)
223   Data_DocError Save( const char* theFileName );
224
225   //! Removes document data
226   void Close();
227
228   //! Starts a new operation (opens a tansaction)
229   void StartOperation();
230   
231   //! Finishes the previously started operation (closes the transaction)
232   //void CommitOperation(
233   //  const TCollection_ExtendedString& theName = TCollection_ExtendedString() );
234     
235   //! Aborts the operation 
236   void AbortOperation();
237   
238   //! Returns true if operation has been started, but not yet finished or aborted
239   bool IsOperation();
240   
241   //! Returns true if document was modified (since creation/opening)
242   bool IsModified();
243
244   //! Returns True if there are available Undos
245   bool CanUndo();
246   
247   //! Returns a list of stored undo actions
248   //const TDF_DeltaList& GetUndos();
249   
250   //! Clears a list of stored undo actions
251   void ClearUndos();
252   
253   //! Undoes last operation
254   void Undo();
255
256   //! Returns True if there are available Redos
257   bool CanRedo();
258   
259   //! Returns a list of stored undo actions
260   //const TDF_DeltaList& GetRedos();
261   
262   //! Clears a list of stored undo actions
263   void ClearRedos();
264   
265   //! Redoes last operation
266   void Redo();
267
268   //! Creates and locates in the document a new object
269   //! \param theKind kind of the created object, can not be UNKNOWN
270   //! \returns the created object
271   HYDROData_Entity CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Entity (const ObjectKind)] ;
272   %MethodCode
273
274     Handle(HYDROData_Entity) anObject;
275     Py_BEGIN_ALLOW_THREADS
276     anObject =  sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) :
277                                 sipCpp->CreateObject( a0 );
278     Py_END_ALLOW_THREADS
279
280     sipRes = createPointer( anObject );
281     
282   %End
283
284   HYDROData_Entity FindObjectByName( const QString&   theName,
285                                      const ObjectKind theKind = KIND_UNKNOWN ) 
286   [Handle_HYDROData_Entity (const QString&, const ObjectKind)] ;
287   %MethodCode
288
289     Handle(HYDROData_Entity) anObject;
290     Py_BEGIN_ALLOW_THREADS
291     anObject =  sipSelfWasArg ? sipCpp->HYDROData_Document::FindObjectByName( *a0, a1 ) :
292                                 sipCpp->FindObjectByName( *a0, a1 );
293     Py_END_ALLOW_THREADS
294
295     sipRes = createPointer( anObject );
296     
297   %End
298
299   HYDROData_SequenceOfObjects FindObjectsByNames( const QStringList& theNames,
300                                                   const ObjectKind   theKind = KIND_UNKNOWN );
301
302   void SetLocalCS( double, double );
303
304   //! Get the appropriate interpolator by the name.
305   HYDROData_IProfilesInterpolator* GetInterpolator( const TCollection_AsciiString& theName ) const;
306
307   //! Get list of registered interpolator names.
308   NCollection_Sequence<TCollection_AsciiString> GetInterpolatorNames() const;
309
310 protected:
311
312   //! Creates new document: private because "Document" method must be used instead of direct creation.
313   HYDROData_Document();
314   
315   //! Deletes all high-level data, managed this document
316   ~HYDROData_Document();
317
318 };