]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #651: wrapping for Python
authorasl <asl@opencascade.com>
Fri, 13 Nov 2015 13:42:59 +0000 (16:42 +0300)
committerasl <asl@opencascade.com>
Fri, 13 Nov 2015 13:42:59 +0000 (16:42 +0300)
43 files changed:
src/HYDROData/HYDROData_AltitudeObject.cxx
src/HYDROData/HYDROData_AltitudeObject.h
src/HYDROData/HYDROData_Bathymetry.cxx
src/HYDROData/HYDROData_Bathymetry.h
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_Channel.h
src/HYDROData/HYDROData_Confluence.cxx
src/HYDROData/HYDROData_Confluence.h
src/HYDROData/HYDROData_Document.cxx
src/HYDROData/HYDROData_Document.h
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_Image.cxx
src/HYDROData/HYDROData_Image.h
src/HYDROData/HYDROData_ImmersibleZone.cxx
src/HYDROData/HYDROData_ImmersibleZone.h
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDROData/HYDROData_Obstacle.cxx
src/HYDROData/HYDROData_Obstacle.h
src/HYDROData/HYDROData_Polyline3D.cxx
src/HYDROData/HYDROData_Polyline3D.h
src/HYDROData/HYDROData_PolylineXY.cxx
src/HYDROData/HYDROData_PolylineXY.h
src/HYDROData/HYDROData_Profile.cxx
src/HYDROData/HYDROData_Profile.h
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Region.h
src/HYDROData/HYDROData_River.cxx
src/HYDROData/HYDROData_River.h
src/HYDROData/HYDROData_Stream.cxx
src/HYDROData/HYDROData_Stream.h
src/HYDROData/HYDROData_StricklerTable.cxx
src/HYDROData/HYDROData_StricklerTable.h
src/HYDROPy/HYDROData_Document.sip
src/HYDROPy/HYDROData_Entity.sip
src/HYDROPy/HYDROData_LandCoverMap.sip
src/HYDRO_tests/reference_data/lc_dump.dbf [new file with mode: 0644]
src/HYDRO_tests/reference_data/lc_dump.py [new file with mode: 0644]
src/HYDRO_tests/reference_data/test_LCM.dbf [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx

index deac2dc0cf2d0bcd4970587c4361f63e0bc5d217..44e21d0866be36649ad57330155f96a4e68f1c33 100644 (file)
@@ -33,7 +33,8 @@ HYDROData_AltitudeObject::~HYDROData_AltitudeObject()
 {
 }
 
-QStringList HYDROData_AltitudeObject::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_AltitudeObject::DumpToPython( const QString& thePyScriptPath,
+                                                    MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aName = GetObjPyName();
index 3d5423371b673ac4180d86337f535c8f7bda3880..3d10f39bf0b10031d3aa543413f906a96c097137 100644 (file)
@@ -55,7 +55,8 @@ public:
   /**
    * Dump Altitude object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
 public:      
 
index 73e763ef27ac061a40fb2c287de62773f01df5ba..b1204e6fe43cdf496e182b5b83e4ef83175cf0eb 100644 (file)
@@ -56,7 +56,8 @@ HYDROData_Bathymetry::~HYDROData_Bathymetry()
 {
 }
 
-QStringList HYDROData_Bathymetry::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Bathymetry::DumpToPython( const QString& thePyScriptPath,
+                                                MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aBathymetryName = GetObjPyName();
index 5c3551997e1ba8ec082dd48654cfe3726f97cb9e..0842b12f9c9abe743ffc94309dda6116af854cad 100644 (file)
@@ -66,7 +66,8 @@ public:
   /**
    * Dump Bathymetry object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
 public:      
   // Public methods to work with Bathymetry altitudes.
index 34b413fa97e92e229ec27e6076e0ec6646ad57a5..d0927c2bcdfc4fea9aa7771da9c7f973c51cfd34 100644 (file)
@@ -115,7 +115,8 @@ void HYDROData_CalculationCase::SetName( const QString& theName )
   HYDROData_Entity::SetName( theName );
 }
 
-QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_CalculationCase::DumpToPython( const QString&       thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   aResList.prepend( "# Calculation case" );
@@ -132,7 +133,7 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre
   {
     Handle(HYDROData_Object) aRefGeomObj =
       Handle(HYDROData_Object)::DownCast( anIter.Value() );
-    setPythonReferenceObject( theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
+    setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefGeomObj, "AddGeometryObject" );
   }
   aResList << QString( "" );
 
@@ -160,7 +161,7 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre
   }
 
   Handle(HYDROData_PolylineXY) aBoundaryPolyline = GetBoundaryPolyline();
-  setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
+  setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
 
   if( aMode==AUTOMATIC )
     DumpRulesToPython( aCalculName, aResList );
@@ -173,7 +174,7 @@ QStringList HYDROData_CalculationCase::DumpToPython( MapOfTreatedObjects& theTre
   {
     // Now we restore the
     // - regions and zones order
-    DumpRegionsToPython( aResList, theTreatedObjects, GetRegions() );   
+    DumpRegionsToPython( aResList, thePyScriptPath, theTreatedObjects, GetRegions() );   
   }
 
   // Export calculation case
@@ -1291,6 +1292,7 @@ void HYDROData_CalculationCase::UpdateRegionsNames( const HYDROData_SequenceOfOb
 }
 
 void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList,
+                                                     const QString& thePyScriptPath,
                                                      MapOfTreatedObjects& theTreatedObjects,
                                                      const HYDROData_SequenceOfObjects& theRegions ) const
 {
@@ -1304,7 +1306,7 @@ void HYDROData_CalculationCase::DumpRegionsToPython( QStringList& theResList,
       continue;
 
     theTreatedObjects.insert( aRegion->GetName(), aRegion );
-    QStringList aRegDump = aRegion->DumpToPython( theTreatedObjects );
+    QStringList aRegDump = aRegion->DumpToPython( thePyScriptPath, theTreatedObjects );
     theResList << aRegDump;
   }
 }
index 4f09be72ec1e39b582747c55fba5434f598a26e8..7db0d86bfcb91b9e6b5d7895984ad58968818b18 100644 (file)
@@ -124,7 +124,8 @@ public:
   /**
    * Dump Calculation object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Update the calcualtion case object.
@@ -444,8 +445,9 @@ private:
                            const QString& theOldCaseName,
                            const QString& theName );
   
-  void DumpRegionsToPython( QStringList& theResList,
-                            MapOfTreatedObjects& theTreatedObjects,
+  void DumpRegionsToPython( QStringList&                       theResList,
+                            const QString&                     thePyScriptPath,
+                            MapOfTreatedObjects&               theTreatedObjects,
                             const HYDROData_SequenceOfObjects& theRegions ) const;
 
 protected:
index 9a8fae8657a8a4250d6aa3263216fb65d23de6a4..cd4800b425a3ae9a488280cd910d9659eaf9b5f5 100644 (file)
@@ -80,16 +80,17 @@ HYDROData_Channel::~HYDROData_Channel()
 {
 }
 
-QStringList HYDROData_Channel::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Channel::DumpToPython( const QString& thePyScriptPath,
+                                             MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aName = GetObjPyName();
 
   Handle(HYDROData_Polyline3D) aRefGideLine = GetGuideLine();
-  setPythonReferenceObject( theTreatedObjects, aResList, aRefGideLine, "SetGuideLine" );
+  setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefGideLine, "SetGuideLine" );
 
   Handle(HYDROData_Profile) aRefProfile = GetProfile();
-  setPythonReferenceObject( theTreatedObjects, aResList, aRefProfile, "SetProfile" );
+  setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefProfile, "SetProfile" );
 
   aResList << QString( "" );
   aResList << QString( "%1.Update();" ).arg( aName );
index 86ed56b0c5b150559a9e5d5f274ce2022ad50475..372e57a7a46facbf470ec4881cf62f43562ad9cc 100644 (file)
@@ -83,7 +83,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Returns the list of all reference objects of this object.
index e3995a6964d2bfbd22d6032fd2722ef99b9b85bf..aec5701b45f4687442beaed45449f770afdfdffe 100644 (file)
@@ -37,7 +37,8 @@ HYDROData_Confluence::~HYDROData_Confluence()
 {
 }
 
-QStringList HYDROData_Confluence::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Confluence::DumpToPython( const QString& thePyScriptPath,
+                                                MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aName = GetObjPyName();
index ec0ac2fe69c83be78b90521a04b4ec7e8cd10d3b..e96a6a9a9cec416d5b6e4336df8a0faa75281c84 100644 (file)
@@ -49,7 +49,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy );
 
index ae714b1711df2aa8bfe97d4eaa02558813e14098..653ddb8e2dd0686962afd0c40b8858d3f85cd8e1 100644 (file)
@@ -232,18 +232,18 @@ void HYDROData_Document::SetDefaultStricklerCoefficient( double theCoeff ) const
     }
 }
 
-bool HYDROData_Document::DumpToPython( const QString& theFileName,
+bool HYDROData_Document::DumpToPython( const QString& thePyScriptPath,
                                        const bool     theIsMultiFile ) const
 {
   // Try to open the file
-  QFile aFile( theFileName );
+  QFile aFile( thePyScriptPath );
   if ( !aFile.open( QIODevice::WriteOnly ) )
     return false;
 
   MapOfTreatedObjects aTreatedObjects;
 
   // Dump header for python script
-  QStringList aHeaderDump = DumpToPython( aTreatedObjects, theIsMultiFile );
+  QStringList aHeaderDump = DumpToPython( thePyScriptPath, aTreatedObjects, theIsMultiFile );
   if ( aHeaderDump.isEmpty() )
     return false;
 
@@ -259,19 +259,19 @@ bool HYDROData_Document::DumpToPython( const QString& theFileName,
   HYDROData_Tool::WriteStringsToFile( aFile, QStringList() << aLCS );
 
   // Dump all model objects to Python script
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_IMAGE );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_STRICKLER_TABLE );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_POLYLINEXY );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_BATHYMETRY );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_PROFILE );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_POLYLINE );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_IMMERSIBLE_ZONE );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_STREAM );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_CHANNEL );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_DIGUE );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_OBSTACLE );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_LAND_COVER_MAP );
-  aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_CALCULATION );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_IMAGE );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_STRICKLER_TABLE );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_POLYLINEXY );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_BATHYMETRY );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_PROFILE );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_POLYLINE );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_IMMERSIBLE_ZONE );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_STREAM );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_CHANNEL );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_DIGUE );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_OBSTACLE );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_LAND_COVER_MAP );
+  aRes = aRes && dumpPartitionToPython( aFile, thePyScriptPath, theIsMultiFile, aTreatedObjects, KIND_CALCULATION );
 
   // Dump code to close python fuction
   if ( aRes && theIsMultiFile )
@@ -298,7 +298,8 @@ QString HYDROData_Document::GetDocPyName() const
   return aDocName;
 }
 
-QStringList HYDROData_Document::DumpToPython( MapOfTreatedObjects& theTreatedObjects,
+QStringList HYDROData_Document::DumpToPython( const QString& thePyScriptPath,
+                                              MapOfTreatedObjects& theTreatedObjects,
                                               const bool           theIsMultiFile ) const
 {
   QString aDocName = GetDocPyName();
@@ -333,6 +334,7 @@ QStringList HYDROData_Document::DumpToPython( MapOfTreatedObjects& theTreatedObj
 }
 
 bool HYDROData_Document::dumpPartitionToPython( QFile&               theFile,
+                                                const QString&       thePyScriptPath,
                                                 const bool           theIsMultiFile,
                                                 MapOfTreatedObjects& theTreatedObjects,
                                                 const ObjectKind&    theObjectKind ) const
@@ -357,7 +359,7 @@ bool HYDROData_Document::dumpPartitionToPython( QFile&               theFile,
 
     theTreatedObjects.insert( anObjName, anObject );
 
-    QStringList anObjDump = anObject->DumpToPython( theTreatedObjects );
+    QStringList anObjDump = anObject->DumpToPython( thePyScriptPath, theTreatedObjects );
 
     if ( theIsMultiFile )
     {
@@ -885,4 +887,25 @@ QColor HYDROData_Document::GetAssociatedColor( const QString& theStricklerType,
       return aTable->GetColor( theStricklerType );
   }
   return QColor();
-}
\ No newline at end of file
+}
+
+void HYDROData_Document::CollectQGISValues( const QString& theAttrName,
+                                            QStringList& theAttrValues,
+                                            QStringList& theStricklerTypes ) const
+{
+  HYDROData_Iterator It( this, KIND_STRICKLER_TABLE );
+  for( ; It.More(); It.Next() )
+  {
+    Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( It.Current() );
+    if( !aTable.IsNull() && aTable->GetAttrName()==theAttrName )
+    {
+      theAttrValues.clear();
+      theStricklerTypes = aTable->GetTypes();
+      foreach( QString aType, theStricklerTypes )
+      {
+        QString anAttrValue = aTable->GetAttrValue( aType );
+        theAttrValues.append( anAttrValue );
+      }
+    }
+  }
+}
index 3601a6b6a0bc9860f52c41034303974c1c381a18..e3c7b1c81821d9ebeff01bffad29c1ec17fbda3e 100644 (file)
@@ -103,13 +103,18 @@ public:
   //! 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,
+  HYDRODATA_EXPORT bool DumpToPython( const QString& thePyScriptPath,
                                       const bool     theIsMultiFile ) const;
 
   //! Dump model data to Python script representation.
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects,
+  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.
@@ -254,6 +259,7 @@ private:
 
   // Dump objects of type \c theObjectKind to file \c theFile
   bool dumpPartitionToPython( QFile&               theFile,
+                              const QString&       thePyScriptPath,
                               const bool           theIsMultiFile,
                               MapOfTreatedObjects& theDumpedObjects,
                               const ObjectKind&    theObjectKind ) const;
index f0b9e5fb034a06e9b26123375f8f69eab2fe0fc2..7857cbc7f10141e5be65fb8a30e687ea69d0444d 100644 (file)
@@ -87,7 +87,8 @@ void HYDROData_Entity::SetName(const QString& theName)
   TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData()));
 }
 
-QStringList HYDROData_Entity::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Entity::DumpToPython( const QString& thePyScriptPath,
+                                            MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList anEmptyList;
   return anEmptyList;
@@ -654,12 +655,13 @@ QString HYDROData_Entity::getPyTypeID() const
   }
 }
 
-void HYDROData_Entity::setPythonReferenceObject( MapOfTreatedObjects&            theTreatedObjects,
+void HYDROData_Entity::setPythonReferenceObject( const QString&                  thePyScriptPath,
+                                                 MapOfTreatedObjects&            theTreatedObjects,
                                                  QStringList&                    theScript,
                                                  const Handle(HYDROData_Entity)& theRefObject,
                                                  const QString&                  theMethod ) const
 {
-  if ( !checkObjectPythonDefinition( theTreatedObjects, theScript, theRefObject ) )
+  if ( !checkObjectPythonDefinition( thePyScriptPath, theTreatedObjects, theScript, theRefObject ) )
     return;
 
   QString aRefObjName = theRefObject->GetObjPyName();
@@ -669,7 +671,8 @@ void HYDROData_Entity::setPythonReferenceObject( MapOfTreatedObjects&
                .arg( anObjName ).arg( theMethod ).arg( aRefObjName );
 }
 
-bool HYDROData_Entity::checkObjectPythonDefinition( MapOfTreatedObjects&            theTreatedObjects,
+bool HYDROData_Entity::checkObjectPythonDefinition( const QString&                  thePyScriptPath,
+                                                    MapOfTreatedObjects&            theTreatedObjects,
                                                     QStringList&                    theScript,
                                                     const Handle(HYDROData_Entity)& theRefObject ) const
 {
@@ -684,7 +687,7 @@ bool HYDROData_Entity::checkObjectPythonDefinition( MapOfTreatedObjects&
     return true;
 
   // The definition of reference object must be dumped before this
-  QStringList aRefObjDump = theRefObject->DumpToPython( theTreatedObjects );
+  QStringList aRefObjDump = theRefObject->DumpToPython( thePyScriptPath, theTreatedObjects );
   if ( aRefObjDump.isEmpty() )
     return false;
 
index 0c612ba279daf2ac967c76498700636c7f91a7d4..7e22bf794db5940372b09211648ac912ab4c0e2a 100644 (file)
@@ -145,7 +145,8 @@ public:
    * You should reimplement this function in your derived class if it
    * has Python API and can be imported/exported from/to Python script.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Updates object state. Base implementation dose nothing.
@@ -410,12 +411,14 @@ protected:
    */
   QString getPyTypeID() const;
 
-  void setPythonReferenceObject( MapOfTreatedObjects&            theTreatedObjects,
+  void setPythonReferenceObject( const QString&                  thePyScriptPath,
+                                 MapOfTreatedObjects&            theTreatedObjects,
                                  QStringList&                    theScript,
                                  const Handle(HYDROData_Entity)& theRefObject,
                                  const QString&                  theMethod ) const;
 
-  bool checkObjectPythonDefinition( MapOfTreatedObjects&            theTreatedObjects,
+  bool checkObjectPythonDefinition( const QString&                  thePyScriptPath,
+                                    MapOfTreatedObjects&            theTreatedObjects,
                                     QStringList&                    theScript,
                                     const Handle(HYDROData_Entity)& theRefObject ) const;
 
index 4e91edafb18e9e543e5069a31cb8f3f5ca54827b..0874417f028bbf0601f19c6cea68655c29b81bd7 100644 (file)
@@ -62,7 +62,8 @@ HYDROData_Image::~HYDROData_Image()
 {
 }
 
-QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Image::DumpToPython( const QString&       thePyScriptPath,
+                                           MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString anImageName = GetObjPyName();
@@ -127,7 +128,7 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject
       if ( aTransformationMode == ReferenceImage )
       {
         Handle(HYDROData_Image) aRefImg = GetTrsfReferenceImage();
-        setPythonReferenceObject( theTreatedObjects, aResList, aRefImg, "SetTrsfReferenceImage" );
+        setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefImg, "SetTrsfReferenceImage" );
       }
     }
   }
@@ -170,7 +171,7 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject
       for ( int i = 0; i < aNbReferences; ++i )
       {
         Handle(HYDROData_Image) aRefImg = Handle(HYDROData_Image)::DownCast( Reference( i ) );
-        setPythonReferenceObject( theTreatedObjects, aResList, aRefImg, "AppendReference" );
+        setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefImg, "AppendReference" );
       }
     }
   }
