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_Entity* copyObject( HYDROData_Entity* theObject );
29 Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject );
30 HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& 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_Entity* copyObject( HYDROData_Entity* theObject )
59 HYDROData_Entity* aRes = NULL;
60 if ( theObject == NULL )
63 switch( theObject->GetKind() )
67 aRes = new HYDROData_Image( *dynamic_cast<HYDROData_Image*>( theObject ) );
72 aRes = new HYDROData_Polyline3D( *dynamic_cast<HYDROData_Polyline3D*>( theObject ) );
77 aRes = new HYDROData_Bathymetry( *dynamic_cast<HYDROData_Bathymetry*>( theObject ) );
82 aRes = new HYDROData_AltitudeObject( *dynamic_cast<HYDROData_AltitudeObject*>( theObject ) );
85 case KIND_IMMERSIBLE_ZONE:
87 aRes = new HYDROData_ImmersibleZone( *dynamic_cast<HYDROData_ImmersibleZone*>( theObject ) );
92 aRes = new HYDROData_River( *dynamic_cast<HYDROData_River*>( theObject ) );
97 aRes = new HYDROData_Stream( *dynamic_cast<HYDROData_Stream*>( theObject ) );
100 case KIND_CONFLUENCE:
102 aRes = new HYDROData_Confluence( *dynamic_cast<HYDROData_Confluence*>( theObject ) );
107 aRes = new HYDROData_Channel( *dynamic_cast<HYDROData_Channel*>( theObject ) );
112 aRes = new HYDROData_Obstacle( *dynamic_cast<HYDROData_Obstacle*>( theObject ) );
117 aRes = new HYDROData_Digue( *dynamic_cast<HYDROData_Digue*>( theObject ) );
122 aRes = new HYDROData_Profile( *dynamic_cast<HYDROData_Profile*>( theObject ) );
127 aRes = new HYDROData_ProfileUZ( *dynamic_cast<HYDROData_ProfileUZ*>( theObject ) );
130 case KIND_POLYLINEXY:
132 aRes = new HYDROData_PolylineXY( *dynamic_cast<HYDROData_PolylineXY*>( theObject ) );
135 case KIND_CALCULATION:
137 aRes = new HYDROData_CalculationCase( *dynamic_cast<HYDROData_CalculationCase*>( theObject ) );
142 aRes = new HYDROData_Region( *dynamic_cast<HYDROData_Region*>( theObject ) );
147 aRes = new HYDROData_Zone( *dynamic_cast<HYDROData_Zone*>( theObject ) );
150 case KIND_SHAPES_GROUP:
152 aRes = new HYDROData_ShapesGroup( *dynamic_cast<HYDROData_ShapesGroup*>( theObject ) );
155 case KIND_SPLITTED_GROUP:
157 aRes = new HYDROData_SplittedShapesGroup( *dynamic_cast<HYDROData_SplittedShapesGroup*>( theObject ) );
160 case KIND_OBSTACLE_ALTITUDE:
162 aRes = new HYDROData_ObstacleAltitude( *dynamic_cast<HYDROData_ObstacleAltitude*>( theObject ) );
170 Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject )
172 Handle(HYDROData_Entity) aRes = copyObject( theObject );
176 HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& theObject )
178 HYDROData_Entity* aRes = NULL;
180 if ( !theObject.IsNull() )
181 aRes = copyObject( theObject.operator->() );
190 //! Returns the existing document or creates new if it is not exist
191 static HYDROData_Document Document( const int theStudyID ) [Handle_HYDROData_Document (const int)] ;
194 Handle(HYDROData_Document) aDocument;
196 Py_BEGIN_ALLOW_THREADS
197 aDocument = HYDROData_Document::Document( a0 );
200 if ( !aDocument.IsNull() )
201 sipRes = aDocument.operator->();
205 //! Returns true if data model contains document for this study
206 static bool HasDocument( const int theStudyID );
208 //! Loads the OCAF document from the file.
209 //! \param theFileName full name of the file to load
210 //! \param theStudyID identifier of the SALOME study to associate with loaded file
211 //! \returns error status (OK in case of success)
212 static Data_DocError Load( const char* theFileName, const int theStudyID );
214 //! Saves the OCAF document to the file.
215 //! \param theFileName full name of the file to store
216 //! \returns error status (OK in case of success)
217 Data_DocError Save( const char* theFileName );
219 //! Removes document data
222 //! Starts a new operation (opens a tansaction)
223 void StartOperation();
225 //! Finishes the previously started operation (closes the transaction)
226 //void CommitOperation(
227 // const TCollection_ExtendedString& theName = TCollection_ExtendedString() );
229 //! Aborts the operation
230 void AbortOperation();
232 //! Returns true if operation has been started, but not yet finished or aborted
235 //! Returns true if document was modified (since creation/opening)
238 //! Returns True if there are available Undos
241 //! Returns a list of stored undo actions
242 //const TDF_DeltaList& GetUndos();
244 //! Clears a list of stored undo actions
247 //! Undoes last operation
250 //! Returns True if there are available Redos
253 //! Returns a list of stored undo actions
254 //const TDF_DeltaList& GetRedos();
256 //! Clears a list of stored undo actions
259 //! Redoes last operation
262 //! Creates and locates in the document a new object
263 //! \param theKind kind of the created object, can not be UNKNOWN
264 //! \returns the created object
265 HYDROData_Entity CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Entity (const ObjectKind)] ;
268 Handle(HYDROData_Entity) anObject;
269 Py_BEGIN_ALLOW_THREADS
270 anObject = sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) :
271 sipCpp->CreateObject( a0 );
274 sipRes = createPointer( anObject );
280 //! Creates new document: private because "Document" method must be used instead of direct creation.
281 HYDROData_Document();
283 //! Deletes all high-level data, managed this document
284 ~HYDROData_Document();