]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1048
authorisn <isn@opencascade.com>
Thu, 24 Nov 2016 11:03:11 +0000 (14:03 +0300)
committerisn <isn@opencascade.com>
Thu, 24 Nov 2016 11:03:11 +0000 (14:03 +0300)
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx
src/HYDROGUI/HYDROGUI_ExportCalculationOp.h
src/HYDROPy/HYDROData_LandCoverMap.sip
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx

index d0949778ad6e792cd8d126b9b19e588c1f109d21..ebfd1803afdbaa9bed23409cbe04798429ca7f06 100644 (file)
@@ -1046,7 +1046,8 @@ QString HYDROData_CalculationCase::Export( int theStudyId ) const
   SALOMEDS::Study_var aDSStudy = HYDROData_GeomTool::GetStudyByID( theStudyId );
   
   QString aGeomObjEntry, anErrorMsg;
-  bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg );
+  QString statMess;
+  bool isOK = Export( aGEOMEngine, aDSStudy, aGeomObjEntry, anErrorMsg, statMess );
   return isOK ? aGeomObjEntry : QString();
 #endif
 }
@@ -1055,7 +1056,8 @@ QString HYDROData_CalculationCase::Export( int theStudyId ) const
 bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
                                         SALOMEDS::Study_ptr theStudy,
                                         QString& theGeomObjEntry,
-                                        QString& theErrorMsg ) const
+                                        QString& theErrorMsg,
+                                        QString& statMess) const
 {
   HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroupsDefs;
 
@@ -1122,8 +1124,9 @@ bool HYDROData_CalculationCase::Export( GEOM::GEOM_Gen_var  theGeomEngine,
   if( aRes && !GetLandCoverMap().IsNull() && !GetStricklerTable().IsNull() )
   {
     QString aTelemacFileName = GetName() + ".telemac";
-    aRes = GetLandCoverMap()->ExportTelemac( aTelemacFileName, 1E-2, GetStricklerTable() );
-    theErrorMsg = QString( "The export to TELEMAC %1 failed" ).arg( aTelemacFileName );
+    aRes = GetLandCoverMap()->ExportTelemac( aTelemacFileName, 1E-2, GetStricklerTable(), statMess );
+    if (!aRes)
+      theErrorMsg = QString( "The export to TELEMAC %1 failed" ).arg( aTelemacFileName );
   }
   return aRes;
 }
index 242a8b6832138f0be4360ecdacfe269687639f9b..b88a108ea4b7bdd4f63ef35784acfd20972718c7 100644 (file)
@@ -301,7 +301,8 @@ public:
   HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
                                         SALOMEDS::Study_ptr theStudy,
                                         QString& theGeomObjEntry,
-                                        QString& theErrorMsg ) const;
+                                        QString& theErrorMsg,
+                                        QString& statMess) const;
 #endif
 
 public:      
index c582b16fcc4143a2842f97b97fa89f57f3de270b..c9788e204acafce3ed71e35c1a2a7e997280dcb7 100644 (file)
@@ -62,6 +62,7 @@
 #include <TopTools_DataMapOfShapeListOfShape.hxx>
 #include <NCollection_DoubleMap.hxx>
 #include <HYDROData_LCM_FaceClassifier.h>
+#include <QDir>
 
 #include <stdexcept>
 
@@ -367,7 +368,8 @@ bool EdgeDiscretization( const TopoDS_Edge& theEdge,
 */
 bool HYDROData_LandCoverMap::ExportTelemac( const QString& theFileName,
                                             double theDeflection,
-                                            const Handle(HYDROData_StricklerTable)& theTable ) const
+                                            const Handle(HYDROData_StricklerTable)& theTable,
+                                            QString& statMessage) const
 {
   TopoDS_Shape aLandCoverMapShape = GetShape();
   TopTools_ListOfShape aListOfFaces;
@@ -418,7 +420,16 @@ bool HYDROData_LandCoverMap::ExportTelemac( const QString& theFileName,
 
   QFile aFile( theFileName );
   if( !aFile.open( QFile::WriteOnly | QFile::Text ) )
-    return false;
+  {
+    QString homeDirPath = QDir::homePath();
+    aFile.setFileName(homeDirPath);
+    if (aFile.open( QFile::WriteOnly | QFile::Text ) )
+      statMessage = "Telemac file have been exported to the home directory:" + homeDirPath;
+    else
+      return false;
+  }
+  else
+    statMessage = "Telemac file have been exported to the current directory";
 
   QTextStream aStream( &aFile );
   aStream << "# nodes\n";
index e009351a2baa6e20176ca49c3baa0b7218103401..f6e681b04bff09cdf79d04060799c3d498635004 100644 (file)
@@ -111,7 +111,8 @@ public:
 
   HYDRODATA_EXPORT bool ExportTelemac( const QString& theFileName,
                                        double theDeflection,
-                                       const Handle_HYDROData_StricklerTable& theTable ) const;
+                                       const Handle_HYDROData_StricklerTable& theTable,
+                                       QString& statMessage) const;
 
   HYDRODATA_EXPORT bool Add( const Handle( HYDROData_Object )&, const QString& theType );
   HYDRODATA_EXPORT bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType );
