1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI_ComputeDlg.cxx
23 // Author : Edward AGAPOV, Open CASCADE S.A.S.
26 #include "SMESHGUI_ComputeDlg.h"
29 #include "SMESHGUI_GEOMGenUtils.h"
30 #include "SMESHGUI_MeshUtils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMESHGUI_HypothesesUtils.h"
33 #include "SMESHGUI_MeshEditPreview.h"
34 #include "SMESH_ActorUtils.h"
36 #include <SMDS_SetIterator.hxx>
37 #include <SMDS_Mesh.hxx>
39 // SALOME GEOM includes
41 #include <GEOM_Actor.h>
43 // SALOME GUI includes
44 #include <LightApp_SelectionMgr.h>
45 #include <LightApp_UpdateFlags.h>
46 #include <SALOME_ListIO.hxx>
47 #include <SVTK_ViewWindow.h>
48 #include <SVTK_ViewModel.h>
49 #include <SalomeApp_Application.h>
50 #include <SUIT_ResourceMgr.h>
51 #include <SUIT_OverrideCursor.h>
52 #include <SUIT_MessageBox.h>
53 #include <SUIT_Desktop.h>
54 #include <QtxComboBox.h>
56 // SALOME KERNEL includes
57 #include <SALOMEDS_SObject.hxx>
58 #include <SALOMEDSClient_SObject.hxx>
61 #include <BRep_Tool.hxx>
63 #include <TopExp_Explorer.hxx>
64 #include <TopTools_IndexedMapOfShape.hxx>
67 #include <TopLoc_Location.hxx>
68 #include <Poly_Triangulation.hxx>
69 #include <Bnd_Box.hxx>
70 #include <BRepBndLib.hxx>
71 #include <BRepMesh_IncrementalMesh.hxx>
73 #include <Standard_ErrorHandler.hxx>
77 #include <QPushButton>
79 #include <QRadioButton>
80 #include <QTableWidget>
81 #include <QHeaderView>
82 #include <QGridLayout>
83 #include <QHBoxLayout>
84 #include <QVBoxLayout>
85 #include <QButtonGroup>
88 #include <vtkProperty.h>
97 #define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
99 static void addSeparator( QWidget* parent )
101 QGridLayout* l = qobject_cast<QGridLayout*>( parent->layout() );
102 int row = l->rowCount();
103 int cols = l->columnCount();
104 for ( int i = 0; i < cols; i++ ) {
105 QFrame* hline = new QFrame( parent );
106 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
107 l->addWidget( hline, row, i );
112 COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
115 //using namespace SMESH;
119 //=============================================================================
121 * \brief Allocate some memory at construction and release it at destruction.
122 * Is used to be able to continue working after mesh generation or visualization
123 * break due to lack of memory
125 //=============================================================================
130 MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M
131 void release() { delete [] myBuf; myBuf = 0; }
132 ~MemoryReserve() { release(); }
135 // =========================================================================================
137 * \brief Class showing shapes without publishing
139 // =========================================================================================
141 class TShapeDisplayer
144 // -----------------------------------------------------------------------
145 TShapeDisplayer(): myViewWindow(0)
147 myProperty = vtkProperty::New();
148 myProperty->SetRepresentationToWireframe();
149 myProperty->SetColor( 250, 0, 250 );
150 myProperty->SetAmbientColor( 250, 0, 250 );
151 myProperty->SetDiffuseColor( 250, 0, 250 );
152 //myProperty->SetSpecularColor( 250, 0, 250 );
153 myProperty->SetLineWidth( 5 );
155 // -----------------------------------------------------------------------
159 myProperty->Delete();
161 // -----------------------------------------------------------------------
164 if ( hasViewWindow() ) {
165 TActorIterator actorIt = actorIterator();
166 while ( actorIt.more() )
167 if (VTKViewer_Actor* anActor = actorIt.next()) {
168 myViewWindow->RemoveActor( anActor );
172 myIndexToShape.Clear();
174 myShownActors.clear();
177 // -----------------------------------------------------------------------
178 void SetVisibility (bool theVisibility)
180 TActorIterator actorIt = shownIterator();
181 while ( actorIt.more() )
182 if (VTKViewer_Actor* anActor = actorIt.next())
183 anActor->SetVisibility(theVisibility);
184 SMESH::RepaintCurrentView();
186 // -----------------------------------------------------------------------
187 bool HasReadyActorsFor (int subShapeID, GEOM::GEOM_Object_var aMainShape )
189 std::string mainEntry;
190 if ( !aMainShape->_is_nil() )
191 mainEntry = aMainShape->GetStudyEntry();
192 return ( myMainEntry == mainEntry &&
193 myBuiltSubs.find( subShapeID ) != myBuiltSubs.end() );
195 // -----------------------------------------------------------------------
196 void Show( int subShapeID, GEOM::GEOM_Object_var aMainShape, bool only = false)
198 SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() );
199 std::string mainEntry;
200 if ( !aMainShape->_is_nil() )
201 mainEntry = aMainShape->GetStudyEntry();
202 if ( myMainEntry != mainEntry || aViewWindow != myViewWindow ) { // remove actors
205 if ( !aMainShape->_is_nil() && GEOMBase::GetShape(aMainShape, aShape)) {
206 checkTriangulation( aShape );
207 TopExp::MapShapes(aShape, myIndexToShape);
208 myActors.resize( myIndexToShape.Extent(), 0 );
209 myShownActors.reserve( myIndexToShape.Extent() );
211 myMainEntry = mainEntry;
212 myViewWindow = aViewWindow;
214 if ( only ) { // hide shown actors
215 TActorIterator actorIt = shownIterator();
216 while ( actorIt.more() )
217 if (VTKViewer_Actor* anActor = actorIt.next())
218 anActor->SetVisibility(false);
219 myShownActors.clear();
221 // find actors to show
222 TopoDS_Shape aShape = myIndexToShape( subShapeID );
223 if ( !aShape.IsNull() ) {
224 TopAbs_ShapeEnum type( aShape.ShapeType() >= TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE );
225 for ( TopExp_Explorer exp( aShape, type ); exp.More(); exp.Next() ) {
226 //checkTriangulation( exp.Current() );
227 if ( GEOM_Actor* anActor = getActor( exp.Current() ))
228 myShownActors.push_back( anActor );
230 if ( type == TopAbs_FACE ) {
231 for ( TopExp_Explorer exp( aShape, TopAbs_EDGE ); exp.More(); exp.Next() ) {
232 const TopoDS_Edge & edge = TopoDS::Edge( exp.Current() );
233 if ( !BRep_Tool::Degenerated( edge ))
234 if ( GEOM_Actor* anActor = getActor( exp.Current() ))
235 myShownActors.push_back( anActor );
239 myBuiltSubs.insert( subShapeID );
242 // -----------------------------------------------------------------------
246 typedef std::vector<GEOM_Actor*> TActorVec;
248 TActorVec myShownActors;
249 TopTools_IndexedMapOfShape myIndexToShape;
250 std::string myMainEntry;
251 SVTK_ViewWindow* myViewWindow;
252 vtkProperty* myProperty;
253 std::set<int> myBuiltSubs;
255 // -----------------------------------------------------------------------
256 typedef SMDS_SetIterator< GEOM_Actor*, TActorVec::const_iterator> TActorIterator;
257 TActorIterator actorIterator() {
258 return TActorIterator( myActors.begin(), myActors.end() );
260 TActorIterator shownIterator() {
261 return TActorIterator( myShownActors.begin(), myShownActors.end() );
263 // -----------------------------------------------------------------------
264 GEOM_Actor* getActor(const TopoDS_Shape& shape)
266 int index = myIndexToShape.FindIndex( shape ) - 1;
267 if ( index < 0 || index >= myActors.size() )
269 GEOM_Actor* & actor = myActors[ index ];
271 actor = GEOM_Actor::New();
273 actor->SetShape(shape,0,0);
274 actor->SetProperty(myProperty);
275 actor->SetShadingProperty(myProperty);
276 actor->SetWireframeProperty(myProperty);
277 actor->SetPreviewProperty(myProperty);
278 actor->PickableOff();
279 // if ( shape.ShapeType() == TopAbs_EDGE )
280 // actor->SubShapeOn();
281 myViewWindow->AddActor( actor );
286 // -----------------------------------------------------------------------
287 void checkTriangulation(const TopoDS_Shape& shape)
289 TopLoc_Location aLoc;
290 Standard_Boolean alreadymesh = Standard_True;
291 TopExp_Explorer ex(shape, TopAbs_FACE);
293 for ( ; ex.More(); ex.Next()) {
294 const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
295 Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
296 if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
299 for (ex.Init(shape, TopAbs_EDGE); ex.More(); ex.Next()) {
300 const TopoDS_Edge& edge = TopoDS::Edge(ex.Current());
301 Handle(Poly_Polygon3D) aPoly = BRep_Tool::Polygon3D(edge, aLoc);
302 if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
304 if (alreadymesh) return;
305 // Compute default deflection
307 BRepBndLib::Add(shape, B);
308 Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
309 B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
310 double deflection = Max( aXmax-aXmin, Max ( aYmax-aYmin, aZmax-aZmin)) * 0.01 *4;
311 BRepMesh_IncrementalMesh MESH(shape,deflection);
313 // -----------------------------------------------------------------------
314 bool hasViewWindow() const
316 if ( !myViewWindow ) return false;
318 if ( SalomeApp_Application* anApp = SMESHGUI::GetSMESHGUI()->getApp() )
319 return FindVtkViewWindow( anApp->getViewManager(SVTK_Viewer::Type(), false ),
325 // =========================================================================================
327 * \brief Return text describing an error
329 #define CASE2TEXT(enum) case SMESH::enum: text = QObject::tr( #enum ); break;
330 QString errorText(int errCode, const char* comment)
334 CASE2TEXT( COMPERR_OK );
335 CASE2TEXT( COMPERR_BAD_INPUT_MESH);
336 CASE2TEXT( COMPERR_STD_EXCEPTION );
337 CASE2TEXT( COMPERR_OCC_EXCEPTION );
338 case SMESH::COMPERR_SLM_EXCEPTION: break; // avoid double "Salome exception"
339 CASE2TEXT( COMPERR_EXCEPTION );
340 CASE2TEXT( COMPERR_MEMORY_PB );
341 CASE2TEXT( COMPERR_BAD_SHAPE );
342 case SMESH::COMPERR_ALGO_FAILED:
343 if ( strlen(comment) == 0 )
344 text = QObject::tr("COMPERR_ALGO_FAILED");
347 text = QString("#%1").arg( -errCode );
349 if ( text.length() > 0 ) text += ". ";
350 return text + comment;
352 // -----------------------------------------------------------------------
354 * \brief Return SO of a subshape
356 _PTR(SObject) getSubShapeSO( int subShapeID, GEOM::GEOM_Object_var aMainShape)
358 _PTR(SObject) so = SMESH::FindSObject(aMainShape);
359 if ( subShapeID == 1 || !so )
361 _PTR(ChildIterator) it;
362 if (_PTR(Study) study = SMESH::GetActiveStudyDocument())
363 it = study->NewChildIterator(so);
366 for ( it->InitEx(true); !subSO && it->More(); it->Next() ) {
367 GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( it->Value() );
368 if ( !geom->_is_nil() ) {
369 GEOM::ListOfLong_var list = geom->GetSubShapeIndices();
370 if ( list->length() == 1 && list[0] == subShapeID )
377 // -----------------------------------------------------------------------
379 * \brief Return subshape by ID
381 GEOM::GEOM_Object_ptr getSubShape( int subShapeID, GEOM::GEOM_Object_var aMainShape)
383 GEOM::GEOM_Object_var aSubShape;
384 if ( subShapeID == 1 )
385 aSubShape = aMainShape;
386 else if ( _PTR(SObject) so = getSubShapeSO( subShapeID, aMainShape ))
387 aSubShape = SMESH::SObjectToInterface<GEOM::GEOM_Object>( so );
389 aSubShape = SMESH::GetSubShape( aMainShape, subShapeID );
390 return aSubShape._retn();
392 // -----------------------------------------------------------------------
394 * \brief Return shape type name
396 #define CASE2NAME(enum) case GEOM::enum: name = QObject::tr( "GEOM_" #enum ); break;
397 QString shapeTypeName(GEOM::GEOM_Object_var aShape, const char* dflt = "" )
400 if ( !aShape->_is_nil() ) {
401 switch ( aShape->GetShapeType() ) {
408 CASE2NAME( COMPSOLID );
409 CASE2NAME( COMPOUND );
415 // -----------------------------------------------------------------------
417 * \brief Return text describing a subshape
419 QString shapeText(int subShapeID, GEOM::GEOM_Object_var aMainShape )
422 if ( _PTR(SObject) aSO = getSubShapeSO( subShapeID, aMainShape ))
423 text = aSO->GetName().c_str();
425 text = QString("#%1").arg( subShapeID );
426 QString typeName = shapeTypeName( getSubShape( subShapeID, aMainShape ));
427 if ( typeName.length() )
428 text += QString(" (%1)").arg(typeName);
432 // -----------------------------------------------------------------------
434 * \brief Return a list of selected rows
436 int getSelectedRows(QTableWidget* table, QList<int>& rows)
439 QList<QTableWidgetSelectionRange> selRanges = table->selectedRanges();
440 QTableWidgetSelectionRange range;
441 foreach( range, selRanges )
443 for ( int row = range.topRow(); row <= range.bottomRow(); ++row )
446 if ( rows.isEmpty() && table->currentRow() > -1 )
447 rows.append( table->currentRow() );
455 // =========================================================================================
457 * \brief Box showing mesh info
459 // =========================================================================================
461 SMESHGUI_MeshInfosBox::SMESHGUI_MeshInfosBox(const bool full, QWidget* theParent)
462 : QGroupBox( tr("SMESH_MESHINFO_TITLE"), theParent ), myFull( full )
464 QGridLayout* l = new QGridLayout(this);
465 l->setMargin( MARGIN );
466 l->setSpacing( SPACING );
468 QFont italic = font(); italic.setItalic(true);
469 QFont bold = font(); bold.setBold(true);
475 lab = new QLabel( this );
476 lab->setMinimumWidth(100); lab->setFont( italic );
477 l->addWidget( lab, row, 0 );
479 lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), this );
480 lab->setMinimumWidth(100); lab->setFont( italic );
481 l->addWidget( lab, row, 1 );
483 lab = new QLabel(tr("SMESH_MESHINFO_ORDER1"), this );
484 lab->setMinimumWidth(100); lab->setFont( italic );
485 l->addWidget( lab, row, 2 );
487 lab = new QLabel(tr("SMESH_MESHINFO_ORDER2"), this );
488 lab->setMinimumWidth(100); lab->setFont( italic );
489 l->addWidget( lab, row, 3 );
494 row = l->rowCount(); // retrieve current row count
496 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
497 lab->setFont( bold );
498 l->addWidget( lab, row, 0 );
500 myNbNode = new QLabel( this );
501 l->addWidget( myNbNode, row, 1 );
503 addSeparator(this); // add separator
506 row = l->rowCount(); // retrieve current row count
508 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
509 lab->setFont( bold );
510 l->addWidget( lab, row, 0 );
512 myNbEdge = new QLabel( this );
513 l->addWidget( myNbEdge, row, 1 );
515 myNbLinEdge = new QLabel( this );
516 l->addWidget( myNbLinEdge, row, 2 );
518 myNbQuadEdge = new QLabel( this );
519 l->addWidget( myNbQuadEdge, row, 3 );
521 addSeparator(this); // add separator
524 row = l->rowCount(); // retrieve current row count
526 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
527 lab->setFont( bold );
528 l->addWidget( lab, row, 0 );
530 myNbFace = new QLabel( this );
531 l->addWidget( myNbFace, row, 1 );
533 myNbLinFace = new QLabel( this );
534 l->addWidget( myNbLinFace, row, 2 );
536 myNbQuadFace = new QLabel( this );
537 l->addWidget( myNbQuadFace, row, 3 );
539 row++; // increment row count
541 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
542 l->addWidget( lab, row, 0 );
544 myNbTrai = new QLabel( this );
545 l->addWidget( myNbTrai, row, 1 );
547 myNbLinTrai = new QLabel( this );
548 l->addWidget( myNbLinTrai, row, 2 );
550 myNbQuadTrai = new QLabel( this );
551 l->addWidget( myNbQuadTrai, row, 3 );
553 row++; // increment row count
555 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
556 l->addWidget( lab, row, 0 );
558 myNbQuad = new QLabel( this );
559 l->addWidget( myNbQuad, row, 1 );
561 myNbLinQuad = new QLabel( this );
562 l->addWidget( myNbLinQuad, row, 2 );
564 myNbQuadQuad = new QLabel( this );
565 l->addWidget( myNbQuadQuad, row, 3 );
567 row++; // increment row count
569 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYGONES")), this );
570 l->addWidget( lab, row, 0 );
571 myNbPolyg = new QLabel( this );
572 l->addWidget( myNbPolyg, row, 1 );
574 addSeparator(this); // add separator
577 row = l->rowCount(); // retrieve current row count
579 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
580 lab->setFont( bold );
581 l->addWidget( lab, row, 0 );
583 myNbVolum = new QLabel( this );
584 l->addWidget( myNbVolum, row, 1 );
586 myNbLinVolum = new QLabel( this );
587 l->addWidget( myNbLinVolum, row, 2 );
589 myNbQuadVolum = new QLabel( this );
590 l->addWidget( myNbQuadVolum, row, 3 );
592 row++; // increment row count
594 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
595 l->addWidget( lab, row, 0 );
597 myNbTetra = new QLabel( this );
598 l->addWidget( myNbTetra, row, 1 );
600 myNbLinTetra = new QLabel( this );
601 l->addWidget( myNbLinTetra, row, 2 );
603 myNbQuadTetra = new QLabel( this );
604 l->addWidget( myNbQuadTetra, row, 3 );
606 row++; // increment row count
608 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
609 l->addWidget( lab, row, 0 );
611 myNbHexa = new QLabel( this );
612 l->addWidget( myNbHexa, row, 1 );
614 myNbLinHexa = new QLabel( this );
615 l->addWidget( myNbLinHexa, row, 2 );
617 myNbQuadHexa = new QLabel( this );
618 l->addWidget( myNbQuadHexa, row, 3 );
620 row++; // increment row count
622 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
623 l->addWidget( lab, row, 0 );
625 myNbPyra = new QLabel( this );
626 l->addWidget( myNbPyra, row, 1 );
628 myNbLinPyra = new QLabel( this );
629 l->addWidget( myNbLinPyra, row, 2 );
631 myNbQuadPyra = new QLabel( this );
632 l->addWidget( myNbQuadPyra, row, 3 );
634 row++; // increment row count
636 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
637 l->addWidget( lab, row, 0 );
639 myNbPrism = new QLabel( this );
640 l->addWidget( myNbPrism, row, 1 );
642 myNbLinPrism = new QLabel( this );
643 l->addWidget( myNbLinPrism, row, 2 );
645 myNbQuadPrism = new QLabel( this );
646 l->addWidget( myNbQuadPrism, row, 3 );
648 row++; // increment row count
650 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
651 l->addWidget( lab, row, 0 );
653 myNbPolyh = new QLabel( this );
654 l->addWidget( myNbPolyh, row, 1 );
659 row = l->rowCount(); // retrieve current row count
661 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
662 l->addWidget( lab, row, 0 );
664 myNbNode = new QLabel( this );
665 l->addWidget( myNbNode, row, 1 );
668 row = l->rowCount(); // retrieve current row count
670 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
671 l->addWidget( lab, row, 0 );
673 myNbEdge = new QLabel( this );
674 l->addWidget( myNbEdge, row, 1 );
676 myNbLinEdge = new QLabel( this );
677 l->addWidget( myNbLinEdge, row, 2 );
679 myNbQuadEdge = new QLabel( this );
680 l->addWidget( myNbQuadEdge, row, 3 );
683 row = l->rowCount(); // retrieve current row count
685 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
686 l->addWidget( lab, row, 0 );
688 myNbFace = new QLabel( this );
689 l->addWidget( myNbFace, row, 1 );
691 myNbLinFace = new QLabel( this );
692 l->addWidget( myNbLinFace, row, 2 );
694 myNbQuadFace = new QLabel( this );
695 l->addWidget( myNbQuadFace, row, 3 );
698 row = l->rowCount(); // retrieve current row count
700 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
701 l->addWidget( lab, row, 0 );
703 myNbVolum = new QLabel( this );
704 l->addWidget( myNbVolum, row, 1 );
706 myNbLinVolum = new QLabel( this );
707 l->addWidget( myNbLinVolum, row, 2 );
709 myNbQuadVolum = new QLabel( this );
710 l->addWidget( myNbQuadVolum, row, 3 );
714 // =========================================================================================
716 * \brief Set mesh info
718 // =========================================================================================
720 void SMESHGUI_MeshInfosBox::SetInfoByMesh(SMESH::SMESH_Mesh_var mesh)
722 const SMESH::ElementOrder lin = SMESH::ORDER_LINEAR;
726 myNbNode ->setText( QString("%1").arg( mesh->NbNodes() ));
729 nbTot = mesh->NbEdges(), nbLin = mesh->NbEdgesOfOrder(lin);
730 myNbEdge ->setText( QString("%1").arg( nbTot ));
731 myNbLinEdge ->setText( QString("%1").arg( nbLin ));
732 myNbQuadEdge ->setText( QString("%1").arg( nbTot - nbLin ));
735 nbTot = mesh->NbFaces(), nbLin = mesh->NbFacesOfOrder(lin);
736 myNbFace ->setText( QString("%1").arg( nbTot ));
737 myNbLinFace ->setText( QString("%1").arg( nbLin ));
738 myNbQuadFace ->setText( QString("%1").arg( nbTot - nbLin ));
741 nbTot = mesh->NbVolumes(), nbLin = mesh->NbVolumesOfOrder(lin);
742 myNbVolum ->setText( QString("%1").arg( nbTot ));
743 myNbLinVolum ->setText( QString("%1").arg( nbLin ));
744 myNbQuadVolum->setText( QString("%1").arg( nbTot - nbLin ));
749 nbTot = mesh->NbTriangles(), nbLin = mesh->NbTrianglesOfOrder(lin);
750 myNbTrai ->setText( QString("%1").arg( nbTot ));
751 myNbLinTrai ->setText( QString("%1").arg( nbLin ));
752 myNbQuadTrai ->setText( QString("%1").arg( nbTot - nbLin ));
754 nbTot = mesh->NbQuadrangles(), nbLin = mesh->NbQuadranglesOfOrder(lin);
755 myNbQuad ->setText( QString("%1").arg( nbTot ));
756 myNbLinQuad ->setText( QString("%1").arg( nbLin ));
757 myNbQuadQuad ->setText( QString("%1").arg( nbTot - nbLin ));
759 myNbPolyg ->setText( QString("%1").arg( mesh->NbPolygons() ));
762 nbTot = mesh->NbTetras(), nbLin = mesh->NbTetrasOfOrder(lin);
763 myNbTetra ->setText( QString("%1").arg( nbTot ));
764 myNbLinTetra ->setText( QString("%1").arg( nbLin ));
765 myNbQuadTetra->setText( QString("%1").arg( nbTot - nbLin ));
767 nbTot = mesh->NbHexas(), nbLin = mesh->NbHexasOfOrder(lin);
768 myNbHexa ->setText( QString("%1").arg( nbTot ));
769 myNbLinHexa ->setText( QString("%1").arg( nbLin ));
770 myNbQuadHexa ->setText( QString("%1").arg( nbTot - nbLin ));
772 nbTot = mesh->NbPyramids(), nbLin = mesh->NbPyramidsOfOrder(lin);
773 myNbPyra ->setText( QString("%1").arg( nbTot ));
774 myNbLinPyra ->setText( QString("%1").arg( nbLin ));
775 myNbQuadPyra ->setText( QString("%1").arg( nbTot - nbLin ));
777 nbTot = mesh->NbPrisms(), nbLin = mesh->NbPrismsOfOrder(lin);
778 myNbPrism ->setText( QString("%1").arg( nbTot ));
779 myNbLinPrism ->setText( QString("%1").arg( nbLin ));
780 myNbQuadPrism->setText( QString("%1").arg( nbTot - nbLin ));
782 myNbPolyh ->setText( QString("%1").arg( mesh->NbPolyhedrons() ));
786 // =========================================================================================
788 * \brief Dialog to compute a mesh and show computation errors
790 //=======================================================================
792 SMESHGUI_ComputeDlg::SMESHGUI_ComputeDlg( QWidget* parent, bool ForEval )
793 : SMESHGUI_Dialog( parent, false, true, Close/* | Help*/ )
795 QVBoxLayout* aDlgLay = new QVBoxLayout (mainFrame());
796 aDlgLay->setMargin( 0 );
797 aDlgLay->setSpacing( SPACING );
799 QFrame* aMainFrame = createMainFrame(mainFrame(),ForEval);
801 aDlgLay->addWidget(aMainFrame);
803 aDlgLay->setStretchFactor(aMainFrame, 1);
806 // =========================================================================================
810 //=======================================================================
812 SMESHGUI_ComputeDlg::~SMESHGUI_ComputeDlg()
816 //=======================================================================
817 // function : createMainFrame()
818 // purpose : Create frame containing dialog's fields
819 //=======================================================================
821 QFrame* SMESHGUI_ComputeDlg::createMainFrame (QWidget* theParent, bool ForEval)
823 QFrame* aFrame = new QFrame(theParent);
825 SUIT_ResourceMgr* rm = resourceMgr();
826 QPixmap iconCompute (rm->loadPixmap("SMESH", tr("ICON_COMPUTE")));
832 aPixGrp = new QGroupBox(tr("EVAL_DLG"), aFrame);
835 aPixGrp = new QGroupBox(tr("CONSTRUCTOR"), aFrame);
837 QButtonGroup* aBtnGrp = new QButtonGroup(this);
838 QHBoxLayout* aPixGrpLayout = new QHBoxLayout(aPixGrp);
839 aPixGrpLayout->setMargin(MARGIN); aPixGrpLayout->setSpacing(SPACING);
841 QRadioButton* aRBut = new QRadioButton(aPixGrp);
842 aRBut->setIcon(iconCompute);
843 aRBut->setChecked(true);
844 aPixGrpLayout->addWidget(aRBut);
845 aBtnGrp->addButton(aRBut, 0);
849 QGroupBox* nameBox = new QGroupBox(tr("SMESH_MESHINFO_NAME"), aFrame );
850 QHBoxLayout* nameBoxLayout = new QHBoxLayout(nameBox);
851 nameBoxLayout->setMargin(MARGIN); nameBoxLayout->setSpacing(SPACING);
852 myMeshName = new QLabel(nameBox);
853 nameBoxLayout->addWidget(myMeshName);
857 myBriefInfo = new SMESHGUI_MeshInfosBox(false, aFrame);
858 myFullInfo = new SMESHGUI_MeshInfosBox(true, aFrame);
860 // Computation errors
862 myCompErrorGroup = new QGroupBox(tr("ERRORS"), aFrame);
863 myTable = new QTableWidget( 1, NB_COLUMNS, myCompErrorGroup);
864 myShowBtn = new QPushButton(tr("SHOW_SHAPE"), myCompErrorGroup);
865 myPublishBtn = new QPushButton(tr("PUBLISH_SHAPE"), myCompErrorGroup);
866 myBadMeshBtn = new QPushButton(tr("SHOW_BAD_MESH"), myCompErrorGroup);
868 //myTable->setReadOnly( true ); // VSR: check
869 myTable->setEditTriggers( QAbstractItemView::NoEditTriggers );
870 myTable->hideColumn( COL_PUBLISHED );
871 myTable->hideColumn( COL_SHAPEID );
872 myTable->hideColumn( COL_BAD_MESH );
873 myTable->horizontalHeader()->setResizeMode( COL_ERROR, QHeaderView::Interactive );
876 headers << tr( "COL_ALGO_HEADER" );
877 headers << tr( "COL_SHAPE_HEADER" );
878 headers << tr( "COL_ERROR_HEADER" );
879 headers << tr( "COL_SHAPEID_HEADER" );
880 headers << tr( "COL_PUBLISHED_HEADER" );
882 myTable->setHorizontalHeaderLabels( headers );
885 QGridLayout* grpLayout = new QGridLayout(myCompErrorGroup);
886 grpLayout->setSpacing(SPACING);
887 grpLayout->setMargin(MARGIN);
888 grpLayout->addWidget( myTable, 0, 0, 4, 1 );
889 grpLayout->addWidget( myShowBtn, 0, 1 );
890 grpLayout->addWidget( myPublishBtn, 1, 1 );
891 grpLayout->addWidget( myBadMeshBtn, 2, 1 );
892 grpLayout->setRowStretch( 3, 1 );
894 // Hypothesis definition errors
896 myHypErrorGroup = new QGroupBox(tr("SMESH_WRN_MISSING_PARAMETERS"), aFrame);
897 QHBoxLayout* myHypErrorGroupLayout = new QHBoxLayout(myHypErrorGroup);
898 myHypErrorGroupLayout->setMargin(MARGIN);
899 myHypErrorGroupLayout->setSpacing(SPACING);
900 myHypErrorLabel = new QLabel(myHypErrorGroup);
901 myHypErrorGroupLayout->addWidget(myHypErrorLabel);
905 myMemoryLackGroup = new QGroupBox(tr("ERRORS"), aFrame);
906 QVBoxLayout* myMemoryLackGroupLayout = new QVBoxLayout(myMemoryLackGroup);
907 myMemoryLackGroupLayout->setMargin(MARGIN);
908 myMemoryLackGroupLayout->setSpacing(SPACING);
909 QLabel* memLackLabel = new QLabel(tr("MEMORY_LACK"), myMemoryLackGroup);
910 QFont bold = memLackLabel->font(); bold.setBold(true);
911 memLackLabel->setFont( bold );
912 memLackLabel->setMinimumWidth(300);
913 myMemoryLackGroupLayout->addWidget(memLackLabel);
915 // add all widgets to aFrame
916 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
917 aLay->setMargin( 0 );
918 aLay->setSpacing( 0 );
919 aLay->addWidget( aPixGrp );
920 aLay->addWidget( nameBox );
921 aLay->addWidget( myBriefInfo );
922 aLay->addWidget( myFullInfo );
923 aLay->addWidget( myHypErrorGroup );
924 aLay->addWidget( myCompErrorGroup );
925 aLay->addWidget( myMemoryLackGroup );
926 aLay->setStretchFactor( myCompErrorGroup, 1 );
928 ((QPushButton*) button( OK ))->setDefault( true );
933 //================================================================================
937 //================================================================================
939 SMESHGUI_BaseComputeOp::SMESHGUI_BaseComputeOp()
940 : SMESHGUI_Operation(), myCompDlg( 0 )
942 myTShapeDisplayer = new SMESH::TShapeDisplayer();
943 myBadMeshDisplayer = 0;
945 //myHelpFileName = "/files/about_meshes.htm"; // V3
946 myHelpFileName = "about_meshes_page.html"; // V4
949 //================================================================================
951 * \brief Start operation
952 * \purpose Init dialog fields, connect signals and slots, show dialog
954 //================================================================================
956 void SMESHGUI_BaseComputeOp::startOperation()
958 // create compute dialog if not created before
961 myMesh = SMESH::SMESH_Mesh::_nil();
962 myMainShape = GEOM::GEOM_Object::_nil();
965 LightApp_SelectionMgr *Sel = selectionMgr();
966 SALOME_ListIO selected; Sel->selectedObjects( selected );
968 int nbSel = selected.Extent();
970 SUIT_MessageBox::warning(desktop(),
971 tr("SMESH_WRN_WARNING"),
972 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
977 myIObject = selected.First();
978 myMesh = SMESH::GetMeshByIO(myIObject);
979 if (myMesh->_is_nil()) {
980 SUIT_MessageBox::warning(desktop(),
981 tr("SMESH_WRN_WARNING"),
982 tr("SMESH_WRN_NO_AVAILABLE_DATA"));
986 myMainShape = myMesh->GetShapeToMesh();
988 SMESHGUI_Operation::startOperation();
991 //================================================================================
993 * \brief computeMesh()
995 //================================================================================
997 void SMESHGUI_BaseComputeOp::computeMesh()
1001 SMESH::MemoryReserve aMemoryReserve;
1003 SMESH::compute_error_array_var aCompErrors;
1006 bool computeFailed = true, memoryLack = false;
1008 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
1009 bool hasShape = myMesh->HasShapeToMesh();
1010 bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
1011 if ( shapeOK && aMeshSObj )
1013 myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
1014 SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
1015 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
1016 if ( errors->length() > 0 ) {
1017 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
1019 SUIT_OverrideCursor aWaitCursor;
1021 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1024 if (gen->Compute(myMesh, myMainShape))
1025 computeFailed = false;
1027 catch(const SALOME::SALOME_Exception & S_ex){
1031 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1034 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
1035 // check if there are memory problems
1036 for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
1037 memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
1039 catch(const SALOME::SALOME_Exception & S_ex){
1043 // NPAL16631: if ( !memoryLack )
1045 SMESH::ModifiedMesh(aMeshSObj, !computeFailed, myMesh->NbNodes() == 0);
1046 update( UF_ObjBrowser | UF_Model );
1049 // NPAL16631: if ( getSMESHGUI()->automaticUpdate() )
1050 if ( !memoryLack && getSMESHGUI()->automaticUpdate() )
1053 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1056 SMESH::Update(myIObject, true);
1060 MESSAGE ( "Exception thrown during mesh visualization" );
1062 if ( SMDS_Mesh::CheckMemory(true) ) { // has memory to show warning?
1063 SMESH::OnVisuException();
1070 LightApp_SelectionMgr *Sel = selectionMgr();
1073 SALOME_ListIO selected;
1074 selected.Append( myIObject );
1075 Sel->setSelectedObjects( selected );
1081 aMemoryReserve.release();
1083 myCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
1087 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
1088 bool noHypoError = ( aHypErrors.isEmpty() );
1090 SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
1091 int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
1093 bool isShowResultDlg = true;
1094 switch( aNotifyMode ) {
1095 case 0: // show the mesh computation result dialog NEVER
1096 isShowResultDlg = false;
1099 case 1: // show the mesh computation result dialog if there are some errors
1100 if ( memoryLack || !noCompError || !noHypoError )
1101 isShowResultDlg = true;
1104 isShowResultDlg = false;
1108 default: // show the result dialog after each mesh computation
1109 isShowResultDlg = true;
1113 if ( isShowResultDlg )
1114 showComputeResult( memoryLack, noCompError,aCompErrors, noHypoError, aHypErrors );
1117 void SMESHGUI_BaseComputeOp::showComputeResult( const bool theMemoryLack,
1118 const bool theNoCompError,
1119 SMESH::compute_error_array_var& theCompErrors,
1120 const bool theNoHypoError,
1121 const QString& theHypErrors )
1123 bool hasShape = myMesh->HasShapeToMesh();
1124 SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
1125 aCompDlg->myMemoryLackGroup->hide();
1127 if ( theMemoryLack )
1129 aCompDlg->myMemoryLackGroup->show();
1130 aCompDlg->myFullInfo->hide();
1131 aCompDlg->myBriefInfo->hide();
1132 aCompDlg->myHypErrorGroup->hide();
1133 aCompDlg->myCompErrorGroup->hide();
1135 else if ( theNoCompError && theNoHypoError )
1137 aCompDlg->myFullInfo->SetInfoByMesh( myMesh );
1138 aCompDlg->myFullInfo->show();
1139 aCompDlg->myBriefInfo->hide();
1140 aCompDlg->myHypErrorGroup->hide();
1141 aCompDlg->myCompErrorGroup->hide();
1145 QTableWidget* tbl = aCompDlg->myTable;
1146 aCompDlg->myBriefInfo->SetInfoByMesh( myMesh );
1147 aCompDlg->myBriefInfo->show();
1148 aCompDlg->myFullInfo->hide();
1150 if ( theNoHypoError ) {
1151 aCompDlg->myHypErrorGroup->hide();
1154 aCompDlg->myHypErrorGroup->show();
1155 aCompDlg->myHypErrorLabel->setText( theHypErrors );
1158 if ( theNoCompError ) {
1159 aCompDlg->myCompErrorGroup->hide();
1162 aCompDlg->myCompErrorGroup->show();
1165 aCompDlg->myPublishBtn->hide();
1166 aCompDlg->myShowBtn->hide();
1169 aCompDlg->myPublishBtn->show();
1170 aCompDlg->myShowBtn->show();
1173 // fill table of errors
1174 tbl->setRowCount( theCompErrors->length() );
1175 if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
1176 else tbl->showColumn( COL_SHAPE );
1177 tbl->setColumnWidth( COL_ERROR, 200 );
1179 bool hasBadMesh = false;
1180 for ( int row = 0; row < theCompErrors->length(); ++row )
1182 SMESH::ComputeError & err = theCompErrors[ row ];
1184 QString text = err.algoName.in();
1185 if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
1186 else tbl->item( row, COL_ALGO )->setText( text );
1188 text = SMESH::errorText( err.code, err.comment.in() );
1189 if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
1190 else tbl->item( row, COL_ERROR )->setText( text );
1192 text = QString("%1").arg( err.subShapeID );
1193 if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
1194 else tbl->item( row, COL_SHAPEID )->setText( text );
1196 text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
1197 if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
1198 else tbl->item( row, COL_SHAPE )->setText( text );
1200 text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
1201 if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
1202 else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled
1204 text = err.hasBadMesh ? "hasBadMesh" : "";
1205 if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
1206 else tbl->item( row, COL_BAD_MESH )->setText( text );
1207 if ( err.hasBadMesh ) hasBadMesh = true;
1209 //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
1210 tbl->resizeRowToContents( row );
1212 tbl->resizeColumnToContents( COL_ALGO );
1213 tbl->resizeColumnToContents( COL_SHAPE );
1216 aCompDlg->myBadMeshBtn->show();
1218 aCompDlg->myBadMeshBtn->hide();
1220 tbl->setCurrentCell(0,0);
1221 currentCellChanged(); // to update buttons
1224 // show dialog and wait, becase Compute can be invoked from Preview operation
1225 //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
1229 //================================================================================
1231 * \brief Stops operation
1233 //================================================================================
1235 void SMESHGUI_BaseComputeOp::stopOperation()
1237 SMESHGUI_Operation::stopOperation();
1238 if ( myTShapeDisplayer )
1239 myTShapeDisplayer->SetVisibility( false );
1240 if ( myBadMeshDisplayer ) {
1241 myBadMeshDisplayer->SetVisibility( false );
1242 // delete it in order not to have problems at its destruction when the viewer
1243 // where it worked is dead due to e.g. study closing
1244 delete myBadMeshDisplayer;
1245 myBadMeshDisplayer = 0;
1247 myIObject.Nullify();
1250 //================================================================================
1252 * \brief publish selected subshape
1254 //================================================================================
1256 void SMESHGUI_BaseComputeOp::onPublishShape()
1258 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
1259 SALOMEDS::Study_var study = SMESHGUI::GetSMESHGen()->GetCurrentStudy();
1262 SMESH::getSelectedRows( table(), rows );
1264 foreach ( row, rows )
1266 int curSub = table()->item(row, COL_SHAPEID)->text().toInt();
1267 GEOM::GEOM_Object_var shape = SMESH::getSubShape( curSub, myMainShape );
1268 if ( !shape->_is_nil() && ! SMESH::getSubShapeSO( curSub, myMainShape ))
1270 if ( !SMESH::getSubShapeSO( 1, myMainShape )) // the main shape not published
1272 QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( myMainShape, "MAIN_SHAPE" ));
1273 SALOMEDS::SObject_var so =
1274 geomGen->AddInStudy( study, myMainShape, name.toLatin1().data(), GEOM::GEOM_Object::_nil());
1275 // look for myMainShape in the table
1276 for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
1277 if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
1278 if ( so->_is_nil() ) {
1279 table()->item( r, COL_SHAPE )->setText( so->GetName() );
1280 table()->item( r, COL_PUBLISHED )->setText( so->GetID() );
1285 if ( curSub == 1 ) continue;
1287 QString name = GEOMBase::GetDefaultName( SMESH::shapeTypeName( shape, "ERROR_SHAPE" ));
1288 SALOMEDS::SObject_var so = geomGen->AddInStudy( study, shape, name.toLatin1().data(), myMainShape);
1289 if ( !so->_is_nil() ) {
1290 table()->item( row, COL_SHAPE )->setText( so->GetName() );
1291 table()->item( row, COL_PUBLISHED )->setText( so->GetID() );
1295 getSMESHGUI()->getApp()->updateObjectBrowser();
1296 currentCellChanged(); // to update buttons
1299 //================================================================================
1301 * \brief show mesh elements preventing computation of a submesh of current row
1303 //================================================================================
1305 void SMESHGUI_BaseComputeOp::onShowBadMesh()
1307 myTShapeDisplayer->SetVisibility( false );
1309 if ( SMESH::getSelectedRows( table(), rows ) == 1 ) {
1310 bool hasBadMesh = ( !table()->item(rows.front(), COL_BAD_MESH)->text().isEmpty() );
1312 int curSub = table()->item(rows.front(), COL_SHAPEID)->text().toInt();
1313 SMESHGUI* gui = getSMESHGUI();
1314 SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
1315 SVTK_ViewWindow* view = SMESH::GetViewWindow( gui );
1316 if ( myBadMeshDisplayer ) delete myBadMeshDisplayer;
1317 myBadMeshDisplayer = new SMESHGUI_MeshEditPreview( view );
1318 SMESH::MeshPreviewStruct_var aMeshData = gen->GetBadInputElements(myMesh,curSub);
1319 vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
1320 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
1321 // delete property !!!!!!!!!!
1322 vtkProperty* prop = vtkProperty::New();
1323 prop->SetLineWidth( aLineWidth * 3 );
1324 prop->SetPointSize( aPointSize * 3 );
1325 prop->SetColor( 250, 0, 250 );
1326 myBadMeshDisplayer->GetActor()->SetProperty( prop );
1327 myBadMeshDisplayer->SetData( aMeshData._retn() );
1332 //================================================================================
1334 * \brief SLOT called when a selected cell in table() changed
1336 //================================================================================
1338 void SMESHGUI_BaseComputeOp::currentCellChanged()
1340 myTShapeDisplayer->SetVisibility( false );
1341 if ( myBadMeshDisplayer )
1342 myBadMeshDisplayer->SetVisibility( false );
1344 bool publishEnable = 0, showEnable = 0, showOnly = 1, hasBadMesh = 0;
1346 int nbSelected = SMESH::getSelectedRows( table(), rows );
1348 foreach ( row, rows )
1350 bool hasData = ( !table()->item( row, COL_SHAPE )->text().isEmpty() );
1351 bool isPublished = ( !table()->item( row, COL_PUBLISHED )->text().isEmpty() );
1352 if ( hasData && !isPublished )
1353 publishEnable = true;
1355 int curSub = table()->item( row, COL_SHAPEID )->text().toInt();
1356 bool prsReady = myTShapeDisplayer->HasReadyActorsFor( curSub, myMainShape );
1358 myTShapeDisplayer->Show( curSub, myMainShape, showOnly );
1365 if ( !table()->item(row, COL_BAD_MESH)->text().isEmpty() )
1368 myCompDlg->myPublishBtn->setEnabled( publishEnable );
1369 myCompDlg->myShowBtn ->setEnabled( showEnable );
1370 myCompDlg->myBadMeshBtn->setEnabled( hasBadMesh && ( nbSelected == 1 ));
1373 //================================================================================
1375 * \brief update preview
1377 //================================================================================
1379 void SMESHGUI_BaseComputeOp::onPreviewShape()
1381 if ( myTShapeDisplayer )
1383 SUIT_OverrideCursor aWaitCursor;
1385 SMESH::getSelectedRows( table(), rows );
1387 bool showOnly = true;
1389 foreach ( row, rows )
1391 int curSub = table()->item( row, COL_SHAPEID )->text().toInt();
1393 myTShapeDisplayer->Show( curSub, myMainShape, showOnly );
1397 currentCellChanged(); // to update buttons
1401 //================================================================================
1405 //================================================================================
1407 SMESHGUI_BaseComputeOp::~SMESHGUI_BaseComputeOp()
1411 delete myTShapeDisplayer;
1412 if ( myBadMeshDisplayer )
1413 delete myBadMeshDisplayer;
1416 //================================================================================
1418 * \brief Gets dialog of compute operation
1419 * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation
1421 //================================================================================
1423 SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::computeDlg() const
1427 SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
1428 me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), false );
1429 // connect signals and slots
1430 connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
1431 connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
1432 connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
1434 QTableWidget* aTable = me->table();
1435 connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
1436 connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));
1441 //================================================================================
1443 * \brief returns from compute mesh result dialog
1445 //================================================================================
1447 bool SMESHGUI_BaseComputeOp::onApply()
1452 //================================================================================
1454 * \brief Return a table
1456 //================================================================================
1458 QTableWidget* SMESHGUI_BaseComputeOp::table()
1460 return myCompDlg->myTable;
1464 //================================================================================
1466 * \brief Constructor
1468 //================================================================================
1470 SMESHGUI_ComputeOp::SMESHGUI_ComputeOp()
1471 : SMESHGUI_BaseComputeOp()
1476 //================================================================================
1478 * \brief Desctructor
1480 //================================================================================
1482 SMESHGUI_ComputeOp::~SMESHGUI_ComputeOp()
1486 //================================================================================
1488 * \brief perform it's intention action: compute mesh
1490 //================================================================================
1492 void SMESHGUI_ComputeOp::startOperation()
1494 SMESHGUI_BaseComputeOp::startOperation();
1498 //================================================================================
1500 * \brief Gets dialog of this operation
1501 * \retval LightApp_Dialog* - pointer to dialog of this operation
1503 //================================================================================
1505 LightApp_Dialog* SMESHGUI_ComputeOp::dlg() const
1507 return computeDlg();
1510 //================================================================================
1512 * \brief Constructor
1514 //================================================================================
1516 SMESHGUI_PrecomputeOp::SMESHGUI_PrecomputeOp()
1517 : SMESHGUI_BaseComputeOp(),
1520 myPreviewDisplayer( 0 )
1522 myHelpFileName = "constructing_meshes_page.html#preview_mesh_anchor";
1525 //================================================================================
1529 //================================================================================
1531 SMESHGUI_PrecomputeOp::~SMESHGUI_PrecomputeOp()
1536 if ( myPreviewDisplayer )
1537 delete myPreviewDisplayer;
1538 myPreviewDisplayer = 0;
1541 //================================================================================
1543 * \brief Gets current dialog of this operation
1544 * \retval LightApp_Dialog* - pointer to dialog of this operation
1546 //================================================================================
1548 LightApp_Dialog* SMESHGUI_PrecomputeOp::dlg() const
1553 //================================================================================
1555 * \brief perform it's intention action: prepare data
1557 //================================================================================
1559 void SMESHGUI_PrecomputeOp::startOperation()
1563 myDlg = new SMESHGUI_PrecomputeDlg( desktop() );
1566 connect( myDlg, SIGNAL( preview() ), this, SLOT( onPreview() ) );
1567 connect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onCompute() ) );
1568 connect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onCompute() ) );
1570 myActiveDlg = myDlg;
1572 // connect signal to compute dialog. which will be shown after Compute mesh operation
1573 SMESHGUI_ComputeDlg* cmpDlg = computeDlg();
1576 // disconnect signals
1577 disconnect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1578 disconnect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1579 disconnect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
1580 disconnect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
1581 disconnect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
1584 if( cmpDlg->testButtonFlags( QtxDialog::OK ) )
1585 connect( cmpDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1586 if( cmpDlg->testButtonFlags( QtxDialog::Apply ) )
1587 connect( cmpDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1588 if( cmpDlg->testButtonFlags( QtxDialog::Help ) )
1589 connect( cmpDlg, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
1590 if( cmpDlg->testButtonFlags( QtxDialog::Cancel ) )
1591 connect( cmpDlg, SIGNAL( dlgCancel() ), this, SLOT( onCancel() ) );
1592 if( cmpDlg->testButtonFlags( QtxDialog::Close ) )
1593 connect( cmpDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
1596 SMESHGUI_BaseComputeOp::startOperation();
1598 // disconnect slot from preview dialog to have Apply from results of compute operation only
1599 disconnect( myDlg, SIGNAL( dlgOk() ), this, SLOT( onOk() ) );
1600 disconnect( myDlg, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
1605 //================================================================================
1607 * \brief Stops operation
1609 //================================================================================
1611 void SMESHGUI_PrecomputeOp::stopOperation()
1613 if ( myPreviewDisplayer )
1615 myPreviewDisplayer->SetVisibility( false );
1616 delete myPreviewDisplayer;
1617 myPreviewDisplayer = 0;
1619 myMapShapeId.clear();
1620 SMESHGUI_BaseComputeOp::stopOperation();
1623 //================================================================================
1625 * \brief perform it's intention action: reinitialise dialog
1627 //================================================================================
1629 void SMESHGUI_PrecomputeOp::resumeOperation()
1631 if ( myActiveDlg == myDlg )
1633 SMESHGUI_BaseComputeOp::resumeOperation();
1636 void SMESHGUI_PrecomputeOp::initDialog()
1639 QMap<int, int> modeMap;
1640 _PTR(SObject) aHypRoot;
1641 _PTR(GenericAttribute) anAttr;
1642 int aPart = SMESH::Tag_RefOnAppliedAlgorithms;
1644 _PTR(SObject) pMesh = studyDS()->FindObjectID( myIObject->getEntry() );
1645 if ( pMesh && pMesh->FindSubObject( aPart, aHypRoot ) )
1647 _PTR(ChildIterator) anIter =
1648 SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
1649 for ( ; anIter->More(); anIter->Next() )
1651 _PTR(SObject) anObj = anIter->Value();
1652 _PTR(SObject) aRefObj;
1653 if ( anObj->ReferencedObject( aRefObj ) )
1658 if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
1660 CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
1661 if ( CORBA::is_nil( aVar ) )
1664 SMESH::SMESH_Algo_var algo = SMESH::SMESH_3D_Algo::_narrow( aVar );
1665 if ( !algo->_is_nil() )
1667 modeMap[ SMESH::DIM_1D ] = 0;
1668 modeMap[ SMESH::DIM_2D ] = 0;
1672 algo = SMESH::SMESH_2D_Algo::_narrow( aVar );
1673 if ( !algo->_is_nil() )
1674 modeMap[ SMESH::DIM_1D ] = 0;
1679 if ( modeMap.contains( SMESH::DIM_1D ) )
1680 modes.append( SMESH::DIM_1D );
1681 if ( modeMap.contains( SMESH::DIM_2D ) )
1682 modes.append( SMESH::DIM_2D );
1684 myDlg->setPreviewModes( modes );
1687 //================================================================================
1689 * \brief perform it's intention action: compute mesh
1691 //================================================================================
1693 void SMESHGUI_PrecomputeOp::onCompute()
1696 myMapShapeId.clear();
1697 myActiveDlg = computeDlg();
1701 //================================================================================
1703 * \brief perform it's intention action: compute mesh
1705 //================================================================================
1707 void SMESHGUI_PrecomputeOp::onCancel()
1709 QObject* curDlg = sender();
1710 if ( curDlg == computeDlg() && myActiveDlg == myDlg )
1712 // return from error messages
1717 if ( myActiveDlg == myDlg && !myMesh->_is_nil() && myMapShapeId.count() )
1719 // ask to remove already computed mesh elements
1720 if ( SUIT_MessageBox::question( desktop(), tr( "SMESH_WARNING" ),
1721 tr( "CLEAR_SUBMESH_QUESTION" ),
1722 tr( "SMESH_BUT_DELETE" ), tr( "SMESH_BUT_NO" ), 0, 1 ) == 0 )
1724 // remove all submeshes for collected shapes
1725 QMap<int,int>::const_iterator it = myMapShapeId.constBegin();
1726 for ( ; it != myMapShapeId.constEnd(); ++it )
1727 myMesh->ClearSubMesh( *it );
1730 myMapShapeId.clear();
1731 SMESHGUI_BaseComputeOp::onCancel();
1734 //================================================================================
1736 * \brief perform it's intention action: preview mesh
1738 //================================================================================
1740 void SMESHGUI_PrecomputeOp::onPreview()
1742 if ( !myDlg || myMesh->_is_nil() || myMainShape->_is_nil() )
1745 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
1748 // Compute preview of mesh,
1749 // i.e. compute mesh till indicated dimension
1750 int dim = myDlg->getPreviewMode();
1752 SMESH::MemoryReserve aMemoryReserve;
1754 SMESH::compute_error_array_var aCompErrors;
1757 bool computeFailed = true, memoryLack = false;
1759 SMESHGUI_ComputeDlg* aCompDlg = computeDlg();
1760 aCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
1762 SMESHGUI* gui = getSMESHGUI();
1763 SMESH::SMESH_Gen_var gen = gui->GetSMESHGen();
1764 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
1765 if ( errors->length() > 0 ) {
1766 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
1769 SUIT_OverrideCursor aWaitCursor;
1771 SVTK_ViewWindow* view = SMESH::GetViewWindow( gui );
1772 if ( myPreviewDisplayer ) delete myPreviewDisplayer;
1773 myPreviewDisplayer = new SMESHGUI_MeshEditPreview( view );
1775 SMESH::long_array_var aShapesId = new SMESH::long_array();
1777 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1781 SMESH::MeshPreviewStruct_var previewData =
1782 gen->Precompute(myMesh, myMainShape, (SMESH::Dimension)dim, aShapesId);
1783 SMESH::MeshPreviewStruct* previewRes = previewData._retn();
1784 if ( previewRes && previewRes->nodesXYZ.length() > 0 )
1786 computeFailed = false;
1787 myPreviewDisplayer->SetData( previewRes );
1788 // append shape indeces with computed mesh entities
1789 for ( int i = 0, n = aShapesId->length(); i < n; i++ )
1790 myMapShapeId[ aShapesId[ i ] ] = 0;
1793 myPreviewDisplayer->SetVisibility(false);
1795 catch(const SALOME::SALOME_Exception & S_ex){
1797 myPreviewDisplayer->SetVisibility(false);
1801 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1804 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
1805 // check if there are memory problems
1806 for ( int i = 0; (i < aCompErrors->length()) && !memoryLack; ++i )
1807 memoryLack = ( aCompErrors[ i ].code == SMESH::COMPERR_MEMORY_PB );
1809 catch(const SALOME::SALOME_Exception & S_ex){
1814 aMemoryReserve.release();
1816 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
1817 bool noHypoError = ( aHypErrors.isEmpty() );
1819 SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( gui );
1820 int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
1822 bool isShowError = true;
1823 switch( aNotifyMode ) {
1824 case 0: // show the mesh computation result dialog NEVER
1825 isShowError = false;
1827 case 1: // show the mesh computation result dialog if there are some errors
1828 default: // show the result dialog after each mesh computation
1829 if ( !computeFailed && !memoryLack && noCompError && noHypoError )
1830 isShowError = false;
1834 aWaitCursor.suspend();
1839 aCompDlg->setWindowTitle(tr( computeFailed ? "SMESH_WRN_COMPUTE_FAILED" : "SMESH_COMPUTE_SUCCEED"));
1840 showComputeResult( memoryLack, noCompError, aCompErrors, noHypoError, aHypErrors );
1845 //================================================================================
1847 * \brief Constructor
1849 //================================================================================
1851 SMESHGUI_PrecomputeDlg::SMESHGUI_PrecomputeDlg( QWidget* parent )
1852 : SMESHGUI_Dialog( parent, false, false, OK | Cancel | Help )
1854 setWindowTitle( tr( "CAPTION" ) );
1856 setButtonText( OK, tr( "COMPUTE" ) );
1857 QFrame* main = mainFrame();
1859 QVBoxLayout* layout = new QVBoxLayout( main );
1861 QFrame* frame = new QFrame( main );
1862 layout->setMargin(0); layout->setSpacing(0);
1863 layout->addWidget( frame );
1865 QHBoxLayout* frameLay = new QHBoxLayout( frame );
1866 frameLay->setMargin(0); frameLay->setSpacing(SPACING);
1868 myPreviewMode = new QtxComboBox( frame );
1869 frameLay->addWidget( myPreviewMode );
1871 myPreviewBtn = new QPushButton( tr( "PREVIEW" ), frame );
1872 frameLay->addWidget( myPreviewBtn );
1874 connect( myPreviewBtn, SIGNAL( clicked( bool ) ), this, SIGNAL( preview() ) );
1877 //================================================================================
1881 //================================================================================
1883 SMESHGUI_PrecomputeDlg::~SMESHGUI_PrecomputeDlg()
1887 //================================================================================
1889 * \brief Sets available preview modes
1891 //================================================================================
1893 void SMESHGUI_PrecomputeDlg::setPreviewModes( const QList<int>& theModes )
1895 myPreviewMode->clear();
1896 QList<int>::const_iterator it = theModes.constBegin();
1897 for ( int i = 0; it != theModes.constEnd(); ++it, i++ )
1899 QString mode = QString( "PREVIEW_%1" ).arg( *it );
1900 myPreviewMode->addItem( tr( mode.toLatin1().data() ) );
1901 myPreviewMode->setId( i, *it );
1903 myPreviewBtn->setEnabled( !theModes.isEmpty() );
1906 //================================================================================
1908 * \brief Returns current preview mesh mode
1910 //================================================================================
1912 int SMESHGUI_PrecomputeDlg::getPreviewMode() const
1914 return myPreviewMode->currentId();
1918 //================================================================================
1920 * \brief Constructor
1922 //================================================================================
1924 SMESHGUI_EvaluateOp::SMESHGUI_EvaluateOp()
1925 : SMESHGUI_BaseComputeOp()
1930 //================================================================================
1932 * \brief Desctructor
1934 //================================================================================
1936 SMESHGUI_EvaluateOp::~SMESHGUI_EvaluateOp()
1940 //================================================================================
1942 * \brief perform it's intention action: compute mesh
1944 //================================================================================
1946 void SMESHGUI_EvaluateOp::startOperation()
1948 SMESHGUI_BaseComputeOp::evaluateDlg();
1949 SMESHGUI_BaseComputeOp::startOperation();
1953 //================================================================================
1955 * \brief Gets dialog of this operation
1956 * \retval LightApp_Dialog* - pointer to dialog of this operation
1958 //================================================================================
1960 LightApp_Dialog* SMESHGUI_EvaluateOp::dlg() const
1962 return evaluateDlg();
1965 //================================================================================
1967 * \brief evaluaateMesh()
1969 //================================================================================
1971 void SMESHGUI_BaseComputeOp::evaluateMesh()
1975 SMESH::MemoryReserve aMemoryReserve;
1977 SMESH::compute_error_array_var aCompErrors;
1980 bool evaluateFailed = true, memoryLack = false;
1981 std::vector<int> aResVec(18);
1983 _PTR(SObject) aMeshSObj = SMESH::FindSObject(myMesh);
1984 bool hasShape = myMesh->HasShapeToMesh();
1985 bool shapeOK = myMainShape->_is_nil() ? !hasShape : hasShape;
1986 if ( shapeOK && aMeshSObj )
1988 myCompDlg->myMeshName->setText( aMeshSObj->GetName().c_str() );
1989 SMESH::SMESH_Gen_var gen = getSMESHGUI()->GetSMESHGen();
1990 SMESH::algo_error_array_var errors = gen->GetAlgoState(myMesh,myMainShape);
1991 if ( errors->length() > 0 ) {
1992 aHypErrors = SMESH::GetMessageOnAlgoStateErrors( errors.in() );
1994 SUIT_OverrideCursor aWaitCursor;
1996 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1999 SMESH::long_array_var aVec = gen->Evaluate(myMesh, myMainShape);
2000 for(int i=0; i<17; i++) {
2001 aResVec[i] = aVec[i];
2004 catch(const SALOME::SALOME_Exception & S_ex){
2009 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
2012 aCompErrors = gen->GetComputeErrors( myMesh, myMainShape );
2014 catch(const SALOME::SALOME_Exception & S_ex){
2020 aMemoryReserve.release();
2022 evaluateFailed = ( aCompErrors->length() > 0 );
2023 myCompDlg->setWindowTitle(tr( evaluateFailed ? "SMESH_WRN_EVALUATE_FAILED" : "SMESH_EVALUATE_SUCCEED"));
2027 bool noCompError = ( !aCompErrors.operator->() || aCompErrors->length() == 0 );
2028 bool noHypoError = ( aHypErrors.isEmpty() );
2030 //SUIT_ResourceMgr* resMgr = SMESH::GetResourceMgr( SMESHGUI::GetSMESHGUI() );
2031 //int aNotifyMode = resMgr->integerValue( "SMESH", "show_result_notification" );
2033 bool isShowResultDlg = true;
2035 //switch( aNotifyMode ) {
2036 //case 0: // show the mesh computation result dialog NEVER
2037 //isShowResultDlg = false;
2040 //case 1: // show the mesh computation result dialog if there are some errors
2041 //if ( memoryLack || !noHypoError )
2042 // isShowResultDlg = true;
2045 // isShowResultDlg = false;
2049 //default: // show the result dialog after each mesh computation
2050 //isShowResultDlg = true;
2054 if ( isShowResultDlg )
2055 //showComputeResult( memoryLack, noCompError,aCompErrors, noHypoError, aHypErrors );
2056 showEvaluateResult( aResVec, memoryLack, noCompError, aCompErrors,
2057 noHypoError, aHypErrors);
2061 void SMESHGUI_BaseComputeOp::showEvaluateResult(std::vector<int> theVec,
2062 const bool theMemoryLack,
2063 const bool theNoCompError,
2064 SMESH::compute_error_array_var& theCompErrors,
2065 const bool theNoHypoError,
2066 const QString& theHypErrors)
2068 bool hasShape = myMesh->HasShapeToMesh();
2069 SMESHGUI_ComputeDlg* aCompDlg = evaluateDlg();
2070 aCompDlg->myMemoryLackGroup->hide();
2072 if ( theMemoryLack )
2074 aCompDlg->myMemoryLackGroup->show();
2075 aCompDlg->myFullInfo->hide();
2076 aCompDlg->myBriefInfo->hide();
2077 aCompDlg->myHypErrorGroup->hide();
2078 aCompDlg->myCompErrorGroup->hide();
2080 else if ( theNoCompError && theNoHypoError )
2082 //aCompDlg->myFullInfo->SetInfoByMesh( myMesh );
2083 aCompDlg->myFullInfo->SetInfoByEval( theVec );
2084 aCompDlg->myFullInfo->show();
2085 aCompDlg->myBriefInfo->hide();
2086 aCompDlg->myHypErrorGroup->hide();
2087 aCompDlg->myCompErrorGroup->hide();
2091 QTableWidget* tbl = aCompDlg->myTable;
2092 //aCompDlg->myBriefInfo->SetInfoByMesh( myMesh );
2093 aCompDlg->myBriefInfo->SetInfoByEval( theVec );
2094 aCompDlg->myBriefInfo->show();
2095 aCompDlg->myFullInfo->hide();
2097 if ( theNoHypoError ) {
2098 aCompDlg->myHypErrorGroup->hide();
2101 aCompDlg->myHypErrorGroup->show();
2102 aCompDlg->myHypErrorLabel->setText( theHypErrors );
2105 if ( theNoCompError ) {
2106 aCompDlg->myCompErrorGroup->hide();
2109 aCompDlg->myCompErrorGroup->show();
2111 aCompDlg->myPublishBtn->hide();
2112 aCompDlg->myShowBtn->hide();
2114 // fill table of errors
2115 tbl->setRowCount( theCompErrors->length() );
2116 if ( !hasShape ) tbl->hideColumn( COL_SHAPE );
2117 else tbl->showColumn( COL_SHAPE );
2118 tbl->setColumnWidth( COL_ERROR, 200 );
2120 bool hasBadMesh = false;
2121 for ( int row = 0; row < theCompErrors->length(); ++row )
2123 SMESH::ComputeError & err = theCompErrors[ row ];
2125 QString text = err.algoName.in();
2126 if ( !tbl->item( row, COL_ALGO ) ) tbl->setItem( row, COL_ALGO, new QTableWidgetItem( text ) );
2127 else tbl->item( row, COL_ALGO )->setText( text );
2129 text = SMESH::errorText( err.code, err.comment.in() );
2130 if ( !tbl->item( row, COL_ERROR ) ) tbl->setItem( row, COL_ERROR, new QTableWidgetItem( text ) );
2131 else tbl->item( row, COL_ERROR )->setText( text );
2133 text = QString("%1").arg( err.subShapeID );
2134 if ( !tbl->item( row, COL_SHAPEID ) ) tbl->setItem( row, COL_SHAPEID, new QTableWidgetItem( text ) );
2135 else tbl->item( row, COL_SHAPEID )->setText( text );
2137 text = hasShape ? SMESH::shapeText( err.subShapeID, myMainShape ) : QString("");
2138 if ( !tbl->item( row, COL_SHAPE ) ) tbl->setItem( row, COL_SHAPE, new QTableWidgetItem( text ) );
2139 else tbl->item( row, COL_SHAPE )->setText( text );
2141 text = ( !hasShape || SMESH::getSubShapeSO( err.subShapeID, myMainShape )) ? "PUBLISHED" : "";
2142 if ( !tbl->item( row, COL_PUBLISHED ) ) tbl->setItem( row, COL_PUBLISHED, new QTableWidgetItem( text ) );
2143 else tbl->item( row, COL_PUBLISHED )->setText( text ); // if text=="", "PUBLISH" button enabled
2145 text = err.hasBadMesh ? "hasBadMesh" : "";
2146 if ( !tbl->item( row, COL_BAD_MESH ) ) tbl->setItem( row, COL_BAD_MESH, new QTableWidgetItem( text ) );
2147 else tbl->item( row, COL_BAD_MESH )->setText( text );
2148 if ( err.hasBadMesh ) hasBadMesh = true;
2150 //tbl->item( row, COL_ERROR )->setWordWrap( true ); // VSR: TODO ???
2151 tbl->resizeRowToContents( row );
2153 tbl->resizeColumnToContents( COL_ALGO );
2154 tbl->resizeColumnToContents( COL_SHAPE );
2157 aCompDlg->myBadMeshBtn->show();
2159 aCompDlg->myBadMeshBtn->hide();
2161 tbl->setCurrentCell(0,0);
2162 currentCellChanged(); // to update buttons
2165 // show dialog and wait, becase Compute can be invoked from Preview operation
2166 //aCompDlg->exec(); // this way it becomes modal - impossible to rotate model in the Viewer
2171 // =========================================================================================
2173 * \brief Set mesh info
2175 // =========================================================================================
2177 void SMESHGUI_MeshInfosBox::SetInfoByEval(std::vector<int> theVec)
2180 myNbNode ->setText( QString("%1").arg( theVec[0] ));
2183 int nbTot = theVec[1] + theVec[2];
2184 myNbEdge ->setText( QString("%1").arg( nbTot ));
2185 myNbLinEdge ->setText( QString("%1").arg( theVec[1] ));
2186 myNbQuadEdge ->setText( QString("%1").arg( theVec[2] ));
2191 for(; i<=7; i++) nbTot += theVec[i];
2192 myNbFace ->setText( QString("%1").arg( nbTot ));
2193 myNbLinFace ->setText( QString("%1").arg( theVec[3] + theVec[5] ));
2194 myNbQuadFace ->setText( QString("%1").arg( theVec[4] + theVec[6] ));
2198 for(i=8; i<=16; i++) nbTot += theVec[i];
2199 int nbLin = 0, nbQua = 0;;
2200 for(i=0; i<=3; i++) {
2201 nbLin += theVec[8+2*i];
2202 nbQua += theVec[9+2*i];
2204 myNbVolum ->setText( QString("%1").arg( nbTot ));
2205 myNbLinVolum ->setText( QString("%1").arg( nbLin ));
2206 myNbQuadVolum->setText( QString("%1").arg( nbQua ));
2211 myNbTrai ->setText( QString("%1").arg( theVec[3] + theVec[4] ));
2212 myNbLinTrai ->setText( QString("%1").arg( theVec[3] ));
2213 myNbQuadTrai ->setText( QString("%1").arg( theVec[4] ));
2215 myNbQuad ->setText( QString("%1").arg( theVec[5] + theVec[6] ));
2216 myNbLinQuad ->setText( QString("%1").arg( theVec[5] ));
2217 myNbQuadQuad ->setText( QString("%1").arg( theVec[6] ));
2219 myNbPolyg ->setText( QString("%1").arg( theVec[7] ));
2222 myNbTetra ->setText( QString("%1").arg( theVec[8] + theVec[9] ));
2223 myNbLinTetra ->setText( QString("%1").arg( theVec[8] ));
2224 myNbQuadTetra->setText( QString("%1").arg( theVec[9] ));
2226 myNbHexa ->setText( QString("%1").arg( theVec[14] + theVec[15] ));
2227 myNbLinHexa ->setText( QString("%1").arg( theVec[14] ));
2228 myNbQuadHexa ->setText( QString("%1").arg( theVec[15] ));
2230 myNbPyra ->setText( QString("%1").arg( theVec[10] + theVec[11] ));
2231 myNbLinPyra ->setText( QString("%1").arg( theVec[10] ));
2232 myNbQuadPyra ->setText( QString("%1").arg( theVec[11] ));
2234 myNbPrism ->setText( QString("%1").arg( theVec[12] + theVec[13] ));
2235 myNbLinPrism ->setText( QString("%1").arg( theVec[12] ));
2236 myNbQuadPrism->setText( QString("%1").arg( theVec[13] ));
2238 myNbPolyh ->setText( QString("%1").arg( theVec[16] ));
2242 //================================================================================
2244 * \brief Gets dialog of evaluate operation
2245 * \retval SMESHGUI_ComputeDlg* - pointer to dialog of this operation
2247 //================================================================================
2249 SMESHGUI_ComputeDlg* SMESHGUI_BaseComputeOp::evaluateDlg() const
2253 SMESHGUI_BaseComputeOp* me = (SMESHGUI_BaseComputeOp*)this;
2254 me->myCompDlg = new SMESHGUI_ComputeDlg( desktop(), true );
2255 // connect signals and slots
2256 connect(myCompDlg->myShowBtn, SIGNAL (clicked()), SLOT(onPreviewShape()));
2257 connect(myCompDlg->myPublishBtn, SIGNAL (clicked()), SLOT(onPublishShape()));
2258 connect(myCompDlg->myBadMeshBtn, SIGNAL (clicked()), SLOT(onShowBadMesh()));
2259 QTableWidget* aTable = me->table();
2260 connect(aTable, SIGNAL(itemSelectionChanged()), SLOT(currentCellChanged()));
2261 connect(aTable, SIGNAL(currentCellChanged(int,int,int,int)), SLOT(currentCellChanged()));