+
+//================================================================================
+/*!
+ * \brief Gets dialog of this operation
+ * \retval LightApp_Dialog* - pointer to dialog of this operation
+ */
+//================================================================================
+
+LightApp_Dialog* SMESHGUI_ComputeOp::dlg() const
+{
+ return computeDlg();
+}
+
+//================================================================================
+/*!
+ * \brief Constructor
+*/
+//================================================================================
+
+SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp()
+ : SMESHGUI_BaseComputeOp(),
+ myDlg( 0 ),
+ myOrderMgr( 0 ),
+ myActiveDlg( 0 ),
+ myPreviewDisplayer( 0 )
+{
+ myHelpFileName = "constructing_meshes_page.html#preview_mesh_anchor";
+}
+
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+
+SMESHGUI_PrecomputeOp::~SMESHGUI_PrecomputeOp()
+{
+ delete myDlg;
+ myDlg = 0;
+ delete myOrderMgr;
+ myOrderMgr = 0;
+ myActiveDlg = 0;
+ if ( myPreviewDisplayer )
+ delete myPreviewDisplayer;
+ myPreviewDisplayer = 0;
+}
+
+//================================================================================
+/*!
+ * \brief Gets current dialog of this operation
+ * \retval LightApp_Dialog* - pointer to dialog of this operation
+ */
+//================================================================================
+
+LightApp_Dialog* SMESHGUI_PrecomputeOp::dlg() const
+{
+ return myActiveDlg;
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: prepare data
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::startOperation()
+{
+ if ( !myDlg )
+ {
+ myDlg = new SMESHGUI_PrecomputeDlg( desktop() );
+
+ // connect signals
+ connect( myDlg, SIGNAL( preview() ), this, SLOT( onPreview() ) );
+ connect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onCompute() ) );
+ connect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onCompute() ) );
+ }
+ myActiveDlg = myDlg;
+
+ // connect signal to compute dialog. which will be shown after Compute mesh operation
+ SMESHGUI_ComputeDlg* cmpDlg = computeDlg();
+ if ( cmpDlg )
+ {
+ // disconnect signals
+ disconnect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
+ disconnect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+ disconnect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
+ disconnect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
+ disconnect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
+
+ // connect signals
+ if( cmpDlg->testButtonFlags( QtxDialog::OK ) )
+ connect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
+ if( cmpDlg->testButtonFlags( QtxDialog::Apply ) )
+ connect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+ if( cmpDlg->testButtonFlags( QtxDialog::Help ) )
+ connect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
+ if( cmpDlg->testButtonFlags( QtxDialog::Cancel ) )
+ connect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
+ if( cmpDlg->testButtonFlags( QtxDialog::Close ) )
+ connect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
+ }
+
+ SMESHGUI_BaseComputeOp::startOperation();
+ if (myMesh->_is_nil())
+ return;
+
+ if (myDlg->getPreviewMode() == -1)
+ {
+ // nothing to preview
+ SUIT_MessageBox::warning(desktop(),
+ tr("SMESH_WRN_WARNING"),
+ tr("SMESH_WRN_NOTHING_PREVIEW"));
+ onCancel();
+ return;
+ }
+
+ // disconnect slot from preview dialog to have Apply from results of compute operation only
+ disconnect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
+ disconnect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+
+ myDlg->show();
+}
+
+//================================================================================
+/*!
+ * \brief Stops operation
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::stopOperation()
+{
+ if ( myPreviewDisplayer )
+ {
+ myPreviewDisplayer->SetVisibility( false );
+ delete myPreviewDisplayer;
+ myPreviewDisplayer = 0;
+ }
+ myMapShapeId.clear();
+ SMESHGUI_BaseComputeOp::stopOperation();
+}
+
+//================================================================================
+/*!
+ * \brief reinitialize dialog after operaiton become active again
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::resumeOperation()
+{
+ if ( myActiveDlg == myDlg )
+ initDialog();
+ SMESHGUI_BaseComputeOp::resumeOperation();
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: reinitialise dialog
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::initDialog()
+{
+ QList<int> modes;
+
+ QMap<int, int> modeMap;
+ _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
+ getAssignedAlgos( pMesh, modeMap );
+ if ( modeMap.contains( SMESH::DIM_3D ) )
+ {
+ if ( modeMap.contains( SMESH::DIM_2D ) )
+ modes.append( SMESH::DIM_2D );
+ if ( modeMap.contains( SMESH::DIM_1D ) )
+ modes.append( SMESH::DIM_1D );
+ }
+ else if ( modeMap.contains( SMESH::DIM_2D ) )
+ {
+ if ( modeMap.contains( SMESH::DIM_1D ) )
+ modes.append( SMESH::DIM_1D );
+ }
+
+ myOrderMgr = new SMESHGUI_MeshOrderMgr( myDlg->getMeshOrderBox() );
+ myOrderMgr->SetMesh( myMesh );
+ bool isOrder = myOrderMgr->GetMeshOrder(myPrevOrder);
+ myDlg->getMeshOrderBox()->setShown(isOrder);
+ if ( !isOrder ) {
+ delete myOrderMgr;
+ myOrderMgr = 0;
+ }
+
+ myDlg->setPreviewModes( modes );
+}
+
+//================================================================================
+/*!
+ * \brief detect asigned mesh algorithms
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh,
+ QMap<int,int>& theModeMap)
+{
+ _PTR(SObject) aHypRoot;
+ _PTR(GenericAttribute) anAttr;
+ int aPart = SMESH::Tag_RefOnAppliedAlgorithms;
+ if ( theMesh && theMesh->FindSubObject( aPart, aHypRoot ) )
+ {
+ _PTR(ChildIterator) anIter =
+ SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
+ for ( ; anIter->More(); anIter->Next() )
+ {
+ _PTR(SObject) anObj = anIter->Value();
+ _PTR(SObject) aRefObj;
+ if ( anObj->ReferencedObject( aRefObj ) )
+ anObj = aRefObj;
+ else
+ continue;
+
+ if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
+ {
+ CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
+ if ( CORBA::is_nil( aVar ) )
+ continue;
+
+ for( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
+ {
+ SMESH::SMESH_Algo_var algo;
+ switch(dim) {
+ case SMESH::DIM_1D: algo = SMESH::SMESH_1D_Algo::_narrow( aVar ); break;
+ case SMESH::DIM_2D: algo = SMESH::SMESH_2D_Algo::_narrow( aVar ); break;
+ case SMESH::DIM_3D: algo = SMESH::SMESH_3D_Algo::_narrow( aVar ); break;
+ default: break;
+ }
+ if ( !algo->_is_nil() )
+ theModeMap[ dim ] = 0;
+ }
+ }
+ }
+ }
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: compute mesh
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::onCompute()
+{
+ myDlg->hide();
+ if (myOrderMgr && myOrderMgr->IsOrderChanged())
+ myOrderMgr->SetMeshOrder();
+ myMapShapeId.clear();
+ myActiveDlg = computeDlg();
+ computeMesh();
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: compute mesh
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::onCancel()
+{
+ QObject* curDlg = sender();
+ if ( curDlg == computeDlg() && myActiveDlg == myDlg )
+ {
+ // return from error messages
+ myDlg->show();
+ return;
+ }
+
+ bool isRestoreOrder = false;
+ if ( myActiveDlg == myDlg && !myMesh->_is_nil() && myMapShapeId.count() )
+ {
+ // ask to remove already computed mesh elements
+ if ( SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
+ tr( "CLEAR_SUBMESH_QUESTION" ),
+ tr( "SMESH_BUT_DELETE" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0 )
+ {
+ // remove all submeshes for collected shapes
+ QMap<int,int>::const_iterator it = myMapShapeId.constBegin();
+ for ( ; it != myMapShapeId.constEnd(); ++it )
+ myMesh->ClearSubMesh( *it );
+ isRestoreOrder = true;
+ }
+ }
+
+ // return previous mesh order
+ if (myOrderMgr && myOrderMgr->IsOrderChanged()) {
+ if (!isRestoreOrder)
+ isRestoreOrder =
+ (SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
+ tr( "SMESH_REJECT_MESH_ORDER" ),
+ tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0);
+ if (isRestoreOrder)
+ myOrderMgr->SetMeshOrder(myPrevOrder);
+ }
+
+ delete myOrderMgr;
+ myOrderMgr = 0;
+
+ myMapShapeId.clear();
+ SMESHGUI_BaseComputeOp::onCancel();
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: preview mesh
+ */
+//================================================================================
+
+void SMESHGUI_PrecomputeOp::onPreview()
+{
+ if ( !myDlg || myMesh->_is_nil() || myMainShape->_is_nil() )
+ return;
+
+ _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
+ if ( !aMeshSObj )
+ return;
+
+ // set modified submesh priority if any
+ if (myOrderMgr && myOrderMgr->IsOrderChanged())
+ myOrderMgr->SetMeshOrder();
+
+ // Compute preview of mesh,
+ // i.e. compute mesh till indicated dimension
+ int dim = myDlg->getPreviewMode();
+
+ SMESH::MemoryReserve aMemoryReserve;
+
+ SMESH::compute_error_array_var aCompErrors;
+ QString aHypErrors;
+
+ bool computeFailed = true, memoryLack = false;
+
+ SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
+ aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
+
+ SMESHGUI* gui = getSMESHGUI();
+ SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
+ SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
+ if ( errors->length() > 0 ) {
+ aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
+ }
+
+ SUIT_OverrideCursor aWaitCursor;
+
+ SVTK_ViewWindow* view = SMESH::GetViewWindow( gui );
+ if ( myPreviewDisplayer ) delete myPreviewDisplayer;
+ myPreviewDisplayer = new SMESHGUI_MeshEditPreview( view );
+
+ SMESH::long_array_var aShapesId = new SMESH::long_array();
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+
+ SMESH::MeshPreviewStruct_var previewData =
+ gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId);
+
+ SMESH::MeshPreviewStruct* previewRes = previewData._retn();
+ if ( previewRes && previewRes->nodesXYZ.length() > 0 )
+ {
+ computeFailed = false;
+ myPreviewDisplayer->SetData( previewRes );
+ // append shape indeces with computed mesh entities
+ for ( int i = 0, n = aShapesId->length(); i < n; i++ )
+ myMapShapeId[ aShapesId[ i ] ] = 0;
+ }
+ else
+ myPreviewDisplayer->SetVisibility(false);
+ }
+ catch(const SALOME::SALOME_Exception & S_ex){
+ memoryLack = true;
+ myPreviewDisplayer->SetVisibility(false);
+ }
+
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
+ // check if there are memory problems
+ for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
+ memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
+ }
+ catch(const SALOME::SALOME_Exception & S_ex){
+ memoryLack = true;
+ }
+
+ if ( memoryLack )
+ aMemoryReserve.release();
+
+ bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
+ bool noHypoError = ( aHypErrors.isEmpty() );
+
+ SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( gui );
+ int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
+
+ bool isShowError = true;
+ switch( aNotifyMode ) {
+ case 0: // show the mesh computation result dialog NEVER
+ isShowError = false;
+ break;
+ case 1: // show the mesh computation result dialog if there are some errors
+ default: // show the result dialog after each mesh computation
+ if ( !computeFailed && !memoryLack && noCompError && noHypoError )
+ isShowError = false;
+ break;
+ }
+
+ aWaitCursor.suspend();
+ // SHOW ERRORS
+ if ( isShowError )
+ {
+ myDlg->hide();
+ aCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
+ showComputeResult( memoryLack, noCompError, aCompErrors, noHypoError, aHypErrors );
+ }
+}
+
+
+//================================================================================
+/*!
+ * \brief Constructor
+*/
+//================================================================================
+
+SMESHGUI_PrecomputeDlg::SMESHGUI_PrecomputeDlg( QWidget* parent )
+ : SMESHGUI_Dialog( parent, false, false, OK | Cancel | Help ),
+ myOrderBox(0)
+{
+ setWindowTitle( tr( "CAPTION" ) );
+
+ setButtonText( OK, tr( "COMPUTE" ) );
+ QFrame* main = mainFrame();
+
+ QVBoxLayout* layout = new QVBoxLayout( main );
+
+ myOrderBox = new SMESHGUI_MeshOrderBox( main );
+ layout->addWidget(myOrderBox);
+
+ QFrame* frame = new QFrame( main );
+ layout->setMargin(0); layout->setSpacing(0);
+ layout->addWidget( frame );
+
+ QHBoxLayout* frameLay = new QHBoxLayout( frame );
+ frameLay->setMargin(0); frameLay->setSpacing(SPACING);
+
+ myPreviewMode = new QtxComboBox( frame );
+ frameLay->addWidget( myPreviewMode );
+
+ myPreviewBtn = new QPushButton( tr( "PREVIEW" ), frame );
+ frameLay->addWidget( myPreviewBtn );
+
+ connect( myPreviewBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( preview() ) );
+}
+
+//================================================================================
+/*!
+ * \brief Destructor
+*/
+//================================================================================
+
+SMESHGUI_PrecomputeDlg::~SMESHGUI_PrecomputeDlg()
+{
+}
+
+//================================================================================
+/*!
+ * \brief Sets available preview modes
+*/
+//================================================================================
+
+void SMESHGUI_PrecomputeDlg::setPreviewModes( const QList<int>& theModes )
+{
+ myPreviewMode->clear();
+ QList<int>::const_iterator it = theModes.constBegin();
+ for ( int i = 0; it != theModes.constEnd(); ++it, i++ )
+ {
+ QString mode = QString( "PREVIEW_%1" ).arg( *it );
+ myPreviewMode->addItem( tr( mode.toLatin1().data() ) );
+ myPreviewMode->setId( i, *it );
+ }
+ myPreviewBtn->setEnabled( !theModes.isEmpty() );
+}
+
+//================================================================================
+/*!
+ * \brief Returns current preview mesh mode
+*/
+//================================================================================
+
+int SMESHGUI_PrecomputeDlg::getPreviewMode() const
+{
+ return myPreviewMode->currentId();
+}
+
+//================================================================================
+/*!
+ * \brief Returns current preview mesh mode
+*/
+//================================================================================
+
+SMESHGUI_MeshOrderBox* SMESHGUI_PrecomputeDlg::getMeshOrderBox() const
+{
+ return myOrderBox;
+}
+
+
+//================================================================================
+/*!
+ * \brief Constructor
+*/
+//================================================================================
+
+SMESHGUI_EvaluateOp::SMESHGUI_EvaluateOp()
+ : SMESHGUI_BaseComputeOp()
+{
+}
+
+
+//================================================================================
+/*!
+ * \brief Desctructor
+*/
+//================================================================================
+
+SMESHGUI_EvaluateOp::~SMESHGUI_EvaluateOp()
+{
+}
+
+//================================================================================
+/*!
+ * \brief perform it's intention action: compute mesh
+ */
+//================================================================================
+
+void SMESHGUI_EvaluateOp::startOperation()
+{
+ SMESHGUI_BaseComputeOp::evaluateDlg();
+ SMESHGUI_BaseComputeOp::startOperation();
+ if (myMesh->_is_nil())
+ return;
+ evaluateMesh();
+}
+
+//================================================================================
+/*!
+ * \brief Gets dialog of this operation
+ * \retval LightApp_Dialog* - pointer to dialog of this operation
+ */
+//================================================================================
+
+LightApp_Dialog* SMESHGUI_EvaluateOp::dlg() const
+{
+ return evaluateDlg();
+}
+
+//================================================================================
+/*!
+ * \brief evaluateMesh()
+*/
+//================================================================================
+
+void SMESHGUI_BaseComputeOp::evaluateMesh()
+{
+ // EVALUATE MESH
+
+ SMESH::MemoryReserve aMemoryReserve;
+
+ SMESH::compute_error_array_var aCompErrors;
+ QString aHypErrors;
+
+ bool evaluateFailed = true, memoryLack = false;
+ SMESH::long_array_var aRes;
+
+ _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
+ if ( !aMeshSObj ) // IPAL21340
+ return;
+
+ bool hasShape = myMesh->HasShapeToMesh();
+ bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
+ if ( shapeOK )
+ {
+ myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
+ SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
+ SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
+ if ( errors->length() > 0 ) {
+ aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
+ }
+ SUIT_OverrideCursor aWaitCursor;
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ aRes = gen->Evaluate(myMesh, myMainShape);
+ }
+ catch(const SALOME::SALOME_Exception & S_ex){
+ memoryLack = true;
+ }
+
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
+ }
+ catch(const SALOME::SALOME_Exception & S_ex){
+ memoryLack = true;
+ }
+ }
+
+ if ( memoryLack )
+ aMemoryReserve.release();
+
+ evaluateFailed = ( aCompErrors->length() > 0 );
+ myCompDlg->setWindowTitle(tr( evaluateFailed ? "SMESH_WRN_EVALUATE_FAILED" : "SMESH_EVALUATE_SUCCEED"));
+
+ // SHOW ERRORS
+
+ bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
+ bool noHypoError = ( aHypErrors.isEmpty() );
+
+ //SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
+ //int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
+
+ bool isShowResultDlg = true;
+ //if( noHypoError )
+ //switch( aNotifyMode ) {
+ //case 0: // show the mesh computation result dialog NEVER
+ //isShowResultDlg = false;
+ //commit();
+ //break;
+ //case 1: // show the mesh computation result dialog if there are some errors
+ //if ( memoryLack || !noHypoError )
+ // isShowResultDlg = true;
+ //else
+ //{
+ // isShowResultDlg = false;
+ // commit();
+ //}
+ //break;
+ //default: // show the result dialog after each mesh computation
+ //isShowResultDlg = true;
+ //}
+
+ // SHOW RESULTS
+ if ( isShowResultDlg )
+ showEvaluateResult( aRes, memoryLack, noCompError, aCompErrors,
+ noHypoError, aHypErrors);
+}
+
+
+void SMESHGUI_BaseComputeOp::showEvaluateResult(const SMESH::long_array& theRes,
+ const bool theMemoryLack,
+ const bool theNoCompError,
+ SMESH::compute_error_array_var& theCompErrors,
+ const bool theNoHypoError,
+ const QString& theHypErrors)
+{
+ bool hasShape = myMesh->HasShapeToMesh();
+ SMESHGUI_ComputeDlg* aCompDlg = evaluateDlg();
+ aCompDlg->myMemoryLackGroup->hide();
+
+ if ( theMemoryLack )
+ {
+ aCompDlg->myMemoryLackGroup->show();
+ aCompDlg->myFullInfo->hide();
+ aCompDlg->myBriefInfo->hide();
+ aCompDlg->myHypErrorGroup->hide();
+ aCompDlg->myCompErrorGroup->hide();
+ }
+ else if ( theNoCompError && theNoHypoError )
+ {
+ aCompDlg->myFullInfo->SetMeshInfo( theRes );
+ aCompDlg->myFullInfo->show();
+ aCompDlg->myBriefInfo->hide();
+ aCompDlg->myHypErrorGroup->hide();
+ aCompDlg->myCompErrorGroup->hide();
+ }
+ else
+ {
+ QTableWidget* tbl = aCompDlg->myTable;
+ aCompDlg->myBriefInfo->SetMeshInfo( theRes );
+ aCompDlg->myBriefInfo->show();
+ aCompDlg->myFullInfo->hide();
+
+ if ( theNoHypoError ) {
+ aCompDlg->myHypErrorGroup->hide();
+ }
+ else {
+ aCompDlg->myHypErrorGroup->show();
+ aCompDlg->myHypErrorLabel->setText( theHypErrors );
+ }
+
+ if ( theNoCompError ) {
+ aCompDlg->myCompErrorGroup->hide();
+ }
+ else {
+ aCompDlg->myCompErrorGroup->show();
+
+ aCompDlg->myPublishBtn->hide();
+ aCompDlg->myShowBtn->hide();
+
+ // fill table of errors
+ tbl->setRowCount( theCompErrors->length() );
+ if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
+ else tbl->showColumn( COL_SHAPE );
+ tbl->setColumnWidth( COL_ERROR, 200 );
+
+ bool hasBadMesh = false;
+ for ( int row = 0; row < theCompErrors->length(); ++row )
+ {
+ SMESH::ComputeError & err = theCompErrors[ row ];
+
+ QString text = err.algoName.in();
+ if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
+ else tbl->item( row, COL_ALGO )->setText( text );
+
+ text = SMESH::errorText( err.code, err.comment.in() );
+ if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
+ else tbl->item( row, COL_ERROR )->setText( text );
+
+ text = QString("%1").arg( err.subShapeID );
+ if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
+ else tbl->item( row, COL_SHAPEID )->setText( text );
+
+ text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
+ if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
+ else tbl->item( row, COL_SHAPE )->setText( text );
+
+ text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
+ if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
+ else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled
+
+ text = err.hasBadMesh ? "hasBadMesh" : "";
+ if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
+ else tbl->item( row, COL_BAD_MESH )->setText( text );
+ if ( err.hasBadMesh ) hasBadMesh = true;
+
+ //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
+ tbl->resizeRowToContents( row );
+ }
+ tbl->resizeColumnToContents( COL_ALGO );
+ tbl->resizeColumnToContents( COL_SHAPE );
+ tbl->setWordWrap( true );
+
+ if ( hasBadMesh )
+ aCompDlg->myBadMeshBtn->show();
+ else
+ aCompDlg->myBadMeshBtn->hide();
+
+ tbl->setCurrentCell(0,0);
+ currentCellChanged(); // to update buttons
+ }
+ }
+ // show dialog and wait, becase Compute can be invoked from Preview operation
+ //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
+ aCompDlg->show();
+}
+
+
+//================================================================================
+/*!
+ * \brief Gets dialog of evaluate operation
+ * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation
+ */
+//================================================================================
+
+SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::evaluateDlg() const
+{
+ if ( !myCompDlg )
+ {
+ SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
+ me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), true );
+ // connect signals and slots
+ connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
+ connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
+ connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
+ QTableWidget* aTable = me->table();
+ connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
+ connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));
+ }
+ return myCompDlg;
+}
+