[SALOME platform 0019316]: Need to have a better interface with GHS3D diagnostics

+  void onShowBadMesh();
This commit is contained in:
eap 2008-07-21 09:58:11 +00:00
parent 3ffc0ecded
commit 481dfe6e2e
2 changed files with 101 additions and 23 deletions

View File

@ -33,9 +33,11 @@
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_HypothesesUtils.h" #include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_MeshEditPreview.h"
#include "SMESH_ActorUtils.h"
#include "SMDS_SetIterator.hxx" #include "SMDS_SetIterator.hxx"
#include <SMDS_Mesh.hxx> #include "SMDS_Mesh.hxx"
#include "GEOMBase.h" #include "GEOMBase.h"
#include "GEOM_Actor.h" #include "GEOM_Actor.h"
@ -107,7 +109,9 @@
(new QFrame(father))->setFrameStyle(QFrame::HLine | QFrame::Sunken);\ (new QFrame(father))->setFrameStyle(QFrame::HLine | QFrame::Sunken);\
} }
enum TCol { COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, NB_COLUMNS }; enum TCol {
COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
};
using namespace SMESH; using namespace SMESH;
@ -125,7 +129,8 @@ namespace SMESH {
{ {
char* myBuf; char* myBuf;
MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M
~MemoryReserve() { delete [] myBuf; } void release() { delete [] myBuf; myBuf = 0; }
~MemoryReserve() { release(); }
}; };
// ========================================================================================= // =========================================================================================
@ -429,7 +434,7 @@ namespace SMESH {
/*! /*!
* \brief Return a list of selected rows * \brief Return a list of selected rows
*/ */
bool getSelectedRows(QTable* table, list< int > & rows) int getSelectedRows(QTable* table, list< int > & rows)
{ {
rows.clear(); rows.clear();
int nbSel = table->numSelections(); int nbSel = table->numSelections();
@ -443,7 +448,7 @@ namespace SMESH {
if (rows.empty() && table->currentRow() > -1 ) if (rows.empty() && table->currentRow() > -1 )
rows.push_back( table->currentRow() ); rows.push_back( table->currentRow() );
return !rows.empty(); return rows.size();
} }
} // namespace SMESH } // namespace SMESH
@ -699,10 +704,12 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent)
myTable = new QTable( 1, NB_COLUMNS, myCompErrorGroup, "myTable"); myTable = new QTable( 1, NB_COLUMNS, myCompErrorGroup, "myTable");
myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup, "myShowBtn"); myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup, "myShowBtn");
myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup, "myPublishBtn"); myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup, "myPublishBtn");
myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup, "myBadMeshBtn");
myTable->setReadOnly( TRUE ); myTable->setReadOnly( TRUE );
myTable->hideColumn( COL_PUBLISHED ); myTable->hideColumn( COL_PUBLISHED );
myTable->hideColumn( COL_SHAPEID ); myTable->hideColumn( COL_SHAPEID );
myTable->hideColumn( COL_BAD_MESH );
myTable->setColumnStretchable( COL_ERROR, 1 ); myTable->setColumnStretchable( COL_ERROR, 1 );
for ( int col = 0; col < NB_COLUMNS; ++col ) { for ( int col = 0; col < NB_COLUMNS; ++col ) {
QString header; QString header;
@ -723,10 +730,11 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent)
grpLayout->setAlignment(Qt::AlignTop); grpLayout->setAlignment(Qt::AlignTop);
grpLayout->setSpacing(SPACING); grpLayout->setSpacing(SPACING);
grpLayout->setMargin(MARGIN); grpLayout->setMargin(MARGIN);
grpLayout->addMultiCellWidget( myTable, 0, 2, 0, 0 ); grpLayout->addMultiCellWidget( myTable, 0, 3, 0, 0 );
grpLayout->addWidget ( myShowBtn, 0, 1 ); grpLayout->addWidget ( myShowBtn, 0, 1 );
grpLayout->addWidget ( myPublishBtn, 1, 1 ); grpLayout->addWidget ( myPublishBtn, 1, 1 );
grpLayout->setRowStretch( 2, 1 ); grpLayout->addWidget ( myBadMeshBtn, 2, 1 );
grpLayout->setRowStretch( 3, 1 );
// Hypothesis definition errors // Hypothesis definition errors
@ -767,12 +775,15 @@ SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
{ {
myDlg = new SMESHGUI_ComputeDlg; myDlg = new SMESHGUI_ComputeDlg;
myTShapeDisplayer = new TShapeDisplayer(); myTShapeDisplayer = new TShapeDisplayer();
myBadMeshDisplayer = 0;
//myHelpFileName = "/files/about_meshes.htm"; // V3 //myHelpFileName = "/files/about_meshes.htm"; // V3
myHelpFileName = "about_meshes_page.html"; // V4 myHelpFileName = "about_meshes_page.html"; // V4
// connect signals and slots // connect signals and slots
connect(myDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape())); connect(myDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
connect(myDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape())); connect(myDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
connect(myDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
connect(table(),SIGNAL(selectionChanged()), SLOT(currentCellChanged())); connect(table(),SIGNAL(selectionChanged()), SLOT(currentCellChanged()));
connect(table(),SIGNAL(currentChanged(int,int)), SLOT(currentCellChanged())); connect(table(),SIGNAL(currentChanged(int,int)), SLOT(currentCellChanged()));
} }
@ -788,7 +799,7 @@ void SMESHGUI_ComputeOp::startOperation()
// check selection // check selection
SMESH::SMESH_Mesh_var aMesh; myMesh = SMESH::SMESH_Mesh::_nil();
myMainShape = GEOM::GEOM_Object::_nil(); myMainShape = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr *Sel = selectionMgr(); LightApp_SelectionMgr *Sel = selectionMgr();
@ -805,8 +816,8 @@ void SMESHGUI_ComputeOp::startOperation()
} }
Handle(SALOME_InteractiveObject) IObject = selected.First(); Handle(SALOME_InteractiveObject) IObject = selected.First();
aMesh = SMESH::GetMeshByIO(IObject); myMesh = SMESH::GetMeshByIO(IObject);
if (aMesh->_is_nil()) { if (myMesh->_is_nil()) {
SUIT_MessageBox::warn1(desktop(), SUIT_MessageBox::warn1(desktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_NO_AVAILABLE_DATA"), tr("SMESH_WRN_NO_AVAILABLE_DATA"),
@ -824,15 +835,15 @@ void SMESHGUI_ComputeOp::startOperation()
bool computeFailed = true, memoryLack = false; bool computeFailed = true, memoryLack = false;
_PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh); _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
myMainShape = aMesh->GetShapeToMesh(); myMainShape = myMesh->GetShapeToMesh();
bool hasShape = aMesh->HasShapeToMesh(); bool hasShape = myMesh->HasShapeToMesh();
bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape; bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
if ( shapeOK && aMeshSObj ) if ( shapeOK && aMeshSObj )
{ {
myDlg->myMeshName->setText( aMeshSObj->GetName() ); myDlg->myMeshName->setText( aMeshSObj->GetName() );
SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen(); SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
SMESH::algo_error_array_var errors = gen->GetAlgoState(aMesh,myMainShape); SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
if ( errors->length() > 0 ) { if ( errors->length() > 0 ) {
aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() ); aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
} }
@ -841,7 +852,7 @@ void SMESHGUI_ComputeOp::startOperation()
#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
if (gen->Compute(aMesh, myMainShape)) if (gen->Compute(myMesh, myMainShape))
computeFailed = false; computeFailed = false;
} }
catch(const SALOME::SALOME_Exception & S_ex){ catch(const SALOME::SALOME_Exception & S_ex){
@ -851,7 +862,7 @@ void SMESHGUI_ComputeOp::startOperation()
#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
aCompErrors = gen->GetComputeErrors( aMesh, myMainShape ); aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
// check if there are memory problems // check if there are memory problems
for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i ) for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB ); memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
@ -862,7 +873,7 @@ void SMESHGUI_ComputeOp::startOperation()
// NPAL16631: if ( !memoryLack ) // NPAL16631: if ( !memoryLack )
{ {
SMESH::ModifiedMesh(aMeshSObj, !computeFailed, aMesh->NbNodes() == 0); SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
update( UF_ObjBrowser | UF_Model ); update( UF_ObjBrowser | UF_Model );
// SHOW MESH // SHOW MESH
@ -890,6 +901,10 @@ void SMESHGUI_ComputeOp::startOperation()
Sel->setSelectedObjects( selected ); Sel->setSelectedObjects( selected );
} }
} }
if ( memoryLack )
aMemoryReserve.release();
myDlg->setCaption(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED")); myDlg->setCaption(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
myDlg->myMemoryLackGroup->hide(); myDlg->myMemoryLackGroup->hide();
@ -908,7 +923,7 @@ void SMESHGUI_ComputeOp::startOperation()
} }
else if ( noCompError && noHypoError ) else if ( noCompError && noHypoError )
{ {
myDlg->myFullInfo->SetInfoByMesh( aMesh ); myDlg->myFullInfo->SetInfoByMesh( myMesh );
myDlg->myFullInfo->show(); myDlg->myFullInfo->show();
myDlg->myBriefInfo->hide(); myDlg->myBriefInfo->hide();
myDlg->myHypErrorGroup->hide(); myDlg->myHypErrorGroup->hide();
@ -917,7 +932,7 @@ void SMESHGUI_ComputeOp::startOperation()
else else
{ {
QTable* tbl = myDlg->myTable; QTable* tbl = myDlg->myTable;
myDlg->myBriefInfo->SetInfoByMesh( aMesh ); myDlg->myBriefInfo->SetInfoByMesh( myMesh );
myDlg->myBriefInfo->show(); myDlg->myBriefInfo->show();
myDlg->myFullInfo->hide(); myDlg->myFullInfo->hide();
@ -950,6 +965,7 @@ void SMESHGUI_ComputeOp::startOperation()
else tbl->showColumn( COL_SHAPE ); else tbl->showColumn( COL_SHAPE );
tbl->setColumnWidth( COL_ERROR, 200 ); tbl->setColumnWidth( COL_ERROR, 200 );
bool hasBadMesh = false;
for ( int row = 0; row < aCompErrors->length(); ++row ) for ( int row = 0; row < aCompErrors->length(); ++row )
{ {
SMESH::ComputeError & err = aCompErrors[ row ]; SMESH::ComputeError & err = aCompErrors[ row ];
@ -963,12 +979,21 @@ void SMESHGUI_ComputeOp::startOperation()
text = ( !hasShape || getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : ""; text = ( !hasShape || getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
tbl->setText( row, COL_PUBLISHED, text ); // if text=="", "PUBLISH" button enabled tbl->setText( row, COL_PUBLISHED, text ); // if text=="", "PUBLISH" button enabled
text = err.hasBadMesh ? "hasBadMesh" : "";
tbl->setText( row, COL_BAD_MESH, text );
if ( err.hasBadMesh ) hasBadMesh = true;
tbl->item( row, COL_ERROR )->setWordWrap( TRUE ); tbl->item( row, COL_ERROR )->setWordWrap( TRUE );
tbl->adjustRow( row ); tbl->adjustRow( row );
} }
tbl->adjustColumn( COL_ALGO ); tbl->adjustColumn( COL_ALGO );
tbl->adjustColumn( COL_SHAPE ); tbl->adjustColumn( COL_SHAPE );
if ( hasBadMesh )
myDlg->myBadMeshBtn->show();
else
myDlg->myBadMeshBtn->hide();
tbl->setCurrentCell(0,0); tbl->setCurrentCell(0,0);
currentCellChanged(); // to update buttons currentCellChanged(); // to update buttons
} }
@ -986,6 +1011,13 @@ void SMESHGUI_ComputeOp::stopOperation()
{ {
SMESHGUI_Operation::stopOperation(); SMESHGUI_Operation::stopOperation();
myTShapeDisplayer->SetVisibility( false ); myTShapeDisplayer->SetVisibility( false );
if ( myBadMeshDisplayer ) {
myBadMeshDisplayer->SetVisibility( false );
// delete it in order not to have problems at its destruction when the viewer
// where it worked is dead due to e.g. study closing
delete myBadMeshDisplayer;
myBadMeshDisplayer = 0;
}
} }
//================================================================================ //================================================================================
@ -1037,6 +1069,39 @@ void SMESHGUI_ComputeOp::onPublishShape()
currentCellChanged(); // to update buttons currentCellChanged(); // to update buttons
} }
//================================================================================
/*!
* \brief show mesh elements preventing computation of a submesh of current row
*/
//================================================================================
void SMESHGUI_ComputeOp::onShowBadMesh()
{
myTShapeDisplayer->SetVisibility( false );
list< int > rows;
if ( getSelectedRows( table(), rows ) == 1 ) {
bool hasBadMesh = ( !table()->text(rows.front(), COL_BAD_MESH).isEmpty() );
if ( hasBadMesh ) {
int curSub = table()->text(rows.front(), COL_SHAPEID).toInt();
SMESHGUI* gui = getSMESHGUI();
SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
SVTK_ViewWindow* view = GetViewWindow( gui );
if ( myBadMeshDisplayer ) delete myBadMeshDisplayer;
myBadMeshDisplayer = new SMESHGUI_MeshEditPreview( view );
SMESH::MeshPreviewStruct_var aMeshData = gen->GetBadInputElements(myMesh,curSub);
vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
// delete property !!!!!!!!!!
vtkProperty* prop = vtkProperty::New();
prop->SetLineWidth( aLineWidth * 3 );
prop->SetPointSize( aPointSize * 3 );
prop->SetColor( 250, 0, 250 );
myBadMeshDisplayer->GetActor()->SetProperty( prop );
myBadMeshDisplayer->SetData( aMeshData._retn() );
}
}
}
//================================================================================ //================================================================================
/*! /*!
* \brief SLOT called when a selected cell in table() changed * \brief SLOT called when a selected cell in table() changed
@ -1046,11 +1111,13 @@ void SMESHGUI_ComputeOp::onPublishShape()
void SMESHGUI_ComputeOp::currentCellChanged() void SMESHGUI_ComputeOp::currentCellChanged()
{ {
myTShapeDisplayer->SetVisibility( false ); myTShapeDisplayer->SetVisibility( false );
if ( myBadMeshDisplayer )
myBadMeshDisplayer->SetVisibility( false );
bool publishEnable = 0, showEnable = 0, showOnly = 1; bool publishEnable = 0, showEnable = 0, showOnly = 1, hasBadMesh = 0;
list< int > rows; list< int > rows;
list< int >::iterator row; list< int >::iterator row;
getSelectedRows( table(), rows ); int nbSelected = getSelectedRows( table(), rows );
for ( row = rows.begin(); row != rows.end(); ++row ) for ( row = rows.begin(); row != rows.end(); ++row )
{ {
bool hasData = ( !table()->text(*row, COL_SHAPE).isEmpty() ); bool hasData = ( !table()->text(*row, COL_SHAPE).isEmpty() );
@ -1067,9 +1134,13 @@ void SMESHGUI_ComputeOp::currentCellChanged()
else { else {
showEnable = true; showEnable = true;
} }
if ( !table()->text(*row, COL_BAD_MESH).isEmpty() )
hasBadMesh = true;
} }
myDlg->myPublishBtn->setEnabled( publishEnable ); myDlg->myPublishBtn->setEnabled( publishEnable );
myDlg->myShowBtn ->setEnabled( showEnable ); myDlg->myShowBtn ->setEnabled( showEnable );
myDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 ));
} }
//================================================================================ //================================================================================
@ -1108,7 +1179,9 @@ void SMESHGUI_ComputeOp::onPreviewShape()
SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp() SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp()
{ {
if ( myTShapeDisplayer ) delete myTShapeDisplayer; delete myTShapeDisplayer;
if ( myBadMeshDisplayer )
delete myBadMeshDisplayer;
} }
//================================================================================ //================================================================================

View File

@ -42,6 +42,7 @@ class QPushButton;
class QTable; class QTable;
class QLabel; class QLabel;
class SMESHGUI_ComputeDlg; class SMESHGUI_ComputeDlg;
class SMESHGUI_MeshEditPreview;
class GEOM_Actor; class GEOM_Actor;
namespace SMESH { namespace SMESH {
@ -73,6 +74,7 @@ private slots:
void onPreviewShape(); void onPreviewShape();
void onPublishShape(); void onPublishShape();
void onShowBadMesh();
void currentCellChanged(); void currentCellChanged();
private: private:
@ -81,8 +83,10 @@ private:
SMESHGUI_ComputeDlg* myDlg; SMESHGUI_ComputeDlg* myDlg;
SMESH::SMESH_Mesh_var myMesh;
GEOM::GEOM_Object_var myMainShape; GEOM::GEOM_Object_var myMainShape;
SMESH::TShapeDisplayer* myTShapeDisplayer; SMESH::TShapeDisplayer* myTShapeDisplayer;
SMESHGUI_MeshEditPreview* myBadMeshDisplayer;
}; };
/*! /*!
@ -137,6 +141,7 @@ private:
QTable* myTable; QTable* myTable;
QPushButton* myShowBtn; QPushButton* myShowBtn;
QPushButton* myPublishBtn; QPushButton* myPublishBtn;
QPushButton* myBadMeshBtn;
SMESHGUI_MeshInfosBox* myBriefInfo; SMESHGUI_MeshInfosBox* myBriefInfo;
SMESHGUI_MeshInfosBox* myFullInfo; SMESHGUI_MeshInfosBox* myFullInfo;