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