1 // Copyright (C) 2007-2008 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_MeshInfosBox.cxx
23 // Author : Edward AGAPOV, Open CASCADE S.A.S.
26 #include "SMESHGUI_MeshInfosBox.h"
28 #include "SMDSAbs_ElementType.hxx"
33 #include <QGridLayout>
38 #define COLONIZE(str) (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
40 static void addSeparator( QWidget* parent )
42 QGridLayout* l = qobject_cast<QGridLayout*>( parent->layout() );
43 int row = l->rowCount();
44 int cols = l->columnCount();
45 for ( int i = 0; i < cols; i++ ) {
46 QFrame* hline = new QFrame( parent );
47 hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
48 l->addWidget( hline, row, i );
53 COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
56 // =========================================================================================
58 * \brief Box showing mesh info
60 // =========================================================================================
62 SMESHGUI_MeshInfosBox::SMESHGUI_MeshInfosBox(const bool full, QWidget* theParent)
63 : QGroupBox( tr("SMESH_MESHINFO_TITLE"), theParent ), myFull( full ),
64 myNbNode(0), my0DElem(0), myNbEdge(0), myNbLinEdge(0), myNbQuadEdge(0),
65 myNbTrai(0), myNbLinTrai(0), myNbQuadTrai(0), myNbQuad(0), myNbLinQuad(0),
66 myNbQuadQuad(0), myNbFace(0), myNbLinFace(0), myNbQuadFace(0), myNbPolyg(0),
67 myNbHexa(0), myNbLinHexa(0), myNbQuadHexa(0), myNbTetra(0), myNbLinTetra(0),
68 myNbQuadTetra(0), myNbPyra(0), myNbLinPyra(0), myNbQuadPyra(0), myNbPrism(0),
69 myNbLinPrism(0), myNbQuadPrism(0), myNbVolum(0), myNbLinVolum(0), myNbQuadVolum(0),
72 QGridLayout* l = new QGridLayout(this);
73 l->setMargin( MARGIN );
74 l->setSpacing( SPACING );
76 QFont italic = font(); italic.setItalic(true);
77 QFont bold = font(); bold.setBold(true);
83 lab = new QLabel( this );
84 lab->setMinimumWidth(100); lab->setFont( italic );
85 l->addWidget( lab, row, 0 );
87 lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), this );
88 lab->setMinimumWidth(100); lab->setFont( italic );
89 l->addWidget( lab, row, 1 );
91 lab = new QLabel(tr("SMESH_MESHINFO_ORDER1"), this );
92 lab->setMinimumWidth(100); lab->setFont( italic );
93 l->addWidget( lab, row, 2 );
95 lab = new QLabel(tr("SMESH_MESHINFO_ORDER2"), this );
96 lab->setMinimumWidth(100); lab->setFont( italic );
97 l->addWidget( lab, row, 3 );
102 row = l->rowCount(); // retrieve current row count
104 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
105 lab->setFont( bold );
106 l->addWidget( lab, row, 0 );
108 myNbNode = new QLabel( this );
109 l->addWidget( myNbNode, row, 1 );
111 addSeparator(this); // add separator
114 row = l->rowCount(); // retrieve current row count
116 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
117 lab->setFont( bold );
118 l->addWidget( lab, row, 0 );
120 my0DElem = new QLabel( this );
121 l->addWidget( my0DElem, row, 1 );
123 addSeparator(this); // add separator
126 row = l->rowCount(); // retrieve current row count
128 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
129 lab->setFont( bold );
130 l->addWidget( lab, row, 0 );
132 myNbEdge = new QLabel( this );
133 l->addWidget( myNbEdge, row, 1 );
135 myNbLinEdge = new QLabel( this );
136 l->addWidget( myNbLinEdge, row, 2 );
138 myNbQuadEdge = new QLabel( this );
139 l->addWidget( myNbQuadEdge, row, 3 );
141 addSeparator(this); // add separator
144 row = l->rowCount(); // retrieve current row count
146 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
147 lab->setFont( bold );
148 l->addWidget( lab, row, 0 );
150 myNbFace = new QLabel( this );
151 l->addWidget( myNbFace, row, 1 );
153 myNbLinFace = new QLabel( this );
154 l->addWidget( myNbLinFace, row, 2 );
156 myNbQuadFace = new QLabel( this );
157 l->addWidget( myNbQuadFace, row, 3 );
159 row++; // increment row count
161 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
162 l->addWidget( lab, row, 0 );
164 myNbTrai = new QLabel( this );
165 l->addWidget( myNbTrai, row, 1 );
167 myNbLinTrai = new QLabel( this );
168 l->addWidget( myNbLinTrai, row, 2 );
170 myNbQuadTrai = new QLabel( this );
171 l->addWidget( myNbQuadTrai, row, 3 );
173 row++; // increment row count
175 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
176 l->addWidget( lab, row, 0 );
178 myNbQuad = new QLabel( this );
179 l->addWidget( myNbQuad, row, 1 );
181 myNbLinQuad = new QLabel( this );
182 l->addWidget( myNbLinQuad, row, 2 );
184 myNbQuadQuad = new QLabel( this );
185 l->addWidget( myNbQuadQuad, row, 3 );
187 row++; // increment row count
189 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYGONES")), this );
190 l->addWidget( lab, row, 0 );
191 myNbPolyg = new QLabel( this );
192 l->addWidget( myNbPolyg, row, 1 );
194 addSeparator(this); // add separator
197 row = l->rowCount(); // retrieve current row count
199 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
200 lab->setFont( bold );
201 l->addWidget( lab, row, 0 );
203 myNbVolum = new QLabel( this );
204 l->addWidget( myNbVolum, row, 1 );
206 myNbLinVolum = new QLabel( this );
207 l->addWidget( myNbLinVolum, row, 2 );
209 myNbQuadVolum = new QLabel( this );
210 l->addWidget( myNbQuadVolum, row, 3 );
212 row++; // increment row count
214 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
215 l->addWidget( lab, row, 0 );
217 myNbTetra = new QLabel( this );
218 l->addWidget( myNbTetra, row, 1 );
220 myNbLinTetra = new QLabel( this );
221 l->addWidget( myNbLinTetra, row, 2 );
223 myNbQuadTetra = new QLabel( this );
224 l->addWidget( myNbQuadTetra, row, 3 );
226 row++; // increment row count
228 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
229 l->addWidget( lab, row, 0 );
231 myNbHexa = new QLabel( this );
232 l->addWidget( myNbHexa, row, 1 );
234 myNbLinHexa = new QLabel( this );
235 l->addWidget( myNbLinHexa, row, 2 );
237 myNbQuadHexa = new QLabel( this );
238 l->addWidget( myNbQuadHexa, row, 3 );
240 row++; // increment row count
242 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
243 l->addWidget( lab, row, 0 );
245 myNbPyra = new QLabel( this );
246 l->addWidget( myNbPyra, row, 1 );
248 myNbLinPyra = new QLabel( this );
249 l->addWidget( myNbLinPyra, row, 2 );
251 myNbQuadPyra = new QLabel( this );
252 l->addWidget( myNbQuadPyra, row, 3 );
254 row++; // increment row count
256 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
257 l->addWidget( lab, row, 0 );
259 myNbPrism = new QLabel( this );
260 l->addWidget( myNbPrism, row, 1 );
262 myNbLinPrism = new QLabel( this );
263 l->addWidget( myNbLinPrism, row, 2 );
265 myNbQuadPrism = new QLabel( this );
266 l->addWidget( myNbQuadPrism, row, 3 );
268 row++; // increment row count
270 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
271 l->addWidget( lab, row, 0 );
273 myNbPolyh = new QLabel( this );
274 l->addWidget( myNbPolyh, row, 1 );
279 row = l->rowCount(); // retrieve current row count
281 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
282 l->addWidget( lab, row, 0 );
284 myNbNode = new QLabel( this );
285 l->addWidget( myNbNode, row, 1 );
288 row = l->rowCount(); // retrieve current row count
290 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
291 l->addWidget( lab, row, 0 );
293 my0DElem = new QLabel( this );
294 l->addWidget( my0DElem, row, 1 );
296 addSeparator(this); // add separator
299 row = l->rowCount(); // retrieve current row count
301 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
302 l->addWidget( lab, row, 0 );
304 myNbEdge = new QLabel( this );
305 l->addWidget( myNbEdge, row, 1 );
307 myNbLinEdge = new QLabel( this );
308 l->addWidget( myNbLinEdge, row, 2 );
310 myNbQuadEdge = new QLabel( this );
311 l->addWidget( myNbQuadEdge, row, 3 );
314 row = l->rowCount(); // retrieve current row count
316 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
317 l->addWidget( lab, row, 0 );
319 myNbFace = new QLabel( this );
320 l->addWidget( myNbFace, row, 1 );
322 myNbLinFace = new QLabel( this );
323 l->addWidget( myNbLinFace, row, 2 );
325 myNbQuadFace = new QLabel( this );
326 l->addWidget( myNbQuadFace, row, 3 );
329 row = l->rowCount(); // retrieve current row count
331 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
332 l->addWidget( lab, row, 0 );
334 myNbVolum = new QLabel( this );
335 l->addWidget( myNbVolum, row, 1 );
337 myNbLinVolum = new QLabel( this );
338 l->addWidget( myNbLinVolum, row, 2 );
340 myNbQuadVolum = new QLabel( this );
341 l->addWidget( myNbQuadVolum, row, 3 );
345 // =========================================================================================
347 * \brief Set mesh info
349 // =========================================================================================
351 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
354 myNbNode ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
357 my0DElem ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
360 myNbEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] +
361 theInfo[SMDSEntity_Quad_Edge] ));
362 myNbLinEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] ));
363 myNbQuadEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Edge] ));
366 myNbFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
367 theInfo[SMDSEntity_Quad_Triangle] +
368 theInfo[SMDSEntity_Quadrangle] +
369 theInfo[SMDSEntity_Quad_Quadrangle] +
370 theInfo[SMDSEntity_Polygon] ));
371 myNbLinFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
372 theInfo[SMDSEntity_Quadrangle] +
373 theInfo[SMDSEntity_Polygon] ));
374 myNbQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] +
375 theInfo[SMDSEntity_Quad_Quadrangle] ));
378 myNbVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
379 theInfo[SMDSEntity_Quad_Tetra] +
380 theInfo[SMDSEntity_Pyramid] +
381 theInfo[SMDSEntity_Quad_Pyramid] +
382 theInfo[SMDSEntity_Hexa] +
383 theInfo[SMDSEntity_Quad_Hexa] +
384 theInfo[SMDSEntity_Penta] +
385 theInfo[SMDSEntity_Quad_Penta] +
386 theInfo[SMDSEntity_Polyhedra] ));
387 myNbLinVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
388 theInfo[SMDSEntity_Pyramid] +
389 theInfo[SMDSEntity_Hexa] +
390 theInfo[SMDSEntity_Penta] +
391 theInfo[SMDSEntity_Polyhedra] ));
392 myNbQuadVolum->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] +
393 theInfo[SMDSEntity_Quad_Pyramid] +
394 theInfo[SMDSEntity_Quad_Hexa] +
395 theInfo[SMDSEntity_Quad_Penta] ));
400 myNbTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
401 theInfo[SMDSEntity_Quad_Triangle] ));
402 myNbLinTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] ));
403 myNbQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] ));
405 myNbQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] +
406 theInfo[SMDSEntity_Quad_Quadrangle] ));
407 myNbLinQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] ));
408 myNbQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Quadrangle] ));
410 myNbPolyg ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
413 myNbTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
414 theInfo[SMDSEntity_Quad_Tetra] ));
415 myNbLinTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] ));
416 myNbQuadTetra->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] ));
418 myNbHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] +
419 theInfo[SMDSEntity_Quad_Hexa] ));
420 myNbLinHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] ));
421 myNbQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Hexa] ));
423 myNbPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] +
424 theInfo[SMDSEntity_Quad_Pyramid] ));
425 myNbLinPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] ));
426 myNbQuadPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Pyramid] ));
428 myNbPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] +
429 theInfo[SMDSEntity_Quad_Penta] ));
430 myNbLinPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] ));
431 myNbQuadPrism->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Penta] ));
433 myNbPolyh ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));