Salome HOME
Compute progress bar
authoreap <eap@opencascade.com>
Wed, 3 Jul 2013 16:01:42 +0000 (16:01 +0000)
committereap <eap@opencascade.com>
Wed, 3 Jul 2013 16:01:42 +0000 (16:01 +0000)
src/SMESHGUI/SMESHGUI_ComputeDlg.cxx
src/SMESHGUI/SMESHGUI_ComputeDlg.h
src/SMESHGUI/SMESH_msg_en.ts
src/SMESHGUI/SMESH_msg_fr.ts

index 4883f787383fe629ea0b7640411894d2bf8bf6d9..214dc244603a3e6ad1feb0d20334ffa6c0966d75 100644 (file)
@@ -92,6 +92,7 @@
 #include <QButtonGroup>
 #include <QCloseEvent>
 #include <QTimerEvent>
 #include <QButtonGroup>
 #include <QCloseEvent>
 #include <QTimerEvent>
+#include <QProgressBar>
 
 // VTK includes
 #include <vtkProperty.h>
 
 // VTK includes
 #include <vtkProperty.h>
 
 #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 {
   COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
 };
 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)
 {
   // --
     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);
 
   QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this );
   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 );
   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 );
 
   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(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();
 
   adjustSize();
   update();
 
@@ -788,10 +779,15 @@ bool SMESHGUI_ComputeDlg_QThreadQDialog::result()
 void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel()
 {
   qthread.cancel();
 void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel()
 {
   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())
   {
     close();
   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
 #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();
       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;
     }
     catch(const SALOME::SALOME_Exception & S_ex) {
       memoryLack = true;
@@ -904,26 +896,26 @@ void SMESHGUI_BaseComputeOp::computeMesh()
       int entities = SMESH_Actor::eAllEntity;
       if ( !memoryLack )
       {
       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
         {
           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_
           }
           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" ),
         {
           SUIT_MessageBox::warning( desktop(),
                                     tr( "SMESH_WRN_WARNING" ),
index e8101a311d5913cb3b27dfd352b1e78d0f03100e..d67709d3757c5e568067eb99b6038258ab95d94a 100644 (file)
@@ -49,6 +49,7 @@ class QPushButton;
 class QTableWidget;
 class QLabel;
 class QtxComboBox;
 class QTableWidget;
 class QLabel;
 class QtxComboBox;
+class QProgressBar;
 class SMESHGUI_ComputeDlg;
 class SMESHGUI_MeshInfosBox;
 class SMESHGUI_PrecomputeDlg;
 class SMESHGUI_ComputeDlg;
 class SMESHGUI_MeshInfosBox;
 class SMESHGUI_PrecomputeDlg;
@@ -318,6 +319,7 @@ private:
   QLabel *                    nbNodesLabel;
   QLabel *                    nbElemsLabel;
   QLabel *                    freeRAMLabel;
   QLabel *                    nbNodesLabel;
   QLabel *                    nbElemsLabel;
   QLabel *                    freeRAMLabel;
+  QProgressBar*               progressBar;
 };
 
 #endif // SMESHGUI_COMPUTEDLG_H
 };
 
 #endif // SMESHGUI_COMPUTEDLG_H
index e217a0183b87944aa7430ff66b31dd2d48b3ddff..6fd576050eaaf007441d1c08b79dec7b652bf8e0 100644 (file)
@@ -4651,6 +4651,21 @@ Please, create VTK viewer and try again</translation>
         <translation>Bad Mesh to Group</translation>
     </message>
 </context>
         <translation>Bad Mesh to Group</translation>
     </message>
 </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>
     <name>SMESHGUI_PrecomputeDlg</name>
     <message>
 <context>
     <name>SMESHGUI_PrecomputeDlg</name>
     <message>
index d7fb4f8fe8285521a694ebd597189ead59f62eb7..65e5bb7b576c9cb5c4228d36402de5abccb2f5ed 100755 (executable)
@@ -7484,4 +7484,19 @@ en raison de leurs types incompatibles:
         <translation>Coef de réduction:</translation>
     </message>
 </context>
         <translation>Coef de réduction:</translation>
     </message>
 </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>