1 // Copyright (C) 2007-2013 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.
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),
67 myNbQuad(0), myNbLinQuad(0), myNbQuadQuad(0),
68 myNbFace(0), myNbLinFace(0), myNbQuadFace(0),
70 myNbHexa(0), myNbLinHexa(0), myNbQuadHexa(0),
71 myNbTetra(0),myNbLinTetra(0),myNbQuadTetra(0),
72 myNbPyra(0), myNbLinPyra(0), myNbQuadPyra(0),
73 myNbPrism(0),myNbLinPrism(0), myNbQuadPrism(0),
74 myNbVolum(0), myNbLinVolum(0), myNbQuadVolum(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 );
108 row = l->rowCount(); // retrieve current row count
110 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
111 lab->setFont( bold );
112 l->addWidget( lab, row, 0 );
114 myNbNode = new QLabel( this );
115 l->addWidget( myNbNode, row, 1 );
117 addSeparator(this); // add separator
120 row = l->rowCount(); // retrieve current row count
122 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
123 lab->setFont( bold );
124 l->addWidget( lab, row, 0 );
126 my0DElem = new QLabel( this );
127 l->addWidget( my0DElem, row, 1 );
129 addSeparator(this); // add separator
132 row = l->rowCount(); // retrieve current row count
134 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_BALLS")), this );
135 lab->setFont( bold );
136 l->addWidget( lab, row, 0 );
138 myBall = new QLabel( this );
139 l->addWidget( myBall, row, 1 );
141 addSeparator(this); // add separator
144 row = l->rowCount(); // retrieve current row count
146 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
147 lab->setFont( bold );
148 l->addWidget( lab, row, 0 );
150 myNbEdge = new QLabel( this );
151 l->addWidget( myNbEdge, row, 1 );
153 myNbLinEdge = new QLabel( this );
154 l->addWidget( myNbLinEdge, row, 2 );
156 myNbQuadEdge = new QLabel( this );
157 l->addWidget( myNbQuadEdge, row, 3 );
159 addSeparator(this); // add separator
162 row = l->rowCount(); // retrieve current row count
164 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
165 lab->setFont( bold );
166 l->addWidget( lab, row, 0 );
168 myNbFace = new QLabel( this );
169 l->addWidget( myNbFace, row, 1 );
171 myNbLinFace = new QLabel( this );
172 l->addWidget( myNbLinFace, row, 2 );
174 myNbQuadFace = new QLabel( this );
175 l->addWidget( myNbQuadFace, row, 3 );
177 row++; // increment row count
179 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
180 l->addWidget( lab, row, 0 );
182 myNbTrai = new QLabel( this );
183 l->addWidget( myNbTrai, row, 1 );
185 myNbLinTrai = new QLabel( this );
186 l->addWidget( myNbLinTrai, row, 2 );
188 myNbQuadTrai = new QLabel( this );
189 l->addWidget( myNbQuadTrai, row, 3 );
191 row++; // increment row count
193 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
194 l->addWidget( lab, row, 0 );
196 myNbQuad = new QLabel( this );
197 l->addWidget( myNbQuad, row, 1 );
199 myNbLinQuad = new QLabel( this );
200 l->addWidget( myNbLinQuad, row, 2 );
202 myNbQuadQuad = new QLabel( this );
203 l->addWidget( myNbQuadQuad, row, 3 );
205 row++; // increment row count
207 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYGONES")), this );
208 l->addWidget( lab, row, 0 );
209 myNbPolyg = new QLabel( this );
210 l->addWidget( myNbPolyg, row, 1 );
212 addSeparator(this); // add separator
215 row = l->rowCount(); // retrieve current row count
217 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
218 lab->setFont( bold );
219 l->addWidget( lab, row, 0 );
221 myNbVolum = new QLabel( this );
222 l->addWidget( myNbVolum, row, 1 );
224 myNbLinVolum = new QLabel( this );
225 l->addWidget( myNbLinVolum, row, 2 );
227 myNbQuadVolum = new QLabel( this );
228 l->addWidget( myNbQuadVolum, row, 3 );
230 row++; // increment row count
232 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
233 l->addWidget( lab, row, 0 );
235 myNbTetra = new QLabel( this );
236 l->addWidget( myNbTetra, row, 1 );
238 myNbLinTetra = new QLabel( this );
239 l->addWidget( myNbLinTetra, row, 2 );
241 myNbQuadTetra = new QLabel( this );
242 l->addWidget( myNbQuadTetra, row, 3 );
244 row++; // increment row count
246 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
247 l->addWidget( lab, row, 0 );
249 myNbHexa = new QLabel( this );
250 l->addWidget( myNbHexa, row, 1 );
252 myNbLinHexa = new QLabel( this );
253 l->addWidget( myNbLinHexa, row, 2 );
255 myNbQuadHexa = new QLabel( this );
256 l->addWidget( myNbQuadHexa, row, 3 );
258 row++; // increment row count
260 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
261 l->addWidget( lab, row, 0 );
263 myNbPyra = new QLabel( this );
264 l->addWidget( myNbPyra, row, 1 );
266 myNbLinPyra = new QLabel( this );
267 l->addWidget( myNbLinPyra, row, 2 );
269 myNbQuadPyra = new QLabel( this );
270 l->addWidget( myNbQuadPyra, row, 3 );
272 row++; // increment row count
274 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
275 l->addWidget( lab, row, 0 );
277 myNbPrism = new QLabel( this );
278 l->addWidget( myNbPrism, row, 1 );
280 myNbLinPrism = new QLabel( this );
281 l->addWidget( myNbLinPrism, row, 2 );
283 myNbQuadPrism = new QLabel( this );
284 l->addWidget( myNbQuadPrism, row, 3 );
286 row++; // increment row count
288 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAPRISM")), this );
289 l->addWidget( lab, row, 0 );
291 myNbHexaPrism = new QLabel( this );
292 l->addWidget( myNbHexaPrism, row, 1 );
294 row++; // increment row count
296 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
297 l->addWidget( lab, row, 0 );
299 myNbPolyh = new QLabel( this );
300 l->addWidget( myNbPolyh, row, 1 );
305 row = l->rowCount(); // retrieve current row count
307 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
308 l->addWidget( lab, row, 0 );
310 myNbNode = new QLabel( this );
311 l->addWidget( myNbNode, row, 1 );
314 row = l->rowCount(); // retrieve current row count
316 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
317 l->addWidget( lab, row, 0 );
319 my0DElem = new QLabel( this );
320 l->addWidget( my0DElem, row, 1 );
323 row = l->rowCount(); // retrieve current row count
325 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_BALLS")), this );
326 l->addWidget( lab, row, 0 );
328 myBall = new QLabel( this );
329 l->addWidget( myBall, row, 1 );
331 addSeparator(this); // add separator
334 row = l->rowCount(); // retrieve current row count
336 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
337 l->addWidget( lab, row, 0 );
339 myNbEdge = new QLabel( this );
340 l->addWidget( myNbEdge, row, 1 );
342 myNbLinEdge = new QLabel( this );
343 l->addWidget( myNbLinEdge, row, 2 );
345 myNbQuadEdge = new QLabel( this );
346 l->addWidget( myNbQuadEdge, row, 3 );
349 row = l->rowCount(); // retrieve current row count
351 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
352 l->addWidget( lab, row, 0 );
354 myNbFace = new QLabel( this );
355 l->addWidget( myNbFace, row, 1 );
357 myNbLinFace = new QLabel( this );
358 l->addWidget( myNbLinFace, row, 2 );
360 myNbQuadFace = new QLabel( this );
361 l->addWidget( myNbQuadFace, row, 3 );
364 row = l->rowCount(); // retrieve current row count
366 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
367 l->addWidget( lab, row, 0 );
369 myNbVolum = new QLabel( this );
370 l->addWidget( myNbVolum, row, 1 );
372 myNbLinVolum = new QLabel( this );
373 l->addWidget( myNbLinVolum, row, 2 );
375 myNbQuadVolum = new QLabel( this );
376 l->addWidget( myNbQuadVolum, row, 3 );
380 // =========================================================================================
382 * \brief Set mesh info
384 // =========================================================================================
386 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
389 myNbNode ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
392 my0DElem ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
395 myBall ->setText( QString("%1").arg( theInfo[SMDSEntity_Ball] ));
398 myNbEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] +
399 theInfo[SMDSEntity_Quad_Edge] ));
400 myNbLinEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] ));
401 myNbQuadEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Edge] ));
404 myNbFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
405 theInfo[SMDSEntity_Quad_Triangle] +
406 theInfo[SMDSEntity_Quadrangle] +
407 theInfo[SMDSEntity_Quad_Quadrangle] +
408 theInfo[SMDSEntity_BiQuad_Quadrangle] +
409 theInfo[SMDSEntity_Polygon] ));
410 myNbLinFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
411 theInfo[SMDSEntity_Quadrangle] +
412 theInfo[SMDSEntity_Polygon] ));
413 myNbQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] +
414 theInfo[SMDSEntity_Quad_Quadrangle] +
415 theInfo[SMDSEntity_BiQuad_Quadrangle] ));
418 myNbVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
419 theInfo[SMDSEntity_Quad_Tetra] +
420 theInfo[SMDSEntity_Pyramid] +
421 theInfo[SMDSEntity_Quad_Pyramid] +
422 theInfo[SMDSEntity_Hexa] +
423 theInfo[SMDSEntity_Quad_Hexa] +
424 theInfo[SMDSEntity_TriQuad_Hexa] +
425 theInfo[SMDSEntity_Penta] +
426 theInfo[SMDSEntity_Quad_Penta] +
427 theInfo[SMDSEntity_Hexagonal_Prism] +
428 theInfo[SMDSEntity_Polyhedra] ));
429 myNbLinVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
430 theInfo[SMDSEntity_Pyramid] +
431 theInfo[SMDSEntity_Hexa] +
432 theInfo[SMDSEntity_Penta] +
433 theInfo[SMDSEntity_Polyhedra] ));
434 myNbQuadVolum->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] +
435 theInfo[SMDSEntity_Quad_Pyramid] +
436 theInfo[SMDSEntity_Quad_Hexa] +
437 theInfo[SMDSEntity_TriQuad_Hexa] +
438 theInfo[SMDSEntity_Quad_Penta] ));
443 myNbTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
444 theInfo[SMDSEntity_Quad_Triangle] ));
445 myNbLinTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] ));
446 myNbQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] ));
448 myNbQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] +
449 theInfo[SMDSEntity_Quad_Quadrangle] +
450 theInfo[SMDSEntity_BiQuad_Quadrangle] ));
451 myNbLinQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] ));
452 myNbQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Quadrangle] +
453 theInfo[SMDSEntity_BiQuad_Quadrangle]));
455 myNbPolyg ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
458 myNbTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
459 theInfo[SMDSEntity_Quad_Tetra] ));
460 myNbLinTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] ));
461 myNbQuadTetra->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] ));
463 myNbHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] +
464 theInfo[SMDSEntity_TriQuad_Hexa],
465 theInfo[SMDSEntity_Quad_Hexa] ));
466 myNbLinHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] ));
467 myNbQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Hexa] +
468 theInfo[SMDSEntity_TriQuad_Hexa] ));
470 myNbPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] +
471 theInfo[SMDSEntity_Quad_Pyramid] ));
472 myNbLinPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] ));
473 myNbQuadPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Pyramid] ));
475 myNbPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] +
476 theInfo[SMDSEntity_Quad_Penta] ));
477 myNbLinPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] ));
478 myNbQuadPrism->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Penta] ));
480 myNbHexaPrism->setText( QString("%1").arg( theInfo[ SMDSEntity_Hexagonal_Prism ]));
482 myNbPolyh ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));