From: mzn Date: Fri, 26 Oct 2018 15:10:07 +0000 (+0300) Subject: refs #1830: Progress dialog for the interpolation of bathymetry. X-Git-Tag: HYDRO_V2_0_0~8^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=52a9ce5d728824041da42b650b57452763f56a60;p=modules%2Fhydro.git refs #1830: Progress dialog for the interpolation of bathymetry. --- diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx old mode 100644 new mode 100755 index c0f841eb..c274ff5d --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -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; diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 894ec619..daeef25f 100755 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -70,6 +70,8 @@ #include #include +#include + //#define DEB_CALCULATION 1 #ifdef DEB_CALCULATION #include @@ -1045,13 +1047,31 @@ NCollection_Sequence HYDROData_CalculationCase::GetAltitudesForPoints( DEBTRACE("HYDROData_CalculationCase::GetAltitudesForPoints " << theRegion->GetName().toStdString()); NCollection_Sequence 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 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; } diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index 043111d4..f5f8d9e7 100755 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -68,6 +68,8 @@ #include +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(); diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index 2b0ebf0f..0047995a 100755 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -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 ) diff --git a/src/HYDROData/HYDROData_Tree.hxx b/src/HYDROData/HYDROData_Tree.hxx old mode 100644 new mode 100755 index c946caab..1c67bc64 --- a/src/HYDROData/HYDROData_Tree.hxx +++ b/src/HYDROData/HYDROData_Tree.hxx @@ -29,6 +29,9 @@ #ifndef _HYDROData_Tree_HXX_ #define _HYDROData_Tree_HXX_ +#include +#include + //================================================================================ //! Data limiting the tree height @@ -204,6 +207,10 @@ void HYDROData_Tree::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::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(); } /*! diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 9e27d77b..17441f3a 100755 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -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( diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 7be3b68a..30c90a0c 100755 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -42,7 +42,8 @@ #include "HYDROGUI_ShowHideOp.h" #include "HYDROGUI_Overview.h" #include -#include +#include +#include #include #include #include @@ -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 index f143b735..00000000 --- a/src/HYDROGUI/HYDROGUI_ProgressIndicator.cxx +++ /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 -#include -#include - -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 index f936a851..00000000 --- a/src/HYDROGUI/HYDROGUI_ProgressIndicator.h +++ /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 - -#include - -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 index 00000000..fb8b07f1 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_SIProgressIndicator.cxx @@ -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 +#include +#include + +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 index 00000000..b077de5b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_SIProgressIndicator.h @@ -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 + +#include + +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 index 00000000..58a021ee --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.cxx @@ -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 +#include +#include +#include + +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("%1"); + + 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 index 00000000..11ea7652 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ZIProgressIndicator.h @@ -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 + +#include + +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 diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 4c61b5f8..0f46924b 100755 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -2021,11 +2021,6 @@ Would you like to remove all references from the image? PREF_POLYLINE_ARROW_SIZE Polyline arrow size - - - STRICKLER_INTERPOLATION_TLT - Strickler coefficient interpolation - @@ -3771,12 +3766,55 @@ Polyline should consist from one not closed curve. - HYDROGUI_ProgressIndicator + HYDROGUI_SIProgressIndicator + + STRICKLER_INTERPOLATION_TLT + Strickler coefficient interpolation + CANCELLING Cancelling... + + HYDROGUI_ZIProgressIndicator + + BATHYMETRY_INTERPOLATION_TLT + Bathymetry interpolation + + + OBJECT + Object: %1 + + + QUADTREE_STAGE + Quadtree calculation + + + TRIANGULATION_STAGE + Triangulation of the point cloud + + + EXPLORATION_STAGE + Exploration of the mesh nodes + + + PENDING + Pending + + + IN_PROGRESS + In progress + + + COMPLETED + Completed + + + CANCELLING + Cancelling... + +