Salome HOME
refs #1830: Progress dialog for the interpolation of bathymetry.
authormzn <mzn@opencascade.com>
Fri, 26 Oct 2018 15:10:07 +0000 (18:10 +0300)
committermzn <mzn@opencascade.com>
Fri, 26 Oct 2018 15:10:07 +0000 (18:10 +0300)
14 files changed:
src/HYDROData/HYDROData_Bathymetry.cxx [changed mode: 0644->0755]
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_Tool.cxx
src/HYDROData/HYDROData_Tool.h
src/HYDROData/HYDROData_Tree.hxx [changed mode: 0644->0755]
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_ProgressIndicator.cxx [deleted file]
src/HYDROGUI/HYDROGUI_ProgressIndicator.h [deleted file]
src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx [new file with mode: 0755]
src/HYDROGUI/HYDROGUI_SIProgressIndicator.h [new file with mode: 0755]
src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx [new file with mode: 0755]
src/HYDROGUI/HYDROGUI_ZIProgressIndicator.h [new file with mode: 0755]
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

old mode 100644 (file)
new mode 100755 (executable)
index c0f841e..c274ff5
@@ -233,7 +233,6 @@ HYDROData_QuadtreeNode* HYDROData_Bathymetry::ComputeQuadtreeNodes( int key) con
   anAttr->SetID(TDataStd_Integer::GetID());
   DEBTRACE("GetQuadtreeNodes init " << this << " " << key);
   HYDROData_QuadtreeNode* aQuadtree = new HYDROData_QuadtreeNode(0, 30, 5, 0.);
-  myQuadtrees[key] = aQuadtree;
 
   Nodes_3D* aListOfNodes = new Nodes_3D();
 
@@ -252,6 +251,14 @@ HYDROData_QuadtreeNode* HYDROData_Bathymetry::ComputeQuadtreeNodes( int key) con
     }
   DEBTRACE("  GetQuadtreeNodes call setNodesAndCompute");
   aQuadtree->setNodesAndCompute(aListOfNodes);
+
+  Handle(Message_ProgressIndicator) aZIProgress = HYDROData_Tool::GetZIProgress();
+  if ( aZIProgress && aZIProgress->UserBreak() ) {
+    return 0;
+  }
+
+  myQuadtrees[key] = aQuadtree;
+
   return aQuadtree;
 }
 
@@ -309,6 +316,8 @@ vtkPolyData* HYDROData_Bathymetry::ComputeVtkDelaunay2D(int key) const
   if (!aLabel.FindAttribute(TDataStd_RealArray::GetID(), aCoordsArray))
     return 0;
 
+  HYDROData_Tool::SetTriangulationStatus(HYDROData_Tool::Running);
+
   Handle(TDataStd_Integer) anAttr = TDataStd_Integer::Set( myLab.FindChild( DataTag_Delaunay ), key );
   anAttr->SetID(TDataStd_Integer::GetID());
   DEBTRACE("GetVtkDelaunay2D init " << this << " " << key);
@@ -334,6 +343,9 @@ vtkPolyData* HYDROData_Bathymetry::ComputeVtkDelaunay2D(int key) const
   vtkPolyData* data = delaunay2D->GetOutput();
   data->BuildLinks();
   myDelaunay2D[key] = data;
+
+  HYDROData_Tool::SetTriangulationStatus(HYDROData_Tool::Finished);
+
   return data;
 }
 