index fcbb657fa81cdcefc4d57f3074025818f36a0e94..255e0575a34e80a2a190cca1f9bd68806427f50e 100644 (file)
@@ -78,7 +78,8 @@ public:
   /**
    * Dump Image object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Updates object state.
index f3c5467998e8856aab51eec0e77e7d4231fda73e..f3b7d6758a17dda7d0fa43fce4cc9c35a206db17 100644 (file)
@@ -57,17 +57,18 @@ HYDROData_ImmersibleZone::~HYDROData_ImmersibleZone()
 {
 }
 
-QStringList HYDROData_ImmersibleZone::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_ImmersibleZone::DumpToPython( const QString& thePyScriptPath,
+                                                    MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   
   QString aZoneName = GetObjPyName();
 
   Handle(HYDROData_IAltitudeObject) aRefAltitude = GetAltitudeObject();
-  setPythonReferenceObject( theTreatedObjects, aResList, aRefAltitude, "SetAltitudeObject" );
+  setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefAltitude, "SetAltitudeObject" );
 
   Handle(HYDROData_PolylineXY) aRefPolyline = GetPolyline();
-  setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
+  setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefPolyline, "SetPolyline" );
 
   aResList << QString( "" );
 
index 0a9cf54240b4ec5f86139168c64d8796d1fa5075..3e4d6e8475afd48b860470f1378d5a079907b320 100644 (file)
@@ -52,7 +52,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Returns the list of all reference objects of this object.
index 53ac69ae893b51f151df04ecd3764d93d49f278c..aceb28a9700db1c50e73cf7f6a596a2b66c3a5aa 100644 (file)
@@ -21,6 +21,7 @@
 #include <HYDROData_PolylineXY.h>
 #include <HYDROData_Tool.h>
 #include <HYDROData_ShapeFile.h>
+#include <HYDROData_Document.h>
 
 #include <BOPAlgo_BOP.hxx>
 #include <BOPAlgo_Builder.hxx>
@@ -249,10 +250,14 @@ HYDROData_LandCoverMap::DBFStatus HYDROData_LandCoverMap::ImportDBF( const QStri
   for( ; anIt.More(); anIt.Next() )
   {
     int CurIndex = anIt.Index();
-    HYDROData_ShapeFile::DBF_AttrValue AValue = theAttrV[theIndices[CurIndex]];
-    int StricklerTypesInd = theDBFValues.indexOf(QString(AValue.myStrVal));
+    int anIndex = CurIndex;
+    if( !theIndices.isEmpty() )
+      anIndex = theIndices[CurIndex];
+
+    HYDROData_ShapeFile::DBF_AttrValue AValue = theAttrV[anIndex];
+    int StricklerTypesInd = theDBFValues.indexOf( QString( AValue.myStrVal ) );
     if ( StricklerTypesInd != -1)
-      anIt.SetStricklerType(theStricklerTypes[StricklerTypesInd]);
+      anIt.SetStricklerType( theStricklerTypes[StricklerTypesInd] );
     else
       allOK = false;
   }
@@ -897,20 +902,41 @@ TopoDS_Face HYDROData_LandCoverMap::FindByPoint( const gp_Pnt2d& thePoint, QStri
   return TopoDS_Face();
 }
 
+void Dump( const QString& theName, const QStringList& theList, QStringList& theLines )
+{
+  theLines.append( QString( "%1 = QStringList()" ).arg( theName ) );
+  foreach( QString anItem, theList )
+    theLines.append( QString( "%1.append( u\"%2\" )" ).arg( theName ).arg( anItem ) );
+}
+
 /**
   Dump to Python
   @param theTreatedObjects the map of treated objects
 */
