1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <HYDROData_Document.h>
24 HYDROData_Entity* copyObject( HYDROData_Entity* theObject );
25 Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject );
26 HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& theObject );
30 DocError_OK = 0, ///< success
31 DocError_ResourcesProblem, ///< resources files are invalid or not found
32 DocError_CanNotOpen, ///< can not open file for reading or writing
33 DocError_InvalidVersion, ///< version of document is different than expected
34 DocError_InvalidFormat, ///< format of the document is bad
35 DocError_UnknownProblem ///< problem has unknown nature
38 class HYDROData_Document
41 #include <HYDROData_Document.h>
44 %ConvertToSubClassCode
45 if ( !Handle(HYDROData_Document)::DownCast( sipCpp ).IsNull() )
46 sipClass = sipClass_HYDROData_Document;
53 HYDROData_Entity* copyObject( HYDROData_Entity* theObject )
55 HYDROData_Entity* aRes = NULL;
56 if ( theObject == NULL )
59 switch( theObject->GetKind() )
63 aRes = new HYDROData_Image( *dynamic_cast<HYDROData_Image*>( theObject ) );
68 aRes = new HYDROData_Polyline3D( *dynamic_cast<HYDROData_Polyline3D*>( theObject ) );
73 aRes = new HYDROData_Bathymetry( *dynamic_cast<HYDROData_Bathymetry*>( theObject ) );
78 aRes = new HYDROData_AltitudeObject( *dynamic_cast<HYDROData_AltitudeObject*>( theObject ) );
81 case KIND_IMMERSIBLE_ZONE:
83 aRes = new HYDROData_ImmersibleZone( *dynamic_cast<HYDROData_ImmersibleZone*>( theObject ) );
88 aRes = new HYDROData_River( *dynamic_cast<HYDROData_River*>( theObject ) );
93 aRes = new HYDROData_Stream( *dynamic_cast<HYDROData_Stream*>( theObject ) );
98 aRes = new HYDROData_Confluence( *dynamic_cast<HYDROData_Confluence*>( theObject ) );
103 aRes = new HYDROData_Channel( *dynamic_cast<HYDROData_Channel*>( theObject ) );
108 aRes = new HYDROData_Obstacle( *dynamic_cast<HYDROData_Obstacle*>( theObject ) );
113 aRes = new HYDROData_Digue( *dynamic_cast<HYDROData_Digue*>( theObject ) );
118 aRes = new HYDROData_Profile( *dynamic_cast<HYDROData_Profile*>( theObject ) );
123 aRes = new HYDROData_ProfileUZ( *dynamic_cast<HYDROData_ProfileUZ*>( theObject ) );
126 case KIND_POLYLINEXY:
128 aRes = new HYDROData_PolylineXY( *dynamic_cast<HYDROData_PolylineXY*>( theObject ) );
131 case KIND_CALCULATION:
133 aRes = new HYDROData_CalculationCase( *dynamic_cast<HYDROData_CalculationCase*>( theObject ) );
138 aRes = new HYDROData_Region( *dynamic_cast<HYDROData_Region*>( theObject ) );
143 aRes = new HYDROData_Zone( *dynamic_cast<HYDROData_Zone*>( theObject ) );
146 case KIND_SHAPES_GROUP:
148 aRes = new HYDROData_ShapesGroup( *dynamic_cast<HYDROData_ShapesGroup*>( theObject ) );
151 case KIND_SPLITTED_GROUP:
153 aRes = new HYDROData_SplittedShapesGroup( *dynamic_cast<HYDROData_SplittedShapesGroup*>( theObject ) );
156 case KIND_OBSTACLE_ALTITUDE:
158 aRes = new HYDROData_ObstacleAltitude( *dynamic_cast<HYDROData_ObstacleAltitude*>( theObject ) );
161 case KIND_STREAM_ALTITUDE:
163 aRes = new HYDROData_StreamAltitude( *dynamic_cast<HYDROData_StreamAltitude*>( theObject ) );
166 case KIND_STRICKLER_TABLE:
168 aRes = new HYDROData_StricklerTable( *dynamic_cast<HYDROData_StricklerTable*>( theObject ) );
171 case KIND_LAND_COVER_MAP:
173 aRes = new HYDROData_LandCoverMap( *dynamic_cast<HYDROData_LandCoverMap*>( theObject ) );
181 Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject )
183 Handle(HYDROData_Entity) aRes = copyObject( theObject );
187 HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& theObject )
189 HYDROData_Entity* aRes = NULL;
191 if ( !theObject.IsNull() )
192 aRes = copyObject( theObject.operator->() );
201 //! Returns the existing document or creates new if it is not exist
202 static HYDROData_Document Document( const int theStudyID ) [Handle_HYDROData_Document (const int)] ;
205 Handle(HYDROData_Document) aDocument;
207 Py_BEGIN_ALLOW_THREADS
208 aDocument = HYDROData_Document::Document( a0 );
211 if ( !aDocument.IsNull() )
212 sipRes = aDocument.operator->();
216 //! Returns true if data model contains document for this study
217 static bool HasDocument( const int theStudyID );
219 //! Loads the OCAF document from the file.
220 //! \param theFileName full name of the file to load
221 //! \param theStudyID identifier of the SALOME study to associate with loaded file
222 //! \returns error status (OK in case of success)
223 static Data_DocError Load( const char* theFileName, const int theStudyID );
225 //! Saves the OCAF document to the file.
226 //! \param theFileName full name of the file to store
227 //! \returns error status (OK in case of success)
228 Data_DocError Save( const char* theFileName );
230 //! Removes document data
233 //! Starts a new operation (opens a tansaction)
234 void StartOperation();
236 //! Finishes the previously started operation (closes the transaction)
237 //void CommitOperation(
238 // const TCollection_ExtendedString& theName = TCollection_ExtendedString() );
240 //! Aborts the operation
241 void AbortOperation();
243 //! Returns true if operation has been started, but not yet finished or aborted
246 //! Returns true if document was modified (since creation/opening)
249 //! Returns True if there are available Undos
252 //! Returns a list of stored undo actions
253 //const TDF_DeltaList& GetUndos();
255 //! Clears a list of stored undo actions
258 //! Undoes last operation
261 //! Returns True if there are available Redos
264 //! Returns a list of stored undo actions
265 //const TDF_DeltaList& GetRedos();
267 //! Clears a list of stored undo actions
270 //! Redoes last operation
273 //! Creates and locates in the document a new object
274 //! \param theKind kind of the created object, can not be UNKNOWN
275 //! \returns the created object
276 HYDROData_Entity CreateObject( const ObjectKind theKind ) [Handle_HYDROData_Entity (const ObjectKind)] ;
279 Handle(HYDROData_Entity) anObject;
280 Py_BEGIN_ALLOW_THREADS
281 anObject = sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) :
282 sipCpp->CreateObject( a0 );
285 sipRes = createPointer( anObject );
289 HYDROData_Entity FindObjectByName( const QString& theName,
290 const ObjectKind theKind = KIND_UNKNOWN )
291 [Handle_HYDROData_Entity (const QString&, const ObjectKind)] ;
294 Handle(HYDROData_Entity) anObject;
295 Py_BEGIN_ALLOW_THREADS
296 anObject = sipSelfWasArg ? sipCpp->HYDROData_Document::FindObjectByName( *a0, a1 ) :
297 sipCpp->FindObjectByName( *a0, a1 );
300 sipRes = createPointer( anObject );
304 HYDROData_SequenceOfObjects FindObjectsByNames( const QStringList& theNames,
305 const ObjectKind theKind = KIND_UNKNOWN );
307 void SetLocalCS( double, double );
309 //! Get the appropriate interpolator by the name.
310 HYDROData_IProfilesInterpolator* GetInterpolator( const TCollection_AsciiString& theName ) const;
312 //! Get list of registered interpolator names.
313 NCollection_Sequence<TCollection_AsciiString> GetInterpolatorNames() const;
317 //! Creates new document: private because "Document" method must be used instead of direct creation.
318 HYDROData_Document();
320 //! Deletes all high-level data, managed this document
321 ~HYDROData_Document();