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