1 // Copyright (C) 2007-2010 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"
35 #include <LightApp_SelectionMgr.h>
36 #include <SUIT_OverrideCursor.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SVTK_ViewWindow.h>
40 #include <SALOMEDSClient_Study.hxx>
42 #include <QApplication>
43 #include <QButtonGroup>
44 #include <QGridLayout>
45 #include <QHBoxLayout>
46 #include <QHeaderView>
47 #include <QItemDelegate>
51 #include <QPushButton>
52 #include <QRadioButton>
54 #include <QTextBrowser>
55 #include <QTreeWidget>
56 #include <QVBoxLayout>
58 #include "utilities.h"
60 #include <SALOMEconfig.h>
61 #include CORBA_SERVER_HEADER(SMESH_Group)
63 const int SPACING = 6;
65 const int MAXITEMS = 10;
68 \class SMESHGUI_MeshInfo
69 \brief Base mesh information widget
71 Displays the base information about mesh object: mesh, sub-mesh, group or arbitrary ID source.
76 \param parent parent widget
78 SMESHGUI_MeshInfo::SMESHGUI_MeshInfo( QWidget* parent )
79 : QFrame( parent ), myWidgets( iElementsEnd )
81 setFrameStyle( StyledPanel | Sunken );
83 QGridLayout* l = new QGridLayout( this );
84 l->setMargin( MARGIN );
85 l->setSpacing( SPACING );
88 QLabel* aNameLab = new QLabel( tr( "NAME_LAB" ), this );
89 QLabel* aName = createField();
90 aName->setMinimumWidth( 150 );
91 QLabel* aObjLab = new QLabel( tr( "OBJECT_LAB" ), this );
92 QLabel* aObj = createField();
93 aObj->setMinimumWidth( 150 );
94 myWidgets[0] << aNameLab << aName;
95 myWidgets[1] << aObjLab << aObj;
98 QWidget* aNodesLine = createLine();
99 QLabel* aNodesLab = new QLabel( tr( "NODES_LAB" ), this );
100 QLabel* aNodes = createField();
101 myWidgets[2] << aNodesLine;
102 myWidgets[3] << aNodesLab << aNodes;
105 QWidget* aElemLine = createLine();
106 QLabel* aElemLab = new QLabel( tr( "ELEMENTS_LAB" ), this );
107 QLabel* aElemTotal = new QLabel( tr( "TOTAL_LAB" ), this );
108 QLabel* aElemLin = new QLabel( tr( "LINEAR_LAB" ), this );
109 QLabel* aElemQuad = new QLabel( tr( "QUADRATIC_LAB" ), this );
110 myWidgets[4] << aElemLine;
111 myWidgets[5] << aElemLab << aElemTotal << aElemLin << aElemQuad;
114 QWidget* a0DLine = createLine();
115 QLabel* a0DLab = new QLabel( tr( "0D_LAB" ), this );
116 QLabel* a0DTotal = createField();
117 myWidgets[6] << a0DLine;
118 myWidgets[7] << a0DLab << a0DTotal;
121 QWidget* a1DLine = createLine();
122 QLabel* a1DLab = new QLabel( tr( "1D_LAB" ), this );
123 QLabel* a1DTotal = createField();
124 QLabel* a1DLin = createField();
125 QLabel* a1DQuad = createField();
126 myWidgets[8] << a1DLine;
127 myWidgets[9] << a1DLab << a1DTotal << a1DLin << a1DQuad;
130 QWidget* a2DLine = createLine();
131 QLabel* a2DLab = new QLabel( tr( "2D_LAB" ), this );
132 QLabel* a2DTotal = createField();
133 QLabel* a2DLin = createField();
134 QLabel* a2DQuad = createField();
135 QLabel* a2DTriLab = new QLabel( tr( "TRIANGLES_LAB" ), this );
136 QLabel* a2DTriTotal = createField();
137 QLabel* a2DTriLin = createField();
138 QLabel* a2DTriQuad = createField();
139 QLabel* a2DQuaLab = new QLabel( tr( "QUADRANGLES_LAB" ), this );
140 QLabel* a2DQuaTotal = createField();
141 QLabel* a2DQuaLin = createField();
142 QLabel* a2DQuaQuad = createField();
143 QLabel* a2DPolLab = new QLabel( tr( "POLYGONS_LAB" ), this );
144 QLabel* a2DPolTotal = createField();
145 myWidgets[10] << a2DLine;
146 myWidgets[11] << a2DLab << a2DTotal << a2DLin << a2DQuad;
147 myWidgets[12] << a2DTriLab << a2DTriTotal << a2DTriLin << a2DTriQuad;
148 myWidgets[13] << a2DQuaLab << a2DQuaTotal << a2DQuaLin << a2DQuaQuad;
149 myWidgets[14] << a2DPolLab << a2DPolTotal;
152 QWidget* a3DLine = createLine();
153 QLabel* a3DLab = new QLabel( tr( "3D_LAB" ), this );
154 QLabel* a3DTotal = createField();
155 QLabel* a3DLin = createField();
156 QLabel* a3DQuad = createField();
157 QLabel* a3DTetLab = new QLabel( tr( "TETRAHEDRONS_LAB" ), this );
158 QLabel* a3DTetTotal = createField();
159 QLabel* a3DTetLin = createField();
160 QLabel* a3DTetQuad = createField();
161 QLabel* a3DHexLab = new QLabel( tr( "HEXAHEDONRS_LAB" ), this );
162 QLabel* a3DHexTotal = createField();
163 QLabel* a3DHexLin = createField();
164 QLabel* a3DHexQuad = createField();
165 QLabel* a3DPyrLab = new QLabel( tr( "PYRAMIDS_LAB" ), this );
166 QLabel* a3DPyrTotal = createField();
167 QLabel* a3DPyrLin = createField();
168 QLabel* a3DPyrQuad = createField();
169 QLabel* a3DPriLab = new QLabel( tr( "PRISMS_LAB" ), this );
170 QLabel* a3DPriTotal = createField();
171 QLabel* a3DPriLin = createField();
172 QLabel* a3DPriQuad = createField();
173 QLabel* a3DPolLab = new QLabel( tr( "POLYHEDRONS_LAB" ), this );
174 QLabel* a3DPolTotal = createField();
175 myWidgets[15] << a3DLine;
176 myWidgets[16] << a3DLab << a3DTotal << a3DLin << a3DQuad;
177 myWidgets[17] << a3DTetLab << a3DTetTotal << a3DTetLin << a3DTetQuad;
178 myWidgets[18] << a3DHexLab << a3DHexTotal << a3DHexLin << a3DHexQuad;
179 myWidgets[19] << a3DPyrLab << a3DPyrTotal << a3DPyrLin << a3DPyrQuad;
180 myWidgets[20] << a3DPriLab << a3DPriTotal << a3DPriLin << a3DPriQuad;
181 myWidgets[21] << a3DPolLab << a3DPolTotal;
183 setFontAttributes( aNameLab, Bold );
184 setFontAttributes( aObjLab, Bold );
185 setFontAttributes( aNodesLab, Bold );
186 setFontAttributes( aElemLab, Bold );
187 setFontAttributes( aElemTotal, Italic );
188 setFontAttributes( aElemLin, Italic );
189 setFontAttributes( aElemQuad, Italic );
190 setFontAttributes( a0DLab, Bold );
191 setFontAttributes( a1DLab, Bold );
192 setFontAttributes( a2DLab, Bold );
193 setFontAttributes( a3DLab, Bold );
195 l->addWidget( aNameLab, 0, 0 );
196 l->addWidget( aName, 0, 1, 1, 3 );
197 l->addWidget( aObjLab, 1, 0 );
198 l->addWidget( aObj, 1, 1, 1, 3 );
199 l->addWidget( aNodesLine, 2, 0, 1, 4 );
200 l->addWidget( aNodesLab, 3, 0 );
201 l->addWidget( aNodes, 3, 1 );
202 l->addWidget( aElemLine, 4, 0, 1, 4 );
203 l->addWidget( aElemLab, 5, 0 );
204 l->addWidget( aElemTotal, 5, 1 );
205 l->addWidget( aElemLin, 5, 2 );
206 l->addWidget( aElemQuad, 5, 3 );
207 l->addWidget( a0DLine, 6, 1, 1, 3 );
208 l->addWidget( a0DLab, 7, 0 );
209 l->addWidget( a0DTotal, 7, 1 );
210 l->addWidget( a1DLine, 8, 1, 1, 3 );
211 l->addWidget( a1DLab, 9, 0 );
212 l->addWidget( a1DTotal, 9, 1 );
213 l->addWidget( a1DLin, 9, 2 );
214 l->addWidget( a1DQuad, 9, 3 );
215 l->addWidget( a2DLine, 10, 1, 1, 3 );
216 l->addWidget( a2DLab, 11, 0 );
217 l->addWidget( a2DTotal, 11, 1 );
218 l->addWidget( a2DLin, 11, 2 );
219 l->addWidget( a2DQuad, 11, 3 );
220 l->addWidget( a2DTriLab, 12, 0 );
221 l->addWidget( a2DTriTotal, 12, 1 );
222 l->addWidget( a2DTriLin, 12, 2 );
223 l->addWidget( a2DTriQuad, 12, 3 );
224 l->addWidget( a2DQuaLab, 13, 0 );
225 l->addWidget( a2DQuaTotal, 13, 1 );
226 l->addWidget( a2DQuaLin, 13, 2 );
227 l->addWidget( a2DQuaQuad, 13, 3 );
228 l->addWidget( a2DPolLab, 14, 0 );
229 l->addWidget( a2DPolTotal, 14, 1 );
230 l->addWidget( a3DLine, 15, 1, 1, 3 );
231 l->addWidget( a3DLab, 16, 0 );
232 l->addWidget( a3DTotal, 16, 1 );
233 l->addWidget( a3DLin, 16, 2 );
234 l->addWidget( a3DQuad, 16, 3 );
235 l->addWidget( a3DTetLab, 17, 0 );
236 l->addWidget( a3DTetTotal, 17, 1 );
237 l->addWidget( a3DTetLin, 17, 2 );
238 l->addWidget( a3DTetQuad, 17, 3 );
239 l->addWidget( a3DHexLab, 18, 0 );
240 l->addWidget( a3DHexTotal, 18, 1 );
241 l->addWidget( a3DHexLin, 18, 2 );
242 l->addWidget( a3DHexQuad, 18, 3 );
243 l->addWidget( a3DPyrLab, 19, 0 );
244 l->addWidget( a3DPyrTotal, 19, 1 );
245 l->addWidget( a3DPyrLin, 19, 2 );
246 l->addWidget( a3DPyrQuad, 19, 3 );
247 l->addWidget( a3DPriLab, 20, 0 );
248 l->addWidget( a3DPriTotal, 20, 1 );
249 l->addWidget( a3DPriLin, 20, 2 );
250 l->addWidget( a3DPriQuad, 20, 3 );
251 l->addWidget( a3DPolLab, 21, 0 );
252 l->addWidget( a3DPolTotal, 21, 1 );
253 l->setColumnStretch( 0, 0 );
254 l->setColumnStretch( 1, 5 );
255 l->setColumnStretch( 2, 5 );
256 l->setColumnStretch( 3, 5 );
257 l->setRowStretch( 22, 5 );
265 SMESHGUI_MeshInfo::~SMESHGUI_MeshInfo()
270 \brief Show information on the mesh object.
271 \param obj object being processed (mesh, sub-mesh, group, ID source)
273 void SMESHGUI_MeshInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
276 if ( !CORBA::is_nil( obj ) ) {
277 _PTR(SObject) sobj = ObjectToSObject( obj );
279 myWidgets[iName][iSingle]->setProperty( "text", sobj->GetName().c_str() );
280 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( obj );
281 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
282 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( obj );
283 if ( !aMesh->_is_nil() ) {
284 myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_MESH" ) );
286 else if ( !aSubMesh->_is_nil() ) {
287 myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_SUBMESH" ) );
289 else if ( !aGroup->_is_nil() ) {
291 switch( aGroup->GetType() ) {
293 objType = tr( "OBJECT_GROUP_NODES" );
296 objType = tr( "OBJECT_GROUP_EDGES" );
299 objType = tr( "OBJECT_GROUP_FACES" );
302 objType = tr( "OBJECT_GROUP_VOLUMES" );
305 objType = tr( "OBJECT_GROUP_0DELEMS" );
308 objType = tr( "OBJECT_GROUP" );
311 myWidgets[iObject][iSingle]->setProperty( "text", objType );
313 SMESH::long_array_var info = obj->GetMeshInfo();
314 myWidgets[iNodes][iTotal]->setProperty( "text", QString::number( info[SMDSEntity_Node] ) );
315 myWidgets[i0D][iTotal]->setProperty( "text", QString::number( info[SMDSEntity_0D] ) );
316 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
317 myWidgets[i1D][iTotal]->setProperty( "text", QString::number( nbEdges ) );
318 myWidgets[i1D][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Edge] ) );
319 myWidgets[i1D][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Edge] ) );
320 long nbTriangles = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle];
321 long nbQuadrangles = info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle];
322 long nb2DLinear = info[SMDSEntity_Triangle] + info[SMDSEntity_Quadrangle] + info[SMDSEntity_Polygon];
323 long nb2DQuadratic = info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_Quad_Quadrangle];
324 myWidgets[i2D][iTotal]->setProperty( "text", QString::number( nb2DLinear + nb2DQuadratic ) );
325 myWidgets[i2D][iLinear]->setProperty( "text", QString::number( nb2DLinear ) );
326 myWidgets[i2D][iQuadratic]->setProperty( "text", QString::number( nb2DQuadratic ) );
327 myWidgets[i2DTriangles][iTotal]->setProperty( "text", QString::number( nbTriangles ) );
328 myWidgets[i2DTriangles][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Triangle] ) );
329 myWidgets[i2DTriangles][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Triangle] ) );
330 myWidgets[i2DQuadrangles][iTotal]->setProperty( "text", QString::number( nbQuadrangles ) );
331 myWidgets[i2DQuadrangles][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Quadrangle] ) );
332 myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Quadrangle] ) );
333 myWidgets[i2DPolygons][iTotal]->setProperty( "text", QString::number( info[SMDSEntity_Polygon] ) );
334 long nbTetrahedrons = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra];
335 long nbHexahedrons = info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa];
336 long nbPyramids = info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid];
337 long nbPrisms = info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta];
338 long nb3DLinear = info[SMDSEntity_Tetra] + info[SMDSEntity_Hexa] + info[SMDSEntity_Pyramid] + info[SMDSEntity_Penta] + info[SMDSEntity_Polyhedra];
339 long nb3DQuadratic = info[SMDSEntity_Quad_Tetra] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_Quad_Pyramid] + info[SMDSEntity_Quad_Penta];
340 myWidgets[i3D][iTotal]->setProperty( "text", QString::number( nb3DLinear + nb3DQuadratic ) );
341 myWidgets[i3D][iLinear]->setProperty( "text", QString::number( nb3DLinear ) );
342 myWidgets[i3D][iQuadratic]->setProperty( "text", QString::number( nb3DQuadratic ) );
343 myWidgets[i3DTetrahedrons][iTotal]->setProperty( "text", QString::number( nbTetrahedrons ) );
344 myWidgets[i3DTetrahedrons][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Tetra] ) );
345 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Tetra] ) );
346 myWidgets[i3DHexahedrons][iTotal]->setProperty( "text", QString::number( nbHexahedrons ) );
347 myWidgets[i3DHexahedrons][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Hexa] ) );
348 myWidgets[i3DHexahedrons][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Hexa] ) );
349 myWidgets[i3DPyramids][iTotal]->setProperty( "text", QString::number( nbPyramids ) );
350 myWidgets[i3DPyramids][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Pyramid] ) );
351 myWidgets[i3DPyramids][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Pyramid] ) );
352 myWidgets[i3DPrisms][iTotal]->setProperty( "text", QString::number( nbPrisms ) );
353 myWidgets[i3DPrisms][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Penta] ) );
354 myWidgets[i3DPrisms][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Penta] ) );
355 myWidgets[i3DPolyhedrons][iTotal]->setProperty( "text", QString::number( info[SMDSEntity_Polyhedra] ) );
360 \brief Reset the widget to the initial state (nullify all fields).
362 void SMESHGUI_MeshInfo::clear()
364 myWidgets[iName][iSingle]->setProperty( "text", QString() );
365 myWidgets[iObject][iSingle]->setProperty( "text", QString() );
366 myWidgets[iNodes][iTotal]->setProperty( "text", QString::number( 0 ) );
367 myWidgets[i0D][iTotal]->setProperty( "text", QString::number( 0 ) );
368 myWidgets[i1D][iTotal]->setProperty( "text", QString::number( 0 ) );
369 myWidgets[i1D][iLinear]->setProperty( "text", QString::number( 0 ) );
370 myWidgets[i1D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
371 myWidgets[i2D][iTotal]->setProperty( "text", QString::number( 0 ) );
372 myWidgets[i2D][iLinear]->setProperty( "text", QString::number( 0 ) );
373 myWidgets[i2D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
374 myWidgets[i2DTriangles][iTotal]->setProperty( "text", QString::number( 0 ) );
375 myWidgets[i2DTriangles][iLinear]->setProperty( "text", QString::number( 0 ) );
376 myWidgets[i2DTriangles][iQuadratic]->setProperty( "text", QString::number( 0 ) );
377 myWidgets[i2DQuadrangles][iTotal]->setProperty( "text", QString::number( 0 ) );
378 myWidgets[i2DQuadrangles][iLinear]->setProperty( "text", QString::number( 0 ) );
379 myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", QString::number( 0 ) );
380 myWidgets[i2DPolygons][iTotal]->setProperty( "text", QString::number( 0 ) );
381 myWidgets[i3D][iTotal]->setProperty( "text", QString::number( 0 ) );
382 myWidgets[i3D][iLinear]->setProperty( "text", QString::number( 0 ) );
383 myWidgets[i3D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
384 myWidgets[i3DTetrahedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
385 myWidgets[i3DTetrahedrons][iLinear]->setProperty( "text", QString::number( 0 ) );
386 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( 0 ) );
387 myWidgets[i3DHexahedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
388 myWidgets[i3DHexahedrons][iLinear]->setProperty( "text", QString::number( 0 ) );
389 myWidgets[i3DHexahedrons][iQuadratic]->setProperty( "text", QString::number( 0 ) );
390 myWidgets[i3DPyramids][iTotal]->setProperty( "text", QString::number( 0 ) );
391 myWidgets[i3DPyramids][iLinear]->setProperty( "text", QString::number( 0 ) );
392 myWidgets[i3DPyramids][iQuadratic]->setProperty( "text", QString::number( 0 ) );
393 myWidgets[i3DPrisms][iTotal]->setProperty( "text", QString::number( 0 ) );
394 myWidgets[i3DPrisms][iLinear]->setProperty( "text", QString::number( 0 ) );
395 myWidgets[i3DPrisms][iQuadratic]->setProperty( "text", QString::number( 0 ) );
396 myWidgets[i3DPolyhedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
400 \brief Create info field
401 \return new info field
403 QLabel* SMESHGUI_MeshInfo::createField()
405 QLabel* lab = new QLabel( this );
406 lab->setFrameStyle( StyledPanel | Sunken );
407 lab->setAlignment( Qt::AlignCenter );
408 lab->setAutoFillBackground( true );
409 QPalette pal = lab->palette();
410 pal.setColor( QPalette::Window, QApplication::palette().color( QPalette::Active, QPalette::Base ) );
411 lab->setPalette( pal );
412 lab->setMinimumWidth( 70 );
417 \brief Create horizontal rule.
418 \return new line object
420 QWidget* SMESHGUI_MeshInfo::createLine()
422 QFrame* line = new QFrame( this );
423 line->setFrameStyle( HLine | Sunken );
428 \brief Change widget font attributes (bold, italic, ...).
430 \param attr font attributes (XORed flags)
431 \param val value to be set to attributes
433 void SMESHGUI_MeshInfo::setFontAttributes( QWidget* w, int attr, bool val )
437 if ( attr & Bold ) f.setBold( val );
438 if ( attr & Italic ) f.setItalic( val );
444 \brief Show/hide group(s) of fields.
445 \param start beginning of the block
446 \param end end of the block
447 \param on visibility flag
449 void SMESHGUI_MeshInfo::setFieldsVisible( int start, int end, bool on )
451 start = qMax( 0, start );
452 end = qMin( end, (int)iElementsEnd );
453 for ( int i = start; i < end; i++ ) {
454 wlist wl = myWidgets[i];
455 foreach ( QWidget* w, wl ) w->setVisible( on );
460 \class SMESHGUI_ElemInfo
461 \brief Base class for the mesh element information widget.
466 \param parent parent widget
468 SMESHGUI_ElemInfo::SMESHGUI_ElemInfo( QWidget* parent )
469 : QWidget( parent ), myActor( 0 ), myIsElement( -1 )
471 myFrame = new QWidget( this );
472 myExtra = new QWidget( this );
473 myCurrent = new QLabel( "10/43 items shown", myExtra );
474 myCurrent->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
475 myPrev = new QPushButton( tr( "<<" ), myExtra );
476 myNext = new QPushButton( tr( ">>" ), myExtra );
477 QHBoxLayout* hbl = new QHBoxLayout( myExtra );
478 hbl->setContentsMargins( 0, SPACING, 0, 0 );
479 hbl->setSpacing( SPACING );
481 hbl->addWidget( myCurrent );
482 hbl->addWidget( myPrev );
483 hbl->addWidget( myNext );
484 QVBoxLayout* vbl = new QVBoxLayout( this );
486 vbl->setSpacing( 0 );
487 vbl->addWidget( myFrame );
488 vbl->addWidget( myExtra );
489 connect( myPrev, SIGNAL( clicked() ), this, SLOT( showPrevious() ) );
490 connect( myNext, SIGNAL( clicked() ), this, SLOT( showNext() ) );
497 SMESHGUI_ElemInfo::~SMESHGUI_ElemInfo()
502 \brief Set mesh data source (actor)
503 \param actor mesh object actor
505 void SMESHGUI_ElemInfo::setSource( SMESH_Actor* actor )
507 if ( myActor != actor ) {
515 \brief Show mesh element information
516 \param id mesh node / element ID
517 \param isElem show mesh element information if \c true or mesh node information if \c false
519 void SMESHGUI_ElemInfo::showInfo( long id, bool isElem )
523 showInfo( ids, isElem );
527 \brief Show mesh element information
528 \param ids mesh nodes / elements identifiers
529 \param isElem show mesh element information if \c true or mesh node information if \c false
531 void SMESHGUI_ElemInfo::showInfo( QSet<long> ids, bool isElem )
533 QList<long> newIds = ids.toList();
535 if ( myIDs == newIds && myIsElement == isElem ) return;
538 myIsElement = isElem;
541 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
545 \brief Clear mesh element information widget
547 void SMESHGUI_ElemInfo::clear()
556 \brief Get central area widget
557 \return central widget
559 QWidget* SMESHGUI_ElemInfo::frame() const
566 \return actor being used
568 SMESH_Actor* SMESHGUI_ElemInfo::actor() const
574 \brief Get current info mode.
575 \return \c true if mesh element information is shown or \c false if node information is shown
577 bool SMESHGUI_ElemInfo::isElements() const
583 \fn void SMESHGUI_ElemInfo::information( const QList<long>& ids )
584 \brief Show information on the specified nodes / elements
586 This function is to be redefined in sub-classes.
588 \param ids nodes / elements identifiers information is to be shown on
592 \brief Internal clean-up (reset widget)
594 void SMESHGUI_ElemInfo::clearInternal()
599 \brief Get node connectivity
600 \param node mesh node
601 \return node connectivity map
603 SMESHGUI_ElemInfo::Connectivity SMESHGUI_ElemInfo::nodeConnectivity( const SMDS_MeshNode* node )
607 SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
608 while ( it && it->more() ) {
609 const SMDS_MeshElement* ne = it->next();
610 elmap[ ne->GetType() ] << ne->GetID();
617 \brief Format connectivity data to string representation
618 \param connectivity connetivity map
619 \param type element type
620 \return string representation of the connectivity
622 QString SMESHGUI_ElemInfo::formatConnectivity( Connectivity connectivity, int type )
625 if ( connectivity.contains( type ) ) {
626 QList<int> elements = connectivity[ type ];
628 foreach( int id, elements )
629 str << QString::number( id );
631 return str.join( " " );
635 \brief Calculate gravity center of the mesh element
636 \param element mesh element
638 SMESHGUI_ElemInfo::XYZ SMESHGUI_ElemInfo::gravityCenter( const SMDS_MeshElement* element )
642 SMDS_ElemIteratorPtr nodeIt = element->nodesIterator();
643 while ( nodeIt->more() ) {
644 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
645 xyz.add( node->X(), node->Y(), node->Z() );
647 xyz.divide( element->NbNodes() );
653 \brief This slot is called from "Show Previous" button click.
654 Shows information on the previous group of the items.
656 void SMESHGUI_ElemInfo::showPrevious()
658 myIndex = qMax( 0, myIndex-1 );
660 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
664 \brief This slot is called from "Show Next" button click.
665 Shows information on the next group of the items.
667 void SMESHGUI_ElemInfo::showNext()
669 myIndex = qMin( myIndex+1, myIDs.count() / MAXITEMS );
671 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
675 \brief Update widgets state
677 void SMESHGUI_ElemInfo::updateControls()
679 myExtra->setVisible( myIDs.count() > MAXITEMS );
680 myCurrent->setText( tr( "X_FROM_Y_ITEMS_SHOWN" ).arg( myIndex*MAXITEMS+1 ).arg(qMin(myIndex*MAXITEMS+MAXITEMS, myIDs.count())).arg( myIDs.count() ) );
681 myPrev->setEnabled( myIndex > 0 );
682 myNext->setEnabled( (myIndex+1)*MAXITEMS < myIDs.count() );
686 \class SMESHGUI_SimpleElemInfo
687 \brief Represents mesh element information in the simple text area.
692 \param parent parent widget
694 SMESHGUI_SimpleElemInfo::SMESHGUI_SimpleElemInfo( QWidget* parent )
695 : SMESHGUI_ElemInfo( parent )
697 myInfo = new QTextBrowser( frame() );
698 QVBoxLayout* l = new QVBoxLayout( frame() );
700 l->addWidget( myInfo );
704 \brief Show mesh element information
705 \param ids mesh nodes / elements identifiers
707 void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
712 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
713 foreach ( long id, ids ) {
714 if ( !isElements() ) {
718 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
720 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
723 myInfo->append( QString( "<b>%1 #%2</b>" ).arg( tr( "NODE" ) ).arg( id ) );
725 myInfo->append( "" );
727 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
728 arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
729 arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
730 arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
732 myInfo->append( "" );
734 Connectivity connectivity = nodeConnectivity( node );
735 if ( !connectivity.isEmpty() ) {
736 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
737 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
738 if ( !con.isEmpty() )
739 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
740 con = formatConnectivity( connectivity, SMDSAbs_Edge );
741 if ( !con.isEmpty() )
742 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
743 con = formatConnectivity( connectivity, SMDSAbs_Face );
744 if ( !con.isEmpty() )
745 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
746 con = formatConnectivity( connectivity, SMDSAbs_Volume );
747 if ( !con.isEmpty() )
748 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
751 myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
758 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
761 // element ID && type
763 switch( e->GetType() ) {
764 case SMDSAbs_0DElement:
765 stype = tr( "0D ELEMENT" ); break;
767 stype = tr( "EDGE" ); break;
769 stype = tr( "FACE" ); break;
771 stype = tr( "VOLUME" ); break;
775 if ( stype.isEmpty() ) return;
776 myInfo->append( QString( "<b>%1 #%2</b>" ).arg( stype ).arg( id ) );
778 myInfo->append( "" );
781 switch( e->GetEntityType() ) {
782 case SMDSEntity_Triangle:
783 case SMDSEntity_Quad_Triangle:
784 gtype = tr( "TRIANGLE" ); break;
785 case SMDSEntity_Quadrangle:
786 case SMDSEntity_Quad_Quadrangle:
787 gtype = tr( "QUADRANGLE" ); break;
788 case SMDSEntity_Polygon:
789 case SMDSEntity_Quad_Polygon:
790 gtype = tr( "POLYGON" ); break;
791 case SMDSEntity_Tetra:
792 case SMDSEntity_Quad_Tetra:
793 gtype = tr( "TETRAHEDRON" ); break;
794 case SMDSEntity_Pyramid:
795 case SMDSEntity_Quad_Pyramid:
796 gtype = tr( "PYRAMID" ); break;
797 case SMDSEntity_Hexa:
798 case SMDSEntity_Quad_Hexa:
799 gtype = tr( "HEXAHEDRON" ); break;
800 case SMDSEntity_Penta:
801 case SMDSEntity_Quad_Penta:
802 gtype = tr( "PRISM" ); break;
803 case SMDSEntity_Polyhedra:
804 case SMDSEntity_Quad_Polyhedra:
805 gtype = tr( "POLYHEDRON" ); break;
809 if ( !gtype.isEmpty() )
810 myInfo->append( QString( "<b>%1:</b> %2" ).arg( tr( "TYPE" ) ).arg( gtype ) );
811 // quadratic flag and gravity center (any element except 0D)
812 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Last ) {
814 myInfo->append( QString( "<b>%1?</b> %2" ).arg( tr( "QUADRATIC" ) ).arg( e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) ) );
816 myInfo->append( "" );
818 XYZ gc = gravityCenter( e );
819 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "GRAVITY_CENTER" ) ).arg( gc.x() ).arg( gc.y() ).arg( gc.z() ) );
822 myInfo->append( "" );
824 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
825 for ( int idx = 1; nodeIt->more(); idx++ ) {
826 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
827 // node number and ID
828 myInfo->append( QString( "<b>%1 %2/%3</b> - #%4" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ).arg( node->GetID() ) );
830 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
831 arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
832 arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
833 arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
835 Connectivity connectivity = nodeConnectivity( node );
836 if ( !connectivity.isEmpty() ) {
837 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
838 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
839 if ( !con.isEmpty() )
840 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
841 con = formatConnectivity( connectivity, SMDSAbs_Edge );
842 if ( !con.isEmpty() )
843 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
844 con = formatConnectivity( connectivity, SMDSAbs_Face );
845 if ( !con.isEmpty() )
846 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
847 con = formatConnectivity( connectivity, SMDSAbs_Volume );
848 if ( !con.isEmpty() )
849 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
852 myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
857 if ( ids.count() > 1 ) {
858 myInfo->append( "" );
859 myInfo->append( "------" );
860 myInfo->append( "" );
867 \brief Internal clean-up (reset widget)
869 void SMESHGUI_SimpleElemInfo::clearInternal()
875 \class SMESHGUI_TreeElemInfo::ItemDelegate
876 \brief Item delegate for tree mesh info widget
879 class SMESHGUI_TreeElemInfo::ItemDelegate : public QItemDelegate
882 ItemDelegate( QObject* );
883 QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
890 SMESHGUI_TreeElemInfo::ItemDelegate::ItemDelegate( QObject* parent ) : QItemDelegate( parent )
895 \brief Create item editor widget
898 QWidget* SMESHGUI_TreeElemInfo::ItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
900 QWidget* w = index.column() == 0 ? 0: QItemDelegate::createEditor( parent, option, index );
901 if ( qobject_cast<QLineEdit*>( w ) ) qobject_cast<QLineEdit*>( w )->setReadOnly( true );
906 \class SMESHGUI_TreeElemInfo
907 \brief Represents mesh element information in the tree-like form.
912 \param parent parent widget
914 SMESHGUI_TreeElemInfo::SMESHGUI_TreeElemInfo( QWidget* parent )
915 : SMESHGUI_ElemInfo( parent )
917 myInfo = new QTreeWidget( frame() );
918 myInfo->setColumnCount( 2 );
919 myInfo->setHeaderLabels( QStringList() << tr( "PROPERTY" ) << tr( "VALUE" ) );
920 myInfo->header()->setStretchLastSection( true );
921 myInfo->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
922 myInfo->setItemDelegate( new ItemDelegate( myInfo ) );
923 QVBoxLayout* l = new QVBoxLayout( frame() );
925 l->addWidget( myInfo );
929 \brief Show mesh element information
930 \param ids mesh nodes / elements identifiers
932 void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
937 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
938 foreach ( long id, ids ) {
939 if ( !isElements() ) {
943 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
945 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
948 QTreeWidgetItem* nodeItem = createItem( 0, -1 );
949 nodeItem->setText( 0, tr( "NODE" ) );
950 nodeItem->setText( 1, QString( "#%1" ).arg( id ) );
951 nodeItem->setExpanded( true );
953 QTreeWidgetItem* coordItem = createItem( nodeItem, 0 );
954 coordItem->setText( 0, tr( "COORDINATES" ) );
955 coordItem->setExpanded( true );
956 QTreeWidgetItem* xItem = createItem( coordItem );
957 xItem->setText( 0, "X" );
958 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
959 QTreeWidgetItem* yItem = createItem( coordItem );
960 yItem->setText( 0, "Y" );
961 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
962 QTreeWidgetItem* zItem = createItem( coordItem );
963 zItem->setText( 0, "Z" );
964 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
966 QTreeWidgetItem* conItem = createItem( nodeItem, 0 );
967 conItem->setText( 0, tr( "CONNECTIVITY" ) );
968 conItem->setExpanded( true );
969 Connectivity connectivity = nodeConnectivity( node );
970 if ( !connectivity.isEmpty() ) {
971 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
972 if ( !con.isEmpty() ) {
973 QTreeWidgetItem* i = createItem( conItem );
974 i->setText( 0, tr( "0D_ELEMENTS" ) );
975 i->setText( 1, con );
977 con = formatConnectivity( connectivity, SMDSAbs_Edge );
978 if ( !con.isEmpty() ) {
979 QTreeWidgetItem* i = createItem( conItem );
980 i->setText( 0, tr( "EDGES" ) );
981 i->setText( 1, con );
983 con = formatConnectivity( connectivity, SMDSAbs_Face );
984 if ( !con.isEmpty() ) {
985 QTreeWidgetItem* i = createItem( conItem );
986 i->setText( 0, tr( "FACES" ) );
987 i->setText( 1, con );
989 con = formatConnectivity( connectivity, SMDSAbs_Volume );
990 if ( !con.isEmpty() ) {
991 QTreeWidgetItem* i = createItem( conItem );
992 i->setText( 0, tr( "VOLUMES" ) );
993 i->setText( 1, con );
997 conItem->setText( 1, tr( "FREE_NODE" ) );
1002 // show element info
1004 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
1007 // element ID && type
1009 switch( e->GetType() ) {
1010 case SMDSAbs_0DElement:
1011 stype = tr( "0D ELEMENT" ); break;
1013 stype = tr( "EDGE" ); break;
1015 stype = tr( "FACE" ); break;
1016 case SMDSAbs_Volume:
1017 stype = tr( "VOLUME" ); break;
1021 if ( stype.isEmpty() ) return;
1022 QTreeWidgetItem* elemItem = createItem( 0, -1 );
1023 elemItem->setText( 0, stype );
1024 elemItem->setText( 1, QString( "#%1" ).arg( id ) );
1025 elemItem->setExpanded( true );
1028 switch( e->GetEntityType() ) {
1029 case SMDSEntity_Triangle:
1030 case SMDSEntity_Quad_Triangle:
1031 gtype = tr( "TRIANGLE" ); break;
1032 case SMDSEntity_Quadrangle:
1033 case SMDSEntity_Quad_Quadrangle:
1034 gtype = tr( "QUADRANGLE" ); break;
1035 case SMDSEntity_Polygon:
1036 case SMDSEntity_Quad_Polygon:
1037 gtype = tr( "POLYGON" ); break;
1038 case SMDSEntity_Tetra:
1039 case SMDSEntity_Quad_Tetra:
1040 gtype = tr( "TETRAHEDRON" ); break;
1041 case SMDSEntity_Pyramid:
1042 case SMDSEntity_Quad_Pyramid:
1043 gtype = tr( "PYRAMID" ); break;
1044 case SMDSEntity_Hexa:
1045 case SMDSEntity_Quad_Hexa:
1046 gtype = tr( "HEXAHEDRON" ); break;
1047 case SMDSEntity_Penta:
1048 case SMDSEntity_Quad_Penta:
1049 gtype = tr( "PRISM" ); break;
1050 case SMDSEntity_Polyhedra:
1051 case SMDSEntity_Quad_Polyhedra:
1052 gtype = tr( "POLYHEDRON" ); break;
1056 if ( !gtype.isEmpty() ) {
1057 QTreeWidgetItem* typeItem = createItem( elemItem, 0 );
1058 typeItem->setText( 0, tr( "TYPE" ) );
1059 typeItem->setText( 1, gtype );
1061 // quadratic flag and gravity center (any element except 0D)
1062 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Last ) {
1064 QTreeWidgetItem* quadItem = createItem( elemItem, 0 );
1065 quadItem->setText( 0, tr( "QUADRATIC" ) );
1066 quadItem->setText( 1, e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) );
1068 XYZ gc = gravityCenter( e );
1069 QTreeWidgetItem* gcItem = createItem( elemItem, 0 );
1070 gcItem->setText( 0, tr( "GRAVITY_CENTER" ) );
1071 gcItem->setExpanded( true );
1072 QTreeWidgetItem* xItem = createItem( gcItem );
1073 xItem->setText( 0, "X" );
1074 xItem->setText( 1, QString::number( gc.x(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1075 QTreeWidgetItem* yItem = createItem( gcItem );
1076 yItem->setText( 0, "Y" );
1077 yItem->setText( 1, QString::number( gc.y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1078 QTreeWidgetItem* zItem = createItem( gcItem );
1079 zItem->setText( 0, "Z" );
1080 zItem->setText( 1, QString::number( gc.z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1083 QTreeWidgetItem* conItem = createItem( elemItem, 0 );
1084 conItem->setText( 0, tr( "CONNECTIVITY" ) );
1085 conItem->setExpanded( true );
1086 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
1087 for ( int idx = 1; nodeIt->more(); idx++ ) {
1088 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
1089 // node number and ID
1090 QTreeWidgetItem* nodeItem = createItem( conItem, 0 );
1091 nodeItem->setText( 0, QString( "%1 %2/%3" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ) );
1092 nodeItem->setText( 1, QString( "#%1" ).arg( node->GetID() ) );
1093 //nodeItem->setExpanded( true );
1095 QTreeWidgetItem* coordItem = createItem( nodeItem );
1096 coordItem->setText( 0, tr( "COORDINATES" ) );
1097 coordItem->setExpanded( true );
1098 QTreeWidgetItem* xItem = createItem( coordItem );
1099 xItem->setText( 0, "X" );
1100 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1101 QTreeWidgetItem* yItem = createItem( coordItem );
1102 yItem->setText( 0, "Y" );
1103 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1104 QTreeWidgetItem* zItem = createItem( coordItem );
1105 zItem->setText( 0, "Z" );
1106 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
1107 // node connectivity
1108 QTreeWidgetItem* nconItem = createItem( nodeItem );
1109 nconItem->setText( 0, tr( "CONNECTIVITY" ) );
1110 nconItem->setExpanded( true );
1111 Connectivity connectivity = nodeConnectivity( node );
1112 if ( !connectivity.isEmpty() ) {
1113 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
1114 if ( !con.isEmpty() ) {
1115 QTreeWidgetItem* i = createItem( nconItem );
1116 i->setText( 0, tr( "0D_ELEMENTS" ) );
1117 i->setText( 1, con );
1119 con = formatConnectivity( connectivity, SMDSAbs_Edge );
1120 if ( !con.isEmpty() ) {
1121 QTreeWidgetItem* i = createItem( nconItem );
1122 i->setText( 0, tr( "EDGES" ) );
1123 i->setText( 1, con );
1125 con = formatConnectivity( connectivity, SMDSAbs_Face );
1126 if ( !con.isEmpty() ) {
1127 QTreeWidgetItem* i = createItem( nconItem );
1128 i->setText( 0, tr( "FACES" ) );
1129 i->setText( 1, con );
1131 con = formatConnectivity( connectivity, SMDSAbs_Volume );
1132 if ( !con.isEmpty() ) {
1133 QTreeWidgetItem* i = createItem( nconItem );
1134 i->setText( 0, tr( "VOLUMES" ) );
1135 i->setText( 1, con );
1145 \brief Internal clean-up (reset widget)
1147 void SMESHGUI_TreeElemInfo::clearInternal()
1154 \brief Create new tree item.
1155 \param parnt parent tree widget item
1156 \param column item column to be set bold, if it is -1, bold font will be set for all columns
1157 \return new tree widget item
1159 QTreeWidgetItem* SMESHGUI_TreeElemInfo::createItem( QTreeWidgetItem* parent, int column )
1161 QTreeWidgetItem* item;
1163 item = new QTreeWidgetItem( parent );
1165 item = new QTreeWidgetItem( myInfo );
1167 item->setFlags( item->flags() | Qt::ItemIsEditable );
1169 QFont f = item->font( 0 );
1171 if ( column >= 0 && column < myInfo->columnCount() ) {
1172 item->setFont( column, f );
1174 else if ( column == -1 ) {
1175 for ( int i = 0; i < myInfo->columnCount(); i++ )
1176 item->setFont( i, f );
1182 \class SMESHGUI_MeshInfoDlg
1183 \brief Mesh information dialog box
1188 \param parent parent widget
1189 \param page specifies the dialog page to be shown at the start-up
1191 SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page )
1192 : QDialog( parent ), myActor( 0 )
1195 setAttribute( Qt::WA_DeleteOnClose, true );
1196 setWindowTitle( tr( "MESH_INFO" ) );
1197 setSizeGripEnabled( true );
1199 myTabWidget = new QTabWidget( this );
1203 myBaseInfo = new SMESHGUI_MeshInfo( myTabWidget );
1204 myTabWidget->addTab( myBaseInfo, tr( "BASE_INFO" ) );
1208 QWidget* w = new QWidget( myTabWidget );
1210 myMode = new QButtonGroup( this );
1211 myMode->addButton( new QRadioButton( tr( "NODE_MODE" ), w ), NodeMode );
1212 myMode->addButton( new QRadioButton( tr( "ELEM_MODE" ), w ), ElemMode );
1213 myMode->button( NodeMode )->setChecked( true );
1214 myID = new QLineEdit( w );
1215 myID->setValidator( new SMESHGUI_IdValidator( this ) );
1217 int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 );
1218 mode = qMin( 1, qMax( 0, mode ) );
1221 myElemInfo = new SMESHGUI_SimpleElemInfo( w );
1223 myElemInfo = new SMESHGUI_TreeElemInfo( w );
1225 QGridLayout* elemLayout = new QGridLayout( w );
1226 elemLayout->setMargin( MARGIN );
1227 elemLayout->setSpacing( SPACING );
1228 elemLayout->addWidget( myMode->button( NodeMode ), 0, 0 );
1229 elemLayout->addWidget( myMode->button( ElemMode ), 0, 1 );
1230 elemLayout->addWidget( myID, 0, 2 );
1231 elemLayout->addWidget( myElemInfo, 1, 0, 1, 3 );
1233 myTabWidget->addTab( w, tr( "ELEM_INFO" ) );
1235 QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this );
1236 okBtn->setAutoDefault( true );
1237 okBtn->setDefault( true );
1239 QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
1240 helpBtn->setAutoDefault( true );
1242 QHBoxLayout* btnLayout = new QHBoxLayout;
1243 btnLayout->setSpacing( SPACING );
1244 btnLayout->setMargin( 0 );
1246 btnLayout->addWidget( okBtn );
1247 btnLayout->addStretch( 10 );
1248 btnLayout->addWidget( helpBtn );
1250 QVBoxLayout* l = new QVBoxLayout ( this );
1251 l->setMargin( MARGIN );
1252 l->setSpacing( SPACING );
1253 l->addWidget( myTabWidget );
1255 l->addLayout( btnLayout );
1257 myTabWidget->setCurrentIndex( qMax( (int)BaseInfo, qMin( (int)ElemInfo, page ) ) );
1259 connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
1260 connect( helpBtn, SIGNAL( clicked() ), this, SLOT( help() ) );
1261 connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( updateSelection() ) );
1262 connect( myMode, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged() ) );
1263 connect( myID, SIGNAL( textEdited( QString ) ), this, SLOT( idChanged() ) );
1264 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() ) );
1265 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) );
1273 SMESHGUI_MeshInfoDlg::~SMESHGUI_MeshInfoDlg()
1278 \brief Show mesh information
1279 \param IO interactive object
1281 void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO )
1283 SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
1284 if ( !CORBA::is_nil( obj ) ) {
1285 myBaseInfo->showInfo( obj );
1287 myActor = SMESH::FindActorByEntry( IO->getEntry() );
1288 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
1291 if ( myActor && selector ) {
1292 nb = myMode->checkedId() == NodeMode ?
1293 SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
1294 SMESH::GetNameOfSelectedNodes( selector, IO, ID );
1296 myElemInfo->setSource( myActor ) ;
1298 myID->setText( ID.trimmed() );
1300 QStringList idTxt = ID.split( " ", QString::SkipEmptyParts );
1301 foreach ( ID, idTxt )
1302 ids << ID.trimmed().toLong();
1303 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
1307 myElemInfo->clear();
1313 \brief Perform clean-up actions on the dialog box closing.
1315 void SMESHGUI_MeshInfoDlg::reject()
1317 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
1318 selMgr->clearFilters();
1319 SMESH::SetPointRepresentation( false );
1320 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
1321 aViewWindow->SetSelectionMode( ActorSelection );
1326 \brief Process keyboard event
1327 \param e key press event
1329 void SMESHGUI_MeshInfoDlg::keyPressEvent( QKeyEvent* e )
1331 QDialog::keyPressEvent( e );
1332 if ( !e->isAccepted() && e->key() == Qt::Key_F1 ) {
1339 \brief Reactivate dialog box, when mouse pointer goes into it.
1341 void SMESHGUI_MeshInfoDlg::enterEvent( QEvent* )
1347 \brief Setup selection mode depending on the current dialog box state.
1349 void SMESHGUI_MeshInfoDlg::updateSelection()
1351 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
1353 disconnect( selMgr, 0, this, 0 );
1354 selMgr->clearFilters();
1356 if ( myTabWidget->currentIndex() == BaseInfo ) {
1357 SMESH::SetPointRepresentation( false );
1358 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
1359 aViewWindow->SetSelectionMode( ActorSelection );
1362 if ( myMode->checkedId() == NodeMode ) {
1363 SMESH::SetPointRepresentation( true );
1364 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
1365 aViewWindow->SetSelectionMode( NodeSelection );
1368 SMESH::SetPointRepresentation( false );
1369 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
1370 aViewWindow->SetSelectionMode( CellSelection );
1374 QString oldID = myID->text().trimmed();
1375 SMESH_Actor* oldActor = myActor;
1378 connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
1381 if ( oldActor == myActor && myActor && !oldID.isEmpty() ) {
1382 myID->setText( oldID );
1388 \brief Show help page
1390 void SMESHGUI_MeshInfoDlg::help()
1392 SMESH::ShowHelpFile( myTabWidget->currentIndex() == BaseInfo ?
1393 "mesh_infos_page.html#advanced_mesh_infos_anchor" :
1394 "mesh_infos_page.html#mesh_element_info_anchor" );
1398 \brief Show mesh information
1400 void SMESHGUI_MeshInfoDlg::updateInfo()
1402 SUIT_OverrideCursor wc;
1404 SALOME_ListIO selected;
1405 SMESHGUI::selectionMgr()->selectedObjects( selected );
1407 if ( selected.Extent() == 1 ) {
1408 Handle(SALOME_InteractiveObject) IO = selected.First();
1412 // myBaseInfo->clear();
1413 // myElemInfo->clear();
1418 \brief Activate dialog box
1420 void SMESHGUI_MeshInfoDlg::activate()
1422 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
1423 SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this );
1424 myTabWidget->setEnabled( true );
1429 \brief Deactivate dialog box
1431 void SMESHGUI_MeshInfoDlg::deactivate()
1433 myTabWidget->setEnabled( false );
1434 disconnect( SMESHGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
1438 \brief Called when users switches between node / element modes.
1440 void SMESHGUI_MeshInfoDlg::modeChanged()
1447 \brief Caled when users prints mesh element ID in the corresponding field.
1449 void SMESHGUI_MeshInfoDlg::idChanged()
1451 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
1452 if ( myActor && selector ) {
1453 Handle(SALOME_InteractiveObject) IO = myActor->getIO();
1454 TColStd_MapOfInteger ID;
1456 QStringList idTxt = myID->text().split( " ", QString::SkipEmptyParts );
1457 foreach ( QString tid, idTxt ) {
1458 long id = tid.trimmed().toLong();
1459 const SMDS_MeshElement* e = myMode->checkedId() == ElemMode ?
1460 myActor->GetObject()->GetMesh()->FindElement( id ) :
1461 myActor->GetObject()->GetMesh()->FindNode( id );
1467 selector->AddOrRemoveIndex( IO, ID, false );
1468 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
1469 aViewWindow->highlight( IO, true, true );
1470 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );