Salome HOME
First implementation of python API for HYDRO module.
[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 enum Data_DocError {
28   DocError_OK = 0, ///< success
29   DocError_ResourcesProblem, ///< resources files are invalid or not found
30   DocError_CanNotOpen, ///< can not open file for reading or writing
31   DocError_InvalidVersion, ///< version of document is different than expected
32   DocError_InvalidFormat, ///< format of the document is bad
33   DocError_UnknownProblem ///< problem has unknown nature
34 };
35
36 class HYDROData_Document
37 {
38 %TypeHeaderCode
39 #include <HYDROData_Document.h>
40 %End
41
42 %ConvertToSubClassCode
43     if ( !Handle(HYDROData_Document)::DownCast( sipCpp ).IsNull() )
44       sipClass = sipClass_HYDROData_Document;
45     else
46       sipClass = NULL;
47 %End
48
49 public:
50
51   //! Returns the existing document or creates new if it is not exist
52   static HYDROData_Document Document( const int theStudyID ) [Handle_HYDROData_Document (const int)] ;
53   %MethodCode
54
55     Py_BEGIN_ALLOW_THREADS
56     Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( a0 );
57     if ( !aDocument.IsNull() )
58     {
59       sipRes = aDocument.operator->();
60     }
61     
62     Py_END_ALLOW_THREADS
63     
64   %End
65
66   //! Returns true if data model contains document for this study
67   static bool HasDocument( const int theStudyID );
68
69   //! Loads the OCAF document from the file.
70   //! \param theFileName full name of the file to load
71   //! \param theStudyID identifier of the SALOME study to associate with loaded file
72   //! \returns error status (OK in case of success)
73   static Data_DocError Load( const char* theFileName, const int theStudyID );
74
75   //! Saves the OCAF document to the file.
76   //! \param theFileName full name of the file to store
77   //! \returns error status (OK in case of success)
78   Data_DocError Save( const char* theFileName );
79
80   //! Removes document data
81   void Close();
82
83   //! Starts a new operation (opens a tansaction)
84   void StartOperation();
85   
86   //! Finishes the previously started operation (closes the transaction)
87   //void CommitOperation(
88   //  const TCollection_ExtendedString& theName = TCollection_ExtendedString() );
89     
90   //! Aborts the operation 
91   void AbortOperation();
92   
93   //! Returns true if operation has been started, but not yet finished or aborted
94   bool IsOperation();
95   
96   //! Returns true if document was modified (since creation/opening)
97   bool IsModified();
98
99   //! Returns True if there are available Undos
100   bool CanUndo();
101   
102   //! Returns a list of stored undo actions
103   //const TDF_DeltaList& GetUndos();
104   
105   //! Clears a list of stored undo actions
106   void ClearUndos();
107   
108   //! Undoes last operation
109   void Undo();
110
111   //! Returns True if there are available Redos
112   bool CanRedo();
113   
114   //! Returns a list of stored undo actions
115   //const TDF_DeltaList& GetRedos();
116   
117   //! Clears a list of stored undo actions
118   void ClearRedos();
119   
120   //! Redoes last operation
121   void Redo();
122
123   //! Creates and locates in the document a new object
124   //! \param theKind kind of the created object, can not be UNKNOWN
125   //! \returns the created object
126   HYDROData_Object CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Object (const ObjectKind)] ;
127   %MethodCode
128
129     Py_BEGIN_ALLOW_THREADS
130     
131     Handle(HYDROData_Object) anObject = 
132       sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) : sipCpp->CreateObject( a0 );
133     if ( !anObject.IsNull() )
134     {
135       switch( anObject->GetKind() )
136       {
137         case KIND_BATHYMETRY:
138         {
139           Handle(HYDROData_Bathymetry) aBathymetry =
140             Handle(HYDROData_Bathymetry)::DownCast( anObject );
141           sipRes = new HYDROData_Bathymetry( *aBathymetry.operator->() );
142           break;
143         }
144       }
145     }
146         
147     Py_END_ALLOW_THREADS
148     
149   %End
150
151 protected:
152
153   //friend class HYDROData_Iterator;
154   //friend class test_HYDROData_Document;
155
156   //! Creates new document: private because "Document" method must be used instead of direct creation.
157   HYDROData_Document();
158   
159   //! Deletes all high-level data, managed this document
160   ~HYDROData_Document();
161
162 };