Compute progress bar

This commit is contained in:
eap 2013-07-03 16:01:42 +00:00
parent 49cd1d951a
commit f4b63cd2bd
4 changed files with 60 additions and 36 deletions

View File

@ -92,6 +92,7 @@
#include <QButtonGroup> #include <QButtonGroup>
#include <QCloseEvent> #include <QCloseEvent>
#include <QTimerEvent> #include <QTimerEvent>
#include <QProgressBar>
// VTK includes // VTK includes
#include <vtkProperty.h> #include <vtkProperty.h>
@ -109,20 +110,6 @@
#define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" ) #define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
/* OBSOLETE
static void addSeparator( QWidget* parent )
{
QGridLayout* l = qobject_cast<QGridLayout*>( 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 { enum TCol {
COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS 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) qthread(gen, mesh, mainShape)
{ {
// -- // --
setWindowTitle(tr("Compute")); setWindowTitle(tr("TITLE"));
setMinimumWidth( 200 ); setMinimumWidth( 200 );
cancelButton = new QPushButton(tr("Cancel")); cancelButton = new QPushButton(tr("CANCEL"));
cancelButton->setDefault(true); cancelButton->setDefault(true);
QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this ); 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 ); nbNodesLabel = new QLabel("0", this );
nbElemsLabel = new QLabel("0", this ); nbElemsLabel = new QLabel("0", this );
freeRAMLabel = new QLabel("", this ); freeRAMLabel = new QLabel("", this );
progressBar = new QProgressBar(this);
progressBar->setMinimum( 0 );
progressBar->setMaximum( 1000 );
QGridLayout* layout = new QGridLayout(this); QGridLayout* layout = new QGridLayout(this);
layout->setMargin( MARGIN ); layout->setMargin( MARGIN );
@ -770,7 +760,8 @@ SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget
layout->addWidget(freeRAMName, row, 0); layout->addWidget(freeRAMName, row, 0);
layout->addWidget(freeRAMLabel, row++, 1); layout->addWidget(freeRAMLabel, row++, 1);
#endif #endif
layout->addWidget(cancelButton, row, 0, 1, 2); layout->addWidget(progressBar, row++, 0, 1, 2);
layout->addWidget(cancelButton, row++, 0, 1, 2);
adjustSize(); adjustSize();
update(); update();
@ -788,10 +779,15 @@ bool SMESHGUI_ComputeDlg_QThreadQDialog::result()
void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel() void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel()
{ {
qthread.cancel(); qthread.cancel();
} cancelButton->setDown( true );
cancelButton->setText( tr("CANCELING"));
}
void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event) void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event)
{ {
if ( !cancelButton->isDown() ) // not yet cancelled
progressBar->setValue( progressBar->maximum() * qthread.getMesh()->GetComputeProgress() );
if(qthread.isFinished()) if(qthread.isFinished())
{ {
close(); close();
@ -863,13 +859,9 @@ void SMESHGUI_BaseComputeOp::computeMesh()
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#endif #endif
bool res;
SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape); SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape);
qthreaddialog.exec(); qthreaddialog.exec();
res = qthreaddialog.result(); computeFailed = !qthreaddialog.result();
res = gen->Compute(myMesh, myMainShape);
if (res)
computeFailed = false;
} }
catch(const SALOME::SALOME_Exception & S_ex) { catch(const SALOME::SALOME_Exception & S_ex) {
memoryLack = true; memoryLack = true;
@ -904,26 +896,26 @@ void SMESHGUI_BaseComputeOp::computeMesh()
int entities = SMESH_Actor::eAllEntity; int entities = SMESH_Actor::eAllEntity;
if ( !memoryLack ) if ( !memoryLack )
{ {
if ( getSMESHGUI()->automaticUpdate( myMesh, &entities, &limitExceeded ) ) if ( getSMESHGUI()->automaticUpdate( myMesh, &entities, &limitExceeded ) )
{ {
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#endif #endif
SMESH_Actor *anActor = SMESH::FindActorByObject( myMesh ); SMESH_Actor *anActor = SMESH::FindActorByObject( myMesh );
if ( !anActor ) anActor = SMESH::CreateActor( aMeshSObj->GetStudy(), aMeshSObj->GetID().c_str(), true ); if ( !anActor ) anActor = SMESH::CreateActor( aMeshSObj->GetStudy(), aMeshSObj->GetID().c_str(), true );
anActor->SetEntityMode( entities ); anActor->SetEntityMode( entities );
SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor );
SMESH::Update(myIObject, true); SMESH::Update(myIObject, true);
if ( limitExceeded ) if ( limitExceeded )
{ {
SUIT_MessageBox::warning( desktop(), SUIT_MessageBox::warning( desktop(),
tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_WARNING" ),
tr( "SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ) ); tr( "SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ) );
} }
} }
catch (...) { catch (...) {
#ifdef _DEBUG_ #ifdef _DEBUG_
@ -937,7 +929,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
} }
} }
} }
else if ( limitExceeded ) else if ( limitExceeded )
{ {
SUIT_MessageBox::warning( desktop(), SUIT_MessageBox::warning( desktop(),
tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_WARNING" ),

View File

@ -49,6 +49,7 @@ class QPushButton;
class QTableWidget; class QTableWidget;
class QLabel; class QLabel;
class QtxComboBox; class QtxComboBox;
class QProgressBar;
class SMESHGUI_ComputeDlg; class SMESHGUI_ComputeDlg;
class SMESHGUI_MeshInfosBox; class SMESHGUI_MeshInfosBox;
class SMESHGUI_PrecomputeDlg; class SMESHGUI_PrecomputeDlg;
@ -318,6 +319,7 @@ private:
QLabel * nbNodesLabel; QLabel * nbNodesLabel;
QLabel * nbElemsLabel; QLabel * nbElemsLabel;
QLabel * freeRAMLabel; QLabel * freeRAMLabel;
QProgressBar* progressBar;
}; };
#endif // SMESHGUI_COMPUTEDLG_H #endif // SMESHGUI_COMPUTEDLG_H

View File

@ -4651,6 +4651,21 @@ Please, create VTK viewer and try again</translation>
<translation>Bad Mesh to Group</translation> <translation>Bad Mesh to Group</translation>
</message> </message>
</context> </context>
<context>
<name>SMESHGUI_ComputeDlg_QThreadQDialog</name>
<message>
<source>CANCEL</source>
<translation>Cancel</translation>
</message>
<message>
<source>CANCELING</source>
<translation>Canceling...</translation>
</message>
<message>
<source>TITLE</source>
<translation>Compute</translation>
</message>
</context>
<context> <context>
<name>SMESHGUI_PrecomputeDlg</name> <name>SMESHGUI_PrecomputeDlg</name>
<message> <message>

View File

@ -7484,4 +7484,19 @@ en raison de leurs types incompatibles:
<translation>Coef de réduction:</translation> <translation>Coef de réduction:</translation>
</message> </message>
</context> </context>
<context>
<name>SMESHGUI_ComputeDlg_QThreadQDialog</name>
<message>
<source>TITLE</source>
<translation type="unfinished">Compute</translation>
</message>
<message>
<source>CANCELING</source>
<translation type="unfinished">Canceling...</translation>
</message>
<message>
<source>CANCEL</source>
<translation type="unfinished">Cancel</translation>
</message>
</context>
</TS> </TS>