Salome HOME
Drawing of zones in OCC view improved.
[modules/hydro.git] / src / HYDROData / HYDROData_Bathymetry.cxx
index afbb8d0460dee0cd24be5ed88fd06f0e98fda951..43b2b1056a822638cd6af8667a51e792b8f80809 100644 (file)
@@ -1,11 +1,13 @@
 
 #include "HYDROData_Bathymetry.h"
+#include "HYDROData_Document.h"
 #include "HYDROData_Tool.h"
 
 #include <gp_XY.hxx>
 #include <gp_XYZ.hxx>
 
 #include <TDataStd_RealArray.hxx>
+#include <TDataStd_AsciiString.hxx>
 
 #include <QFile>
 #include <QFileInfo>
@@ -14,6 +16,7 @@
 #include <QStringList>
 
 #define INVALID_ALTITUDE_VALUE -9999.0
+#define PYTHON_BATHYMETRY_ID "KIND_BATHYMETRY"
 
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Object)
@@ -27,6 +30,41 @@ HYDROData_Bathymetry::~HYDROData_Bathymetry()
 {
 }
 
+QStringList HYDROData_Bathymetry::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+{
+  QStringList aResList;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( this );
+  if ( aDocument.IsNull() )
+    return aResList;
+                             
+  QString aDocName = aDocument->GetDocPyName();
+  QString aBathymetryName = GetName();
+
+  aResList << QString( "%1 = %2.CreateObject( %3 );" )
+              .arg( aBathymetryName ).arg( aDocName ).arg( PYTHON_BATHYMETRY_ID );
+  aResList << QString( "%1.SetName( \"%2\" );" )
+              .arg( aBathymetryName ).arg( aBathymetryName );
+
+  QString aFilePath = GetFilePath();
+  if ( !aFilePath.isEmpty() )
+  {
+    aResList << QString( "%1.ImportFromFile( \"%2\" );" )
+                .arg( aBathymetryName ).arg( aFilePath );
+  }
+  else
+  {
+    // TODO : bathymetry is composed from other bathymetry(ies)
+  }
+
+  return aResList;
+}
+
+double HYDROData_Bathymetry::GetInvalidAltitude()
+{
+  return INVALID_ALTITUDE_VALUE;
+}
+
 void HYDROData_Bathymetry::SetAltitudePoints( const AltitudePoints& thePoints )
 {
   RemoveAltitudePoints();
@@ -269,6 +307,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
@@ -291,7 +346,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 );
   }