#include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_MeshInfosBox.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_MeshEditPreview.h"
#include "SMESH_ActorUtils.h"
} // namespace SMESH
-// =========================================================================================
-/*!
- * \brief Box showing mesh info
- */
-// =========================================================================================
-
-SMESHGUI_MeshInfosBox::SMESHGUI_MeshInfosBox(const bool full, QWidget* theParent)
- : QGroupBox( tr("SMESH_MESHINFO_TITLE"), theParent ), myFull( full )
-{
- QGridLayout* l = new QGridLayout(this);
- l->setMargin( MARGIN );
- l->setSpacing( SPACING );
-
- QFont italic = font(); italic.setItalic(true);
- QFont bold = font(); bold.setBold(true);
-
- QLabel* lab;
- int row = 0;
-
- // title
- lab = new QLabel( this );
- lab->setMinimumWidth(100); lab->setFont( italic );
- l->addWidget( lab, row, 0 );
- // --
- lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), this );
- lab->setMinimumWidth(100); lab->setFont( italic );
- l->addWidget( lab, row, 1 );
- // --
- lab = new QLabel(tr("SMESH_MESHINFO_ORDER1"), this );
- lab->setMinimumWidth(100); lab->setFont( italic );
- l->addWidget( lab, row, 2 );
- // --
- lab = new QLabel(tr("SMESH_MESHINFO_ORDER2"), this );
- lab->setMinimumWidth(100); lab->setFont( italic );
- l->addWidget( lab, row, 3 );
-
- if ( myFull )
- {
- // nodes
- row = l->rowCount(); // retrieve current row count
- // --
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
- lab->setFont( bold );
- l->addWidget( lab, row, 0 );
- // --
- myNbNode = new QLabel( this );
- l->addWidget( myNbNode, row, 1 );
-
- addSeparator(this); // add separator
-
- // edges
- row = l->rowCount(); // retrieve current row count
- // --
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
- lab->setFont( bold );
- l->addWidget( lab, row, 0 );
- // --
- myNbEdge = new QLabel( this );
- l->addWidget( myNbEdge, row, 1 );
- // --
- myNbLinEdge = new QLabel( this );
- l->addWidget( myNbLinEdge, row, 2 );
- // --
- myNbQuadEdge = new QLabel( this );
- l->addWidget( myNbQuadEdge, row, 3 );
-
- addSeparator(this); // add separator
-
- // faces
- row = l->rowCount(); // retrieve current row count
- // --
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
- lab->setFont( bold );
- l->addWidget( lab, row, 0 );
- // --
- myNbFace = new QLabel( this );
- l->addWidget( myNbFace, row, 1 );
- // --
- myNbLinFace = new QLabel( this );
- l->addWidget( myNbLinFace, row, 2 );
- // --
- myNbQuadFace = new QLabel( this );
- l->addWidget( myNbQuadFace, row, 3 );
- // --
- row++; // increment row count
- // ... triangles
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbTrai = new QLabel( this );
- l->addWidget( myNbTrai, row, 1 );
- // --
- myNbLinTrai = new QLabel( this );
- l->addWidget( myNbLinTrai, row, 2 );
- // --
- myNbQuadTrai = new QLabel( this );
- l->addWidget( myNbQuadTrai, row, 3 );
- // --
- row++; // increment row count
- // ... quadrangles
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbQuad = new QLabel( this );
- l->addWidget( myNbQuad, row, 1 );
- // --
- myNbLinQuad = new QLabel( this );
- l->addWidget( myNbLinQuad, row, 2 );
- // --
- myNbQuadQuad = new QLabel( this );
- l->addWidget( myNbQuadQuad, row, 3 );
- // --
- row++; // increment row count
- // ... poligones
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYGONES")), this );
- l->addWidget( lab, row, 0 );
- myNbPolyg = new QLabel( this );
- l->addWidget( myNbPolyg, row, 1 );
-
- addSeparator(this); // add separator
-
- // volumes
- row = l->rowCount(); // retrieve current row count
- // --
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
- lab->setFont( bold );
- l->addWidget( lab, row, 0 );
- // --
- myNbVolum = new QLabel( this );
- l->addWidget( myNbVolum, row, 1 );
- // --
- myNbLinVolum = new QLabel( this );
- l->addWidget( myNbLinVolum, row, 2 );
- // --
- myNbQuadVolum = new QLabel( this );
- l->addWidget( myNbQuadVolum, row, 3 );
- // --
- row++; // increment row count
- // ... tetras
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbTetra = new QLabel( this );
- l->addWidget( myNbTetra, row, 1 );
- // --
- myNbLinTetra = new QLabel( this );
- l->addWidget( myNbLinTetra, row, 2 );
- // --
- myNbQuadTetra = new QLabel( this );
- l->addWidget( myNbQuadTetra, row, 3 );
- // --
- row++; // increment row count
- // ... hexas
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbHexa = new QLabel( this );
- l->addWidget( myNbHexa, row, 1 );
- // --
- myNbLinHexa = new QLabel( this );
- l->addWidget( myNbLinHexa, row, 2 );
- // --
- myNbQuadHexa = new QLabel( this );
- l->addWidget( myNbQuadHexa, row, 3 );
- // --
- row++; // increment row count
- // ... pyras
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbPyra = new QLabel( this );
- l->addWidget( myNbPyra, row, 1 );
- // --
- myNbLinPyra = new QLabel( this );
- l->addWidget( myNbLinPyra, row, 2 );
- // --
- myNbQuadPyra = new QLabel( this );
- l->addWidget( myNbQuadPyra, row, 3 );
- // --
- row++; // increment row count
- // ... prisms
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbPrism = new QLabel( this );
- l->addWidget( myNbPrism, row, 1 );
- // --
- myNbLinPrism = new QLabel( this );
- l->addWidget( myNbLinPrism, row, 2 );
- // --
- myNbQuadPrism = new QLabel( this );
- l->addWidget( myNbQuadPrism, row, 3 );
- // --
- row++; // increment row count
- // ... polyedres
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbPolyh = new QLabel( this );
- l->addWidget( myNbPolyh, row, 1 );
- }
- else
- {
- // nodes
- row = l->rowCount(); // retrieve current row count
- // --
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbNode = new QLabel( this );
- l->addWidget( myNbNode, row, 1 );
-
- // edges
- row = l->rowCount(); // retrieve current row count
- // --
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
- l->addWidget( lab, row, 0 );
- // --
- myNbEdge = new QLabel( this );
- l->addWidget( myNbEdge, row, 1 );
- // --
- myNbLinEdge = new QLabel( this );
- l->addWidget( myNbLinEdge, row, 2 );
- // --
- myNbQuadEdge = new QLabel( this );
- l->addWidget( myNbQuadEdge, row, 3 );
-
- // faces
- row = l->rowCount(); // retrieve current row count
- // --
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
- l->addWidget( lab, row, 0 );
- // --
- myNbFace = new QLabel( this );
- l->addWidget( myNbFace, row, 1 );
- // --
- myNbLinFace = new QLabel( this );
- l->addWidget( myNbLinFace, row, 2 );
- // --
- myNbQuadFace = new QLabel( this );
- l->addWidget( myNbQuadFace, row, 3 );
-
- // volumes
- row = l->rowCount(); // retrieve current row count
- // --
- lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
- l->addWidget( lab, row, 0 );
- // --
- myNbVolum = new QLabel( this );
- l->addWidget( myNbVolum, row, 1 );
- // --
- myNbLinVolum = new QLabel( this );
- l->addWidget( myNbLinVolum, row, 2 );
- // --
- myNbQuadVolum = new QLabel( this );
- l->addWidget( myNbQuadVolum, row, 3 );
- }
-}
-
-// =========================================================================================
-/*!
- * \brief Set mesh info
- */
-// =========================================================================================
-
-void SMESHGUI_MeshInfosBox::SetInfoByMesh(SMESH::SMESH_Mesh_var mesh)
-{
- const SMESH::ElementOrder lin = SMESH::ORDER_LINEAR;
- int nbTot, nbLin;
-
- // nodes
- myNbNode ->setText( QString("%1").arg( mesh->NbNodes() ));
-
- // edges
- nbTot = mesh->NbEdges(), nbLin = mesh->NbEdgesOfOrder(lin);
- myNbEdge ->setText( QString("%1").arg( nbTot ));
- myNbLinEdge ->setText( QString("%1").arg( nbLin ));
- myNbQuadEdge ->setText( QString("%1").arg( nbTot - nbLin ));
-
- // faces
- nbTot = mesh->NbFaces(), nbLin = mesh->NbFacesOfOrder(lin);
- myNbFace ->setText( QString("%1").arg( nbTot ));
- myNbLinFace ->setText( QString("%1").arg( nbLin ));
- myNbQuadFace ->setText( QString("%1").arg( nbTot - nbLin ));
-
- // volumes
- nbTot = mesh->NbVolumes(), nbLin = mesh->NbVolumesOfOrder(lin);
- myNbVolum ->setText( QString("%1").arg( nbTot ));
- myNbLinVolum ->setText( QString("%1").arg( nbLin ));
- myNbQuadVolum->setText( QString("%1").arg( nbTot - nbLin ));
-
- if ( myFull )
- {
- // triangles
- nbTot = mesh->NbTriangles(), nbLin = mesh->NbTrianglesOfOrder(lin);
- myNbTrai ->setText( QString("%1").arg( nbTot ));
- myNbLinTrai ->setText( QString("%1").arg( nbLin ));
- myNbQuadTrai ->setText( QString("%1").arg( nbTot - nbLin ));
- // quadrangles
- nbTot = mesh->NbQuadrangles(), nbLin = mesh->NbQuadranglesOfOrder(lin);
- myNbQuad ->setText( QString("%1").arg( nbTot ));
- myNbLinQuad ->setText( QString("%1").arg( nbLin ));
- myNbQuadQuad ->setText( QString("%1").arg( nbTot - nbLin ));
- // poligones
- myNbPolyg ->setText( QString("%1").arg( mesh->NbPolygons() ));
-
- // tetras
- nbTot = mesh->NbTetras(), nbLin = mesh->NbTetrasOfOrder(lin);
- myNbTetra ->setText( QString("%1").arg( nbTot ));
- myNbLinTetra ->setText( QString("%1").arg( nbLin ));
- myNbQuadTetra->setText( QString("%1").arg( nbTot - nbLin ));
- // hexas
- nbTot = mesh->NbHexas(), nbLin = mesh->NbHexasOfOrder(lin);
- myNbHexa ->setText( QString("%1").arg( nbTot ));
- myNbLinHexa ->setText( QString("%1").arg( nbLin ));
- myNbQuadHexa ->setText( QString("%1").arg( nbTot - nbLin ));
- // pyras
- nbTot = mesh->NbPyramids(), nbLin = mesh->NbPyramidsOfOrder(lin);
- myNbPyra ->setText( QString("%1").arg( nbTot ));
- myNbLinPyra ->setText( QString("%1").arg( nbLin ));
- myNbQuadPyra ->setText( QString("%1").arg( nbTot - nbLin ));
- // prisms
- nbTot = mesh->NbPrisms(), nbLin = mesh->NbPrismsOfOrder(lin);
- myNbPrism ->setText( QString("%1").arg( nbTot ));
- myNbLinPrism ->setText( QString("%1").arg( nbLin ));
- myNbQuadPrism->setText( QString("%1").arg( nbTot - nbLin ));
- // polyedres
- myNbPolyh ->setText( QString("%1").arg( mesh->NbPolyhedrons() ));
- }
-}
-
// =========================================================================================
/*!
* \brief Dialog to compute a mesh and show computation errors
*/
//=======================================================================
-SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg( QWidget* parent )
+SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg( QWidget* parent, bool ForEval )
: SMESHGUI_Dialog( parent, false, true, Close/* | Help*/ )
{
QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
aDlgLay->setMargin( 0 );
aDlgLay->setSpacing( SPACING );
- QFrame* aMainFrame = createMainFrame (mainFrame());
+ QFrame* aMainFrame = createMainFrame(mainFrame(),ForEval);
aDlgLay->addWidget(aMainFrame);
// purpose : Create frame containing dialog's fields
//=======================================================================
-QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent)
+QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval)
{
QFrame* aFrame = new QFrame(theParent);
// constructor
- QGroupBox* aPixGrp = new QGroupBox(tr("CONSTRUCTOR"), aFrame);
+ QGroupBox* aPixGrp;
+ if(ForEval) {
+ aPixGrp = new QGroupBox(tr("EVAL_DLG"), aFrame);
+ }
+ else {
+ aPixGrp = new QGroupBox(tr("CONSTRUCTOR"), aFrame);
+ }
QButtonGroup* aBtnGrp = new QButtonGroup(this);
QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
aPixGrpLayout->setMargin(MARGIN); aPixGrpLayout->setSpacing(SPACING);
//================================================================================
SMESHGUI_BaseComputeOp::SMESHGUI_BaseComputeOp()
- : SMESHGUI_Operation(),
- myCompDlg( 0 )
+ : SMESHGUI_Operation(), myCompDlg( 0 )
{
myTShapeDisplayer = new SMESH::TShapeDisplayer();
myBadMeshDisplayer = 0;
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_NO_AVAILABLE_DATA"));
onCancel();
-
+ return;
}
myMainShape = myMesh->GetShapeToMesh();
bool computeFailed = true, memoryLack = false;
_PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
+ if ( !aMeshSObj ) // IPAL 21340
+ return;
bool hasShape = myMesh->HasShapeToMesh();
bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
- if ( shapeOK && aMeshSObj )
+ if ( shapeOK )
{
myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
}
else if ( theNoCompError && theNoHypoError )
{
- aCompDlg->myFullInfo->SetInfoByMesh( myMesh );
+ SMESH::long_array_var aRes = myMesh->GetMeshInfo();
+ aCompDlg->myFullInfo->SetMeshInfo( aRes );
aCompDlg->myFullInfo->show();
aCompDlg->myBriefInfo->hide();
aCompDlg->myHypErrorGroup->hide();
else
{
QTableWidget* tbl = aCompDlg->myTable;
- aCompDlg->myBriefInfo->SetInfoByMesh( myMesh );
+ SMESH::long_array_var aRes = myMesh->GetMeshInfo();
+ aCompDlg->myFullInfo->SetMeshInfo( aRes );
aCompDlg->myBriefInfo->show();
aCompDlg->myFullInfo->hide();
if ( !myCompDlg )
{
SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
- me->myCompDlg = new SMESHGUI_ComputeDlg( desktop() );
+ me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), false );
// connect signals and slots
connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
return myCompDlg;
}
+//================================================================================
+/*!
+ * \brief returns from compute mesh result dialog
+ */
+//================================================================================
+
+bool SMESHGUI_BaseComputeOp::onApply()
+{
+ return true;
+}
+
//================================================================================
/*!
* \brief Return a table
computeMesh();
}
-//================================================================================
-/*!
- * \brief perform it's intention action: compute mesh
- */
-//================================================================================
-
-bool SMESHGUI_ComputeOp::onApply()
-{
- return true;
-}
-
//================================================================================
/*!
* \brief Gets dialog of this operation
myActiveDlg( 0 ),
myPreviewDisplayer( 0 )
{
- myHelpFileName = "preview_meshes_page.html"; // V4
+ myHelpFileName = "constructing_meshes_page.html#preview_mesh_anchor";
}
//================================================================================
// 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;
SMESHGUI_BaseComputeOp::startOperation();
+ // 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 perform it's intention action: reinitialise dialog
+ * \brief reinitialize dialog after operaiton become active again
*/
//================================================================================
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 );
+ }
+
+ 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;
-
- _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
- if ( pMesh && pMesh->FindSubObject( aPart, aHypRoot ) )
+ if ( theMesh && theMesh->FindSubObject( aPart, aHypRoot ) )
{
_PTR(ChildIterator) anIter =
SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
if ( CORBA::is_nil( aVar ) )
continue;
-
- SMESH::SMESH_Algo_var algo = SMESH::SMESH_3D_Algo::_narrow( aVar );
- if ( !algo->_is_nil() )
+
+ for( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
{
- modeMap[ SMESH::DIM_1D ] = 0;
- modeMap[ SMESH::DIM_2D ] = 0;
- }
- else
- {
- algo = SMESH::SMESH_2D_Algo::_narrow( aVar );
+ 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() )
- modeMap[ SMESH::DIM_2D ] = 0;
+ theModeMap[ dim ] = 0;
}
}
}
}
- if ( modeMap.contains( SMESH::DIM_1D ) )
- modes.append( SMESH::DIM_1D );
- if ( modeMap.contains( SMESH::DIM_2D ) )
- modes.append( SMESH::DIM_2D );
-
- myDlg->setPreviewModes( modes );
}
//================================================================================
/*!
- * \brief perform it's intention action:
+ * \brief perform it's intention action: compute mesh
*/
//================================================================================
-bool SMESHGUI_PrecomputeOp::onApply()
+void SMESHGUI_PrecomputeOp::onCompute()
{
- QObject* obj = sender();
- if ( obj != myDlg && myActiveDlg == myDlg )
- return true; // just return from error messages
- if ( myActiveDlg == myDlg )
- {
- myDlg->hide();
- myMapShapeId.clear();
- myActiveDlg = computeDlg();
- computeMesh();
- }
-
- return true;
+ myDlg->hide();
+ myMapShapeId.clear();
+ myActiveDlg = computeDlg();
+ computeMesh();
}
//================================================================================
void SMESHGUI_PrecomputeOp::onCancel()
{
QObject* curDlg = sender();
- if ( curDlg == computeDlg() )
+ if ( curDlg == computeDlg() && myActiveDlg == myDlg )
{
- if ( myActiveDlg == myDlg ) // return from error messages
- myDlg->show();
-
+ // return from error messages
+ myDlg->show();
return;
}
{
return myPreviewMode->currentId();
}
+
+
+//================================================================================
+/*!
+ * \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();
+ 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);
+ bool hasShape = myMesh->HasShapeToMesh();
+ bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
+ if ( shapeOK && aMeshSObj )
+ {
+ 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 );
+
+ 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;
+}
+