@@ -460,9 +472,10 @@ double HYDROData_Bathymetry::GetAltitudeForPoint(const gp_XY& thePoint, int theM
   double aResAltitude = anInvalidAltitude;
 
   // --- find the nearest point in the bathymetry cloud, with quadtree
+  Handle(Message_ProgressIndicator) aZIProgress = HYDROData_Tool::GetZIProgress();
 
   HYDROData_QuadtreeNode* aQuadtree = GetQuadtreeNodes();
-  if (!aQuadtree)
+  if (!aQuadtree || (aZIProgress && aZIProgress->UserBreak()))
     {
       DEBTRACE("  no Quadtree");
       return aResAltitude;
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;
 }
index 043111d445776ff40c38a125e98ed9abb8162c73..f5f8d9e77df9fe165d036381260ac7b53ea84f9b 100755 (executable)
@@ -68,6 +68,8 @@
 #include <ShapeAnalysis_FreeBounds.hxx>
 
 
+HYDROData_Tool::ExecStatus HYDROData_Tool::myTriangulationStatus = ExecStatus::None;
+
 static int aMaxNameId = INT_MAX;
 static int aMaxColorNb = 92000;
 void HYDROData_Tool::WriteStringsToFile( QFile&             theFile,
@@ -656,6 +658,32 @@ Handle(Message_ProgressIndicator)& HYDROData_Tool::StricklerInterpolationProgres
   return aPI;
 }
 
+void HYDROData_Tool::SetZIProgress(const Handle(Message_ProgressIndicator)& thePI)
+{
+  BathymetryInterpolationProgress() = thePI;
+}
+  
+const Handle(Message_ProgressIndicator)& HYDROData_Tool::GetZIProgress()
+{
+  return BathymetryInterpolationProgress();
+}
+
+Handle(Message_ProgressIndicator)& HYDROData_Tool::BathymetryInterpolationProgress()
+{
+  static Handle(Message_ProgressIndicator) aPI = NULL;
+  return aPI;
+}
+
+void HYDROData_Tool::SetTriangulationStatus(const ExecStatus& theStatus)
+{
+  myTriangulationStatus = theStatus;
+}
+
+const HYDROData_Tool::ExecStatus& HYDROData_Tool::GetTriangulationStatus()
+{
+  return myTriangulationStatus;
+}
+
 std::ostream& operator<<( std::ostream& theStream, const QString& theText )
 {
   theStream << theText.toStdString();
index 2b0ebf0f70b72d4abcce5f61d3598d17ee964803..0047995a169da453dbf1672a338f20375ea8da49 100755 (executable)
@@ -37,6 +37,7 @@ class gp_XY;
 class QColor;
 class QFile;
 class TCollection_ExtendedString;
+
 #ifdef WIN32
   enum TopAbs_State;
 #else
@@ -51,6 +52,14 @@ class QColor;
 
 class HYDRODATA_EXPORT HYDROData_Tool {
 
+public:
+  enum ExecStatus
+  {
+    None,
+    Running,
+    Finished
+  };
+
 public:
 
   static void                           WriteStringsToFile( QFile&             theFile,
@@ -148,8 +157,16 @@ public:
   static void SetSIProgress(const Handle(Message_ProgressIndicator)& thePI);
   static const Handle(Message_ProgressIndicator)& GetSIProgress();
 
+  static void SetZIProgress(const Handle(Message_ProgressIndicator)& thePI);
+  static const Handle(Message_ProgressIndicator)& GetZIProgress();
+
+  static void SetTriangulationStatus(const ExecStatus& theStatus);
+  static const ExecStatus& GetTriangulationStatus();
+
 private:
   static Handle(Message_ProgressIndicator)& StricklerInterpolationProgress();
+  static Handle(Message_ProgressIndicator)& BathymetryInterpolationProgress();
+  static ExecStatus myTriangulationStatus;
 };
 
 inline bool ValuesEquals( const double& theFirst, const double& theSecond )
old mode 100644 (file)
new mode 100755 (executable)
index c946caa..1c67bc6
@@ -29,6 +29,9 @@
 #ifndef _HYDROData_Tree_HXX_
 #define _HYDROData_Tree_HXX_
 
+#include <HYDROData_Tool.h>
+#include <Message_ProgressSentry.hxx>
+
 //================================================================================
 
 //! Data limiting the tree height
@@ -204,6 +207,10 @@ void HYDROData_Tree<BND_BOX, NB_CHILDREN>::buildChildren()
         root = root->myFather;
       rootSize = root->maxSize();
     }
+  
+  Handle(Message_ProgressIndicator) aZIProgress = myLevel == 0 ? HYDROData_Tool::GetZIProgress() : NULL;
+  Message_ProgressSentry aPSentry(aZIProgress, "QuadTree", 0, NB_CHILDREN + 1, 1);
+
   for (int i = 0; i < NB_CHILDREN; i++)
     {
       // The child is of the same type than its father (For instance, a HYDROData_OctreeNode)
@@ -224,9 +231,16 @@ void HYDROData_Tree<BND_BOX, NB_CHILDREN>::buildChildren()
   // --- After building the NB_CHILDREN boxes, we put the data into the children.
   buildChildrenData();
 
+  if (aPSentry.More()) {
+    aPSentry.Next();
+  }
+
   // --- After we pass to the next level of the Tree
-  for (int i = 0; i < NB_CHILDREN; i++)
+  for (int i = 0; i < NB_CHILDREN && aPSentry.More(); i++, aPSentry.Next()) {
     myChildren[i]->buildChildren();
+  }
+
+  aPSentry.Relieve();
 }
 
 /*!
index 9e27d77ba77b58d76558f2021101ad61139cae3e..17441f3aa5df015faa798f503703232735c4125b 100755 (executable)
@@ -159,7 +159,8 @@ set(PROJECT_HEADERS
     HYDROGUI_SetBoundaryTypePolygonDlg.h
     HYDROGUI_MeasurementToolOp.h
     HYDROGUI_MeasurementToolDlg.h
-    HYDROGUI_ProgressIndicator.h
+    HYDROGUI_SIProgressIndicator.h
+    HYDROGUI_ZIProgressIndicator.h
 )
 
 QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
@@ -321,7 +322,8 @@ set(PROJECT_SOURCES
     HYDROGUI_SetBoundaryTypePolygonDlg.cxx
     HYDROGUI_MeasurementToolOp.cxx
     HYDROGUI_MeasurementToolDlg.cxx
-    HYDROGUI_ProgressIndicator.cxx
+    HYDROGUI_SIProgressIndicator.cxx
+    HYDROGUI_ZIProgressIndicator.cxx
 )
 
 add_definitions(
index 7be3b68ab167aa8cdd51439cab7d049fabee6701..30c90a0c14a780be14ce145901281cc8333b1561 100755 (executable)
@@ -42,7 +42,8 @@
 #include "HYDROGUI_ShowHideOp.h"
 #include "HYDROGUI_Overview.h"
 #include <HYDROGUI_ProfileDlg.h>
-#include <HYDROGUI_ProgressIndicator.h>
+#include <HYDROGUI_SIProgressIndicator.h>
+#include <HYDROGUI_ZIProgressIndicator.h>
 #include <HYDROData_Tool.h>
 #include <HYDROData_Image.h>
 #include <HYDROData_Stream.h>
@@ -156,7 +157,8 @@ void HYDROGUI_Module::initialize( CAM_Application* theApp )
   myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
   myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
 
-  HYDROData_Tool::SetSIProgress( new HYDROGUI_ProgressIndicator( theApp->desktop(), tr( "STRICKLER_INTERPOLATION_TLT" ) ) );
+  HYDROData_Tool::SetSIProgress( new HYDROGUI_SIProgressIndicator( theApp->desktop() ) );
+  HYDROData_Tool::SetZIProgress( new HYDROGUI_ZIProgressIndicator( theApp->desktop() ) );
 }
 
 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
diff --git a/src/HYDROGUI/HYDROGUI_ProgressIndicator.cxx b/src/HYDROGUI/HYDROGUI_ProgressIndicator.cxx
deleted file mode 100644 (file)
index f143b73..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (C) 2014-2015  EDF-R&D
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "HYDROGUI_ProgressIndicator.h"
-
-#include <QProgressBar>
-#include <QVBoxLayout>
-#include <QApplication>
-
-IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_ProgressIndicator, Message_ProgressIndicator)
-
-HYDROGUI_ProgressIndicator::HYDROGUI_ProgressIndicator( QWidget* theParent, const QString& theName )
-: QtxDialog( theParent, true, false, QtxDialog::Cancel ), myUserBreak(false)
-{
-  setWindowTitle( theName );
-
-  QVBoxLayout* aLayout = new QVBoxLayout( mainFrame() );
-  aLayout->setMargin( 5 );
-  aLayout->setSpacing( 5 );
-
-  myBar = new QProgressBar( mainFrame() );
-
-  aLayout->addWidget( myBar );
-
-  setButtonText( Cancel, tr("CANCEL") );
-  setButtonPosition( Center, Cancel );
-  setMinimumWidth( 350 );
-}
-
-HYDROGUI_ProgressIndicator::~HYDROGUI_ProgressIndicator()
-{
-}
-
-Standard_Boolean HYDROGUI_ProgressIndicator::Show(const Standard_Boolean theForce)
-{
-  Standard_Real aPosition = GetPosition();
-  Standard_Boolean isUserBreak = UserBreak();
-
-  bool isFinished = aPosition >= 1 || ( isUserBreak && GetNbScopes() < 2 );
-  if ( isFinished  ) {
-    if ( result() != Accepted ) {
-      QDialog::accept();
-    }
-  } else if (!isVisible()) {
-    open();
-  } 
-
-  if ( theForce ) {
-    if ( !isUserBreak ) {
-      int aNbSteps = myBar->maximum() - myBar->minimum();
-      int aValue = int( aPosition * aNbSteps );
-      myBar->setValue(aValue);
-    }
-
-    QApplication::processEvents();
-  }
-
-  return true;
-}
-
-Standard_Boolean HYDROGUI_ProgressIndicator::UserBreak()
-{
-  return myUserBreak;
-}
-
-void HYDROGUI_ProgressIndicator::Reset()
-{
-  Message_ProgressIndicator::Reset();
-  setButtonText( Cancel, tr("CANCEL") );
-  setButtonEnabled( true, Cancel );
-  myUserBreak = false;
-}
-
-void HYDROGUI_ProgressIndicator::reject()
-{
-  myUserBreak = true;
-  setButtonText( Cancel, tr("CANCELLING") );
-  setButtonEnabled( false, Cancel );
-  QApplication::processEvents();
-}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_ProgressIndicator.h b/src/HYDROGUI/HYDROGUI_ProgressIndicator.h
deleted file mode 100644 (file)
index f936a85..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) 2014-2015  EDF-R&D
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifndef HYDROGUI_PROGRESSINDICATOR_H
-#define HYDROGUI_PROGRESSINDICATOR_H
-
-#include <QtxDialog.h>
-
-#include <Message_ProgressIndicator.hxx>
-
-class QProgressBar;
-
-class HYDROGUI_ProgressIndicator : public QtxDialog, public Message_ProgressIndicator
-{
-  Q_OBJECT
-
-public:
-  HYDROGUI_ProgressIndicator( QWidget* theParent, const QString& theName );
-  virtual ~HYDROGUI_ProgressIndicator();
-  
-  virtual Standard_Boolean Show (const Standard_Boolean theForce);
-
-  virtual Standard_Boolean UserBreak();
-
-  virtual void Reset();
-
-protected slots:
-  virtual void reject();
-
-private:
-  QProgressBar* myBar;
-  bool myUserBreak;
-
-public:
-  DEFINE_STANDARD_RTTIEXT (HYDROGUI_ProgressIndicator, Message_ProgressIndicator)
-};
-
-#endif
diff --git a/src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx b/src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx
new file mode 100755 (executable)
index 0000000..fb8b07f
--- /dev/null
@@ -0,0 +1,95 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_SIProgressIndicator.h"
+
+#include <QProgressBar>
+#include <QVBoxLayout>
+#include <QApplication>
+
+IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_SIProgressIndicator, Message_ProgressIndicator)
+
+HYDROGUI_SIProgressIndicator::HYDROGUI_SIProgressIndicator( QWidget* theParent )
+: QtxDialog( theParent, true, false, QtxDialog::Cancel ), myUserBreak(Standard_False)
+{
+  setWindowTitle( tr( "STRICKLER_INTERPOLATION_TLT" ) );
+
+  QVBoxLayout* aLayout = new QVBoxLayout( mainFrame() );
+  aLayout->setMargin( 5 );
+  aLayout->setSpacing( 5 );
+
+  myBar = new QProgressBar( mainFrame() );
+
+  aLayout->addWidget( myBar );
+
+  setButtonText( Cancel, tr("CANCEL") );
+  setButtonPosition( Center, Cancel );
+  setMinimumWidth( 350 );
+}
+
+HYDROGUI_SIProgressIndicator::~HYDROGUI_SIProgressIndicator()
+{
+}
+
+Standard_Boolean HYDROGUI_SIProgressIndicator::Show(const Standard_Boolean theForce)
+{
+  Standard_Real aPosition = GetPosition();
+  Standard_Boolean isUserBreak = UserBreak();
+
+  bool isFinished = aPosition >= 1 || ( isUserBreak && GetNbScopes() < 2 );
+  if ( isFinished  ) {
+    if ( result() != Accepted ) {
+      QDialog::accept();
+    }
+  } else if (!isVisible()) {
+    open();
+  } 
+
+  if ( theForce ) {
+    if ( !isUserBreak ) {
+      int aNbSteps = myBar->maximum() - myBar->minimum();
+      int aValue = int( aPosition * aNbSteps );
+      myBar->setValue(aValue);
+    }
+
+    QApplication::processEvents();
+  }
+
+  return true;
+}
+
+Standard_Boolean HYDROGUI_SIProgressIndicator::UserBreak()
+{
+  return myUserBreak;
+}
+
+void HYDROGUI_SIProgressIndicator::Reset()
+{
+  Message_ProgressIndicator::Reset();
+  setButtonText( Cancel, tr("CANCEL") );
+  setButtonEnabled( true, Cancel );
+  myUserBreak = Standard_False;
+}
+
+void HYDROGUI_SIProgressIndicator::reject()
+{
+  myUserBreak = Standard_True;
+  setButtonText( Cancel, tr("CANCELLING") );
+  setButtonEnabled( false, Cancel );
+  QApplication::processEvents();
+}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_SIProgressIndicator.h b/src/HYDROGUI/HYDROGUI_SIProgressIndicator.h
new file mode 100755 (executable)
index 0000000..b077de5
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_SIPROGRESSINDICATOR_H
+#define HYDROGUI_SIPROGRESSINDICATOR_H
+
+#include <QtxDialog.h>
+
+#include <Message_ProgressIndicator.hxx>
+
+class QProgressBar;
+
+class HYDROGUI_SIProgressIndicator : public QtxDialog, public Message_ProgressIndicator
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_SIProgressIndicator( QWidget* theParent );
+  virtual ~HYDROGUI_SIProgressIndicator();
+  
+  virtual Standard_Boolean Show (const Standard_Boolean theForce);
+
+  virtual Standard_Boolean UserBreak();
+
+  virtual void Reset();
+
+protected slots:
+  virtual void reject();
+
+private:
+  QProgressBar* myBar;
+  Standard_Boolean myUserBreak;
+
+public:
+  DEFINE_STANDARD_RTTIEXT (HYDROGUI_SIProgressIndicator, Message_ProgressIndicator)
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx b/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx
new file mode 100755 (executable)
index 0000000..58a021e
--- /dev/null
@@ -0,0 +1,133 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ZIProgressIndicator.h"
+#include "HYDROGUI_Tool.h"
+
+#include "HYDROData_Tool.h"
+
+#include <QLabel>
+#include <QProgressBar>
+#include <QVBoxLayout>
+#include <QApplication>
+
+IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_ZIProgressIndicator, Message_ProgressIndicator)
+
+HYDROGUI_ZIProgressIndicator::HYDROGUI_ZIProgressIndicator( QWidget* theParent )
+: QtxDialog( theParent, true, false, QtxDialog::Cancel ), myUserBreak(Standard_False),
+  myQuadTreePosition(0)
+{
+  setWindowTitle( tr( "BATHYMETRY_INTERPOLATION_TLT" ) );
+
+  QVBoxLayout* aLayout = new QVBoxLayout( mainFrame() );
+  aLayout->setMargin( 5 );
+  aLayout->setSpacing( 5 );
+
+  myQuadTreeBar = new QProgressBar( mainFrame() );
+  myTriangulationState = new QLabel( tr( "PENDING" ), mainFrame() );
+  mySummaryBar = new QProgressBar( mainFrame() );
+
+  QString aBold("<b>%1</b>");
+
+  aLayout->addWidget( new QLabel( aBold.arg( tr( "QUADTREE_STAGE" ) ) ) );
+  aLayout->addWidget( myQuadTreeBar );
+  aLayout->addSpacing( 10 );
+  aLayout->addWidget( new QLabel( aBold.arg( tr( "TRIANGULATION_STAGE" ) ) ) );
+  aLayout->addWidget( myTriangulationState );
+  aLayout->addSpacing( 10 );
+  aLayout->addWidget( new QLabel( aBold.arg( tr( "EXPLORATION_STAGE" ) ) ) );
+  aLayout->addWidget( mySummaryBar );
+
+  setButtonText( Cancel, tr( "CANCEL" ) );
+  setButtonPosition( Center, Cancel );
+  setMinimumWidth( 350 );
+}
+
+HYDROGUI_ZIProgressIndicator::~HYDROGUI_ZIProgressIndicator()
+{
+}
+
+Standard_Boolean HYDROGUI_ZIProgressIndicator::Show(const Standard_Boolean theForce)
+{
+  Standard_Boolean isUserBreak = UserBreak();
+  Standard_Real aPosition = GetPosition(); 
+
+  if ( !theForce ) {
+    // quadtree
+    for ( Standard_Integer i = 1; i <= GetNbScopes(); i++ ) {
+      Message_ProgressScale aScope = GetScope(i);
+      QString aName = HYDROGUI_Tool::ToQString( aScope.GetName() ); 
+      if ( aName != "QuadTree" ) {
+        continue;
+      }
+
+      Standard_Real aMin = aScope.GetMin();
+      Standard_Real aMax = aScope.GetMax();
+      Standard_Real aScopeValue = aScope.BaseToLocal( aPosition );
+      myQuadTreePosition = aScopeValue / (aMax - aMin);
+      break;
+    }
+  } else {
+    if ( !isUserBreak ) {
+      myQuadTreeBar->setValue( int( myQuadTreePosition * 100 ) );
+      mySummaryBar->setValue( int( aPosition * 100 ) );
+      HYDROData_Tool::ExecStatus aStatus = HYDROData_Tool::GetTriangulationStatus();
+      if ( aStatus == HYDROData_Tool::Running ) {
+        myTriangulationState->setText( tr("IN_PROGRESS") );
+      } else if ( aStatus == HYDROData_Tool::Finished ) {
+        myTriangulationState->setText( tr("COMPLETED") );
+      }
+    }
+
+    bool isFinished = aPosition >= 1 || ( isUserBreak && GetNbScopes() < 2 );
+    if ( isFinished  ) {
+      if ( result() != Accepted ) {
+        QDialog::accept();
+      } 
+    } else if ( !isVisible() ) {
+      open();
+    }
+
+
+    QApplication::processEvents();
+  }
+
+  return true;
+}
+
+Standard_Boolean HYDROGUI_ZIProgressIndicator::UserBreak()
+{
+  return myUserBreak;
+}
+
+void HYDROGUI_ZIProgressIndicator::Reset()
+{
+  Message_ProgressIndicator::Reset();
+  myTriangulationState->setText( tr( "PENDING" ) );
+  setButtonText( Cancel, tr("CANCEL") );
+  setButtonEnabled( true, Cancel );
+  myUserBreak = Standard_False;
+}
+
+void HYDROGUI_ZIProgressIndicator::reject()
+{
+  myUserBreak = Standard_True;
+  setButtonText( Cancel, tr("CANCELLING") );
+  setButtonEnabled( false, Cancel );
+  QApplication::processEvents();
+}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.h b/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.h
new file mode 100755 (executable)
index 0000000..11ea765
--- /dev/null
@@ -0,0 +1,58 @@
+// Copyright (C) 2014-2015  EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_BATHPROGRESSINDICATOR_H
+#define HYDROGUI_BATHPROGRESSINDICATOR_H
+
+#include <QtxDialog.h>
+
+#include <Message_ProgressIndicator.hxx>
+
+class QLabel;
+class QProgressBar;
+
+class HYDROGUI_ZIProgressIndicator : public QtxDialog, public Message_ProgressIndicator
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ZIProgressIndicator( QWidget* theParent );
+  virtual ~HYDROGUI_ZIProgressIndicator();
+  
+  virtual Standard_Boolean Show (const Standard_Boolean theForce);
+
+  virtual Standard_Boolean UserBreak();
+
+  virtual void Reset();
+
+protected slots:
+  virtual void reject();
+
+private:
+  QProgressBar* myQuadTreeBar;
+  QLabel* myTriangulationState;
+  QProgressBar* mySummaryBar;
+
+  Standard_Real myQuadTreePosition;
+  Standard_Boolean myUserBreak;
+
+public:
+  DEFINE_STANDARD_RTTIEXT (HYDROGUI_ZIProgressIndicator, Message_ProgressIndicator)
+};
+
+#endif
index 4c61b5f8ae6411f47678d4716281a7a176a0cd32..0f46924bf5dd0198bca5eeae0aca98f15d6a69dc 100755 (executable)
@@ -2021,11 +2021,6 @@ Would you like to remove all references from the image?</translation>
       <source>PREF_POLYLINE_ARROW_SIZE</source>\r
       <translation>Polyline arrow size</translation>\r
     </message>\r
-\r
-    <message>\r
-      <source>STRICKLER_INTERPOLATION_TLT</source>\r
-      <translation>Strickler coefficient interpolation</translation>\r
-    </message>\r
   </context>\r
   \r
   <context>\r
@@ -3771,12 +3766,55 @@ Polyline should consist from one not closed curve.</translation>
   </context>\r
   \r
   <context>\r
-    <name>HYDROGUI_ProgressIndicator</name>\r
+    <name>HYDROGUI_SIProgressIndicator</name>\r
+     <message>\r
+      <source>STRICKLER_INTERPOLATION_TLT</source>\r
+      <translation>Strickler coefficient interpolation</translation>\r
+     </message>\r
      <message>\r
       <source>CANCELLING</source>\r
       <translation>Cancelling...</translation>\r
     </message>\r
   </context>\r
 \r
+  <context>\r
+    <name>HYDROGUI_ZIProgressIndicator</name>\r
+     <message>\r
+      <source>BATHYMETRY_INTERPOLATION_TLT</source>\r
+      <translation>Bathymetry interpolation</translation>\r
+     </message>\r
+     <message>\r
+      <source>OBJECT</source>\r
+      <translation>Object: %1</translation>\r
+     </message>\r
+     <message>\r
+      <source>QUADTREE_STAGE</source>\r
+      <translation>Quadtree calculation</translation>\r
+     </message>\r
+     <message>\r
+      <source>TRIANGULATION_STAGE</source>\r
+      <translation>Triangulation of the point cloud</translation>\r
+     </message>\r
+     <message>\r
+      <source>EXPLORATION_STAGE</source>\r
+      <translation>Exploration of the mesh nodes</translation>\r
+     </message>\r
+     <message>\r
+      <source>PENDING</source>\r
+      <translation>Pending</translation>\r
+     </message>\r
+     <message>\r
+      <source>IN_PROGRESS</source>\r
+      <translation>In progress</translation>\r
+     </message>\r
+     <message>\r
+      <source>COMPLETED</source>\r
+      <translation>Completed</translation>\r
+     </message>     \r
+     <message>\r
+      <source>CANCELLING</source>\r
+      <translation>Cancelling...</translation>\r
+     </message>\r
+  </context>\r
 \r
 </TS>\r