From 389e43ab82f20b133ebcc1a98aee9f460176c4e1 Mon Sep 17 00:00:00 2001 From: adv Date: Fri, 6 Sep 2013 08:08:10 +0000 Subject: [PATCH] File path data has been added for Bathymetry and Image objects. --- src/HYDROData/HYDROData_Bathymetry.cxx | 21 ++++++++++++++++++++- src/HYDROData/HYDROData_Bathymetry.h | 14 +++++++++++++- src/HYDROData/HYDROData_Image.cxx | 18 ++++++++++++++++++ src/HYDROData/HYDROData_Image.h | 16 ++++++++++++++-- 4 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 7da61f70..14e6a24a 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -274,6 +275,23 @@ double HYDROData_Bathymetry::GetAltitudeForPoint( const gp_XY& thePoint ) const return aResAltitude; } +void HYDROData_Bathymetry::SetFilePath(const QString& theFilePath) +{ + TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() ); + TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr ); +} + +QString HYDROData_Bathymetry::GetFilePath() const +{ + QString aRes; + + Handle(TDataStd_AsciiString) anAsciiStr; + if ( myLab.FindChild( DataTag_FilePath ).FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) + aRes = QString( anAsciiStr->Get().ToCString() ); + + return aRes; +} + bool HYDROData_Bathymetry::ImportFromFile( const QString& theFileName ) { // Try to open the file @@ -296,7 +314,8 @@ bool HYDROData_Bathymetry::ImportFromFile( const QString& theFileName ) if ( aRes ) { - // Update altitude points of this Bathymetry + // Update file path and altitude points of this Bathymetry + SetFilePath( theFileName ); SetAltitudePoints( aPoints ); } diff --git a/src/HYDROData/HYDROData_Bathymetry.h b/src/HYDROData/HYDROData_Bathymetry.h index d14110f8..3b74f469 100644 --- a/src/HYDROData/HYDROData_Bathymetry.h +++ b/src/HYDROData/HYDROData_Bathymetry.h @@ -32,7 +32,8 @@ protected: enum DataTag { DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve - DataTag_AltitudePoints ///< altitude points, array of reals + DataTag_AltitudePoints, ///< altitude points, array of reals + DataTag_FilePath ///< bathymetry imported file path }; public: @@ -89,6 +90,17 @@ public: public: // Public methods to work with files. + /** + * Stores the bathymetry file path + * \param theFilePath image file path + */ + HYDRODATA_EXPORT void SetFilePath( const QString& theFilePath ); + + /** + * Returns uploaded bathymetry file path + */ + HYDRODATA_EXPORT QString GetFilePath() const; + /** * Imports Bathymetry data from file. The supported file types: * - xyz diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index a41cc264..930d2a0e 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -7,6 +7,7 @@ #include #include #include +#include #include static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000"); @@ -58,6 +59,23 @@ QImage HYDROData_Image::Image() return aResult; } +void HYDROData_Image::SetFilePath(const QString& theFilePath) +{ + TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() ); + TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr ); +} + +QString HYDROData_Image::GetFilePath() const +{ + QString aRes; + + Handle(TDataStd_AsciiString) anAsciiStr; + if ( myLab.FindChild( DataTag_FilePath ).FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) + aRes = QString( anAsciiStr->Get().ToCString() ); + + return aRes; +} + void HYDROData_Image::SetTrsf(const QTransform& theTrsf) { // locate 9 coeffs of matrix into the real array diff --git a/src/HYDROData/HYDROData_Image.h b/src/HYDROData/HYDROData_Image.h index e2df2a4e..8b069add 100644 --- a/src/HYDROData/HYDROData_Image.h +++ b/src/HYDROData/HYDROData_Image.h @@ -23,8 +23,9 @@ protected: enum DataTag { DataTag_First = HYDROData_Object::DataTag_First + 100, ///< first tag, to reserve - DataTag_Operator, ///< name of the operator that must be executed for image update - DataTag_TrsfPoints ///< image transformation points (3 input + 3 output) + DataTag_Operator, ///< name of the operator that must be executed for image update + DataTag_TrsfPoints, ///< image transformation points (3 input + 3 output) + DataTag_FilePath ///< image imported file path }; public: @@ -46,6 +47,17 @@ public: */ HYDRODATA_EXPORT QImage Image(); + /** + * Stores the image file path + * \param theFilePath image file path + */ + HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath); + + /** + * Returns uploaded image file path + */ + HYDRODATA_EXPORT QString GetFilePath() const; + /** * Stores the image transformation * \param theTrsf new transformation -- 2.39.2