Salome HOME
Merge branch 'BR_H2018_2' of https://codev-tuleap.cea.fr/plugins/git/salome/hydro...
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.cxx
old mode 100644 (file)
new mode 100755 (executable)
index 1c5a4d2..daeef25
@@ -47,6 +47,9 @@
 #endif
 
 #include <QSet>
+#include <QFuture>
+#include <QtConcurrent/QtConcurrent>
+#include <QThread>
 
 #include <TopoDS.hxx>
 #include <TopoDS_Shell.hxx>
@@ -67,6 +70,8 @@
 #include <TopTools_ListIteratorOfListOfShape.hxx>
 #include <TDataStd_Integer.hxx>
 
+#include <Message_ProgressSentry.hxx>
+
 //#define  DEB_CALCULATION 1
 #ifdef DEB_CALCULATION
 #include <BRepTools.hxx>
@@ -1042,13 +1047,31 @@ NCollection_Sequence<double> HYDROData_CalculationCase::GetAltitudesForPoints(
   DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString());
   NCollection_Sequence<double> aResSeq;
 
-  for ( int i = 1, n = thePoints.Length(); i <= n; ++i )
-  {
-    const gp_XY& thePnt = thePoints.Value( i );
+  Handle(Message_ProgressIndicator) aZIProgress = HYDROData_Tool::GetZIProgress();
+  if ( aZIProgress ) {
+    aZIProgress->Reset();
+  }
+
+  QFuture<void> aFuture = QtConcurrent::run([&]() {
+    int aNbPoints = thePoints.Length();
+
+    Message_ProgressSentry aPSentry(HYDROData_Tool::GetZIProgress(), "GetAltitudesForPoints", 0, aNbPoints, 1);
+    for ( int i = 1, n = aNbPoints; i <= n && aPSentry.More(); ++i, aPSentry.Next() )
+    {
+      const gp_XY& thePnt = thePoints.Value( i );
     
-    double anAltitude = GetAltitudeForPoint( thePnt, theRegion, theMethod );
-    aResSeq.Append( anAltitude );
+      double anAltitude = GetAltitudeForPoint( thePnt, theRegion, theMethod );
+      aResSeq.Append( anAltitude );
+    }
+  });
+
+  while( aFuture.isRunning() ) {
+    if ( aZIProgress ) {
+      aZIProgress->Show( Standard_True );
+      QThread::usleep(500);
+    }
   }
+  aZIProgress->Show( Standard_True );
 
   return aResSeq;
 }
@@ -1096,7 +1119,21 @@ std::vector<double> HYDROData_CalculationCase::GetStricklerCoefficientForPoints(
   if( aLCM.IsNull() || aTable.IsNull() )
     return theCoeffs;
 
-  aLCM->ClassifyPoints(thePoints, aTable, theCoeffs, DefValue, UseMax );
+  Handle(Message_ProgressIndicator) aSIProgress = HYDROData_Tool::GetSIProgress();
+  if ( aSIProgress ) {
+    aSIProgress->Reset();
+  }
+
+  QFuture<void> aFuture = QtConcurrent::run([&]() {
+    aLCM->ClassifyPoints(thePoints, aTable, theCoeffs, DefValue, UseMax );
+  });
+
+  while( aFuture.isRunning() ) {
+    if ( aSIProgress ) {
+      aSIProgress->Show( Standard_True );
+      QThread::usleep(500);
+    }
+  }
 
   return theCoeffs;
 }