index 93467ea163c0cb457549bfa8ef3c3a4b4a20040f..77978ee51bc52b9902ac70383030e6603f3f16eb 100644 (file)
@@ -65,7 +65,7 @@ void HYDROGUI_ExportCalculationOp::commitOperation()
 
 bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags,
                                                  QString& theErrorMsg,
-                                                 QStringList& theBrowseObjectsEntries )
+                                                 QStringList& theBrowseObjectsEntries)
 {
   // Get the selected calculation case
   Handle(HYDROData_CalculationCase) aCalculation = 
@@ -84,12 +84,13 @@ bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags,
     dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
 
   // Export
+  myStatMess.clear();
   QString anErrorMsg;
   if ( aStudy ) {
     SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
     GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
     QString anEntry;
-    if ( aCalculation->Export( aGeomEngine, aDSStudy, anEntry, theErrorMsg ) ) {
+    if ( aCalculation->Export( aGeomEngine, aDSStudy, anEntry, theErrorMsg, myStatMess ) ) {
       theUpdateFlags = UF_ObjBrowser;
       isOk = true;
     }
@@ -132,7 +133,7 @@ void HYDROGUI_ExportCalculationOp::onApply()
     // Show message box
     SUIT_MessageBox::information( module()->getApp()->desktop(),
                                   tr( "EXPORT_STATUS" ),
-                                  tr( "EXPORT_FINISHED") ); 
+                                  tr( "EXPORT_FINISHED") + "\n" + getStatMess() ); 
   } 
   else {
     abort();
@@ -147,3 +148,8 @@ void HYDROGUI_ExportCalculationOp::onApply()
                                anErrorMsg ); 
   }
 }
+
+QString HYDROGUI_ExportCalculationOp::getStatMess()
+{
+  return myStatMess;
+}
index f7c0d0b30330cbdda6d6f5b57be8f391efe4eefc..e73883ce3adfca22fb7af1764ffea13181fd8758 100644 (file)
@@ -38,6 +38,10 @@ protected:
   virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg,
                                            QStringList& theBrowseObjectsEntries );
   virtual void               onApply();
+
+  QString                    getStatMess();
+
+  QString                    myStatMess;
 };
 
 #endif
\ No newline at end of file
index a502140da27786672c47cfa8c0fc08964689fc9a..0ac9618b38c3b77316bfaf0f536cdc362ee47421 100644 (file)
@@ -75,8 +75,8 @@ public:
     if ( !aRef.IsNull() )
     {
       Py_BEGIN_ALLOW_THREADS
-      sipRes = sipSelfWasArg ? sipCpp->HYDROData_LandCoverMap::ExportTelemac( *a0, a1, aRef ):
-                               sipCpp->ExportTelemac( *a0, a1, aRef );
+      sipRes = sipSelfWasArg ? sipCpp->HYDROData_LandCoverMap::ExportTelemac( *a0, a1, aRef, QString("") ):
+                               sipCpp->ExportTelemac( *a0, a1, aRef, QString("") );
       Py_END_ALLOW_THREADS
     }
   %End
index 074748771701e180e2e8c2073368cd935d4d9486..d4cbc6ee6c211459001f9422953fc579f4baa16e 100644 (file)
@@ -1100,7 +1100,8 @@ void test_HYDROData_LandCoverMap::test_export_telemac()
 
   QString aTmpFileName = "test.telemac";
   QString aTmpPath = QDir::tempPath() + "/" + aTmpFileName;
-  CPPUNIT_ASSERT_EQUAL( true, aMap->ExportTelemac( aTmpPath, 1E-4, aTable ) );
+  QString messStat;
+  CPPUNIT_ASSERT_EQUAL( true, aMap->ExportTelemac( aTmpPath, 1E-4, aTable, messStat ) );
   CPPUNIT_ASSERT_SCRIPTS_EQUAL( aTmpFileName, true, true, 0 );
 
   aDoc->Close();