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 )
65 QGridLayout* l = new QGridLayout(this);
66 l->setMargin( MARGIN );
67 l->setSpacing( SPACING );
69 QFont italic = font(); italic.setItalic(true);
70 QFont bold = font(); bold.setBold(true);
76 lab = new QLabel( this );
77 lab->setMinimumWidth(100); lab->setFont( italic );
78 l->addWidget( lab, row, 0 );
80 lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), this );
81 lab->setMinimumWidth(100); lab->setFont( italic );
82 l->addWidget( lab, row, 1 );
84 lab = new QLabel(tr("SMESH_MESHINFO_ORDER1"), this );
85 lab->setMinimumWidth(100); lab->setFont( italic );
86 l->addWidget( lab, row, 2 );
88 lab = new QLabel(tr("SMESH_MESHINFO_ORDER2"), this );
89 lab->setMinimumWidth(100); lab->setFont( italic );
90 l->addWidget( lab, row, 3 );
95 row = l->rowCount(); // retrieve current row count
97 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
99 l->addWidget( lab, row, 0 );
101 myNbNode = new QLabel( this );
102 l->addWidget( myNbNode, row, 1 );
104 addSeparator(this); // add separator
107 row = l->rowCount(); // retrieve current row count
109 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
110 lab->setFont( bold );
111 l->addWidget( lab, row, 0 );
113 my0DElem = new QLabel( this );
114 l->addWidget( my0DElem, row, 1 );
116 addSeparator(this); // add separator
119 row = l->rowCount(); // retrieve current row count
121 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
122 lab->setFont( bold );
123 l->addWidget( lab, row, 0 );
125 myNbEdge = new QLabel( this );
126 l->addWidget( myNbEdge, row, 1 );
128 myNbLinEdge = new QLabel( this );
129 l->addWidget( myNbLinEdge, row, 2 );
131 myNbQuadEdge = new QLabel( this );
132 l->addWidget( myNbQuadEdge, row, 3 );
134 addSeparator(this); // add separator
137 row = l->rowCount(); // retrieve current row count
139 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
140 lab->setFont( bold );
141 l->addWidget( lab, row, 0 );
143 myNbFace = new QLabel( this );
144 l->addWidget( myNbFace, row, 1 );
146 myNbLinFace = new QLabel( this );
147 l->addWidget( myNbLinFace, row, 2 );
149 myNbQuadFace = new QLabel( this );
150 l->addWidget( myNbQuadFace, row, 3 );
152 row++; // increment row count
154 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
155 l->addWidget( lab, row, 0 );
157 myNbTrai = new QLabel( this );
158 l->addWidget( myNbTrai, row, 1 );
160 myNbLinTrai = new QLabel( this );
161 l->addWidget( myNbLinTrai, row, 2 );
163 myNbQuadTrai = new QLabel( this );
164 l->addWidget( myNbQuadTrai, row, 3 );
166 row++; // increment row count
168 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
169 l->addWidget( lab, row, 0 );
171 myNbQuad = new QLabel( this );
172 l->addWidget( myNbQuad, row, 1 );
174 myNbLinQuad = new QLabel( this );
175 l->addWidget( myNbLinQuad, row, 2 );
177 myNbQuadQuad = new QLabel( this );
178 l->addWidget( myNbQuadQuad, row, 3 );
180 row++; // increment row count
182 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYGONES")), this );
183 l->addWidget( lab, row, 0 );
184 myNbPolyg = new QLabel( this );
185 l->addWidget( myNbPolyg, row, 1 );
187 addSeparator(this); // add separator
190 row = l->rowCount(); // retrieve current row count
192 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
193 lab->setFont( bold );
194 l->addWidget( lab, row, 0 );
196 myNbVolum = new QLabel( this );
197 l->addWidget( myNbVolum, row, 1 );
199 myNbLinVolum = new QLabel( this );
200 l->addWidget( myNbLinVolum, row, 2 );
202 myNbQuadVolum = new QLabel( this );
203 l->addWidget( myNbQuadVolum, row, 3 );
205 row++; // increment row count
207 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
208 l->addWidget( lab, row, 0 );
210 myNbTetra = new QLabel( this );
211 l->addWidget( myNbTetra, row, 1 );
213 myNbLinTetra = new QLabel( this );
214 l->addWidget( myNbLinTetra, row, 2 );
216 myNbQuadTetra = new QLabel( this );
217 l->addWidget( myNbQuadTetra, row, 3 );
219 row++; // increment row count
221 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
222 l->addWidget( lab, row, 0 );
224 myNbHexa = new QLabel( this );
225 l->addWidget( myNbHexa, row, 1 );
227 myNbLinHexa = new QLabel( this );
228 l->addWidget( myNbLinHexa, row, 2 );
230 myNbQuadHexa = new QLabel( this );
231 l->addWidget( myNbQuadHexa, row, 3 );
233 row++; // increment row count
235 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
236 l->addWidget( lab, row, 0 );
238 myNbPyra = new QLabel( this );
239 l->addWidget( myNbPyra, row, 1 );
241 myNbLinPyra = new QLabel( this );
242 l->addWidget( myNbLinPyra, row, 2 );
244 myNbQuadPyra = new QLabel( this );
245 l->addWidget( myNbQuadPyra, row, 3 );
247 row++; // increment row count
249 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
250 l->addWidget( lab, row, 0 );
252 myNbPrism = new QLabel( this );
253 l->addWidget( myNbPrism, row, 1 );
255 myNbLinPrism = new QLabel( this );
256 l->addWidget( myNbLinPrism, row, 2 );
258 myNbQuadPrism = new QLabel( this );
259 l->addWidget( myNbQuadPrism, row, 3 );
261 row++; // increment row count
263 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
264 l->addWidget( lab, row, 0 );
266 myNbPolyh = new QLabel( this );
267 l->addWidget( myNbPolyh, row, 1 );
272 row = l->rowCount(); // retrieve current row count
274 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
275 l->addWidget( lab, row, 0 );
277 myNbNode = new QLabel( this );
278 l->addWidget( myNbNode, row, 1 );
281 row = l->rowCount(); // retrieve current row count
283 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
284 l->addWidget( lab, row, 0 );
286 myNbEdge = new QLabel( this );
287 l->addWidget( myNbEdge, row, 1 );
289 myNbLinEdge = new QLabel( this );
290 l->addWidget( myNbLinEdge, row, 2 );
292 myNbQuadEdge = new QLabel( this );
293 l->addWidget( myNbQuadEdge, row, 3 );
296 row = l->rowCount(); // retrieve current row count
298 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
299 l->addWidget( lab, row, 0 );
301 myNbFace = new QLabel( this );
302 l->addWidget( myNbFace, row, 1 );
304 myNbLinFace = new QLabel( this );
305 l->addWidget( myNbLinFace, row, 2 );
307 myNbQuadFace = new QLabel( this );
308 l->addWidget( myNbQuadFace, row, 3 );
311 row = l->rowCount(); // retrieve current row count
313 lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
314 l->addWidget( lab, row, 0 );
316 myNbVolum = new QLabel( this );
317 l->addWidget( myNbVolum, row, 1 );
319 myNbLinVolum = new QLabel( this );
320 l->addWidget( myNbLinVolum, row, 2 );
322 myNbQuadVolum = new QLabel( this );
323 l->addWidget( myNbQuadVolum, row, 3 );
327 // =========================================================================================
329 * \brief Set mesh info
331 // =========================================================================================
333 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
336 myNbNode ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
339 my0DElem ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
342 myNbEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] +
343 theInfo[SMDSEntity_Quad_Edge] ));
344 myNbLinEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] ));
345 myNbQuadEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Edge] ));
348 myNbFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
349 theInfo[SMDSEntity_Quad_Triangle] +
350 theInfo[SMDSEntity_Quadrangle] +
351 theInfo[SMDSEntity_Quad_Quadrangle] +
352 theInfo[SMDSEntity_Polygon] ));
353 myNbLinFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
354 theInfo[SMDSEntity_Quadrangle] +
355 theInfo[SMDSEntity_Polygon] ));
356 myNbQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] +
357 theInfo[SMDSEntity_Quad_Quadrangle] ));
360 myNbVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
361 theInfo[SMDSEntity_Quad_Tetra] +
362 theInfo[SMDSEntity_Pyramid] +
363 theInfo[SMDSEntity_Quad_Pyramid] +
364 theInfo[SMDSEntity_Hexa] +
365 theInfo[SMDSEntity_Quad_Hexa] +
366 theInfo[SMDSEntity_Penta] +
367 theInfo[SMDSEntity_Quad_Penta] +
368 theInfo[SMDSEntity_Polyhedra] ));
369 myNbLinVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
370 theInfo[SMDSEntity_Pyramid] +
371 theInfo[SMDSEntity_Hexa] +
372 theInfo[SMDSEntity_Penta] +
373 theInfo[SMDSEntity_Polyhedra] ));
374 myNbQuadVolum->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] +
375 theInfo[SMDSEntity_Quad_Pyramid] +
376 theInfo[SMDSEntity_Quad_Hexa] +
377 theInfo[SMDSEntity_Quad_Penta] ));
382 myNbTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
383 theInfo[SMDSEntity_Quad_Triangle] ));
384 myNbLinTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] ));
385 myNbQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] ));
387 myNbQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] +
388 theInfo[SMDSEntity_Quad_Quadrangle] ));
389 myNbLinQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] ));
390 myNbQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Quadrangle] ));
392 myNbPolyg ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
395 myNbTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
396 theInfo[SMDSEntity_Quad_Tetra] ));
397 myNbLinTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] ));
398 myNbQuadTetra->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] ));
400 myNbHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] +
401 theInfo[SMDSEntity_Quad_Hexa] ));
402 myNbLinHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] ));
403 myNbQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Hexa] ));
405 myNbPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] +
406 theInfo[SMDSEntity_Quad_Pyramid] ));
407 myNbLinPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] ));
408 myNbQuadPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Pyramid] ));
410 myNbPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] +
411 theInfo[SMDSEntity_Quad_Penta] ));
412 myNbLinPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] ));
413 myNbQuadPrism->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Penta] ));
415 myNbPolyh ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));