+//================================================================================
+//================================================================================
+
+SMESHGUI_ComputeDlg_QThread::SMESHGUI_ComputeDlg_QThread(SMESH::SMESH_Gen_var gen,
+ SMESH::SMESH_Mesh_var mesh,
+ GEOM::GEOM_Object_var mainShape)
+{
+ myResult = false;
+ myGen = gen;
+ myMesh = mesh;
+ myMainShape = mainShape;
+}
+
+void SMESHGUI_ComputeDlg_QThread::run()
+{
+ myResult = myGen->Compute(myMesh, myMainShape);
+}
+
+bool SMESHGUI_ComputeDlg_QThread::result()
+{
+ return myResult;
+}
+
+void SMESHGUI_ComputeDlg_QThread::cancel()
+{
+ myGen->CancelCompute(myMesh, myMainShape);
+}
+
+//================================================================================
+//================================================================================
+
+SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget * parent,
+ SMESH::SMESH_Gen_var gen,
+ SMESH::SMESH_Mesh_var mesh,
+ GEOM::GEOM_Object_var mainShape)
+ : QDialog(parent,
+ Qt::WindowSystemMenuHint |
+ Qt::WindowCloseButtonHint |
+ Qt::Dialog |
+ Qt::WindowMaximizeButtonHint),
+ qthread(gen, mesh, mainShape)
+{
+ // --
+ setWindowTitle(tr("Compute"));
+ setMinimumWidth( 200 );
+
+ cancelButton = new QPushButton(tr("Cancel"));
+ cancelButton->setDefault(true);
+
+ QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this );
+ QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this );
+ nbNodesLabel = new QLabel("0", this );
+ nbElemsLabel = new QLabel("0", this );
+
+ QGridLayout* layout = new QGridLayout(this);
+ layout->setMargin( MARGIN );
+ layout->setSpacing( SPACING );
+ layout->addWidget(nbNodesName, 0, 0);
+ layout->addWidget(nbNodesLabel, 0, 1);
+ layout->addWidget(nbElemsName, 1, 0);
+ layout->addWidget(nbElemsLabel, 1, 1);
+ layout->addWidget(cancelButton, 2, 0, 1, 2);
+ adjustSize();
+ update();
+
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));
+ // --
+ startTimer(300); // millisecs
+ qthread.start();
+}
+
+bool SMESHGUI_ComputeDlg_QThreadQDialog::result()
+{
+ return qthread.result();
+}
+
+void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel()
+{
+ qthread.cancel();
+}
+
+void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event)
+{
+ if(qthread.isFinished())
+ {
+ close();
+ }
+ nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() ));
+ nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() ));
+ event->accept();
+}
+
+void SMESHGUI_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event)
+{
+ if(qthread.isRunning())
+ {
+ event->ignore();
+ return;
+ }
+ event->accept();
+}
+