-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SMESHGUI_ComputeDlg.cxx
// Author : Edward AGAPOV, Open CASCADE S.A.S.
// SMESH includes
#include "SMESHGUI_MeshInfosBox.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_MeshEditPreview.h"
+#include "SMESHGUI_MeshOrderOp.h"
+#include "SMESHGUI_MeshOrderDlg.h"
+
#include "SMESH_ActorUtils.h"
#include <SMDS_SetIterator.hxx>
// SALOME GEOM includes
#include <GEOMBase.h>
#include <GEOM_Actor.h>
+#include <GEOM_wrap.hxx>
// SALOME GUI includes
#include <LightApp_SelectionMgr.h>
// SALOME KERNEL includes
#include <SALOMEDS_SObject.hxx>
#include <SALOMEDSClient_SObject.hxx>
+#include <SALOMEDS_wrap.hxx>
// OCCT includes
#include <BRep_Tool.hxx>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QButtonGroup>
+#include <QCloseEvent>
+#include <QTimerEvent>
// VTK includes
#include <vtkProperty.h>
#define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
+/* OBSOLETE
static void addSeparator( QWidget* parent )
{
QGridLayout* l = qobject_cast<QGridLayout*>( parent->layout() );
l->addWidget( hline, row, i );
}
}
+*/
enum TCol {
COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
{
QString text;
switch ( errCode ) {
- CASE2TEXT( COMPERR_OK );
- CASE2TEXT( COMPERR_BAD_INPUT_MESH);
- CASE2TEXT( COMPERR_STD_EXCEPTION );
- CASE2TEXT( COMPERR_OCC_EXCEPTION );
+ CASE2TEXT( COMPERR_OK );
+ CASE2TEXT( COMPERR_BAD_INPUT_MESH );
+ CASE2TEXT( COMPERR_STD_EXCEPTION );
+ CASE2TEXT( COMPERR_OCC_EXCEPTION );
case SMESH::COMPERR_SLM_EXCEPTION: break; // avoid double "Salome exception"
- CASE2TEXT( COMPERR_EXCEPTION );
- CASE2TEXT( COMPERR_MEMORY_PB );
- CASE2TEXT( COMPERR_BAD_SHAPE );
+ CASE2TEXT( COMPERR_EXCEPTION );
+ CASE2TEXT( COMPERR_MEMORY_PB );
+ CASE2TEXT( COMPERR_BAD_SHAPE );
+ CASE2TEXT( COMPERR_CANCELED );
+ CASE2TEXT( COMPERR_NO_MESH_ON_SHAPE );
case SMESH::COMPERR_ALGO_FAILED:
if ( strlen(comment) == 0 )
text = QObject::tr("COMPERR_ALGO_FAILED");
break;
+ case SMESH::COMPERR_WARNING:
+ return comment ? QString(comment) : QObject::tr("COMPERR_UNKNOWN");
default:
text = QString("#%1").arg( -errCode );
}
}
// -----------------------------------------------------------------------
/*!
- * \brief Return SO of a subshape
+ * \brief Return SO of a sub-shape
*/
_PTR(SObject) getSubShapeSO( int subShapeID, GEOM::GEOM_Object_var aMainShape)
{
}
// -----------------------------------------------------------------------
/*!
- * \brief Return subshape by ID
+ * \brief Return sub-shape by ID. WARNING: UnRegister() must be called on a result
*/
GEOM::GEOM_Object_ptr getSubShape( int subShapeID, GEOM::GEOM_Object_var aMainShape)
{
GEOM::GEOM_Object_var aSubShape;
- if ( subShapeID == 1 )
+ if ( subShapeID == 1 ) {
aSubShape = aMainShape;
- else if ( _PTR(SObject) so = getSubShapeSO( subShapeID, aMainShape ))
+ aSubShape->Register();
+ }
+ else if ( _PTR(SObject) so = getSubShapeSO( subShapeID, aMainShape )) {
aSubShape = SMESH::SObjectToInterface<GEOM::GEOM_Object>( so );
- else
+ aSubShape->Register();
+ }
+ else {
aSubShape = SMESH::GetSubShape( aMainShape, subShapeID );
+ // future call of UnRegister() will delete a servant of this new object
+ }
return aSubShape._retn();
}
// -----------------------------------------------------------------------
}
// -----------------------------------------------------------------------
/*!
- * \brief Return text describing a subshape
+ * \brief Return text describing a sub-shape
*/
QString shapeText(int subShapeID, GEOM::GEOM_Object_var aMainShape )
{
text = aSO->GetName().c_str();
else {
text = QString("#%1").arg( subShapeID );
- QString typeName = shapeTypeName( getSubShape( subShapeID, aMainShape ));
+ GEOM::GEOM_Object_wrap shape = getSubShape( subShapeID, aMainShape );
+ QString typeName = shapeTypeName( shape );
if ( typeName.length() )
text += QString(" (%1)").arg(typeName);
}
// Computation errors
myCompErrorGroup = new QGroupBox(tr("ERRORS"), aFrame);
- myTable = new QTableWidget( 1, NB_COLUMNS, myCompErrorGroup);
- myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup);
- myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup);
- myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup);
+ myWarningLabel = new QLabel(QString("<b>%1</b>").arg(tr("COMPUTE_WARNING")), myCompErrorGroup);
+ myTable = new QTableWidget( 1, NB_COLUMNS, myCompErrorGroup);
+ myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup);
+ myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup);
+ myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup);
//myTable->setReadOnly( true ); // VSR: check
myTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
myTable->hideColumn( COL_SHAPEID );
myTable->hideColumn( COL_BAD_MESH );
myTable->horizontalHeader()->setResizeMode( COL_ERROR, QHeaderView::Interactive );
+ myTable->setWordWrap( true );
+ myTable->horizontalHeader()->setStretchLastSection( true );
+ myTable->setMinimumWidth( 500 );
QStringList headers;
headers << tr( "COL_ALGO_HEADER" );
QGridLayout* grpLayout = new QGridLayout(myCompErrorGroup);
grpLayout->setSpacing(SPACING);
grpLayout->setMargin(MARGIN);
- grpLayout->addWidget( myTable, 0, 0, 4, 1 );
- grpLayout->addWidget( myShowBtn, 0, 1 );
- grpLayout->addWidget( myPublishBtn, 1, 1 );
- grpLayout->addWidget( myBadMeshBtn, 2, 1 );
- grpLayout->setRowStretch( 3, 1 );
+ 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->setColumnStretch( 3, 1 );
// Hypothesis definition errors
myHelpFileName = "about_meshes_page.html"; // V4
}
+SMESH::SMESH_Mesh_ptr SMESHGUI_BaseComputeOp::getMesh()
+{
+ LightApp_SelectionMgr* Sel = selectionMgr();
+ SALOME_ListIO selected; Sel->selectedObjects( selected );
+ Handle(SALOME_InteractiveObject) anIO = selected.First();
+ SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
+ return myMesh->_is_nil() ? aMesh._retn() : SMESH::SMESH_Mesh::_duplicate( myMesh );
+}
+
//================================================================================
/*!
* \brief Start operation
SMESHGUI_Operation::startOperation();
}
+//================================================================================
+//================================================================================
+
+SMESHGUI_ComputeDlg_QThread::SMESHGUI_ComputeDlg_QThread(SMESH::SMESH_Gen_var gen,
+ SMESH::SMESH_Mesh_var mesh,
+ GEOM::GEOM_Object_var mainShape)
+{
+ myResult = false;
+ myGen = gen;
+ myMesh = mesh;
+ myMainShape = mainShape;
+}
+
+void SMESHGUI_ComputeDlg_QThread::run()
+{
+ myResult = myGen->Compute(myMesh, myMainShape);
+}
+
+bool SMESHGUI_ComputeDlg_QThread::result()
+{
+ return myResult;
+}
+
+void SMESHGUI_ComputeDlg_QThread::cancel()
+{
+ myGen->CancelCompute(myMesh, myMainShape);
+}
+
+//================================================================================
+//================================================================================
+
+SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget * parent,
+ SMESH::SMESH_Gen_var gen,
+ SMESH::SMESH_Mesh_var mesh,
+ GEOM::GEOM_Object_var mainShape)
+ : QDialog(parent,
+ Qt::WindowSystemMenuHint |
+ Qt::WindowCloseButtonHint |
+ Qt::Dialog |
+ Qt::WindowMaximizeButtonHint),
+ qthread(gen, mesh, mainShape)
+{
+ // --
+ setWindowTitle(tr("Compute"));
+ setMinimumWidth( 200 );
+
+ cancelButton = new QPushButton(tr("Cancel"));
+ cancelButton->setDefault(true);
+
+ QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this );
+ QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this );
+ nbNodesLabel = new QLabel("0", this );
+ nbElemsLabel = new QLabel("0", this );
+
+ 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);
+ adjustSize();
+ update();
+
+ connect(cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));
+ // --
+ startTimer(300); // millisecs
+ qthread.start();
+}
+
+bool SMESHGUI_ComputeDlg_QThreadQDialog::result()
+{
+ return qthread.result();
+}
+
+void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel()
+{
+ qthread.cancel();
+}
+
+void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event)
+{
+ if(qthread.isFinished())
+ {
+ close();
+ }
+ nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() ));
+ nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() ));
+ event->accept();
+}
+
+void SMESHGUI_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event)
+{
+ if(qthread.isRunning())
+ {
+ event->ignore();
+ return;
+ }
+ event->accept();
+}
+
//================================================================================
/*!
* \brief computeMesh()
if ( errors->length() > 0 ) {
aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
}
+ if ( myMesh->HasModificationsToDiscard() && // issue 0020693
+ SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
+ tr( "FULL_RECOMPUTE_QUESTION" ),
+ tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 1, 0 ) == 0 )
+ myMesh->Clear();
SUIT_OverrideCursor aWaitCursor;
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
- if (gen->Compute(myMesh, myMainShape))
+ //SMESH::UpdateNulData(myIObject, true);
+ bool res;
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+ SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape);
+ qthreaddialog.exec();
+ res = qthreaddialog.result();
+#else
+ res = gen->Compute(myMesh, myMainShape);
+#endif
+ if (res)
computeFailed = false;
}
catch(const SALOME::SALOME_Exception & S_ex){
memoryLack = true;
}
+ if ( !memoryLack && !SMDS_Mesh::CheckMemory(true) ) { // has memory to show dialog boxes?
+ memoryLack = true;
+ }
+
// NPAL16631: if ( !memoryLack )
{
SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
// SHOW MESH
// NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
- if ( !memoryLack && getSMESHGUI()->automaticUpdate() )
+ SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
+ long newSize = myMesh->NbElements();
+ bool limitExceeded;
+ if ( !memoryLack )
{
- try {
+ if ( getSMESHGUI()->automaticUpdate( newSize, &limitExceeded ) )
+ {
+ try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
+ OCC_CATCH_SIGNALS;
#endif
- SMESH::Update(myIObject, true);
- }
- catch (...) {
+ SMESH::Update(myIObject, true);
+ }
+ catch (...) {
#ifdef _DEBUG_
- MESSAGE ( "Exception thrown during mesh visualization" );
+ MESSAGE ( "Exception thrown during mesh visualization" );
#endif
- if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
- SMESH::OnVisuException();
- }
- else {
- memoryLack = true;
+ if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
+ SMESH::OnVisuException();
+ }
+ else {
+ memoryLack = true;
+ }
}
}
+ 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 ) );
+ }
}
LightApp_SelectionMgr *Sel = selectionMgr();
if ( Sel )
void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
const bool theNoCompError,
SMESH::compute_error_array_var& theCompErrors,
- const bool theNoHypoError,
+ const bool theNoHypoError,
const QString& theHypErrors )
{
bool hasShape = myMesh->HasShapeToMesh();
}
else
{
- QTableWidget* tbl = aCompDlg->myTable;
+ bool onlyWarnings = !theNoCompError; // == valid mesh computed but there are errors reported
+ for ( int i = 0; i < theCompErrors->length() && onlyWarnings; ++i )
+ onlyWarnings = ( theCompErrors[ i ].code == SMESH::COMPERR_WARNING ||
+ theCompErrors[ i ].code == SMESH::COMPERR_NO_MESH_ON_SHAPE );
+
+ // full or brief mesh info
SMESH::long_array_var aRes = myMesh->GetMeshInfo();
- aCompDlg->myFullInfo->SetMeshInfo( aRes );
- aCompDlg->myBriefInfo->show();
- aCompDlg->myFullInfo->hide();
+ if ( onlyWarnings ) {
+ aCompDlg->myFullInfo->SetMeshInfo( aRes );
+ aCompDlg->myFullInfo->show();
+ aCompDlg->myBriefInfo->hide();
+ } else {
+ aCompDlg->myBriefInfo->SetMeshInfo( aRes );
+ aCompDlg->myBriefInfo->show();
+ aCompDlg->myFullInfo->hide();
+ }
+ // pbs of hypo dfinitions
if ( theNoHypoError ) {
aCompDlg->myHypErrorGroup->hide();
- }
- else {
+ } else {
aCompDlg->myHypErrorGroup->show();
aCompDlg->myHypErrorLabel->setText( theHypErrors );
}
- if ( theNoCompError ) {
+ // table of errors
+ if ( theNoCompError )
+ {
aCompDlg->myCompErrorGroup->hide();
}
- else {
+ else
+ {
aCompDlg->myCompErrorGroup->show();
+ if ( onlyWarnings )
+ aCompDlg->myWarningLabel->show();
+ else
+ aCompDlg->myWarningLabel->hide();
+
if ( !hasShape ) {
aCompDlg->myPublishBtn->hide();
aCompDlg->myShowBtn->hide();
}
// fill table of errors
+ QTableWidget* tbl = aCompDlg->myTable;
tbl->setRowCount( theCompErrors->length() );
if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
else tbl->showColumn( COL_SHAPE );
}
tbl->resizeColumnToContents( COL_ALGO );
tbl->resizeColumnToContents( COL_SHAPE );
+ tbl->setWordWrap( true );
if ( hasBadMesh )
aCompDlg->myBadMeshBtn->show();
//================================================================================
/*!
- * \brief publish selected subshape
+ * \brief publish selected sub-shape
*/
//================================================================================
foreach ( row, rows )
{
int curSub = table()->item(row, COL_SHAPEID)->text().toInt();
- GEOM::GEOM_Object_var shape = SMESH::getSubShape( curSub, myMainShape );
+ GEOM::GEOM_Object_wrap shape = SMESH::getSubShape( curSub, myMainShape );
if ( !shape->_is_nil() && ! SMESH::getSubShapeSO( curSub, myMainShape ))
{
if ( !SMESH::getSubShapeSO( 1, myMainShape )) // the main shape not published
{
QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( myMainShape, "MAIN_SHAPE" ));
- SALOMEDS::SObject_var so =
+ SALOMEDS::SObject_wrap so =
geomGen->AddInStudy( study, myMainShape, name.toLatin1().data(), GEOM::GEOM_Object::_nil());
// look for myMainShape in the table
for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
if ( so->_is_nil() ) {
- table()->item( r, COL_SHAPE )->setText( so->GetName() );
- table()->item( r, COL_PUBLISHED )->setText( so->GetID() );
+ CORBA::String_var name = so->GetName();
+ CORBA::String_var entry = so->GetID();
+ table()->item( r, COL_SHAPE )->setText( name.in() );
+ table()->item( r, COL_PUBLISHED )->setText( entry.in() );
}
break;
}
if ( curSub == 1 ) continue;
}
QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( shape, "ERROR_SHAPE" ));
- SALOMEDS::SObject_var so = geomGen->AddInStudy( study, shape, name.toLatin1().data(), myMainShape);
+ SALOMEDS::SObject_wrap so = geomGen->AddInStudy( study, shape, name.toLatin1().data(), myMainShape);
if ( !so->_is_nil() ) {
- table()->item( row, COL_SHAPE )->setText( so->GetName() );
- table()->item( row, COL_PUBLISHED )->setText( so->GetID() );
+ CORBA::String_var name = so->GetName();
+ CORBA::String_var entry = so->GetID();
+ table()->item( row, COL_SHAPE )->setText( name.in() );
+ table()->item( row, COL_PUBLISHED )->setText( entry.in() );
}
}
}
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() );
+ prop->Delete();
}
}
}
computeMesh();
}
+//================================================================================
+/*!
+ * \brief check the same operations on the same mesh
+ */
+//================================================================================
+
+bool SMESHGUI_BaseComputeOp::isValid( SUIT_Operation* theOp ) const
+{
+ SMESHGUI_BaseComputeOp* baseOp = dynamic_cast<SMESHGUI_BaseComputeOp*>( theOp );
+ bool ret = true;
+ if ( !myMesh->_is_nil() && baseOp ) {
+ SMESH::SMESH_Mesh_var aMesh = baseOp->getMesh();
+ if ( !aMesh->_is_nil() && aMesh->GetId() == myMesh->GetId() ) ret = false;
+ }
+ return ret;
+}
+
//================================================================================
/*!
* \brief Gets dialog of this operation
SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp()
: SMESHGUI_BaseComputeOp(),
myDlg( 0 ),
+ myOrderMgr( 0 ),
myActiveDlg( 0 ),
myPreviewDisplayer( 0 )
{
{
delete myDlg;
myDlg = 0;
+ delete myOrderMgr;
+ myOrderMgr = 0;
myActiveDlg = 0;
if ( myPreviewDisplayer )
delete myPreviewDisplayer;
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() ) );
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 );
}
void SMESHGUI_PrecomputeOp::onCompute()
{
myDlg->hide();
+ if (myOrderMgr && myOrderMgr->IsOrderChanged())
+ myOrderMgr->SetMeshOrder();
myMapShapeId.clear();
myActiveDlg = computeDlg();
computeMesh();
return;
}
+ bool isRestoreOrder = false;
if ( myActiveDlg == myDlg && !myMesh->_is_nil() && myMapShapeId.count() )
{
// ask to remove already computed mesh elements
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();
}
_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::MeshPreviewStruct_var previewData =
gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId);
+
SMESH::MeshPreviewStruct* previewRes = previewData._retn();
if ( previewRes && previewRes->nodesXYZ.length() > 0 )
{
//================================================================================
SMESHGUI_PrecomputeDlg::SMESHGUI_PrecomputeDlg( QWidget* parent )
- : SMESHGUI_Dialog( parent, false, false, OK | Cancel | Help )
+ : SMESHGUI_Dialog( parent, false, false, OK | Cancel | Help ),
+ myOrderBox(0)
{
setWindowTitle( tr( "CAPTION" ) );
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 );
return myPreviewMode->currentId();
}
+//================================================================================
+/*!
+ * \brief Returns current preview mesh mode
+*/
+//================================================================================
+
+SMESHGUI_MeshOrderBox* SMESHGUI_PrecomputeDlg::getMeshOrderBox() const
+{
+ return myOrderBox;
+}
+
//================================================================================
/*!
}
tbl->resizeColumnToContents( COL_ALGO );
tbl->resizeColumnToContents( COL_SHAPE );
+ tbl->setWordWrap( true );
if ( hasBadMesh )
aCompDlg->myBadMeshBtn->show();