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_SIProgressIndicator.h"
21 #include <QProgressBar>
22 #include <QVBoxLayout>
23 #include <QApplication>
25 #include "HYDRO_trace.hxx"
27 IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_SIProgressIndicator, Message_ProgressIndicator)
29 HYDROGUI_SIProgressIndicator::HYDROGUI_SIProgressIndicator( QWidget* theParent )
30 : QtxDialog( theParent, true, false, QtxDialog::Cancel ), myUserBreak(Standard_False)
32 setWindowTitle( tr( "STRICKLER_INTERPOLATION_TLT" ) );
34 QVBoxLayout* aLayout = new QVBoxLayout( mainFrame() );
35 aLayout->setMargin( 5 );
36 aLayout->setSpacing( 5 );
38 myBar = new QProgressBar( mainFrame() );
40 aLayout->addWidget( myBar );
42 setButtonText( Cancel, tr("CANCEL") );
43 setButtonPosition( Center, Cancel );
44 setMinimumWidth( 350 );
47 HYDROGUI_SIProgressIndicator::~HYDROGUI_SIProgressIndicator()
51 void HYDROGUI_SIProgressIndicator::Show(const Message_ProgressScope& theScope, const Standard_Boolean theForce)
54 Standard_Real aPosition = GetPosition();
57 DEBTRACE("aPosition=" << aPosition << " myCount:" <<myCount);
58 Standard_Boolean isUserBreak = UserBreak();
60 bool isFinished = aPosition >= 1 || ( isUserBreak );
61 if ( isFinished && theForce ) { // theForce == true : call from main thread, Qt display safe
62 if ( result() != Accepted ) {
65 } else if (!isVisible() && theForce) { // theForce == true : call from main thread, Qt display safe
71 int aNbSteps = myBar->maximum() - myBar->minimum();
72 int aValue = int( aPosition * aNbSteps );
73 myBar->setValue(aValue);
76 QApplication::processEvents();
82 Standard_Boolean HYDROGUI_SIProgressIndicator::UserBreak()
87 void HYDROGUI_SIProgressIndicator::Reset()
89 Message_ProgressIndicator::Reset();
90 setButtonText( Cancel, tr("CANCEL") );
91 setButtonEnabled( true, Cancel );
92 myUserBreak = Standard_False;
96 void HYDROGUI_SIProgressIndicator::reject()
98 myUserBreak = Standard_True;
99 setButtonText( Cancel, tr("CANCELLING") );
100 setButtonEnabled( false, Cancel );
101 QApplication::processEvents();