X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Document.h;h=6e164226183d804685bf44b6ff61ce2ceea3de71;hb=c5ae2ec8ffa7b30a77bcef4fbb316c6ece4928b5;hp=1ec24ee7e11540fc86a1c47665f771660f690094;hpb=2d3a78deaed27c428589ef3474c1c346324962f2;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Document.h b/src/HYDROData/HYDROData_Document.h index 1ec24ee7..6e164226 100644 --- a/src/HYDROData/HYDROData_Document.h +++ b/src/HYDROData/HYDROData_Document.h @@ -1,13 +1,37 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + #ifndef HYDROData_Document_HeaderFile #define HYDROData_Document_HeaderFile -#include -#include - +#include #include -class QFile; +class HYDROData_InterpolatorsFactory; +class HYDROData_IProfilesInterpolator; +class Handle(HYDROData_StricklerTable); +class Handle(HYDROData_LandCoverMap); +class QFile; +class gp_Pnt2d; +class gp_Pnt; +class gp_XYZ; +class gp_XY; /** * Errors that could appear on document open/save actions. @@ -42,9 +66,21 @@ public: //! Returns the existing document or creates new if it is not exist HYDRODATA_EXPORT static Handle(HYDROData_Document) Document(const int theStudyID); + //! Returns the document by object + HYDRODATA_EXPORT static Handle(HYDROData_Document) Document( + const TDF_Label& theObjectLabel ); + +public: + //! Returns true if data model contains document for this study HYDRODATA_EXPORT static bool HasDocument(const int theStudyID); + //! Get study id by document instance, if document doesn't exists return false + HYDRODATA_EXPORT static bool DocumentId( const Handle(HYDROData_Document)& theDocument, + int& theDocId ); + +public: + //! Loads the OCAF document from the file. //! \param theFileName full name of the file to load //! \param theStudyID identifier of the SALOME study to associate with loaded file @@ -59,10 +95,73 @@ public: //! Removes document data HYDRODATA_EXPORT void Close(); +public: + + // Returns name of document instance in python dump script + HYDRODATA_EXPORT QString GetDocPyName() const; + //! Dump study document to Python script representation. //! \param theFileName full name of the file to store //! \returns true if document has been successfuly dumped - HYDRODATA_EXPORT bool DumpToPython( const QString& theFileName ) const; + HYDRODATA_EXPORT bool DumpToPython( const QString& thePyScriptPath, + const bool theIsMultiFile ) const; + + //! Dump model data to Python script representation. + HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath, + MapOfTreatedObjects& theTreatedObjects, + const bool theIsMultiFile ) const; + + HYDRODATA_EXPORT void CollectQGISValues( const QString& theAttrName, + QStringList& theAttrValues, + QStringList& theStricklerTypes ) const; + +public: + + // Methods to work with objects presentation. + + //! Returns the order of objects presentation. Objects in returned sequence + //! are order from top to low depending on z-level parameter. Objects that + //! have no z-level parameter are located at the end of sequence and + //! sorted alphabetically. + //! Only the following types of objects considered: + //! 1. KIND_IMAGE + //! 2. KIND_IMMERSIBLE_ZONE + //! 3. KIND_CHANNEL + //! 4. KIND_RIVER + //! 5. KIND_STREAM + //! 6. KIND_OBSTACLE + //! 7. KIND_DIGUE + //! 8. KIND_POLYLINEXY + //! 9. KIND_ZONE + //! \param theIsAll if flag is true then all objects will be included, + //! otherwise only objects which have the z-level parameter + //! \returns ordered sequence of objects + HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetObjectsLayerOrder( + const Standard_Boolean theIsAll = Standard_True ) const; + + //! Sets the order of objects presentation. + HYDRODATA_EXPORT void SetObjectsLayerOrder( const HYDROData_SequenceOfObjects& theOrder ); + + //! Show object at the top of other model objects. If the object + //! already has the z-level parameter then nothing will be done. + HYDRODATA_EXPORT void Show( const Handle_HYDROData_Entity& theObject ); + + //! Show sequence of objects at the top of other model objects. + //! The objects from the sequence will be sorted alphabetically at first. + HYDRODATA_EXPORT void Show( const HYDROData_SequenceOfObjects& theObjects ); + + //! Removes the order of objects presentation. + HYDRODATA_EXPORT void RemoveObjectsLayerOrder(); + + HYDRODATA_EXPORT void GetLocalCS( double&, double& ) const; + HYDRODATA_EXPORT void SetLocalCS( double, double ); + HYDRODATA_EXPORT void Transform( double& X, double& Y, bool IsToLocalCS ) const; + HYDRODATA_EXPORT void Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const; + HYDRODATA_EXPORT void Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const; + HYDRODATA_EXPORT void Transform( gp_XY& thePnt, bool IsToLocalCS ) const; + HYDRODATA_EXPORT void Transform( double& X, double& Y, double& Z, bool IsToLocalCS ) const; + +public: //! Starts a new operation (opens a tansaction) HYDRODATA_EXPORT void StartOperation(); @@ -76,6 +175,8 @@ public: //! Returns true if document was modified (since creation/opening) HYDRODATA_EXPORT bool IsModified(); +public: + //! Returns True if there are available Undos HYDRODATA_EXPORT bool CanUndo(); //! Returns a list of stored undo actions @@ -94,39 +195,83 @@ public: //! Redoes last operation HYDRODATA_EXPORT void Redo(); +public: + //! Creates and locates in the document a new object //! \param theKind kind of the created object, can not be UNKNOWN //! \returns the created object - HYDRODATA_EXPORT Handle_HYDROData_Object CreateObject(const ObjectKind theKind); + HYDRODATA_EXPORT Handle(HYDROData_Entity) CreateObject(const ObjectKind theKind); -protected: + //! Find the data object with the specified name. + HYDRODATA_EXPORT Handle(HYDROData_Entity) FindObjectByName( + const QString& theName, + const ObjectKind theObjectKind = KIND_UNKNOWN ) const; + + //! Find the data objects with the specified names. + HYDRODATA_EXPORT HYDROData_SequenceOfObjects FindObjectsByNames( + const QStringList& theNames, + const ObjectKind theObjectKind = KIND_UNKNOWN ) const; + +public: + + //! Returns interpolator factory instance + HYDRODATA_EXPORT HYDROData_InterpolatorsFactory* GetInterpolatorsFactory(); + + //! Get the appropriate interpolator by the name. + HYDRODATA_EXPORT HYDROData_IProfilesInterpolator* GetInterpolator( const TCollection_AsciiString& theName ) const; + + //! Get list of registered interpolator names. + HYDRODATA_EXPORT NCollection_Sequence GetInterpolatorNames() const; + +public: + //! Returns default strickler coefficient + HYDRODATA_EXPORT double GetDefaultStricklerCoefficient() const; + + //! Sets default strickler coefficient + HYDRODATA_EXPORT void SetDefaultStricklerCoefficient( double ) const; + + HYDRODATA_EXPORT QColor GetAssociatedColor( const QString& theStricklerType, const Handle(HYDROData_StricklerTable)& theTable ) const; + +protected: friend class HYDROData_Iterator; friend class test_HYDROData_Document; //! Creates new document: private because "Document" method must be used instead of direct creation. - HYDROData_Document(); + HYDRODATA_EXPORT HYDROData_Document(); //! Creates new document by existing OCAF structure - HYDROData_Document(const Handle(TDocStd_Document)& theDoc); + HYDRODATA_EXPORT HYDROData_Document(const Handle(TDocStd_Document)& theDoc); //! Deletes all high-level data, managed this document - ~HYDROData_Document(); + HYDRODATA_EXPORT ~HYDROData_Document(); //! Returns the new identifier of the new object (may be used for correct ordering of objects) HYDRODATA_EXPORT int NewID(); //! Returns the label where the objects are located (used by Iterator) - TDF_Label LabelOfObjects(); + HYDRODATA_EXPORT TDF_Label LabelOfObjects(); + + HYDRODATA_EXPORT TDF_Label LabelOfLocalCS() const; private: + // Dump header Python part in to file \c theFile + bool DumpToPython( QFile& theFile, + MapOfTreatedObjects& theTreatedObjects ) const; + // Dump objects of type \c theObjectKind to file \c theFile - bool dumpPartitionToPython( QFile& theFile, - QMap& theDumpedObjects, - const ObjectKind& theObjectKind ) const; + bool dumpPartitionToPython( QFile& theFile, + const QString& thePyScriptPath, + const bool theIsMultiFile, + MapOfTreatedObjects& theDumpedObjects, + const ObjectKind& theObjectKind ) const; + void UpdateLCSFields() const; private: Handle(TDocStd_Document) myDoc; ///< OCAF document instance corresponding for keeping all persistent data int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method + double myLX, myLY; + + HYDROData_InterpolatorsFactory* myInterpolatorsFactory; ///< iterpolators factory }; #endif