From f4b63cd2bd34dad07c839b1da8c88fa43143bd8f Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 3 Jul 2013 16:01:42 +0000 Subject: [PATCH] Compute progress bar --- src/SMESHGUI/SMESHGUI_ComputeDlg.cxx | 64 ++++++++++++---------------- src/SMESHGUI/SMESHGUI_ComputeDlg.h | 2 + src/SMESHGUI/SMESH_msg_en.ts | 15 +++++++ src/SMESHGUI/SMESH_msg_fr.ts | 15 +++++++ 4 files changed, 60 insertions(+), 36 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index 4883f7873..214dc2446 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -92,6 +92,7 @@ #include #include #include +#include // VTK includes #include @@ -109,20 +110,6 @@ #define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" ) -/* OBSOLETE -static void addSeparator( QWidget* parent ) -{ - QGridLayout* l = qobject_cast( parent->layout() ); - int row = l->rowCount(); - int cols = l->columnCount(); - for ( int i = 0; i < cols; i++ ) { - QFrame* hline = new QFrame( parent ); - hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - l->addWidget( hline, row, i ); - } -} -*/ - enum TCol { COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS }; @@ -745,10 +732,10 @@ SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget qthread(gen, mesh, mainShape) { // -- - setWindowTitle(tr("Compute")); + setWindowTitle(tr("TITLE")); setMinimumWidth( 200 ); - cancelButton = new QPushButton(tr("Cancel")); + cancelButton = new QPushButton(tr("CANCEL")); cancelButton->setDefault(true); QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this ); @@ -757,6 +744,9 @@ SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget nbNodesLabel = new QLabel("0", this ); nbElemsLabel = new QLabel("0", this ); freeRAMLabel = new QLabel("", this ); + progressBar = new QProgressBar(this); + progressBar->setMinimum( 0 ); + progressBar->setMaximum( 1000 ); QGridLayout* layout = new QGridLayout(this); layout->setMargin( MARGIN ); @@ -770,7 +760,8 @@ SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget layout->addWidget(freeRAMName, row, 0); layout->addWidget(freeRAMLabel, row++, 1); #endif - layout->addWidget(cancelButton, row, 0, 1, 2); + layout->addWidget(progressBar, row++, 0, 1, 2); + layout->addWidget(cancelButton, row++, 0, 1, 2); adjustSize(); update(); @@ -788,10 +779,15 @@ bool SMESHGUI_ComputeDlg_QThreadQDialog::result() void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel() { qthread.cancel(); -} + cancelButton->setDown( true ); + cancelButton->setText( tr("CANCELING")); +} void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event) { + if ( !cancelButton->isDown() ) // not yet cancelled + progressBar->setValue( progressBar->maximum() * qthread.getMesh()->GetComputeProgress() ); + if(qthread.isFinished()) { close(); @@ -863,13 +859,9 @@ void SMESHGUI_BaseComputeOp::computeMesh() #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif - bool res; SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape); qthreaddialog.exec(); - res = qthreaddialog.result(); - res = gen->Compute(myMesh, myMainShape); - if (res) - computeFailed = false; + computeFailed = !qthreaddialog.result(); } catch(const SALOME::SALOME_Exception & S_ex) { memoryLack = true; @@ -904,26 +896,26 @@ void SMESHGUI_BaseComputeOp::computeMesh() int entities = SMESH_Actor::eAllEntity; if ( !memoryLack ) { - if ( getSMESHGUI()->automaticUpdate( myMesh, &entities, &limitExceeded ) ) + if ( getSMESHGUI()->automaticUpdate( myMesh, &entities, &limitExceeded ) ) { try { #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 OCC_CATCH_SIGNALS; #endif - SMESH_Actor *anActor = SMESH::FindActorByObject( myMesh ); - if ( !anActor ) anActor = SMESH::CreateActor( aMeshSObj->GetStudy(), aMeshSObj->GetID().c_str(), true ); + SMESH_Actor *anActor = SMESH::FindActorByObject( myMesh ); + if ( !anActor ) anActor = SMESH::CreateActor( aMeshSObj->GetStudy(), aMeshSObj->GetID().c_str(), true ); - anActor->SetEntityMode( entities ); - SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); + anActor->SetEntityMode( entities ); + SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); - SMESH::Update(myIObject, true); + SMESH::Update(myIObject, true); - if ( limitExceeded ) - { - SUIT_MessageBox::warning( desktop(), - tr( "SMESH_WRN_WARNING" ), - tr( "SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ) ); - } + if ( limitExceeded ) + { + SUIT_MessageBox::warning( desktop(), + tr( "SMESH_WRN_WARNING" ), + tr( "SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ) ); + } } catch (...) { #ifdef _DEBUG_ @@ -937,7 +929,7 @@ void SMESHGUI_BaseComputeOp::computeMesh() } } } - else if ( limitExceeded ) + else if ( limitExceeded ) { SUIT_MessageBox::warning( desktop(), tr( "SMESH_WRN_WARNING" ), diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.h b/src/SMESHGUI/SMESHGUI_ComputeDlg.h index e8101a311..d67709d37 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.h +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.h @@ -49,6 +49,7 @@ class QPushButton; class QTableWidget; class QLabel; class QtxComboBox; +class QProgressBar; class SMESHGUI_ComputeDlg; class SMESHGUI_MeshInfosBox; class SMESHGUI_PrecomputeDlg; @@ -318,6 +319,7 @@ private: QLabel * nbNodesLabel; QLabel * nbElemsLabel; QLabel * freeRAMLabel; + QProgressBar* progressBar; }; #endif // SMESHGUI_COMPUTEDLG_H diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index e217a0183..6fd576050 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -4651,6 +4651,21 @@ Please, create VTK viewer and try again Bad Mesh to Group + + SMESHGUI_ComputeDlg_QThreadQDialog + + CANCEL + Cancel + + + CANCELING + Canceling... + + + TITLE + Compute + + SMESHGUI_PrecomputeDlg diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index d7fb4f8fe..65e5bb7b5 100755 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -7484,4 +7484,19 @@ en raison de leurs types incompatibles: Coef de réduction: + + SMESHGUI_ComputeDlg_QThreadQDialog + + TITLE + Compute + + + CANCELING + Canceling... + + + CANCEL + Cancel + + -- 2.30.2