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 ) ) );
1108 if( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
1110 myInfo->append( "" );
1112 int shapeID = e->getshapeId();
1113 if ( shapeID > 0 ) {
1115 switch ( actor()->GetObject()->GetMesh()->FindElement( shapeID )->GetType() ) {
1116 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" ); break;
1117 case SMDS_TOP_FACE: shapeType = tr( "FACE" ); break;
1118 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1119 default: shapeType = tr( "SOLID" );
1121 myInfo->append( QString( "<b>%1:</b> %2 #%3" ).arg( tr( "Position" ) ).arg( shapeType ).arg( shapeID ) );
1126 if ( ids.count() > 1 ) {
1127 myInfo->append( "" );
1128 myInfo->append( "------" );
1129 myInfo->append( "" );
1136 \brief Internal clean-up (reset widget)
1138 void SMESHGUI_SimpleElemInfo::clearInternal()
1144 \class SMESHGUI_TreeElemInfo::ItemDelegate
1145 \brief Item delegate for tree mesh info widget
1148 class SMESHGUI_TreeElemInfo::ItemDelegate : public QItemDelegate
1151 ItemDelegate( QObject* );
1152 QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
1159 SMESHGUI_TreeElemInfo::ItemDelegate::ItemDelegate( QObject* parent ) : QItemDelegate( parent )
1164 \brief Create item editor widget
1167 QWidget* SMESHGUI_TreeElemInfo::ItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
1169 QWidget* w = index.column() == 0 ? 0: QItemDelegate::createEditor( parent, option, index );
1170 if ( qobject_cast<QLineEdit*>( w ) ) qobject_cast<QLineEdit*>( w )->setReadOnly( true );
1175 \class SMESHGUI_TreeElemInfo
1176 \brief Represents mesh element information in the tree-like form.
1181 \param parent parent widget
1183 SMESHGUI_TreeElemInfo::SMESHGUI_TreeElemInfo( QWidget* parent )
1184 : SMESHGUI_ElemInfo( parent )
1186 myInfo = new QTreeWidget( frame() );
1187 myInfo->setColumnCount( 2 );
1188 myInfo->setHeaderLabels( QStringList() << tr( "PROPERTY" ) << tr( "VALUE" ) );
1189 myInfo->header()->setStretchLastSection( true );
1190 myInfo->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
1191 myInfo->setItemDelegate( new ItemDelegate( myInfo ) );
1192 QVBoxLayout* l = new QVBoxLayout( frame() );
1194 l->addWidget( myInfo );
1198 \brief Show mesh element information
1199 \param ids mesh nodes / elements identifiers
1201 void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
1206 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
1207 int cprecision = -1;
1208 if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) )
1209 cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 );
1210 foreach ( long id, ids ) {
1211 if ( !isElements() ) {
1215 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
1217 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
1220 QTreeWidgetItem* nodeItem = createItem( 0, Bold | All );
1221 nodeItem->setText( 0, tr( "NODE" ) );
1222 nodeItem->setText( 1, QString( "#%1" ).arg( id ) );
1224 QTreeWidgetItem* coordItem = createItem( nodeItem, Bold );
1225 coordItem->setText( 0, tr( "COORDINATES" ) );
1226 QTreeWidgetItem* xItem = createItem( coordItem );
1227 xItem->setText( 0, "X" );
1228 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1229 QTreeWidgetItem* yItem = createItem( coordItem );
1230 yItem->setText( 0, "Y" );
1231 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1232 QTreeWidgetItem* zItem = createItem( coordItem );
1233 zItem->setText( 0, "Z" );
1234 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1236 QTreeWidgetItem* conItem = createItem( nodeItem, Bold );
1237 conItem->setText( 0, tr( "CONNECTIVITY" ) );
1238 Connectivity connectivity = nodeConnectivity( node );
1239 if ( !connectivity.isEmpty() ) {
1240 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1241 if ( !con.isEmpty() ) {
1242 QTreeWidgetItem* i = createItem( conItem );
1243 i->setText( 0, tr( "0D_ELEMENTS" ) );
1244 i->setText( 1, con );
1246 con = formatConnectivity( connectivity, SMDSAbs_Ball );
1247 if ( !con.isEmpty() ) {
1248 QTreeWidgetItem* i = createItem( conItem );
1249 i->setText( 0, tr( "BALL_ELEMENTS" ) );
1250 i->setText( 1, con );
1252 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1253 if ( !con.isEmpty() ) {
1254 QTreeWidgetItem* i = createItem( conItem );
1255 i->setText( 0, tr( "EDGES" ) );
1256 i->setText( 1, con );
1258 con = formatConnectivity( connectivity, SMDSAbs_Face );
1259 if ( !con.isEmpty() ) {
1260 QTreeWidgetItem* i = createItem( conItem );
1261 i->setText( 0, tr( "FACES" ) );
1262 i->setText( 1, con );
1264 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1265 if ( !con.isEmpty() ) {
1266 QTreeWidgetItem* i = createItem( conItem );
1267 i->setText( 0, tr( "VOLUMES" ) );
1268 i->setText( 1, con );
1272 conItem->setText( 1, tr( "FREE_NODE" ) );
1275 int shapeID = node->getshapeId();
1278 SMDS_PositionPtr pos = node->GetPosition();
1279 SMDS_TypeOfPosition posType = pos->GetTypeOfPosition();
1282 switch ( posType ) {
1283 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" );
1284 u = static_cast<SMDS_EdgePosition*>( pos )->GetUParameter();
1286 case SMDS_TOP_FACE: shapeType = tr( "FACE" );
1287 u = static_cast<SMDS_FacePosition*>( pos )->GetUParameter();
1288 v = static_cast<SMDS_FacePosition*>( pos )->GetVParameter();
1290 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1291 default: shapeType = tr( "SOLID" );
1293 QTreeWidgetItem* posItem = createItem( nodeItem, Bold );
1294 posItem->setText( 0, tr("NODE_POSITION") );
1295 posItem->setText( 1, (shapeType + " #%1").arg( shapeID ));
1296 if ( posType == SMDS_TOP_EDGE || posType == SMDS_TOP_FACE ) {
1297 QTreeWidgetItem* uItem = createItem( posItem );
1298 uItem->setText( 0, tr("U_POSITION") );
1299 uItem->setText( 1, QString::number( u, precision > 0 ? 'f' : 'g', qAbs( precision )));
1300 if ( posType == SMDS_TOP_FACE ) {
1301 QTreeWidgetItem* vItem = createItem( posItem );
1302 vItem->setText( 0, tr("V_POSITION") );
1303 vItem->setText( 1, QString::number( v, precision > 0 ? 'f' : 'g', qAbs( precision )));
1310 // show element info
1312 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
1313 SMESH::Controls::NumericalFunctorPtr afunctor;
1316 // element ID && type
1318 switch( e->GetType() ) {
1319 case SMDSAbs_0DElement:
1320 stype = tr( "0D ELEMENT" ); break;
1322 stype = tr( "BALL" ); break;
1324 stype = tr( "EDGE" ); break;
1326 stype = tr( "FACE" ); break;
1327 case SMDSAbs_Volume:
1328 stype = tr( "VOLUME" ); break;
1332 if ( stype.isEmpty() ) return;
1333 QTreeWidgetItem* elemItem = createItem( 0, Bold | All );
1334 elemItem->setText( 0, stype );
1335 elemItem->setText( 1, QString( "#%1" ).arg( id ) );
1338 switch( e->GetEntityType() ) {
1339 case SMDSEntity_Triangle:
1340 case SMDSEntity_Quad_Triangle:
1341 gtype = tr( "TRIANGLE" ); break;
1342 case SMDSEntity_Quadrangle:
1343 case SMDSEntity_Quad_Quadrangle:
1344 case SMDSEntity_BiQuad_Quadrangle:
1345 gtype = tr( "QUADRANGLE" ); break;
1346 case SMDSEntity_Polygon:
1347 case SMDSEntity_Quad_Polygon:
1348 gtype = tr( "POLYGON" ); break;
1349 case SMDSEntity_Tetra:
1350 case SMDSEntity_Quad_Tetra:
1351 gtype = tr( "TETRAHEDRON" ); break;
1352 case SMDSEntity_Pyramid:
1353 case SMDSEntity_Quad_Pyramid:
1354 gtype = tr( "PYRAMID" ); break;
1355 case SMDSEntity_Hexa:
1356 case SMDSEntity_Quad_Hexa:
1357 case SMDSEntity_TriQuad_Hexa:
1358 gtype = tr( "HEXAHEDRON" ); break;
1359 case SMDSEntity_Penta:
1360 case SMDSEntity_Quad_Penta:
1361 gtype = tr( "PRISM" ); break;
1362 case SMDSEntity_Hexagonal_Prism:
1363 gtype = tr( "HEX_PRISM" ); break;
1364 case SMDSEntity_Polyhedra:
1365 case SMDSEntity_Quad_Polyhedra:
1366 gtype = tr( "POLYHEDRON" ); break;
1370 if ( !gtype.isEmpty() ) {
1371 QTreeWidgetItem* typeItem = createItem( elemItem, Bold );
1372 typeItem->setText( 0, tr( "TYPE" ) );
1373 typeItem->setText( 1, gtype );
1375 // quadratic flag and gravity center (any element except 0D)
1376 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Ball ) {
1378 QTreeWidgetItem* quadItem = createItem( elemItem, Bold );
1379 quadItem->setText( 0, tr( "QUADRATIC" ) );
1380 quadItem->setText( 1, e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) );
1382 XYZ gc = gravityCenter( e );
1383 QTreeWidgetItem* gcItem = createItem( elemItem, Bold );
1384 gcItem->setText( 0, tr( "GRAVITY_CENTER" ) );
1385 QTreeWidgetItem* xItem = createItem( gcItem );
1386 xItem->setText( 0, "X" );
1387 xItem->setText( 1, QString::number( gc.x(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1388 QTreeWidgetItem* yItem = createItem( gcItem );
1389 yItem->setText( 0, "Y" );
1390 yItem->setText( 1, QString::number( gc.y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1391 QTreeWidgetItem* zItem = createItem( gcItem );
1392 zItem->setText( 0, "Z" );
1393 zItem->setText( 1, QString::number( gc.z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1395 if ( const SMDS_BallElement* ball = dynamic_cast<const SMDS_BallElement*>( e )) {
1397 QTreeWidgetItem* diamItem = createItem( elemItem, Bold );
1398 diamItem->setText( 0, tr( "BALL_DIAMETER" ) );
1399 diamItem->setText( 1, QString( "%1" ).arg( ball->GetDiameter() ));
1402 QTreeWidgetItem* conItem = createItem( elemItem, Bold );
1403 conItem->setText( 0, tr( "CONNECTIVITY" ) );
1404 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
1405 for ( int idx = 1; nodeIt->more(); idx++ ) {
1406 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
1407 // node number and ID
1408 QTreeWidgetItem* nodeItem = createItem( conItem, Bold );
1409 nodeItem->setText( 0, QString( "%1 %2 / %3" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ) );
1410 nodeItem->setText( 1, QString( "#%1" ).arg( node->GetID() ) );
1411 nodeItem->setExpanded( false );
1413 QTreeWidgetItem* coordItem = createItem( nodeItem );
1414 coordItem->setText( 0, tr( "COORDINATES" ) );
1415 QTreeWidgetItem* xItem = createItem( coordItem );
1416 xItem->setText( 0, "X" );
1417 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1418 QTreeWidgetItem* yItem = createItem( coordItem );
1419 yItem->setText( 0, "Y" );
1420 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1421 QTreeWidgetItem* zItem = createItem( coordItem );
1422 zItem->setText( 0, "Z" );
1423 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1424 // node connectivity
1425 QTreeWidgetItem* nconItem = createItem( nodeItem );
1426 nconItem->setText( 0, tr( "CONNECTIVITY" ) );
1427 Connectivity connectivity = nodeConnectivity( node );
1428 if ( !connectivity.isEmpty() ) {
1429 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1430 if ( !con.isEmpty() ) {
1431 QTreeWidgetItem* i = createItem( nconItem );
1432 i->setText( 0, tr( "0D_ELEMENTS" ) );
1433 i->setText( 1, con );
1435 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1436 if ( !con.isEmpty() ) {
1437 QTreeWidgetItem* i = createItem( nconItem );
1438 i->setText( 0, tr( "EDGES" ) );
1439 i->setText( 1, con );
1441 con = formatConnectivity( connectivity, SMDSAbs_Ball );
1442 if ( !con.isEmpty() ) {
1443 QTreeWidgetItem* i = createItem( nconItem );
1444 i->setText( 0, tr( "BALL_ELEMENTS" ) );
1445 i->setText( 1, con );
1447 con = formatConnectivity( connectivity, SMDSAbs_Face );
1448 if ( !con.isEmpty() ) {
1449 QTreeWidgetItem* i = createItem( nconItem );
1450 i->setText( 0, tr( "FACES" ) );
1451 i->setText( 1, con );
1453 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1454 if ( !con.isEmpty() ) {
1455 QTreeWidgetItem* i = createItem( nconItem );
1456 i->setText( 0, tr( "VOLUMES" ) );
1457 i->setText( 1, con );
1462 QTreeWidgetItem* cntrItem = createItem( elemItem, Bold );
1463 cntrItem->setText( 0, tr( "MEN_CTRL" ) );
1465 if( e->GetType()==SMDSAbs_Edge){
1466 afunctor.reset( new SMESH::Controls::Length() );
1467 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1468 afunctor->SetPrecision( cprecision );
1469 QTreeWidgetItem* lenItem = createItem( cntrItem, Bold );
1470 lenItem->setText( 0, tr( "LENGTH_EDGES" ) );
1471 lenItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1473 if( e->GetType() == SMDSAbs_Face ) {
1475 afunctor.reset( new SMESH::Controls::Area() );
1476 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1477 afunctor->SetPrecision( cprecision );
1478 QTreeWidgetItem* areaItem = createItem( cntrItem, Bold );
1479 areaItem->setText( 0, tr( "AREA_ELEMENTS" ) );
1480 areaItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue(id) ) );
1482 afunctor.reset( new SMESH::Controls::Taper() );
1483 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1484 afunctor->SetPrecision( cprecision );
1485 QTreeWidgetItem* taperlItem = createItem( cntrItem, Bold );
1486 taperlItem->setText( 0, tr( "MEN_TAPER" ) );
1487 taperlItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1489 afunctor.reset( new SMESH::Controls::AspectRatio() );
1490 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1491 QTreeWidgetItem* ratlItem = createItem( cntrItem, Bold );
1492 ratlItem->setText( 0, tr( "ASPECTRATIO_ELEMENTS" ));
1493 ratlItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1495 afunctor.reset( new SMESH::Controls::MinimumAngle() );
1496 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1497 afunctor->SetPrecision( cprecision );
1498 QTreeWidgetItem* minanglItem = createItem( cntrItem, Bold );
1499 minanglItem->setText( 0, tr( "MINIMUMANGLE_ELEMENTS" ) );
1500 minanglItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1502 afunctor.reset( new SMESH::Controls::Warping() );
1503 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1504 afunctor->SetPrecision( cprecision );
1505 QTreeWidgetItem* warpItem = createItem( cntrItem, Bold );
1506 warpItem->setText( 0, tr( "STB_WARP" ));
1507 warpItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1509 afunctor.reset( new SMESH::Controls::Skew() );
1510 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1511 afunctor->SetPrecision( cprecision );
1512 QTreeWidgetItem* skewItem = createItem( cntrItem, Bold );
1513 skewItem->setText( 0, tr( "TOP_SKEW" ) );
1514 skewItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1516 afunctor.reset( new SMESH::Controls::MaxElementLength2D() );
1517 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1518 QTreeWidgetItem* diamItem = createItem( cntrItem, Bold );
1519 diamItem->setText( 0, tr( "MAX_ELEMENT_LENGTH_2D" ));
1520 diamItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1522 if( e->GetType() == SMDSAbs_Volume ) {
1524 afunctor.reset( new SMESH::Controls::AspectRatio3D() );
1525 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1526 QTreeWidgetItem* ratlItem3 = createItem( cntrItem, Bold );
1527 ratlItem3->setText( 0, tr( "ASPECTRATIO_3D_ELEMENTS" ) );
1528 ratlItem3->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1530 afunctor.reset( new SMESH::Controls::Volume() );
1531 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1532 QTreeWidgetItem* volItem = createItem( cntrItem, Bold );
1533 volItem->setText( 0, tr( "MEN_VOLUME_3D" ) );
1534 volItem->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1536 afunctor.reset( new SMESH::Controls::MaxElementLength3D() );
1537 afunctor->SetMesh( actor()->GetObject()->GetMesh() );
1538 QTreeWidgetItem* diam3Item = createItem( cntrItem, Bold );
1539 diam3Item->setText( 0, tr( "MAX_ELEMENT_LENGTH_3D" ) );
1540 diam3Item->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
1542 if( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
1544 int shapeID = e->getshapeId();
1545 if ( shapeID > 0 ) {
1546 QTreeWidgetItem* shItem = createItem( elemItem, Bold );
1548 switch ( actor()->GetObject()->GetMesh()->FindElement( shapeID )->GetType() ) {
1549 case SMDS_TOP_EDGE: shapeType = tr( "EDGE" ); break;
1550 case SMDS_TOP_FACE: shapeType = tr( "FACE" ); break;
1551 case SMDS_TOP_VERTEX: shapeType = tr( "VERTEX" ); break;
1552 default: shapeType = tr( "SOLID" );
1554 shItem->setText( 0, tr( "Position" ) );
1555 shItem->setText( 1, QString( "%1 #%2" ).arg(shapeType).arg( shapeID ) );
1564 \brief Internal clean-up (reset widget)
1566 void SMESHGUI_TreeElemInfo::clearInternal()
1573 \brief Create new tree item.
1574 \param parent parent tree widget item
1575 \param flags item flag
1576 \return new tree widget item
1578 QTreeWidgetItem* SMESHGUI_TreeElemInfo::createItem( QTreeWidgetItem* parent, int flags )
1580 QTreeWidgetItem* item;
1582 item = new QTreeWidgetItem( parent );
1584 item = new QTreeWidgetItem( myInfo );
1586 item->setFlags( item->flags() | Qt::ItemIsEditable );
1588 QFont f = item->font( 0 );
1590 for ( int i = 0; i < myInfo->columnCount(); i++ ) {
1591 if ( ( flags & Bold ) && ( i == 0 || flags & All ) )
1592 item->setFont( i, f );
1595 item->setExpanded( true );
1601 \brief Mesh information computer
1604 The class is created for different computation operation. Currently it is used
1605 to compute number of underlying nodes for the groups.
1611 GrpComputor::GrpComputor( SMESH::SMESH_GroupBase_ptr grp, QTreeWidgetItem* item, QObject* parent )
1612 : QObject( parent ), myItem( item )
1614 myGroup = SMESH::SMESH_GroupBase::_narrow( grp );
1618 \brief Compute function
1620 void GrpComputor::compute()
1622 if ( !CORBA::is_nil( myGroup ) && myItem ) {
1623 QTreeWidgetItem* item = myItem;
1625 int nbNodes = myGroup->GetNumberOfNodes();
1626 item->treeWidget()->removeItemWidget( item, 1 );
1627 item->setText( 1, QString::number( nbNodes ));
1632 \class SMESHGUI_AddInfo
1633 \brief The wigdet shows additional information on the mesh object.
1638 \param parent parent widget
1640 SMESHGUI_AddInfo::SMESHGUI_AddInfo( QWidget* parent )
1641 : QTreeWidget( parent )
1643 setColumnCount( 2 );
1644 header()->setStretchLastSection( true );
1645 header()->setResizeMode( 0, QHeaderView::ResizeToContents );
1652 SMESHGUI_AddInfo::~SMESHGUI_AddInfo()
1657 \brief Show additional information on the selected object
1658 \param obj object being processed (mesh, sub-mesh, group, ID source)
1660 void SMESHGUI_AddInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
1662 setProperty( "group_index", 0 );
1663 setProperty( "submesh_index", 0 );
1664 myComputors.clear();
1667 if ( CORBA::is_nil( obj ) ) return;
1669 _PTR(SObject) sobj = SMESH::ObjectToSObject( obj );
1670 if ( !sobj ) return;
1673 QTreeWidgetItem* nameItem = createItem( 0, Bold | All );
1674 nameItem->setText( 0, tr( "NAME" ) );
1675 nameItem->setText( 1, sobj->GetName().c_str() );
1677 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( obj );
1678 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
1679 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( obj );
1681 if ( !aMesh->_is_nil() )
1682 meshInfo( aMesh, nameItem );
1683 else if ( !aSubMesh->_is_nil() )
1684 subMeshInfo( aSubMesh, nameItem );
1685 else if ( !aGroup->_is_nil() )
1686 groupInfo( aGroup.in(), nameItem );
1690 \brief Create new tree item.
1691 \param parent parent tree widget item
1692 \param flags item flag
1693 \return new tree widget item
1695 QTreeWidgetItem* SMESHGUI_AddInfo::createItem( QTreeWidgetItem* parent, int flags )
1697 QTreeWidgetItem* item;
1700 item = new QTreeWidgetItem( parent );
1702 item = new QTreeWidgetItem( this );
1704 //item->setFlags( item->flags() | Qt::ItemIsEditable );
1706 QFont f = item->font( 0 );
1708 for ( int i = 0; i < columnCount(); i++ ) {
1709 if ( ( flags & Bold ) && ( i == 0 || flags & All ) )
1710 item->setFont( i, f );
1713 item->setExpanded( true );
1718 \brief Show mesh info
1719 \param mesh mesh object
1720 \param parent parent tree item
1722 void SMESHGUI_AddInfo::meshInfo( SMESH::SMESH_Mesh_ptr mesh, QTreeWidgetItem* parent )
1725 GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh();
1726 SALOME_MED::MedFileInfo* inf = mesh->GetMEDFileInfo();
1727 QTreeWidgetItem* typeItem = createItem( parent, Bold );
1728 typeItem->setText( 0, tr( "TYPE" ) );
1729 if ( !CORBA::is_nil( shape ) ) {
1730 typeItem->setText( 1, tr( "MESH_ON_GEOMETRY" ) );
1731 _PTR(SObject) sobj = SMESH::ObjectToSObject( shape );
1733 QTreeWidgetItem* gobjItem = createItem( typeItem );
1734 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1735 gobjItem->setText( 1, sobj->GetName().c_str() );
1738 else if ( strlen( (char*)inf->fileName ) > 0 ) {
1739 typeItem->setText( 1, tr( "MESH_FROM_FILE" ) );
1740 QTreeWidgetItem* fileItem = createItem( typeItem );
1741 fileItem->setText( 0, tr( "FILE_NAME" ) );
1742 fileItem->setText( 1, (char*)inf->fileName );
1745 typeItem->setText( 1, tr( "STANDALONE_MESH" ) );
1749 myGroups = mesh->GetGroups();
1753 mySubMeshes = mesh->GetSubMeshes();
1758 \brief Show sub-mesh info
1759 \param subMesh sub-mesh object
1760 \param parent parent tree item
1762 void SMESHGUI_AddInfo::subMeshInfo( SMESH::SMESH_subMesh_ptr subMesh, QTreeWidgetItem* parent )
1764 bool isShort = parent->parent() != 0;
1768 _PTR(SObject) sobj = SMESH::ObjectToSObject( subMesh->GetFather() );
1770 QTreeWidgetItem* nameItem = createItem( parent, Bold );
1771 nameItem->setText( 0, tr( "PARENT_MESH" ) );
1772 nameItem->setText( 1, sobj->GetName().c_str() );
1777 GEOM::GEOM_Object_var gobj = subMesh->GetSubShape();
1778 _PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
1780 QTreeWidgetItem* gobjItem = createItem( parent, Bold );
1781 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1782 gobjItem->setText( 1, sobj->GetName().c_str() );
1787 \brief Show group info
1788 \param grp mesh group object
1789 \param parent parent tree item
1791 void SMESHGUI_AddInfo::groupInfo( SMESH::SMESH_GroupBase_ptr grp, QTreeWidgetItem* parent )
1793 bool isShort = parent->parent() != 0;
1795 SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( grp );
1796 SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( grp );
1797 SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( grp );
1801 _PTR(SObject) sobj = SMESH::ObjectToSObject( grp->GetMesh() );
1803 QTreeWidgetItem* nameItem = createItem( parent, Bold );
1804 nameItem->setText( 0, tr( "PARENT_MESH" ) );
1805 nameItem->setText( 1, sobj->GetName().c_str() );
1809 // type : group on geometry, standalone group, group on filter
1810 QTreeWidgetItem* typeItem = createItem( parent, Bold );
1811 typeItem->setText( 0, tr( "TYPE" ) );
1812 if ( !CORBA::is_nil( aStdGroup ) ) {
1813 typeItem->setText( 1, tr( "STANDALONE_GROUP" ) );
1815 else if ( !CORBA::is_nil( aGeomGroup ) ) {
1816 typeItem->setText( 1, tr( "GROUP_ON_GEOMETRY" ) );
1817 GEOM::GEOM_Object_var gobj = aGeomGroup->GetShape();
1818 _PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
1820 QTreeWidgetItem* gobjItem = createItem( typeItem );
1821 gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
1822 gobjItem->setText( 1, sobj->GetName().c_str() );
1825 else if ( !CORBA::is_nil( aFltGroup ) ) {
1826 typeItem->setText( 1, tr( "GROUP_ON_FILTER" ) );
1831 QString etype = tr( "UNKNOWN" );
1832 switch( grp->GetType() ) {
1834 etype = tr( "NODE" );
1837 etype = tr( "EDGE" );
1840 etype = tr( "FACE" );
1843 etype = tr( "VOLUME" );
1846 etype = tr( "0DELEM" );
1849 etype = tr( "BALL" );
1854 QTreeWidgetItem* etypeItem = createItem( parent, Bold );
1855 etypeItem->setText( 0, tr( "ENTITY_TYPE" ) );
1856 etypeItem->setText( 1, etype );
1860 QTreeWidgetItem* sizeItem = createItem( parent, Bold );
1861 sizeItem->setText( 0, tr( "SIZE" ) );
1862 sizeItem->setText( 1, QString::number( grp->Size() ) );
1865 SALOMEDS::Color color = grp->GetColor();
1866 QTreeWidgetItem* colorItem = createItem( parent, Bold );
1867 colorItem->setText( 0, tr( "COLOR" ) );
1868 colorItem->setBackground( 1, QBrush( QColor( color.R*255., color.G*255., color.B*255.) ) );
1870 // nb of underlying nodes
1871 if ( grp->GetType() != SMESH::NODE) {
1872 QTreeWidgetItem* nodesItem = createItem( parent, Bold );
1873 nodesItem->setText( 0, tr( "NB_NODES" ) );
1874 int nbNodesLimit = SMESHGUI::resourceMgr()->integerValue( "SMESH", "info_groups_nodes_limit", 100000 );
1875 SMESH::SMESH_Mesh_var mesh = grp->GetMesh();
1876 bool meshLoaded = mesh->IsLoaded();
1877 bool toShowNodes = ( grp->IsNodeInfoAvailable() || nbNodesLimit <= 0 || grp->Size() <= nbNodesLimit );
1878 if ( toShowNodes && meshLoaded ) {
1879 // already calculated and up-to-date
1880 nodesItem->setText( 1, QString::number( grp->GetNumberOfNodes() ) );
1883 QPushButton* btn = new QPushButton( tr( meshLoaded ? "COMPUTE" : "LOAD"), this );
1884 setItemWidget( nodesItem, 1, btn );
1885 GrpComputor* comp = new GrpComputor( grp, nodesItem, this );
1886 connect( btn, SIGNAL( clicked() ), comp, SLOT( compute() ) );
1887 myComputors.append( comp );
1889 connect( btn, SIGNAL( clicked() ), this, SLOT( changeLoadToCompute() ) );
1894 void SMESHGUI_AddInfo::showGroups()
1896 myComputors.clear();
1898 QTreeWidgetItem* parent = topLevelItemCount() > 0 ? topLevelItem( 0 ) : 0; // parent should be first top level item
1899 if ( !parent ) return;
1901 int idx = property( "group_index" ).toInt();
1903 QTreeWidgetItem* itemGroups = 0;
1904 for ( int i = 0; i < parent->childCount() && !itemGroups; i++ ) {
1905 if ( parent->child( i )->data( 0, Qt::UserRole ).toInt() == GROUPS_ID ) {
1906 itemGroups = parent->child( i );
1907 ExtraWidget* extra = dynamic_cast<ExtraWidget*>( itemWidget( itemGroups, 1 ) );
1909 extra->updateControls( myGroups->length(), idx );
1910 while ( itemGroups->childCount() ) delete itemGroups->child( 0 ); // clear child items
1914 QMap<int, QTreeWidgetItem*> grpItems;
1915 for ( int i = idx*MAXITEMS ; i < qMin( (idx+1)*MAXITEMS, (int)myGroups->length() ); i++ ) {
1916 SMESH::SMESH_GroupBase_var grp = myGroups[i];
1917 if ( CORBA::is_nil( grp ) ) continue;
1918 _PTR(SObject) grpSObj = SMESH::ObjectToSObject( grp );
1919 if ( !grpSObj ) continue;
1921 int grpType = grp->GetType();
1923 if ( !itemGroups ) {
1924 // create top-level groups container item
1925 itemGroups = createItem( parent, Bold | All );
1926 itemGroups->setText( 0, tr( "GROUPS" ) );
1927 itemGroups->setData( 0, Qt::UserRole, GROUPS_ID );
1929 // total number of groups > 10, show extra widgets for info browsing
1930 if ( myGroups->length() > MAXITEMS ) {
1931 ExtraWidget* extra = new ExtraWidget( this, true );
1932 connect( extra->prev, SIGNAL( clicked() ), this, SLOT( showPreviousGroups() ) );
1933 connect( extra->next, SIGNAL( clicked() ), this, SLOT( showNextGroups() ) );
1934 setItemWidget( itemGroups, 1, extra );
1935 extra->updateControls( myGroups->length(), idx );
1939 if ( grpItems.find( grpType ) == grpItems.end() ) {
1940 grpItems[ grpType ] = createItem( itemGroups, Bold | All );
1941 grpItems[ grpType ]->setText( 0, tr( QString( "GROUPS_%1" ).arg( grpType ).toLatin1().constData() ) );
1942 itemGroups->insertChild( grpType-1, grpItems[ grpType ] );
1946 QTreeWidgetItem* grpNameItem = createItem( grpItems[ grpType ] );
1947 grpNameItem->setText( 0, QString( grpSObj->GetName().c_str() ).trimmed() ); // name is trimmed
1950 groupInfo( grp.in(), grpNameItem );
1954 void SMESHGUI_AddInfo::showSubMeshes()
1956 QTreeWidgetItem* parent = topLevelItemCount() > 0 ? topLevelItem( 0 ) : 0; // parent should be first top level item
1957 if ( !parent ) return;
1959 int idx = property( "submesh_index" ).toInt();
1961 QTreeWidgetItem* itemSubMeshes = 0;
1962 for ( int i = 0; i < parent->childCount() && !itemSubMeshes; i++ ) {
1963 if ( parent->child( i )->data( 0, Qt::UserRole ).toInt() == SUBMESHES_ID ) {
1964 itemSubMeshes = parent->child( i );
1965 ExtraWidget* extra = dynamic_cast<ExtraWidget*>( itemWidget( itemSubMeshes, 1 ) );
1967 extra->updateControls( mySubMeshes->length(), idx );
1968 while ( itemSubMeshes->childCount() ) delete itemSubMeshes->child( 0 ); // clear child items
1972 QMap<int, QTreeWidgetItem*> smItems;
1973 for ( int i = idx*MAXITEMS ; i < qMin( (idx+1)*MAXITEMS, (int)mySubMeshes->length() ); i++ ) {
1974 SMESH::SMESH_subMesh_var sm = mySubMeshes[i];
1975 if ( CORBA::is_nil( sm ) ) continue;
1976 _PTR(SObject) smSObj = SMESH::ObjectToSObject( sm );
1977 if ( !smSObj ) continue;
1979 GEOM::GEOM_Object_var gobj = sm->GetSubShape();
1980 if ( CORBA::is_nil(gobj ) ) continue;
1982 int smType = gobj->GetShapeType();
1983 if ( smType == GEOM::COMPSOLID ) smType = GEOM::COMPOUND;
1985 if ( !itemSubMeshes ) {
1986 itemSubMeshes = createItem( parent, Bold | All );
1987 itemSubMeshes->setText( 0, tr( "SUBMESHES" ) );
1988 itemSubMeshes->setData( 0, Qt::UserRole, SUBMESHES_ID );
1990 // total number of sub-meshes > 10, show extra widgets for info browsing
1991 if ( mySubMeshes->length() > MAXITEMS ) {
1992 ExtraWidget* extra = new ExtraWidget( this, true );
1993 connect( extra->prev, SIGNAL( clicked() ), this, SLOT( showPreviousSubMeshes() ) );
1994 connect( extra->next, SIGNAL( clicked() ), this, SLOT( showNextSubMeshes() ) );
1995 setItemWidget( itemSubMeshes, 1, extra );
1996 extra->updateControls( mySubMeshes->length(), idx );
2000 if ( smItems.find( smType ) == smItems.end() ) {
2001 smItems[ smType ] = createItem( itemSubMeshes, Bold | All );
2002 smItems[ smType ]->setText( 0, tr( QString( "SUBMESHES_%1" ).arg( smType ).toLatin1().constData() ) );
2003 itemSubMeshes->insertChild( smType, smItems[ smType ] );
2007 QTreeWidgetItem* smNameItem = createItem( smItems[ smType ] );
2008 smNameItem->setText( 0, QString( smSObj->GetName().c_str() ).trimmed() ); // name is trimmed
2011 subMeshInfo( sm.in(), smNameItem );
2016 * \brief Change button label of "nb underlying node" group from "Load" to "Compute"
2018 void SMESHGUI_AddInfo::changeLoadToCompute()
2020 for ( int i = 0; i < myComputors.count(); ++i )
2022 if ( QTreeWidgetItem* item = myComputors[i]->getItem() )
2024 if ( QPushButton* btn = qobject_cast<QPushButton*>( itemWidget ( item, 1 ) ) )
2025 btn->setText( tr("COMPUTE") );
2030 void SMESHGUI_AddInfo::showPreviousGroups()
2032 int idx = property( "group_index" ).toInt();
2033 setProperty( "group_index", idx-1 );
2037 void SMESHGUI_AddInfo::showNextGroups()
2039 int idx = property( "group_index" ).toInt();
2040 setProperty( "group_index", idx+1 );
2044 void SMESHGUI_AddInfo::showPreviousSubMeshes()
2046 int idx = property( "submesh_index" ).toInt();
2047 setProperty( "submesh_index", idx-1 );
2051 void SMESHGUI_AddInfo::showNextSubMeshes()
2053 int idx = property( "submesh_index" ).toInt();
2054 setProperty( "submesh_index", idx+1 );
2059 \class SMESHGUI_MeshInfoDlg
2060 \brief Mesh information dialog box
2065 \param parent parent widget
2066 \param page specifies the dialog page to be shown at the start-up
2068 SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page )
2069 : QDialog( parent ), myActor( 0 )
2072 setAttribute( Qt::WA_DeleteOnClose, true );
2073 setWindowTitle( tr( "MESH_INFO" ) );
2074 setSizeGripEnabled( true );
2076 myTabWidget = new QTabWidget( this );
2080 myBaseInfo = new SMESHGUI_MeshInfo( myTabWidget );
2081 myTabWidget->addTab( myBaseInfo, tr( "BASE_INFO" ) );
2085 QWidget* w = new QWidget( myTabWidget );
2087 myMode = new QButtonGroup( this );
2088 myMode->addButton( new QRadioButton( tr( "NODE_MODE" ), w ), NodeMode );
2089 myMode->addButton( new QRadioButton( tr( "ELEM_MODE" ), w ), ElemMode );
2090 myMode->button( NodeMode )->setChecked( true );
2091 myID = new QLineEdit( w );
2092 myID->setValidator( new SMESHGUI_IdValidator( this ) );
2094 int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 );
2095 mode = qMin( 1, qMax( 0, mode ) );
2098 myElemInfo = new SMESHGUI_SimpleElemInfo( w );
2100 myElemInfo = new SMESHGUI_TreeElemInfo( w );
2102 QGridLayout* elemLayout = new QGridLayout( w );
2103 elemLayout->setMargin( MARGIN );
2104 elemLayout->setSpacing( SPACING );
2105 elemLayout->addWidget( myMode->button( NodeMode ), 0, 0 );
2106 elemLayout->addWidget( myMode->button( ElemMode ), 0, 1 );
2107 elemLayout->addWidget( myID, 0, 2 );
2108 elemLayout->addWidget( myElemInfo, 1, 0, 1, 3 );
2110 myTabWidget->addTab( w, tr( "ELEM_INFO" ) );
2114 myAddInfo = new SMESHGUI_AddInfo( myTabWidget );
2115 myTabWidget->addTab( myAddInfo, tr( "ADDITIONAL_INFO" ) );
2119 QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this );
2120 okBtn->setAutoDefault( true );
2121 okBtn->setDefault( true );
2123 QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
2124 helpBtn->setAutoDefault( true );
2126 QHBoxLayout* btnLayout = new QHBoxLayout;
2127 btnLayout->setSpacing( SPACING );
2128 btnLayout->setMargin( 0 );
2130 btnLayout->addWidget( okBtn );
2131 btnLayout->addStretch( 10 );
2132 btnLayout->addWidget( helpBtn );
2134 QVBoxLayout* l = new QVBoxLayout ( this );
2135 l->setMargin( MARGIN );
2136 l->setSpacing( SPACING );
2137 l->addWidget( myTabWidget );
2138 l->addLayout( btnLayout );
2140 myTabWidget->setCurrentIndex( qMax( (int)BaseInfo, qMin( (int)ElemInfo, page ) ) );
2142 connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
2143 connect( helpBtn, SIGNAL( clicked() ), this, SLOT( help() ) );
2144 connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( updateSelection() ) );
2145 connect( myMode, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged() ) );
2146 connect( myID, SIGNAL( textEdited( QString ) ), this, SLOT( idChanged() ) );
2147 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() ) );
2148 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) );
2156 SMESHGUI_MeshInfoDlg::~SMESHGUI_MeshInfoDlg()
2161 \brief Show mesh information
2162 \param IO interactive object
2164 void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO )
2166 SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
2167 if ( !CORBA::is_nil( obj ) ) {
2168 myBaseInfo->showInfo( obj );
2169 myAddInfo->showInfo( obj );
2171 myActor = SMESH::FindActorByEntry( IO->getEntry() );
2172 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
2175 if ( myActor && selector ) {
2176 nb = myMode->checkedId() == NodeMode ?
2177 SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
2178 SMESH::GetNameOfSelectedNodes( selector, IO, ID );
2180 myElemInfo->setSource( myActor ) ;
2182 myID->setText( ID.trimmed() );
2184 QStringList idTxt = ID.split( " ", QString::SkipEmptyParts );
2185 foreach ( ID, idTxt )
2186 ids << ID.trimmed().toLong();
2187 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
2191 myElemInfo->clear();
2197 \brief Perform clean-up actions on the dialog box closing.
2199 void SMESHGUI_MeshInfoDlg::reject()
2201 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
2202 selMgr->clearFilters();
2203 SMESH::SetPointRepresentation( false );
2204 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2205 aViewWindow->SetSelectionMode( ActorSelection );
2210 \brief Process keyboard event
2211 \param e key press event
2213 void SMESHGUI_MeshInfoDlg::keyPressEvent( QKeyEvent* e )
2215 QDialog::keyPressEvent( e );
2216 if ( !e->isAccepted() && e->key() == Qt::Key_F1 ) {
2223 \brief Reactivate dialog box, when mouse pointer goes into it.
2225 void SMESHGUI_MeshInfoDlg::enterEvent( QEvent* )
2231 \brief Setup selection mode depending on the current dialog box state.
2233 void SMESHGUI_MeshInfoDlg::updateSelection()
2235 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
2237 disconnect( selMgr, 0, this, 0 );
2238 selMgr->clearFilters();
2240 if ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) {
2241 SMESH::SetPointRepresentation( false );
2242 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2243 aViewWindow->SetSelectionMode( ActorSelection );
2246 if ( myMode->checkedId() == NodeMode ) {
2247 SMESH::SetPointRepresentation( true );
2248 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2249 aViewWindow->SetSelectionMode( NodeSelection );
2252 SMESH::SetPointRepresentation( false );
2253 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2254 aViewWindow->SetSelectionMode( CellSelection );
2258 QString oldID = myID->text().trimmed();
2259 SMESH_Actor* oldActor = myActor;
2262 connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
2265 if ( oldActor == myActor && myActor && !oldID.isEmpty() ) {
2266 myID->setText( oldID );
2272 \brief Show help page
2274 void SMESHGUI_MeshInfoDlg::help()
2276 SMESH::ShowHelpFile( ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) ?
2277 "mesh_infos_page.html#advanced_mesh_infos_anchor" :
2278 "mesh_infos_page.html#mesh_element_info_anchor" );
2282 \brief Show mesh information
2284 void SMESHGUI_MeshInfoDlg::updateInfo()
2286 SUIT_OverrideCursor wc;
2288 SALOME_ListIO selected;
2289 SMESHGUI::selectionMgr()->selectedObjects( selected );
2291 if ( selected.Extent() == 1 ) {
2292 Handle(SALOME_InteractiveObject) IO = selected.First();
2296 // myBaseInfo->clear();
2297 // myElemInfo->clear();
2298 // myAddInfo->clear();
2303 \brief Activate dialog box
2305 void SMESHGUI_MeshInfoDlg::activate()
2307 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
2308 SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this );
2309 myTabWidget->setEnabled( true );
2314 \brief Deactivate dialog box
2316 void SMESHGUI_MeshInfoDlg::deactivate()
2318 myTabWidget->setEnabled( false );
2319 disconnect( SMESHGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
2323 \brief Called when users switches between node / element modes.
2325 void SMESHGUI_MeshInfoDlg::modeChanged()
2332 \brief Caled when users prints mesh element ID in the corresponding field.
2334 void SMESHGUI_MeshInfoDlg::idChanged()
2336 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
2337 if ( myActor && selector ) {
2338 Handle(SALOME_InteractiveObject) IO = myActor->getIO();
2339 TColStd_MapOfInteger ID;
2341 QStringList idTxt = myID->text().split( " ", QString::SkipEmptyParts );
2342 foreach ( QString tid, idTxt ) {
2343 long id = tid.trimmed().toLong();
2344 const SMDS_MeshElement* e = myMode->checkedId() == ElemMode ?
2345 myActor->GetObject()->GetMesh()->FindElement( id ) :
2346 myActor->GetObject()->GetMesh()->FindNode( id );
2352 selector->AddOrRemoveIndex( IO, ID, false );
2353 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
2354 aViewWindow->highlight( IO, true, true );
2355 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );