1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_ZIProgressIndicator.h"
20 #include "HYDROGUI_Tool.h"
22 #include "HYDROData_Tool.h"
25 #include <QProgressBar>
26 #include <QVBoxLayout>
27 #include <QApplication>
29 #include "HYDRO_trace.hxx"
31 IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_ZIProgressIndicator, Message_ProgressIndicator)
33 HYDROGUI_ZIProgressIndicator::HYDROGUI_ZIProgressIndicator( QWidget* theParent )
34 : QtxDialog( theParent, true, false, QtxDialog::Cancel ), myUserBreak(Standard_False),
37 setWindowTitle( tr( "BATHYMETRY_INTERPOLATION_TLT" ) );
39 QVBoxLayout* aLayout = new QVBoxLayout( mainFrame() );
40 aLayout->setMargin( 5 );
41 aLayout->setSpacing( 5 );
43 myQuadTreeBar = new QProgressBar( mainFrame() );
44 myTriangulationState = new QLabel( tr( "PENDING" ), mainFrame() );
45 mySummaryBar = new QProgressBar( mainFrame() );
47 QString aBold("<b>%1</b>");
49 aLayout->addWidget( new QLabel( aBold.arg( tr( "QUADTREE_STAGE" ) ) ) );
50 aLayout->addWidget( myQuadTreeBar );
51 aLayout->addSpacing( 10 );
52 aLayout->addWidget( new QLabel( aBold.arg( tr( "TRIANGULATION_STAGE" ) ) ) );
53 aLayout->addWidget( myTriangulationState );
54 aLayout->addSpacing( 10 );
55 aLayout->addWidget( new QLabel( aBold.arg( tr( "EXPLORATION_STAGE" ) ) ) );
56 aLayout->addWidget( mySummaryBar );
58 setButtonText( Cancel, tr( "CANCEL" ) );
59 setButtonPosition( Center, Cancel );
60 setMinimumWidth( 350 );
63 HYDROGUI_ZIProgressIndicator::~HYDROGUI_ZIProgressIndicator()
67 void HYDROGUI_ZIProgressIndicator::Show(const Message_ProgressScope& theScope, const Standard_Boolean theForce)
70 Standard_Boolean isUserBreak = UserBreak();
71 Standard_Real aPosition = GetPosition();
74 DEBTRACE("aPosition=" << aPosition << " myCount:" <<myCount);
78 QString aName = HYDROGUI_Tool::ToQString( theScope.Name() );
79 DEBTRACE("ScopeName="<< aName);
80 myQuadTreePosition = theScope.GetPortion();
83 myQuadTreeBar->setValue( int( myQuadTreePosition * 100 ) );
84 mySummaryBar->setValue( int( aPosition * 100 ) );
85 HYDROData_Tool::ExecStatus aStatus = HYDROData_Tool::GetTriangulationStatus();
86 if ( aStatus == HYDROData_Tool::Running ) {
87 myTriangulationState->setText( tr("IN_PROGRESS") );
88 } else if ( aStatus == HYDROData_Tool::Finished ) {
89 myTriangulationState->setText( tr("COMPLETED") );
93 bool isFinished = aPosition >= 1 || ( isUserBreak );
94 if ( isFinished && theForce ) { // theForce == true : call from main thread, Qt display safe
95 if ( result() != Accepted ) {
98 } else if ( !isVisible() && theForce ) { // theForce == true : call from main thread, Qt display safe
103 QApplication::processEvents();
109 Standard_Boolean HYDROGUI_ZIProgressIndicator::UserBreak()
114 void HYDROGUI_ZIProgressIndicator::Reset()
116 Message_ProgressIndicator::Reset();
117 myTriangulationState->setText( tr( "PENDING" ) );
118 setButtonText( Cancel, tr("CANCEL") );
119 setButtonEnabled( true, Cancel );
120 myUserBreak = Standard_False;
124 void HYDROGUI_ZIProgressIndicator::reject()
126 myUserBreak = Standard_True;
127 setButtonText( Cancel, tr("CANCELLING") );
128 setButtonEnabled( false, Cancel );
129 QApplication::processEvents();