#include "SMESHGUI_MeshOrderOp.h"
#include "SMESHGUI_MeshOrderDlg.h"
+#include "SMESH_Actor.h"
#include "SMESH_ActorUtils.h"
#include <SMDS_SetIterator.hxx>
#include <SALOMEDSClient_SObject.hxx>
#include <SALOMEDS_wrap.hxx>
+#include CORBA_SERVER_HEADER(SMESH_Group)
+
// OCCT includes
#include <BRep_Tool.hxx>
#include <TopExp.hxx>
#include <QButtonGroup>
#include <QCloseEvent>
#include <QTimerEvent>
+#include <QProgressBar>
// VTK includes
#include <vtkProperty.h>
#include <vector>
#include <set>
+#ifndef WIN32
+#include <sys/sysinfo.h>
+#endif
+
#define SPACING 6
#define MARGIN 11
#define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
-/* OBSOLETE
-static void addSeparator( QWidget* parent )
-{
- QGridLayout* l = qobject_cast<QGridLayout*>( parent->layout() );
- int row = l->rowCount();
- int cols = l->columnCount();
- for ( int i = 0; i < cols; i++ ) {
- QFrame* hline = new QFrame( parent );
- hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
- l->addWidget( hline, row, i );
- }
-}
-*/
-
enum TCol {
COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
};
text = QObject::tr("COMPERR_ALGO_FAILED");
break;
case SMESH::COMPERR_WARNING:
- return comment ? QString(comment) : QObject::tr("COMPERR_UNKNOWN");
+ text = QObject::tr( (comment && strlen(comment)) ? "COMPERR_WARNING" : "COMPERR_UNKNOWN");
+ break;
default:
text = QString("#%1").arg( -errCode );
}
foreach( range, selRanges )
{
for ( int row = range.topRow(); row <= range.bottomRow(); ++row )
- rows.append( row );
+ if ( !rows.count( row ))
+ rows.append( row );
}
if ( rows.isEmpty() && table->currentRow() > -1 )
- rows.append( table->currentRow() );
+ if ( !rows.count( table->currentRow() ))
+ rows.append( table->currentRow() );
return rows.count();
}
myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup);
myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup);
myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup);
+ myBadMeshToGroupBtn = new QPushButton(tr("GROUP_OF_BAD_MESH"), myCompErrorGroup);
//myTable->setReadOnly( true ); // VSR: check
myTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
QGridLayout* grpLayout = new QGridLayout(myCompErrorGroup);
grpLayout->setSpacing(SPACING);
grpLayout->setMargin(MARGIN);
- grpLayout->addWidget( myWarningLabel, 0, 0, 1, 4 );
- grpLayout->addWidget( myTable, 1, 0, 1, 4 );
- grpLayout->addWidget( myShowBtn, 2, 0 );
- grpLayout->addWidget( myPublishBtn, 2, 1 );
- grpLayout->addWidget( myBadMeshBtn, 2, 2 );
+ grpLayout->addWidget( myWarningLabel, 0, 0, 1, 4 );
+ grpLayout->addWidget( myTable, 1, 0, 1, 4 );
+ grpLayout->addWidget( myShowBtn, 2, 0 );
+ grpLayout->addWidget( myPublishBtn, 2, 1 );
+ grpLayout->addWidget( myBadMeshBtn, 2, 2 );
+ grpLayout->addWidget( myBadMeshToGroupBtn, 2, 3 );
grpLayout->setColumnStretch( 3, 1 );
// Hypothesis definition errors
qthread(gen, mesh, mainShape)
{
// --
- setWindowTitle(tr("Compute"));
+ setWindowTitle(tr("TITLE"));
setMinimumWidth( 200 );
- cancelButton = new QPushButton(tr("Cancel"));
+ cancelButton = new QPushButton(tr("CANCEL"));
cancelButton->setDefault(true);
+ cancelButton->setCheckable(true);
QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this );
QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this );
+ QLabel * freeRAMName = new QLabel(tr("SMESH_FREERAM"), this );
nbNodesLabel = new QLabel("0", this );
nbElemsLabel = new QLabel("0", this );
+ freeRAMLabel = new QLabel("", this );
+ progressBar = new QProgressBar(this);
+ progressBar->setMinimum( 0 );
+ progressBar->setMaximum( 1000 );
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);
+ int row = 0;
+ layout->addWidget(nbNodesName, row, 0);
+ layout->addWidget(nbNodesLabel, row++, 1);
+ layout->addWidget(nbElemsName, row, 0);
+ layout->addWidget(nbElemsLabel, row++, 1);
+#ifndef WNT
+ layout->addWidget(freeRAMName, row, 0);
+ layout->addWidget(freeRAMLabel, row++, 1);
+#endif
+ layout->addWidget(progressBar, row++, 0, 1, 2);
+ layout->addWidget(cancelButton, row++, 0, 1, 2);
adjustSize();
update();
void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel()
{
qthread.cancel();
-}
+ cancelButton->setText( tr("CANCELING"));
+ cancelButton->setEnabled(false);
+}
void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event)
{
+ if ( !cancelButton->isChecked() ) // not yet cancelled
+ progressBar->setValue( progressBar->maximum() * qthread.getMesh()->GetComputeProgress() );
+
if(qthread.isFinished())
- {
- close();
- }
- nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() ));
- nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() ));
+ {
+ close();
+ }
+ else
+ {
+ nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() ));
+ nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() ));
+#ifndef WNT
+ struct sysinfo si;
+ const int err = sysinfo( &si );
+ if ( err )
+ freeRAMLabel->setText("");
+ else
+ freeRAMLabel->setText( tr("SMESH_GIGABYTE").arg
+ ( si.freeram * si.mem_unit /1024./1024./1024., 0, 'f', 2 ));
+#endif
+ }
event->accept();
}
void SMESHGUI_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event)
{
if(qthread.isRunning())
- {
+ {
event->ignore();
return;
}
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
- bool res;
SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape);
qthreaddialog.exec();
- res = qthreaddialog.result();
- res = gen->Compute(myMesh, myMainShape);
- if (res)
- computeFailed = false;
+ computeFailed = !qthreaddialog.result();
}
catch(const SALOME::SALOME_Exception & S_ex) {
memoryLack = true;
// SHOW MESH
// NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
- long newSize = myMesh->NbElements();
bool limitExceeded;
+ long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 );
+ int entities = SMESH_Actor::eAllEntity;
+ int hidden = 0;
if ( !memoryLack )
{
- if ( getSMESHGUI()->automaticUpdate( newSize, &limitExceeded ) )
+ if ( getSMESHGUI()->automaticUpdate( myMesh, &entities, &limitExceeded, &hidden ) )
{
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
+ SMESH_Actor *anActor = SMESH::FindActorByObject( myMesh );
+ if ( !anActor ) anActor = SMESH::CreateActor( aMeshSObj->GetStudy(), aMeshSObj->GetID().c_str(), true );
+ if ( anActor ) // actor is not created for an empty mesh
+ {
+ anActor->SetEntityMode( entities );
+ SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor );
+ }
SMESH::Update(myIObject, true);
+
+ if ( limitExceeded )
+ {
+ QStringList hiddenMsg;
+ if ( hidden & SMESH_Actor::e0DElements ) hiddenMsg << tr( "SMESH_ELEMS0D" );
+ if ( hidden & SMESH_Actor::eEdges ) hiddenMsg << tr( "SMESH_EDGES" );
+ if ( hidden & SMESH_Actor::eFaces ) hiddenMsg << tr( "SMESH_FACES" );
+ if ( hidden & SMESH_Actor::eVolumes ) hiddenMsg << tr( "SMESH_VOLUMES" );
+ if ( hidden & SMESH_Actor::eBallElem ) hiddenMsg << tr( "SMESH_BALLS" );
+ SUIT_MessageBox::warning( desktop(),
+ tr( "SMESH_WRN_WARNING" ),
+ tr( "SMESH_WRN_SIZE_INC_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ).arg( hiddenMsg.join(", ") ) );
+ }
}
catch (...) {
#ifdef _DEBUG_
}
else if ( limitExceeded )
{
- long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 );
SUIT_MessageBox::warning( desktop(),
tr( "SMESH_WRN_WARNING" ),
- tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( newSize ).arg( limitSize ) );
+ tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( myMesh->NbElements() ).arg( limitSize ) );
}
}
LightApp_SelectionMgr *Sel = selectionMgr();
tbl->resizeColumnToContents( COL_SHAPE );
tbl->setWordWrap( true );
- if ( hasBadMesh )
+ if ( hasBadMesh ) {
aCompDlg->myBadMeshBtn->show();
- else
+ aCompDlg->myBadMeshToGroupBtn->show();
+ }
+ else {
aCompDlg->myBadMeshBtn->hide();
-
+ aCompDlg->myBadMeshToGroupBtn->hide();
+ }
tbl->setCurrentCell(0,0);
currentCellChanged(); // to update buttons
}
}
}
+//================================================================================
+/*!
+ * \brief create groups of bad mesh elements preventing computation of a submesh of current row
+ */
+//================================================================================
+
+void SMESHGUI_BaseComputeOp::onGroupOfBadMesh()
+{
+ QList<int> rows;
+ SMESH::getSelectedRows( table(), rows );
+ int row;
+ foreach ( row, rows )
+ {
+ bool hasBadMesh = ( !table()->item(row, COL_BAD_MESH)->text().isEmpty() );
+ if ( hasBadMesh ) {
+ int curSub = table()->item(rows.front(), COL_SHAPEID)->text().toInt();
+ QString grName = table()->item(rows.front(), COL_SHAPE)->text();
+ if ( grName.isEmpty() ) grName = "bad mesh";
+ else grName = "bad mesh of " + grName;
+ SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
+ SMESH::ListOfGroups_var groups
+ ( gen->MakeGroupsOfBadInputElements(myMesh,curSub,grName.toLatin1().data()) );
+ update( UF_ObjBrowser | UF_Model );
+ if( LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( application() ))
+ {
+ QStringList anEntryList;
+ for ( size_t i = 0; i < groups->length(); ++i )
+ if ( _PTR(SObject) so = SMESH::FindSObject( groups[i] ))
+ anEntryList.append( so->GetID().c_str() );
+
+ if ( !anEntryList.isEmpty())
+ anApp->browseObjects( anEntryList, true, false );
+ }
+ }
+ }
+}
+
//================================================================================
/*!
* \brief SLOT called when a selected cell in table() changed
SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
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()));
- connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
+ connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
+ connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
+ connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
+ connect(myCompDlg->myBadMeshToGroupBtn, SIGNAL (clicked()), SLOT(onGroupOfBadMesh()));
QTableWidget* aTable = me->table();
connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));