1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SMESHGUI_MeshInfosBox.cxx
21 // Author : Edward AGAPOV, Open CASCADE S.A.S.
24 #include "SMESHGUI_MeshInfosBox.h"
26 #include "SMDSAbs_ElementType.hxx"
31 #include <QGridLayout>
36 #define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
38 static void addSeparator( QWidget* parent )
40 QGridLayout* l = qobject_cast<QGridLayout*>( parent->layout() );
41 int row = l->rowCount();
42 int cols = l->columnCount();
43 for ( int i = 0; i < cols; i++ ) {
44 QFrame* hline = new QFrame( parent );
45 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
46 l->addWidget( hline, row, i );
51 COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
54 // =========================================================================================
56 * \brief Box showing mesh info
58 // =========================================================================================
60 SMESHGUI_MeshInfosBox::SMESHGUI_MeshInfosBox(const bool full, QWidget* theParent)
61 : QGroupBox( tr("SMESH_MESHINFO_TITLE"), theParent ), myFull( full ),
65 myNbEdge(0), myNbLinEdge(0), myNbQuadEdge(0),
66 myNbTrai(0), myNbLinTrai(0), myNbQuadTrai(0), myNbBiQuadTrai(0),
67 myNbQuad(0), myNbLinQuad(0), myNbQuadQuad(0), myNbBiQuadQuad(0),
68 myNbFace(0), myNbLinFace(0), myNbQuadFace(0), myNbBiQuadFace(0),
69 myNbPolyg(0), myNbQuadPolyg(0),
70 myNbHexa(0), myNbLinHexa(0), myNbQuadHexa(0), myNbBiQuadHexa(0),
71 myNbTetra(0),myNbLinTetra(0),myNbQuadTetra(0),
72 myNbPyra(0), myNbLinPyra(0), myNbQuadPyra(0),
73 myNbPrism(0),myNbLinPrism(0), myNbQuadPrism(0), myNbBiQuadPrism(0),
74 myNbVolum(0), myNbLinVolum(0), myNbQuadVolum(0), myNbBiQuadVolum(0),
78 QGridLayout* l = new QGridLayout(this);
79 l->setMargin( MARGIN );
80 l->setSpacing( SPACING );
82 QFont italic = font(); italic.setItalic(true);
83 QFont bold = font(); bold.setBold(true);
89 lab = new QLabel( this );
90 lab->setMinimumWidth(100); lab->setFont( italic );
91 l->addWidget( lab, row, 0 );
93 lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), this );
94 lab->setMinimumWidth(100); lab->setFont( italic );
95 l->addWidget( lab, row, 1 );
97 lab = new QLabel(tr("SMESH_MESHINFO_ORDER1"), this );
98 lab->setMinimumWidth(100); lab->setFont( italic );
99 l->addWidget( lab, row, 2 );
101 lab = new QLabel(tr("SMESH_MESHINFO_ORDER2"), this );
102 lab->setMinimumWidth(100); lab->setFont( italic );
103 l->addWidget( lab, row, 3 );
105 lab = new QLabel(tr("SMESH_MESHINFO_ORDER3"), this );
106 lab->setMinimumWidth(100); lab->setFont( italic );
107 l->addWidget( lab, row, 4 );
112 row = l->rowCount(); // retrieve current row count
114 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
115 lab->setFont( bold );
116 l->addWidget( lab, row, 0 );
118 myNbNode = new QLabel( this );
119 l->addWidget( myNbNode, row, 1 );
121 addSeparator(this); // add separator
124 row = l->rowCount(); // retrieve current row count
126 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
127 lab->setFont( bold );
128 l->addWidget( lab, row, 0 );
130 my0DElem = new QLabel( this );
131 l->addWidget( my0DElem, row, 1 );
133 addSeparator(this); // add separator
136 row = l->rowCount(); // retrieve current row count
138 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_BALLS")), this );
139 lab->setFont( bold );
140 l->addWidget( lab, row, 0 );
142 myBall = new QLabel( this );
143 l->addWidget( myBall, row, 1 );
145 addSeparator(this); // add separator
148 row = l->rowCount(); // retrieve current row count
150 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
151 lab->setFont( bold );
152 l->addWidget( lab, row, 0 );
154 myNbEdge = new QLabel( this );
155 l->addWidget( myNbEdge, row, 1 );
157 myNbLinEdge = new QLabel( this );
158 l->addWidget( myNbLinEdge, row, 2 );
160 myNbQuadEdge = new QLabel( this );
161 l->addWidget( myNbQuadEdge, row, 3 );
163 addSeparator(this); // add separator
166 row = l->rowCount(); // retrieve current row count
168 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
169 lab->setFont( bold );
170 l->addWidget( lab, row, 0 );
172 myNbFace = new QLabel( this );
173 l->addWidget( myNbFace, row, 1 );
175 myNbLinFace = new QLabel( this );
176 l->addWidget( myNbLinFace, row, 2 );
178 myNbQuadFace = new QLabel( this );
179 l->addWidget( myNbQuadFace, row, 3 );
181 myNbBiQuadFace = new QLabel( this );
182 l->addWidget( myNbBiQuadFace, row, 4 );
184 row++; // increment row count
186 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
187 l->addWidget( lab, row, 0 );
189 myNbTrai = new QLabel( this );
190 l->addWidget( myNbTrai, row, 1 );
192 myNbLinTrai = new QLabel( this );
193 l->addWidget( myNbLinTrai, row, 2 );
195 myNbQuadTrai = new QLabel( this );
196 l->addWidget( myNbQuadTrai, row, 3 );
198 myNbBiQuadTrai = new QLabel( this );
199 l->addWidget( myNbBiQuadTrai, row, 4 );
201 row++; // increment row count
203 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
204 l->addWidget( lab, row, 0 );
206 myNbQuad = new QLabel( this );
207 l->addWidget( myNbQuad, row, 1 );
209 myNbLinQuad = new QLabel( this );
210 l->addWidget( myNbLinQuad, row, 2 );
212 myNbQuadQuad = new QLabel( this );
213 l->addWidget( myNbQuadQuad, row, 3 );
215 myNbBiQuadQuad = new QLabel( this );
216 l->addWidget( myNbBiQuadQuad, row, 4 );
218 row++; // increment row count
220 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYGONES")), this );
221 l->addWidget( lab, row, 0 );
223 myNbPolyg = new QLabel( this );
224 l->addWidget( myNbPolyg, row, 1 );
226 myNbLinPolyg = new QLabel( this );
227 l->addWidget( myNbLinPolyg, row, 2 );
229 myNbQuadPolyg = new QLabel( this );
230 l->addWidget( myNbQuadPolyg, row, 3 );
232 addSeparator(this); // add separator
235 row = l->rowCount(); // retrieve current row count
237 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
238 lab->setFont( bold );
239 l->addWidget( lab, row, 0 );
241 myNbVolum = new QLabel( this );
242 l->addWidget( myNbVolum, row, 1 );
244 myNbLinVolum = new QLabel( this );
245 l->addWidget( myNbLinVolum, row, 2 );
247 myNbQuadVolum = new QLabel( this );
248 l->addWidget( myNbQuadVolum, row, 3 );
250 myNbBiQuadVolum = new QLabel( this );
251 l->addWidget( myNbBiQuadVolum, row, 4 );
253 row++; // increment row count
255 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
256 l->addWidget( lab, row, 0 );
258 myNbTetra = new QLabel( this );
259 l->addWidget( myNbTetra, row, 1 );
261 myNbLinTetra = new QLabel( this );
262 l->addWidget( myNbLinTetra, row, 2 );
264 myNbQuadTetra = new QLabel( this );
265 l->addWidget( myNbQuadTetra, row, 3 );
267 row++; // increment row count
269 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
270 l->addWidget( lab, row, 0 );
272 myNbHexa = new QLabel( this );
273 l->addWidget( myNbHexa, row, 1 );
275 myNbLinHexa = new QLabel( this );
276 l->addWidget( myNbLinHexa, row, 2 );
278 myNbQuadHexa = new QLabel( this );
279 l->addWidget( myNbQuadHexa, row, 3 );
281 myNbBiQuadHexa = new QLabel( this );
282 l->addWidget( myNbBiQuadHexa, row, 4 );
284 row++; // increment row count
286 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
287 l->addWidget( lab, row, 0 );
289 myNbPyra = new QLabel( this );
290 l->addWidget( myNbPyra, row, 1 );
292 myNbLinPyra = new QLabel( this );
293 l->addWidget( myNbLinPyra, row, 2 );
295 myNbQuadPyra = new QLabel( this );
296 l->addWidget( myNbQuadPyra, row, 3 );
298 row++; // increment row count
300 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
301 l->addWidget( lab, row, 0 );
303 myNbPrism = new QLabel( this );
304 l->addWidget( myNbPrism, row, 1 );
306 myNbLinPrism = new QLabel( this );
307 l->addWidget( myNbLinPrism, row, 2 );
309 myNbQuadPrism = new QLabel( this );
310 l->addWidget( myNbQuadPrism, row, 3 );
312 myNbBiQuadPrism = new QLabel( this );
313 l->addWidget( myNbBiQuadPrism, row, 4 );
315 row++; // increment row count
317 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAPRISM")), this );
318 l->addWidget( lab, row, 0 );
320 myNbHexaPrism = new QLabel( this );
321 l->addWidget( myNbHexaPrism, row, 1 );
323 row++; // increment row count
325 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
326 l->addWidget( lab, row, 0 );
328 myNbPolyh = new QLabel( this );
329 l->addWidget( myNbPolyh, row, 1 );
334 row = l->rowCount(); // retrieve current row count
336 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
337 l->addWidget( lab, row, 0 );
339 myNbNode = new QLabel( this );
340 l->addWidget( myNbNode, row, 1 );
343 row = l->rowCount(); // retrieve current row count
345 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
346 l->addWidget( lab, row, 0 );
348 my0DElem = new QLabel( this );
349 l->addWidget( my0DElem, row, 1 );
352 row = l->rowCount(); // retrieve current row count
354 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_BALLS")), this );
355 l->addWidget( lab, row, 0 );
357 myBall = new QLabel( this );
358 l->addWidget( myBall, row, 1 );
360 addSeparator(this); // add separator
363 row = l->rowCount(); // retrieve current row count
365 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
366 l->addWidget( lab, row, 0 );
368 myNbEdge = new QLabel( this );
369 l->addWidget( myNbEdge, row, 1 );
371 myNbLinEdge = new QLabel( this );
372 l->addWidget( myNbLinEdge, row, 2 );
374 myNbQuadEdge = new QLabel( this );
375 l->addWidget( myNbQuadEdge, row, 3 );
378 row = l->rowCount(); // retrieve current row count
380 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
381 l->addWidget( lab, row, 0 );
383 myNbFace = new QLabel( this );
384 l->addWidget( myNbFace, row, 1 );
386 myNbLinFace = new QLabel( this );
387 l->addWidget( myNbLinFace, row, 2 );
389 myNbQuadFace = new QLabel( this );
390 l->addWidget( myNbQuadFace, row, 3 );
392 myNbBiQuadFace = new QLabel( this );
393 l->addWidget( myNbBiQuadFace, row, 4 );
396 row = l->rowCount(); // retrieve current row count
398 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
399 l->addWidget( lab, row, 0 );
401 myNbVolum = new QLabel( this );
402 l->addWidget( myNbVolum, row, 1 );
404 myNbLinVolum = new QLabel( this );
405 l->addWidget( myNbLinVolum, row, 2 );
407 myNbQuadVolum = new QLabel( this );
408 l->addWidget( myNbQuadVolum, row, 3 );
410 myNbBiQuadVolum = new QLabel( this );
411 l->addWidget( myNbBiQuadVolum, row, 4 );
415 // =========================================================================================
417 * \brief Set mesh info
419 // =========================================================================================
421 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
424 myNbNode ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
427 my0DElem ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
430 myBall ->setText( QString("%1").arg( theInfo[SMDSEntity_Ball] ));
433 myNbEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] +
434 theInfo[SMDSEntity_Quad_Edge] ));
435 myNbLinEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] ));
436 myNbQuadEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Edge] ));
439 myNbFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
440 theInfo[SMDSEntity_Quad_Triangle] +
441 theInfo[SMDSEntity_BiQuad_Triangle] +
442 theInfo[SMDSEntity_Quadrangle] +
443 theInfo[SMDSEntity_Quad_Quadrangle] +
444 theInfo[SMDSEntity_BiQuad_Quadrangle] +
445 theInfo[SMDSEntity_Polygon] +
446 theInfo[SMDSEntity_Quad_Polygon]));
447 myNbLinFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
448 theInfo[SMDSEntity_Quadrangle] +
449 theInfo[SMDSEntity_Polygon] ));
450 myNbQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] +
451 theInfo[SMDSEntity_Quad_Quadrangle] +
452 theInfo[SMDSEntity_Quad_Polygon] ));
453 myNbBiQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_BiQuad_Triangle] +
454 theInfo[SMDSEntity_BiQuad_Quadrangle] ));
457 myNbVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
458 theInfo[SMDSEntity_Quad_Tetra] +
459 theInfo[SMDSEntity_Pyramid] +
460 theInfo[SMDSEntity_Quad_Pyramid] +
461 theInfo[SMDSEntity_Hexa] +
462 theInfo[SMDSEntity_Quad_Hexa] +
463 theInfo[SMDSEntity_TriQuad_Hexa] +
464 theInfo[SMDSEntity_Penta] +
465 theInfo[SMDSEntity_Quad_Penta] +
466 theInfo[SMDSEntity_BiQuad_Penta] +
467 theInfo[SMDSEntity_Hexagonal_Prism] +
468 theInfo[SMDSEntity_Polyhedra] ));
469 myNbLinVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
470 theInfo[SMDSEntity_Pyramid] +
471 theInfo[SMDSEntity_Hexa] +
472 theInfo[SMDSEntity_Penta] +
473 theInfo[SMDSEntity_Polyhedra] ));
474 myNbQuadVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] +
475 theInfo[SMDSEntity_Quad_Pyramid] +
476 theInfo[SMDSEntity_Quad_Hexa] +
477 theInfo[SMDSEntity_Quad_Penta] ));
478 myNbBiQuadVolum->setText( QString("%1").arg( theInfo[SMDSEntity_TriQuad_Hexa] +
479 theInfo[SMDSEntity_BiQuad_Penta] ));
484 myNbTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
485 theInfo[SMDSEntity_Quad_Triangle] +
486 theInfo[SMDSEntity_BiQuad_Triangle] ));
487 myNbLinTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] ));
488 myNbQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] ));
489 myNbBiQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_BiQuad_Triangle] ));
491 myNbQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] +
492 theInfo[SMDSEntity_Quad_Quadrangle] +
493 theInfo[SMDSEntity_BiQuad_Quadrangle] ));
494 myNbLinQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] ));
495 myNbQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Quadrangle] ));
496 myNbBiQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_BiQuad_Quadrangle]));
498 myNbPolyg ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] +
499 theInfo[SMDSEntity_Quad_Polygon] ));
500 myNbLinPolyg ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
501 myNbQuadPolyg ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Polygon] ));
504 myNbTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
505 theInfo[SMDSEntity_Quad_Tetra] ));
506 myNbLinTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] ));
507 myNbQuadTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] ));
509 myNbHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] +
510 theInfo[SMDSEntity_TriQuad_Hexa] +
511 theInfo[SMDSEntity_Quad_Hexa] ));
512 myNbLinHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] ));
513 myNbQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Hexa] ));
514 myNbBiQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_TriQuad_Hexa] ));
516 myNbPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] +
517 theInfo[SMDSEntity_Quad_Pyramid] ));
518 myNbLinPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] ));
519 myNbQuadPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Pyramid] ));
521 myNbPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] +
522 theInfo[SMDSEntity_Quad_Penta] +
523 theInfo[SMDSEntity_BiQuad_Penta] ));
524 myNbLinPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] ));
525 myNbQuadPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Penta] ));
526 myNbBiQuadPrism->setText( QString("%1").arg( theInfo[SMDSEntity_BiQuad_Penta] ));
528 myNbHexaPrism->setText( QString("%1").arg( theInfo[ SMDSEntity_Hexagonal_Prism ]));
530 myNbPolyh ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));