mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-14 02:30:33 +05:00
[SALOME platform 0019316]: Need to have a better interface with GHS3D diagnostics
+ void onShowBadMesh();
This commit is contained in:
parent
3ffc0ecded
commit
481dfe6e2e
@ -33,9 +33,11 @@
|
||||
#include "SMESHGUI_Utils.h"
|
||||
#include "SMESHGUI_VTKUtils.h"
|
||||
#include "SMESHGUI_HypothesesUtils.h"
|
||||
#include "SMESHGUI_MeshEditPreview.h"
|
||||
#include "SMESH_ActorUtils.h"
|
||||
|
||||
#include "SMDS_SetIterator.hxx"
|
||||
#include <SMDS_Mesh.hxx>
|
||||
#include "SMDS_Mesh.hxx"
|
||||
|
||||
#include "GEOMBase.h"
|
||||
#include "GEOM_Actor.h"
|
||||
@ -107,7 +109,9 @@
|
||||
(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;
|
||||
|
||||
@ -125,7 +129,8 @@ namespace SMESH {
|
||||
{
|
||||
char* myBuf;
|
||||
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
|
||||
*/
|
||||
bool getSelectedRows(QTable* table, list< int > & rows)
|
||||
int getSelectedRows(QTable* table, list< int > & rows)
|
||||
{
|
||||
rows.clear();
|
||||
int nbSel = table->numSelections();
|
||||
@ -443,7 +448,7 @@ namespace SMESH {
|
||||
if (rows.empty() && table->currentRow() > -1 )
|
||||
rows.push_back( table->currentRow() );
|
||||
|
||||
return !rows.empty();
|
||||
return rows.size();
|
||||
}
|
||||
|
||||
} // namespace SMESH
|
||||
@ -699,10 +704,12 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent)
|
||||
myTable = new QTable( 1, NB_COLUMNS, myCompErrorGroup, "myTable");
|
||||
myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup, "myShowBtn");
|
||||
myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup, "myPublishBtn");
|
||||
myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup, "myBadMeshBtn");
|
||||
|
||||
myTable->setReadOnly( TRUE );
|
||||
myTable->hideColumn( COL_PUBLISHED );
|
||||
myTable->hideColumn( COL_SHAPEID );
|
||||
myTable->hideColumn( COL_BAD_MESH );
|
||||
myTable->setColumnStretchable( COL_ERROR, 1 );
|
||||
for ( int col = 0; col < NB_COLUMNS; ++col ) {
|
||||
QString header;
|
||||
@ -723,10 +730,11 @@ QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent)
|
||||
grpLayout->setAlignment(Qt::AlignTop);
|
||||
grpLayout->setSpacing(SPACING);
|
||||
grpLayout->setMargin(MARGIN);
|
||||
grpLayout->addMultiCellWidget( myTable, 0, 2, 0, 0 );
|
||||
grpLayout->addMultiCellWidget( myTable, 0, 3, 0, 0 );
|
||||
grpLayout->addWidget ( myShowBtn, 0, 1 );
|
||||
grpLayout->addWidget ( myPublishBtn, 1, 1 );
|
||||
grpLayout->setRowStretch( 2, 1 );
|
||||
grpLayout->addWidget ( myBadMeshBtn, 2, 1 );
|
||||
grpLayout->setRowStretch( 3, 1 );
|
||||
|
||||
// Hypothesis definition errors
|
||||
|
||||
@ -767,12 +775,15 @@ SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
|
||||
{
|
||||
myDlg = new SMESHGUI_ComputeDlg;
|
||||
myTShapeDisplayer = new TShapeDisplayer();
|
||||
myBadMeshDisplayer = 0;
|
||||
|
||||
//myHelpFileName = "/files/about_meshes.htm"; // V3
|
||||
myHelpFileName = "about_meshes_page.html"; // V4
|
||||
|
||||
// connect signals and slots
|
||||
connect(myDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
|
||||
connect(myDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
|
||||
connect(myDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
|
||||
connect(table(),SIGNAL(selectionChanged()), SLOT(currentCellChanged()));
|
||||
connect(table(),SIGNAL(currentChanged(int,int)), SLOT(currentCellChanged()));
|
||||
}
|
||||
@ -788,7 +799,7 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
|
||||
// check selection
|
||||
|
||||
SMESH::SMESH_Mesh_var aMesh;
|
||||
myMesh = SMESH::SMESH_Mesh::_nil();
|
||||
myMainShape = GEOM::GEOM_Object::_nil();
|
||||
|
||||
LightApp_SelectionMgr *Sel = selectionMgr();
|
||||
@ -805,8 +816,8 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
}
|
||||
|
||||
Handle(SALOME_InteractiveObject) IObject = selected.First();
|
||||
aMesh = SMESH::GetMeshByIO(IObject);
|
||||
if (aMesh->_is_nil()) {
|
||||
myMesh = SMESH::GetMeshByIO(IObject);
|
||||
if (myMesh->_is_nil()) {
|
||||
SUIT_MessageBox::warn1(desktop(),
|
||||
tr("SMESH_WRN_WARNING"),
|
||||
tr("SMESH_WRN_NO_AVAILABLE_DATA"),
|
||||
@ -824,15 +835,15 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
|
||||
bool computeFailed = true, memoryLack = false;
|
||||
|
||||
_PTR(SObject) aMeshSObj = SMESH::FindSObject(aMesh);
|
||||
myMainShape = aMesh->GetShapeToMesh();
|
||||
bool hasShape = aMesh->HasShapeToMesh();
|
||||
_PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
|
||||
myMainShape = myMesh->GetShapeToMesh();
|
||||
bool hasShape = myMesh->HasShapeToMesh();
|
||||
bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
|
||||
if ( shapeOK && aMeshSObj )
|
||||
{
|
||||
myDlg->myMeshName->setText( aMeshSObj->GetName() );
|
||||
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 ) {
|
||||
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
|
||||
OCC_CATCH_SIGNALS;
|
||||
#endif
|
||||
if (gen->Compute(aMesh, myMainShape))
|
||||
if (gen->Compute(myMesh, myMainShape))
|
||||
computeFailed = false;
|
||||
}
|
||||
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
|
||||
OCC_CATCH_SIGNALS;
|
||||
#endif
|
||||
aCompErrors = gen->GetComputeErrors( aMesh, myMainShape );
|
||||
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 );
|
||||
@ -862,7 +873,7 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
|
||||
// NPAL16631: if ( !memoryLack )
|
||||
{
|
||||
SMESH::ModifiedMesh(aMeshSObj, !computeFailed, aMesh->NbNodes() == 0);
|
||||
SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
|
||||
update( UF_ObjBrowser | UF_Model );
|
||||
|
||||
// SHOW MESH
|
||||
@ -890,6 +901,10 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
Sel->setSelectedObjects( selected );
|
||||
}
|
||||
}
|
||||
|
||||
if ( memoryLack )
|
||||
aMemoryReserve.release();
|
||||
|
||||
myDlg->setCaption(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
|
||||
myDlg->myMemoryLackGroup->hide();
|
||||
|
||||
@ -908,7 +923,7 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
}
|
||||
else if ( noCompError && noHypoError )
|
||||
{
|
||||
myDlg->myFullInfo->SetInfoByMesh( aMesh );
|
||||
myDlg->myFullInfo->SetInfoByMesh( myMesh );
|
||||
myDlg->myFullInfo->show();
|
||||
myDlg->myBriefInfo->hide();
|
||||
myDlg->myHypErrorGroup->hide();
|
||||
@ -917,7 +932,7 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
else
|
||||
{
|
||||
QTable* tbl = myDlg->myTable;
|
||||
myDlg->myBriefInfo->SetInfoByMesh( aMesh );
|
||||
myDlg->myBriefInfo->SetInfoByMesh( myMesh );
|
||||
myDlg->myBriefInfo->show();
|
||||
myDlg->myFullInfo->hide();
|
||||
|
||||
@ -950,6 +965,7 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
else tbl->showColumn( COL_SHAPE );
|
||||
tbl->setColumnWidth( COL_ERROR, 200 );
|
||||
|
||||
bool hasBadMesh = false;
|
||||
for ( int row = 0; row < aCompErrors->length(); ++row )
|
||||
{
|
||||
SMESH::ComputeError & err = aCompErrors[ row ];
|
||||
@ -963,12 +979,21 @@ void SMESHGUI_ComputeOp::startOperation()
|
||||
text = ( !hasShape || getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
|
||||
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->adjustRow( row );
|
||||
}
|
||||
tbl->adjustColumn( COL_ALGO );
|
||||
tbl->adjustColumn( COL_SHAPE );
|
||||
|
||||
if ( hasBadMesh )
|
||||
myDlg->myBadMeshBtn->show();
|
||||
else
|
||||
myDlg->myBadMeshBtn->hide();
|
||||
|
||||
tbl->setCurrentCell(0,0);
|
||||
currentCellChanged(); // to update buttons
|
||||
}
|
||||
@ -986,6 +1011,13 @@ void SMESHGUI_ComputeOp::stopOperation()
|
||||
{
|
||||
SMESHGUI_Operation::stopOperation();
|
||||
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
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \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
|
||||
@ -1046,11 +1111,13 @@ void SMESHGUI_ComputeOp::onPublishShape()
|
||||
void SMESHGUI_ComputeOp::currentCellChanged()
|
||||
{
|
||||
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 >::iterator row;
|
||||
getSelectedRows( table(), rows );
|
||||
int nbSelected = getSelectedRows( table(), rows );
|
||||
for ( row = rows.begin(); row != rows.end(); ++row )
|
||||
{
|
||||
bool hasData = ( !table()->text(*row, COL_SHAPE).isEmpty() );
|
||||
@ -1067,9 +1134,13 @@ void SMESHGUI_ComputeOp::currentCellChanged()
|
||||
else {
|
||||
showEnable = true;
|
||||
}
|
||||
|
||||
if ( !table()->text(*row, COL_BAD_MESH).isEmpty() )
|
||||
hasBadMesh = true;
|
||||
}
|
||||
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()
|
||||
{
|
||||
if ( myTShapeDisplayer ) delete myTShapeDisplayer;
|
||||
delete myTShapeDisplayer;
|
||||
if ( myBadMeshDisplayer )
|
||||
delete myBadMeshDisplayer;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
|
@ -42,6 +42,7 @@ class QPushButton;
|
||||
class QTable;
|
||||
class QLabel;
|
||||
class SMESHGUI_ComputeDlg;
|
||||
class SMESHGUI_MeshEditPreview;
|
||||
class GEOM_Actor;
|
||||
|
||||
namespace SMESH {
|
||||
@ -73,6 +74,7 @@ private slots:
|
||||
|
||||
void onPreviewShape();
|
||||
void onPublishShape();
|
||||
void onShowBadMesh();
|
||||
void currentCellChanged();
|
||||
|
||||
private:
|
||||
@ -81,8 +83,10 @@ private:
|
||||
|
||||
SMESHGUI_ComputeDlg* myDlg;
|
||||
|
||||
SMESH::SMESH_Mesh_var myMesh;
|
||||
GEOM::GEOM_Object_var myMainShape;
|
||||
SMESH::TShapeDisplayer* myTShapeDisplayer;
|
||||
SMESHGUI_MeshEditPreview* myBadMeshDisplayer;
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -137,6 +141,7 @@ private:
|
||||
QTable* myTable;
|
||||
QPushButton* myShowBtn;
|
||||
QPushButton* myPublishBtn;
|
||||
QPushButton* myBadMeshBtn;
|
||||
|
||||
SMESHGUI_MeshInfosBox* myBriefInfo;
|
||||
SMESHGUI_MeshInfosBox* myFullInfo;
|
||||
|
Loading…
Reference in New Issue
Block a user