1 // Copyright (C) 2007-2011 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 ),
62 myNbNode(0), my0DElem(0), myNbEdge(0), myNbLinEdge(0), myNbQuadEdge(0),
63 myNbTrai(0), myNbLinTrai(0), myNbQuadTrai(0), myNbQuad(0), myNbLinQuad(0),
64 myNbQuadQuad(0), myNbFace(0), myNbLinFace(0), myNbQuadFace(0), myNbPolyg(0),
65 myNbHexa(0), myNbLinHexa(0), myNbQuadHexa(0), myNbTetra(0), myNbLinTetra(0),
66 myNbQuadTetra(0), myNbPyra(0), myNbLinPyra(0), myNbQuadPyra(0), myNbPrism(0),
67 myNbLinPrism(0), myNbQuadPrism(0), myNbVolum(0), myNbLinVolum(0), myNbQuadVolum(0),
70 QGridLayout* l = new QGridLayout(this);
71 l->setMargin( MARGIN );
72 l->setSpacing( SPACING );
74 QFont italic = font(); italic.setItalic(true);
75 QFont bold = font(); bold.setBold(true);
81 lab = new QLabel( this );
82 lab->setMinimumWidth(100); lab->setFont( italic );
83 l->addWidget( lab, row, 0 );
85 lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), this );
86 lab->setMinimumWidth(100); lab->setFont( italic );
87 l->addWidget( lab, row, 1 );
89 lab = new QLabel(tr("SMESH_MESHINFO_ORDER1"), this );
90 lab->setMinimumWidth(100); lab->setFont( italic );
91 l->addWidget( lab, row, 2 );
93 lab = new QLabel(tr("SMESH_MESHINFO_ORDER2"), this );
94 lab->setMinimumWidth(100); lab->setFont( italic );
95 l->addWidget( lab, row, 3 );
100 row = l->rowCount(); // retrieve current row count
102 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
103 lab->setFont( bold );
104 l->addWidget( lab, row, 0 );
106 myNbNode = new QLabel( this );
107 l->addWidget( myNbNode, row, 1 );
109 addSeparator(this); // add separator
112 row = l->rowCount(); // retrieve current row count
114 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
115 lab->setFont( bold );
116 l->addWidget( lab, row, 0 );
118 my0DElem = new QLabel( this );
119 l->addWidget( my0DElem, row, 1 );
121 addSeparator(this); // add separator
124 row = l->rowCount(); // retrieve current row count
126 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
127 lab->setFont( bold );
128 l->addWidget( lab, row, 0 );
130 myNbEdge = new QLabel( this );
131 l->addWidget( myNbEdge, row, 1 );
133 myNbLinEdge = new QLabel( this );
134 l->addWidget( myNbLinEdge, row, 2 );
136 myNbQuadEdge = new QLabel( this );
137 l->addWidget( myNbQuadEdge, row, 3 );
139 addSeparator(this); // add separator
142 row = l->rowCount(); // retrieve current row count
144 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
145 lab->setFont( bold );
146 l->addWidget( lab, row, 0 );
148 myNbFace = new QLabel( this );
149 l->addWidget( myNbFace, row, 1 );
151 myNbLinFace = new QLabel( this );
152 l->addWidget( myNbLinFace, row, 2 );
154 myNbQuadFace = new QLabel( this );
155 l->addWidget( myNbQuadFace, row, 3 );
157 row++; // increment row count
159 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
160 l->addWidget( lab, row, 0 );
162 myNbTrai = new QLabel( this );
163 l->addWidget( myNbTrai, row, 1 );
165 myNbLinTrai = new QLabel( this );
166 l->addWidget( myNbLinTrai, row, 2 );
168 myNbQuadTrai = new QLabel( this );
169 l->addWidget( myNbQuadTrai, row, 3 );
171 row++; // increment row count
173 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
174 l->addWidget( lab, row, 0 );
176 myNbQuad = new QLabel( this );
177 l->addWidget( myNbQuad, row, 1 );
179 myNbLinQuad = new QLabel( this );
180 l->addWidget( myNbLinQuad, row, 2 );
182 myNbQuadQuad = new QLabel( this );
183 l->addWidget( myNbQuadQuad, row, 3 );
185 row++; // increment row count
187 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYGONES")), this );
188 l->addWidget( lab, row, 0 );
189 myNbPolyg = new QLabel( this );
190 l->addWidget( myNbPolyg, row, 1 );
192 addSeparator(this); // add separator
195 row = l->rowCount(); // retrieve current row count
197 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
198 lab->setFont( bold );
199 l->addWidget( lab, row, 0 );
201 myNbVolum = new QLabel( this );
202 l->addWidget( myNbVolum, row, 1 );
204 myNbLinVolum = new QLabel( this );
205 l->addWidget( myNbLinVolum, row, 2 );
207 myNbQuadVolum = new QLabel( this );
208 l->addWidget( myNbQuadVolum, row, 3 );
210 row++; // increment row count
212 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
213 l->addWidget( lab, row, 0 );
215 myNbTetra = new QLabel( this );
216 l->addWidget( myNbTetra, row, 1 );
218 myNbLinTetra = new QLabel( this );
219 l->addWidget( myNbLinTetra, row, 2 );
221 myNbQuadTetra = new QLabel( this );
222 l->addWidget( myNbQuadTetra, row, 3 );
224 row++; // increment row count
226 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
227 l->addWidget( lab, row, 0 );
229 myNbHexa = new QLabel( this );
230 l->addWidget( myNbHexa, row, 1 );
232 myNbLinHexa = new QLabel( this );
233 l->addWidget( myNbLinHexa, row, 2 );
235 myNbQuadHexa = new QLabel( this );
236 l->addWidget( myNbQuadHexa, row, 3 );
238 row++; // increment row count
240 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
241 l->addWidget( lab, row, 0 );
243 myNbPyra = new QLabel( this );
244 l->addWidget( myNbPyra, row, 1 );
246 myNbLinPyra = new QLabel( this );
247 l->addWidget( myNbLinPyra, row, 2 );
249 myNbQuadPyra = new QLabel( this );
250 l->addWidget( myNbQuadPyra, row, 3 );
252 row++; // increment row count
254 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
255 l->addWidget( lab, row, 0 );
257 myNbPrism = new QLabel( this );
258 l->addWidget( myNbPrism, row, 1 );
260 myNbLinPrism = new QLabel( this );
261 l->addWidget( myNbLinPrism, row, 2 );
263 myNbQuadPrism = new QLabel( this );
264 l->addWidget( myNbQuadPrism, row, 3 );
266 row++; // increment row count
268 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
269 l->addWidget( lab, row, 0 );
271 myNbPolyh = new QLabel( this );
272 l->addWidget( myNbPolyh, row, 1 );
277 row = l->rowCount(); // retrieve current row count
279 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
280 l->addWidget( lab, row, 0 );
282 myNbNode = new QLabel( this );
283 l->addWidget( myNbNode, row, 1 );
286 row = l->rowCount(); // retrieve current row count
288 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
289 l->addWidget( lab, row, 0 );
291 my0DElem = new QLabel( this );
292 l->addWidget( my0DElem, row, 1 );
294 addSeparator(this); // add separator
297 row = l->rowCount(); // retrieve current row count
299 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
300 l->addWidget( lab, row, 0 );
302 myNbEdge = new QLabel( this );
303 l->addWidget( myNbEdge, row, 1 );
305 myNbLinEdge = new QLabel( this );
306 l->addWidget( myNbLinEdge, row, 2 );
308 myNbQuadEdge = new QLabel( this );
309 l->addWidget( myNbQuadEdge, row, 3 );
312 row = l->rowCount(); // retrieve current row count
314 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
315 l->addWidget( lab, row, 0 );
317 myNbFace = new QLabel( this );
318 l->addWidget( myNbFace, row, 1 );
320 myNbLinFace = new QLabel( this );
321 l->addWidget( myNbLinFace, row, 2 );
323 myNbQuadFace = new QLabel( this );
324 l->addWidget( myNbQuadFace, row, 3 );
327 row = l->rowCount(); // retrieve current row count
329 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
330 l->addWidget( lab, row, 0 );
332 myNbVolum = new QLabel( this );
333 l->addWidget( myNbVolum, row, 1 );
335 myNbLinVolum = new QLabel( this );
336 l->addWidget( myNbLinVolum, row, 2 );
338 myNbQuadVolum = new QLabel( this );
339 l->addWidget( myNbQuadVolum, row, 3 );
343 // =========================================================================================
345 * \brief Set mesh info
347 // =========================================================================================
349 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
352 myNbNode ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
355 my0DElem ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
358 myNbEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] +
359 theInfo[SMDSEntity_Quad_Edge] ));
360 myNbLinEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] ));
361 myNbQuadEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Edge] ));
364 myNbFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
365 theInfo[SMDSEntity_Quad_Triangle] +
366 theInfo[SMDSEntity_Quadrangle] +
367 theInfo[SMDSEntity_Quad_Quadrangle] +
368 theInfo[SMDSEntity_Polygon] ));
369 myNbLinFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
370 theInfo[SMDSEntity_Quadrangle] +
371 theInfo[SMDSEntity_Polygon] ));
372 myNbQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] +
373 theInfo[SMDSEntity_Quad_Quadrangle] ));
376 myNbVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
377 theInfo[SMDSEntity_Quad_Tetra] +
378 theInfo[SMDSEntity_Pyramid] +
379 theInfo[SMDSEntity_Quad_Pyramid] +
380 theInfo[SMDSEntity_Hexa] +
381 theInfo[SMDSEntity_Quad_Hexa] +
382 theInfo[SMDSEntity_Penta] +
383 theInfo[SMDSEntity_Quad_Penta] +
384 theInfo[SMDSEntity_Polyhedra] ));
385 myNbLinVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
386 theInfo[SMDSEntity_Pyramid] +
387 theInfo[SMDSEntity_Hexa] +
388 theInfo[SMDSEntity_Penta] +
389 theInfo[SMDSEntity_Polyhedra] ));
390 myNbQuadVolum->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] +
391 theInfo[SMDSEntity_Quad_Pyramid] +
392 theInfo[SMDSEntity_Quad_Hexa] +
393 theInfo[SMDSEntity_Quad_Penta] ));
398 myNbTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
399 theInfo[SMDSEntity_Quad_Triangle] ));
400 myNbLinTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] ));
401 myNbQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] ));
403 myNbQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] +
404 theInfo[SMDSEntity_Quad_Quadrangle] ));
405 myNbLinQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] ));
406 myNbQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Quadrangle] ));
408 myNbPolyg ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
411 myNbTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
412 theInfo[SMDSEntity_Quad_Tetra] ));
413 myNbLinTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] ));
414 myNbQuadTetra->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] ));
416 myNbHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] +
417 theInfo[SMDSEntity_Quad_Hexa] ));
418 myNbLinHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] ));
419 myNbQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Hexa] ));
421 myNbPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] +
422 theInfo[SMDSEntity_Quad_Pyramid] ));
423 myNbLinPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] ));
424 myNbQuadPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Pyramid] ));
426 myNbPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] +
427 theInfo[SMDSEntity_Quad_Penta] ));
428 myNbLinPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] ));
429 myNbQuadPrism->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Penta] ));
431 myNbPolyh ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));