Salome HOME
refs #1830: Progress dialog for the interpolation of bathymetry.
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.cxx
index 894ec61953bb2afdb5067c7e7b801af2d4420b59..daeef25f6996c84cd3dc1933a96725936c71958b 100755 (executable)
@@ -70,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>
@@ -1045,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;
 }