Salome HOME
Checkbox for the point C is improved in Import Image dialog. Now coordinates edit...
[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_Object* copyObject( HYDROData_Object* theObject );
29 Handle(HYDROData_Object) createHandle( HYDROData_Object* theObject );
30 HYDROData_Object* createPointer( const Handle(HYDROData_Object)& 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_Object* copyObject( HYDROData_Object* theObject )
58   {
59     HYDROData_Object* 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_Polyline( *dynamic_cast<HYDROData_Polyline*>( 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_CALCULATION:
81       {
82         aRes = new HYDROData_Calculation( *dynamic_cast<HYDROData_Calculation*>( theObject ) );
83         break;
84       }
85       case KIND_ZONE:
86       {
87         aRes = new HYDROData_Zone( *dynamic_cast<HYDROData_Zone*>( theObject ) );
88         break;
89       }
90       case KIND_REGION:
91       {
92         aRes = new HYDROData_Region( *dynamic_cast<HYDROData_Region*>( theObject ) );
93         break;
94       }
95     }
96     
97     return aRes;
98   }
99   
100   Handle(HYDROData_Object) createHandle( HYDROData_Object* theObject )
101   {
102     Handle(HYDROData_Object) aRes = copyObject( theObject );
103     return aRes;
104   }
105   
106   HYDROData_Object* createPointer( const Handle(HYDROData_Object)& theObject )
107   {
108     HYDROData_Object* aRes = NULL;
109     
110     if ( !theObject.IsNull() )
111       aRes = copyObject( theObject.operator->() );
112     
113     return aRes;
114   }
115
116 %End
117
118 public:
119
120   //! Returns the existing document or creates new if it is not exist
121   static HYDROData_Document Document( const int theStudyID ) [Handle_HYDROData_Document (const int)] ;
122   %MethodCode
123
124     Handle(HYDROData_Document) aDocument;
125
126     Py_BEGIN_ALLOW_THREADS
127     aDocument = HYDROData_Document::Document( a0 );
128     Py_END_ALLOW_THREADS
129
130     if ( !aDocument.IsNull() )
131       sipRes = aDocument.operator->();
132
133   %End
134
135   //! Returns true if data model contains document for this study
136   static bool HasDocument( const int theStudyID );
137
138   //! Loads the OCAF document from the file.
139   //! \param theFileName full name of the file to load
140   //! \param theStudyID identifier of the SALOME study to associate with loaded file
141   //! \returns error status (OK in case of success)
142   static Data_DocError Load( const char* theFileName, const int theStudyID );
143
144   //! Saves the OCAF document to the file.
145   //! \param theFileName full name of the file to store
146   //! \returns error status (OK in case of success)
147   Data_DocError Save( const char* theFileName );
148
149   //! Removes document data
150   void Close();
151
152   //! Starts a new operation (opens a tansaction)
153   void StartOperation();
154   
155   //! Finishes the previously started operation (closes the transaction)
156   //void CommitOperation(
157   //  const TCollection_ExtendedString& theName = TCollection_ExtendedString() );
158     
159   //! Aborts the operation 
160   void AbortOperation();
161   
162   //! Returns true if operation has been started, but not yet finished or aborted
163   bool IsOperation();
164   
165   //! Returns true if document was modified (since creation/opening)
166   bool IsModified();
167
168   //! Returns True if there are available Undos
169   bool CanUndo();
170   
171   //! Returns a list of stored undo actions
172   //const TDF_DeltaList& GetUndos();
173   
174   //! Clears a list of stored undo actions
175   void ClearUndos();
176   
177   //! Undoes last operation
178   void Undo();
179
180   //! Returns True if there are available Redos
181   bool CanRedo();
182   
183   //! Returns a list of stored undo actions
184   //const TDF_DeltaList& GetRedos();
185   
186   //! Clears a list of stored undo actions
187   void ClearRedos();
188   
189   //! Redoes last operation
190   void Redo();
191
192   //! Creates and locates in the document a new object
193   //! \param theKind kind of the created object, can not be UNKNOWN
194   //! \returns the created object
195   HYDROData_Object CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Object (const ObjectKind)] ;
196   %MethodCode
197
198     Handle(HYDROData_Object) anObject;
199     Py_BEGIN_ALLOW_THREADS
200     anObject =  sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) :
201                                 sipCpp->CreateObject( a0 );
202     Py_END_ALLOW_THREADS
203
204     sipRes = createPointer( anObject );
205     
206   %End
207
208 protected:
209
210   //! Creates new document: private because "Document" method must be used instead of direct creation.
211   HYDROData_Document();
212   
213   //! Deletes all high-level data, managed this document
214   ~HYDROData_Document();
215
216 };