-QStringList HYDROData_LandCoverMap::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_LandCoverMap::DumpToPython( const QString&       thePyScriptPath,
+                                                  MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aName = GetObjPyName();
 
-  QString aShapeFileName = aName + ".shp";
-  QString aDbfFileName = aName + ".dbf";
+  QString aShapeFileName = thePyScriptPath;
+  aShapeFileName.replace( ".py", ".shp" );
+  QString aDbfFileName = thePyScriptPath;
+  aDbfFileName.replace( ".py", ".dbf" );
+
+  //TODO: export shape file
+
+  QString anAttr = "CODE_06"; //TODO: some custom choice
+  QStringList anAttrValues, aTypes;
+  HYDROData_Document::Document( myLab )->CollectQGISValues( anAttr, anAttrValues, aTypes );
+  ExportDBF( aDbfFileName, anAttr, anAttrValues, aTypes );
+
+  //TODO: insert command to import shape file
 
-  QString anAttr = "CODE_06";
-  //ExportDBF( aDbfFileName, anAttr, 
+  Dump( "attr_values", anAttrValues, aResList );
+  Dump( "types", aTypes, aResList );
+  aResList << QString( "%1.ImportDBF( '%2', '%3', attr_values, types )" ).
+    arg( aName ).arg( aDbfFileName ).arg( anAttr );
 
   return aResList;
 }
