1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 #include <HYDROData_Document.h>
28 HYDROData_Object* copyObject( HYDROData_Object* theObject );
29 Handle(HYDROData_Object) createHandle( HYDROData_Object* theObject );
30 HYDROData_Object* createPointer( const Handle(HYDROData_Object)& theObject );
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
42 class HYDROData_Document
45 #include <HYDROData_Document.h>
48 %ConvertToSubClassCode
49 if ( !Handle(HYDROData_Document)::DownCast( sipCpp ).IsNull() )
50 sipClass = sipClass_HYDROData_Document;
57 HYDROData_Object* copyObject( HYDROData_Object* theObject )
59 HYDROData_Object* aRes = NULL;
60 if ( theObject == NULL )
63 switch( theObject->GetKind() )
67 aRes = new HYDROData_Image( *dynamic_cast<HYDROData_Image*>( theObject ) );
72 aRes = new HYDROData_Polyline( *dynamic_cast<HYDROData_Polyline*>( theObject ) );
77 aRes = new HYDROData_Bathymetry( *dynamic_cast<HYDROData_Bathymetry*>( theObject ) );
80 case KIND_CALCULATION:
82 aRes = new HYDROData_Calculation( *dynamic_cast<HYDROData_Calculation*>( theObject ) );
87 aRes = new HYDROData_Zone( *dynamic_cast<HYDROData_Zone*>( theObject ) );
95 Handle(HYDROData_Object) createHandle( HYDROData_Object* theObject )
97 Handle(HYDROData_Object) aRes = copyObject( theObject );
101 HYDROData_Object* createPointer( const Handle(HYDROData_Object)& theObject )
103 HYDROData_Object* aRes = NULL;
105 if ( !theObject.IsNull() )
106 aRes = copyObject( theObject.operator->() );
115 //! Returns the existing document or creates new if it is not exist
116 static HYDROData_Document Document( const int theStudyID ) [Handle_HYDROData_Document (const int)] ;
119 Handle(HYDROData_Document) aDocument;
121 Py_BEGIN_ALLOW_THREADS
122 aDocument = HYDROData_Document::Document( a0 );
125 if ( !aDocument.IsNull() )
126 sipRes = aDocument.operator->();
130 //! Returns true if data model contains document for this study
131 static bool HasDocument( const int theStudyID );
133 //! Loads the OCAF document from the file.
134 //! \param theFileName full name of the file to load
135 //! \param theStudyID identifier of the SALOME study to associate with loaded file
136 //! \returns error status (OK in case of success)
137 static Data_DocError Load( const char* theFileName, const int theStudyID );
139 //! Saves the OCAF document to the file.
140 //! \param theFileName full name of the file to store
141 //! \returns error status (OK in case of success)
142 Data_DocError Save( const char* theFileName );
144 //! Removes document data
147 //! Starts a new operation (opens a tansaction)
148 void StartOperation();
150 //! Finishes the previously started operation (closes the transaction)
151 //void CommitOperation(
152 // const TCollection_ExtendedString& theName = TCollection_ExtendedString() );
154 //! Aborts the operation
155 void AbortOperation();
157 //! Returns true if operation has been started, but not yet finished or aborted
160 //! Returns true if document was modified (since creation/opening)
163 //! Returns True if there are available Undos
166 //! Returns a list of stored undo actions
167 //const TDF_DeltaList& GetUndos();
169 //! Clears a list of stored undo actions
172 //! Undoes last operation
175 //! Returns True if there are available Redos
178 //! Returns a list of stored undo actions
179 //const TDF_DeltaList& GetRedos();
181 //! Clears a list of stored undo actions
184 //! Redoes last operation
187 //! Creates and locates in the document a new object
188 //! \param theKind kind of the created object, can not be UNKNOWN
189 //! \returns the created object
190 HYDROData_Object CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Object (const ObjectKind)] ;
193 Handle(HYDROData_Object) anObject;
194 Py_BEGIN_ALLOW_THREADS
195 anObject = sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) :
196 sipCpp->CreateObject( a0 );
199 sipRes = createPointer( anObject );
205 //! Creates new document: private because "Document" method must be used instead of direct creation.
206 HYDROData_Document();
208 //! Deletes all high-level data, managed this document
209 ~HYDROData_Document();