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 <QGridLayout>
49 #include <QHBoxLayout>
50 #include <QHeaderView>
51 #include <QItemDelegate>
55 #include <QPushButton>
56 #include <QRadioButton>
58 #include <QTextBrowser>
59 #include <QVBoxLayout>
61 #include "utilities.h"
63 #include <SALOMEconfig.h>
64 #include CORBA_SERVER_HEADER(GEOM_Gen)
66 const int SPACING = 6;
68 const int MAXITEMS = 10;
69 const int GROUPS_ID = 100;
70 const int SUBMESHES_ID = 200;
77 class ExtraWidget : public QWidget
80 ExtraWidget( QWidget*, bool = false );
83 void updateControls( int, int, int = MAXITEMS );
92 ExtraWidget::ExtraWidget( QWidget* parent, bool b ) : QWidget( parent ), brief( b )
94 current = new QLabel( this );
95 current->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
96 prev = new QPushButton( tr( "<<" ), this );
97 next = new QPushButton( tr( ">>" ), this );
98 QHBoxLayout* hbl = new QHBoxLayout( this );
99 hbl->setContentsMargins( 0, SPACING, 0, 0 );
100 hbl->setSpacing( SPACING );
102 hbl->addWidget( current );
103 hbl->addWidget( prev );
104 hbl->addWidget( next );
107 ExtraWidget::~ExtraWidget()
111 void ExtraWidget::updateControls( int total, int index, int blockSize )
113 setVisible( total > blockSize );
114 QString format = brief ? QString( "%1-%2 / %3" ) : SMESHGUI_MeshInfoDlg::tr( "X_FROM_Y_ITEMS_SHOWN" );
115 current->setText( format.arg( index*blockSize+1 ).arg( qMin( index*blockSize+blockSize, total ) ).arg( total ) );
116 prev->setEnabled( index > 0 );
117 next->setEnabled( (index+1)*blockSize < total );
121 \class SMESHGUI_MeshInfo
122 \brief Base mesh information widget
124 Displays the base information about mesh object: mesh, sub-mesh, group or arbitrary ID source.
129 \param parent parent widget
131 SMESHGUI_MeshInfo::SMESHGUI_MeshInfo( QWidget* parent )
132 : QFrame( parent ), myWidgets( iElementsEnd )
134 setFrameStyle( StyledPanel | Sunken );
136 QGridLayout* l = new QGridLayout( this );
137 l->setMargin( MARGIN );
138 l->setSpacing( SPACING );
143 QLabel* aNameLab = new QLabel( tr( "NAME_LAB" ), this );
144 QLabel* aName = createField();
145 aName->setMinimumWidth( 150 );
146 QLabel* aObjLab = new QLabel( tr( "OBJECT_LAB" ), this );
147 QLabel* aObj = createField();
148 aObj->setMinimumWidth( 150 );
149 myWidgets[ index++ ] << aNameLab << aName;
150 myWidgets[ index++ ] << aObjLab << aObj;
153 QWidget* aNodesLine = createLine();
154 QLabel* aNodesLab = new QLabel( tr( "NODES_LAB" ), this );
155 QLabel* aNodes = createField();
156 myWidgets[ index++ ] << aNodesLine;
157 myWidgets[ index++ ] << aNodesLab << aNodes;
160 QWidget* aElemLine = createLine();
161 QLabel* aElemLab = new QLabel( tr( "ELEMENTS_LAB" ), this );
162 QLabel* aElemTotal = new QLabel( tr( "TOTAL_LAB" ), this );
163 QLabel* aElemLin = new QLabel( tr( "LINEAR_LAB" ), this );
164 QLabel* aElemQuad = new QLabel( tr( "QUADRATIC_LAB" ), this );
165 myWidgets[ index++ ] << aElemLine;
166 myWidgets[ index++ ] << aElemLab << aElemTotal << aElemLin << aElemQuad;
169 QWidget* a0DLine = createLine();
170 QLabel* a0DLab = new QLabel( tr( "0D_LAB" ), this );
171 QLabel* a0DTotal = createField();
172 myWidgets[ index++ ] << a0DLine;
173 myWidgets[ index++ ] << a0DLab << a0DTotal;
176 QWidget* aBallLine = createLine();
177 QLabel* aBallLab = new QLabel( tr( "BALL_LAB" ), this );
178 QLabel* aBallTotal = createField();
179 myWidgets[ index++ ] << aBallLine;
180 myWidgets[ index++ ] << aBallLab << aBallTotal;
183 QWidget* a1DLine = createLine();
184 QLabel* a1DLab = new QLabel( tr( "1D_LAB" ), this );
185 QLabel* a1DTotal = createField();
186 QLabel* a1DLin = createField();
187 QLabel* a1DQuad = createField();
188 myWidgets[ index++ ] << a1DLine;
189 myWidgets[ index++ ] << a1DLab << a1DTotal << a1DLin << a1DQuad;
192 QWidget* a2DLine = createLine();
193 QLabel* a2DLab = new QLabel( tr( "2D_LAB" ), this );
194 QLabel* a2DTotal = createField();
195 QLabel* a2DLin = createField();
196 QLabel* a2DQuad = createField();
197 QLabel* a2DTriLab = new QLabel( tr( "TRIANGLES_LAB" ), this );
198 QLabel* a2DTriTotal = createField();
199 QLabel* a2DTriLin = createField();
200 QLabel* a2DTriQuad = createField();
201 QLabel* a2DQuaLab = new QLabel( tr( "QUADRANGLES_LAB" ), this );
202 QLabel* a2DQuaTotal = createField();
203 QLabel* a2DQuaLin = createField();
204 QLabel* a2DQuaQuad = createField();
205 QLabel* a2DPolLab = new QLabel( tr( "POLYGONS_LAB" ), this );
206 QLabel* a2DPolTotal = createField();
207 myWidgets[ index++ ] << a2DLine;
208 myWidgets[ index++ ] << a2DLab << a2DTotal << a2DLin << a2DQuad;
209 myWidgets[ index++ ] << a2DTriLab << a2DTriTotal << a2DTriLin << a2DTriQuad;
210 myWidgets[ index++ ] << a2DQuaLab << a2DQuaTotal << a2DQuaLin << a2DQuaQuad;
211 myWidgets[ index++ ] << a2DPolLab << a2DPolTotal;
214 QWidget* a3DLine = createLine();
215 QLabel* a3DLab = new QLabel( tr( "3D_LAB" ), this );
216 QLabel* a3DTotal = createField();
217 QLabel* a3DLin = createField();
218 QLabel* a3DQuad = createField();
219 QLabel* a3DTetLab = new QLabel( tr( "TETRAHEDRONS_LAB" ), this );
220 QLabel* a3DTetTotal = createField();
221 QLabel* a3DTetLin = createField();
222 QLabel* a3DTetQuad = createField();
223 QLabel* a3DHexLab = new QLabel( tr( "HEXAHEDONRS_LAB" ), this );
224 QLabel* a3DHexTotal = createField();
225 QLabel* a3DHexLin = createField();
226 QLabel* a3DHexQuad = createField();
227 QLabel* a3DPyrLab = new QLabel( tr( "PYRAMIDS_LAB" ), this );
228 QLabel* a3DPyrTotal = createField();
229 QLabel* a3DPyrLin = createField();
230 QLabel* a3DPyrQuad = createField();
231 QLabel* a3DPriLab = new QLabel( tr( "PRISMS_LAB" ), this );
232 QLabel* a3DPriTotal = createField();
233 QLabel* a3DPriLin = createField();
234 QLabel* a3DPriQuad = createField();
235 QLabel* a3DHexPriLab = new QLabel( tr( "HEX_PRISMS_LAB" ), this );
236 QLabel* a3DHexPriTotal = createField();
237 QLabel* a3DPolLab = new QLabel( tr( "POLYHEDRONS_LAB" ), this );
238 QLabel* a3DPolTotal = createField();
239 myWidgets[ index++ ] << a3DLine;
240 myWidgets[ index++ ] << a3DLab << a3DTotal << a3DLin << a3DQuad;
241 myWidgets[ index++ ] << a3DTetLab << a3DTetTotal << a3DTetLin << a3DTetQuad;
242 myWidgets[ index++ ] << a3DHexLab << a3DHexTotal << a3DHexLin << a3DHexQuad;
243 myWidgets[ index++ ] << a3DPyrLab << a3DPyrTotal << a3DPyrLin << a3DPyrQuad;
244 myWidgets[ index++ ] << a3DPriLab << a3DPriTotal << a3DPriLin << a3DPriQuad;
245 myWidgets[ index++ ] << a3DHexPriLab << a3DHexPriTotal;
246 myWidgets[ index++ ] << a3DPolLab << a3DPolTotal;
248 myLoadBtn = new QPushButton( tr( "BUT_LOAD_MESH" ), this );
249 myLoadBtn->setAutoDefault( true );
250 connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( loadMesh() ) );
252 setFontAttributes( aNameLab, Bold );
253 setFontAttributes( aObjLab, Bold );
254 setFontAttributes( aNodesLab, Bold );
255 setFontAttributes( aElemLab, Bold );
256 setFontAttributes( aElemTotal, Italic );
257 setFontAttributes( aElemLin, Italic );
258 setFontAttributes( aElemQuad, Italic );
259 setFontAttributes( a0DLab, Bold );
260 setFontAttributes( aBallLab, Bold );
261 setFontAttributes( a1DLab, Bold );
262 setFontAttributes( a2DLab, Bold );
263 setFontAttributes( a3DLab, Bold );
265 l->addWidget( aNameLab, 0, 0 );
266 l->addWidget( aName, 0, 1, 1, 3 );
267 l->addWidget( aObjLab, 1, 0 );
268 l->addWidget( aObj, 1, 1, 1, 3 );
269 l->addWidget( aNodesLine, 2, 0, 1, 4 );
270 l->addWidget( aNodesLab, 3, 0 );
271 l->addWidget( aNodes, 3, 1 );
272 l->addWidget( aElemLine, 4, 0, 1, 4 );
273 l->addWidget( aElemLab, 5, 0 );
274 l->addWidget( aElemTotal, 5, 1 );
275 l->addWidget( aElemLin, 5, 2 );
276 l->addWidget( aElemQuad, 5, 3 );
277 l->addWidget( a0DLine, 6, 1, 1, 3 );
278 l->addWidget( a0DLab, 7, 0 );
279 l->addWidget( a0DTotal, 7, 1 );
280 l->addWidget( aBallLine, 8, 1, 1, 3 );
281 l->addWidget( aBallLab, 9, 0 );
282 l->addWidget( aBallTotal, 9, 1 );
283 l->addWidget( a1DLine, 10, 1, 1, 3 );
284 l->addWidget( a1DLab, 11, 0 );
285 l->addWidget( a1DTotal, 11, 1 );
286 l->addWidget( a1DLin, 11, 2 );
287 l->addWidget( a1DQuad, 11, 3 );
288 l->addWidget( a2DLine, 12, 1, 1, 3 );
289 l->addWidget( a2DLab, 13, 0 );
290 l->addWidget( a2DTotal, 13, 1 );
291 l->addWidget( a2DLin, 13, 2 );
292 l->addWidget( a2DQuad, 13, 3 );
293 l->addWidget( a2DTriLab, 14, 0 );
294 l->addWidget( a2DTriTotal, 14, 1 );
295 l->addWidget( a2DTriLin, 14, 2 );
296 l->addWidget( a2DTriQuad, 14, 3 );
297 l->addWidget( a2DQuaLab, 15, 0 );
298 l->addWidget( a2DQuaTotal, 15, 1 );
299 l->addWidget( a2DQuaLin, 15, 2 );
300 l->addWidget( a2DQuaQuad, 15, 3 );
301 l->addWidget( a2DPolLab, 16, 0 );
302 l->addWidget( a2DPolTotal, 16, 1 );
303 l->addWidget( a3DLine, 17, 1, 1, 3 );
304 l->addWidget( a3DLab, 18, 0 );
305 l->addWidget( a3DTotal, 18, 1 );
306 l->addWidget( a3DLin, 18, 2 );
307 l->addWidget( a3DQuad, 18, 3 );
308 l->addWidget( a3DTetLab, 19, 0 );
309 l->addWidget( a3DTetTotal, 19, 1 );
310 l->addWidget( a3DTetLin, 19, 2 );
311 l->addWidget( a3DTetQuad, 19, 3 );
312 l->addWidget( a3DHexLab, 20, 0 );
313 l->addWidget( a3DHexTotal, 20, 1 );
314 l->addWidget( a3DHexLin, 20, 2 );
315 l->addWidget( a3DHexQuad, 20, 3 );
316 l->addWidget( a3DPyrLab, 21, 0 );
317 l->addWidget( a3DPyrTotal, 21, 1 );
318 l->addWidget( a3DPyrLin, 21, 2 );
319 l->addWidget( a3DPyrQuad, 21, 3 );
320 l->addWidget( a3DPriLab, 22, 0 );
321 l->addWidget( a3DPriTotal, 22, 1 );
322 l->addWidget( a3DPriLin, 22, 2 );
323 l->addWidget( a3DPriQuad, 22, 3 );
324 l->addWidget( a3DHexPriLab, 23, 0 );
325 l->addWidget( a3DHexPriTotal, 23, 1 );
326 l->addWidget( a3DPolLab, 24, 0 );
327 l->addWidget( a3DPolTotal, 24, 1 );
328 l->addWidget( myLoadBtn, 25, 1, 1, 3 );
329 l->setColumnStretch( 0, 0 );
330 l->setColumnStretch( 1, 5 );
331 l->setColumnStretch( 2, 5 );
332 l->setColumnStretch( 3, 5 );
333 l->setRowStretch( 23, 5 );
341 SMESHGUI_MeshInfo::~SMESHGUI_MeshInfo()
346 \brief Show information on the mesh object.
347 \param obj object being processed (mesh, sub-mesh, group, ID source)
349 void SMESHGUI_MeshInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
352 if ( !CORBA::is_nil( obj ) ) {
353 _PTR(SObject) sobj = SMESH::ObjectToSObject( obj );
355 myWidgets[iName][iSingle]->setProperty( "text", sobj->GetName().c_str() );
356 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( obj );
357 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
358 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( obj );
359 if ( !aMesh->_is_nil() ) {
360 myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_MESH" ) );
362 else if ( !aSubMesh->_is_nil() ) {
363 myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_SUBMESH" ) );
365 else if ( !aGroup->_is_nil() ) {
367 switch( aGroup->GetType() ) {
369 objType = tr( "OBJECT_GROUP_NODES" );
372 objType = tr( "OBJECT_GROUP_EDGES" );
375 objType = tr( "OBJECT_GROUP_FACES" );
378 objType = tr( "OBJECT_GROUP_VOLUMES" );
381 objType = tr( "OBJECT_GROUP_0DELEMS" );
384 objType = tr( "OBJECT_GROUP_BALLS" );
387 objType = tr( "OBJECT_GROUP" );
390 myWidgets[iObject][iSingle]->setProperty( "text", objType );
392 SMESH::long_array_var info = obj->GetMeshInfo();
393 myWidgets[iNodes][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Node] ) );
394 myWidgets[i0D][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_0D] ) );
395 myWidgets[iBalls][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Ball] ) );
396 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
397 myWidgets[i1D][iTotal] ->setProperty( "text", QString::number( nbEdges ) );
398 myWidgets[i1D][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Edge] ) );
399 myWidgets[i1D][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Edge] ) );
400 long nbTriangles = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle];
401 long nbQuadrangles = info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle];
402 long nb2DLinear = info[SMDSEntity_Triangle] + info[SMDSEntity_Quadrangle] + info[SMDSEntity_Polygon];
403 long nb2DQuadratic = info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle];
404 myWidgets[i2D][iTotal] ->setProperty( "text", QString::number( nb2DLinear + nb2DQuadratic ) );
405 myWidgets[i2D][iLinear] ->setProperty( "text", QString::number( nb2DLinear ) );
406 myWidgets[i2D][iQuadratic] ->setProperty( "text", QString::number( nb2DQuadratic ) );
407 myWidgets[i2DTriangles][iTotal] ->setProperty( "text", QString::number( nbTriangles ) );
408 myWidgets[i2DTriangles][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Triangle] ) );
409 myWidgets[i2DTriangles][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Triangle] ) );
410 myWidgets[i2DQuadrangles][iTotal] ->setProperty( "text", QString::number( nbQuadrangles ) );
411 myWidgets[i2DQuadrangles][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Quadrangle] ) );
412 myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] ));
413 myWidgets[i2DPolygons][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Polygon] ) );
414 long nbTetrahedrons = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra];
415 long nbHexahedrons = info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa];
416 long nbPyramids = info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid];
417 long nbPrisms = info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta];
418 long nb3DLinear = info[SMDSEntity_Tetra] + info[SMDSEntity_Hexa] + info[SMDSEntity_Pyramid] + info[SMDSEntity_Penta] + info[SMDSEntity_Polyhedra] + info[SMDSEntity_Hexagonal_Prism];
419 long nb3DQuadratic = info[SMDSEntity_Quad_Tetra] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] + info[SMDSEntity_Quad_Pyramid] + info[SMDSEntity_Quad_Penta];
420 myWidgets[i3D][iTotal] ->setProperty( "text", QString::number( nb3DLinear + nb3DQuadratic ) );
421 myWidgets[i3D][iLinear] ->setProperty( "text", QString::number( nb3DLinear ) );
422 myWidgets[i3D][iQuadratic] ->setProperty( "text", QString::number( nb3DQuadratic ) );
423 myWidgets[i3DTetrahedrons][iTotal] ->setProperty( "text", QString::number( nbTetrahedrons ) );
424 myWidgets[i3DTetrahedrons][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Tetra] ) );
425 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Tetra] ) );
426 myWidgets[i3DHexahedrons][iTotal] ->setProperty( "text", QString::number( nbHexahedrons ) );
427 myWidgets[i3DHexahedrons][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Hexa] ) );
428 myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] ) );
429 myWidgets[i3DPyramids][iTotal] ->setProperty( "text", QString::number( nbPyramids ) );
430 myWidgets[i3DPyramids][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Pyramid] ) );
431 myWidgets[i3DPyramids][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Pyramid] ) );
432 myWidgets[i3DPrisms][iTotal] ->setProperty( "text", QString::number( nbPrisms ) );
433 myWidgets[i3DPrisms][iLinear] ->setProperty( "text", QString::number( info[SMDSEntity_Penta] ) );
434 myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Penta] ) );
435 myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Hexagonal_Prism] ) );
436 myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Polyhedra] ) );
438 // before full loading from study file, type of elements in a sub-mesh can't be defined
440 bool infoOK = obj->IsMeshInfoCorrect();
441 myLoadBtn->setVisible( !infoOK );
445 // 1. Type of 2D or 3D elements is unknown but their nb is OK (for a sub-mesh)
446 // 2. No info at all (for a group on geom or filter)
447 bool hasAnyInfo = false;
448 for ( size_t i = 0; i < info->length() && !hasAnyInfo; ++i )
449 hasAnyInfo = info[i];
450 if ( hasAnyInfo ) // believe it is a sub-mesh
452 if ( nb2DLinear + nb2DQuadratic > 0 )
454 myWidgets[i2D][iLinear] ->setProperty( "text", "?" );
455 myWidgets[i2D][iQuadratic] ->setProperty( "text", "?" );
456 myWidgets[i2DTriangles][iTotal] ->setProperty( "text", "?" );
457 myWidgets[i2DTriangles][iLinear] ->setProperty( "text", "?" );
458 myWidgets[i2DTriangles][iQuadratic] ->setProperty( "text", "?" );
459 myWidgets[i2DQuadrangles][iTotal] ->setProperty( "text", "?" );
460 myWidgets[i2DQuadrangles][iLinear] ->setProperty( "text", "?" );
461 myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", "?" );
462 myWidgets[i2DPolygons][iTotal] ->setProperty( "text", "?" );
464 else if ( nb3DLinear + nb3DQuadratic > 0 )
466 myWidgets[i3D][iLinear] ->setProperty( "text", "?" );
467 myWidgets[i3D][iQuadratic] ->setProperty( "text", "?" );
468 myWidgets[i3DTetrahedrons][iTotal] ->setProperty( "text", "?" );
469 myWidgets[i3DTetrahedrons][iLinear] ->setProperty( "text", "?" );
470 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", "?" );
471 myWidgets[i3DHexahedrons][iTotal] ->setProperty( "text", "?" );
472 myWidgets[i3DHexahedrons][iLinear] ->setProperty( "text", "?" );
473 myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", "?" );
474 myWidgets[i3DPyramids][iTotal] ->setProperty( "text", "?" );
475 myWidgets[i3DPyramids][iLinear] ->setProperty( "text", "?" );
476 myWidgets[i3DPyramids][iQuadratic] ->setProperty( "text", "?" );
477 myWidgets[i3DPrisms][iTotal] ->setProperty( "text", "?" );
478 myWidgets[i3DPrisms][iLinear] ->setProperty( "text", "?" );
479 myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", "?" );
480 myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", "?" );
481 myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", "?" );
486 myWidgets[iNodes][iTotal] ->setProperty( "text", "?" );
487 myWidgets[i0D][iTotal] ->setProperty( "text", "?" );
488 myWidgets[iBalls][iTotal] ->setProperty( "text", "?" );
489 myWidgets[i1D][iTotal] ->setProperty( "text", "?" );
490 myWidgets[i1D][iLinear] ->setProperty( "text", "?" );
491 myWidgets[i1D][iQuadratic] ->setProperty( "text", "?" );
492 myWidgets[i2D][iTotal] ->setProperty( "text", "?" );
493 myWidgets[i2D][iLinear] ->setProperty( "text", "?" );
494 myWidgets[i2D][iQuadratic] ->setProperty( "text", "?" );
495 myWidgets[i2DTriangles][iTotal] ->setProperty( "text", "?" );
496 myWidgets[i2DTriangles][iLinear] ->setProperty( "text", "?" );
497 myWidgets[i2DTriangles][iQuadratic] ->setProperty( "text", "?" );
498 myWidgets[i2DQuadrangles][iTotal] ->setProperty( "text", "?" );
499 myWidgets[i2DQuadrangles][iLinear] ->setProperty( "text", "?" );
500 myWidgets[i2DQuadrangles][iQuadratic] ->setProperty( "text", "?" );
501 myWidgets[i2DPolygons][iTotal] ->setProperty( "text", "?" );
502 myWidgets[i3D][iTotal] ->setProperty( "text", "?" );
503 myWidgets[i3D][iLinear] ->setProperty( "text", "?" );
504 myWidgets[i3D][iQuadratic] ->setProperty( "text", "?" );
505 myWidgets[i3DTetrahedrons][iTotal] ->setProperty( "text", "?" );
506 myWidgets[i3DTetrahedrons][iLinear] ->setProperty( "text", "?" );
507 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", "?" );
508 myWidgets[i3DHexahedrons][iTotal] ->setProperty( "text", "?" );
509 myWidgets[i3DHexahedrons][iLinear] ->setProperty( "text", "?" );
510 myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", "?" );
511 myWidgets[i3DPyramids][iTotal] ->setProperty( "text", "?" );
512 myWidgets[i3DPyramids][iLinear] ->setProperty( "text", "?" );
513 myWidgets[i3DPyramids][iQuadratic] ->setProperty( "text", "?" );
514 myWidgets[i3DPrisms][iTotal] ->setProperty( "text", "?" );
515 myWidgets[i3DPrisms][iLinear] ->setProperty( "text", "?" );
516 myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", "?" );
517 myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", "?" );
518 myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", "?" );
525 \brief Load mesh from a study file
527 void SMESHGUI_MeshInfo::loadMesh()
529 SUIT_OverrideCursor wc;
531 SALOME_ListIO selected;
532 SMESHGUI::selectionMgr()->selectedObjects( selected );
534 if ( selected.Extent() == 1 ) {
535 Handle(SALOME_InteractiveObject) IO = selected.First();
536 SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
537 if ( !CORBA::is_nil( obj ) ) {
538 SMESH::SMESH_Mesh_var mesh = obj->GetMesh();
539 if ( !mesh->_is_nil() )
549 \brief Reset the widget to the initial state (nullify all fields).
551 void SMESHGUI_MeshInfo::clear()
553 myWidgets[iName][iSingle] ->setProperty( "text", QString() );
554 myWidgets[iObject][iSingle] ->setProperty( "text", QString() );
555 myWidgets[iNodes][iTotal] ->setProperty( "text", QString::number( 0 ) );
556 myWidgets[i0D][iTotal] ->setProperty( "text", QString::number( 0 ) );
557 myWidgets[iBalls][iTotal] ->setProperty( "text", QString::number( 0 ) );
558 myWidgets[i1D][iTotal] ->setProperty( "text", QString::number( 0 ) );
559 myWidgets[i1D][iLinear] ->setProperty( "text", QString::number( 0 ) );
560 myWidgets[i1D][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
561 myWidgets[i2D][iTotal] ->setProperty( "text", QString::number( 0 ) );
562 myWidgets[i2D][iLinear] ->setProperty( "text", QString::number( 0 ) );
563 myWidgets[i2D][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
564 myWidgets[i2DTriangles][iTotal] ->setProperty( "text", QString::number( 0 ) );
565 myWidgets[i2DTriangles][iLinear] ->setProperty( "text", QString::number( 0 ) );
566 myWidgets[i2DTriangles][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
567 myWidgets[i2DQuadrangles][iTotal] ->setProperty( "text", QString::number( 0 ) );
568 myWidgets[i2DQuadrangles][iLinear] ->setProperty( "text", QString::number( 0 ) );
569 myWidgets[i2DQuadrangles][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
570 myWidgets[i2DPolygons][iTotal] ->setProperty( "text", QString::number( 0 ) );
571 myWidgets[i3D][iTotal] ->setProperty( "text", QString::number( 0 ) );
572 myWidgets[i3D][iLinear] ->setProperty( "text", QString::number( 0 ) );
573 myWidgets[i3D][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
574 myWidgets[i3DTetrahedrons][iTotal] ->setProperty( "text", QString::number( 0 ) );
575 myWidgets[i3DTetrahedrons][iLinear] ->setProperty( "text", QString::number( 0 ) );
576 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( 0 ) );
577 myWidgets[i3DHexahedrons][iTotal] ->setProperty( "text", QString::number( 0 ) );
578 myWidgets[i3DHexahedrons][iLinear] ->setProperty( "text", QString::number( 0 ) );
579 myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
580 myWidgets[i3DPyramids][iTotal] ->setProperty( "text", QString::number( 0 ) );
581 myWidgets[i3DPyramids][iLinear] ->setProperty( "text", QString::number( 0 ) );
582 myWidgets[i3DPyramids][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
583 myWidgets[i3DPrisms][iTotal] ->setProperty( "text", QString::number( 0 ) );
584 myWidgets[i3DPrisms][iLinear] ->setProperty( "text", QString::number( 0 ) );
585 myWidgets[i3DPrisms][iQuadratic] ->setProperty( "text", QString::number( 0 ) );
586 myWidgets[i3DHexaPrisms][iTotal] ->setProperty( "text", QString::number( 0 ) );
587 myWidgets[i3DPolyhedrons][iTotal] ->setProperty( "text", QString::number( 0 ) );
591 \brief Create info field
592 \return new info field
594 QLabel* SMESHGUI_MeshInfo::createField()
596 QLabel* lab = new QLabel( this );
597 lab->setFrameStyle( StyledPanel | Sunken );
598 lab->setAlignment( Qt::AlignCenter );
599 lab->setAutoFillBackground( true );
600 QPalette pal = lab->palette();
601 pal.setColor( QPalette::Window, QApplication::palette().color( QPalette::Active, QPalette::Base ) );
602 lab->setPalette( pal );
603 lab->setMinimumWidth( 70 );
608 \brief Create horizontal rule.
609 \return new line object
611 QWidget* SMESHGUI_MeshInfo::createLine()
613 QFrame* line = new QFrame( this );
614 line->setFrameStyle( HLine | Sunken );
619 \brief Change widget font attributes (bold, italic, ...).
621 \param attr font attributes (XORed flags)
622 \param val value to be set to attributes
624 void SMESHGUI_MeshInfo::setFontAttributes( QWidget* w, int attr, bool val )
628 if ( attr & Bold ) f.setBold( val );
629 if ( attr & Italic ) f.setItalic( val );
635 \brief Show/hide group(s) of fields.
636 \param start beginning of the block
637 \param end end of the block
638 \param on visibility flag
640 void SMESHGUI_MeshInfo::setFieldsVisible( int start, int end, bool on )
642 start = qMax( 0, start );
643 end = qMin( end, (int)iElementsEnd );
644 for ( int i = start; i < end; i++ ) {
645 wlist wl = myWidgets[i];
646 foreach ( QWidget* w, wl ) w->setVisible( on );
651 \class SMESHGUI_ElemInfo
652 \brief Base class for the mesh element information widget.
657 \param parent parent widget
659 SMESHGUI_ElemInfo::SMESHGUI_ElemInfo( QWidget* parent )
660 : QWidget( parent ), myActor( 0 ), myIsElement( -1 )
662 myFrame = new QWidget( this );
663 myExtra = new ExtraWidget( this );
664 QVBoxLayout* vbl = new QVBoxLayout( this );
666 vbl->setSpacing( 0 );
667 vbl->addWidget( myFrame );
668 vbl->addWidget( myExtra );
669 connect( myExtra->prev, SIGNAL( clicked() ), this, SLOT( showPrevious() ) );
670 connect( myExtra->next, SIGNAL( clicked() ), this, SLOT( showNext() ) );
677 SMESHGUI_ElemInfo::~SMESHGUI_ElemInfo()
682 \brief Set mesh data source (actor)
683 \param actor mesh object actor
685 void SMESHGUI_ElemInfo::setSource( SMESH_Actor* actor )
687 if ( myActor != actor ) {
695 \brief Show mesh element information
696 \param id mesh node / element ID
697 \param isElem show mesh element information if \c true or mesh node information if \c false
699 void SMESHGUI_ElemInfo::showInfo( long id, bool isElem )
703 showInfo( ids, isElem );
707 \brief Show mesh element information
708 \param ids mesh nodes / elements identifiers
709 \param isElem show mesh element information if \c true or mesh node information if \c false
711 void SMESHGUI_ElemInfo::showInfo( QSet<long> ids, bool isElem )
713 QList<long> newIds = ids.toList();
715 if ( myIDs == newIds && myIsElement == isElem ) return;
718 myIsElement = isElem;
721 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
725 \brief Clear mesh element information widget
727 void SMESHGUI_ElemInfo::clear()
736 \brief Get central area widget
737 \return central widget
739 QWidget* SMESHGUI_ElemInfo::frame() const
746 \return actor being used
748 SMESH_Actor* SMESHGUI_ElemInfo::actor() const
754 \brief Get current info mode.
755 \return \c true if mesh element information is shown or \c false if node information is shown
757 bool SMESHGUI_ElemInfo::isElements() const
763 \fn void SMESHGUI_ElemInfo::information( const QList<long>& ids )
764 \brief Show information on the specified nodes / elements
766 This function is to be redefined in sub-classes.
768 \param ids nodes / elements identifiers information is to be shown on
772 \brief Internal clean-up (reset widget)
774 void SMESHGUI_ElemInfo::clearInternal()
779 \brief Get node connectivity
780 \param node mesh node
781 \return node connectivity map
783 SMESHGUI_ElemInfo::Connectivity SMESHGUI_ElemInfo::nodeConnectivity( const SMDS_MeshNode* node )
787 SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
788 while ( it && it->more() ) {
789 const SMDS_MeshElement* ne = it->next();
790 elmap[ ne->GetType() ] << ne->GetID();
797 \brief Format connectivity data to string representation
798 \param connectivity connetivity map
799 \param type element type
800 \return string representation of the connectivity
802 QString SMESHGUI_ElemInfo::formatConnectivity( Connectivity connectivity, int type )
805 if ( connectivity.contains( type ) ) {
806 QList<int> elements = connectivity[ type ];
808 foreach( int id, elements )
809 str << QString::number( id );
811 return str.join( " " );
815 \brief Calculate gravity center of the mesh element
816 \param element mesh element
818 SMESHGUI_ElemInfo::XYZ SMESHGUI_ElemInfo::gravityCenter( const SMDS_MeshElement* element )
822 SMDS_ElemIteratorPtr nodeIt = element->nodesIterator();
823 while ( nodeIt->more() ) {
824 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
825 xyz.add( node->X(), node->Y(), node->Z() );
827 xyz.divide( element->NbNodes() );
833 \brief This slot is called from "Show Previous" button click.
834 Shows information on the previous group of the items.
836 void SMESHGUI_ElemInfo::showPrevious()
838 myIndex = qMax( 0, myIndex-1 );
840 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
844 \brief This slot is called from "Show Next" button click.
845 Shows information on the next group of the items.
847 void SMESHGUI_ElemInfo::showNext()
849 myIndex = qMin( myIndex+1, myIDs.count() / MAXITEMS );
851 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
855 \brief Update widgets state
857 void SMESHGUI_ElemInfo::updateControls()
859 myExtra->updateControls( myIDs.count(), myIndex );
863 \class SMESHGUI_SimpleElemInfo
864 \brief Represents mesh element information in the simple text area.
869 \param parent parent widget
871 SMESHGUI_SimpleElemInfo::SMESHGUI_SimpleElemInfo( QWidget* parent )
872 : SMESHGUI_ElemInfo( parent )
874 myInfo = new QTextBrowser( frame() );
875 QVBoxLayout* l = new QVBoxLayout( frame() );
877 l->addWidget( myInfo );
881 \brief Show mesh element information
882 \param ids mesh nodes / elements identifiers
884 void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
889 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
891 if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) )
892 cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 );
893 foreach ( long id, ids ) {
894 if ( !isElements() ) {
898 const SMDS_MeshNode* node = actor()->GetObject()->GetMesh()->FindNode( id );
902 myInfo->append( QString( "<b>%1 #%2</b>" ).arg( tr( "NODE" ) ).arg( id ) );
904 myInfo->append( "" );
906 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
907 arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
908 arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
909 arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
911 myInfo->append( "" );
913 Connectivity connectivity = nodeConnectivity( node );
914 if ( !connectivity.isEmpty() ) {
915 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
916 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
917 if ( !con.isEmpty() )
918 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
919 con = formatConnectivity( connectivity, SMDSAbs_Edge );
920 if ( !con.isEmpty() )
921 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
922 con = formatConnectivity( connectivity, SMDSAbs_Ball );
923 if ( !con.isEmpty() )
924 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "BALL_ELEMENTS" ) ).arg( con ) );
925 con = formatConnectivity( connectivity, SMDSAbs_Face );
926 if ( !con.isEmpty() )
927 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
928 con = formatConnectivity( connectivity, SMDSAbs_Volume );
929 if ( !con.isEmpty() )
930 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
933 myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
940 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
941 SMESH::Controls::NumericalFunctorPtr afunctor;
944 // element ID && type
946 switch( e->GetType() ) {
947 case SMDSAbs_0DElement:
948 stype = tr( "0D ELEMENT" ); break;
950 stype = tr( "BALL" ); break;
952 stype = tr( "EDGE" ); break;
954 stype = tr( "FACE" ); break;
956 stype = tr( "VOLUME" ); break;
960 if ( stype.isEmpty() ) return;
961 myInfo->append( QString( "<b>%1 #%2</b>" ).arg( stype ).arg( id ) );
963 myInfo->append( "" );
966 switch( e->GetEntityType() ) {
967 case SMDSEntity_Triangle:
968 case SMDSEntity_Quad_Triangle:
969 gtype = tr( "TRIANGLE" ); break;
970 case SMDSEntity_Quadrangle:
971 case SMDSEntity_Quad_Quadrangle:
972 case SMDSEntity_BiQuad_Quadrangle:
973 gtype = tr( "QUADRANGLE" ); break;
974 case SMDSEntity_Polygon:
975 case SMDSEntity_Quad_Polygon:
976 gtype = tr( "POLYGON" ); break;
977 case SMDSEntity_Tetra:
978 case SMDSEntity_Quad_Tetra:
979 gtype = tr( "TETRAHEDRON" ); break;
980 case SMDSEntity_Pyramid:
981 case SMDSEntity_Quad_Pyramid:
982 gtype = tr( "PYRAMID" ); break;
983 case SMDSEntity_Hexa:
984 case SMDSEntity_Quad_Hexa:
985 case SMDSEntity_TriQuad_Hexa:
986 gtype = tr( "HEXAHEDRON" ); break;
987 case SMDSEntity_Penta:
988 case SMDSEntity_Quad_Penta:
989 gtype = tr( "PRISM" ); break;
990 case SMDSEntity_Hexagonal_Prism:
991 gtype = tr( "HEX_PRISM" ); break;
992 case SMDSEntity_Polyhedra:
993 case SMDSEntity_Quad_Polyhedra:
994 gtype = tr( "POLYHEDRON" ); break;
998 if ( !gtype.isEmpty() )
999 myInfo->append( QString( "<b>%1:</b> %2" ).arg( tr( "TYPE" ) ).arg( gtype ) );
1000 // quadratic flag and gravity center (any element except 0D)
1001 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Ball ) {
1003 myInfo->append( QString( "<b>%1?</b> %2" ).arg( tr( "QUADRATIC" ) ).arg( e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) ) );
1005 myInfo->append( "" );
1007 XYZ gc = gravityCenter( e );
1008 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "GRAVITY_CENTER" ) ).arg( gc.x() ).arg( gc.y() ).arg( gc.z() ) );
1010 if ( const SMDS_BallElement* ball = dynamic_cast<const SMDS_BallElement*>( e )) {
1012 myInfo->append( QString( "<b>%1:</b> %2" ).arg( tr( "BALL_DIAMETER" ) ).arg( ball->GetDiameter() ));
1015 myInfo->append( "" );
1017 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
1018 for ( int idx = 1; nodeIt->more(); idx++ ) {
1019 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
1020 // node number and ID
1021 myInfo->append( QString( "<b>%1 %2/%3</b> - #%4" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ).arg( node->GetID() ) );
1023 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
1024 arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
1025 arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
1026 arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1027 // node connectivity
1028 Connectivity connectivity = nodeConnectivity( node );
1029 if ( !connectivity.isEmpty() ) {
1030 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
1031 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1032 if ( !con.isEmpty() )
1033 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
1034 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1035 if ( !con.isEmpty() )
1036 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
1037 con = formatConnectivity( connectivity, SMDSAbs_Face );
1038 if ( !con.isEmpty() )
1039 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
1040 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1041 if ( !con.isEmpty() )
1042 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
1045 myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
1049 myInfo->append( "" );
1051 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "MEN_CTRL" ) ) );
1053 if ( e->GetType() == SMDSAbs_Edge ) {
1054 afunctor.reset( new SMESH::Controls::Length() );
1055 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1056 afunctor->SetPrecision( cprecision );
1057 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "LENGTH_EDGES" ) ).arg( afunctor->GetValue( id ) ) );
1059 if( e->GetType() == SMDSAbs_Face ) {
1061 afunctor.reset( new SMESH::Controls::Area() );
1062 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1063 afunctor->SetPrecision( cprecision );
1064 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "AREA_ELEMENTS" ) ).arg( afunctor->GetValue( id ) ) );
1066 afunctor.reset( new SMESH::Controls::Taper() );
1067 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1068 afunctor->SetPrecision( cprecision );
1069 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MEN_TAPER" ) ).arg( afunctor->GetValue( id ) ) );
1071 afunctor.reset( new SMESH::Controls::AspectRatio() );
1072 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1073 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "ASPECTRATIO_ELEMENTS" ) ).arg( afunctor->GetValue( id ) ) );
1075 afunctor.reset( new SMESH::Controls::MinimumAngle() );
1076 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1077 afunctor->SetPrecision( cprecision );
1078 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MINIMUMANGLE_ELEMENTS" ) ).arg( afunctor->GetValue( id ) ) );
1080 afunctor.reset( new SMESH::Controls::Warping() );
1081 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1082 afunctor->SetPrecision( cprecision );
1083 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "STB_WARP" ) ).arg( afunctor->GetValue( id ) ) );
1085 afunctor.reset( new SMESH::Controls::Skew() );
1086 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1087 afunctor->SetPrecision( cprecision );
1088 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "TOP_SKEW" ) ).arg( afunctor->GetValue( id ) ) );
1090 afunctor.reset( new SMESH::Controls::MaxElementLength2D() );
1091 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1092 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_2D" ) ).arg( afunctor->GetValue( id ) ) );
1094 if( e->GetType() == SMDSAbs_Volume ) {
1096 afunctor.reset( new SMESH::Controls::AspectRatio3D() );
1097 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1098 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "ASPECTRATIO_3D_ELEMENTS" ) ).arg( afunctor->GetValue( id ) ) );
1100 afunctor.reset( new SMESH::Controls::Volume() );
1101 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1102 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MEN_VOLUME_3D" ) ).arg( afunctor->GetValue( id ) ) );
1104 afunctor.reset( new SMESH::Controls::Volume() );
1105 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1106 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_3D" ) ).arg( afunctor->GetValue( id ) ) );
1109 if( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
1111 myInfo->append( "" );
1113 int shapeID = e->getshapeId();
1114 if ( shapeID > 0 ) {
1116 switch ( actor()->GetObject()->GetMesh()->FindElement( shapeID )->GetType() ) {
1117 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" ); break;
1118 case SMDS_TOP_FACE: shapeType = tr( "FACE" ); break;
1119 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1120 default: shapeType = tr( "SOLID" );
1122 myInfo->append( QString( "<b>%1:</b> %2 #%3" ).arg( tr( "Position" ) ).arg( shapeType ).arg( shapeID ) );
1128 if ( ids.count() > 1 ) {
1129 myInfo->append( "" );
1130 myInfo->append( "------" );
1131 myInfo->append( "" );
1138 \brief Internal clean-up (reset widget)
1140 void SMESHGUI_SimpleElemInfo::clearInternal()
1146 \class SMESHGUI_TreeElemInfo::ItemDelegate
1147 \brief Item delegate for tree mesh info widget
1150 class SMESHGUI_TreeElemInfo::ItemDelegate : public QItemDelegate
1153 ItemDelegate( QObject* );
1154 QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
1161 SMESHGUI_TreeElemInfo::ItemDelegate::ItemDelegate( QObject* parent ) : QItemDelegate( parent )
1166 \brief Create item editor widget
1169 QWidget* SMESHGUI_TreeElemInfo::ItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
1171 QWidget* w = index.column() == 0 ? 0: QItemDelegate::createEditor( parent, option, index );
1172 if ( qobject_cast<QLineEdit*>( w ) ) qobject_cast<QLineEdit*>( w )->setReadOnly( true );
1177 \class SMESHGUI_TreeElemInfo
1178 \brief Represents mesh element information in the tree-like form.
1183 \param parent parent widget
1185 SMESHGUI_TreeElemInfo::SMESHGUI_TreeElemInfo( QWidget* parent )
1186 : SMESHGUI_ElemInfo( parent )
1188 myInfo = new QTreeWidget( frame() );
1189 myInfo->setColumnCount( 2 );
1190 myInfo->setHeaderLabels( QStringList() << tr( "PROPERTY" ) << tr( "VALUE" ) );
1191 myInfo->header()->setStretchLastSection( true );
1192 myInfo->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
1193 myInfo->setItemDelegate( new ItemDelegate( myInfo ) );
1194 QVBoxLayout* l = new QVBoxLayout( frame() );
1196 l->addWidget( myInfo );
1200 \brief Show mesh element information
1201 \param ids mesh nodes / elements identifiers
1203 void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
1208 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
1209 int cprecision = -1;
1210 if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) )
1211 cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 );
1212 foreach ( long id, ids ) {
1213 if ( !isElements() ) {
1217 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
1219 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
1222 QTreeWidgetItem* nodeItem = createItem( 0, Bold | All );
1223 nodeItem->setText( 0, tr( "NODE" ) );
1224 nodeItem->setText( 1, QString( "#%1" ).arg( id ) );
1226 QTreeWidgetItem* coordItem = createItem( nodeItem, Bold );
1227 coordItem->setText( 0, tr( "COORDINATES" ) );
1228 QTreeWidgetItem* xItem = createItem( coordItem );
1229 xItem->setText( 0, "X" );
1230 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1231 QTreeWidgetItem* yItem = createItem( coordItem );
1232 yItem->setText( 0, "Y" );
1233 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1234 QTreeWidgetItem* zItem = createItem( coordItem );
1235 zItem->setText( 0, "Z" );
1236 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1238 QTreeWidgetItem* conItem = createItem( nodeItem, Bold );
1239 conItem->setText( 0, tr( "CONNECTIVITY" ) );
1240 Connectivity connectivity = nodeConnectivity( node );
1241 if ( !connectivity.isEmpty() ) {
1242 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1243 if ( !con.isEmpty() ) {
1244 QTreeWidgetItem* i = createItem( conItem );
1245 i->setText( 0, tr( "0D_ELEMENTS" ) );
1246 i->setText( 1, con );
1248 con = formatConnectivity( connectivity, SMDSAbs_Ball );
1249 if ( !con.isEmpty() ) {
1250 QTreeWidgetItem* i = createItem( conItem );
1251 i->setText( 0, tr( "BALL_ELEMENTS" ) );
1252 i->setText( 1, con );
1254 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1255 if ( !con.isEmpty() ) {
1256 QTreeWidgetItem* i = createItem( conItem );
1257 i->setText( 0, tr( "EDGES" ) );
1258 i->setText( 1, con );
1260 con = formatConnectivity( connectivity, SMDSAbs_Face );
1261 if ( !con.isEmpty() ) {
1262 QTreeWidgetItem* i = createItem( conItem );
1263 i->setText( 0, tr( "FACES" ) );
1264 i->setText( 1, con );
1266 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1267 if ( !con.isEmpty() ) {
1268 QTreeWidgetItem* i = createItem( conItem );
1269 i->setText( 0, tr( "VOLUMES" ) );
1270 i->setText( 1, con );
1274 conItem->setText( 1, tr( "FREE_NODE" ) );
1277 int shapeID = node->getshapeId();
1280 SMDS_PositionPtr pos = node->GetPosition();
1281 SMDS_TypeOfPosition posType = pos->GetTypeOfPosition();
1284 switch ( posType ) {
1285 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" );
1286 u = static_cast<SMDS_EdgePosition*>( pos )->GetUParameter();
1288 case SMDS_TOP_FACE: shapeType = tr( "FACE" );
1289 u = static_cast<SMDS_FacePosition*>( pos )->GetUParameter();
1290 v = static_cast<SMDS_FacePosition*>( pos )->GetVParameter();
1292 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1293 default: shapeType = tr( "SOLID" );
1295 QTreeWidgetItem* posItem = createItem( nodeItem, Bold );
1296 posItem->setText( 0, tr("NODE_POSITION") );
1297 posItem->setText( 1, (shapeType + " #%1").arg( shapeID ));
1298 if ( posType == SMDS_TOP_EDGE || posType == SMDS_TOP_FACE ) {
1299 QTreeWidgetItem* uItem = createItem( posItem );
1300 uItem->setText( 0, tr("U_POSITION") );
1301 uItem->setText( 1, QString::number( u, precision > 0 ? 'f' : 'g', qAbs( precision )));
1302 if ( posType == SMDS_TOP_FACE ) {
1303 QTreeWidgetItem* vItem = createItem( posItem );
1304 vItem->setText( 0, tr("V_POSITION") );
1305 vItem->setText( 1, QString::number( v, precision > 0 ? 'f' : 'g', qAbs( precision )));
1312 // show element info
1314 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
1315 SMESH::Controls::NumericalFunctorPtr afunctor;
1318 // element ID && type
1320 switch( e->GetType() ) {
1321 case SMDSAbs_0DElement:
1322 stype = tr( "0D ELEMENT" ); break;
1324 stype = tr( "BALL" ); break;
1326 stype = tr( "EDGE" ); break;
1328 stype = tr( "FACE" ); break;
1329 case SMDSAbs_Volume:
1330 stype = tr( "VOLUME" ); break;
1334 if ( stype.isEmpty() ) return;
1335 QTreeWidgetItem* elemItem = createItem( 0, Bold | All );
1336 elemItem->setText( 0, stype );
1337 elemItem->setText( 1, QString( "#%1" ).arg( id ) );
1340 switch( e->GetEntityType() ) {
1341 case SMDSEntity_Triangle:
1342 case SMDSEntity_Quad_Triangle:
1343 gtype = tr( "TRIANGLE" ); break;
1344 case SMDSEntity_Quadrangle:
1345 case SMDSEntity_Quad_Quadrangle:
1346 case SMDSEntity_BiQuad_Quadrangle:
1347 gtype = tr( "QUADRANGLE" ); break;
1348 case SMDSEntity_Polygon:
1349 case SMDSEntity_Quad_Polygon:
1350 gtype = tr( "POLYGON" ); break;
1351 case SMDSEntity_Tetra:
1352 case SMDSEntity_Quad_Tetra:
1353 gtype = tr( "TETRAHEDRON" ); break;
1354 case SMDSEntity_Pyramid:
1355 case SMDSEntity_Quad_Pyramid:
1356 gtype = tr( "PYRAMID" ); break;
1357 case SMDSEntity_Hexa:
1358 case SMDSEntity_Quad_Hexa:
1359 case SMDSEntity_TriQuad_Hexa:
1360 gtype = tr( "HEXAHEDRON" ); break;
1361 case SMDSEntity_Penta:
1362 case SMDSEntity_Quad_Penta:
1363 gtype = tr( "PRISM" ); break;
1364 case SMDSEntity_Hexagonal_Prism:
1365 gtype = tr( "HEX_PRISM" ); break;
1366 case SMDSEntity_Polyhedra:
1367 case SMDSEntity_Quad_Polyhedra:
1368 gtype = tr( "POLYHEDRON" ); break;
1372 if ( !gtype.isEmpty() ) {
1373 QTreeWidgetItem* typeItem = createItem( elemItem, Bold );
1374 typeItem->setText( 0, tr( "TYPE" ) );
1375 typeItem->setText( 1, gtype );
1377 // quadratic flag and gravity center (any element except 0D)
1378 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Ball ) {
1380 QTreeWidgetItem* quadItem = createItem( elemItem, Bold );
1381 quadItem->setText( 0, tr( "QUADRATIC" ) );
1382 quadItem->setText( 1, e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) );
1384 XYZ gc = gravityCenter( e );
1385 QTreeWidgetItem* gcItem = createItem( elemItem, Bold );
1386 gcItem->setText( 0, tr( "GRAVITY_CENTER" ) );
1387 QTreeWidgetItem* xItem = createItem( gcItem );
1388 xItem->setText( 0, "X" );
1389 xItem->setText( 1, QString::number( gc.x(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1390 QTreeWidgetItem* yItem = createItem( gcItem );
1391 yItem->setText( 0, "Y" );
1392 yItem->setText( 1, QString::number( gc.y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1393 QTreeWidgetItem* zItem = createItem( gcItem );
1394 zItem->setText( 0, "Z" );
1395 zItem->setText( 1, QString::number( gc.z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1397 if ( const SMDS_BallElement* ball = dynamic_cast<const SMDS_BallElement*>( e )) {
1399 QTreeWidgetItem* diamItem = createItem( elemItem, Bold );
1400 diamItem->setText( 0, tr( "BALL_DIAMETER" ) );
1401 diamItem->setText( 1, QString( "%1" ).arg( ball->GetDiameter() ));
1404 QTreeWidgetItem* conItem = createItem( elemItem, Bold );
1405 conItem->setText( 0, tr( "CONNECTIVITY" ) );
1406 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
1407 for ( int idx = 1; nodeIt->more(); idx++ ) {
1408 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
1409 // node number and ID
1410 QTreeWidgetItem* nodeItem = createItem( conItem, Bold );
1411 nodeItem->setText( 0, QString( "%1 %2 / %3" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ) );
1412 nodeItem->setText( 1, QString( "#%1" ).arg( node->GetID() ) );
1413 nodeItem->setExpanded( false );
1415 QTreeWidgetItem* coordItem = createItem( nodeItem );
1416 coordItem->setText( 0, tr( "COORDINATES" ) );
1417 QTreeWidgetItem* xItem = createItem( coordItem );
1418 xItem->setText( 0, "X" );
1419 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1420 QTreeWidgetItem* yItem = createItem( coordItem );
1421 yItem->setText( 0, "Y" );
1422 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1423 QTreeWidgetItem* zItem = createItem( coordItem );
1424 zItem->setText( 0, "Z" );
1425 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1426 // node connectivity
1427 QTreeWidgetItem* nconItem = createItem( nodeItem );
1428 nconItem->setText( 0, tr( "CONNECTIVITY" ) );
1429 Connectivity connectivity = nodeConnectivity( node );
1430 if ( !connectivity.isEmpty() ) {
1431 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1432 if ( !con.isEmpty() ) {
1433 QTreeWidgetItem* i = createItem( nconItem );
1434 i->setText( 0, tr( "0D_ELEMENTS" ) );
1435 i->setText( 1, con );
1437 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1438 if ( !con.isEmpty() ) {
1439 QTreeWidgetItem* i = createItem( nconItem );
1440 i->setText( 0, tr( "EDGES" ) );
1441 i->setText( 1, con );
1443 con = formatConnectivity( connectivity, SMDSAbs_Ball );
1444 if ( !con.isEmpty() ) {
1445 QTreeWidgetItem* i = createItem( nconItem );
1446 i->setText( 0, tr( "BALL_ELEMENTS" ) );
1447 i->setText( 1, con );
1449 con = formatConnectivity( connectivity, SMDSAbs_Face );
1450 if ( !con.isEmpty() ) {
1451 QTreeWidgetItem* i = createItem( nconItem );
1452 i->setText( 0, tr( "FACES" ) );
1453 i->setText( 1, con );
1455 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1456 if ( !con.isEmpty() ) {
1457 QTreeWidgetItem* i = createItem( nconItem );
1458 i->setText( 0, tr( "VOLUMES" ) );
1459 i->setText( 1, con );
1464 QTreeWidgetItem* cntrItem = createItem( elemItem, Bold );
1465 cntrItem->setText( 0, tr( "MEN_CTRL" ) );
1467 if( e->GetType()==SMDSAbs_Edge){
1468 afunctor.reset( new SMESH::Controls::Length() );
1469 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1470 afunctor->SetPrecision( cprecision );
1471 QTreeWidgetItem* lenItem = createItem( cntrItem, Bold );
1472 lenItem->setText( 0, tr( "LENGTH_EDGES" ) );
1473 lenItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1475 if( e->GetType() == SMDSAbs_Face ) {
1477 afunctor.reset( new SMESH::Controls::Area() );
1478 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1479 afunctor->SetPrecision( cprecision );
1480 QTreeWidgetItem* areaItem = createItem( cntrItem, Bold );
1481 areaItem->setText( 0, tr( "AREA_ELEMENTS" ) );
1482 areaItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue(id) ) );
1484 afunctor.reset( new SMESH::Controls::Taper() );
1485 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1486 afunctor->SetPrecision( cprecision );
1487 QTreeWidgetItem* taperlItem = createItem( cntrItem, Bold );
1488 taperlItem->setText( 0, tr( "MEN_TAPER" ) );
1489 taperlItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1491 afunctor.reset( new SMESH::Controls::AspectRatio() );
1492 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1493 QTreeWidgetItem* ratlItem = createItem( cntrItem, Bold );
1494 ratlItem->setText( 0, tr( "ASPECTRATIO_ELEMENTS" ));
1495 ratlItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1497 afunctor.reset( new SMESH::Controls::MinimumAngle() );
1498 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1499 afunctor->SetPrecision( cprecision );
1500 QTreeWidgetItem* minanglItem = createItem( cntrItem, Bold );
1501 minanglItem->setText( 0, tr( "MINIMUMANGLE_ELEMENTS" ) );
1502 minanglItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1504 afunctor.reset( new SMESH::Controls::Warping() );
1505 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1506 afunctor->SetPrecision( cprecision );
1507 QTreeWidgetItem* warpItem = createItem( cntrItem, Bold );
1508 warpItem->setText( 0, tr( "STB_WARP" ));
1509 warpItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1511 afunctor.reset( new SMESH::Controls::Skew() );
1512 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1513 afunctor->SetPrecision( cprecision );
1514 QTreeWidgetItem* skewItem = createItem( cntrItem, Bold );
1515 skewItem->setText( 0, tr( "TOP_SKEW" ) );
1516 skewItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1518 afunctor.reset( new SMESH::Controls::MaxElementLength2D() );
1519 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1520 QTreeWidgetItem* diamItem = createItem( cntrItem, Bold );
1521 diamItem->setText( 0, tr( "MAX_ELEMENT_LENGTH_2D" ));
1522 diamItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1524 if( e->GetType() == SMDSAbs_Volume ) {
1526 afunctor.reset( new SMESH::Controls::AspectRatio3D() );
1527 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1528 QTreeWidgetItem* ratlItem3 = createItem( cntrItem, Bold );
1529 ratlItem3->setText( 0, tr( "ASPECTRATIO_3D_ELEMENTS" ) );
1530 ratlItem3->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1532 afunctor.reset( new SMESH::Controls::Volume() );
1533 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1534 QTreeWidgetItem* volItem = createItem( cntrItem, Bold );
1535 volItem->setText( 0, tr( "MEN_VOLUME_3D" ) );
1536 volItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1538 afunctor.reset( new SMESH::Controls::MaxElementLength3D() );
1539 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1540 QTreeWidgetItem* diam3Item = createItem( cntrItem, Bold );
1541 diam3Item->setText( 0, tr( "MAX_ELEMENT_LENGTH_3D" ) );
1542 diam3Item->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1545 if( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
1547 int shapeID = e->getshapeId();
1548 if ( shapeID > 0 ) {
1549 QTreeWidgetItem* shItem = createItem( elemItem, Bold );
1551 switch ( actor()->GetObject()->GetMesh()->FindElement( shapeID )->GetType() ) {
1552 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" ); break;
1553 case SMDS_TOP_FACE: shapeType = tr( "FACE" ); break;
1554 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1555 default: shapeType = tr( "SOLID" );
1557 shItem->setText( 0, tr( "Position" ) );
1558 shItem->setText( 1, QString( "%1 #%2" ).arg(shapeType).arg( shapeID ) );
1568 \brief Internal clean-up (reset widget)
1570 void SMESHGUI_TreeElemInfo::clearInternal()
1577 \brief Create new tree item.
1578 \param parent parent tree widget item
1579 \param flags item flag
1580 \return new tree widget item
1582 QTreeWidgetItem* SMESHGUI_TreeElemInfo::createItem( QTreeWidgetItem* parent, int flags )
1584 QTreeWidgetItem* item;
1586 item = new QTreeWidgetItem( parent );
1588 item = new QTreeWidgetItem( myInfo );
1590 item->setFlags( item->flags() | Qt::ItemIsEditable );
1592 QFont f = item->font( 0 );
1594 for ( int i = 0; i < myInfo->columnCount(); i++ ) {
1595 if ( ( flags & Bold ) && ( i == 0 || flags & All ) )
1596 item->setFont( i, f );
1599 item->setExpanded( true );
1605 \brief Mesh information computer
1608 The class is created for different computation operation. Currently it is used
1609 to compute number of underlying nodes for the groups.
1615 GrpComputor::GrpComputor( SMESH::SMESH_GroupBase_ptr grp, QTreeWidgetItem* item, QObject* parent )
1616 : QObject( parent ), myItem( item )
1618 myGroup = SMESH::SMESH_GroupBase::_narrow( grp );
1622 \brief Compute function
1624 void GrpComputor::compute()
1626 if ( !CORBA::is_nil( myGroup ) && myItem ) {
1627 QTreeWidgetItem* item = myItem;
1629 int nbNodes = myGroup->GetNumberOfNodes();
1630 item->treeWidget()->removeItemWidget( item, 1 );
1631 item->setText( 1, QString::number( nbNodes ));
1636 \class SMESHGUI_AddInfo
1637 \brief The wigdet shows additional information on the mesh object.
1642 \param parent parent widget
1644 SMESHGUI_AddInfo::SMESHGUI_AddInfo( QWidget* parent )
1645 : QTreeWidget( parent )
1647 setColumnCount( 2 );
1648 header()->setStretchLastSection( true );
1649 header()->setResizeMode( 0, QHeaderView::ResizeToContents );
1656 SMESHGUI_AddInfo::~SMESHGUI_AddInfo()
1661 \brief Show additional information on the selected object
1662 \param obj object being processed (mesh, sub-mesh, group, ID source)
1664 void SMESHGUI_AddInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
1666 setProperty( "group_index", 0 );
1667 setProperty( "submesh_index", 0 );
1668 myComputors.clear();
1671 if ( CORBA::is_nil( obj ) ) return;
1673 _PTR(SObject) sobj = SMESH::ObjectToSObject( obj );
1674 if ( !sobj ) return;
1677 QTreeWidgetItem* nameItem = createItem( 0, Bold | All );
1678 nameItem->setText( 0, tr( "NAME" ) );
1679 nameItem->setText( 1, sobj->GetName().c_str() );
1681 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( obj );
1682 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
1683 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( obj );
1685 if ( !aMesh->_is_nil() )
1686 meshInfo( aMesh, nameItem );
1687 else if ( !aSubMesh->_is_nil() )
1688 subMeshInfo( aSubMesh, nameItem );
1689 else if ( !aGroup->_is_nil() )
1690 groupInfo( aGroup.in(), nameItem );
1694 \brief Create new tree item.
1695 \param parent parent tree widget item
1696 \param flags item flag
1697 \return new tree widget item
1699 QTreeWidgetItem* SMESHGUI_AddInfo::createItem( QTreeWidgetItem* parent, int flags )
1701 QTreeWidgetItem* item;
1704 item = new QTreeWidgetItem( parent );
1706 item = new QTreeWidgetItem( this );
1708 //item->setFlags( item->flags() | Qt::ItemIsEditable );
1710 QFont f = item->font( 0 );
1712 for ( int i = 0; i < columnCount(); i++ ) {
1713 if ( ( flags & Bold ) && ( i == 0 || flags & All ) )
1714 item->setFont( i, f );
1717 item->setExpanded( true );
1722 \brief Show mesh info
1723 \param mesh mesh object
1724 \param parent parent tree item
1726 void SMESHGUI_AddInfo::meshInfo( SMESH::SMESH_Mesh_ptr mesh, QTreeWidgetItem* parent )
1729 GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh();
1730 SALOME_MED::MedFileInfo* inf = mesh->GetMEDFileInfo();
1731 QTreeWidgetItem* typeItem = createItem( parent, Bold );
1732 typeItem->setText( 0, tr( "TYPE" ) );
1733 if ( !CORBA::is_nil( shape ) ) {
1734 typeItem->setText( 1, tr( "MESH_ON_GEOMETRY" ) );
1735 _PTR(SObject) sobj = SMESH::ObjectToSObject( shape );
1737 QTreeWidgetItem* gobjItem = createItem( typeItem );
1738 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1739 gobjItem->setText( 1, sobj->GetName().c_str() );
1742 else if ( strlen( (char*)inf->fileName ) > 0 ) {
1743 typeItem->setText( 1, tr( "MESH_FROM_FILE" ) );
1744 QTreeWidgetItem* fileItem = createItem( typeItem );
1745 fileItem->setText( 0, tr( "FILE_NAME" ) );
1746 fileItem->setText( 1, (char*)inf->fileName );
1749 typeItem->setText( 1, tr( "STANDALONE_MESH" ) );
1753 myGroups = mesh->GetGroups();
1757 mySubMeshes = mesh->GetSubMeshes();
1762 \brief Show sub-mesh info
1763 \param subMesh sub-mesh object
1764 \param parent parent tree item
1766 void SMESHGUI_AddInfo::subMeshInfo( SMESH::SMESH_subMesh_ptr subMesh, QTreeWidgetItem* parent )
1768 bool isShort = parent->parent() != 0;
1772 _PTR(SObject) sobj = SMESH::ObjectToSObject( subMesh->GetFather() );
1774 QTreeWidgetItem* nameItem = createItem( parent, Bold );
1775 nameItem->setText( 0, tr( "PARENT_MESH" ) );
1776 nameItem->setText( 1, sobj->GetName().c_str() );
1781 GEOM::GEOM_Object_var gobj = subMesh->GetSubShape();
1782 _PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
1784 QTreeWidgetItem* gobjItem = createItem( parent, Bold );
1785 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1786 gobjItem->setText( 1, sobj->GetName().c_str() );
1791 \brief Show group info
1792 \param grp mesh group object
1793 \param parent parent tree item
1795 void SMESHGUI_AddInfo::groupInfo( SMESH::SMESH_GroupBase_ptr grp, QTreeWidgetItem* parent )
1797 bool isShort = parent->parent() != 0;
1799 SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( grp );
1800 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( grp );
1801 SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( grp );
1805 _PTR(SObject) sobj = SMESH::ObjectToSObject( grp->GetMesh() );
1807 QTreeWidgetItem* nameItem = createItem( parent, Bold );
1808 nameItem->setText( 0, tr( "PARENT_MESH" ) );
1809 nameItem->setText( 1, sobj->GetName().c_str() );
1813 // type : group on geometry, standalone group, group on filter
1814 QTreeWidgetItem* typeItem = createItem( parent, Bold );
1815 typeItem->setText( 0, tr( "TYPE" ) );
1816 if ( !CORBA::is_nil( aStdGroup ) ) {
1817 typeItem->setText( 1, tr( "STANDALONE_GROUP" ) );
1819 else if ( !CORBA::is_nil( aGeomGroup ) ) {
1820 typeItem->setText( 1, tr( "GROUP_ON_GEOMETRY" ) );
1821 GEOM::GEOM_Object_var gobj = aGeomGroup->GetShape();
1822 _PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
1824 QTreeWidgetItem* gobjItem = createItem( typeItem );
1825 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1826 gobjItem->setText( 1, sobj->GetName().c_str() );
1829 else if ( !CORBA::is_nil( aFltGroup ) ) {
1830 typeItem->setText( 1, tr( "GROUP_ON_FILTER" ) );
1835 QString etype = tr( "UNKNOWN" );
1836 switch( grp->GetType() ) {
1838 etype = tr( "NODE" );
1841 etype = tr( "EDGE" );
1844 etype = tr( "FACE" );
1847 etype = tr( "VOLUME" );
1850 etype = tr( "0DELEM" );
1853 etype = tr( "BALL" );
1858 QTreeWidgetItem* etypeItem = createItem( parent, Bold );
1859 etypeItem->setText( 0, tr( "ENTITY_TYPE" ) );
1860 etypeItem->setText( 1, etype );
1864 QTreeWidgetItem* sizeItem = createItem( parent, Bold );
1865 sizeItem->setText( 0, tr( "SIZE" ) );
1866 sizeItem->setText( 1, QString::number( grp->Size() ) );
1869 SALOMEDS::Color color = grp->GetColor();
1870 QTreeWidgetItem* colorItem = createItem( parent, Bold );
1871 colorItem->setText( 0, tr( "COLOR" ) );
1872 colorItem->setBackground( 1, QBrush( QColor( color.R*255., color.G*255., color.B*255.) ) );
1874 // nb of underlying nodes
1875 if ( grp->GetType() != SMESH::NODE) {
1876 QTreeWidgetItem* nodesItem = createItem( parent, Bold );
1877 nodesItem->setText( 0, tr( "NB_NODES" ) );
1878 int nbNodesLimit = SMESHGUI::resourceMgr()->integerValue( "SMESH", "info_groups_nodes_limit", 100000 );
1879 SMESH::SMESH_Mesh_var mesh = grp->GetMesh();
1880 bool meshLoaded = mesh->IsLoaded();
1881 bool toShowNodes = ( grp->IsNodeInfoAvailable() || nbNodesLimit <= 0 || grp->Size() <= nbNodesLimit );
1882 if ( toShowNodes && meshLoaded ) {
1883 // already calculated and up-to-date
1884 nodesItem->setText( 1, QString::number( grp->GetNumberOfNodes() ) );
1887 QPushButton* btn = new QPushButton( tr( meshLoaded ? "COMPUTE" : "LOAD"), this );
1888 setItemWidget( nodesItem, 1, btn );
1889 GrpComputor* comp = new GrpComputor( grp, nodesItem, this );
1890 connect( btn, SIGNAL( clicked() ), comp, SLOT( compute() ) );
1891 myComputors.append( comp );
1893 connect( btn, SIGNAL( clicked() ), this, SLOT( changeLoadToCompute() ) );
1898 void SMESHGUI_AddInfo::showGroups()
1900 myComputors.clear();
1902 QTreeWidgetItem* parent = topLevelItemCount() > 0 ? topLevelItem( 0 ) : 0; // parent should be first top level item
1903 if ( !parent ) return;
1905 int idx = property( "group_index" ).toInt();
1907 QTreeWidgetItem* itemGroups = 0;
1908 for ( int i = 0; i < parent->childCount() && !itemGroups; i++ ) {
1909 if ( parent->child( i )->data( 0, Qt::UserRole ).toInt() == GROUPS_ID ) {
1910 itemGroups = parent->child( i );
1911 ExtraWidget* extra = dynamic_cast<ExtraWidget*>( itemWidget( itemGroups, 1 ) );
1913 extra->updateControls( myGroups->length(), idx );
1914 while ( itemGroups->childCount() ) delete itemGroups->child( 0 ); // clear child items
1918 QMap<int, QTreeWidgetItem*> grpItems;
1919 for ( int i = idx*MAXITEMS ; i < qMin( (idx+1)*MAXITEMS, (int)myGroups->length() ); i++ ) {
1920 SMESH::SMESH_GroupBase_var grp = myGroups[i];
1921 if ( CORBA::is_nil( grp ) ) continue;
1922 _PTR(SObject) grpSObj = SMESH::ObjectToSObject( grp );
1923 if ( !grpSObj ) continue;
1925 int grpType = grp->GetType();
1927 if ( !itemGroups ) {
1928 // create top-level groups container item
1929 itemGroups = createItem( parent, Bold | All );
1930 itemGroups->setText( 0, tr( "GROUPS" ) );
1931 itemGroups->setData( 0, Qt::UserRole, GROUPS_ID );
1933 // total number of groups > 10, show extra widgets for info browsing
1934 if ( myGroups->length() > MAXITEMS ) {
1935 ExtraWidget* extra = new ExtraWidget( this, true );
1936 connect( extra->prev, SIGNAL( clicked() ), this, SLOT( showPreviousGroups() ) );
1937 connect( extra->next, SIGNAL( clicked() ), this, SLOT( showNextGroups() ) );
1938 setItemWidget( itemGroups, 1, extra );
1939 extra->updateControls( myGroups->length(), idx );
1943 if ( grpItems.find( grpType ) == grpItems.end() ) {
1944 grpItems[ grpType ] = createItem( itemGroups, Bold | All );
1945 grpItems[ grpType ]->setText( 0, tr( QString( "GROUPS_%1" ).arg( grpType ).toLatin1().constData() ) );
1946 itemGroups->insertChild( grpType-1, grpItems[ grpType ] );
1950 QTreeWidgetItem* grpNameItem = createItem( grpItems[ grpType ] );
1951 grpNameItem->setText( 0, QString( grpSObj->GetName().c_str() ).trimmed() ); // name is trimmed
1954 groupInfo( grp.in(), grpNameItem );
1958 void SMESHGUI_AddInfo::showSubMeshes()
1960 QTreeWidgetItem* parent = topLevelItemCount() > 0 ? topLevelItem( 0 ) : 0; // parent should be first top level item
1961 if ( !parent ) return;
1963 int idx = property( "submesh_index" ).toInt();
1965 QTreeWidgetItem* itemSubMeshes = 0;
1966 for ( int i = 0; i < parent->childCount() && !itemSubMeshes; i++ ) {
1967 if ( parent->child( i )->data( 0, Qt::UserRole ).toInt() == SUBMESHES_ID ) {
1968 itemSubMeshes = parent->child( i );
1969 ExtraWidget* extra = dynamic_cast<ExtraWidget*>( itemWidget( itemSubMeshes, 1 ) );
1971 extra->updateControls( mySubMeshes->length(), idx );
1972 while ( itemSubMeshes->childCount() ) delete itemSubMeshes->child( 0 ); // clear child items
1976 QMap<int, QTreeWidgetItem*> smItems;
1977 for ( int i = idx*MAXITEMS ; i < qMin( (idx+1)*MAXITEMS, (int)mySubMeshes->length() ); i++ ) {
1978 SMESH::SMESH_subMesh_var sm = mySubMeshes[i];
1979 if ( CORBA::is_nil( sm ) ) continue;
1980 _PTR(SObject) smSObj = SMESH::ObjectToSObject( sm );
1981 if ( !smSObj ) continue;
1983 GEOM::GEOM_Object_var gobj = sm->GetSubShape();
1984 if ( CORBA::is_nil(gobj ) ) continue;
1986 int smType = gobj->GetShapeType();
1987 if ( smType == GEOM::COMPSOLID ) smType = GEOM::COMPOUND;
1989 if ( !itemSubMeshes ) {
1990 itemSubMeshes = createItem( parent, Bold | All );
1991 itemSubMeshes->setText( 0, tr( "SUBMESHES" ) );
1992 itemSubMeshes->setData( 0, Qt::UserRole, SUBMESHES_ID );
1994 // total number of sub-meshes > 10, show extra widgets for info browsing
1995 if ( mySubMeshes->length() > MAXITEMS ) {
1996 ExtraWidget* extra = new ExtraWidget( this, true );
1997 connect( extra->prev, SIGNAL( clicked() ), this, SLOT( showPreviousSubMeshes() ) );
1998 connect( extra->next, SIGNAL( clicked() ), this, SLOT( showNextSubMeshes() ) );
1999 setItemWidget( itemSubMeshes, 1, extra );
2000 extra->updateControls( mySubMeshes->length(), idx );
2004 if ( smItems.find( smType ) == smItems.end() ) {
2005 smItems[ smType ] = createItem( itemSubMeshes, Bold | All );
2006 smItems[ smType ]->setText( 0, tr( QString( "SUBMESHES_%1" ).arg( smType ).toLatin1().constData() ) );
2007 itemSubMeshes->insertChild( smType, smItems[ smType ] );
2011 QTreeWidgetItem* smNameItem = createItem( smItems[ smType ] );
2012 smNameItem->setText( 0, QString( smSObj->GetName().c_str() ).trimmed() ); // name is trimmed
2015 subMeshInfo( sm.in(), smNameItem );
2020 * \brief Change button label of "nb underlying node" group from "Load" to "Compute"
2022 void SMESHGUI_AddInfo::changeLoadToCompute()
2024 for ( int i = 0; i < myComputors.count(); ++i )
2026 if ( QTreeWidgetItem* item = myComputors[i]->getItem() )
2028 if ( QPushButton* btn = qobject_cast<QPushButton*>( itemWidget ( item, 1 ) ) )
2029 btn->setText( tr("COMPUTE") );
2034 void SMESHGUI_AddInfo::showPreviousGroups()
2036 int idx = property( "group_index" ).toInt();
2037 setProperty( "group_index", idx-1 );
2041 void SMESHGUI_AddInfo::showNextGroups()
2043 int idx = property( "group_index" ).toInt();
2044 setProperty( "group_index", idx+1 );
2048 void SMESHGUI_AddInfo::showPreviousSubMeshes()
2050 int idx = property( "submesh_index" ).toInt();
2051 setProperty( "submesh_index", idx-1 );
2055 void SMESHGUI_AddInfo::showNextSubMeshes()
2057 int idx = property( "submesh_index" ).toInt();
2058 setProperty( "submesh_index", idx+1 );
2063 \class SMESHGUI_MeshInfoDlg
2064 \brief Mesh information dialog box
2069 \param parent parent widget
2070 \param page specifies the dialog page to be shown at the start-up
2072 SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page )
2073 : QDialog( parent ), myActor( 0 )
2076 setAttribute( Qt::WA_DeleteOnClose, true );
2077 setWindowTitle( tr( "MESH_INFO" ) );
2078 setSizeGripEnabled( true );
2080 myTabWidget = new QTabWidget( this );
2084 myBaseInfo = new SMESHGUI_MeshInfo( myTabWidget );
2085 myTabWidget->addTab( myBaseInfo, tr( "BASE_INFO" ) );
2089 QWidget* w = new QWidget( myTabWidget );
2091 myMode = new QButtonGroup( this );
2092 myMode->addButton( new QRadioButton( tr( "NODE_MODE" ), w ), NodeMode );
2093 myMode->addButton( new QRadioButton( tr( "ELEM_MODE" ), w ), ElemMode );
2094 myMode->button( NodeMode )->setChecked( true );
2095 myID = new QLineEdit( w );
2096 myID->setValidator( new SMESHGUI_IdValidator( this ) );
2098 int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 );
2099 mode = qMin( 1, qMax( 0, mode ) );
2102 myElemInfo = new SMESHGUI_SimpleElemInfo( w );
2104 myElemInfo = new SMESHGUI_TreeElemInfo( w );
2106 QGridLayout* elemLayout = new QGridLayout( w );
2107 elemLayout->setMargin( MARGIN );
2108 elemLayout->setSpacing( SPACING );
2109 elemLayout->addWidget( myMode->button( NodeMode ), 0, 0 );
2110 elemLayout->addWidget( myMode->button( ElemMode ), 0, 1 );
2111 elemLayout->addWidget( myID, 0, 2 );
2112 elemLayout->addWidget( myElemInfo, 1, 0, 1, 3 );
2114 myTabWidget->addTab( w, tr( "ELEM_INFO" ) );
2118 myAddInfo = new SMESHGUI_AddInfo( myTabWidget );
2119 myTabWidget->addTab( myAddInfo, tr( "ADDITIONAL_INFO" ) );
2123 QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this );
2124 okBtn->setAutoDefault( true );
2125 okBtn->setDefault( true );
2127 QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
2128 helpBtn->setAutoDefault( true );
2130 QHBoxLayout* btnLayout = new QHBoxLayout;
2131 btnLayout->setSpacing( SPACING );
2132 btnLayout->setMargin( 0 );
2134 btnLayout->addWidget( okBtn );
2135 btnLayout->addStretch( 10 );
2136 btnLayout->addWidget( helpBtn );
2138 QVBoxLayout* l = new QVBoxLayout ( this );
2139 l->setMargin( MARGIN );
2140 l->setSpacing( SPACING );
2141 l->addWidget( myTabWidget );
2142 l->addLayout( btnLayout );
2144 myTabWidget->setCurrentIndex( qMax( (int)BaseInfo, qMin( (int)ElemInfo, page ) ) );
2146 connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
2147 connect( helpBtn, SIGNAL( clicked() ), this, SLOT( help() ) );
2148 connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( updateSelection() ) );
2149 connect( myMode, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged() ) );
2150 connect( myID, SIGNAL( textEdited( QString ) ), this, SLOT( idChanged() ) );
2151 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() ) );
2152 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) );
2160 SMESHGUI_MeshInfoDlg::~SMESHGUI_MeshInfoDlg()
2165 \brief Show mesh information
2166 \param IO interactive object
2168 void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO )
2170 SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
2171 if ( !CORBA::is_nil( obj ) ) {
2172 myBaseInfo->showInfo( obj );
2173 myAddInfo->showInfo( obj );
2175 myActor = SMESH::FindActorByEntry( IO->getEntry() );
2176 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
2179 if ( myActor && selector ) {
2180 nb = myMode->checkedId() == NodeMode ?
2181 SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
2182 SMESH::GetNameOfSelectedNodes( selector, IO, ID );
2184 myElemInfo->setSource( myActor ) ;
2186 myID->setText( ID.trimmed() );
2188 QStringList idTxt = ID.split( " ", QString::SkipEmptyParts );
2189 foreach ( ID, idTxt )
2190 ids << ID.trimmed().toLong();
2191 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
2195 myElemInfo->clear();
2201 \brief Perform clean-up actions on the dialog box closing.
2203 void SMESHGUI_MeshInfoDlg::reject()
2205 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
2206 selMgr->clearFilters();
2207 SMESH::SetPointRepresentation( false );
2208 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2209 aViewWindow->SetSelectionMode( ActorSelection );
2214 \brief Process keyboard event
2215 \param e key press event
2217 void SMESHGUI_MeshInfoDlg::keyPressEvent( QKeyEvent* e )
2219 QDialog::keyPressEvent( e );
2220 if ( !e->isAccepted() && e->key() == Qt::Key_F1 ) {
2227 \brief Reactivate dialog box, when mouse pointer goes into it.
2229 void SMESHGUI_MeshInfoDlg::enterEvent( QEvent* )
2235 \brief Setup selection mode depending on the current dialog box state.
2237 void SMESHGUI_MeshInfoDlg::updateSelection()
2239 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
2241 disconnect( selMgr, 0, this, 0 );
2242 selMgr->clearFilters();
2244 if ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) {
2245 SMESH::SetPointRepresentation( false );
2246 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2247 aViewWindow->SetSelectionMode( ActorSelection );
2250 if ( myMode->checkedId() == NodeMode ) {
2251 SMESH::SetPointRepresentation( true );
2252 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2253 aViewWindow->SetSelectionMode( NodeSelection );
2256 SMESH::SetPointRepresentation( false );
2257 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2258 aViewWindow->SetSelectionMode( CellSelection );
2262 QString oldID = myID->text().trimmed();
2263 SMESH_Actor* oldActor = myActor;
2266 connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
2269 if ( oldActor == myActor && myActor && !oldID.isEmpty() ) {
2270 myID->setText( oldID );
2276 \brief Show help page
2278 void SMESHGUI_MeshInfoDlg::help()
2280 SMESH::ShowHelpFile( ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) ?
2281 "mesh_infos_page.html#advanced_mesh_infos_anchor" :
2282 "mesh_infos_page.html#mesh_element_info_anchor" );
2286 \brief Show mesh information
2288 void SMESHGUI_MeshInfoDlg::updateInfo()
2290 SUIT_OverrideCursor wc;
2292 SALOME_ListIO selected;
2293 SMESHGUI::selectionMgr()->selectedObjects( selected );
2295 if ( selected.Extent() == 1 ) {
2296 Handle(SALOME_InteractiveObject) IO = selected.First();
2300 // myBaseInfo->clear();
2301 // myElemInfo->clear();
2302 // myAddInfo->clear();
2307 \brief Activate dialog box
2309 void SMESHGUI_MeshInfoDlg::activate()
2311 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
2312 SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this );
2313 myTabWidget->setEnabled( true );
2318 \brief Deactivate dialog box
2320 void SMESHGUI_MeshInfoDlg::deactivate()
2322 myTabWidget->setEnabled( false );
2323 disconnect( SMESHGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
2327 \brief Called when users switches between node / element modes.
2329 void SMESHGUI_MeshInfoDlg::modeChanged()
2336 \brief Caled when users prints mesh element ID in the corresponding field.
2338 void SMESHGUI_MeshInfoDlg::idChanged()
2340 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
2341 if ( myActor && selector ) {
2342 Handle(SALOME_InteractiveObject) IO = myActor->getIO();
2343 TColStd_MapOfInteger ID;
2345 QStringList idTxt = myID->text().split( " ", QString::SkipEmptyParts );
2346 foreach ( QString tid, idTxt ) {
2347 long id = tid.trimmed().toLong();
2348 const SMDS_MeshElement* e = myMode->checkedId() == ElemMode ?
2349 myActor->GetObject()->GetMesh()->FindElement( id ) :
2350 myActor->GetObject()->GetMesh()->FindNode( id );
2356 selector->AddOrRemoveIndex( IO, ID, false );
2357 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2358 aViewWindow->highlight( IO, true, true );
2359 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );