1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SMESHGUI_ComputeDlg.cxx
21 // Author : Edward AGAPOV, Open CASCADE S.A.S.
24 #include "SMESHGUI_ComputeDlg.h"
27 #include "SMESHGUI_GEOMGenUtils.h"
28 #include "SMESHGUI_MeshUtils.h"
29 #include "SMESHGUI_VTKUtils.h"
30 #include "SMESHGUI_MeshInfosBox.h"
31 #include "SMESHGUI_HypothesesUtils.h"
32 #include "SMESHGUI_MeshEditPreview.h"
33 #include "SMESHGUI_MeshOrderOp.h"
34 #include "SMESHGUI_MeshOrderDlg.h"
36 #include "SMESH_ActorUtils.h"
38 #include <SMDS_SetIterator.hxx>
39 #include <SMDS_Mesh.hxx>
41 // SALOME GEOM includes
43 #include <GEOM_Actor.h>
44 #include <GEOM_wrap.hxx>
46 // SALOME GUI includes
47 #include <LightApp_SelectionMgr.h>
48 #include <LightApp_UpdateFlags.h>
49 #include <SALOME_ListIO.hxx>
50 #include <SVTK_ViewWindow.h>
51 #include <SVTK_ViewModel.h>
52 #include <SalomeApp_Application.h>
53 #include <SUIT_ResourceMgr.h>
54 #include <SUIT_OverrideCursor.h>
55 #include <SUIT_MessageBox.h>
56 #include <SUIT_Desktop.h>
57 #include <QtxComboBox.h>
59 // SALOME KERNEL includes
60 #include <SALOMEDS_SObject.hxx>
61 #include <SALOMEDSClient_SObject.hxx>
62 #include <SALOMEDS_wrap.hxx>
65 #include <BRep_Tool.hxx>
67 #include <TopExp_Explorer.hxx>
68 #include <TopTools_IndexedMapOfShape.hxx>
71 #include <TopLoc_Location.hxx>
72 #include <Poly_Triangulation.hxx>
73 #include <Bnd_Box.hxx>
74 #include <BRepBndLib.hxx>
75 #include <BRepMesh_IncrementalMesh.hxx>
77 #include <Standard_ErrorHandler.hxx>
81 #include <QPushButton>
83 #include <QRadioButton>
84 #include <QTableWidget>
85 #include <QHeaderView>
86 #include <QGridLayout>
87 #include <QHBoxLayout>
88 #include <QVBoxLayout>
89 #include <QButtonGroup>
90 #include <QCloseEvent>
91 #include <QTimerEvent>
94 #include <vtkProperty.h>
103 #define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
106 static void addSeparator( QWidget* parent )
108 QGridLayout* l = qobject_cast<QGridLayout*>( parent->layout() );
109 int row = l->rowCount();
110 int cols = l->columnCount();
111 for ( int i = 0; i < cols; i++ ) {
112 QFrame* hline = new QFrame( parent );
113 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
114 l->addWidget( hline, row, i );
120 COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
123 //using namespace SMESH;
127 //=============================================================================
129 * \brief Allocate some memory at construction and release it at destruction.
130 * Is used to be able to continue working after mesh generation or visualization
131 * break due to lack of memory
133 //=============================================================================
138 MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M
139 void release() { delete [] myBuf; myBuf = 0; }
140 ~MemoryReserve() { release(); }
143 // =========================================================================================
145 * \brief Class showing shapes without publishing
147 // =========================================================================================
149 class TShapeDisplayer
152 // -----------------------------------------------------------------------
153 TShapeDisplayer(): myViewWindow(0)
155 myProperty = vtkProperty::New();
156 myProperty->SetRepresentationToWireframe();
157 myProperty->SetColor( 250, 0, 250 );
158 myProperty->SetAmbientColor( 250, 0, 250 );
159 myProperty->SetDiffuseColor( 250, 0, 250 );
160 //myProperty->SetSpecularColor( 250, 0, 250 );
161 myProperty->SetLineWidth( 5 );
163 // -----------------------------------------------------------------------
167 myProperty->Delete();
169 // -----------------------------------------------------------------------
172 if ( hasViewWindow() ) {
173 TActorIterator actorIt = actorIterator();
174 while ( actorIt.more() )
175 if (VTKViewer_Actor* anActor = actorIt.next()) {
176 myViewWindow->RemoveActor( anActor );
180 myIndexToShape.Clear();
182 myShownActors.clear();
185 // -----------------------------------------------------------------------
186 void SetVisibility (bool theVisibility)
188 TActorIterator actorIt = shownIterator();
189 while ( actorIt.more() )
190 if (VTKViewer_Actor* anActor = actorIt.next())
191 anActor->SetVisibility(theVisibility);
192 SMESH::RepaintCurrentView();
194 // -----------------------------------------------------------------------
195 bool HasReadyActorsFor (int subShapeID, GEOM::GEOM_Object_var aMainShape )
197 std::string mainEntry;
198 if ( !aMainShape->_is_nil() )
199 mainEntry = aMainShape->GetStudyEntry();
200 return ( myMainEntry == mainEntry &&
201 myBuiltSubs.find( subShapeID ) != myBuiltSubs.end() );
203 // -----------------------------------------------------------------------
204 void Show( int subShapeID, GEOM::GEOM_Object_var aMainShape, bool only = false)
206 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() );
207 std::string mainEntry;
208 if ( !aMainShape->_is_nil() )
209 mainEntry = aMainShape->GetStudyEntry();
210 if ( myMainEntry != mainEntry || aViewWindow != myViewWindow ) { // remove actors
213 if ( !aMainShape->_is_nil() && GEOMBase::GetShape(aMainShape, aShape)) {
214 checkTriangulation( aShape );
215 TopExp::MapShapes(aShape, myIndexToShape);
216 myActors.resize( myIndexToShape.Extent(), 0 );
217 myShownActors.reserve( myIndexToShape.Extent() );
219 myMainEntry = mainEntry;
220 myViewWindow = aViewWindow;
222 if ( only ) { // hide shown actors
223 TActorIterator actorIt = shownIterator();
224 while ( actorIt.more() )
225 if (VTKViewer_Actor* anActor = actorIt.next())
226 anActor->SetVisibility(false);
227 myShownActors.clear();
229 // find actors to show
230 TopoDS_Shape aShape = myIndexToShape( subShapeID );
231 if ( !aShape.IsNull() ) {
232 TopAbs_ShapeEnum type( aShape.ShapeType() >= TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE );
233 for ( TopExp_Explorer exp( aShape, type ); exp.More(); exp.Next() ) {
234 //checkTriangulation( exp.Current() );
235 if ( GEOM_Actor* anActor = getActor( exp.Current() ))
236 myShownActors.push_back( anActor );
238 if ( type == TopAbs_FACE ) {
239 for ( TopExp_Explorer exp( aShape, TopAbs_EDGE ); exp.More(); exp.Next() ) {
240 const TopoDS_Edge & edge = TopoDS::Edge( exp.Current() );
241 if ( !BRep_Tool::Degenerated( edge ))
242 if ( GEOM_Actor* anActor = getActor( exp.Current() ))
243 myShownActors.push_back( anActor );
247 myBuiltSubs.insert( subShapeID );
250 // -----------------------------------------------------------------------
254 typedef std::vector<GEOM_Actor*> TActorVec;
256 TActorVec myShownActors;
257 TopTools_IndexedMapOfShape myIndexToShape;
258 std::string myMainEntry;
259 SVTK_ViewWindow* myViewWindow;
260 vtkProperty* myProperty;
261 std::set<int> myBuiltSubs;
263 // -----------------------------------------------------------------------
264 typedef SMDS_SetIterator< GEOM_Actor*, TActorVec::const_iterator> TActorIterator;
265 TActorIterator actorIterator() {
266 return TActorIterator( myActors.begin(), myActors.end() );
268 TActorIterator shownIterator() {
269 return TActorIterator( myShownActors.begin(), myShownActors.end() );
271 // -----------------------------------------------------------------------
272 GEOM_Actor* getActor(const TopoDS_Shape& shape)
274 int index = myIndexToShape.FindIndex( shape ) - 1;
275 if ( index < 0 || index >= myActors.size() )
277 GEOM_Actor* & actor = myActors[ index ];
279 actor = GEOM_Actor::New();
281 actor->SetShape(shape,0,0);
282 actor->SetProperty(myProperty);
283 actor->SetShadingProperty(myProperty);
284 actor->SetWireframeProperty(myProperty);
285 actor->SetPreviewProperty(myProperty);
286 actor->PickableOff();
287 // if ( shape.ShapeType() == TopAbs_EDGE )
288 // actor->SubShapeOn();
289 myViewWindow->AddActor( actor );
294 // -----------------------------------------------------------------------
295 void checkTriangulation(const TopoDS_Shape& shape)
297 TopLoc_Location aLoc;
298 Standard_Boolean alreadymesh = Standard_True;
299 TopExp_Explorer ex(shape, TopAbs_FACE);
301 for ( ; ex.More(); ex.Next()) {
302 const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
303 Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
304 if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
307 for (ex.Init(shape, TopAbs_EDGE); ex.More(); ex.Next()) {
308 const TopoDS_Edge& edge = TopoDS::Edge(ex.Current());
309 Handle(Poly_Polygon3D) aPoly = BRep_Tool::Polygon3D(edge, aLoc);
310 if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
312 if (alreadymesh) return;
313 // Compute default deflection
315 BRepBndLib::Add(shape, B);
316 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
317 B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
318 double deflection = Max( aXmax-aXmin, Max ( aYmax-aYmin, aZmax-aZmin)) * 0.01 *4;
319 BRepMesh_IncrementalMesh MESH(shape,deflection);
321 // -----------------------------------------------------------------------
322 bool hasViewWindow() const
324 if ( !myViewWindow ) return false;
326 if ( SalomeApp_Application* anApp = SMESHGUI::GetSMESHGUI()->getApp() )
327 return FindVtkViewWindow( anApp->getViewManager(SVTK_Viewer::Type(), false ),
333 // =========================================================================================
335 * \brief Return text describing an error
337 #define CASE2TEXT(enum) case SMESH::enum: text = QObject::tr( #enum ); break;
338 QString errorText(int errCode, const char* comment)
342 CASE2TEXT( COMPERR_OK );
343 CASE2TEXT( COMPERR_BAD_INPUT_MESH );
344 CASE2TEXT( COMPERR_STD_EXCEPTION );
345 CASE2TEXT( COMPERR_OCC_EXCEPTION );
346 case SMESH::COMPERR_SLM_EXCEPTION: break; // avoid double "Salome exception"
347 CASE2TEXT( COMPERR_EXCEPTION );
348 CASE2TEXT( COMPERR_MEMORY_PB );
349 CASE2TEXT( COMPERR_BAD_SHAPE );
350 CASE2TEXT( COMPERR_CANCELED );
351 CASE2TEXT( COMPERR_NO_MESH_ON_SHAPE );
352 case SMESH::COMPERR_ALGO_FAILED:
353 if ( strlen(comment) == 0 )
354 text = QObject::tr("COMPERR_ALGO_FAILED");
356 case SMESH::COMPERR_WARNING:
357 return comment ? QString(comment) : QObject::tr("COMPERR_UNKNOWN");
359 text = QString("#%1").arg( -errCode );
361 if ( text.length() > 0 ) text += ". ";
362 return text + comment;
364 // -----------------------------------------------------------------------
366 * \brief Return SO of a sub-shape
368 _PTR(SObject) getSubShapeSO( int subShapeID, GEOM::GEOM_Object_var aMainShape)
370 _PTR(SObject) so = SMESH::FindSObject(aMainShape);
371 if ( subShapeID == 1 || !so )
373 _PTR(ChildIterator) it;
374 if (_PTR(Study) study = SMESH::GetActiveStudyDocument())
375 it = study->NewChildIterator(so);
378 for ( it->InitEx(true); !subSO && it->More(); it->Next() ) {
379 GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( it->Value() );
380 if ( !geom->_is_nil() ) {
381 GEOM::ListOfLong_var list = geom->GetSubShapeIndices();
382 if ( list->length() == 1 && list[0] == subShapeID )
389 // -----------------------------------------------------------------------
391 * \brief Return sub-shape by ID. WARNING: UnRegister() must be called on a result
393 GEOM::GEOM_Object_ptr getSubShape( int subShapeID, GEOM::GEOM_Object_var aMainShape)
395 GEOM::GEOM_Object_var aSubShape;
396 if ( subShapeID == 1 ) {
397 aSubShape = aMainShape;
398 aSubShape->Register();
400 else if ( _PTR(SObject) so = getSubShapeSO( subShapeID, aMainShape )) {
401 aSubShape = SMESH::SObjectToInterface<GEOM::GEOM_Object>( so );
402 aSubShape->Register();
405 aSubShape = SMESH::GetSubShape( aMainShape, subShapeID );
406 // future call of UnRegister() will delete a servant of this new object
408 return aSubShape._retn();
410 // -----------------------------------------------------------------------
412 * \brief Return shape type name
414 #define CASE2NAME(enum) case GEOM::enum: name = QObject::tr( "GEOM_" #enum ); break;
415 QString shapeTypeName(GEOM::GEOM_Object_var aShape, const char* dflt = "" )
418 if ( !aShape->_is_nil() ) {
419 switch ( aShape->GetShapeType() ) {
426 CASE2NAME( COMPSOLID );
427 CASE2NAME( COMPOUND );
433 // -----------------------------------------------------------------------
435 * \brief Return text describing a sub-shape
437 QString shapeText(int subShapeID, GEOM::GEOM_Object_var aMainShape )
440 if ( _PTR(SObject) aSO = getSubShapeSO( subShapeID, aMainShape ))
441 text = aSO->GetName().c_str();
443 text = QString("#%1").arg( subShapeID );
444 GEOM::GEOM_Object_wrap shape = getSubShape( subShapeID, aMainShape );
445 QString typeName = shapeTypeName( shape );
446 if ( typeName.length() )
447 text += QString(" (%1)").arg(typeName);
451 // -----------------------------------------------------------------------
453 * \brief Return a list of selected rows
455 int getSelectedRows(QTableWidget* table, QList<int>& rows)
458 QList<QTableWidgetSelectionRange> selRanges = table->selectedRanges();
459 QTableWidgetSelectionRange range;
460 foreach( range, selRanges )
462 for ( int row = range.topRow(); row <= range.bottomRow(); ++row )
465 if ( rows.isEmpty() && table->currentRow() > -1 )
466 rows.append( table->currentRow() );
474 // =========================================================================================
476 * \brief Dialog to compute a mesh and show computation errors
478 //=======================================================================
480 SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg( QWidget* parent, bool ForEval )
481 : SMESHGUI_Dialog( parent, false, true, Close/* | Help*/ )
483 QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
484 aDlgLay->setMargin( 0 );
485 aDlgLay->setSpacing( SPACING );
487 QFrame* aMainFrame = createMainFrame(mainFrame(),ForEval);
489 aDlgLay->addWidget(aMainFrame);
491 aDlgLay->setStretchFactor(aMainFrame, 1);
494 // =========================================================================================
498 //=======================================================================
500 SMESHGUI_ComputeDlg::~SMESHGUI_ComputeDlg()
504 //=======================================================================
505 // function : createMainFrame()
506 // purpose : Create frame containing dialog's fields
507 //=======================================================================
509 QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval)
511 QFrame* aFrame = new QFrame(theParent);
513 SUIT_ResourceMgr* rm = resourceMgr();
514 QPixmap iconCompute (rm->loadPixmap("SMESH", tr("ICON_COMPUTE")));
520 aPixGrp = new QGroupBox(tr("EVAL_DLG"), aFrame);
523 aPixGrp = new QGroupBox(tr("CONSTRUCTOR"), aFrame);
525 QButtonGroup* aBtnGrp = new QButtonGroup(this);
526 QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
527 aPixGrpLayout->setMargin(MARGIN); aPixGrpLayout->setSpacing(SPACING);
529 QRadioButton* aRBut = new QRadioButton(aPixGrp);
530 aRBut->setIcon(iconCompute);
531 aRBut->setChecked(true);
532 aPixGrpLayout->addWidget(aRBut);
533 aBtnGrp->addButton(aRBut, 0);
537 QGroupBox* nameBox = new QGroupBox(tr("SMESH_MESHINFO_NAME"), aFrame );
538 QHBoxLayout* nameBoxLayout = new QHBoxLayout(nameBox);
539 nameBoxLayout->setMargin(MARGIN); nameBoxLayout->setSpacing(SPACING);
540 myMeshName = new QLabel(nameBox);
541 nameBoxLayout->addWidget(myMeshName);
545 myBriefInfo = new SMESHGUI_MeshInfosBox(false, aFrame);
546 myFullInfo = new SMESHGUI_MeshInfosBox(true, aFrame);
548 // Computation errors
550 myCompErrorGroup = new QGroupBox(tr("ERRORS"), aFrame);
551 myWarningLabel = new QLabel(QString("<b>%1</b>").arg(tr("COMPUTE_WARNING")), myCompErrorGroup);
552 myTable = new QTableWidget( 1, NB_COLUMNS, myCompErrorGroup);
553 myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup);
554 myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup);
555 myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup);
557 //myTable->setReadOnly( true ); // VSR: check
558 myTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
559 myTable->hideColumn( COL_PUBLISHED );
560 myTable->hideColumn( COL_SHAPEID );
561 myTable->hideColumn( COL_BAD_MESH );
562 myTable->horizontalHeader()->setResizeMode( COL_ERROR, QHeaderView::Interactive );
563 myTable->setWordWrap( true );
564 myTable->horizontalHeader()->setStretchLastSection( true );
565 myTable->setMinimumWidth( 500 );
568 headers << tr( "COL_ALGO_HEADER" );
569 headers << tr( "COL_SHAPE_HEADER" );
570 headers << tr( "COL_ERROR_HEADER" );
571 headers << tr( "COL_SHAPEID_HEADER" );
572 headers << tr( "COL_PUBLISHED_HEADER" );
574 myTable->setHorizontalHeaderLabels( headers );
577 QGridLayout* grpLayout = new QGridLayout(myCompErrorGroup);
578 grpLayout->setSpacing(SPACING);
579 grpLayout->setMargin(MARGIN);
580 grpLayout->addWidget( myWarningLabel, 0, 0, 1, 4 );
581 grpLayout->addWidget( myTable, 1, 0, 1, 4 );
582 grpLayout->addWidget( myShowBtn, 2, 0 );
583 grpLayout->addWidget( myPublishBtn, 2, 1 );
584 grpLayout->addWidget( myBadMeshBtn, 2, 2 );
585 grpLayout->setColumnStretch( 3, 1 );
587 // Hypothesis definition errors
589 myHypErrorGroup = new QGroupBox(tr("SMESH_WRN_MISSING_PARAMETERS"), aFrame);
590 QHBoxLayout* myHypErrorGroupLayout = new QHBoxLayout(myHypErrorGroup);
591 myHypErrorGroupLayout->setMargin(MARGIN);
592 myHypErrorGroupLayout->setSpacing(SPACING);
593 myHypErrorLabel = new QLabel(myHypErrorGroup);
594 myHypErrorGroupLayout->addWidget(myHypErrorLabel);
598 myMemoryLackGroup = new QGroupBox(tr("ERRORS"), aFrame);
599 QVBoxLayout* myMemoryLackGroupLayout = new QVBoxLayout(myMemoryLackGroup);
600 myMemoryLackGroupLayout->setMargin(MARGIN);
601 myMemoryLackGroupLayout->setSpacing(SPACING);
602 QLabel* memLackLabel = new QLabel(tr("MEMORY_LACK"), myMemoryLackGroup);
603 QFont bold = memLackLabel->font(); bold.setBold(true);
604 memLackLabel->setFont( bold );
605 memLackLabel->setMinimumWidth(300);
606 myMemoryLackGroupLayout->addWidget(memLackLabel);
608 // add all widgets to aFrame
609 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
610 aLay->setMargin( 0 );
611 aLay->setSpacing( 0 );
612 aLay->addWidget( aPixGrp );
613 aLay->addWidget( nameBox );
614 aLay->addWidget( myBriefInfo );
615 aLay->addWidget( myFullInfo );
616 aLay->addWidget( myHypErrorGroup );
617 aLay->addWidget( myCompErrorGroup );
618 aLay->addWidget( myMemoryLackGroup );
619 aLay->setStretchFactor( myCompErrorGroup, 1 );
621 ((QPushButton*) button( OK ))->setDefault( true );
626 //================================================================================
630 //================================================================================
632 SMESHGUI_BaseComputeOp::SMESHGUI_BaseComputeOp()
633 : SMESHGUI_Operation(), myCompDlg( 0 )
635 myTShapeDisplayer = new SMESH::TShapeDisplayer();
636 myBadMeshDisplayer = 0;
638 //myHelpFileName = "/files/about_meshes.htm"; // V3
639 myHelpFileName = "about_meshes_page.html"; // V4
642 SMESH::SMESH_Mesh_ptr SMESHGUI_BaseComputeOp::getMesh()
644 LightApp_SelectionMgr* Sel = selectionMgr();
645 SALOME_ListIO selected; Sel->selectedObjects( selected );
646 Handle(SALOME_InteractiveObject) anIO = selected.First();
647 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
648 return myMesh->_is_nil() ? aMesh._retn() : SMESH::SMESH_Mesh::_duplicate( myMesh );
651 //================================================================================
653 * \brief Start operation
654 * \purpose Init dialog fields, connect signals and slots, show dialog
656 //================================================================================
658 void SMESHGUI_BaseComputeOp::startOperation()
660 // create compute dialog if not created before
663 myMesh = SMESH::SMESH_Mesh::_nil();
664 myMainShape = GEOM::GEOM_Object::_nil();
667 LightApp_SelectionMgr *Sel = selectionMgr();
668 SALOME_ListIO selected; Sel->selectedObjects( selected );
670 int nbSel = selected.Extent();
672 SUIT_MessageBox::warning(desktop(),
673 tr("SMESH_WRN_WARNING"),
674 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
679 myIObject = selected.First();
680 myMesh = SMESH::GetMeshByIO(myIObject);
681 if (myMesh->_is_nil()) {
682 SUIT_MessageBox::warning(desktop(),
683 tr("SMESH_WRN_WARNING"),
684 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
688 myMainShape = myMesh->GetShapeToMesh();
690 SMESHGUI_Operation::startOperation();
693 //================================================================================
694 //================================================================================
696 SMESHGUI_ComputeDlg_QThread::SMESHGUI_ComputeDlg_QThread(SMESH::SMESH_Gen_var gen,
697 SMESH::SMESH_Mesh_var mesh,
698 GEOM::GEOM_Object_var mainShape)
703 myMainShape = mainShape;
706 void SMESHGUI_ComputeDlg_QThread::run()
708 myResult = myGen->Compute(myMesh, myMainShape);
711 bool SMESHGUI_ComputeDlg_QThread::result()
716 void SMESHGUI_ComputeDlg_QThread::cancel()
718 myGen->CancelCompute(myMesh, myMainShape);
721 //================================================================================
722 //================================================================================
724 SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget * parent,
725 SMESH::SMESH_Gen_var gen,
726 SMESH::SMESH_Mesh_var mesh,
727 GEOM::GEOM_Object_var mainShape)
729 Qt::WindowSystemMenuHint |
730 Qt::WindowCloseButtonHint |
732 Qt::WindowMaximizeButtonHint),
733 qthread(gen, mesh, mainShape)
736 setWindowTitle(tr("Compute"));
737 setMinimumWidth( 200 );
739 cancelButton = new QPushButton(tr("Cancel"));
740 cancelButton->setDefault(true);
742 QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this );
743 QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this );
744 nbNodesLabel = new QLabel("0", this );
745 nbElemsLabel = new QLabel("0", this );
747 QGridLayout* layout = new QGridLayout(this);
748 layout->setMargin( MARGIN );
749 layout->setSpacing( SPACING );
750 layout->addWidget(nbNodesName, 0, 0);
751 layout->addWidget(nbNodesLabel, 0, 1);
752 layout->addWidget(nbElemsName, 1, 0);
753 layout->addWidget(nbElemsLabel, 1, 1);
754 layout->addWidget(cancelButton, 2, 0, 1, 2);
758 connect(cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));
760 startTimer(300); // millisecs
764 bool SMESHGUI_ComputeDlg_QThreadQDialog::result()
766 return qthread.result();
769 void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel()
774 void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event)
776 if(qthread.isFinished())
780 nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() ));
781 nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() ));
785 void SMESHGUI_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event)
787 if(qthread.isRunning())
795 //================================================================================
797 * \brief computeMesh()
799 //================================================================================
801 void SMESHGUI_BaseComputeOp::computeMesh()
805 SMESH::MemoryReserve aMemoryReserve;
807 SMESH::compute_error_array_var aCompErrors;
810 bool computeFailed = true, memoryLack = false;
812 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
813 if ( !aMeshSObj ) // IPAL 21340
815 bool hasShape = myMesh->HasShapeToMesh();
816 bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
819 myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
820 SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
821 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
822 if ( errors->length() > 0 ) {
823 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
825 if ( myMesh->HasModificationsToDiscard() && // issue 0020693
826 SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
827 tr( "FULL_RECOMPUTE_QUESTION" ),
828 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 1, 0 ) == 0 )
830 SUIT_OverrideCursor aWaitCursor;
832 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
835 //SMESH::UpdateNulData(myIObject, true);
837 #ifdef WITH_SMESH_CANCEL_COMPUTE
838 SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape);
839 qthreaddialog.exec();
840 res = qthreaddialog.result();
842 res = gen->Compute(myMesh, myMainShape);
845 computeFailed = false;
847 catch(const SALOME::SALOME_Exception & S_ex){
851 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
854 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
855 // check if there are memory problems
856 for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
857 memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
859 catch(const SALOME::SALOME_Exception & S_ex){
863 if ( !memoryLack && !SMDS_Mesh::CheckMemory(true) ) { // has memory to show dialog boxes?
867 // NPAL16631: if ( !memoryLack )
869 SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
870 update( UF_ObjBrowser | UF_Model );
873 // NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
874 SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
875 long newSize = myMesh->NbElements();
879 if ( getSMESHGUI()->automaticUpdate( newSize, &limitExceeded ) )
882 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
885 SMESH::Update(myIObject, true);
889 MESSAGE ( "Exception thrown during mesh visualization" );
891 if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
892 SMESH::OnVisuException();
899 else if ( limitExceeded )
901 long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 );
902 SUIT_MessageBox::warning( desktop(),
903 tr( "SMESH_WRN_WARNING" ),
904 tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( newSize ).arg( limitSize ) );
907 LightApp_SelectionMgr *Sel = selectionMgr();
910 SALOME_ListIO selected;
911 selected.Append( myIObject );
912 Sel->setSelectedObjects( selected );
918 aMemoryReserve.release();
920 myCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
924 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
925 bool noHypoError = ( aHypErrors.isEmpty() );
927 SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
928 int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
930 bool isShowResultDlg = true;
931 switch( aNotifyMode ) {
932 case 0: // show the mesh computation result dialog NEVER
933 isShowResultDlg = false;
936 case 1: // show the mesh computation result dialog if there are some errors
937 if ( memoryLack || !noCompError || !noHypoError )
938 isShowResultDlg = true;
941 isShowResultDlg = false;
945 default: // show the result dialog after each mesh computation
946 isShowResultDlg = true;
950 if ( isShowResultDlg )
951 showComputeResult( memoryLack, noCompError,aCompErrors, noHypoError, aHypErrors );
954 void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
955 const bool theNoCompError,
956 SMESH::compute_error_array_var& theCompErrors,
957 const bool theNoHypoError,
958 const QString& theHypErrors )
960 bool hasShape = myMesh->HasShapeToMesh();
961 SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
962 aCompDlg->myMemoryLackGroup->hide();
966 aCompDlg->myMemoryLackGroup->show();
967 aCompDlg->myFullInfo->hide();
968 aCompDlg->myBriefInfo->hide();
969 aCompDlg->myHypErrorGroup->hide();
970 aCompDlg->myCompErrorGroup->hide();
972 else if ( theNoCompError && theNoHypoError )
974 SMESH::long_array_var aRes = myMesh->GetMeshInfo();
975 aCompDlg->myFullInfo->SetMeshInfo( aRes );
976 aCompDlg->myFullInfo->show();
977 aCompDlg->myBriefInfo->hide();
978 aCompDlg->myHypErrorGroup->hide();
979 aCompDlg->myCompErrorGroup->hide();
983 bool onlyWarnings = !theNoCompError; // == valid mesh computed but there are errors reported
984 for ( int i = 0; i < theCompErrors->length() && onlyWarnings; ++i )
985 onlyWarnings = ( theCompErrors[ i ].code == SMESH::COMPERR_WARNING ||
986 theCompErrors[ i ].code == SMESH::COMPERR_NO_MESH_ON_SHAPE );
988 // full or brief mesh info
989 SMESH::long_array_var aRes = myMesh->GetMeshInfo();
990 if ( onlyWarnings ) {
991 aCompDlg->myFullInfo->SetMeshInfo( aRes );
992 aCompDlg->myFullInfo->show();
993 aCompDlg->myBriefInfo->hide();
995 aCompDlg->myBriefInfo->SetMeshInfo( aRes );
996 aCompDlg->myBriefInfo->show();
997 aCompDlg->myFullInfo->hide();
1000 // pbs of hypo dfinitions
1001 if ( theNoHypoError ) {
1002 aCompDlg->myHypErrorGroup->hide();
1004 aCompDlg->myHypErrorGroup->show();
1005 aCompDlg->myHypErrorLabel->setText( theHypErrors );
1009 if ( theNoCompError )
1011 aCompDlg->myCompErrorGroup->hide();
1015 aCompDlg->myCompErrorGroup->show();
1018 aCompDlg->myWarningLabel->show();
1020 aCompDlg->myWarningLabel->hide();
1023 aCompDlg->myPublishBtn->hide();
1024 aCompDlg->myShowBtn->hide();
1027 aCompDlg->myPublishBtn->show();
1028 aCompDlg->myShowBtn->show();
1031 // fill table of errors
1032 QTableWidget* tbl = aCompDlg->myTable;
1033 tbl->setRowCount( theCompErrors->length() );
1034 if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
1035 else tbl->showColumn( COL_SHAPE );
1036 tbl->setColumnWidth( COL_ERROR, 200 );
1038 bool hasBadMesh = false;
1039 for ( int row = 0; row < theCompErrors->length(); ++row )
1041 SMESH::ComputeError & err = theCompErrors[ row ];
1043 QString text = err.algoName.in();
1044 if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
1045 else tbl->item( row, COL_ALGO )->setText( text );
1047 text = SMESH::errorText( err.code, err.comment.in() );
1048 if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
1049 else tbl->item( row, COL_ERROR )->setText( text );
1051 text = QString("%1").arg( err.subShapeID );
1052 if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
1053 else tbl->item( row, COL_SHAPEID )->setText( text );
1055 text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
1056 if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
1057 else tbl->item( row, COL_SHAPE )->setText( text );
1059 text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
1060 if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
1061 else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled
1063 text = err.hasBadMesh ? "hasBadMesh" : "";
1064 if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
1065 else tbl->item( row, COL_BAD_MESH )->setText( text );
1066 if ( err.hasBadMesh ) hasBadMesh = true;
1068 //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
1069 tbl->resizeRowToContents( row );
1071 tbl->resizeColumnToContents( COL_ALGO );
1072 tbl->resizeColumnToContents( COL_SHAPE );
1073 tbl->setWordWrap( true );
1076 aCompDlg->myBadMeshBtn->show();
1078 aCompDlg->myBadMeshBtn->hide();
1080 tbl->setCurrentCell(0,0);
1081 currentCellChanged(); // to update buttons
1084 // show dialog and wait, becase Compute can be invoked from Preview operation
1085 //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
1089 //================================================================================
1091 * \brief Stops operation
1093 //================================================================================
1095 void SMESHGUI_BaseComputeOp::stopOperation()
1097 SMESHGUI_Operation::stopOperation();
1098 if ( myTShapeDisplayer )
1099 myTShapeDisplayer->SetVisibility( false );
1100 if ( myBadMeshDisplayer ) {
1101 myBadMeshDisplayer->SetVisibility( false );
1102 // delete it in order not to have problems at its destruction when the viewer
1103 // where it worked is dead due to e.g. study closing
1104 delete myBadMeshDisplayer;
1105 myBadMeshDisplayer = 0;
1107 myIObject.Nullify();
1110 //================================================================================
1112 * \brief publish selected sub-shape
1114 //================================================================================
1116 void SMESHGUI_BaseComputeOp::onPublishShape()
1118 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
1119 SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
1122 SMESH::getSelectedRows( table(), rows );
1124 foreach ( row, rows )
1126 int curSub = table()->item(row, COL_SHAPEID)->text().toInt();
1127 GEOM::GEOM_Object_wrap shape = SMESH::getSubShape( curSub, myMainShape );
1128 if ( !shape->_is_nil() && ! SMESH::getSubShapeSO( curSub, myMainShape ))
1130 if ( !SMESH::getSubShapeSO( 1, myMainShape )) // the main shape not published
1132 QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( myMainShape, "MAIN_SHAPE" ));
1133 SALOMEDS::SObject_wrap so =
1134 geomGen->AddInStudy( study, myMainShape, name.toLatin1().data(), GEOM::GEOM_Object::_nil());
1135 // look for myMainShape in the table
1136 for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
1137 if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
1138 if ( so->_is_nil() ) {
1139 CORBA::String_var name = so->GetName();
1140 CORBA::String_var entry = so->GetID();
1141 table()->item( r, COL_SHAPE )->setText( name.in() );
1142 table()->item( r, COL_PUBLISHED )->setText( entry.in() );
1147 if ( curSub == 1 ) continue;
1149 QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( shape, "ERROR_SHAPE" ));
1150 SALOMEDS::SObject_wrap so = geomGen->AddInStudy( study, shape, name.toLatin1().data(), myMainShape);
1151 if ( !so->_is_nil() ) {
1152 CORBA::String_var name = so->GetName();
1153 CORBA::String_var entry = so->GetID();
1154 table()->item( row, COL_SHAPE )->setText( name.in() );
1155 table()->item( row, COL_PUBLISHED )->setText( entry.in() );
1159 getSMESHGUI()->getApp()->updateObjectBrowser();
1160 currentCellChanged(); // to update buttons
1163 //================================================================================
1165 * \brief show mesh elements preventing computation of a submesh of current row
1167 //================================================================================
1169 void SMESHGUI_BaseComputeOp::onShowBadMesh()
1171 myTShapeDisplayer->SetVisibility( false );
1173 if ( SMESH::getSelectedRows( table(), rows ) == 1 ) {
1174 bool hasBadMesh = ( !table()->item(rows.front(), COL_BAD_MESH)->text().isEmpty() );
1176 int curSub = table()->item(rows.front(), COL_SHAPEID)->text().toInt();
1177 SMESHGUI* gui = getSMESHGUI();
1178 SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
1179 SVTK_ViewWindow* view = SMESH::GetViewWindow( gui );
1180 if ( myBadMeshDisplayer ) delete myBadMeshDisplayer;
1181 myBadMeshDisplayer = new SMESHGUI_MeshEditPreview( view );
1182 SMESH::MeshPreviewStruct_var aMeshData = gen->GetBadInputElements(myMesh,curSub);
1183 vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
1184 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
1185 vtkProperty* prop = vtkProperty::New();
1186 prop->SetLineWidth( aLineWidth * 3 );
1187 prop->SetPointSize( aPointSize * 3 );
1188 prop->SetColor( 250, 0, 250 );
1189 myBadMeshDisplayer->GetActor()->SetProperty( prop );
1190 myBadMeshDisplayer->SetData( aMeshData._retn() );
1196 //================================================================================
1198 * \brief SLOT called when a selected cell in table() changed
1200 //================================================================================
1202 void SMESHGUI_BaseComputeOp::currentCellChanged()
1204 myTShapeDisplayer->SetVisibility( false );
1205 if ( myBadMeshDisplayer )
1206 myBadMeshDisplayer->SetVisibility( false );
1208 bool publishEnable = 0, showEnable = 0, showOnly = 1, hasBadMesh = 0;
1210 int nbSelected = SMESH::getSelectedRows( table(), rows );
1212 foreach ( row, rows )
1214 bool hasData = ( !table()->item( row, COL_SHAPE )->text().isEmpty() );
1215 bool isPublished = ( !table()->item( row, COL_PUBLISHED )->text().isEmpty() );
1216 if ( hasData && !isPublished )
1217 publishEnable = true;
1219 int curSub = table()->item( row, COL_SHAPEID )->text().toInt();
1220 bool prsReady = myTShapeDisplayer->HasReadyActorsFor( curSub, myMainShape );
1222 myTShapeDisplayer->Show( curSub, myMainShape, showOnly );
1229 if ( !table()->item(row, COL_BAD_MESH)->text().isEmpty() )
1232 myCompDlg->myPublishBtn->setEnabled( publishEnable );
1233 myCompDlg->myShowBtn ->setEnabled( showEnable );
1234 myCompDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 ));
1237 //================================================================================
1239 * \brief update preview
1241 //================================================================================
1243 void SMESHGUI_BaseComputeOp::onPreviewShape()
1245 if ( myTShapeDisplayer )
1247 SUIT_OverrideCursor aWaitCursor;
1249 SMESH::getSelectedRows( table(), rows );
1251 bool showOnly = true;
1253 foreach ( row, rows )
1255 int curSub = table()->item( row, COL_SHAPEID )->text().toInt();
1257 myTShapeDisplayer->Show( curSub, myMainShape, showOnly );
1261 currentCellChanged(); // to update buttons
1265 //================================================================================
1269 //================================================================================
1271 SMESHGUI_BaseComputeOp::~SMESHGUI_BaseComputeOp()
1275 delete myTShapeDisplayer;
1276 if ( myBadMeshDisplayer )
1277 delete myBadMeshDisplayer;
1280 //================================================================================
1282 * \brief Gets dialog of compute operation
1283 * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation
1285 //================================================================================
1287 SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::computeDlg() const
1291 SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
1292 me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), false );
1293 // connect signals and slots
1294 connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
1295 connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
1296 connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
1298 QTableWidget* aTable = me->table();
1299 connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
1300 connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));
1305 //================================================================================
1307 * \brief returns from compute mesh result dialog
1309 //================================================================================
1311 bool SMESHGUI_BaseComputeOp::onApply()
1316 //================================================================================
1318 * \brief Return a table
1320 //================================================================================
1322 QTableWidget* SMESHGUI_BaseComputeOp::table()
1324 return myCompDlg->myTable;
1328 //================================================================================
1330 * \brief Constructor
1332 //================================================================================
1334 SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
1335 : SMESHGUI_BaseComputeOp()
1340 //================================================================================
1342 * \brief Desctructor
1344 //================================================================================
1346 SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp()
1350 //================================================================================
1352 * \brief perform it's intention action: compute mesh
1354 //================================================================================
1356 void SMESHGUI_ComputeOp::startOperation()
1358 SMESHGUI_BaseComputeOp::startOperation();
1359 if (myMesh->_is_nil())
1364 //================================================================================
1366 * \brief check the same operations on the same mesh
1368 //================================================================================
1370 bool SMESHGUI_BaseComputeOp::isValid( SUIT_Operation* theOp ) const
1372 SMESHGUI_BaseComputeOp* baseOp = dynamic_cast<SMESHGUI_BaseComputeOp*>( theOp );
1374 if ( !myMesh->_is_nil() && baseOp ) {
1375 SMESH::SMESH_Mesh_var aMesh = baseOp->getMesh();
1376 if ( !aMesh->_is_nil() && aMesh->GetId() == myMesh->GetId() ) ret = false;
1381 //================================================================================
1383 * \brief Gets dialog of this operation
1384 * \retval LightApp_Dialog* - pointer to dialog of this operation
1386 //================================================================================
1388 LightApp_Dialog* SMESHGUI_ComputeOp::dlg() const
1390 return computeDlg();
1393 //================================================================================
1395 * \brief Constructor
1397 //================================================================================
1399 SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp()
1400 : SMESHGUI_BaseComputeOp(),
1404 myPreviewDisplayer( 0 )
1406 myHelpFileName = "constructing_meshes_page.html#preview_mesh_anchor";
1409 //================================================================================
1413 //================================================================================
1415 SMESHGUI_PrecomputeOp::~SMESHGUI_PrecomputeOp()
1422 if ( myPreviewDisplayer )
1423 delete myPreviewDisplayer;
1424 myPreviewDisplayer = 0;
1427 //================================================================================
1429 * \brief Gets current dialog of this operation
1430 * \retval LightApp_Dialog* - pointer to dialog of this operation
1432 //================================================================================
1434 LightApp_Dialog* SMESHGUI_PrecomputeOp::dlg() const
1439 //================================================================================
1441 * \brief perform it's intention action: prepare data
1443 //================================================================================
1445 void SMESHGUI_PrecomputeOp::startOperation()
1449 myDlg = new SMESHGUI_PrecomputeDlg( desktop() );
1452 connect( myDlg, SIGNAL( preview() ), this, SLOT( onPreview() ) );
1453 connect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onCompute() ) );
1454 connect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onCompute() ) );
1456 myActiveDlg = myDlg;
1458 // connect signal to compute dialog. which will be shown after Compute mesh operation
1459 SMESHGUI_ComputeDlg* cmpDlg = computeDlg();
1462 // disconnect signals
1463 disconnect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1464 disconnect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1465 disconnect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
1466 disconnect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
1467 disconnect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
1470 if( cmpDlg->testButtonFlags( QtxDialog::OK ) )
1471 connect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1472 if( cmpDlg->testButtonFlags( QtxDialog::Apply ) )
1473 connect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1474 if( cmpDlg->testButtonFlags( QtxDialog::Help ) )
1475 connect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
1476 if( cmpDlg->testButtonFlags( QtxDialog::Cancel ) )
1477 connect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
1478 if( cmpDlg->testButtonFlags( QtxDialog::Close ) )
1479 connect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
1482 SMESHGUI_BaseComputeOp::startOperation();
1483 if (myMesh->_is_nil())
1486 if (myDlg->getPreviewMode() == -1)
1488 // nothing to preview
1489 SUIT_MessageBox::warning(desktop(),
1490 tr("SMESH_WRN_WARNING"),
1491 tr("SMESH_WRN_NOTHING_PREVIEW"));
1496 // disconnect slot from preview dialog to have Apply from results of compute operation only
1497 disconnect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1498 disconnect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1503 //================================================================================
1505 * \brief Stops operation
1507 //================================================================================
1509 void SMESHGUI_PrecomputeOp::stopOperation()
1511 if ( myPreviewDisplayer )
1513 myPreviewDisplayer->SetVisibility( false );
1514 delete myPreviewDisplayer;
1515 myPreviewDisplayer = 0;
1517 myMapShapeId.clear();
1518 SMESHGUI_BaseComputeOp::stopOperation();
1521 //================================================================================
1523 * \brief reinitialize dialog after operaiton become active again
1525 //================================================================================
1527 void SMESHGUI_PrecomputeOp::resumeOperation()
1529 if ( myActiveDlg == myDlg )
1531 SMESHGUI_BaseComputeOp::resumeOperation();
1534 //================================================================================
1536 * \brief perform it's intention action: reinitialise dialog
1538 //================================================================================
1540 void SMESHGUI_PrecomputeOp::initDialog()
1544 QMap<int, int> modeMap;
1545 _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
1546 getAssignedAlgos( pMesh, modeMap );
1547 if ( modeMap.contains( SMESH::DIM_3D ) )
1549 if ( modeMap.contains( SMESH::DIM_2D ) )
1550 modes.append( SMESH::DIM_2D );
1551 if ( modeMap.contains( SMESH::DIM_1D ) )
1552 modes.append( SMESH::DIM_1D );
1554 else if ( modeMap.contains( SMESH::DIM_2D ) )
1556 if ( modeMap.contains( SMESH::DIM_1D ) )
1557 modes.append( SMESH::DIM_1D );
1560 myOrderMgr = new SMESHGUI_MeshOrderMgr( myDlg->getMeshOrderBox() );
1561 myOrderMgr->SetMesh( myMesh );
1562 bool isOrder = myOrderMgr->GetMeshOrder(myPrevOrder);
1563 myDlg->getMeshOrderBox()->setShown(isOrder);
1569 myDlg->setPreviewModes( modes );
1572 //================================================================================
1574 * \brief detect asigned mesh algorithms
1576 //================================================================================
1578 void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh,
1579 QMap<int,int>& theModeMap)
1581 _PTR(SObject) aHypRoot;
1582 _PTR(GenericAttribute) anAttr;
1583 int aPart = SMESH::Tag_RefOnAppliedAlgorithms;
1584 if ( theMesh && theMesh->FindSubObject( aPart, aHypRoot ) )
1586 _PTR(ChildIterator) anIter =
1587 SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
1588 for ( ; anIter->More(); anIter->Next() )
1590 _PTR(SObject) anObj = anIter->Value();
1591 _PTR(SObject) aRefObj;
1592 if ( anObj->ReferencedObject( aRefObj ) )
1597 if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
1599 CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
1600 if ( CORBA::is_nil( aVar ) )
1603 for( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
1605 SMESH::SMESH_Algo_var algo;
1607 case SMESH::DIM_1D: algo = SMESH::SMESH_1D_Algo::_narrow( aVar ); break;
1608 case SMESH::DIM_2D: algo = SMESH::SMESH_2D_Algo::_narrow( aVar ); break;
1609 case SMESH::DIM_3D: algo = SMESH::SMESH_3D_Algo::_narrow( aVar ); break;
1612 if ( !algo->_is_nil() )
1613 theModeMap[ dim ] = 0;
1620 //================================================================================
1622 * \brief perform it's intention action: compute mesh
1624 //================================================================================
1626 void SMESHGUI_PrecomputeOp::onCompute()
1629 if (myOrderMgr && myOrderMgr->IsOrderChanged())
1630 myOrderMgr->SetMeshOrder();
1631 myMapShapeId.clear();
1632 myActiveDlg = computeDlg();
1636 //================================================================================
1638 * \brief perform it's intention action: compute mesh
1640 //================================================================================
1642 void SMESHGUI_PrecomputeOp::onCancel()
1644 QObject* curDlg = sender();
1645 if ( curDlg == computeDlg() && myActiveDlg == myDlg )
1647 // return from error messages
1652 bool isRestoreOrder = false;
1653 if ( myActiveDlg == myDlg && !myMesh->_is_nil() && myMapShapeId.count() )
1655 // ask to remove already computed mesh elements
1656 if ( SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
1657 tr( "CLEAR_SUBMESH_QUESTION" ),
1658 tr( "SMESH_BUT_DELETE" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0 )
1660 // remove all submeshes for collected shapes
1661 QMap<int,int>::const_iterator it = myMapShapeId.constBegin();
1662 for ( ; it != myMapShapeId.constEnd(); ++it )
1663 myMesh->ClearSubMesh( *it );
1664 isRestoreOrder = true;
1668 // return previous mesh order
1669 if (myOrderMgr && myOrderMgr->IsOrderChanged()) {
1670 if (!isRestoreOrder)
1672 (SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
1673 tr( "SMESH_REJECT_MESH_ORDER" ),
1674 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0);
1676 myOrderMgr->SetMeshOrder(myPrevOrder);
1682 myMapShapeId.clear();
1683 SMESHGUI_BaseComputeOp::onCancel();
1686 //================================================================================
1688 * \brief perform it's intention action: preview mesh
1690 //================================================================================
1692 void SMESHGUI_PrecomputeOp::onPreview()
1694 if ( !myDlg || myMesh->_is_nil() || myMainShape->_is_nil() )
1697 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
1701 // set modified submesh priority if any
1702 if (myOrderMgr && myOrderMgr->IsOrderChanged())
1703 myOrderMgr->SetMeshOrder();
1705 // Compute preview of mesh,
1706 // i.e. compute mesh till indicated dimension
1707 int dim = myDlg->getPreviewMode();
1709 SMESH::MemoryReserve aMemoryReserve;
1711 SMESH::compute_error_array_var aCompErrors;
1714 bool computeFailed = true, memoryLack = false;
1716 SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
1717 aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
1719 SMESHGUI* gui = getSMESHGUI();
1720 SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
1721 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
1722 if ( errors->length() > 0 ) {
1723 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
1726 SUIT_OverrideCursor aWaitCursor;
1728 SVTK_ViewWindow* view = SMESH::GetViewWindow( gui );
1729 if ( myPreviewDisplayer ) delete myPreviewDisplayer;
1730 myPreviewDisplayer = new SMESHGUI_MeshEditPreview( view );
1732 SMESH::long_array_var aShapesId = new SMESH::long_array();
1734 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1738 SMESH::MeshPreviewStruct_var previewData =
1739 gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId);
1741 SMESH::MeshPreviewStruct* previewRes = previewData._retn();
1742 if ( previewRes && previewRes->nodesXYZ.length() > 0 )
1744 computeFailed = false;
1745 myPreviewDisplayer->SetData( previewRes );
1746 // append shape indeces with computed mesh entities
1747 for ( int i = 0, n = aShapesId->length(); i < n; i++ )
1748 myMapShapeId[ aShapesId[ i ] ] = 0;
1751 myPreviewDisplayer->SetVisibility(false);
1753 catch(const SALOME::SALOME_Exception & S_ex){
1755 myPreviewDisplayer->SetVisibility(false);
1759 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1762 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
1763 // check if there are memory problems
1764 for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
1765 memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
1767 catch(const SALOME::SALOME_Exception & S_ex){
1772 aMemoryReserve.release();
1774 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
1775 bool noHypoError = ( aHypErrors.isEmpty() );
1777 SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( gui );
1778 int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
1780 bool isShowError = true;
1781 switch( aNotifyMode ) {
1782 case 0: // show the mesh computation result dialog NEVER
1783 isShowError = false;
1785 case 1: // show the mesh computation result dialog if there are some errors
1786 default: // show the result dialog after each mesh computation
1787 if ( !computeFailed && !memoryLack && noCompError && noHypoError )
1788 isShowError = false;
1792 aWaitCursor.suspend();
1797 aCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
1798 showComputeResult( memoryLack, noCompError, aCompErrors, noHypoError, aHypErrors );
1803 //================================================================================
1805 * \brief Constructor
1807 //================================================================================
1809 SMESHGUI_PrecomputeDlg::SMESHGUI_PrecomputeDlg( QWidget* parent )
1810 : SMESHGUI_Dialog( parent, false, false, OK | Cancel | Help ),
1813 setWindowTitle( tr( "CAPTION" ) );
1815 setButtonText( OK, tr( "COMPUTE" ) );
1816 QFrame* main = mainFrame();
1818 QVBoxLayout* layout = new QVBoxLayout( main );
1820 myOrderBox = new SMESHGUI_MeshOrderBox( main );
1821 layout->addWidget(myOrderBox);
1823 QFrame* frame = new QFrame( main );
1824 layout->setMargin(0); layout->setSpacing(0);
1825 layout->addWidget( frame );
1827 QHBoxLayout* frameLay = new QHBoxLayout( frame );
1828 frameLay->setMargin(0); frameLay->setSpacing(SPACING);
1830 myPreviewMode = new QtxComboBox( frame );
1831 frameLay->addWidget( myPreviewMode );
1833 myPreviewBtn = new QPushButton( tr( "PREVIEW" ), frame );
1834 frameLay->addWidget( myPreviewBtn );
1836 connect( myPreviewBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( preview() ) );
1839 //================================================================================
1843 //================================================================================
1845 SMESHGUI_PrecomputeDlg::~SMESHGUI_PrecomputeDlg()
1849 //================================================================================
1851 * \brief Sets available preview modes
1853 //================================================================================
1855 void SMESHGUI_PrecomputeDlg::setPreviewModes( const QList<int>& theModes )
1857 myPreviewMode->clear();
1858 QList<int>::const_iterator it = theModes.constBegin();
1859 for ( int i = 0; it != theModes.constEnd(); ++it, i++ )
1861 QString mode = QString( "PREVIEW_%1" ).arg( *it );
1862 myPreviewMode->addItem( tr( mode.toLatin1().data() ) );
1863 myPreviewMode->setId( i, *it );
1865 myPreviewBtn->setEnabled( !theModes.isEmpty() );
1868 //================================================================================
1870 * \brief Returns current preview mesh mode
1872 //================================================================================
1874 int SMESHGUI_PrecomputeDlg::getPreviewMode() const
1876 return myPreviewMode->currentId();
1879 //================================================================================
1881 * \brief Returns current preview mesh mode
1883 //================================================================================
1885 SMESHGUI_MeshOrderBox* SMESHGUI_PrecomputeDlg::getMeshOrderBox() const
1891 //================================================================================
1893 * \brief Constructor
1895 //================================================================================
1897 SMESHGUI_EvaluateOp::SMESHGUI_EvaluateOp()
1898 : SMESHGUI_BaseComputeOp()
1903 //================================================================================
1905 * \brief Desctructor
1907 //================================================================================
1909 SMESHGUI_EvaluateOp::~SMESHGUI_EvaluateOp()
1913 //================================================================================
1915 * \brief perform it's intention action: compute mesh
1917 //================================================================================
1919 void SMESHGUI_EvaluateOp::startOperation()
1921 SMESHGUI_BaseComputeOp::evaluateDlg();
1922 SMESHGUI_BaseComputeOp::startOperation();
1923 if (myMesh->_is_nil())
1928 //================================================================================
1930 * \brief Gets dialog of this operation
1931 * \retval LightApp_Dialog* - pointer to dialog of this operation
1933 //================================================================================
1935 LightApp_Dialog* SMESHGUI_EvaluateOp::dlg() const
1937 return evaluateDlg();
1940 //================================================================================
1942 * \brief evaluateMesh()
1944 //================================================================================
1946 void SMESHGUI_BaseComputeOp::evaluateMesh()
1950 SMESH::MemoryReserve aMemoryReserve;
1952 SMESH::compute_error_array_var aCompErrors;
1955 bool evaluateFailed = true, memoryLack = false;
1956 SMESH::long_array_var aRes;
1958 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
1959 if ( !aMeshSObj ) // IPAL21340
1962 bool hasShape = myMesh->HasShapeToMesh();
1963 bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
1966 myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
1967 SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
1968 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
1969 if ( errors->length() > 0 ) {
1970 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
1972 SUIT_OverrideCursor aWaitCursor;
1974 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1977 aRes = gen->Evaluate(myMesh, myMainShape);
1979 catch(const SALOME::SALOME_Exception & S_ex){
1984 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1987 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
1989 catch(const SALOME::SALOME_Exception & S_ex){
1995 aMemoryReserve.release();
1997 evaluateFailed = ( aCompErrors->length() > 0 );
1998 myCompDlg->setWindowTitle(tr( evaluateFailed ? "SMESH_WRN_EVALUATE_FAILED" : "SMESH_EVALUATE_SUCCEED"));
2002 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
2003 bool noHypoError = ( aHypErrors.isEmpty() );
2005 //SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
2006 //int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
2008 bool isShowResultDlg = true;
2010 //switch( aNotifyMode ) {
2011 //case 0: // show the mesh computation result dialog NEVER
2012 //isShowResultDlg = false;
2015 //case 1: // show the mesh computation result dialog if there are some errors
2016 //if ( memoryLack || !noHypoError )
2017 // isShowResultDlg = true;
2020 // isShowResultDlg = false;
2024 //default: // show the result dialog after each mesh computation
2025 //isShowResultDlg = true;
2029 if ( isShowResultDlg )
2030 showEvaluateResult( aRes, memoryLack, noCompError, aCompErrors,
2031 noHypoError, aHypErrors);
2035 void SMESHGUI_BaseComputeOp::showEvaluateResult(const SMESH::long_array& theRes,
2036 const bool theMemoryLack,
2037 const bool theNoCompError,
2038 SMESH::compute_error_array_var& theCompErrors,
2039 const bool theNoHypoError,
2040 const QString& theHypErrors)
2042 bool hasShape = myMesh->HasShapeToMesh();
2043 SMESHGUI_ComputeDlg* aCompDlg = evaluateDlg();
2044 aCompDlg->myMemoryLackGroup->hide();
2046 if ( theMemoryLack )
2048 aCompDlg->myMemoryLackGroup->show();
2049 aCompDlg->myFullInfo->hide();
2050 aCompDlg->myBriefInfo->hide();
2051 aCompDlg->myHypErrorGroup->hide();
2052 aCompDlg->myCompErrorGroup->hide();
2054 else if ( theNoCompError && theNoHypoError )
2056 aCompDlg->myFullInfo->SetMeshInfo( theRes );
2057 aCompDlg->myFullInfo->show();
2058 aCompDlg->myBriefInfo->hide();
2059 aCompDlg->myHypErrorGroup->hide();
2060 aCompDlg->myCompErrorGroup->hide();
2064 QTableWidget* tbl = aCompDlg->myTable;
2065 aCompDlg->myBriefInfo->SetMeshInfo( theRes );
2066 aCompDlg->myBriefInfo->show();
2067 aCompDlg->myFullInfo->hide();
2069 if ( theNoHypoError ) {
2070 aCompDlg->myHypErrorGroup->hide();
2073 aCompDlg->myHypErrorGroup->show();
2074 aCompDlg->myHypErrorLabel->setText( theHypErrors );
2077 if ( theNoCompError ) {
2078 aCompDlg->myCompErrorGroup->hide();
2081 aCompDlg->myCompErrorGroup->show();
2083 aCompDlg->myPublishBtn->hide();
2084 aCompDlg->myShowBtn->hide();
2086 // fill table of errors
2087 tbl->setRowCount( theCompErrors->length() );
2088 if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
2089 else tbl->showColumn( COL_SHAPE );
2090 tbl->setColumnWidth( COL_ERROR, 200 );
2092 bool hasBadMesh = false;
2093 for ( int row = 0; row < theCompErrors->length(); ++row )
2095 SMESH::ComputeError & err = theCompErrors[ row ];
2097 QString text = err.algoName.in();
2098 if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
2099 else tbl->item( row, COL_ALGO )->setText( text );
2101 text = SMESH::errorText( err.code, err.comment.in() );
2102 if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
2103 else tbl->item( row, COL_ERROR )->setText( text );
2105 text = QString("%1").arg( err.subShapeID );
2106 if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
2107 else tbl->item( row, COL_SHAPEID )->setText( text );
2109 text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
2110 if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
2111 else tbl->item( row, COL_SHAPE )->setText( text );
2113 text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
2114 if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
2115 else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled
2117 text = err.hasBadMesh ? "hasBadMesh" : "";
2118 if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
2119 else tbl->item( row, COL_BAD_MESH )->setText( text );
2120 if ( err.hasBadMesh ) hasBadMesh = true;
2122 //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
2123 tbl->resizeRowToContents( row );
2125 tbl->resizeColumnToContents( COL_ALGO );
2126 tbl->resizeColumnToContents( COL_SHAPE );
2127 tbl->setWordWrap( true );
2130 aCompDlg->myBadMeshBtn->show();
2132 aCompDlg->myBadMeshBtn->hide();
2134 tbl->setCurrentCell(0,0);
2135 currentCellChanged(); // to update buttons
2138 // show dialog and wait, becase Compute can be invoked from Preview operation
2139 //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
2144 //================================================================================
2146 * \brief Gets dialog of evaluate operation
2147 * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation
2149 //================================================================================
2151 SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::evaluateDlg() const
2155 SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
2156 me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), true );
2157 // connect signals and slots
2158 connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
2159 connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
2160 connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
2161 QTableWidget* aTable = me->table();
2162 connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
2163 connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));