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