1 // Copyright (C) 2007-2012 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 );
322 addSeparator(this); // add separator
325 row = l->rowCount(); // retrieve current row count
327 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
328 l->addWidget( lab, row, 0 );
330 myNbEdge = new QLabel( this );
331 l->addWidget( myNbEdge, row, 1 );
333 myNbLinEdge = new QLabel( this );
334 l->addWidget( myNbLinEdge, row, 2 );
336 myNbQuadEdge = new QLabel( this );
337 l->addWidget( myNbQuadEdge, row, 3 );
340 row = l->rowCount(); // retrieve current row count
342 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
343 l->addWidget( lab, row, 0 );
345 myNbFace = new QLabel( this );
346 l->addWidget( myNbFace, row, 1 );
348 myNbLinFace = new QLabel( this );
349 l->addWidget( myNbLinFace, row, 2 );
351 myNbQuadFace = new QLabel( this );
352 l->addWidget( myNbQuadFace, row, 3 );
355 row = l->rowCount(); // retrieve current row count
357 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
358 l->addWidget( lab, row, 0 );
360 myNbVolum = new QLabel( this );
361 l->addWidget( myNbVolum, row, 1 );
363 myNbLinVolum = new QLabel( this );
364 l->addWidget( myNbLinVolum, row, 2 );
366 myNbQuadVolum = new QLabel( this );
367 l->addWidget( myNbQuadVolum, row, 3 );
371 // =========================================================================================
373 * \brief Set mesh info
375 // =========================================================================================
377 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
380 myNbNode ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
383 my0DElem ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
386 myBall ->setText( QString("%1").arg( theInfo[SMDSEntity_Ball] ));
389 myNbEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] +
390 theInfo[SMDSEntity_Quad_Edge] ));
391 myNbLinEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] ));
392 myNbQuadEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Edge] ));
395 myNbFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
396 theInfo[SMDSEntity_Quad_Triangle] +
397 theInfo[SMDSEntity_Quadrangle] +
398 theInfo[SMDSEntity_Quad_Quadrangle] +
399 theInfo[SMDSEntity_BiQuad_Quadrangle] +
400 theInfo[SMDSEntity_Polygon] ));
401 myNbLinFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
402 theInfo[SMDSEntity_Quadrangle] +
403 theInfo[SMDSEntity_Polygon] ));
404 myNbQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] +
405 theInfo[SMDSEntity_Quad_Quadrangle] +
406 theInfo[SMDSEntity_BiQuad_Quadrangle] ));
409 myNbVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
410 theInfo[SMDSEntity_Quad_Tetra] +
411 theInfo[SMDSEntity_Pyramid] +
412 theInfo[SMDSEntity_Quad_Pyramid] +
413 theInfo[SMDSEntity_Hexa] +
414 theInfo[SMDSEntity_Quad_Hexa] +
415 theInfo[SMDSEntity_TriQuad_Hexa] +
416 theInfo[SMDSEntity_Penta] +
417 theInfo[SMDSEntity_Quad_Penta] +
418 theInfo[SMDSEntity_Hexagonal_Prism] +
419 theInfo[SMDSEntity_Polyhedra] ));
420 myNbLinVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
421 theInfo[SMDSEntity_Pyramid] +
422 theInfo[SMDSEntity_Hexa] +
423 theInfo[SMDSEntity_Penta] +
424 theInfo[SMDSEntity_Polyhedra] ));
425 myNbQuadVolum->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] +
426 theInfo[SMDSEntity_Quad_Pyramid] +
427 theInfo[SMDSEntity_Quad_Hexa] +
428 theInfo[SMDSEntity_TriQuad_Hexa] +
429 theInfo[SMDSEntity_Quad_Penta] ));
434 myNbTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
435 theInfo[SMDSEntity_Quad_Triangle] ));
436 myNbLinTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] ));
437 myNbQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] ));
439 myNbQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] +
440 theInfo[SMDSEntity_Quad_Quadrangle],
441 theInfo[SMDSEntity_BiQuad_Quadrangle] ));
442 myNbLinQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] ));
443 myNbQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Quadrangle] +
444 theInfo[SMDSEntity_BiQuad_Quadrangle]));
446 myNbPolyg ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
449 myNbTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
450 theInfo[SMDSEntity_Quad_Tetra] ));
451 myNbLinTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] ));
452 myNbQuadTetra->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] ));
454 myNbHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] +
455 theInfo[SMDSEntity_TriQuad_Hexa],
456 theInfo[SMDSEntity_Quad_Hexa] ));
457 myNbLinHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] ));
458 myNbQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Hexa] +
459 theInfo[SMDSEntity_TriQuad_Hexa] ));
461 myNbPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] +
462 theInfo[SMDSEntity_Quad_Pyramid] ));
463 myNbLinPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] ));
464 myNbQuadPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Pyramid] ));
466 myNbPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] +
467 theInfo[SMDSEntity_Quad_Penta] ));
468 myNbLinPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] ));
469 myNbQuadPrism->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Penta] ));
471 myNbHexaPrism->setText( QString("%1").arg( theInfo[ SMDSEntity_Hexagonal_Prism ]));
473 myNbPolyh ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));