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 HYDROData_Document* aDoc = dynamic_cast< HYDROData_Document*>( sipCpp );
47 sipClass = sipClass_HYDROData_Document;
54 HYDROData_Entity* copyObject( HYDROData_Entity* theObject )
56 HYDROData_Entity* aRes = NULL;
57 if ( theObject == NULL )
60 switch( theObject->GetKind() )
64 aRes = new HYDROData_Image( *dynamic_cast<HYDROData_Image*>( theObject ) );
69 aRes = new HYDROData_Polyline3D( *dynamic_cast<HYDROData_Polyline3D*>( theObject ) );
74 aRes = new HYDROData_Bathymetry( *dynamic_cast<HYDROData_Bathymetry*>( theObject ) );
79 aRes = new HYDROData_AltitudeObject( *dynamic_cast<HYDROData_AltitudeObject*>( theObject ) );
82 case KIND_IMMERSIBLE_ZONE:
84 aRes = new HYDROData_ImmersibleZone( *dynamic_cast<HYDROData_ImmersibleZone*>( theObject ) );
89 aRes = new HYDROData_BCPolygon( *dynamic_cast<HYDROData_BCPolygon*>( theObject ) );
94 aRes = new HYDROData_River( *dynamic_cast<HYDROData_River*>( theObject ) );
99 aRes = new HYDROData_Stream( *dynamic_cast<HYDROData_Stream*>( theObject ) );
102 case KIND_CONFLUENCE:
104 aRes = new HYDROData_Confluence( *dynamic_cast<HYDROData_Confluence*>( theObject ) );
109 aRes = new HYDROData_Channel( *dynamic_cast<HYDROData_Channel*>( theObject ) );
114 aRes = new HYDROData_Obstacle( *dynamic_cast<HYDROData_Obstacle*>( theObject ) );
119 aRes = new HYDROData_Digue( *dynamic_cast<HYDROData_Digue*>( theObject ) );
124 aRes = new HYDROData_Profile( *dynamic_cast<HYDROData_Profile*>( theObject ) );
129 aRes = new HYDROData_ProfileUZ( *dynamic_cast<HYDROData_ProfileUZ*>( theObject ) );
132 case KIND_POLYLINEXY:
134 aRes = new HYDROData_PolylineXY( *dynamic_cast<HYDROData_PolylineXY*>( theObject ) );
137 case KIND_CALCULATION:
139 aRes = new HYDROData_CalculationCase( *dynamic_cast<HYDROData_CalculationCase*>( theObject ) );
144 aRes = new HYDROData_Region( *dynamic_cast<HYDROData_Region*>( theObject ) );
149 aRes = new HYDROData_Zone( *dynamic_cast<HYDROData_Zone*>( theObject ) );
152 case KIND_SHAPES_GROUP:
154 aRes = new HYDROData_ShapesGroup( *dynamic_cast<HYDROData_ShapesGroup*>( theObject ) );
157 case KIND_SPLIT_GROUP:
159 aRes = new HYDROData_SplitShapesGroup( *dynamic_cast<HYDROData_SplitShapesGroup*>( theObject ) );
162 case KIND_OBSTACLE_ALTITUDE:
164 aRes = new HYDROData_ObstacleAltitude( *dynamic_cast<HYDROData_ObstacleAltitude*>( theObject ) );
167 case KIND_STREAM_ALTITUDE:
169 aRes = new HYDROData_StreamAltitude( *dynamic_cast<HYDROData_StreamAltitude*>( theObject ) );
172 case KIND_STRICKLER_TABLE:
174 aRes = new HYDROData_StricklerTable( *dynamic_cast<HYDROData_StricklerTable*>( theObject ) );
177 case KIND_LAND_COVER_MAP:
179 aRes = new HYDROData_LandCoverMap( *dynamic_cast<HYDROData_LandCoverMap*>( theObject ) );
187 Handle(HYDROData_Entity) createHandle( HYDROData_Entity* theObject )
189 Handle(HYDROData_Entity) aRes = copyObject( theObject );
193 HYDROData_Entity* createPointer( const Handle(HYDROData_Entity)& theObject )
195 HYDROData_Entity* aRes = NULL;
197 if ( !theObject.IsNull() )
198 aRes = copyObject( theObject.operator->() );
207 //! Returns the existing document or creates new if it is not exist
208 static HYDROData_Document Document( const int theStudyID ) [opencascade::handle<HYDROData_Document> (const int)] ;
211 Handle(HYDROData_Document) aDocument;
213 Py_BEGIN_ALLOW_THREADS
214 aDocument = HYDROData_Document::Document( a0 );
217 if ( !aDocument.IsNull() )
218 sipRes = aDocument.operator->();
222 //! Returns true if data model contains document for this study
223 static bool HasDocument( const int theStudyID );
225 //! Loads the OCAF document from the file.
226 //! \param theFileName full name of the file to load
227 //! \param theStudyID identifier of the SALOME study to associate with loaded file
228 //! \returns error status (OK in case of success)
229 static Data_DocError Load( const char* theFileName, const int theStudyID );
231 //! Saves the OCAF document to the file.
232 //! \param theFileName full name of the file to store
233 //! \returns error status (OK in case of success)
234 Data_DocError Save( const char* theFileName );
236 //! Removes document data
239 //! Starts a new operation (opens a tansaction)
240 void StartOperation();
242 //! Finishes the previously started operation (closes the transaction)
243 //void CommitOperation(
244 // const TCollection_ExtendedString& theName = TCollection_ExtendedString() );
246 //! Aborts the operation
247 void AbortOperation();
249 //! Returns true if operation has been started, but not yet finished or aborted
252 //! Returns true if document was modified (since creation/opening)
255 //! Returns True if there are available Undos
258 //! Returns a list of stored undo actions
259 //const TDF_DeltaList& GetUndos();
261 //! Clears a list of stored undo actions
264 //! Undoes last operation
267 //! Returns True if there are available Redos
270 //! Returns a list of stored undo actions
271 //const TDF_DeltaList& GetRedos();
273 //! Clears a list of stored undo actions
276 //! Redoes last operation
279 //! Creates and locates in the document a new object
280 //! \param theKind kind of the created object, can not be UNKNOWN
281 //! \returns the created object
282 HYDROData_Entity CreateObject( const ObjectKind theKind ) [opencascade::handle<HYDROData_Entity> (const ObjectKind)] ;
285 Handle(HYDROData_Entity) anObject;
286 Py_BEGIN_ALLOW_THREADS
287 anObject = sipSelfWasArg ? sipCpp->HYDROData_Document::CreateObject( a0 ) :
288 sipCpp->CreateObject( a0 );
291 sipRes = createPointer( anObject );
295 HYDROData_Entity FindObjectByName( const QString& theName,
296 const ObjectKind theKind = KIND_UNKNOWN )
297 [opencascade::handle<HYDROData_Entity> (const QString&, const ObjectKind)] ;
300 Handle(HYDROData_Entity) anObject;
301 Py_BEGIN_ALLOW_THREADS
302 anObject = sipSelfWasArg ? sipCpp->HYDROData_Document::FindObjectByName( *a0, a1 ) :
303 sipCpp->FindObjectByName( *a0, a1 );
306 sipRes = createPointer( anObject );
310 HYDROData_SequenceOfObjects FindObjectsByNames( const QStringList& theNames,
311 const ObjectKind theKind = KIND_UNKNOWN );
313 void SetLocalCS( double, double );
315 //! Get the appropriate interpolator by the name.
316 HYDROData_IProfilesInterpolator* GetInterpolator( const TCollection_AsciiString& theName ) const;
318 //! Get list of registered interpolator names.
319 NCollection_Sequence<TCollection_AsciiString> GetInterpolatorNames() const;
323 //! Creates new document: private because "Document" method must be used instead of direct creation.
324 HYDROData_Document();
326 //! Deletes all high-level data, managed this document
327 ~HYDROData_Document();