1 // Copyright (C) 2007-2012 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_MeshInfo.cxx
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 #include "SMESHGUI_MeshInfo.h"
27 #include "SMESH_Actor.h"
29 #include "SMESHGUI_IdValidator.h"
30 #include "SMESHGUI_Utils.h"
31 #include "SMESHGUI_VTKUtils.h"
32 #include "SMDSAbs_ElementType.hxx"
33 #include "SMDS_Mesh.hxx"
34 #include "SMDS_BallElement.hxx"
35 #include "SMDS_EdgePosition.hxx"
36 #include "SMDS_FacePosition.hxx"
37 #include "SMESH_ControlsDef.hxx"
39 #include <LightApp_SelectionMgr.h>
40 #include <SUIT_OverrideCursor.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <SVTK_ViewWindow.h>
44 #include <SALOMEDSClient_Study.hxx>
46 #include <QApplication>
47 #include <QButtonGroup>
48 #include <QContextMenuEvent>
49 #include <QGridLayout>
50 #include <QHBoxLayout>
51 #include <QHeaderView>
52 #include <QItemDelegate>
57 #include <QPushButton>
58 #include <QRadioButton>
60 #include <QTextBrowser>
61 #include <QVBoxLayout>
63 #include "utilities.h"
65 #include <SALOMEconfig.h>
66 #include CORBA_SERVER_HEADER(GEOM_Gen)
68 const int SPACING = 6;
70 const int MAXITEMS = 10;
71 const int GROUPS_ID = 100;
72 const int SUBMESHES_ID = 200;
75 TypeRole = Qt::UserRole + 10,
80 NodeConnectivity = 100,
89 class ExtraWidget : public QWidget
92 ExtraWidget( QWidget*, bool = false );
95 void updateControls( int, int, int = MAXITEMS );
104 ExtraWidget::ExtraWidget( QWidget* parent, bool b ) : QWidget( parent ), brief( b )
106 current = new QLabel( this );
107 current->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
108 prev = new QPushButton( tr( "<<" ), this );
109 next = new QPushButton( tr( ">>" ), this );
110 QHBoxLayout* hbl = new QHBoxLayout( this );
111 hbl->setContentsMargins( 0, SPACING, 0, 0 );
112 hbl->setSpacing( SPACING );
114 hbl->addWidget( current );
115 hbl->addWidget( prev );
116 hbl->addWidget( next );
119 ExtraWidget::~ExtraWidget()
123 void ExtraWidget::updateControls( int total, int index, int blockSize )
125 setVisible( total > blockSize );
126 QString format = brief ? QString( "%1-%2 / %3" ) : SMESHGUI_MeshInfoDlg::tr( "X_FROM_Y_ITEMS_SHOWN" );
127 current->setText( format.arg( index*blockSize+1 ).arg( qMin( index*blockSize+blockSize, total ) ).arg( total ) );
128 prev->setEnabled( index > 0 );
129 next->setEnabled( (index+1)*blockSize < total );
133 \class SMESHGUI_MeshInfo
134 \brief Base mesh information widget
136 Displays the base information about mesh object: mesh, sub-mesh, group or arbitrary ID source.
141 \param parent parent widget
143 SMESHGUI_MeshInfo::SMESHGUI_MeshInfo( QWidget* parent )
144 : QFrame( parent ), myWidgets( iElementsEnd )
146 setFrameStyle( StyledPanel | Sunken );
148 QGridLayout* l = new QGridLayout( this );
149 l->setMargin( MARGIN );
150 l->setSpacing( SPACING );
155 QLabel* aNameLab = new QLabel( tr( "NAME_LAB" ), this );
156 QLabel* aName = createField();
157 aName->setMinimumWidth( 150 );
158 QLabel* aObjLab = new QLabel( tr( "OBJECT_LAB" ), this );
159 QLabel* aObj = createField();
160 aObj->setMinimumWidth( 150 );
161 myWidgets[ index++ ] << aNameLab << aName;
162 myWidgets[ index++ ] << aObjLab << aObj;
165 QWidget* aNodesLine = createLine();
166 QLabel* aNodesLab = new QLabel( tr( "NODES_LAB" ), this );
167 QLabel* aNodes = createField();
168 myWidgets[ index++ ] << aNodesLine;
169 myWidgets[ index++ ] << aNodesLab << aNodes;
172 QWidget* aElemLine = createLine();
173 QLabel* aElemLab = new QLabel( tr( "ELEMENTS_LAB" ), this );
174 QLabel* aElemTotal = new QLabel( tr( "TOTAL_LAB" ), this );
175 QLabel* aElemLin = new QLabel( tr( "LINEAR_LAB" ), this );
176 QLabel* aElemQuad = new QLabel( tr( "QUADRATIC_LAB" ), this );
177 myWidgets[ index++ ] << aElemLine;
178 myWidgets[ index++ ] << aElemLab << aElemTotal << aElemLin << aElemQuad;
181 QWidget* a0DLine = createLine();
182 QLabel* a0DLab = new QLabel( tr( "0D_LAB" ), this );
183 QLabel* a0DTotal = createField();
184 myWidgets[ index++ ] << a0DLine;
185 myWidgets[ index++ ] << a0DLab << a0DTotal;
188 QWidget* aBallLine = createLine();
189 QLabel* aBallLab = new QLabel( tr( "BALL_LAB" ), this );
190 QLabel* aBallTotal = createField();
191 myWidgets[ index++ ] << aBallLine;
192 myWidgets[ index++ ] << aBallLab << aBallTotal;
195 QWidget* a1DLine = createLine();
196 QLabel* a1DLab = new QLabel( tr( "1D_LAB" ), this );
197 QLabel* a1DTotal = createField();
198 QLabel* a1DLin = createField();
199 QLabel* a1DQuad = createField();
200 myWidgets[ index++ ] << a1DLine;
201 myWidgets[ index++ ] << a1DLab << a1DTotal << a1DLin << a1DQuad;
204 QWidget* a2DLine = createLine();
205 QLabel* a2DLab = new QLabel( tr( "2D_LAB" ), this );
206 QLabel* a2DTotal = createField();
207 QLabel* a2DLin = createField();
208 QLabel* a2DQuad = createField();
209 QLabel* a2DTriLab = new QLabel( tr( "TRIANGLES_LAB" ), this );
210 QLabel* a2DTriTotal = createField();
211 QLabel* a2DTriLin = createField();
212 QLabel* a2DTriQuad = createField();
213 QLabel* a2DQuaLab = new QLabel( tr( "QUADRANGLES_LAB" ), this );
214 QLabel* a2DQuaTotal = createField();
215 QLabel* a2DQuaLin = createField();
216 QLabel* a2DQuaQuad = createField();
217 QLabel* a2DPolLab = new QLabel( tr( "POLYGONS_LAB" ), this );
218 QLabel* a2DPolTotal = createField();
219 myWidgets[ index++ ] << a2DLine;
220 myWidgets[ index++ ] << a2DLab << a2DTotal << a2DLin << a2DQuad;
221 myWidgets[ index++ ] << a2DTriLab << a2DTriTotal << a2DTriLin << a2DTriQuad;
222 myWidgets[ index++ ] << a2DQuaLab << a2DQuaTotal << a2DQuaLin << a2DQuaQuad;
223 myWidgets[ index++ ] << a2DPolLab << a2DPolTotal;
226 QWidget* a3DLine = createLine();
227 QLabel* a3DLab = new QLabel( tr( "3D_LAB" ), this );
228 QLabel* a3DTotal = createField();
229 QLabel* a3DLin = createField();
230 QLabel* a3DQuad = createField();
231 QLabel* a3DTetLab = new QLabel( tr( "TETRAHEDRONS_LAB" ), this );
232 QLabel* a3DTetTotal = createField();
233 QLabel* a3DTetLin = createField();
234 QLabel* a3DTetQuad = createField();
235 QLabel* a3DHexLab = new QLabel( tr( "HEXAHEDONRS_LAB" ), this );
236 QLabel* a3DHexTotal = createField();
237 QLabel* a3DHexLin = createField();
238 QLabel* a3DHexQuad = createField();
239 QLabel* a3DPyrLab = new QLabel( tr( "PYRAMIDS_LAB" ), this );
240 QLabel* a3DPyrTotal = createField();
241 QLabel* a3DPyrLin = createField();
242 QLabel* a3DPyrQuad = createField();
243 QLabel* a3DPriLab = new QLabel( tr( "PRISMS_LAB" ), this );
244 QLabel* a3DPriTotal = createField();
245 QLabel* a3DPriLin = createField();
246 QLabel* a3DPriQuad = createField();
247 QLabel* a3DHexPriLab = new QLabel( tr( "HEX_PRISMS_LAB" ), this );
248 QLabel* a3DHexPriTotal = createField();
249 QLabel* a3DPolLab = new QLabel( tr( "POLYHEDRONS_LAB" ), this );
250 QLabel* a3DPolTotal = createField();
251 myWidgets[ index++ ] << a3DLine;
252 myWidgets[ index++ ] << a3DLab << a3DTotal << a3DLin << a3DQuad;
253 myWidgets[ index++ ] << a3DTetLab << a3DTetTotal << a3DTetLin << a3DTetQuad;
254 myWidgets[ index++ ] << a3DHexLab << a3DHexTotal << a3DHexLin << a3DHexQuad;
255 myWidgets[ index++ ] << a3DPyrLab << a3DPyrTotal << a3DPyrLin << a3DPyrQuad;
256 myWidgets[ index++ ] << a3DPriLab << a3DPriTotal << a3DPriLin << a3DPriQuad;
257 myWidgets[ index++ ] << a3DHexPriLab << a3DHexPriTotal;
258 myWidgets[ index++ ] << a3DPolLab << a3DPolTotal;
260 myLoadBtn = new QPushButton( tr( "BUT_LOAD_MESH" ), this );
261 myLoadBtn->setAutoDefault( true );
262 connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( loadMesh() ) );
264 setFontAttributes( aNameLab, Bold );
265 setFontAttributes( aObjLab, Bold );
266 setFontAttributes( aNodesLab, Bold );
267 setFontAttributes( aElemLab, Bold );
268 setFontAttributes( aElemTotal, Italic );
269 setFontAttributes( aElemLin, Italic );
270 setFontAttributes( aElemQuad, Italic );
271 setFontAttributes( a0DLab, Bold );
272 setFontAttributes( aBallLab, Bold );
273 setFontAttributes( a1DLab, Bold );
274 setFontAttributes( a2DLab, Bold );
275 setFontAttributes( a3DLab, Bold );
277 l->addWidget( aNameLab, 0, 0 );
278 l->addWidget( aName, 0, 1, 1, 3 );
279 l->addWidget( aObjLab, 1, 0 );
280 l->addWidget( aObj, 1, 1, 1, 3 );
281 l->addWidget( aNodesLine, 2, 0, 1, 4 );
282 l->addWidget( aNodesLab, 3, 0 );
283 l->addWidget( aNodes, 3, 1 );
284 l->addWidget( aElemLine, 4, 0, 1, 4 );
285 l->addWidget( aElemLab, 5, 0 );
286 l->addWidget( aElemTotal, 5, 1 );
287 l->addWidget( aElemLin, 5, 2 );
288 l->addWidget( aElemQuad, 5, 3 );
289 l->addWidget( a0DLine, 6, 1, 1, 3 );
290 l->addWidget( a0DLab, 7, 0 );
291 l->addWidget( a0DTotal, 7, 1 );
292 l->addWidget( aBallLine, 8, 1, 1, 3 );
293 l->addWidget( aBallLab, 9, 0 );
294 l->addWidget( aBallTotal, 9, 1 );
295 l->addWidget( a1DLine, 10, 1, 1, 3 );
296 l->addWidget( a1DLab, 11, 0 );
297 l->addWidget( a1DTotal, 11, 1 );
298 l->addWidget( a1DLin, 11, 2 );
299 l->addWidget( a1DQuad, 11, 3 );
300 l->addWidget( a2DLine, 12, 1, 1, 3 );
301 l->addWidget( a2DLab, 13, 0 );
302 l->addWidget( a2DTotal, 13, 1 );
303 l->addWidget( a2DLin, 13, 2 );
304 l->addWidget( a2DQuad, 13, 3 );
305 l->addWidget( a2DTriLab, 14, 0 );
306 l->addWidget( a2DTriTotal, 14, 1 );
307 l->addWidget( a2DTriLin, 14, 2 );
308 l->addWidget( a2DTriQuad, 14, 3 );
309 l->addWidget( a2DQuaLab, 15, 0 );
310 l->addWidget( a2DQuaTotal, 15, 1 );
311 l->addWidget( a2DQuaLin, 15, 2 );
312 l->addWidget( a2DQuaQuad, 15, 3 );
313 l->addWidget( a2DPolLab, 16, 0 );
314 l->addWidget( a2DPolTotal, 16, 1 );
315 l->addWidget( a3DLine, 17, 1, 1, 3 );
316 l->addWidget( a3DLab, 18, 0 );
317 l->addWidget( a3DTotal, 18, 1 );
318 l->addWidget( a3DLin, 18, 2 );
319 l->addWidget( a3DQuad, 18, 3 );
320 l->addWidget( a3DTetLab, 19, 0 );
321 l->addWidget( a3DTetTotal, 19, 1 );
322 l->addWidget( a3DTetLin, 19, 2 );
323 l->addWidget( a3DTetQuad, 19, 3 );
324 l->addWidget( a3DHexLab, 20, 0 );
325 l->addWidget( a3DHexTotal, 20, 1 );
326 l->addWidget( a3DHexLin, 20, 2 );
327 l->addWidget( a3DHexQuad, 20, 3 );
328 l->addWidget( a3DPyrLab, 21, 0 );
329 l->addWidget( a3DPyrTotal, 21, 1 );
330 l->addWidget( a3DPyrLin, 21, 2 );
331 l->addWidget( a3DPyrQuad, 21, 3 );
332 l->addWidget( a3DPriLab, 22, 0 );
333 l->addWidget( a3DPriTotal, 22, 1 );
334 l->addWidget( a3DPriLin, 22, 2 );
335 l->addWidget( a3DPriQuad, 22, 3 );
336 l->addWidget( a3DHexPriLab, 23, 0 );
337 l->addWidget( a3DHexPriTotal, 23, 1 );
338 l->addWidget( a3DPolLab, 24, 0 );
339 l->addWidget( a3DPolTotal, 24, 1 );
340 l->addWidget( myLoadBtn, 25, 1, 1, 3 );
341 l->setColumnStretch( 0, 0 );
342 l->setColumnStretch( 1, 5 );
343 l->setColumnStretch( 2, 5 );
344 l->setColumnStretch( 3, 5 );
345 l->setRowStretch( 23, 5 );
353 SMESHGUI_MeshInfo::~SMESHGUI_MeshInfo()
358 \brief Show information on the mesh object.
359 \param obj object being processed (mesh, sub-mesh, group, ID source)
361 void SMESHGUI_MeshInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
364 if ( !CORBA::is_nil( obj ) ) {
365 _PTR(SObject) sobj = SMESH::ObjectToSObject( obj );
367 myWidgets[iName][iSingle]->setProperty( "text", sobj->GetName().c_str() );
368 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( obj );
369 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
370 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( obj );
371 if ( !aMesh->_is_nil() ) {
372 myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_MESH" ) );
374 else if ( !aSubMesh->_is_nil() ) {
375 myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_SUBMESH" ) );
377 else if ( !aGroup->_is_nil() ) {
379 switch( aGroup->GetType() ) {
381 objType = tr( "OBJECT_GROUP_NODES" );
384 objType = tr( "OBJECT_GROUP_EDGES" );
387 objType = tr( "OBJECT_GROUP_FACES" );
390 objType = tr( "OBJECT_GROUP_VOLUMES" );
393 objType = tr( "OBJECT_GROUP_0DELEMS" );
396 objType = tr( "OBJECT_GROUP_BALLS" );
399 objType = tr( "OBJECT_GROUP" );
402 myWidgets[iObject][iSingle]->setProperty( "text", objType );
404 SMESH::long_array_var info = obj->GetMeshInfo();
405 myWidgets[iNodes][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Node] ) );
406 myWidgets[i0D][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_0D] ) );
407 myWidgets[iBalls][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Ball] ) );
408 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
409 myWidgets[i1D][iTotal] ->setProperty( "text", QString::number( nbEdges ) );
410 myWidgets[i1D][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Edge] ) );
411 myWidgets[i1D][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Edge] ) );
412 long nbTriangles = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle];
413 long nbQuadrangles = info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle];
414 long nb2DLinear = info[SMDSEntity_Triangle] + info[SMDSEntity_Quadrangle] + info[SMDSEntity_Polygon];
415 long nb2DQuadratic = info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle];
416 myWidgets[i2D][iTotal] ->setProperty( "text", QString::number( nb2DLinear + nb2DQuadratic ) );
417 myWidgets[i2D][iLinear] ->setProperty( "text", QString::number( nb2DLinear ) );
418 myWidgets[i2D][iQuadratic] ->setProperty( "text", QString::number( nb2DQuadratic ) );
419 myWidgets[i2DTriangles][iTotal] ->setProperty( "text", QString::number( nbTriangles ) );
420 myWidgets[i2DTriangles][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Triangle] ) );
421 myWidgets[i2DTriangles][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Triangle] ) );
422 myWidgets[i2DQuadrangles][iTotal] ->setProperty( "text", QString::number( nbQuadrangles ) );
423 myWidgets[i2DQuadrangles][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Quadrangle] ) );
424 myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] ));
425 myWidgets[i2DPolygons][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Polygon] ) );
426 long nbTetrahedrons = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra];
427 long nbHexahedrons = info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa];
428 long nbPyramids = info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid];
429 long nbPrisms = info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta];
430 long nb3DLinear = info[SMDSEntity_Tetra] + info[SMDSEntity_Hexa] + info[SMDSEntity_Pyramid] + info[SMDSEntity_Penta] + info[SMDSEntity_Polyhedra] + info[SMDSEntity_Hexagonal_Prism];
431 long nb3DQuadratic = info[SMDSEntity_Quad_Tetra] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] + info[SMDSEntity_Quad_Pyramid] + info[SMDSEntity_Quad_Penta];
432 myWidgets[i3D][iTotal] ->setProperty( "text", QString::number( nb3DLinear + nb3DQuadratic ) );
433 myWidgets[i3D][iLinear] ->setProperty( "text", QString::number( nb3DLinear ) );
434 myWidgets[i3D][iQuadratic] ->setProperty( "text", QString::number( nb3DQuadratic ) );
435 myWidgets[i3DTetrahedrons][iTotal] ->setProperty( "text", QString::number( nbTetrahedrons ) );
436 myWidgets[i3DTetrahedrons][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Tetra] ) );
437 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Tetra] ) );
438 myWidgets[i3DHexahedrons][iTotal] ->setProperty( "text", QString::number( nbHexahedrons ) );
439 myWidgets[i3DHexahedrons][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Hexa] ) );
440 myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] ) );
441 myWidgets[i3DPyramids][iTotal] ->setProperty( "text", QString::number( nbPyramids ) );
442 myWidgets[i3DPyramids][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Pyramid] ) );
443 myWidgets[i3DPyramids][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Pyramid] ) );
444 myWidgets[i3DPrisms][iTotal] ->setProperty( "text", QString::number( nbPrisms ) );
445 myWidgets[i3DPrisms][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Penta] ) );
446 myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Penta] ) );
447 myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Hexagonal_Prism] ) );
448 myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Polyhedra] ) );
450 // before full loading from study file, type of elements in a sub-mesh can't be defined
452 bool infoOK = obj->IsMeshInfoCorrect();
453 myLoadBtn->setVisible( !infoOK );
457 // 1. Type of 2D or 3D elements is unknown but their nb is OK (for a sub-mesh)
458 // 2. No info at all (for a group on geom or filter)
459 bool hasAnyInfo = false;
460 for ( size_t i = 0; i < info->length() && !hasAnyInfo; ++i )
461 hasAnyInfo = info[i];
462 if ( hasAnyInfo ) // believe it is a sub-mesh
464 if ( nb2DLinear + nb2DQuadratic > 0 )
466 myWidgets[i2D][iLinear] ->setProperty( "text", "?" );
467 myWidgets[i2D][iQuadratic] ->setProperty( "text", "?" );
468 myWidgets[i2DTriangles][iTotal] ->setProperty( "text", "?" );
469 myWidgets[i2DTriangles][iLinear] ->setProperty( "text", "?" );
470 myWidgets[i2DTriangles][iQuadratic] ->setProperty( "text", "?" );
471 myWidgets[i2DQuadrangles][iTotal] ->setProperty( "text", "?" );
472 myWidgets[i2DQuadrangles][iLinear] ->setProperty( "text", "?" );
473 myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", "?" );
474 myWidgets[i2DPolygons][iTotal] ->setProperty( "text", "?" );
476 else if ( nb3DLinear + nb3DQuadratic > 0 )
478 myWidgets[i3D][iLinear] ->setProperty( "text", "?" );
479 myWidgets[i3D][iQuadratic] ->setProperty( "text", "?" );
480 myWidgets[i3DTetrahedrons][iTotal] ->setProperty( "text", "?" );
481 myWidgets[i3DTetrahedrons][iLinear] ->setProperty( "text", "?" );
482 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", "?" );
483 myWidgets[i3DHexahedrons][iTotal] ->setProperty( "text", "?" );
484 myWidgets[i3DHexahedrons][iLinear] ->setProperty( "text", "?" );
485 myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", "?" );
486 myWidgets[i3DPyramids][iTotal] ->setProperty( "text", "?" );
487 myWidgets[i3DPyramids][iLinear] ->setProperty( "text", "?" );
488 myWidgets[i3DPyramids][iQuadratic] ->setProperty( "text", "?" );
489 myWidgets[i3DPrisms][iTotal] ->setProperty( "text", "?" );
490 myWidgets[i3DPrisms][iLinear] ->setProperty( "text", "?" );
491 myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", "?" );
492 myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", "?" );
493 myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", "?" );
498 myWidgets[iNodes][iTotal] ->setProperty( "text", "?" );
499 myWidgets[i0D][iTotal] ->setProperty( "text", "?" );
500 myWidgets[iBalls][iTotal] ->setProperty( "text", "?" );
501 myWidgets[i1D][iTotal] ->setProperty( "text", "?" );
502 myWidgets[i1D][iLinear] ->setProperty( "text", "?" );
503 myWidgets[i1D][iQuadratic] ->setProperty( "text", "?" );
504 myWidgets[i2D][iTotal] ->setProperty( "text", "?" );
505 myWidgets[i2D][iLinear] ->setProperty( "text", "?" );
506 myWidgets[i2D][iQuadratic] ->setProperty( "text", "?" );
507 myWidgets[i2DTriangles][iTotal] ->setProperty( "text", "?" );
508 myWidgets[i2DTriangles][iLinear] ->setProperty( "text", "?" );
509 myWidgets[i2DTriangles][iQuadratic] ->setProperty( "text", "?" );
510 myWidgets[i2DQuadrangles][iTotal] ->setProperty( "text", "?" );
511 myWidgets[i2DQuadrangles][iLinear] ->setProperty( "text", "?" );
512 myWidgets[i2DQuadrangles][iQuadratic] ->setProperty( "text", "?" );
513 myWidgets[i2DPolygons][iTotal] ->setProperty( "text", "?" );
514 myWidgets[i3D][iTotal] ->setProperty( "text", "?" );
515 myWidgets[i3D][iLinear] ->setProperty( "text", "?" );
516 myWidgets[i3D][iQuadratic] ->setProperty( "text", "?" );
517 myWidgets[i3DTetrahedrons][iTotal] ->setProperty( "text", "?" );
518 myWidgets[i3DTetrahedrons][iLinear] ->setProperty( "text", "?" );
519 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", "?" );
520 myWidgets[i3DHexahedrons][iTotal] ->setProperty( "text", "?" );
521 myWidgets[i3DHexahedrons][iLinear] ->setProperty( "text", "?" );
522 myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", "?" );
523 myWidgets[i3DPyramids][iTotal] ->setProperty( "text", "?" );
524 myWidgets[i3DPyramids][iLinear] ->setProperty( "text", "?" );
525 myWidgets[i3DPyramids][iQuadratic] ->setProperty( "text", "?" );
526 myWidgets[i3DPrisms][iTotal] ->setProperty( "text", "?" );
527 myWidgets[i3DPrisms][iLinear] ->setProperty( "text", "?" );
528 myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", "?" );
529 myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", "?" );
530 myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", "?" );
537 \brief Load mesh from a study file
539 void SMESHGUI_MeshInfo::loadMesh()
541 SUIT_OverrideCursor wc;
543 SALOME_ListIO selected;
544 SMESHGUI::selectionMgr()->selectedObjects( selected );
546 if ( selected.Extent() == 1 ) {
547 Handle(SALOME_InteractiveObject) IO = selected.First();
548 SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
549 if ( !CORBA::is_nil( obj ) ) {
550 SMESH::SMESH_Mesh_var mesh = obj->GetMesh();
551 if ( !mesh->_is_nil() )
561 \brief Reset the widget to the initial state (nullify all fields).
563 void SMESHGUI_MeshInfo::clear()
565 myWidgets[iName][iSingle] ->setProperty( "text", QString() );
566 myWidgets[iObject][iSingle] ->setProperty( "text", QString() );
567 myWidgets[iNodes][iTotal] ->setProperty( "text", QString::number( 0 ) );
568 myWidgets[i0D][iTotal] ->setProperty( "text", QString::number( 0 ) );
569 myWidgets[iBalls][iTotal] ->setProperty( "text", QString::number( 0 ) );
570 myWidgets[i1D][iTotal] ->setProperty( "text", QString::number( 0 ) );
571 myWidgets[i1D][iLinear] ->setProperty( "text", QString::number( 0 ) );
572 myWidgets[i1D][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
573 myWidgets[i2D][iTotal] ->setProperty( "text", QString::number( 0 ) );
574 myWidgets[i2D][iLinear] ->setProperty( "text", QString::number( 0 ) );
575 myWidgets[i2D][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
576 myWidgets[i2DTriangles][iTotal] ->setProperty( "text", QString::number( 0 ) );
577 myWidgets[i2DTriangles][iLinear] ->setProperty( "text", QString::number( 0 ) );
578 myWidgets[i2DTriangles][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
579 myWidgets[i2DQuadrangles][iTotal] ->setProperty( "text", QString::number( 0 ) );
580 myWidgets[i2DQuadrangles][iLinear] ->setProperty( "text", QString::number( 0 ) );
581 myWidgets[i2DQuadrangles][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
582 myWidgets[i2DPolygons][iTotal] ->setProperty( "text", QString::number( 0 ) );
583 myWidgets[i3D][iTotal] ->setProperty( "text", QString::number( 0 ) );
584 myWidgets[i3D][iLinear] ->setProperty( "text", QString::number( 0 ) );
585 myWidgets[i3D][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
586 myWidgets[i3DTetrahedrons][iTotal] ->setProperty( "text", QString::number( 0 ) );
587 myWidgets[i3DTetrahedrons][iLinear] ->setProperty( "text", QString::number( 0 ) );
588 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( 0 ) );
589 myWidgets[i3DHexahedrons][iTotal] ->setProperty( "text", QString::number( 0 ) );
590 myWidgets[i3DHexahedrons][iLinear] ->setProperty( "text", QString::number( 0 ) );
591 myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
592 myWidgets[i3DPyramids][iTotal] ->setProperty( "text", QString::number( 0 ) );
593 myWidgets[i3DPyramids][iLinear] ->setProperty( "text", QString::number( 0 ) );
594 myWidgets[i3DPyramids][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
595 myWidgets[i3DPrisms][iTotal] ->setProperty( "text", QString::number( 0 ) );
596 myWidgets[i3DPrisms][iLinear] ->setProperty( "text", QString::number( 0 ) );
597 myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
598 myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", QString::number( 0 ) );
599 myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", QString::number( 0 ) );
603 \brief Create info field
604 \return new info field
606 QLabel* SMESHGUI_MeshInfo::createField()
608 QLabel* lab = new QLabel( this );
609 lab->setFrameStyle( StyledPanel | Sunken );
610 lab->setAlignment( Qt::AlignCenter );
611 lab->setAutoFillBackground( true );
612 QPalette pal = lab->palette();
613 pal.setColor( QPalette::Window, QApplication::palette().color( QPalette::Active, QPalette::Base ) );
614 lab->setPalette( pal );
615 lab->setMinimumWidth( 70 );
620 \brief Create horizontal rule.
621 \return new line object
623 QWidget* SMESHGUI_MeshInfo::createLine()
625 QFrame* line = new QFrame( this );
626 line->setFrameStyle( HLine | Sunken );
631 \brief Change widget font attributes (bold, italic, ...).
633 \param attr font attributes (XORed flags)
634 \param val value to be set to attributes
636 void SMESHGUI_MeshInfo::setFontAttributes( QWidget* w, int attr, bool val )
640 if ( attr & Bold ) f.setBold( val );
641 if ( attr & Italic ) f.setItalic( val );
647 \brief Show/hide group(s) of fields.
648 \param start beginning of the block
649 \param end end of the block
650 \param on visibility flag
652 void SMESHGUI_MeshInfo::setFieldsVisible( int start, int end, bool on )
654 start = qMax( 0, start );
655 end = qMin( end, (int)iElementsEnd );
656 for ( int i = start; i < end; i++ ) {
657 wlist wl = myWidgets[i];
658 foreach ( QWidget* w, wl ) w->setVisible( on );
663 \class SMESHGUI_ElemInfo
664 \brief Base class for the mesh element information widget.
669 \param parent parent widget
671 SMESHGUI_ElemInfo::SMESHGUI_ElemInfo( QWidget* parent )
672 : QWidget( parent ), myActor( 0 ), myIsElement( -1 )
674 myFrame = new QWidget( this );
675 myExtra = new ExtraWidget( this );
676 QVBoxLayout* vbl = new QVBoxLayout( this );
678 vbl->setSpacing( 0 );
679 vbl->addWidget( myFrame );
680 vbl->addWidget( myExtra );
681 connect( myExtra->prev, SIGNAL( clicked() ), this, SLOT( showPrevious() ) );
682 connect( myExtra->next, SIGNAL( clicked() ), this, SLOT( showNext() ) );
689 SMESHGUI_ElemInfo::~SMESHGUI_ElemInfo()
694 \brief Set mesh data source (actor)
695 \param actor mesh object actor
697 void SMESHGUI_ElemInfo::setSource( SMESH_Actor* actor )
699 if ( myActor != actor ) {
707 \brief Show mesh element information
708 \param id mesh node / element ID
709 \param isElem show mesh element information if \c true or mesh node information if \c false
711 void SMESHGUI_ElemInfo::showInfo( long id, bool isElem )
715 showInfo( ids, isElem );
719 \brief Show mesh element information
720 \param ids mesh nodes / elements identifiers
721 \param isElem show mesh element information if \c true or mesh node information if \c false
723 void SMESHGUI_ElemInfo::showInfo( QSet<long> ids, bool isElem )
725 QList<long> newIds = ids.toList();
727 if ( myIDs == newIds && myIsElement == isElem ) return;
730 myIsElement = isElem;
733 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
737 \brief Clear mesh element information widget
739 void SMESHGUI_ElemInfo::clear()
748 \brief Get central area widget
749 \return central widget
751 QWidget* SMESHGUI_ElemInfo::frame() const
758 \return actor being used
760 SMESH_Actor* SMESHGUI_ElemInfo::actor() const
766 \brief Get current info mode.
767 \return \c true if mesh element information is shown or \c false if node information is shown
769 bool SMESHGUI_ElemInfo::isElements() const
775 \fn void SMESHGUI_ElemInfo::information( const QList<long>& ids )
776 \brief Show information on the specified nodes / elements
778 This function is to be redefined in sub-classes.
780 \param ids nodes / elements identifiers information is to be shown on
784 \brief Internal clean-up (reset widget)
786 void SMESHGUI_ElemInfo::clearInternal()
791 \brief Get node connectivity
792 \param node mesh node
793 \return node connectivity map
795 SMESHGUI_ElemInfo::Connectivity SMESHGUI_ElemInfo::nodeConnectivity( const SMDS_MeshNode* node )
799 SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
800 while ( it && it->more() ) {
801 const SMDS_MeshElement* ne = it->next();
802 elmap[ ne->GetType() ] << ne->GetID();
809 \brief Format connectivity data to string representation
810 \param connectivity connetivity map
811 \param type element type
812 \return string representation of the connectivity
814 QString SMESHGUI_ElemInfo::formatConnectivity( Connectivity connectivity, int type )
817 if ( connectivity.contains( type ) ) {
818 QList<int> elements = connectivity[ type ];
820 foreach( int id, elements )
821 str << QString::number( id );
823 return str.join( " " );
827 \brief Calculate gravity center of the mesh element
828 \param element mesh element
830 SMESHGUI_ElemInfo::XYZ SMESHGUI_ElemInfo::gravityCenter( const SMDS_MeshElement* element )
834 SMDS_ElemIteratorPtr nodeIt = element->nodesIterator();
835 while ( nodeIt->more() ) {
836 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
837 xyz.add( node->X(), node->Y(), node->Z() );
839 xyz.divide( element->NbNodes() );
845 \brief This slot is called from "Show Previous" button click.
846 Shows information on the previous group of the items.
848 void SMESHGUI_ElemInfo::showPrevious()
850 myIndex = qMax( 0, myIndex-1 );
852 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
856 \brief This slot is called from "Show Next" button click.
857 Shows information on the next group of the items.
859 void SMESHGUI_ElemInfo::showNext()
861 myIndex = qMin( myIndex+1, myIDs.count() / MAXITEMS );
863 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
867 \brief Update widgets state
869 void SMESHGUI_ElemInfo::updateControls()
871 myExtra->updateControls( myIDs.count(), myIndex );
875 \class SMESHGUI_SimpleElemInfo
876 \brief Represents mesh element information in the simple text area.
881 \param parent parent widget
883 SMESHGUI_SimpleElemInfo::SMESHGUI_SimpleElemInfo( QWidget* parent )
884 : SMESHGUI_ElemInfo( parent )
886 myInfo = new QTextBrowser( frame() );
887 QVBoxLayout* l = new QVBoxLayout( frame() );
889 l->addWidget( myInfo );
893 \brief Show mesh element information
894 \param ids mesh nodes / elements identifiers
896 void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
901 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
903 if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) )
904 cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 );
905 foreach ( long id, ids ) {
906 if ( !isElements() ) {
910 const SMDS_MeshNode* node = actor()->GetObject()->GetMesh()->FindNode( id );
914 myInfo->append( QString( "<b>%1 #%2</b>" ).arg( tr( "NODE" ) ).arg( id ) );
916 myInfo->append( "" );
918 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
919 arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
920 arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
921 arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
923 myInfo->append( "" );
925 Connectivity connectivity = nodeConnectivity( node );
926 if ( !connectivity.isEmpty() ) {
927 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
928 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
929 if ( !con.isEmpty() )
930 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
931 con = formatConnectivity( connectivity, SMDSAbs_Edge );
932 if ( !con.isEmpty() )
933 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
934 con = formatConnectivity( connectivity, SMDSAbs_Ball );
935 if ( !con.isEmpty() )
936 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "BALL_ELEMENTS" ) ).arg( con ) );
937 con = formatConnectivity( connectivity, SMDSAbs_Face );
938 if ( !con.isEmpty() )
939 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
940 con = formatConnectivity( connectivity, SMDSAbs_Volume );
941 if ( !con.isEmpty() )
942 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
945 myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
952 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
953 SMESH::Controls::NumericalFunctorPtr afunctor;
956 // element ID && type
958 switch( e->GetType() ) {
959 case SMDSAbs_0DElement:
960 stype = tr( "0D ELEMENT" ); break;
962 stype = tr( "BALL" ); break;
964 stype = tr( "EDGE" ); break;
966 stype = tr( "FACE" ); break;
968 stype = tr( "VOLUME" ); break;
972 if ( stype.isEmpty() ) return;
973 myInfo->append( QString( "<b>%1 #%2</b>" ).arg( stype ).arg( id ) );
975 myInfo->append( "" );
978 switch( e->GetEntityType() ) {
979 case SMDSEntity_Triangle:
980 case SMDSEntity_Quad_Triangle:
981 gtype = tr( "TRIANGLE" ); break;
982 case SMDSEntity_Quadrangle:
983 case SMDSEntity_Quad_Quadrangle:
984 case SMDSEntity_BiQuad_Quadrangle:
985 gtype = tr( "QUADRANGLE" ); break;
986 case SMDSEntity_Polygon:
987 case SMDSEntity_Quad_Polygon:
988 gtype = tr( "POLYGON" ); break;
989 case SMDSEntity_Tetra:
990 case SMDSEntity_Quad_Tetra:
991 gtype = tr( "TETRAHEDRON" ); break;
992 case SMDSEntity_Pyramid:
993 case SMDSEntity_Quad_Pyramid:
994 gtype = tr( "PYRAMID" ); break;
995 case SMDSEntity_Hexa:
996 case SMDSEntity_Quad_Hexa:
997 case SMDSEntity_TriQuad_Hexa:
998 gtype = tr( "HEXAHEDRON" ); break;
999 case SMDSEntity_Penta:
1000 case SMDSEntity_Quad_Penta:
1001 gtype = tr( "PRISM" ); break;
1002 case SMDSEntity_Hexagonal_Prism:
1003 gtype = tr( "HEX_PRISM" ); break;
1004 case SMDSEntity_Polyhedra:
1005 case SMDSEntity_Quad_Polyhedra:
1006 gtype = tr( "POLYHEDRON" ); break;
1010 if ( !gtype.isEmpty() )
1011 myInfo->append( QString( "<b>%1:</b> %2" ).arg( tr( "TYPE" ) ).arg( gtype ) );
1012 // quadratic flag and gravity center (any element except 0D)
1013 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Ball ) {
1015 myInfo->append( QString( "<b>%1?</b> %2" ).arg( tr( "QUADRATIC" ) ).arg( e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) ) );
1017 myInfo->append( "" );
1019 XYZ gc = gravityCenter( e );
1020 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "GRAVITY_CENTER" ) ).arg( gc.x() ).arg( gc.y() ).arg( gc.z() ) );
1022 if ( const SMDS_BallElement* ball = dynamic_cast<const SMDS_BallElement*>( e )) {
1024 myInfo->append( QString( "<b>%1:</b> %2" ).arg( tr( "BALL_DIAMETER" ) ).arg( ball->GetDiameter() ));
1027 myInfo->append( "" );
1029 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
1030 for ( int idx = 1; nodeIt->more(); idx++ ) {
1031 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
1032 // node number and ID
1033 myInfo->append( QString( "<b>%1 %2/%3</b> - #%4" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ).arg( node->GetID() ) );
1035 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
1036 arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
1037 arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
1038 arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1039 // node connectivity
1040 Connectivity connectivity = nodeConnectivity( node );
1041 if ( !connectivity.isEmpty() ) {
1042 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
1043 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1044 if ( !con.isEmpty() )
1045 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
1046 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1047 if ( !con.isEmpty() )
1048 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
1049 con = formatConnectivity( connectivity, SMDSAbs_Face );
1050 if ( !con.isEmpty() )
1051 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
1052 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1053 if ( !con.isEmpty() )
1054 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
1057 myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
1061 myInfo->append( "" );
1063 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "MEN_CTRL" ) ) );
1065 if ( e->GetType() == SMDSAbs_Edge ) {
1066 afunctor.reset( new SMESH::Controls::Length() );
1067 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1068 afunctor->SetPrecision( cprecision );
1069 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "LENGTH_EDGES" ) ).arg( afunctor->GetValue( id ) ) );
1071 if( e->GetType() == SMDSAbs_Face ) {
1073 afunctor.reset( new SMESH::Controls::Area() );
1074 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1075 afunctor->SetPrecision( cprecision );
1076 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "AREA_ELEMENTS" ) ).arg( afunctor->GetValue( id ) ) );
1078 afunctor.reset( new SMESH::Controls::Taper() );
1079 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1080 afunctor->SetPrecision( cprecision );
1081 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MEN_TAPER" ) ).arg( afunctor->GetValue( id ) ) );
1083 afunctor.reset( new SMESH::Controls::AspectRatio() );
1084 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1085 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "ASPECTRATIO_ELEMENTS" ) ).arg( afunctor->GetValue( id ) ) );
1087 afunctor.reset( new SMESH::Controls::MinimumAngle() );
1088 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1089 afunctor->SetPrecision( cprecision );
1090 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MINIMUMANGLE_ELEMENTS" ) ).arg( afunctor->GetValue( id ) ) );
1092 afunctor.reset( new SMESH::Controls::Warping() );
1093 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1094 afunctor->SetPrecision( cprecision );
1095 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "STB_WARP" ) ).arg( afunctor->GetValue( id ) ) );
1097 afunctor.reset( new SMESH::Controls::Skew() );
1098 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1099 afunctor->SetPrecision( cprecision );
1100 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "TOP_SKEW" ) ).arg( afunctor->GetValue( id ) ) );
1102 afunctor.reset( new SMESH::Controls::MaxElementLength2D() );
1103 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1104 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_2D" ) ).arg( afunctor->GetValue( id ) ) );
1106 if( e->GetType() == SMDSAbs_Volume ) {
1108 afunctor.reset( new SMESH::Controls::AspectRatio3D() );
1109 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1110 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "ASPECTRATIO_3D_ELEMENTS" ) ).arg( afunctor->GetValue( id ) ) );
1112 afunctor.reset( new SMESH::Controls::Volume() );
1113 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1114 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MEN_VOLUME_3D" ) ).arg( afunctor->GetValue( id ) ) );
1116 afunctor.reset( new SMESH::Controls::Volume() );
1117 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1118 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_3D" ) ).arg( afunctor->GetValue( id ) ) );
1121 if( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
1123 myInfo->append( "" );
1125 int shapeID = e->getshapeId();
1126 if ( shapeID > 0 ) {
1128 switch ( actor()->GetObject()->GetMesh()->FindElement( shapeID )->GetType() ) {
1129 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" ); break;
1130 case SMDS_TOP_FACE: shapeType = tr( "FACE" ); break;
1131 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1132 default: shapeType = tr( "SOLID" );
1134 myInfo->append( QString( "<b>%1:</b> %2 #%3" ).arg( tr( "Position" ) ).arg( shapeType ).arg( shapeID ) );
1140 if ( ids.count() > 1 ) {
1141 myInfo->append( "" );
1142 myInfo->append( "------" );
1143 myInfo->append( "" );
1150 \brief Internal clean-up (reset widget)
1152 void SMESHGUI_SimpleElemInfo::clearInternal()
1158 \class SMESHGUI_TreeElemInfo::ItemDelegate
1159 \brief Item delegate for tree mesh info widget
1162 class SMESHGUI_TreeElemInfo::ItemDelegate : public QItemDelegate
1165 ItemDelegate( QObject* );
1166 QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
1173 SMESHGUI_TreeElemInfo::ItemDelegate::ItemDelegate( QObject* parent ) : QItemDelegate( parent )
1178 \brief Create item editor widget
1181 QWidget* SMESHGUI_TreeElemInfo::ItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
1183 QWidget* w = index.column() == 0 ? 0: QItemDelegate::createEditor( parent, option, index );
1184 if ( qobject_cast<QLineEdit*>( w ) ) qobject_cast<QLineEdit*>( w )->setReadOnly( true );
1189 \class SMESHGUI_TreeElemInfo
1190 \brief Represents mesh element information in the tree-like form.
1195 \param parent parent widget
1197 SMESHGUI_TreeElemInfo::SMESHGUI_TreeElemInfo( QWidget* parent )
1198 : SMESHGUI_ElemInfo( parent )
1200 myInfo = new QTreeWidget( frame() );
1201 myInfo->setColumnCount( 2 );
1202 myInfo->setHeaderLabels( QStringList() << tr( "PROPERTY" ) << tr( "VALUE" ) );
1203 myInfo->header()->setStretchLastSection( true );
1204 myInfo->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
1205 myInfo->setItemDelegate( new ItemDelegate( myInfo ) );
1206 QVBoxLayout* l = new QVBoxLayout( frame() );
1208 l->addWidget( myInfo );
1209 connect( myInfo, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( itemDoubleClicked( QTreeWidgetItem*, int ) ) );
1213 \brief Show mesh element information
1214 \param ids mesh nodes / elements identifiers
1216 void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
1221 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
1222 int cprecision = -1;
1223 if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) )
1224 cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 );
1225 foreach ( long id, ids ) {
1226 if ( !isElements() ) {
1230 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
1232 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
1235 QTreeWidgetItem* nodeItem = createItem( 0, Bold | All );
1236 nodeItem->setText( 0, tr( "NODE" ) );
1237 nodeItem->setText( 1, QString( "#%1" ).arg( id ) );
1239 QTreeWidgetItem* coordItem = createItem( nodeItem, Bold );
1240 coordItem->setText( 0, tr( "COORDINATES" ) );
1241 QTreeWidgetItem* xItem = createItem( coordItem );
1242 xItem->setText( 0, "X" );
1243 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1244 QTreeWidgetItem* yItem = createItem( coordItem );
1245 yItem->setText( 0, "Y" );
1246 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1247 QTreeWidgetItem* zItem = createItem( coordItem );
1248 zItem->setText( 0, "Z" );
1249 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1251 QTreeWidgetItem* conItem = createItem( nodeItem, Bold );
1252 conItem->setText( 0, tr( "CONNECTIVITY" ) );
1253 Connectivity connectivity = nodeConnectivity( node );
1254 if ( !connectivity.isEmpty() ) {
1255 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1256 if ( !con.isEmpty() ) {
1257 QTreeWidgetItem* i = createItem( conItem );
1258 i->setText( 0, tr( "0D_ELEMENTS" ) );
1259 i->setText( 1, con );
1261 con = formatConnectivity( connectivity, SMDSAbs_Ball );
1262 if ( !con.isEmpty() ) {
1263 QTreeWidgetItem* i = createItem( conItem );
1264 i->setText( 0, tr( "BALL_ELEMENTS" ) );
1265 i->setText( 1, con );
1266 i->setData( 1, TypeRole, NodeConnectivity );
1268 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1269 if ( !con.isEmpty() ) {
1270 QTreeWidgetItem* i = createItem( conItem );
1271 i->setText( 0, tr( "EDGES" ) );
1272 i->setText( 1, con );
1273 i->setData( 1, TypeRole, NodeConnectivity );
1275 con = formatConnectivity( connectivity, SMDSAbs_Face );
1276 if ( !con.isEmpty() ) {
1277 QTreeWidgetItem* i = createItem( conItem );
1278 i->setText( 0, tr( "FACES" ) );
1279 i->setText( 1, con );
1280 i->setData( 1, TypeRole, NodeConnectivity );
1282 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1283 if ( !con.isEmpty() ) {
1284 QTreeWidgetItem* i = createItem( conItem );
1285 i->setText( 0, tr( "VOLUMES" ) );
1286 i->setText( 1, con );
1287 i->setData( 1, TypeRole, NodeConnectivity );
1291 conItem->setText( 1, tr( "FREE_NODE" ) );
1294 int shapeID = node->getshapeId();
1297 SMDS_PositionPtr pos = node->GetPosition();
1298 SMDS_TypeOfPosition posType = pos->GetTypeOfPosition();
1301 switch ( posType ) {
1302 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" );
1303 u = static_cast<SMDS_EdgePosition*>( pos )->GetUParameter();
1305 case SMDS_TOP_FACE: shapeType = tr( "FACE" );
1306 u = static_cast<SMDS_FacePosition*>( pos )->GetUParameter();
1307 v = static_cast<SMDS_FacePosition*>( pos )->GetVParameter();
1309 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1310 default: shapeType = tr( "SOLID" );
1312 QTreeWidgetItem* posItem = createItem( nodeItem, Bold );
1313 posItem->setText( 0, tr("NODE_POSITION") );
1314 posItem->setText( 1, (shapeType + " #%1").arg( shapeID ));
1315 if ( posType == SMDS_TOP_EDGE || posType == SMDS_TOP_FACE ) {
1316 QTreeWidgetItem* uItem = createItem( posItem );
1317 uItem->setText( 0, tr("U_POSITION") );
1318 uItem->setText( 1, QString::number( u, precision > 0 ? 'f' : 'g', qAbs( precision )));
1319 if ( posType == SMDS_TOP_FACE ) {
1320 QTreeWidgetItem* vItem = createItem( posItem );
1321 vItem->setText( 0, tr("V_POSITION") );
1322 vItem->setText( 1, QString::number( v, precision > 0 ? 'f' : 'g', qAbs( precision )));
1329 // show element info
1331 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
1332 SMESH::Controls::NumericalFunctorPtr afunctor;
1335 // element ID && type
1337 switch( e->GetType() ) {
1338 case SMDSAbs_0DElement:
1339 stype = tr( "0D ELEMENT" ); break;
1341 stype = tr( "BALL" ); break;
1343 stype = tr( "EDGE" ); break;
1345 stype = tr( "FACE" ); break;
1346 case SMDSAbs_Volume:
1347 stype = tr( "VOLUME" ); break;
1351 if ( stype.isEmpty() ) return;
1352 QTreeWidgetItem* elemItem = createItem( 0, Bold | All );
1353 elemItem->setText( 0, stype );
1354 elemItem->setText( 1, QString( "#%1" ).arg( id ) );
1357 switch( e->GetEntityType() ) {
1358 case SMDSEntity_Triangle:
1359 case SMDSEntity_Quad_Triangle:
1360 gtype = tr( "TRIANGLE" ); break;
1361 case SMDSEntity_Quadrangle:
1362 case SMDSEntity_Quad_Quadrangle:
1363 case SMDSEntity_BiQuad_Quadrangle:
1364 gtype = tr( "QUADRANGLE" ); break;
1365 case SMDSEntity_Polygon:
1366 case SMDSEntity_Quad_Polygon:
1367 gtype = tr( "POLYGON" ); break;
1368 case SMDSEntity_Tetra:
1369 case SMDSEntity_Quad_Tetra:
1370 gtype = tr( "TETRAHEDRON" ); break;
1371 case SMDSEntity_Pyramid:
1372 case SMDSEntity_Quad_Pyramid:
1373 gtype = tr( "PYRAMID" ); break;
1374 case SMDSEntity_Hexa:
1375 case SMDSEntity_Quad_Hexa:
1376 case SMDSEntity_TriQuad_Hexa:
1377 gtype = tr( "HEXAHEDRON" ); break;
1378 case SMDSEntity_Penta:
1379 case SMDSEntity_Quad_Penta:
1380 gtype = tr( "PRISM" ); break;
1381 case SMDSEntity_Hexagonal_Prism:
1382 gtype = tr( "HEX_PRISM" ); break;
1383 case SMDSEntity_Polyhedra:
1384 case SMDSEntity_Quad_Polyhedra:
1385 gtype = tr( "POLYHEDRON" ); break;
1389 if ( !gtype.isEmpty() ) {
1390 QTreeWidgetItem* typeItem = createItem( elemItem, Bold );
1391 typeItem->setText( 0, tr( "TYPE" ) );
1392 typeItem->setText( 1, gtype );
1394 // quadratic flag and gravity center (any element except 0D)
1395 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Ball ) {
1397 QTreeWidgetItem* quadItem = createItem( elemItem, Bold );
1398 quadItem->setText( 0, tr( "QUADRATIC" ) );
1399 quadItem->setText( 1, e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) );
1401 XYZ gc = gravityCenter( e );
1402 QTreeWidgetItem* gcItem = createItem( elemItem, Bold );
1403 gcItem->setText( 0, tr( "GRAVITY_CENTER" ) );
1404 QTreeWidgetItem* xItem = createItem( gcItem );
1405 xItem->setText( 0, "X" );
1406 xItem->setText( 1, QString::number( gc.x(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1407 QTreeWidgetItem* yItem = createItem( gcItem );
1408 yItem->setText( 0, "Y" );
1409 yItem->setText( 1, QString::number( gc.y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1410 QTreeWidgetItem* zItem = createItem( gcItem );
1411 zItem->setText( 0, "Z" );
1412 zItem->setText( 1, QString::number( gc.z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1414 if ( const SMDS_BallElement* ball = dynamic_cast<const SMDS_BallElement*>( e )) {
1416 QTreeWidgetItem* diamItem = createItem( elemItem, Bold );
1417 diamItem->setText( 0, tr( "BALL_DIAMETER" ) );
1418 diamItem->setText( 1, QString( "%1" ).arg( ball->GetDiameter() ));
1421 QTreeWidgetItem* conItem = createItem( elemItem, Bold );
1422 conItem->setText( 0, tr( "CONNECTIVITY" ) );
1423 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
1424 for ( int idx = 1; nodeIt->more(); idx++ ) {
1425 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
1426 // node number and ID
1427 QTreeWidgetItem* nodeItem = createItem( conItem, Bold );
1428 nodeItem->setText( 0, QString( "%1 %2 / %3" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ) );
1429 nodeItem->setText( 1, QString( "#%1" ).arg( node->GetID() ) );
1430 nodeItem->setData( 1, TypeRole, ElemConnectivity );
1431 nodeItem->setData( 1, IdRole, node->GetID() );
1432 nodeItem->setExpanded( false );
1434 QTreeWidgetItem* coordItem = createItem( nodeItem );
1435 coordItem->setText( 0, tr( "COORDINATES" ) );
1436 QTreeWidgetItem* xItem = createItem( coordItem );
1437 xItem->setText( 0, "X" );
1438 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1439 QTreeWidgetItem* yItem = createItem( coordItem );
1440 yItem->setText( 0, "Y" );
1441 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1442 QTreeWidgetItem* zItem = createItem( coordItem );
1443 zItem->setText( 0, "Z" );
1444 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1445 // node connectivity
1446 QTreeWidgetItem* nconItem = createItem( nodeItem );
1447 nconItem->setText( 0, tr( "CONNECTIVITY" ) );
1448 Connectivity connectivity = nodeConnectivity( node );
1449 if ( !connectivity.isEmpty() ) {
1450 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1451 if ( !con.isEmpty() ) {
1452 QTreeWidgetItem* i = createItem( nconItem );
1453 i->setText( 0, tr( "0D_ELEMENTS" ) );
1454 i->setText( 1, con );
1456 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1457 if ( !con.isEmpty() ) {
1458 QTreeWidgetItem* i = createItem( nconItem );
1459 i->setText( 0, tr( "EDGES" ) );
1460 i->setText( 1, con );
1461 i->setData( 1, TypeRole, NodeConnectivity );
1463 con = formatConnectivity( connectivity, SMDSAbs_Ball );
1464 if ( !con.isEmpty() ) {
1465 QTreeWidgetItem* i = createItem( nconItem );
1466 i->setText( 0, tr( "BALL_ELEMENTS" ) );
1467 i->setText( 1, con );
1468 i->setData( 1, TypeRole, NodeConnectivity );
1470 con = formatConnectivity( connectivity, SMDSAbs_Face );
1471 if ( !con.isEmpty() ) {
1472 QTreeWidgetItem* i = createItem( nconItem );
1473 i->setText( 0, tr( "FACES" ) );
1474 i->setText( 1, con );
1475 i->setData( 1, TypeRole, NodeConnectivity );
1477 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1478 if ( !con.isEmpty() ) {
1479 QTreeWidgetItem* i = createItem( nconItem );
1480 i->setText( 0, tr( "VOLUMES" ) );
1481 i->setText( 1, con );
1482 i->setData( 1, TypeRole, NodeConnectivity );
1487 QTreeWidgetItem* cntrItem = createItem( elemItem, Bold );
1488 cntrItem->setText( 0, tr( "MEN_CTRL" ) );
1490 if( e->GetType()==SMDSAbs_Edge){
1491 afunctor.reset( new SMESH::Controls::Length() );
1492 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1493 afunctor->SetPrecision( cprecision );
1494 QTreeWidgetItem* lenItem = createItem( cntrItem, Bold );
1495 lenItem->setText( 0, tr( "LENGTH_EDGES" ) );
1496 lenItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1498 if( e->GetType() == SMDSAbs_Face ) {
1500 afunctor.reset( new SMESH::Controls::Area() );
1501 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1502 afunctor->SetPrecision( cprecision );
1503 QTreeWidgetItem* areaItem = createItem( cntrItem, Bold );
1504 areaItem->setText( 0, tr( "AREA_ELEMENTS" ) );
1505 areaItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue(id) ) );
1507 afunctor.reset( new SMESH::Controls::Taper() );
1508 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1509 afunctor->SetPrecision( cprecision );
1510 QTreeWidgetItem* taperlItem = createItem( cntrItem, Bold );
1511 taperlItem->setText( 0, tr( "MEN_TAPER" ) );
1512 taperlItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1514 afunctor.reset( new SMESH::Controls::AspectRatio() );
1515 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1516 QTreeWidgetItem* ratlItem = createItem( cntrItem, Bold );
1517 ratlItem->setText( 0, tr( "ASPECTRATIO_ELEMENTS" ));
1518 ratlItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1520 afunctor.reset( new SMESH::Controls::MinimumAngle() );
1521 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1522 afunctor->SetPrecision( cprecision );
1523 QTreeWidgetItem* minanglItem = createItem( cntrItem, Bold );
1524 minanglItem->setText( 0, tr( "MINIMUMANGLE_ELEMENTS" ) );
1525 minanglItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1527 afunctor.reset( new SMESH::Controls::Warping() );
1528 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1529 afunctor->SetPrecision( cprecision );
1530 QTreeWidgetItem* warpItem = createItem( cntrItem, Bold );
1531 warpItem->setText( 0, tr( "STB_WARP" ));
1532 warpItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1534 afunctor.reset( new SMESH::Controls::Skew() );
1535 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1536 afunctor->SetPrecision( cprecision );
1537 QTreeWidgetItem* skewItem = createItem( cntrItem, Bold );
1538 skewItem->setText( 0, tr( "TOP_SKEW" ) );
1539 skewItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1541 afunctor.reset( new SMESH::Controls::MaxElementLength2D() );
1542 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1543 QTreeWidgetItem* diamItem = createItem( cntrItem, Bold );
1544 diamItem->setText( 0, tr( "MAX_ELEMENT_LENGTH_2D" ));
1545 diamItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1547 if( e->GetType() == SMDSAbs_Volume ) {
1549 afunctor.reset( new SMESH::Controls::AspectRatio3D() );
1550 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1551 QTreeWidgetItem* ratlItem3 = createItem( cntrItem, Bold );
1552 ratlItem3->setText( 0, tr( "ASPECTRATIO_3D_ELEMENTS" ) );
1553 ratlItem3->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1555 afunctor.reset( new SMESH::Controls::Volume() );
1556 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1557 QTreeWidgetItem* volItem = createItem( cntrItem, Bold );
1558 volItem->setText( 0, tr( "MEN_VOLUME_3D" ) );
1559 volItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1561 afunctor.reset( new SMESH::Controls::MaxElementLength3D() );
1562 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1563 QTreeWidgetItem* diam3Item = createItem( cntrItem, Bold );
1564 diam3Item->setText( 0, tr( "MAX_ELEMENT_LENGTH_3D" ) );
1565 diam3Item->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1568 if( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
1570 int shapeID = e->getshapeId();
1571 if ( shapeID > 0 ) {
1572 QTreeWidgetItem* shItem = createItem( elemItem, Bold );
1574 switch ( actor()->GetObject()->GetMesh()->FindElement( shapeID )->GetType() ) {
1575 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" ); break;
1576 case SMDS_TOP_FACE: shapeType = tr( "FACE" ); break;
1577 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1578 default: shapeType = tr( "SOLID" );
1580 shItem->setText( 0, tr( "Position" ) );
1581 shItem->setText( 1, QString( "%1 #%2" ).arg(shapeType).arg( shapeID ) );
1591 \brief Internal clean-up (reset widget)
1593 void SMESHGUI_TreeElemInfo::clearInternal()
1600 \brief Create new tree item.
1601 \param parent parent tree widget item
1602 \param flags item flag
1603 \return new tree widget item
1605 QTreeWidgetItem* SMESHGUI_TreeElemInfo::createItem( QTreeWidgetItem* parent, int flags )
1607 QTreeWidgetItem* item;
1609 item = new QTreeWidgetItem( parent );
1611 item = new QTreeWidgetItem( myInfo );
1613 item->setFlags( item->flags() | Qt::ItemIsEditable );
1615 QFont f = item->font( 0 );
1617 for ( int i = 0; i < myInfo->columnCount(); i++ ) {
1618 if ( ( flags & Bold ) && ( i == 0 || flags & All ) )
1619 item->setFont( i, f );
1622 item->setExpanded( true );
1626 void SMESHGUI_TreeElemInfo::contextMenuEvent( QContextMenuEvent* e )
1628 QList< QTreeWidgetItem* > widgets = myInfo->selectedItems();
1629 if ( widgets.isEmpty() ) return;
1630 QTreeWidgetItem* aTreeItem = widgets.first();
1631 int type = aTreeItem->data( 1, TypeRole ).toInt();
1632 int id = aTreeItem->data( 1, IdRole ).toInt();
1634 QAction* a = menu.addAction( tr( "SHOW_ITEM_INFO" ) );
1635 if ( type == ElemConnectivity && id > 0 && menu.exec( e->globalPos() ) == a )
1636 emit( itemInfo( id ) );
1637 else if ( type == NodeConnectivity && menu.exec( e->globalPos() ) == a )
1638 emit( itemInfo( aTreeItem->text( 1 ) ) );
1641 void SMESHGUI_TreeElemInfo::itemDoubleClicked( QTreeWidgetItem* theItem, int theColumn )
1644 int type = theItem->data( 1, TypeRole ).toInt();
1645 int id = theItem->data( 1, IdRole ).toInt();
1646 if ( type == ElemConnectivity && id > 0 )
1647 emit( itemInfo( id ) );
1648 else if ( type == NodeConnectivity )
1649 emit( itemInfo( theItem->text( 1 ) ) );
1655 \brief Mesh information computer
1658 The class is created for different computation operation. Currently it is used
1659 to compute number of underlying nodes for the groups.
1665 GrpComputor::GrpComputor( SMESH::SMESH_GroupBase_ptr grp, QTreeWidgetItem* item, QObject* parent )
1666 : QObject( parent ), myItem( item )
1668 myGroup = SMESH::SMESH_GroupBase::_narrow( grp );
1672 \brief Compute function
1674 void GrpComputor::compute()
1676 if ( !CORBA::is_nil( myGroup ) && myItem ) {
1677 QTreeWidgetItem* item = myItem;
1679 int nbNodes = myGroup->GetNumberOfNodes();
1680 item->treeWidget()->removeItemWidget( item, 1 );
1681 item->setText( 1, QString::number( nbNodes ));
1686 \class SMESHGUI_AddInfo
1687 \brief The wigdet shows additional information on the mesh object.
1692 \param parent parent widget
1694 SMESHGUI_AddInfo::SMESHGUI_AddInfo( QWidget* parent )
1695 : QTreeWidget( parent )
1697 setColumnCount( 2 );
1698 header()->setStretchLastSection( true );
1699 header()->setResizeMode( 0, QHeaderView::ResizeToContents );
1706 SMESHGUI_AddInfo::~SMESHGUI_AddInfo()
1711 \brief Show additional information on the selected object
1712 \param obj object being processed (mesh, sub-mesh, group, ID source)
1714 void SMESHGUI_AddInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
1716 setProperty( "group_index", 0 );
1717 setProperty( "submesh_index", 0 );
1718 myComputors.clear();
1721 if ( CORBA::is_nil( obj ) ) return;
1723 _PTR(SObject) sobj = SMESH::ObjectToSObject( obj );
1724 if ( !sobj ) return;
1727 QTreeWidgetItem* nameItem = createItem( 0, Bold | All );
1728 nameItem->setText( 0, tr( "NAME" ) );
1729 nameItem->setText( 1, sobj->GetName().c_str() );
1731 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( obj );
1732 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
1733 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( obj );
1735 if ( !aMesh->_is_nil() )
1736 meshInfo( aMesh, nameItem );
1737 else if ( !aSubMesh->_is_nil() )
1738 subMeshInfo( aSubMesh, nameItem );
1739 else if ( !aGroup->_is_nil() )
1740 groupInfo( aGroup.in(), nameItem );
1744 \brief Create new tree item.
1745 \param parent parent tree widget item
1746 \param flags item flag
1747 \return new tree widget item
1749 QTreeWidgetItem* SMESHGUI_AddInfo::createItem( QTreeWidgetItem* parent, int flags )
1751 QTreeWidgetItem* item;
1754 item = new QTreeWidgetItem( parent );
1756 item = new QTreeWidgetItem( this );
1758 //item->setFlags( item->flags() | Qt::ItemIsEditable );
1760 QFont f = item->font( 0 );
1762 for ( int i = 0; i < columnCount(); i++ ) {
1763 if ( ( flags & Bold ) && ( i == 0 || flags & All ) )
1764 item->setFont( i, f );
1767 item->setExpanded( true );
1772 \brief Show mesh info
1773 \param mesh mesh object
1774 \param parent parent tree item
1776 void SMESHGUI_AddInfo::meshInfo( SMESH::SMESH_Mesh_ptr mesh, QTreeWidgetItem* parent )
1779 GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh();
1780 SALOME_MED::MedFileInfo* inf = mesh->GetMEDFileInfo();
1781 QTreeWidgetItem* typeItem = createItem( parent, Bold );
1782 typeItem->setText( 0, tr( "TYPE" ) );
1783 if ( !CORBA::is_nil( shape ) ) {
1784 typeItem->setText( 1, tr( "MESH_ON_GEOMETRY" ) );
1785 _PTR(SObject) sobj = SMESH::ObjectToSObject( shape );
1787 QTreeWidgetItem* gobjItem = createItem( typeItem );
1788 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1789 gobjItem->setText( 1, sobj->GetName().c_str() );
1792 else if ( strlen( (char*)inf->fileName ) > 0 ) {
1793 typeItem->setText( 1, tr( "MESH_FROM_FILE" ) );
1794 QTreeWidgetItem* fileItem = createItem( typeItem );
1795 fileItem->setText( 0, tr( "FILE_NAME" ) );
1796 fileItem->setText( 1, (char*)inf->fileName );
1799 typeItem->setText( 1, tr( "STANDALONE_MESH" ) );
1803 myGroups = mesh->GetGroups();
1807 mySubMeshes = mesh->GetSubMeshes();
1812 \brief Show sub-mesh info
1813 \param subMesh sub-mesh object
1814 \param parent parent tree item
1816 void SMESHGUI_AddInfo::subMeshInfo( SMESH::SMESH_subMesh_ptr subMesh, QTreeWidgetItem* parent )
1818 bool isShort = parent->parent() != 0;
1822 _PTR(SObject) sobj = SMESH::ObjectToSObject( subMesh->GetFather() );
1824 QTreeWidgetItem* nameItem = createItem( parent, Bold );
1825 nameItem->setText( 0, tr( "PARENT_MESH" ) );
1826 nameItem->setText( 1, sobj->GetName().c_str() );
1831 GEOM::GEOM_Object_var gobj = subMesh->GetSubShape();
1832 _PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
1834 QTreeWidgetItem* gobjItem = createItem( parent, Bold );
1835 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1836 gobjItem->setText( 1, sobj->GetName().c_str() );
1841 \brief Show group info
1842 \param grp mesh group object
1843 \param parent parent tree item
1845 void SMESHGUI_AddInfo::groupInfo( SMESH::SMESH_GroupBase_ptr grp, QTreeWidgetItem* parent )
1847 bool isShort = parent->parent() != 0;
1849 SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( grp );
1850 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( grp );
1851 SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( grp );
1855 _PTR(SObject) sobj = SMESH::ObjectToSObject( grp->GetMesh() );
1857 QTreeWidgetItem* nameItem = createItem( parent, Bold );
1858 nameItem->setText( 0, tr( "PARENT_MESH" ) );
1859 nameItem->setText( 1, sobj->GetName().c_str() );
1863 // type : group on geometry, standalone group, group on filter
1864 QTreeWidgetItem* typeItem = createItem( parent, Bold );
1865 typeItem->setText( 0, tr( "TYPE" ) );
1866 if ( !CORBA::is_nil( aStdGroup ) ) {
1867 typeItem->setText( 1, tr( "STANDALONE_GROUP" ) );
1869 else if ( !CORBA::is_nil( aGeomGroup ) ) {
1870 typeItem->setText( 1, tr( "GROUP_ON_GEOMETRY" ) );
1871 GEOM::GEOM_Object_var gobj = aGeomGroup->GetShape();
1872 _PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
1874 QTreeWidgetItem* gobjItem = createItem( typeItem );
1875 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1876 gobjItem->setText( 1, sobj->GetName().c_str() );
1879 else if ( !CORBA::is_nil( aFltGroup ) ) {
1880 typeItem->setText( 1, tr( "GROUP_ON_FILTER" ) );
1885 QString etype = tr( "UNKNOWN" );
1886 switch( grp->GetType() ) {
1888 etype = tr( "NODE" );
1891 etype = tr( "EDGE" );
1894 etype = tr( "FACE" );
1897 etype = tr( "VOLUME" );
1900 etype = tr( "0DELEM" );
1903 etype = tr( "BALL" );
1908 QTreeWidgetItem* etypeItem = createItem( parent, Bold );
1909 etypeItem->setText( 0, tr( "ENTITY_TYPE" ) );
1910 etypeItem->setText( 1, etype );
1914 QTreeWidgetItem* sizeItem = createItem( parent, Bold );
1915 sizeItem->setText( 0, tr( "SIZE" ) );
1916 sizeItem->setText( 1, QString::number( grp->Size() ) );
1919 SALOMEDS::Color color = grp->GetColor();
1920 QTreeWidgetItem* colorItem = createItem( parent, Bold );
1921 colorItem->setText( 0, tr( "COLOR" ) );
1922 colorItem->setBackground( 1, QBrush( QColor( color.R*255., color.G*255., color.B*255.) ) );
1924 // nb of underlying nodes
1925 if ( grp->GetType() != SMESH::NODE) {
1926 QTreeWidgetItem* nodesItem = createItem( parent, Bold );
1927 nodesItem->setText( 0, tr( "NB_NODES" ) );
1928 int nbNodesLimit = SMESHGUI::resourceMgr()->integerValue( "SMESH", "info_groups_nodes_limit", 100000 );
1929 SMESH::SMESH_Mesh_var mesh = grp->GetMesh();
1930 bool meshLoaded = mesh->IsLoaded();
1931 bool toShowNodes = ( grp->IsNodeInfoAvailable() || nbNodesLimit <= 0 || grp->Size() <= nbNodesLimit );
1932 if ( toShowNodes && meshLoaded ) {
1933 // already calculated and up-to-date
1934 nodesItem->setText( 1, QString::number( grp->GetNumberOfNodes() ) );
1937 QPushButton* btn = new QPushButton( tr( meshLoaded ? "COMPUTE" : "LOAD"), this );
1938 setItemWidget( nodesItem, 1, btn );
1939 GrpComputor* comp = new GrpComputor( grp, nodesItem, this );
1940 connect( btn, SIGNAL( clicked() ), comp, SLOT( compute() ) );
1941 myComputors.append( comp );
1943 connect( btn, SIGNAL( clicked() ), this, SLOT( changeLoadToCompute() ) );
1948 void SMESHGUI_AddInfo::showGroups()
1950 myComputors.clear();
1952 QTreeWidgetItem* parent = topLevelItemCount() > 0 ? topLevelItem( 0 ) : 0; // parent should be first top level item
1953 if ( !parent ) return;
1955 int idx = property( "group_index" ).toInt();
1957 QTreeWidgetItem* itemGroups = 0;
1958 for ( int i = 0; i < parent->childCount() && !itemGroups; i++ ) {
1959 if ( parent->child( i )->data( 0, Qt::UserRole ).toInt() == GROUPS_ID ) {
1960 itemGroups = parent->child( i );
1961 ExtraWidget* extra = dynamic_cast<ExtraWidget*>( itemWidget( itemGroups, 1 ) );
1963 extra->updateControls( myGroups->length(), idx );
1964 while ( itemGroups->childCount() ) delete itemGroups->child( 0 ); // clear child items
1968 QMap<int, QTreeWidgetItem*> grpItems;
1969 for ( int i = idx*MAXITEMS ; i < qMin( (idx+1)*MAXITEMS, (int)myGroups->length() ); i++ ) {
1970 SMESH::SMESH_GroupBase_var grp = myGroups[i];
1971 if ( CORBA::is_nil( grp ) ) continue;
1972 _PTR(SObject) grpSObj = SMESH::ObjectToSObject( grp );
1973 if ( !grpSObj ) continue;
1975 int grpType = grp->GetType();
1977 if ( !itemGroups ) {
1978 // create top-level groups container item
1979 itemGroups = createItem( parent, Bold | All );
1980 itemGroups->setText( 0, tr( "GROUPS" ) );
1981 itemGroups->setData( 0, Qt::UserRole, GROUPS_ID );
1983 // total number of groups > 10, show extra widgets for info browsing
1984 if ( myGroups->length() > MAXITEMS ) {
1985 ExtraWidget* extra = new ExtraWidget( this, true );
1986 connect( extra->prev, SIGNAL( clicked() ), this, SLOT( showPreviousGroups() ) );
1987 connect( extra->next, SIGNAL( clicked() ), this, SLOT( showNextGroups() ) );
1988 setItemWidget( itemGroups, 1, extra );
1989 extra->updateControls( myGroups->length(), idx );
1993 if ( grpItems.find( grpType ) == grpItems.end() ) {
1994 grpItems[ grpType ] = createItem( itemGroups, Bold | All );
1995 grpItems[ grpType ]->setText( 0, tr( QString( "GROUPS_%1" ).arg( grpType ).toLatin1().constData() ) );
1996 itemGroups->insertChild( grpType-1, grpItems[ grpType ] );
2000 QTreeWidgetItem* grpNameItem = createItem( grpItems[ grpType ] );
2001 grpNameItem->setText( 0, QString( grpSObj->GetName().c_str() ).trimmed() ); // name is trimmed
2004 groupInfo( grp.in(), grpNameItem );
2008 void SMESHGUI_AddInfo::showSubMeshes()
2010 QTreeWidgetItem* parent = topLevelItemCount() > 0 ? topLevelItem( 0 ) : 0; // parent should be first top level item
2011 if ( !parent ) return;
2013 int idx = property( "submesh_index" ).toInt();
2015 QTreeWidgetItem* itemSubMeshes = 0;
2016 for ( int i = 0; i < parent->childCount() && !itemSubMeshes; i++ ) {
2017 if ( parent->child( i )->data( 0, Qt::UserRole ).toInt() == SUBMESHES_ID ) {
2018 itemSubMeshes = parent->child( i );
2019 ExtraWidget* extra = dynamic_cast<ExtraWidget*>( itemWidget( itemSubMeshes, 1 ) );
2021 extra->updateControls( mySubMeshes->length(), idx );
2022 while ( itemSubMeshes->childCount() ) delete itemSubMeshes->child( 0 ); // clear child items
2026 QMap<int, QTreeWidgetItem*> smItems;
2027 for ( int i = idx*MAXITEMS ; i < qMin( (idx+1)*MAXITEMS, (int)mySubMeshes->length() ); i++ ) {
2028 SMESH::SMESH_subMesh_var sm = mySubMeshes[i];
2029 if ( CORBA::is_nil( sm ) ) continue;
2030 _PTR(SObject) smSObj = SMESH::ObjectToSObject( sm );
2031 if ( !smSObj ) continue;
2033 GEOM::GEOM_Object_var gobj = sm->GetSubShape();
2034 if ( CORBA::is_nil(gobj ) ) continue;
2036 int smType = gobj->GetShapeType();
2037 if ( smType == GEOM::COMPSOLID ) smType = GEOM::COMPOUND;
2039 if ( !itemSubMeshes ) {
2040 itemSubMeshes = createItem( parent, Bold | All );
2041 itemSubMeshes->setText( 0, tr( "SUBMESHES" ) );
2042 itemSubMeshes->setData( 0, Qt::UserRole, SUBMESHES_ID );
2044 // total number of sub-meshes > 10, show extra widgets for info browsing
2045 if ( mySubMeshes->length() > MAXITEMS ) {
2046 ExtraWidget* extra = new ExtraWidget( this, true );
2047 connect( extra->prev, SIGNAL( clicked() ), this, SLOT( showPreviousSubMeshes() ) );
2048 connect( extra->next, SIGNAL( clicked() ), this, SLOT( showNextSubMeshes() ) );
2049 setItemWidget( itemSubMeshes, 1, extra );
2050 extra->updateControls( mySubMeshes->length(), idx );
2054 if ( smItems.find( smType ) == smItems.end() ) {
2055 smItems[ smType ] = createItem( itemSubMeshes, Bold | All );
2056 smItems[ smType ]->setText( 0, tr( QString( "SUBMESHES_%1" ).arg( smType ).toLatin1().constData() ) );
2057 itemSubMeshes->insertChild( smType, smItems[ smType ] );
2061 QTreeWidgetItem* smNameItem = createItem( smItems[ smType ] );
2062 smNameItem->setText( 0, QString( smSObj->GetName().c_str() ).trimmed() ); // name is trimmed
2065 subMeshInfo( sm.in(), smNameItem );
2070 * \brief Change button label of "nb underlying node" group from "Load" to "Compute"
2072 void SMESHGUI_AddInfo::changeLoadToCompute()
2074 for ( int i = 0; i < myComputors.count(); ++i )
2076 if ( QTreeWidgetItem* item = myComputors[i]->getItem() )
2078 if ( QPushButton* btn = qobject_cast<QPushButton*>( itemWidget ( item, 1 ) ) )
2079 btn->setText( tr("COMPUTE") );
2084 void SMESHGUI_AddInfo::showPreviousGroups()
2086 int idx = property( "group_index" ).toInt();
2087 setProperty( "group_index", idx-1 );
2091 void SMESHGUI_AddInfo::showNextGroups()
2093 int idx = property( "group_index" ).toInt();
2094 setProperty( "group_index", idx+1 );
2098 void SMESHGUI_AddInfo::showPreviousSubMeshes()
2100 int idx = property( "submesh_index" ).toInt();
2101 setProperty( "submesh_index", idx-1 );
2105 void SMESHGUI_AddInfo::showNextSubMeshes()
2107 int idx = property( "submesh_index" ).toInt();
2108 setProperty( "submesh_index", idx+1 );
2113 \class SMESHGUI_MeshInfoDlg
2114 \brief Mesh information dialog box
2119 \param parent parent widget
2120 \param page specifies the dialog page to be shown at the start-up
2122 SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page )
2123 : QDialog( parent ), myActor( 0 )
2126 setAttribute( Qt::WA_DeleteOnClose, true );
2127 setWindowTitle( tr( "MESH_INFO" ) );
2128 setSizeGripEnabled( true );
2130 myTabWidget = new QTabWidget( this );
2134 myBaseInfo = new SMESHGUI_MeshInfo( myTabWidget );
2135 myTabWidget->addTab( myBaseInfo, tr( "BASE_INFO" ) );
2139 QWidget* w = new QWidget( myTabWidget );
2141 myMode = new QButtonGroup( this );
2142 myMode->addButton( new QRadioButton( tr( "NODE_MODE" ), w ), NodeMode );
2143 myMode->addButton( new QRadioButton( tr( "ELEM_MODE" ), w ), ElemMode );
2144 myMode->button( NodeMode )->setChecked( true );
2145 myID = new QLineEdit( w );
2146 myID->setValidator( new SMESHGUI_IdValidator( this ) );
2148 int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 );
2149 mode = qMin( 1, qMax( 0, mode ) );
2152 myElemInfo = new SMESHGUI_SimpleElemInfo( w );
2154 myElemInfo = new SMESHGUI_TreeElemInfo( w );
2156 QGridLayout* elemLayout = new QGridLayout( w );
2157 elemLayout->setMargin( MARGIN );
2158 elemLayout->setSpacing( SPACING );
2159 elemLayout->addWidget( myMode->button( NodeMode ), 0, 0 );
2160 elemLayout->addWidget( myMode->button( ElemMode ), 0, 1 );
2161 elemLayout->addWidget( myID, 0, 2 );
2162 elemLayout->addWidget( myElemInfo, 1, 0, 1, 3 );
2164 myTabWidget->addTab( w, tr( "ELEM_INFO" ) );
2168 myAddInfo = new SMESHGUI_AddInfo( myTabWidget );
2169 myTabWidget->addTab( myAddInfo, tr( "ADDITIONAL_INFO" ) );
2173 QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this );
2174 okBtn->setAutoDefault( true );
2175 okBtn->setDefault( true );
2177 QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
2178 helpBtn->setAutoDefault( true );
2180 QHBoxLayout* btnLayout = new QHBoxLayout;
2181 btnLayout->setSpacing( SPACING );
2182 btnLayout->setMargin( 0 );
2184 btnLayout->addWidget( okBtn );
2185 btnLayout->addStretch( 10 );
2186 btnLayout->addWidget( helpBtn );
2188 QVBoxLayout* l = new QVBoxLayout ( this );
2189 l->setMargin( MARGIN );
2190 l->setSpacing( SPACING );
2191 l->addWidget( myTabWidget );
2192 l->addLayout( btnLayout );
2194 myTabWidget->setCurrentIndex( qMax( (int)BaseInfo, qMin( (int)ElemInfo, page ) ) );
2196 connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
2197 connect( helpBtn, SIGNAL( clicked() ), this, SLOT( help() ) );
2198 connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( updateSelection() ) );
2199 connect( myMode, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged() ) );
2200 connect( myID, SIGNAL( textChanged( QString ) ), this, SLOT( idChanged() ) );
2201 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() ) );
2202 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) );
2203 connect( myElemInfo, SIGNAL( itemInfo( int ) ), this, SLOT( showItemInfo( int ) ) );
2204 connect( myElemInfo, SIGNAL( itemInfo( QString ) ), this, SLOT( showItemInfo( QString ) ) );
2212 SMESHGUI_MeshInfoDlg::~SMESHGUI_MeshInfoDlg()
2217 \brief Show mesh information
2218 \param IO interactive object
2220 void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO )
2222 SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
2223 if ( !CORBA::is_nil( obj ) ) {
2224 myBaseInfo->showInfo( obj );
2225 myAddInfo->showInfo( obj );
2227 myActor = SMESH::FindActorByEntry( IO->getEntry() );
2228 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
2231 if ( myActor && selector ) {
2232 nb = myMode->checkedId() == NodeMode ?
2233 SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
2234 SMESH::GetNameOfSelectedNodes( selector, IO, ID );
2236 myElemInfo->setSource( myActor ) ;
2238 myID->setText( ID.trimmed() );
2240 QStringList idTxt = ID.split( " ", QString::SkipEmptyParts );
2241 foreach ( ID, idTxt )
2242 ids << ID.trimmed().toLong();
2243 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
2247 myElemInfo->clear();
2253 \brief Perform clean-up actions on the dialog box closing.
2255 void SMESHGUI_MeshInfoDlg::reject()
2257 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
2258 selMgr->clearFilters();
2259 SMESH::SetPointRepresentation( false );
2260 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2261 aViewWindow->SetSelectionMode( ActorSelection );
2266 \brief Process keyboard event
2267 \param e key press event
2269 void SMESHGUI_MeshInfoDlg::keyPressEvent( QKeyEvent* e )
2271 QDialog::keyPressEvent( e );
2272 if ( !e->isAccepted() && e->key() == Qt::Key_F1 ) {
2279 \brief Reactivate dialog box, when mouse pointer goes into it.
2281 void SMESHGUI_MeshInfoDlg::enterEvent( QEvent* )
2287 \brief Setup selection mode depending on the current dialog box state.
2289 void SMESHGUI_MeshInfoDlg::updateSelection()
2291 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
2293 disconnect( selMgr, 0, this, 0 );
2294 selMgr->clearFilters();
2296 if ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) {
2297 SMESH::SetPointRepresentation( false );
2298 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2299 aViewWindow->SetSelectionMode( ActorSelection );
2302 if ( myMode->checkedId() == NodeMode ) {
2303 SMESH::SetPointRepresentation( true );
2304 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2305 aViewWindow->SetSelectionMode( NodeSelection );
2308 SMESH::SetPointRepresentation( false );
2309 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2310 aViewWindow->SetSelectionMode( CellSelection );
2314 QString oldID = myID->text().trimmed();
2315 SMESH_Actor* oldActor = myActor;
2318 connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
2321 if ( oldActor == myActor && myActor && !oldID.isEmpty() ) {
2322 myID->setText( oldID );
2328 \brief Show help page
2330 void SMESHGUI_MeshInfoDlg::help()
2332 SMESH::ShowHelpFile( ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) ?
2333 "mesh_infos_page.html#advanced_mesh_infos_anchor" :
2334 "mesh_infos_page.html#mesh_element_info_anchor" );
2338 \brief Show mesh information
2340 void SMESHGUI_MeshInfoDlg::updateInfo()
2342 SUIT_OverrideCursor wc;
2344 SALOME_ListIO selected;
2345 SMESHGUI::selectionMgr()->selectedObjects( selected );
2347 if ( selected.Extent() == 1 ) {
2348 Handle(SALOME_InteractiveObject) IO = selected.First();
2352 // myBaseInfo->clear();
2353 // myElemInfo->clear();
2354 // myAddInfo->clear();
2359 \brief Activate dialog box
2361 void SMESHGUI_MeshInfoDlg::activate()
2363 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
2364 SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this );
2365 myTabWidget->setEnabled( true );
2370 \brief Deactivate dialog box
2372 void SMESHGUI_MeshInfoDlg::deactivate()
2374 myTabWidget->setEnabled( false );
2375 disconnect( SMESHGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
2379 \brief Called when users switches between node / element modes.
2381 void SMESHGUI_MeshInfoDlg::modeChanged()
2388 \brief Caled when users prints mesh element ID in the corresponding field.
2390 void SMESHGUI_MeshInfoDlg::idChanged()
2392 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
2393 if ( myActor && selector ) {
2394 Handle(SALOME_InteractiveObject) IO = myActor->getIO();
2395 TColStd_MapOfInteger ID;
2397 QStringList idTxt = myID->text().split( " ", QString::SkipEmptyParts );
2398 foreach ( QString tid, idTxt ) {
2399 long id = tid.trimmed().toLong();
2400 const SMDS_MeshElement* e = myMode->checkedId() == ElemMode ?
2401 myActor->GetObject()->GetMesh()->FindElement( id ) :
2402 myActor->GetObject()->GetMesh()->FindNode( id );
2408 selector->AddOrRemoveIndex( IO, ID, false );
2409 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() ) {
2410 aViewWindow->highlight( IO, true, true );
2411 aViewWindow->Repaint();
2413 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
2417 void SMESHGUI_MeshInfoDlg::showItemInfo( int id )
2419 if ( id > 0 && myActor->GetObject()->GetMesh()->FindNode( id ) ) {
2420 myMode->button( NodeMode )->click();
2421 myID->setText( QString::number( id ) );
2425 void SMESHGUI_MeshInfoDlg::showItemInfo( const QString& theStr )
2427 if ( !theStr.isEmpty() ) {
2428 myMode->button( ElemMode )->click();
2429 myID->setText( theStr );