index e078ddd0ae0a09f52bf9540368068876caf75439..3a671664f17f45f6c77f25f872f3214d408debf1 100644 (file)
@@ -91,7 +91,7 @@ public:
                                         const QString& theFieldName, 
                                         const QStringList& DBFValues,
                                         const QStringList& StricklerTypes,
-                                        const QList<int>& theIndices );
+                                        const QList<int>& theIndices = QList<int>() );
  
   HYDRODATA_EXPORT void ExportDBF( const QString& theDBFFileName,
                                    const QString& theFieldName, 
@@ -118,7 +118,8 @@ public:
 
   HYDRODATA_EXPORT QString StricklerType( const TopoDS_Face& ) const;
 
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   HYDRODATA_EXPORT int GetLCCount() const;
   HYDRODATA_EXPORT bool IsEmpty() const;
index 6af8456d008e19bf3a123b20383251cb705bc66e..9c738a117a80ee24fe011b18b5bf39cd68b5e196 100644 (file)
@@ -88,7 +88,8 @@ HYDROData_Obstacle::~HYDROData_Obstacle()
 {
 }
 
-QStringList HYDROData_Obstacle::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Obstacle::DumpToPython( const QString&       thePyScriptPath,
+                                              MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   
index 3c792a16b1427440dc70b4929b6ea6a72e16d085..bbf690a2259e77a775c52ead1e9429e06e2a7504 100644 (file)
@@ -52,7 +52,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Update the immersible zone object.
index d11aaf9348ed2d334017edeec9783dea8c97f520..564f4f2cd4f2f18f1a878bc15d279fb7d43e2451 100644 (file)
@@ -63,20 +63,21 @@ HYDROData_Polyline3D::~HYDROData_Polyline3D()
 {
 }
 
-QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Polyline3D::DumpToPython( const QString& thePyScriptPath,
+                                                MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aPolylineName = GetObjPyName();
 
   Handle(HYDROData_PolylineXY) aRefPolyline = GetPolylineXY();
-  setPythonReferenceObject( theTreatedObjects, aResList, aRefPolyline, "SetPolylineXY" );
+  setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefPolyline, "SetPolylineXY" );
 
   Handle(HYDROData_ProfileUZ) aRefProfileUZ = GetProfileUZ();
   if ( !aRefProfileUZ.IsNull() )
   {
     Handle(HYDROData_Profile) aProfile = 
       Handle(HYDROData_Profile)::DownCast( aRefProfileUZ->GetFatherObject() );
-    if ( checkObjectPythonDefinition( theTreatedObjects, aResList, aProfile ) )
+    if ( checkObjectPythonDefinition( thePyScriptPath, theTreatedObjects, aResList, aProfile ) )
     {
       QString aProfileName = aProfile->GetObjPyName();
       if ( !aProfileName.isEmpty() )
@@ -96,7 +97,7 @@ QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedO
       {
         Handle(HYDROData_Profile) aProfile = 
           Handle(HYDROData_Profile)::DownCast( aChildProfileUZ->GetFatherObject() );
-        if ( checkObjectPythonDefinition( theTreatedObjects, aResList, aProfile ) )
+        if ( checkObjectPythonDefinition( thePyScriptPath, theTreatedObjects, aResList, aProfile ) )
         {
           QString aProfileName = aProfile->GetObjPyName();
           if ( !aProfileName.isEmpty() )
@@ -107,7 +108,7 @@ QStringList HYDROData_Polyline3D::DumpToPython( MapOfTreatedObjects& theTreatedO
         }
       }
 
-      setPythonReferenceObject( theTreatedObjects, aResList, aRefBathymetry, "SetAltitudeObject" );
+      setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aRefBathymetry, "SetAltitudeObject" );
     }
   }
 
index 2506681e944d2e55851e1a9f92ba08ca8edf7d95..1705f29aeeacc777f1a4715db012c1dac4eea3b1 100644 (file)
@@ -61,7 +61,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Returns the list of all reference objects of this object.
index 559947e684ce444fb16022fbd976538962c507f5..5127c91b7d84b4a8421bfe7ad5f25f58e2ee68d0 100644 (file)
@@ -130,7 +130,8 @@ HYDROData_PolylineXY::~HYDROData_PolylineXY()
 {
 }
 
-QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_PolylineXY::DumpToPython( const QString&       thePyScriptPath,
+                                                MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aPolylineName = GetObjPyName();
index 611a2a30f51a8eb3a2683937da67e5842a9c871b..e9181876b885f1421da0765e5d64cb7c866d6dd5 100644 (file)
@@ -57,7 +57,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Update the wire contour on the basis of the polyline data.
index 217c49c9981db2e5471b2412470258b21bfb8ca8..76b0bed2cfd9b9fecad39e2cece3555fe8c4779c 100644 (file)
@@ -64,7 +64,8 @@ HYDROData_Profile::~HYDROData_Profile()
 {
 }
 
-QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Profile::DumpToPython( const QString&       thePyScriptPath,
+                                             MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aProfileName = GetObjPyName();
index f1f5238076afee17d34b514fcfd36118348b99f5..5bcc450da7a182a4503ace453f15920e1c00e90d 100644 (file)
@@ -63,7 +63,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Returns the top shape of the object.
index 582357e8dc2f33fce07215099e70dd3bfe9105ef..60210bbc30e700e689d31d8d9f0f40faac5b8262 100644 (file)
@@ -388,7 +388,8 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs*
   return aResShape;
 }
 
-QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Region::DumpToPython( const QString&       thePyScriptPath,
+                                            MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList;
 
@@ -433,7 +434,7 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec
     }
 
     // add zone
-    setPythonReferenceObject( theTreatedObjects, aResList, aZone, "AddZone" );
+    setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aZone, "AddZone" );
   }
 
   return aResList;
index b8da0556160d93457d168e4c8480e8b67fa1633e..f92ae0e11de28c4e0203634126b38c0511b650ca 100644 (file)
@@ -59,7 +59,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Returns flag indicating that object is updateble or not.
index 406ca4b121ce9f9d92b9ecc037d7eb9ea45aa03b..7f28594a41fb0f97ceb8d8e5e665e6012a277efa 100644 (file)
@@ -37,7 +37,8 @@ HYDROData_River::~HYDROData_River()
 {
 }
 
-QStringList HYDROData_River::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_River::DumpToPython( const QString& thePyScriptPath,
+                                           MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aName = GetObjPyName();
index dee7d62484e84e286b78f23adc81bf0ef33124e3..0873ce156351eef391863e08f8b14b7aad892c98 100644 (file)
@@ -49,7 +49,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Update the immersible zone object.
index c2def15f030fcaccf22861a997e6d5de74748f99..5f6f828fe406ee267227e23f3c4a181da8f6b201 100644 (file)
@@ -103,25 +103,26 @@ HYDROData_Stream::~HYDROData_Stream()
 {
 }
 
-QStringList HYDROData_Stream::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_Stream::DumpToPython( const QString&       thePyScriptPath,
+                                            MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aName = GetObjPyName();
 
   Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
-  setPythonReferenceObject( theTreatedObjects, aResList, aHydAxis, "SetHydraulicAxis" );
+  setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aHydAxis, "SetHydraulicAxis" );
 
   HYDROData_SequenceOfObjects aSeqOfProfiles = GetProfiles();
   for ( int i = 1, aNb = aSeqOfProfiles.Size(); i <= aNb; ++i )
   {
     const Handle(HYDROData_Entity) aProfile = aSeqOfProfiles.Value( i );
-    setPythonReferenceObject( theTreatedObjects, aResList, aProfile, "AddProfile" );
+    setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aProfile, "AddProfile" );
   }
 
   // Set bottom polyline if exists
   const Handle(HYDROData_Polyline3D) aBottomPolyline = GetBottomPolyline();
   if ( !aBottomPolyline.IsNull() ) {
-    setPythonReferenceObject( theTreatedObjects, aResList, aBottomPolyline, "SetBottomPolyline" );
+    setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aBottomPolyline, "SetBottomPolyline" );
   }
 
   aResList << QString( "" );
