Salome HOME
59900714e0e1032b34a505f89e98239253467205
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshInfosBox.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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, or (at your option) any later version.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File   : SMESHGUI_MeshInfosBox.cxx
21 // Author : Edward AGAPOV, Open CASCADE S.A.S.
22 // SMESH includes
23 //
24 #include "SMESHGUI_MeshInfosBox.h"
25
26 #include "SMDSAbs_ElementType.hxx"
27
28 // Qt includes
29 #include <QFrame>
30 #include <QLabel>
31 #include <QGridLayout>
32
33 #define SPACING 6
34 #define MARGIN  11
35
36 #define COLONIZE(str)   (QString(str).contains(":") > 0 ? QString(str) : QString(str) + " :" )
37
38 static void addSeparator( QWidget* parent )
39 {
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 );
47   }
48 }
49
50 enum TCol {
51   COL_ALGO = 0, COL_SHAPE, COL_ERROR, COL_SHAPEID, COL_PUBLISHED, COL_BAD_MESH, NB_COLUMNS
52 };
53
54 // =========================================================================================
55 /*!
56  * \brief Box showing mesh info
57  */
58 // =========================================================================================
59
60 SMESHGUI_MeshInfosBox::SMESHGUI_MeshInfosBox(const bool full, QWidget* theParent)
61 : QGroupBox( tr("SMESH_MESHINFO_TITLE"), theParent ), myFull( full ),
62   myNbNode(0),
63   my0DElem(0),
64   myBall(0),
65   myNbEdge(0), myNbLinEdge(0), myNbQuadEdge(0),
66   myNbTrai(0), myNbLinTrai(0), myNbQuadTrai(0), myNbBiQuadTrai(0),
67   myNbQuad(0), myNbLinQuad(0), myNbQuadQuad(0), myNbBiQuadQuad(0),
68   myNbFace(0), myNbLinFace(0), myNbQuadFace(0), myNbBiQuadFace(0),
69   myNbPolyg(0),
70   myNbHexa(0), myNbLinHexa(0), myNbQuadHexa(0), myNbBiQuadHexa(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), myNbBiQuadVolum(0),
75   myNbHexaPrism(0),
76   myNbPolyh(0)
77 {
78   QGridLayout* l = new QGridLayout(this);
79   l->setMargin( MARGIN );
80   l->setSpacing( SPACING );
81
82   QFont italic = font(); italic.setItalic(true);
83   QFont bold   = font(); bold.setBold(true);
84
85   QLabel* lab;
86   int row = 0;
87
88   // title
89   lab = new QLabel( this );
90   lab->setMinimumWidth(100); lab->setFont( italic );
91   l->addWidget( lab, row, 0 );
92   // --
93   lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), this );
94   lab->setMinimumWidth(100); lab->setFont( italic );
95   l->addWidget( lab, row, 1 );
96   // --
97   lab = new QLabel(tr("SMESH_MESHINFO_ORDER1"), this );
98   lab->setMinimumWidth(100); lab->setFont( italic );
99   l->addWidget( lab, row, 2 );
100   // --
101   lab = new QLabel(tr("SMESH_MESHINFO_ORDER2"), this );
102   lab->setMinimumWidth(100); lab->setFont( italic );
103   l->addWidget( lab, row, 3 );
104   // --
105   lab = new QLabel(tr("SMESH_MESHINFO_ORDER3"), this );
106   lab->setMinimumWidth(100); lab->setFont( italic );
107   l->addWidget( lab, row, 4 );
108
109   if ( myFull )
110   {
111     // nodes
112     row = l->rowCount();         // retrieve current row count
113     // --
114     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
115     lab->setFont( bold );
116     l->addWidget( lab,           row, 0 );
117     // --
118     myNbNode = new QLabel( this );
119     l->addWidget( myNbNode,      row, 1 );
120
121     addSeparator(this);          // add separator
122
123     // 0D elements
124     row = l->rowCount();         // retrieve current row count
125     // --
126     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
127     lab->setFont( bold );
128     l->addWidget( lab,           row, 0 );
129     // --
130     my0DElem = new QLabel( this );
131     l->addWidget( my0DElem,      row, 1 );
132
133     addSeparator(this);          // add separator
134
135     // balls
136     row = l->rowCount();         // retrieve current row count
137     // --
138     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_BALLS")), this );
139     lab->setFont( bold );
140     l->addWidget( lab,           row, 0 );
141     // --
142     myBall = new QLabel( this );
143     l->addWidget( myBall,      row, 1 );
144
145     addSeparator(this);          // add separator
146
147     // edges
148     row = l->rowCount();         // retrieve current row count
149     // --
150     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
151     lab->setFont( bold );
152     l->addWidget( lab,           row, 0 );
153     // --
154     myNbEdge = new QLabel( this );
155     l->addWidget( myNbEdge,      row, 1 );
156     // --
157     myNbLinEdge = new QLabel( this );
158     l->addWidget( myNbLinEdge,   row, 2 );
159     // --
160     myNbQuadEdge = new QLabel( this );
161     l->addWidget( myNbQuadEdge,  row, 3 );
162
163     addSeparator(this);          // add separator
164
165     // faces
166     row = l->rowCount();         // retrieve current row count
167     // --
168     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
169     lab->setFont( bold );
170     l->addWidget( lab,            row, 0 );
171     // --
172     myNbFace       = new QLabel( this );
173     l->addWidget( myNbFace,       row, 1 );
174     // --
175     myNbLinFace    = new QLabel( this );
176     l->addWidget( myNbLinFace,    row,  2 );
177     // --
178     myNbQuadFace   = new QLabel( this );
179     l->addWidget( myNbQuadFace,   row, 3 );
180     // --
181     myNbBiQuadFace = new QLabel( this );
182     l->addWidget( myNbBiQuadFace, row, 4 );
183     // --
184     row++;                       // increment row count
185     // ... triangles
186     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
187     l->addWidget( lab,            row, 0 );
188     // --
189     myNbTrai       = new QLabel( this );
190     l->addWidget( myNbTrai,       row, 1 );
191     // --
192     myNbLinTrai    = new QLabel( this );
193     l->addWidget( myNbLinTrai,    row, 2 );
194     // --
195     myNbQuadTrai   = new QLabel( this );
196     l->addWidget( myNbQuadTrai,   row, 3 );
197     // --
198     myNbBiQuadTrai = new QLabel( this );
199     l->addWidget( myNbBiQuadTrai, row, 4 );
200     // --
201     row++;                       // increment row count
202     // ... quadrangles
203     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
204     l->addWidget( lab,            row, 0 );
205     // --
206     myNbQuad       = new QLabel( this );
207     l->addWidget( myNbQuad,       row, 1 );
208     // --
209     myNbLinQuad    = new QLabel( this );
210     l->addWidget( myNbLinQuad,    row, 2 );
211     // --
212     myNbQuadQuad   = new QLabel( this );
213     l->addWidget( myNbQuadQuad,   row, 3 );
214     // --
215     myNbBiQuadQuad = new QLabel( this );
216     l->addWidget( myNbBiQuadQuad, row, 4 );
217     // --
218     row++;                       // increment row count
219     // ... poligones
220     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYGONES")), this );
221     l->addWidget( lab,           row, 0 );
222     myNbPolyg    = new QLabel( this );
223     l->addWidget( myNbPolyg,     row, 1 );
224
225     addSeparator(this);          // add separator
226
227     // volumes
228     row = l->rowCount();         // retrieve current row count
229     // --
230     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
231     lab->setFont( bold );
232     l->addWidget( lab,             row, 0 );
233     // --
234     myNbVolum       = new QLabel( this );
235     l->addWidget( myNbVolum,       row, 1 );
236     // --
237     myNbLinVolum    = new QLabel( this );
238     l->addWidget( myNbLinVolum,    row, 2 );
239     // --
240     myNbQuadVolum   = new QLabel( this );
241     l->addWidget( myNbQuadVolum,   row, 3 );
242     // --
243     myNbBiQuadVolum = new QLabel( this );
244     l->addWidget( myNbBiQuadVolum, row, 4 );
245     // --
246     row++;                       // increment row count
247     // ... tetras
248     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
249     l->addWidget( lab,           row, 0 );
250     // --
251     myNbTetra     = new QLabel( this );
252     l->addWidget( myNbTetra,     row, 1 );
253     // --
254     myNbLinTetra  = new QLabel( this );
255     l->addWidget( myNbLinTetra,  row, 2 );
256     // --
257     myNbQuadTetra = new QLabel( this );
258     l->addWidget( myNbQuadTetra, row, 3 );
259     // --
260     row++;                       // increment row count
261     // ... hexas
262     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
263     l->addWidget( lab,            row, 0 );
264     // --
265     myNbHexa       = new QLabel( this );
266     l->addWidget( myNbHexa,       row, 1 );
267     // --
268     myNbLinHexa    = new QLabel( this );
269     l->addWidget( myNbLinHexa,    row, 2 );
270     // --
271     myNbQuadHexa   = new QLabel( this );
272     l->addWidget( myNbQuadHexa,   row, 3 );
273     // --
274     myNbBiQuadHexa = new QLabel( this );
275     l->addWidget( myNbBiQuadHexa, row, 4 );
276     // --
277     row++;                       // increment row count
278     // ... pyras
279     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
280     l->addWidget( lab,           row, 0 );
281     // --
282     myNbPyra      = new QLabel( this );
283     l->addWidget( myNbPyra,      row, 1 );
284     // --
285     myNbLinPyra   = new QLabel( this );
286     l->addWidget( myNbLinPyra,   row, 2 );
287     // --
288     myNbQuadPyra  = new QLabel( this );
289     l->addWidget( myNbQuadPyra,  row, 3 );
290     // --
291     row++;                       // increment row count
292     // ... prisms
293     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
294     l->addWidget( lab,           row, 0 );
295     // --
296     myNbPrism     = new QLabel( this );
297     l->addWidget( myNbPrism,     row, 1 );
298     // --
299     myNbLinPrism  = new QLabel( this );
300     l->addWidget( myNbLinPrism,  row, 2 );
301     // --
302     myNbQuadPrism = new QLabel( this );
303     l->addWidget( myNbQuadPrism, row, 3 );
304     // --
305     row++;                       // increment row count
306     // ... hexa prisms
307     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAPRISM")), this );
308     l->addWidget( lab,           row, 0 );
309     // --
310     myNbHexaPrism     = new QLabel( this );
311     l->addWidget( myNbHexaPrism, row, 1 );
312     // --
313     row++;                       // increment row count
314     // ... polyedres
315     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
316     l->addWidget( lab,           row, 0 );
317     // --
318     myNbPolyh     = new QLabel( this );
319     l->addWidget( myNbPolyh,     row, 1 );
320   }
321   else
322   {
323     // nodes
324     row = l->rowCount();         // retrieve current row count
325     // --
326     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
327     l->addWidget( lab,           row, 0 );
328     // --
329     myNbNode      = new QLabel( this );
330     l->addWidget( myNbNode,      row, 1 );
331
332     // 0D elements
333     row = l->rowCount();         // retrieve current row count
334     // --
335     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
336     l->addWidget( lab,           row, 0 );
337     // --
338     my0DElem = new QLabel( this );
339     l->addWidget( my0DElem,      row, 1 );
340
341     // balls
342     row = l->rowCount();         // retrieve current row count
343     // --
344     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_BALLS")), this );
345     l->addWidget( lab,           row, 0 );
346     // --
347     myBall = new QLabel( this );
348     l->addWidget( myBall,        row, 1 );
349
350     addSeparator(this);          // add separator
351
352     // edges
353     row = l->rowCount();         // retrieve current row count
354     // --
355     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
356     l->addWidget( lab,           row, 0 );
357     // --
358     myNbEdge      = new QLabel( this );
359     l->addWidget( myNbEdge,      row, 1 );
360     // --
361     myNbLinEdge   = new QLabel( this );
362     l->addWidget( myNbLinEdge,   row, 2 );
363     // --
364     myNbQuadEdge  = new QLabel( this );
365     l->addWidget( myNbQuadEdge,  row, 3 );
366
367     // faces
368     row = l->rowCount();         // retrieve current row count
369     // --
370     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
371     l->addWidget( lab,            row, 0 );
372     // --
373     myNbFace       = new QLabel( this );
374     l->addWidget( myNbFace,       row, 1 );
375     // --
376     myNbLinFace    = new QLabel( this );
377     l->addWidget( myNbLinFace,    row, 2 );
378     // --
379     myNbQuadFace   = new QLabel( this );
380     l->addWidget( myNbQuadFace,   row, 3 );
381     // --
382     myNbBiQuadFace = new QLabel( this );
383     l->addWidget( myNbBiQuadFace, row, 4 );
384
385     // volumes
386     row = l->rowCount();         // retrieve current row count
387     // --
388     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
389     l->addWidget( lab,             row, 0 );
390     // --
391     myNbVolum       = new QLabel( this );
392     l->addWidget( myNbVolum,       row, 1 );
393     // --
394     myNbLinVolum    = new QLabel( this );
395     l->addWidget( myNbLinVolum,    row, 2 );
396     // --
397     myNbQuadVolum   = new QLabel( this );
398     l->addWidget( myNbQuadVolum,   row, 3 );
399     // --
400     myNbBiQuadVolum = new QLabel( this );
401     l->addWidget( myNbBiQuadVolum, row, 4 );
402   }
403 }
404
405 // =========================================================================================
406 /*!
407  * \brief Set mesh info
408  */
409 // =========================================================================================
410
411 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
412 {
413   // nodes
414   myNbNode       ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
415
416   //0D elements
417   my0DElem       ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
418
419   //balls
420   myBall         ->setText( QString("%1").arg( theInfo[SMDSEntity_Ball] ));
421
422   // edges
423   myNbEdge       ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] +
424                                                theInfo[SMDSEntity_Quad_Edge] ));
425   myNbLinEdge    ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] ));
426   myNbQuadEdge   ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Edge] ));
427
428   // faces
429   myNbFace       ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
430                                                theInfo[SMDSEntity_Quad_Triangle] +
431                                                theInfo[SMDSEntity_BiQuad_Triangle] +
432                                                theInfo[SMDSEntity_Quadrangle] +
433                                                theInfo[SMDSEntity_Quad_Quadrangle] +
434                                                theInfo[SMDSEntity_BiQuad_Quadrangle] +
435                                                theInfo[SMDSEntity_Polygon] ));
436   myNbLinFace    ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
437                                                theInfo[SMDSEntity_Quadrangle] +
438                                                theInfo[SMDSEntity_Polygon] ));
439   myNbQuadFace   ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] +
440                                                theInfo[SMDSEntity_Quad_Quadrangle] ));
441   myNbBiQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_BiQuad_Triangle] +
442                                                theInfo[SMDSEntity_BiQuad_Quadrangle] ));
443
444   // volumes
445   myNbVolum      ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
446                                                theInfo[SMDSEntity_Quad_Tetra] +
447                                                theInfo[SMDSEntity_Pyramid] +
448                                                theInfo[SMDSEntity_Quad_Pyramid] +
449                                                theInfo[SMDSEntity_Hexa] +
450                                                theInfo[SMDSEntity_Quad_Hexa] +
451                                                theInfo[SMDSEntity_TriQuad_Hexa] +
452                                                theInfo[SMDSEntity_Penta] +
453                                                theInfo[SMDSEntity_Quad_Penta] +
454                                                theInfo[SMDSEntity_Hexagonal_Prism] +
455                                                theInfo[SMDSEntity_Polyhedra] ));
456   myNbLinVolum   ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
457                                                theInfo[SMDSEntity_Pyramid] +
458                                                theInfo[SMDSEntity_Hexa] +
459                                                theInfo[SMDSEntity_Penta] +
460                                                theInfo[SMDSEntity_Polyhedra] ));
461   myNbQuadVolum  ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] +
462                                                theInfo[SMDSEntity_Quad_Pyramid] +
463                                                theInfo[SMDSEntity_Quad_Hexa] +
464                                                theInfo[SMDSEntity_Quad_Penta] ));
465   myNbBiQuadVolum->setText( QString("%1").arg( theInfo[SMDSEntity_TriQuad_Hexa] ));
466
467   if ( myFull )
468   {
469     // triangles
470     myNbTrai       ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
471                                                  theInfo[SMDSEntity_Quad_Triangle] +
472                                                  theInfo[SMDSEntity_BiQuad_Triangle] ));
473     myNbLinTrai    ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] ));
474     myNbQuadTrai   ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] ));
475     myNbBiQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_BiQuad_Triangle] ));
476     // quadrangles
477     myNbQuad       ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] +
478                                                  theInfo[SMDSEntity_Quad_Quadrangle] +
479                                                  theInfo[SMDSEntity_BiQuad_Quadrangle] ));
480     myNbLinQuad    ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] ));
481     myNbQuadQuad   ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Quadrangle] ));
482     myNbBiQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_BiQuad_Quadrangle]));
483     // poligones
484     myNbPolyg      ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
485
486     // tetras
487     myNbTetra      ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
488                                                  theInfo[SMDSEntity_Quad_Tetra] ));
489     myNbLinTetra   ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] ));
490     myNbQuadTetra  ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] ));
491     // hexas
492     myNbHexa       ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] +
493                                                  theInfo[SMDSEntity_TriQuad_Hexa] +
494                                                  theInfo[SMDSEntity_Quad_Hexa] ));
495     myNbLinHexa    ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] ));
496     myNbQuadHexa   ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Hexa] ));
497     myNbBiQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_TriQuad_Hexa] ));
498     // pyras
499     myNbPyra     ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] +
500                                                theInfo[SMDSEntity_Quad_Pyramid] ));
501     myNbLinPyra  ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] ));
502     myNbQuadPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Pyramid] ));
503     // prisms
504     myNbPrism    ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] +
505                                                theInfo[SMDSEntity_Quad_Penta] ));
506     myNbLinPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] ));
507     myNbQuadPrism->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Penta] ));
508     // octahedra
509     myNbHexaPrism->setText( QString("%1").arg( theInfo[ SMDSEntity_Hexagonal_Prism ]));
510     // polyedres
511     myNbPolyh    ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));
512   }
513 }