]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Dump Bathymetry data to python script (Feature #13).
authoradv <adv@opencascade.com>
Mon, 9 Sep 2013 07:55:21 +0000 (07:55 +0000)
committeradv <adv@opencascade.com>
Mon, 9 Sep 2013 07:55:21 +0000 (07:55 +0000)
src/HYDROData/HYDROData_Bathymetry.cxx
src/HYDROData/HYDROData_Bathymetry.h

index 14e6a24af744e33d274ce3c545a5ac1a777d4a53..9b9265d0b468267a07630bebb38442347f38dbc6 100644 (file)
@@ -1,5 +1,6 @@
 
 #include "HYDROData_Bathymetry.h"
+#include "HYDROData_Document.h"
 #include "HYDROData_Tool.h"
 
 #include <gp_XY.hxx>
@@ -15,6 +16,7 @@
 #include <QStringList>
 
 #define INVALID_ALTITUDE_VALUE -9999.0
+#define PYTHON_BATHYMETRY_ID "4"
 
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_Object)
@@ -28,6 +30,34 @@ 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 );
+
+  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;
index 3b74f4695473824aa9fe2fd73fecf84827cbbe81..68d08aac30e9df066810065d22255781bbd45d4b 100644 (file)
@@ -46,6 +46,11 @@ public:
   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_BATHYMETRY; }
 
 
+  /**
+   * Dump Bathymetry object to Python script representation.
+   */
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+
 public:      
   // Public methods to work with Bathymetry altitudes.