index cfcd6a1109aa9c3eca56765fc83a4053e394afef..73691575c13f3d943568859068000ad378c15d29 100644 (file)
@@ -100,7 +100,8 @@ public:
   /**
    * Dump object to Python script representation.
    */
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   /**
    * Returns the list of all reference objects of this object.
index b2901ef51abebc2cbfc935850ce893572c5e8b69..e5c2c347ad828fd4031d1efff57c9a98fa968e26 100644 (file)
@@ -203,7 +203,8 @@ void HYDROData_StricklerTable::Clear()
     aMap->ChangeReals( TDataStd_DataMapOfStringReal() );
 }
 
-QStringList HYDROData_StricklerTable::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
+QStringList HYDROData_StricklerTable::DumpToPython( const QString& thePyScriptPath,
+                                                    MapOfTreatedObjects& theTreatedObjects ) const
 {
   QStringList aResList = dumpObjectCreation( theTreatedObjects );
   QString aPyName = GetObjPyName();
index 6c081e1b81794d363625c6cfd251dfabda923904..f50f4546e6303a21b162c6b7ed722da059d3b4a7 100644 (file)
@@ -59,7 +59,8 @@ public:
 
   HYDRODATA_EXPORT void Clear();
 
-  HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
+  HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
+                                                     MapOfTreatedObjects& theTreatedObjects ) const;
 
   HYDRODATA_EXPORT QString GetAttrName() const;
   HYDRODATA_EXPORT bool    SetAttrName( const QString& ) const;
index 584b11dd5e0fb5485a37a97443101c225f61cc5a..2ff3c60440c71c01291430cfcb90659cc0168fb8 100644 (file)
@@ -168,6 +168,11 @@ class HYDROData_Document
         aRes = new HYDROData_StricklerTable( *dynamic_cast<HYDROData_StricklerTable*>( theObject ) );
         break;
       }
+      case KIND_LAND_COVER_MAP:
+      {
+        aRes = new HYDROData_LandCoverMap( *dynamic_cast<HYDROData_LandCoverMap*>( theObject ) );
+        break;
+      }
     }
     
     return aRes;
index ee4e48417ad23aa3c5784c438a799a6f2b76d5fc..52a846352836c1bcaa9ee64b21aad016bb71049d 100644 (file)
@@ -44,6 +44,7 @@ const ObjectKind KIND_SHAPES_GROUP;
 const ObjectKind KIND_SPLITTED_GROUP;
 const ObjectKind KIND_OBSTACLE_ALTITUDE;
 const ObjectKind KIND_STRICKLER_TABLE;
+const ObjectKind KIND_LAND_COVER_MAP;
 
 class HYDROData_Entity
 {
@@ -143,6 +144,10 @@ class HYDROData_Entity
         sipClass = sipClass_HYDROData_StricklerTable;
         break;
 
+      case KIND_LAND_COVER_MAP:
+        sipClass = sipClass_HYDROData_LandCoverMap;
+        break;
+
       case KIND_UNKNOWN:
         sipClass = sipClass_HYDROData_Entity;
         break;
index 734565ea0617d573b65305ec7e4c11cd90255e0f..cd0ed5b8713d08b48da1641e5cd9668b51bbda1b 100644 (file)
@@ -55,8 +55,7 @@ public:
   DBFStatus ImportDBF( const QString& theDBFFileName, 
     const QString& theFieldName, 
     const QStringList& DBFValues,
-    const QStringList& StricklerTypes,
-    const QList<int>& theIndices );
+    const QStringList& StricklerTypes );
  
   void ExportDBF( const QString& theDBFFileName,
     const QString& theFieldName, 
diff --git a/src/HYDRO_tests/reference_data/lc_dump.dbf b/src/HYDRO_tests/reference_data/lc_dump.dbf
new file mode 100644 (file)
index 0000000..2766ee8
Binary files /dev/null and b/src/HYDRO_tests/reference_data/lc_dump.dbf differ
diff --git a/src/HYDRO_tests/reference_data/lc_dump.py b/src/HYDRO_tests/reference_data/lc_dump.py
new file mode 100644 (file)
index 0000000..3b145ea
--- /dev/null
@@ -0,0 +1,91 @@
+# -*- coding: utf-8 -*-
+
+###
+### This file is generated automatically by SALOME v7.6.0 with dump python functionality
+###
+
+import sys
+import salome
+
+salome.salome_init()
+theStudy = salome.myStudy
+
+import salome_notebook
+notebook = salome_notebook.NoteBook(theStudy)
+sys.path.insert( 0, r'D:/asl/hydro/studies')
+
+###
+### HYDRO component
+###
+
+from HYDROPy import *
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
+hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() );
+
+hydro_doc.SetLocalCS( 0, 0 )
+
+DefStr = hydro_doc.CreateObject( KIND_STRICKLER_TABLE );
+DefStr.SetName( "DefStr" );
+
+DefStr.SetAttrName( "CODE_06" );
+
+DefStr.Set( u"Zones de champs, prairies, sans cultures", 20 );
+DefStr.SetAttrValue( u"Zones de champs, prairies, sans cultures", "511" );
+DefStr.SetColor( u"Zones de champs, prairies, sans cultures", QColor( 255, 0, 0 ) );
+
+DefStr.Set( u"Zones à faible urbanization (bourg)", 9 );
+DefStr.SetAttrValue( u"Zones à faible urbanization (bourg)", "" );
+DefStr.SetColor( u"Zones à faible urbanization (bourg)", QColor( 0, 0, 255 ) );
+
+DefStr.Set( u"Zones de champs cultivé à végétation haute", 12.5 );
+DefStr.SetAttrValue( u"Zones de champs cultivé à végétation haute", "" );
+DefStr.SetColor( u"Zones de champs cultivé à végétation haute", QColor( 0, 255, 0 ) );
+
+DefStr.Set( u"Canaux artificiels en béton", 65 );
+DefStr.SetAttrValue( u"Canaux artificiels en béton", "" );
+DefStr.SetColor( u"Canaux artificiels en béton", QColor( 136, 136, 136 ) );
+
+DefStr.Set( u"Canaux naturels", 35 );
+DefStr.SetAttrValue( u"Canaux naturels", "" );
+DefStr.SetColor( u"Canaux naturels", QColor( 255, 0, 255 ) );
+
+DefStr.Set( u"Zones à forte urbanization (agglomération)", 9 );
+DefStr.SetAttrValue( u"Zones à forte urbanization (agglomération)", "" );
+DefStr.SetColor( u"Zones à forte urbanization (agglomération)", QColor( 18, 52, 86 ) );
+
+DefStr.Set( u"Zones de champs cultivé à végétation basse", 17.5 );
+DefStr.SetAttrValue( u"Zones de champs cultivé à végétation basse", "512" );
+DefStr.SetColor( u"Zones de champs cultivé à végétation basse", QColor( 255, 255, 0 ) );
+
+DefStr.Set( u"Zones d'arbustes, de sous-bois", 10 );
+DefStr.SetAttrValue( u"Zones d'arbustes, de sous-bois", "" );
+DefStr.SetColor( u"Zones d'arbustes, de sous-bois", QColor( 0, 255, 255 ) );
+
+
+DefStr.Update();
+
+test_LCM = hydro_doc.CreateObject( KIND_LAND_COVER_MAP );
+test_LCM.SetName( "test_LCM" );
+
+attr_values = QStringList()
+attr_values.append( u"" )
+attr_values.append( u"" )
+attr_values.append( u"" )
+attr_values.append( u"512" )
+attr_values.append( u"" )
+attr_values.append( u"511" )
+attr_values.append( u"" )
+attr_values.append( u"" )
+types = QStringList()
+types.append( u"Canaux artificiels en béton" )
+types.append( u"Canaux naturels" )
+types.append( u"Zones d'arbustes, de sous-bois" )
+types.append( u"Zones de champs cultivé à végétation basse" )
+types.append( u"Zones de champs cultivé à végétation haute" )
+types.append( u"Zones de champs, prairies, sans cultures" )
+types.append( u"Zones à faible urbanization (bourg)" )
+types.append( u"Zones à forte urbanization (agglomération)" )
+test_LCM.ImportDBF( 'C:/tmp/lc_dump.dbf', 'CODE_06', attr_values, types )
+
diff --git a/src/HYDRO_tests/reference_data/test_LCM.dbf b/src/HYDRO_tests/reference_data/test_LCM.dbf
new file mode 100644 (file)
index 0000000..2766ee8
Binary files /dev/null and b/src/HYDRO_tests/reference_data/test_LCM.dbf differ
index 0d52d3e6f723892270adab951ab47b22f0958582..4976d7e624de7674db8ff84ad22843070e266725 100644 (file)
@@ -531,6 +531,11 @@ void test_HYDROData_LandCoverMap::test_dump_python()
 {
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 
+  Handle(HYDROData_StricklerTable) aTable =
+    Handle(HYDROData_StricklerTable)::DownCast( aDoc->CreateObject( KIND_STRICKLER_TABLE ) );
+  CPPUNIT_ASSERT_EQUAL( true, aTable->Import( DEF_STR_PATH ) );
+  aTable->SetName( "DefStr" );
+
   Handle(HYDROData_LandCoverMap) aMap =
     Handle(HYDROData_LandCoverMap)::DownCast( aDoc->CreateObject( KIND_LAND_COVER_MAP ) );
   aMap->SetName( "test_LCM" );
@@ -551,10 +556,15 @@ void test_HYDROData_LandCoverMap::test_dump_python()
                                             127 << 42 << 145 << 43 << 148 << 60 << 90 << 65 );
   CPPUNIT_ASSERT_EQUAL( true, aMap->LocalPartition( aLC3, "test3" ) );
 
-  QString aTmpPath = QDir::tempPath() + "/lc_dump.py";
+  QString aBaseName = "lc_dump.py";
+  QString aBaseShp = "lc_dump.shp";
+  QString aBaseDbf = "lc_dump.dbf";
+  QString aTmpPath = QDir::tempPath() + "/" + aBaseName;
   CPPUNIT_ASSERT_EQUAL( true, aDoc->DumpToPython( aTmpPath, false ) );
 
-  //TODO: compare files
+  CPPUNIT_ASSERT_SCRIPTS_EQUAL( aBaseName, true, false, 20 );
+  //TODO: CPPUNIT_ASSERT_FILES_EQUAL( aBaseShp );
+  //TODO: CPPUNIT_ASSERT_FILES_EQUAL( aBaseDbf );
 
   aDoc->Close();
 }