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>
64 #include CORBA_SERVER_HEADER(SMESH_Group)
67 #include <BRep_Tool.hxx>
69 #include <TopExp_Explorer.hxx>
70 #include <TopTools_IndexedMapOfShape.hxx>
73 #include <TopLoc_Location.hxx>
74 #include <Poly_Triangulation.hxx>
75 #include <Bnd_Box.hxx>
76 #include <BRepBndLib.hxx>
77 #include <BRepMesh_IncrementalMesh.hxx>
79 #include <Standard_ErrorHandler.hxx>
83 #include <QPushButton>
85 #include <QRadioButton>
86 #include <QTableWidget>
87 #include <QHeaderView>
88 #include <QGridLayout>
89 #include <QHBoxLayout>
90 #include <QVBoxLayout>
91 #include <QButtonGroup>
92 #include <QCloseEvent>
93 #include <QTimerEvent>
96 #include <vtkProperty.h>
105 #define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
108 static void addSeparator( QWidget* parent )
110 QGridLayout* l = qobject_cast<QGridLayout*>( parent->layout() );
111 int row = l->rowCount();
112 int cols = l->columnCount();
113 for ( int i = 0; i < cols; i++ ) {
114 QFrame* hline = new QFrame( parent );
115 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
116 l->addWidget( hline, row, i );
122 COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
125 //using namespace SMESH;
129 //=============================================================================
131 * \brief Allocate some memory at construction and release it at destruction.
132 * Is used to be able to continue working after mesh generation or visualization
133 * break due to lack of memory
135 //=============================================================================
140 MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M
141 void release() { delete [] myBuf; myBuf = 0; }
142 ~MemoryReserve() { release(); }
145 // =========================================================================================
147 * \brief Class showing shapes without publishing
149 // =========================================================================================
151 class TShapeDisplayer
154 // -----------------------------------------------------------------------
155 TShapeDisplayer(): myViewWindow(0)
157 myProperty = vtkProperty::New();
158 myProperty->SetRepresentationToWireframe();
159 myProperty->SetColor( 250, 0, 250 );
160 myProperty->SetAmbientColor( 250, 0, 250 );
161 myProperty->SetDiffuseColor( 250, 0, 250 );
162 //myProperty->SetSpecularColor( 250, 0, 250 );
163 myProperty->SetLineWidth( 5 );
165 // -----------------------------------------------------------------------
169 myProperty->Delete();
171 // -----------------------------------------------------------------------
174 if ( hasViewWindow() ) {
175 TActorIterator actorIt = actorIterator();
176 while ( actorIt.more() )
177 if (VTKViewer_Actor* anActor = actorIt.next()) {
178 myViewWindow->RemoveActor( anActor );
182 myIndexToShape.Clear();
184 myShownActors.clear();
187 // -----------------------------------------------------------------------
188 void SetVisibility (bool theVisibility)
190 TActorIterator actorIt = shownIterator();
191 while ( actorIt.more() )
192 if (VTKViewer_Actor* anActor = actorIt.next())
193 anActor->SetVisibility(theVisibility);
194 SMESH::RepaintCurrentView();
196 // -----------------------------------------------------------------------
197 bool HasReadyActorsFor (int subShapeID, GEOM::GEOM_Object_var aMainShape )
199 std::string mainEntry;
200 if ( !aMainShape->_is_nil() )
201 mainEntry = aMainShape->GetStudyEntry();
202 return ( myMainEntry == mainEntry &&
203 myBuiltSubs.find( subShapeID ) != myBuiltSubs.end() );
205 // -----------------------------------------------------------------------
206 void Show( int subShapeID, GEOM::GEOM_Object_var aMainShape, bool only = false)
208 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() );
209 std::string mainEntry;
210 if ( !aMainShape->_is_nil() )
211 mainEntry = aMainShape->GetStudyEntry();
212 if ( myMainEntry != mainEntry || aViewWindow != myViewWindow ) { // remove actors
215 if ( !aMainShape->_is_nil() && GEOMBase::GetShape(aMainShape, aShape)) {
216 checkTriangulation( aShape );
217 TopExp::MapShapes(aShape, myIndexToShape);
218 myActors.resize( myIndexToShape.Extent(), 0 );
219 myShownActors.reserve( myIndexToShape.Extent() );
221 myMainEntry = mainEntry;
222 myViewWindow = aViewWindow;
224 if ( only ) { // hide shown actors
225 TActorIterator actorIt = shownIterator();
226 while ( actorIt.more() )
227 if (VTKViewer_Actor* anActor = actorIt.next())
228 anActor->SetVisibility(false);
229 myShownActors.clear();
231 // find actors to show
232 TopoDS_Shape aShape = myIndexToShape( subShapeID );
233 if ( !aShape.IsNull() ) {
234 TopAbs_ShapeEnum type( aShape.ShapeType() >= TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE );
235 for ( TopExp_Explorer exp( aShape, type ); exp.More(); exp.Next() ) {
236 //checkTriangulation( exp.Current() );
237 if ( GEOM_Actor* anActor = getActor( exp.Current() ))
238 myShownActors.push_back( anActor );
240 if ( type == TopAbs_FACE ) {
241 for ( TopExp_Explorer exp( aShape, TopAbs_EDGE ); exp.More(); exp.Next() ) {
242 const TopoDS_Edge & edge = TopoDS::Edge( exp.Current() );
243 if ( !BRep_Tool::Degenerated( edge ))
244 if ( GEOM_Actor* anActor = getActor( exp.Current() ))
245 myShownActors.push_back( anActor );
249 myBuiltSubs.insert( subShapeID );
252 // -----------------------------------------------------------------------
256 typedef std::vector<GEOM_Actor*> TActorVec;
258 TActorVec myShownActors;
259 TopTools_IndexedMapOfShape myIndexToShape;
260 std::string myMainEntry;
261 SVTK_ViewWindow* myViewWindow;
262 vtkProperty* myProperty;
263 std::set<int> myBuiltSubs;
265 // -----------------------------------------------------------------------
266 typedef SMDS_SetIterator< GEOM_Actor*, TActorVec::const_iterator> TActorIterator;
267 TActorIterator actorIterator() {
268 return TActorIterator( myActors.begin(), myActors.end() );
270 TActorIterator shownIterator() {
271 return TActorIterator( myShownActors.begin(), myShownActors.end() );
273 // -----------------------------------------------------------------------
274 GEOM_Actor* getActor(const TopoDS_Shape& shape)
276 int index = myIndexToShape.FindIndex( shape ) - 1;
277 if ( index < 0 || index >= myActors.size() )
279 GEOM_Actor* & actor = myActors[ index ];
281 actor = GEOM_Actor::New();
283 actor->SetShape(shape,0,0);
284 actor->SetProperty(myProperty);
285 actor->SetShadingProperty(myProperty);
286 actor->SetWireframeProperty(myProperty);
287 actor->SetPreviewProperty(myProperty);
288 actor->PickableOff();
289 // if ( shape.ShapeType() == TopAbs_EDGE )
290 // actor->SubShapeOn();
291 myViewWindow->AddActor( actor );
296 // -----------------------------------------------------------------------
297 void checkTriangulation(const TopoDS_Shape& shape)
299 TopLoc_Location aLoc;
300 Standard_Boolean alreadymesh = Standard_True;
301 TopExp_Explorer ex(shape, TopAbs_FACE);
303 for ( ; ex.More(); ex.Next()) {
304 const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
305 Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
306 if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
309 for (ex.Init(shape, TopAbs_EDGE); ex.More(); ex.Next()) {
310 const TopoDS_Edge& edge = TopoDS::Edge(ex.Current());
311 Handle(Poly_Polygon3D) aPoly = BRep_Tool::Polygon3D(edge, aLoc);
312 if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
314 if (alreadymesh) return;
315 // Compute default deflection
317 BRepBndLib::Add(shape, B);
318 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
319 B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
320 double deflection = Max( aXmax-aXmin, Max ( aYmax-aYmin, aZmax-aZmin)) * 0.01 *4;
321 BRepMesh_IncrementalMesh MESH(shape,deflection);
323 // -----------------------------------------------------------------------
324 bool hasViewWindow() const
326 if ( !myViewWindow ) return false;
328 if ( SalomeApp_Application* anApp = SMESHGUI::GetSMESHGUI()->getApp() )
329 return FindVtkViewWindow( anApp->getViewManager(SVTK_Viewer::Type(), false ),
335 // =========================================================================================
337 * \brief Return text describing an error
339 #define CASE2TEXT(enum) case SMESH::enum: text = QObject::tr( #enum ); break;
340 QString errorText(int errCode, const char* comment)
344 CASE2TEXT( COMPERR_OK );
345 CASE2TEXT( COMPERR_BAD_INPUT_MESH );
346 CASE2TEXT( COMPERR_STD_EXCEPTION );
347 CASE2TEXT( COMPERR_OCC_EXCEPTION );
348 case SMESH::COMPERR_SLM_EXCEPTION: break; // avoid double "Salome exception"
349 CASE2TEXT( COMPERR_EXCEPTION );
350 CASE2TEXT( COMPERR_MEMORY_PB );
351 CASE2TEXT( COMPERR_BAD_SHAPE );
352 CASE2TEXT( COMPERR_CANCELED );
353 CASE2TEXT( COMPERR_NO_MESH_ON_SHAPE );
354 case SMESH::COMPERR_ALGO_FAILED:
355 if ( strlen(comment) == 0 )
356 text = QObject::tr("COMPERR_ALGO_FAILED");
358 case SMESH::COMPERR_WARNING:
359 text = QObject::tr( (comment && strlen(comment)) ? "COMPERR_WARNING" : "COMPERR_UNKNOWN");
362 text = QString("#%1").arg( -errCode );
364 if ( text.length() > 0 ) text += ". ";
365 return text + comment;
367 // -----------------------------------------------------------------------
369 * \brief Return SO of a sub-shape
371 _PTR(SObject) getSubShapeSO( int subShapeID, GEOM::GEOM_Object_var aMainShape)
373 _PTR(SObject) so = SMESH::FindSObject(aMainShape);
374 if ( subShapeID == 1 || !so )
376 _PTR(ChildIterator) it;
377 if (_PTR(Study) study = SMESH::GetActiveStudyDocument())
378 it = study->NewChildIterator(so);
381 for ( it->InitEx(true); !subSO && it->More(); it->Next() ) {
382 GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( it->Value() );
383 if ( !geom->_is_nil() ) {
384 GEOM::ListOfLong_var list = geom->GetSubShapeIndices();
385 if ( list->length() == 1 && list[0] == subShapeID )
392 // -----------------------------------------------------------------------
394 * \brief Return sub-shape by ID. WARNING: UnRegister() must be called on a result
396 GEOM::GEOM_Object_ptr getSubShape( int subShapeID, GEOM::GEOM_Object_var aMainShape)
398 GEOM::GEOM_Object_var aSubShape;
399 if ( subShapeID == 1 ) {
400 aSubShape = aMainShape;
401 aSubShape->Register();
403 else if ( _PTR(SObject) so = getSubShapeSO( subShapeID, aMainShape )) {
404 aSubShape = SMESH::SObjectToInterface<GEOM::GEOM_Object>( so );
405 aSubShape->Register();
408 aSubShape = SMESH::GetSubShape( aMainShape, subShapeID );
409 // future call of UnRegister() will delete a servant of this new object
411 return aSubShape._retn();
413 // -----------------------------------------------------------------------
415 * \brief Return shape type name
417 #define CASE2NAME(enum) case GEOM::enum: name = QObject::tr( "GEOM_" #enum ); break;
418 QString shapeTypeName(GEOM::GEOM_Object_var aShape, const char* dflt = "" )
421 if ( !aShape->_is_nil() ) {
422 switch ( aShape->GetShapeType() ) {
429 CASE2NAME( COMPSOLID );
430 CASE2NAME( COMPOUND );
436 // -----------------------------------------------------------------------
438 * \brief Return text describing a sub-shape
440 QString shapeText(int subShapeID, GEOM::GEOM_Object_var aMainShape )
443 if ( _PTR(SObject) aSO = getSubShapeSO( subShapeID, aMainShape ))
444 text = aSO->GetName().c_str();
446 text = QString("#%1").arg( subShapeID );
447 GEOM::GEOM_Object_wrap shape = getSubShape( subShapeID, aMainShape );
448 QString typeName = shapeTypeName( shape );
449 if ( typeName.length() )
450 text += QString(" (%1)").arg(typeName);
454 // -----------------------------------------------------------------------
456 * \brief Return a list of selected rows
458 int getSelectedRows(QTableWidget* table, QList<int>& rows)
461 QList<QTableWidgetSelectionRange> selRanges = table->selectedRanges();
462 QTableWidgetSelectionRange range;
463 foreach( range, selRanges )
465 for ( int row = range.topRow(); row <= range.bottomRow(); ++row )
466 if ( !rows.count( row ))
469 if ( rows.isEmpty() && table->currentRow() > -1 )
470 if ( !rows.count( table->currentRow() ))
471 rows.append( table->currentRow() );
479 // =========================================================================================
481 * \brief Dialog to compute a mesh and show computation errors
483 //=======================================================================
485 SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg( QWidget* parent, bool ForEval )
486 : SMESHGUI_Dialog( parent, false, true, Close/* | Help*/ )
488 QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
489 aDlgLay->setMargin( 0 );
490 aDlgLay->setSpacing( SPACING );
492 QFrame* aMainFrame = createMainFrame(mainFrame(),ForEval);
494 aDlgLay->addWidget(aMainFrame);
496 aDlgLay->setStretchFactor(aMainFrame, 1);
499 // =========================================================================================
503 //=======================================================================
505 SMESHGUI_ComputeDlg::~SMESHGUI_ComputeDlg()
509 //=======================================================================
510 // function : createMainFrame()
511 // purpose : Create frame containing dialog's fields
512 //=======================================================================
514 QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval)
516 QFrame* aFrame = new QFrame(theParent);
518 SUIT_ResourceMgr* rm = resourceMgr();
519 QPixmap iconCompute (rm->loadPixmap("SMESH", tr("ICON_COMPUTE")));
525 aPixGrp = new QGroupBox(tr("EVAL_DLG"), aFrame);
528 aPixGrp = new QGroupBox(tr("CONSTRUCTOR"), aFrame);
530 QButtonGroup* aBtnGrp = new QButtonGroup(this);
531 QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
532 aPixGrpLayout->setMargin(MARGIN); aPixGrpLayout->setSpacing(SPACING);
534 QRadioButton* aRBut = new QRadioButton(aPixGrp);
535 aRBut->setIcon(iconCompute);
536 aRBut->setChecked(true);
537 aPixGrpLayout->addWidget(aRBut);
538 aBtnGrp->addButton(aRBut, 0);
542 QGroupBox* nameBox = new QGroupBox(tr("SMESH_MESHINFO_NAME"), aFrame );
543 QHBoxLayout* nameBoxLayout = new QHBoxLayout(nameBox);
544 nameBoxLayout->setMargin(MARGIN); nameBoxLayout->setSpacing(SPACING);
545 myMeshName = new QLabel(nameBox);
546 nameBoxLayout->addWidget(myMeshName);
550 myBriefInfo = new SMESHGUI_MeshInfosBox(false, aFrame);
551 myFullInfo = new SMESHGUI_MeshInfosBox(true, aFrame);
553 // Computation errors
555 myCompErrorGroup = new QGroupBox(tr("ERRORS"), aFrame);
556 myWarningLabel = new QLabel(QString("<b>%1</b>").arg(tr("COMPUTE_WARNING")), myCompErrorGroup);
557 myTable = new QTableWidget( 1, NB_COLUMNS, myCompErrorGroup);
558 myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup);
559 myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup);
560 myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup);
561 myBadMeshToGroupBtn = new QPushButton(tr("GROUP_OF_BAD_MESH"), myCompErrorGroup);
563 //myTable->setReadOnly( true ); // VSR: check
564 myTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
565 myTable->hideColumn( COL_PUBLISHED );
566 myTable->hideColumn( COL_SHAPEID );
567 myTable->hideColumn( COL_BAD_MESH );
568 myTable->horizontalHeader()->setResizeMode( COL_ERROR, QHeaderView::Interactive );
569 myTable->setWordWrap( true );
570 myTable->horizontalHeader()->setStretchLastSection( true );
571 myTable->setMinimumWidth( 500 );
574 headers << tr( "COL_ALGO_HEADER" );
575 headers << tr( "COL_SHAPE_HEADER" );
576 headers << tr( "COL_ERROR_HEADER" );
577 headers << tr( "COL_SHAPEID_HEADER" );
578 headers << tr( "COL_PUBLISHED_HEADER" );
580 myTable->setHorizontalHeaderLabels( headers );
583 QGridLayout* grpLayout = new QGridLayout(myCompErrorGroup);
584 grpLayout->setSpacing(SPACING);
585 grpLayout->setMargin(MARGIN);
586 grpLayout->addWidget( myWarningLabel, 0, 0, 1, 4 );
587 grpLayout->addWidget( myTable, 1, 0, 1, 4 );
588 grpLayout->addWidget( myShowBtn, 2, 0 );
589 grpLayout->addWidget( myPublishBtn, 2, 1 );
590 grpLayout->addWidget( myBadMeshBtn, 2, 2 );
591 grpLayout->addWidget( myBadMeshToGroupBtn, 2, 3 );
592 grpLayout->setColumnStretch( 3, 1 );
594 // Hypothesis definition errors
596 myHypErrorGroup = new QGroupBox(tr("SMESH_WRN_MISSING_PARAMETERS"), aFrame);
597 QHBoxLayout* myHypErrorGroupLayout = new QHBoxLayout(myHypErrorGroup);
598 myHypErrorGroupLayout->setMargin(MARGIN);
599 myHypErrorGroupLayout->setSpacing(SPACING);
600 myHypErrorLabel = new QLabel(myHypErrorGroup);
601 myHypErrorGroupLayout->addWidget(myHypErrorLabel);
605 myMemoryLackGroup = new QGroupBox(tr("ERRORS"), aFrame);
606 QVBoxLayout* myMemoryLackGroupLayout = new QVBoxLayout(myMemoryLackGroup);
607 myMemoryLackGroupLayout->setMargin(MARGIN);
608 myMemoryLackGroupLayout->setSpacing(SPACING);
609 QLabel* memLackLabel = new QLabel(tr("MEMORY_LACK"), myMemoryLackGroup);
610 QFont bold = memLackLabel->font(); bold.setBold(true);
611 memLackLabel->setFont( bold );
612 memLackLabel->setMinimumWidth(300);
613 myMemoryLackGroupLayout->addWidget(memLackLabel);
615 // add all widgets to aFrame
616 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
617 aLay->setMargin( 0 );
618 aLay->setSpacing( 0 );
619 aLay->addWidget( aPixGrp );
620 aLay->addWidget( nameBox );
621 aLay->addWidget( myBriefInfo );
622 aLay->addWidget( myFullInfo );
623 aLay->addWidget( myHypErrorGroup );
624 aLay->addWidget( myCompErrorGroup );
625 aLay->addWidget( myMemoryLackGroup );
626 aLay->setStretchFactor( myCompErrorGroup, 1 );
628 ((QPushButton*) button( OK ))->setDefault( true );
633 //================================================================================
637 //================================================================================
639 SMESHGUI_BaseComputeOp::SMESHGUI_BaseComputeOp()
640 : SMESHGUI_Operation(), myCompDlg( 0 )
642 myTShapeDisplayer = new SMESH::TShapeDisplayer();
643 myBadMeshDisplayer = 0;
645 //myHelpFileName = "/files/about_meshes.htm"; // V3
646 myHelpFileName = "about_meshes_page.html"; // V4
649 SMESH::SMESH_Mesh_ptr SMESHGUI_BaseComputeOp::getMesh()
651 LightApp_SelectionMgr* Sel = selectionMgr();
652 SALOME_ListIO selected; Sel->selectedObjects( selected );
653 Handle(SALOME_InteractiveObject) anIO = selected.First();
654 SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(anIO);
655 return myMesh->_is_nil() ? aMesh._retn() : SMESH::SMESH_Mesh::_duplicate( myMesh );
658 //================================================================================
660 * \brief Start operation
661 * \purpose Init dialog fields, connect signals and slots, show dialog
663 //================================================================================
665 void SMESHGUI_BaseComputeOp::startOperation()
667 // create compute dialog if not created before
670 myMesh = SMESH::SMESH_Mesh::_nil();
671 myMainShape = GEOM::GEOM_Object::_nil();
674 LightApp_SelectionMgr *Sel = selectionMgr();
675 SALOME_ListIO selected; Sel->selectedObjects( selected );
677 int nbSel = selected.Extent();
679 SUIT_MessageBox::warning(desktop(),
680 tr("SMESH_WRN_WARNING"),
681 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
686 myIObject = selected.First();
687 myMesh = SMESH::GetMeshByIO(myIObject);
688 if (myMesh->_is_nil()) {
689 SUIT_MessageBox::warning(desktop(),
690 tr("SMESH_WRN_WARNING"),
691 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
695 myMainShape = myMesh->GetShapeToMesh();
697 SMESHGUI_Operation::startOperation();
700 //================================================================================
701 //================================================================================
703 SMESHGUI_ComputeDlg_QThread::SMESHGUI_ComputeDlg_QThread(SMESH::SMESH_Gen_var gen,
704 SMESH::SMESH_Mesh_var mesh,
705 GEOM::GEOM_Object_var mainShape)
710 myMainShape = mainShape;
713 void SMESHGUI_ComputeDlg_QThread::run()
715 myResult = myGen->Compute(myMesh, myMainShape);
718 bool SMESHGUI_ComputeDlg_QThread::result()
723 void SMESHGUI_ComputeDlg_QThread::cancel()
725 myGen->CancelCompute(myMesh, myMainShape);
728 //================================================================================
729 //================================================================================
731 SMESHGUI_ComputeDlg_QThreadQDialog::SMESHGUI_ComputeDlg_QThreadQDialog(QWidget * parent,
732 SMESH::SMESH_Gen_var gen,
733 SMESH::SMESH_Mesh_var mesh,
734 GEOM::GEOM_Object_var mainShape)
736 Qt::WindowSystemMenuHint |
737 Qt::WindowCloseButtonHint |
739 Qt::WindowMaximizeButtonHint),
740 qthread(gen, mesh, mainShape)
743 setWindowTitle(tr("Compute"));
744 setMinimumWidth( 200 );
746 cancelButton = new QPushButton(tr("Cancel"));
747 cancelButton->setDefault(true);
749 QLabel * nbNodesName = new QLabel(tr("SMESH_MESHINFO_NODES"), this );
750 QLabel * nbElemsName = new QLabel(tr("SMESH_MESHINFO_ELEMENTS"), this );
751 nbNodesLabel = new QLabel("0", this );
752 nbElemsLabel = new QLabel("0", this );
754 QGridLayout* layout = new QGridLayout(this);
755 layout->setMargin( MARGIN );
756 layout->setSpacing( SPACING );
757 layout->addWidget(nbNodesName, 0, 0);
758 layout->addWidget(nbNodesLabel, 0, 1);
759 layout->addWidget(nbElemsName, 1, 0);
760 layout->addWidget(nbElemsLabel, 1, 1);
761 layout->addWidget(cancelButton, 2, 0, 1, 2);
765 connect(cancelButton, SIGNAL(clicked()), this, SLOT(onCancel()));
767 startTimer(300); // millisecs
771 bool SMESHGUI_ComputeDlg_QThreadQDialog::result()
773 return qthread.result();
776 void SMESHGUI_ComputeDlg_QThreadQDialog::onCancel()
781 void SMESHGUI_ComputeDlg_QThreadQDialog::timerEvent(QTimerEvent *event)
783 if(qthread.isFinished())
787 nbNodesLabel->setText( QString("%1").arg( qthread.getMesh()->NbNodes() ));
788 nbElemsLabel->setText( QString("%1").arg( qthread.getMesh()->NbElements() ));
792 void SMESHGUI_ComputeDlg_QThreadQDialog::closeEvent(QCloseEvent *event)
794 if(qthread.isRunning())
802 //================================================================================
804 * \brief computeMesh()
806 //================================================================================
808 void SMESHGUI_BaseComputeOp::computeMesh()
812 SMESH::MemoryReserve aMemoryReserve;
814 SMESH::compute_error_array_var aCompErrors;
817 bool computeFailed = true, memoryLack = false;
819 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
820 if ( !aMeshSObj ) // IPAL 21340
822 bool hasShape = myMesh->HasShapeToMesh();
823 bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
826 myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
827 SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
828 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
829 if ( errors->length() > 0 ) {
830 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
832 if ( myMesh->HasModificationsToDiscard() && // issue 0020693
833 SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
834 tr( "FULL_RECOMPUTE_QUESTION" ),
835 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 1, 0 ) == 0 )
837 SUIT_OverrideCursor aWaitCursor;
839 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
843 SMESHGUI_ComputeDlg_QThreadQDialog qthreaddialog(desktop(), gen, myMesh, myMainShape);
844 qthreaddialog.exec();
845 res = qthreaddialog.result();
846 res = gen->Compute(myMesh, myMainShape);
848 computeFailed = false;
850 catch(const SALOME::SALOME_Exception & S_ex) {
854 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
857 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
858 // check if there are memory problems
859 for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
860 memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
862 catch(const SALOME::SALOME_Exception & S_ex) {
866 if ( !memoryLack && !SMDS_Mesh::CheckMemory(true) ) { // has memory to show dialog boxes?
870 // NPAL16631: if ( !memoryLack )
872 SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
873 update( UF_ObjBrowser | UF_Model );
876 // NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
877 SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
878 long newSize = myMesh->NbElements();
882 if ( getSMESHGUI()->automaticUpdate( newSize, &limitExceeded ) )
885 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
888 SMESH::Update(myIObject, true);
892 MESSAGE ( "Exception thrown during mesh visualization" );
894 if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
895 SMESH::OnVisuException();
902 else if ( limitExceeded )
904 long limitSize = resMgr->integerValue( "SMESH", "update_limit", 500000 );
905 SUIT_MessageBox::warning( desktop(),
906 tr( "SMESH_WRN_WARNING" ),
907 tr( "SMESH_WRN_SIZE_LIMIT_EXCEEDED" ).arg( newSize ).arg( limitSize ) );
910 LightApp_SelectionMgr *Sel = selectionMgr();
913 SALOME_ListIO selected;
914 selected.Append( myIObject );
915 Sel->setSelectedObjects( selected );
921 aMemoryReserve.release();
923 myCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
927 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
928 bool noHypoError = ( aHypErrors.isEmpty() );
930 SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
931 int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
933 bool isShowResultDlg = true;
934 switch( aNotifyMode ) {
935 case 0: // show the mesh computation result dialog NEVER
936 isShowResultDlg = false;
939 case 1: // show the mesh computation result dialog if there are some errors
940 if ( memoryLack || !noCompError || !noHypoError )
941 isShowResultDlg = true;
944 isShowResultDlg = false;
948 default: // show the result dialog after each mesh computation
949 isShowResultDlg = true;
953 if ( isShowResultDlg )
954 showComputeResult( memoryLack, noCompError,aCompErrors, noHypoError, aHypErrors );
957 void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
958 const bool theNoCompError,
959 SMESH::compute_error_array_var& theCompErrors,
960 const bool theNoHypoError,
961 const QString& theHypErrors )
963 bool hasShape = myMesh->HasShapeToMesh();
964 SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
965 aCompDlg->myMemoryLackGroup->hide();
969 aCompDlg->myMemoryLackGroup->show();
970 aCompDlg->myFullInfo->hide();
971 aCompDlg->myBriefInfo->hide();
972 aCompDlg->myHypErrorGroup->hide();
973 aCompDlg->myCompErrorGroup->hide();
975 else if ( theNoCompError && theNoHypoError )
977 SMESH::long_array_var aRes = myMesh->GetMeshInfo();
978 aCompDlg->myFullInfo->SetMeshInfo( aRes );
979 aCompDlg->myFullInfo->show();
980 aCompDlg->myBriefInfo->hide();
981 aCompDlg->myHypErrorGroup->hide();
982 aCompDlg->myCompErrorGroup->hide();
986 bool onlyWarnings = !theNoCompError; // == valid mesh computed but there are errors reported
987 for ( int i = 0; i < theCompErrors->length() && onlyWarnings; ++i )
988 onlyWarnings = ( theCompErrors[ i ].code == SMESH::COMPERR_WARNING ||
989 theCompErrors[ i ].code == SMESH::COMPERR_NO_MESH_ON_SHAPE );
991 // full or brief mesh info
992 SMESH::long_array_var aRes = myMesh->GetMeshInfo();
993 if ( onlyWarnings ) {
994 aCompDlg->myFullInfo->SetMeshInfo( aRes );
995 aCompDlg->myFullInfo->show();
996 aCompDlg->myBriefInfo->hide();
998 aCompDlg->myBriefInfo->SetMeshInfo( aRes );
999 aCompDlg->myBriefInfo->show();
1000 aCompDlg->myFullInfo->hide();
1003 // pbs of hypo dfinitions
1004 if ( theNoHypoError ) {
1005 aCompDlg->myHypErrorGroup->hide();
1007 aCompDlg->myHypErrorGroup->show();
1008 aCompDlg->myHypErrorLabel->setText( theHypErrors );
1012 if ( theNoCompError )
1014 aCompDlg->myCompErrorGroup->hide();
1018 aCompDlg->myCompErrorGroup->show();
1021 aCompDlg->myWarningLabel->show();
1023 aCompDlg->myWarningLabel->hide();
1026 aCompDlg->myPublishBtn->hide();
1027 aCompDlg->myShowBtn->hide();
1030 aCompDlg->myPublishBtn->show();
1031 aCompDlg->myShowBtn->show();
1034 // fill table of errors
1035 QTableWidget* tbl = aCompDlg->myTable;
1036 tbl->setRowCount( theCompErrors->length() );
1037 if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
1038 else tbl->showColumn( COL_SHAPE );
1039 tbl->setColumnWidth( COL_ERROR, 200 );
1041 bool hasBadMesh = false;
1042 for ( int row = 0; row < theCompErrors->length(); ++row )
1044 SMESH::ComputeError & err = theCompErrors[ row ];
1046 QString text = err.algoName.in();
1047 if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
1048 else tbl->item( row, COL_ALGO )->setText( text );
1050 text = SMESH::errorText( err.code, err.comment.in() );
1051 if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
1052 else tbl->item( row, COL_ERROR )->setText( text );
1054 text = QString("%1").arg( err.subShapeID );
1055 if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
1056 else tbl->item( row, COL_SHAPEID )->setText( text );
1058 text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
1059 if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
1060 else tbl->item( row, COL_SHAPE )->setText( text );
1062 text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
1063 if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
1064 else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled
1066 text = err.hasBadMesh ? "hasBadMesh" : "";
1067 if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
1068 else tbl->item( row, COL_BAD_MESH )->setText( text );
1069 if ( err.hasBadMesh ) hasBadMesh = true;
1071 //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
1072 tbl->resizeRowToContents( row );
1074 tbl->resizeColumnToContents( COL_ALGO );
1075 tbl->resizeColumnToContents( COL_SHAPE );
1076 tbl->setWordWrap( true );
1079 aCompDlg->myBadMeshBtn->show();
1080 aCompDlg->myBadMeshToGroupBtn->show();
1083 aCompDlg->myBadMeshBtn->hide();
1084 aCompDlg->myBadMeshToGroupBtn->hide();
1086 tbl->setCurrentCell(0,0);
1087 currentCellChanged(); // to update buttons
1090 // show dialog and wait, becase Compute can be invoked from Preview operation
1091 //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
1095 //================================================================================
1097 * \brief Stops operation
1099 //================================================================================
1101 void SMESHGUI_BaseComputeOp::stopOperation()
1103 SMESHGUI_Operation::stopOperation();
1104 if ( myTShapeDisplayer )
1105 myTShapeDisplayer->SetVisibility( false );
1106 if ( myBadMeshDisplayer ) {
1107 myBadMeshDisplayer->SetVisibility( false );
1108 // delete it in order not to have problems at its destruction when the viewer
1109 // where it worked is dead due to e.g. study closing
1110 delete myBadMeshDisplayer;
1111 myBadMeshDisplayer = 0;
1113 myIObject.Nullify();
1116 //================================================================================
1118 * \brief publish selected sub-shape
1120 //================================================================================
1122 void SMESHGUI_BaseComputeOp::onPublishShape()
1124 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
1125 SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
1128 SMESH::getSelectedRows( table(), rows );
1130 foreach ( row, rows )
1132 int curSub = table()->item(row, COL_SHAPEID)->text().toInt();
1133 GEOM::GEOM_Object_wrap shape = SMESH::getSubShape( curSub, myMainShape );
1134 if ( !shape->_is_nil() && ! SMESH::getSubShapeSO( curSub, myMainShape ))
1136 if ( !SMESH::getSubShapeSO( 1, myMainShape )) // the main shape not published
1138 QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( myMainShape, "MAIN_SHAPE" ));
1139 SALOMEDS::SObject_wrap so =
1140 geomGen->AddInStudy( study, myMainShape, name.toLatin1().data(), GEOM::GEOM_Object::_nil());
1141 // look for myMainShape in the table
1142 for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
1143 if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
1144 if ( so->_is_nil() ) {
1145 CORBA::String_var name = so->GetName();
1146 CORBA::String_var entry = so->GetID();
1147 table()->item( r, COL_SHAPE )->setText( name.in() );
1148 table()->item( r, COL_PUBLISHED )->setText( entry.in() );
1153 if ( curSub == 1 ) continue;
1155 QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( shape, "ERROR_SHAPE" ));
1156 SALOMEDS::SObject_wrap so = geomGen->AddInStudy( study, shape, name.toLatin1().data(), myMainShape);
1157 if ( !so->_is_nil() ) {
1158 CORBA::String_var name = so->GetName();
1159 CORBA::String_var entry = so->GetID();
1160 table()->item( row, COL_SHAPE )->setText( name.in() );
1161 table()->item( row, COL_PUBLISHED )->setText( entry.in() );
1165 getSMESHGUI()->getApp()->updateObjectBrowser();
1166 currentCellChanged(); // to update buttons
1169 //================================================================================
1171 * \brief show mesh elements preventing computation of a submesh of current row
1173 //================================================================================
1175 void SMESHGUI_BaseComputeOp::onShowBadMesh()
1177 myTShapeDisplayer->SetVisibility( false );
1179 if ( SMESH::getSelectedRows( table(), rows ) == 1 ) {
1180 bool hasBadMesh = ( !table()->item(rows.front(), COL_BAD_MESH)->text().isEmpty() );
1182 int curSub = table()->item(rows.front(), COL_SHAPEID)->text().toInt();
1183 SMESHGUI* gui = getSMESHGUI();
1184 SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
1185 SVTK_ViewWindow* view = SMESH::GetViewWindow( gui );
1186 if ( myBadMeshDisplayer ) delete myBadMeshDisplayer;
1187 myBadMeshDisplayer = new SMESHGUI_MeshEditPreview( view );
1188 SMESH::MeshPreviewStruct_var aMeshData = gen->GetBadInputElements(myMesh,curSub);
1189 double aPointSize = SMESH::GetFloat("SMESH:node_size",3);
1190 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
1191 vtkProperty* prop = vtkProperty::New();
1192 prop->SetLineWidth( aLineWidth * 3 );
1193 prop->SetPointSize( aPointSize * 3 );
1194 prop->SetColor( 250, 0, 250 );
1195 myBadMeshDisplayer->GetActor()->SetProperty( prop );
1196 myBadMeshDisplayer->SetData( aMeshData._retn() );
1202 //================================================================================
1204 * \brief create groups of bad mesh elements preventing computation of a submesh of current row
1206 //================================================================================
1208 void SMESHGUI_BaseComputeOp::onGroupOfBadMesh()
1211 SMESH::getSelectedRows( table(), rows );
1213 foreach ( row, rows )
1215 bool hasBadMesh = ( !table()->item(row, COL_BAD_MESH)->text().isEmpty() );
1217 int curSub = table()->item(rows.front(), COL_SHAPEID)->text().toInt();
1218 QString grName = table()->item(rows.front(), COL_SHAPE)->text();
1219 if ( grName.isEmpty() ) grName = "bad mesh";
1220 else grName = "bad mesh of " + grName;
1221 SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
1222 SMESH::ListOfGroups_var groups
1223 ( gen->MakeGroupsOfBadInputElements(myMesh,curSub,grName.toLatin1().data()) );
1224 update( UF_ObjBrowser | UF_Model );
1225 if( LightApp_Application* anApp = dynamic_cast<LightApp_Application*>( application() ))
1227 QStringList anEntryList;
1228 for ( size_t i = 0; i < groups->length(); ++i )
1229 if ( _PTR(SObject) so = SMESH::FindSObject( groups[i] ))
1230 anEntryList.append( so->GetID().c_str() );
1232 if ( !anEntryList.isEmpty())
1233 anApp->browseObjects( anEntryList, true, false );
1239 //================================================================================
1241 * \brief SLOT called when a selected cell in table() changed
1243 //================================================================================
1245 void SMESHGUI_BaseComputeOp::currentCellChanged()
1247 myTShapeDisplayer->SetVisibility( false );
1248 if ( myBadMeshDisplayer )
1249 myBadMeshDisplayer->SetVisibility( false );
1251 bool publishEnable = 0, showEnable = 0, showOnly = 1, hasBadMesh = 0;
1253 int nbSelected = SMESH::getSelectedRows( table(), rows );
1255 foreach ( row, rows )
1257 bool hasData = ( !table()->item( row, COL_SHAPE )->text().isEmpty() );
1258 bool isPublished = ( !table()->item( row, COL_PUBLISHED )->text().isEmpty() );
1259 if ( hasData && !isPublished )
1260 publishEnable = true;
1262 int curSub = table()->item( row, COL_SHAPEID )->text().toInt();
1263 bool prsReady = myTShapeDisplayer->HasReadyActorsFor( curSub, myMainShape );
1265 myTShapeDisplayer->Show( curSub, myMainShape, showOnly );
1272 if ( !table()->item(row, COL_BAD_MESH)->text().isEmpty() )
1275 myCompDlg->myPublishBtn->setEnabled( publishEnable );
1276 myCompDlg->myShowBtn ->setEnabled( showEnable );
1277 myCompDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 ));
1280 //================================================================================
1282 * \brief update preview
1284 //================================================================================
1286 void SMESHGUI_BaseComputeOp::onPreviewShape()
1288 if ( myTShapeDisplayer )
1290 SUIT_OverrideCursor aWaitCursor;
1292 SMESH::getSelectedRows( table(), rows );
1294 bool showOnly = true;
1296 foreach ( row, rows )
1298 int curSub = table()->item( row, COL_SHAPEID )->text().toInt();
1300 myTShapeDisplayer->Show( curSub, myMainShape, showOnly );
1304 currentCellChanged(); // to update buttons
1308 //================================================================================
1312 //================================================================================
1314 SMESHGUI_BaseComputeOp::~SMESHGUI_BaseComputeOp()
1318 delete myTShapeDisplayer;
1319 if ( myBadMeshDisplayer )
1320 delete myBadMeshDisplayer;
1323 //================================================================================
1325 * \brief Gets dialog of compute operation
1326 * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation
1328 //================================================================================
1330 SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::computeDlg() const
1334 SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
1335 me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), false );
1336 // connect signals and slots
1337 connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
1338 connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
1339 connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
1340 connect(myCompDlg->myBadMeshToGroupBtn, SIGNAL (clicked()), SLOT(onGroupOfBadMesh()));
1342 QTableWidget* aTable = me->table();
1343 connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
1344 connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));
1349 //================================================================================
1351 * \brief returns from compute mesh result dialog
1353 //================================================================================
1355 bool SMESHGUI_BaseComputeOp::onApply()
1360 //================================================================================
1362 * \brief Return a table
1364 //================================================================================
1366 QTableWidget* SMESHGUI_BaseComputeOp::table()
1368 return myCompDlg->myTable;
1372 //================================================================================
1374 * \brief Constructor
1376 //================================================================================
1378 SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
1379 : SMESHGUI_BaseComputeOp()
1384 //================================================================================
1386 * \brief Desctructor
1388 //================================================================================
1390 SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp()
1394 //================================================================================
1396 * \brief perform it's intention action: compute mesh
1398 //================================================================================
1400 void SMESHGUI_ComputeOp::startOperation()
1402 SMESHGUI_BaseComputeOp::startOperation();
1403 if (myMesh->_is_nil())
1408 //================================================================================
1410 * \brief check the same operations on the same mesh
1412 //================================================================================
1414 bool SMESHGUI_BaseComputeOp::isValid( SUIT_Operation* theOp ) const
1416 SMESHGUI_BaseComputeOp* baseOp = dynamic_cast<SMESHGUI_BaseComputeOp*>( theOp );
1418 if ( !myMesh->_is_nil() && baseOp ) {
1419 SMESH::SMESH_Mesh_var aMesh = baseOp->getMesh();
1420 if ( !aMesh->_is_nil() && aMesh->GetId() == myMesh->GetId() ) ret = false;
1425 //================================================================================
1427 * \brief Gets dialog of this operation
1428 * \retval LightApp_Dialog* - pointer to dialog of this operation
1430 //================================================================================
1432 LightApp_Dialog* SMESHGUI_ComputeOp::dlg() const
1434 return computeDlg();
1437 //================================================================================
1439 * \brief Constructor
1441 //================================================================================
1443 SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp()
1444 : SMESHGUI_BaseComputeOp(),
1448 myPreviewDisplayer( 0 )
1450 myHelpFileName = "constructing_meshes_page.html#preview_mesh_anchor";
1453 //================================================================================
1457 //================================================================================
1459 SMESHGUI_PrecomputeOp::~SMESHGUI_PrecomputeOp()
1466 if ( myPreviewDisplayer )
1467 delete myPreviewDisplayer;
1468 myPreviewDisplayer = 0;
1471 //================================================================================
1473 * \brief Gets current dialog of this operation
1474 * \retval LightApp_Dialog* - pointer to dialog of this operation
1476 //================================================================================
1478 LightApp_Dialog* SMESHGUI_PrecomputeOp::dlg() const
1483 //================================================================================
1485 * \brief perform it's intention action: prepare data
1487 //================================================================================
1489 void SMESHGUI_PrecomputeOp::startOperation()
1493 myDlg = new SMESHGUI_PrecomputeDlg( desktop() );
1496 connect( myDlg, SIGNAL( preview() ), this, SLOT( onPreview() ) );
1497 connect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onCompute() ) );
1498 connect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onCompute() ) );
1500 myActiveDlg = myDlg;
1502 // connect signal to compute dialog. which will be shown after Compute mesh operation
1503 SMESHGUI_ComputeDlg* cmpDlg = computeDlg();
1506 // disconnect signals
1507 disconnect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1508 disconnect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1509 disconnect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
1510 disconnect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
1511 disconnect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
1514 if( cmpDlg->testButtonFlags( QtxDialog::OK ) )
1515 connect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1516 if( cmpDlg->testButtonFlags( QtxDialog::Apply ) )
1517 connect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1518 if( cmpDlg->testButtonFlags( QtxDialog::Help ) )
1519 connect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
1520 if( cmpDlg->testButtonFlags( QtxDialog::Cancel ) )
1521 connect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
1522 if( cmpDlg->testButtonFlags( QtxDialog::Close ) )
1523 connect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
1526 SMESHGUI_BaseComputeOp::startOperation();
1527 if (myMesh->_is_nil())
1530 if (myDlg->getPreviewMode() == -1)
1532 // nothing to preview
1533 SUIT_MessageBox::warning(desktop(),
1534 tr("SMESH_WRN_WARNING"),
1535 tr("SMESH_WRN_NOTHING_PREVIEW"));
1540 // disconnect slot from preview dialog to have Apply from results of compute operation only
1541 disconnect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1542 disconnect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1547 //================================================================================
1549 * \brief Stops operation
1551 //================================================================================
1553 void SMESHGUI_PrecomputeOp::stopOperation()
1555 if ( myPreviewDisplayer )
1557 myPreviewDisplayer->SetVisibility( false );
1558 delete myPreviewDisplayer;
1559 myPreviewDisplayer = 0;
1561 myMapShapeId.clear();
1562 SMESHGUI_BaseComputeOp::stopOperation();
1565 //================================================================================
1567 * \brief reinitialize dialog after operaiton become active again
1569 //================================================================================
1571 void SMESHGUI_PrecomputeOp::resumeOperation()
1573 if ( myActiveDlg == myDlg )
1575 SMESHGUI_BaseComputeOp::resumeOperation();
1578 //================================================================================
1580 * \brief perform it's intention action: reinitialise dialog
1582 //================================================================================
1584 void SMESHGUI_PrecomputeOp::initDialog()
1588 QMap<int, int> modeMap;
1589 _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
1590 getAssignedAlgos( pMesh, modeMap );
1591 if ( modeMap.contains( SMESH::DIM_3D ) )
1593 if ( modeMap.contains( SMESH::DIM_2D ) )
1594 modes.append( SMESH::DIM_2D );
1595 if ( modeMap.contains( SMESH::DIM_1D ) )
1596 modes.append( SMESH::DIM_1D );
1598 else if ( modeMap.contains( SMESH::DIM_2D ) )
1600 if ( modeMap.contains( SMESH::DIM_1D ) )
1601 modes.append( SMESH::DIM_1D );
1604 myOrderMgr = new SMESHGUI_MeshOrderMgr( myDlg->getMeshOrderBox() );
1605 myOrderMgr->SetMesh( myMesh );
1606 bool isOrder = myOrderMgr->GetMeshOrder(myPrevOrder);
1607 myDlg->getMeshOrderBox()->setShown(isOrder);
1613 myDlg->setPreviewModes( modes );
1616 //================================================================================
1618 * \brief detect asigned mesh algorithms
1620 //================================================================================
1622 void SMESHGUI_PrecomputeOp::getAssignedAlgos(_PTR(SObject) theMesh,
1623 QMap<int,int>& theModeMap)
1625 _PTR(SObject) aHypRoot;
1626 _PTR(GenericAttribute) anAttr;
1627 int aPart = SMESH::Tag_RefOnAppliedAlgorithms;
1628 if ( theMesh && theMesh->FindSubObject( aPart, aHypRoot ) )
1630 _PTR(ChildIterator) anIter =
1631 SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
1632 for ( ; anIter->More(); anIter->Next() )
1634 _PTR(SObject) anObj = anIter->Value();
1635 _PTR(SObject) aRefObj;
1636 if ( anObj->ReferencedObject( aRefObj ) )
1641 if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
1643 CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
1644 if ( CORBA::is_nil( aVar ) )
1647 for( int dim = SMESH::DIM_1D; dim <= SMESH::DIM_3D; dim++ )
1649 SMESH::SMESH_Algo_var algo;
1651 case SMESH::DIM_1D: algo = SMESH::SMESH_1D_Algo::_narrow( aVar ); break;
1652 case SMESH::DIM_2D: algo = SMESH::SMESH_2D_Algo::_narrow( aVar ); break;
1653 case SMESH::DIM_3D: algo = SMESH::SMESH_3D_Algo::_narrow( aVar ); break;
1656 if ( !algo->_is_nil() )
1657 theModeMap[ dim ] = 0;
1664 //================================================================================
1666 * \brief perform it's intention action: compute mesh
1668 //================================================================================
1670 void SMESHGUI_PrecomputeOp::onCompute()
1673 if (myOrderMgr && myOrderMgr->IsOrderChanged())
1674 myOrderMgr->SetMeshOrder();
1675 myMapShapeId.clear();
1676 myActiveDlg = computeDlg();
1680 //================================================================================
1682 * \brief perform it's intention action: compute mesh
1684 //================================================================================
1686 void SMESHGUI_PrecomputeOp::onCancel()
1688 QObject* curDlg = sender();
1689 if ( curDlg == computeDlg() && myActiveDlg == myDlg )
1691 // return from error messages
1696 bool isRestoreOrder = false;
1697 if ( myActiveDlg == myDlg && !myMesh->_is_nil() && myMapShapeId.count() )
1699 // ask to remove already computed mesh elements
1700 if ( SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
1701 tr( "CLEAR_SUBMESH_QUESTION" ),
1702 tr( "SMESH_BUT_DELETE" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0 )
1704 // remove all submeshes for collected shapes
1705 QMap<int,int>::const_iterator it = myMapShapeId.constBegin();
1706 for ( ; it != myMapShapeId.constEnd(); ++it )
1707 myMesh->ClearSubMesh( *it );
1708 isRestoreOrder = true;
1712 // return previous mesh order
1713 if (myOrderMgr && myOrderMgr->IsOrderChanged()) {
1714 if (!isRestoreOrder)
1716 (SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
1717 tr( "SMESH_REJECT_MESH_ORDER" ),
1718 tr( "SMESH_BUT_YES" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0);
1720 myOrderMgr->SetMeshOrder(myPrevOrder);
1726 myMapShapeId.clear();
1727 SMESHGUI_BaseComputeOp::onCancel();
1730 //================================================================================
1732 * \brief perform it's intention action: preview mesh
1734 //================================================================================
1736 void SMESHGUI_PrecomputeOp::onPreview()
1738 if ( !myDlg || myMesh->_is_nil() || myMainShape->_is_nil() )
1741 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
1745 // set modified submesh priority if any
1746 if (myOrderMgr && myOrderMgr->IsOrderChanged())
1747 myOrderMgr->SetMeshOrder();
1749 // Compute preview of mesh,
1750 // i.e. compute mesh till indicated dimension
1751 int dim = myDlg->getPreviewMode();
1753 SMESH::MemoryReserve aMemoryReserve;
1755 SMESH::compute_error_array_var aCompErrors;
1758 bool computeFailed = true, memoryLack = false;
1760 SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
1761 aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
1763 SMESHGUI* gui = getSMESHGUI();
1764 SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
1765 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
1766 if ( errors->length() > 0 ) {
1767 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
1770 SUIT_OverrideCursor aWaitCursor;
1772 SVTK_ViewWindow* view = SMESH::GetViewWindow( gui );
1773 if ( myPreviewDisplayer ) delete myPreviewDisplayer;
1774 myPreviewDisplayer = new SMESHGUI_MeshEditPreview( view );
1776 SMESH::long_array_var aShapesId = new SMESH::long_array();
1778 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1782 SMESH::MeshPreviewStruct_var previewData =
1783 gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId);
1785 SMESH::MeshPreviewStruct* previewRes = previewData._retn();
1786 if ( previewRes && previewRes->nodesXYZ.length() > 0 )
1788 computeFailed = false;
1789 myPreviewDisplayer->SetData( previewRes );
1790 // append shape indeces with computed mesh entities
1791 for ( int i = 0, n = aShapesId->length(); i < n; i++ )
1792 myMapShapeId[ aShapesId[ i ] ] = 0;
1795 myPreviewDisplayer->SetVisibility(false);
1797 catch(const SALOME::SALOME_Exception & S_ex){
1799 myPreviewDisplayer->SetVisibility(false);
1803 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1806 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
1807 // check if there are memory problems
1808 for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
1809 memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
1811 catch(const SALOME::SALOME_Exception & S_ex){
1816 aMemoryReserve.release();
1818 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
1819 bool noHypoError = ( aHypErrors.isEmpty() );
1821 SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( gui );
1822 int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
1824 bool isShowError = true;
1825 switch( aNotifyMode ) {
1826 case 0: // show the mesh computation result dialog NEVER
1827 isShowError = false;
1829 case 1: // show the mesh computation result dialog if there are some errors
1830 default: // show the result dialog after each mesh computation
1831 if ( !computeFailed && !memoryLack && noCompError && noHypoError )
1832 isShowError = false;
1836 aWaitCursor.suspend();
1841 aCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
1842 showComputeResult( memoryLack, noCompError, aCompErrors, noHypoError, aHypErrors );
1847 //================================================================================
1849 * \brief Constructor
1851 //================================================================================
1853 SMESHGUI_PrecomputeDlg::SMESHGUI_PrecomputeDlg( QWidget* parent )
1854 : SMESHGUI_Dialog( parent, false, false, OK | Cancel | Help ),
1857 setWindowTitle( tr( "CAPTION" ) );
1859 setButtonText( OK, tr( "COMPUTE" ) );
1860 QFrame* main = mainFrame();
1862 QVBoxLayout* layout = new QVBoxLayout( main );
1864 myOrderBox = new SMESHGUI_MeshOrderBox( main );
1865 layout->addWidget(myOrderBox);
1867 QFrame* frame = new QFrame( main );
1868 layout->setMargin(0); layout->setSpacing(0);
1869 layout->addWidget( frame );
1871 QHBoxLayout* frameLay = new QHBoxLayout( frame );
1872 frameLay->setMargin(0); frameLay->setSpacing(SPACING);
1874 myPreviewMode = new QtxComboBox( frame );
1875 frameLay->addWidget( myPreviewMode );
1877 myPreviewBtn = new QPushButton( tr( "PREVIEW" ), frame );
1878 frameLay->addWidget( myPreviewBtn );
1880 connect( myPreviewBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( preview() ) );
1883 //================================================================================
1887 //================================================================================
1889 SMESHGUI_PrecomputeDlg::~SMESHGUI_PrecomputeDlg()
1893 //================================================================================
1895 * \brief Sets available preview modes
1897 //================================================================================
1899 void SMESHGUI_PrecomputeDlg::setPreviewModes( const QList<int>& theModes )
1901 myPreviewMode->clear();
1902 QList<int>::const_iterator it = theModes.constBegin();
1903 for ( int i = 0; it != theModes.constEnd(); ++it, i++ )
1905 QString mode = QString( "PREVIEW_%1" ).arg( *it );
1906 myPreviewMode->addItem( tr( mode.toLatin1().data() ) );
1907 myPreviewMode->setId( i, *it );
1909 myPreviewBtn->setEnabled( !theModes.isEmpty() );
1912 //================================================================================
1914 * \brief Returns current preview mesh mode
1916 //================================================================================
1918 int SMESHGUI_PrecomputeDlg::getPreviewMode() const
1920 return myPreviewMode->currentId();
1923 //================================================================================
1925 * \brief Returns current preview mesh mode
1927 //================================================================================
1929 SMESHGUI_MeshOrderBox* SMESHGUI_PrecomputeDlg::getMeshOrderBox() const
1935 //================================================================================
1937 * \brief Constructor
1939 //================================================================================
1941 SMESHGUI_EvaluateOp::SMESHGUI_EvaluateOp()
1942 : SMESHGUI_BaseComputeOp()
1947 //================================================================================
1949 * \brief Desctructor
1951 //================================================================================
1953 SMESHGUI_EvaluateOp::~SMESHGUI_EvaluateOp()
1957 //================================================================================
1959 * \brief perform it's intention action: compute mesh
1961 //================================================================================
1963 void SMESHGUI_EvaluateOp::startOperation()
1965 SMESHGUI_BaseComputeOp::evaluateDlg();
1966 SMESHGUI_BaseComputeOp::startOperation();
1967 if (myMesh->_is_nil())
1972 //================================================================================
1974 * \brief Gets dialog of this operation
1975 * \retval LightApp_Dialog* - pointer to dialog of this operation
1977 //================================================================================
1979 LightApp_Dialog* SMESHGUI_EvaluateOp::dlg() const
1981 return evaluateDlg();
1984 //================================================================================
1986 * \brief evaluateMesh()
1988 //================================================================================
1990 void SMESHGUI_BaseComputeOp::evaluateMesh()
1994 SMESH::MemoryReserve aMemoryReserve;
1996 SMESH::compute_error_array_var aCompErrors;
1999 bool evaluateFailed = true, memoryLack = false;
2000 SMESH::long_array_var aRes;
2002 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
2003 if ( !aMeshSObj ) // IPAL21340
2006 bool hasShape = myMesh->HasShapeToMesh();
2007 bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
2010 myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
2011 SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
2012 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
2013 if ( errors->length() > 0 ) {
2014 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
2016 SUIT_OverrideCursor aWaitCursor;
2018 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2021 aRes = gen->Evaluate(myMesh, myMainShape);
2023 catch(const SALOME::SALOME_Exception & S_ex){
2028 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2031 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
2033 catch(const SALOME::SALOME_Exception & S_ex){
2039 aMemoryReserve.release();
2041 evaluateFailed = ( aCompErrors->length() > 0 );
2042 myCompDlg->setWindowTitle(tr( evaluateFailed ? "SMESH_WRN_EVALUATE_FAILED" : "SMESH_EVALUATE_SUCCEED"));
2046 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
2047 bool noHypoError = ( aHypErrors.isEmpty() );
2049 //SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
2050 //int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
2052 bool isShowResultDlg = true;
2054 //switch( aNotifyMode ) {
2055 //case 0: // show the mesh computation result dialog NEVER
2056 //isShowResultDlg = false;
2059 //case 1: // show the mesh computation result dialog if there are some errors
2060 //if ( memoryLack || !noHypoError )
2061 // isShowResultDlg = true;
2064 // isShowResultDlg = false;
2068 //default: // show the result dialog after each mesh computation
2069 //isShowResultDlg = true;
2073 if ( isShowResultDlg )
2074 showEvaluateResult( aRes, memoryLack, noCompError, aCompErrors,
2075 noHypoError, aHypErrors);
2079 void SMESHGUI_BaseComputeOp::showEvaluateResult(const SMESH::long_array& theRes,
2080 const bool theMemoryLack,
2081 const bool theNoCompError,
2082 SMESH::compute_error_array_var& theCompErrors,
2083 const bool theNoHypoError,
2084 const QString& theHypErrors)
2086 bool hasShape = myMesh->HasShapeToMesh();
2087 SMESHGUI_ComputeDlg* aCompDlg = evaluateDlg();
2088 aCompDlg->myMemoryLackGroup->hide();
2090 if ( theMemoryLack )
2092 aCompDlg->myMemoryLackGroup->show();
2093 aCompDlg->myFullInfo->hide();
2094 aCompDlg->myBriefInfo->hide();
2095 aCompDlg->myHypErrorGroup->hide();
2096 aCompDlg->myCompErrorGroup->hide();
2098 else if ( theNoCompError && theNoHypoError )
2100 aCompDlg->myFullInfo->SetMeshInfo( theRes );
2101 aCompDlg->myFullInfo->show();
2102 aCompDlg->myBriefInfo->hide();
2103 aCompDlg->myHypErrorGroup->hide();
2104 aCompDlg->myCompErrorGroup->hide();
2108 QTableWidget* tbl = aCompDlg->myTable;
2109 aCompDlg->myBriefInfo->SetMeshInfo( theRes );
2110 aCompDlg->myBriefInfo->show();
2111 aCompDlg->myFullInfo->hide();
2113 if ( theNoHypoError ) {
2114 aCompDlg->myHypErrorGroup->hide();
2117 aCompDlg->myHypErrorGroup->show();
2118 aCompDlg->myHypErrorLabel->setText( theHypErrors );
2121 if ( theNoCompError ) {
2122 aCompDlg->myCompErrorGroup->hide();
2125 aCompDlg->myCompErrorGroup->show();
2127 aCompDlg->myPublishBtn->hide();
2128 aCompDlg->myShowBtn->hide();
2130 // fill table of errors
2131 tbl->setRowCount( theCompErrors->length() );
2132 if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
2133 else tbl->showColumn( COL_SHAPE );
2134 tbl->setColumnWidth( COL_ERROR, 200 );
2136 bool hasBadMesh = false;
2137 for ( int row = 0; row < theCompErrors->length(); ++row )
2139 SMESH::ComputeError & err = theCompErrors[ row ];
2141 QString text = err.algoName.in();
2142 if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
2143 else tbl->item( row, COL_ALGO )->setText( text );
2145 text = SMESH::errorText( err.code, err.comment.in() );
2146 if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
2147 else tbl->item( row, COL_ERROR )->setText( text );
2149 text = QString("%1").arg( err.subShapeID );
2150 if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
2151 else tbl->item( row, COL_SHAPEID )->setText( text );
2153 text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
2154 if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
2155 else tbl->item( row, COL_SHAPE )->setText( text );
2157 text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
2158 if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
2159 else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled
2161 text = err.hasBadMesh ? "hasBadMesh" : "";
2162 if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
2163 else tbl->item( row, COL_BAD_MESH )->setText( text );
2164 if ( err.hasBadMesh ) hasBadMesh = true;
2166 //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
2167 tbl->resizeRowToContents( row );
2169 tbl->resizeColumnToContents( COL_ALGO );
2170 tbl->resizeColumnToContents( COL_SHAPE );
2171 tbl->setWordWrap( true );
2174 aCompDlg->myBadMeshBtn->show();
2176 aCompDlg->myBadMeshBtn->hide();
2178 tbl->setCurrentCell(0,0);
2179 currentCellChanged(); // to update buttons
2182 // show dialog and wait, becase Compute can be invoked from Preview operation
2183 //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
2188 //================================================================================
2190 * \brief Gets dialog of evaluate operation
2191 * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation
2193 //================================================================================
2195 SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::evaluateDlg() const
2199 SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
2200 me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), true );
2201 // connect signals and slots
2202 connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
2203 connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
2204 connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
2205 QTableWidget* aTable = me->table();
2206 connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
2207 connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));