]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESHGUI/SMESHGUI_MeshInfosBox.cxx
Salome HOME
Fix OwnHypothesis()
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshInfosBox.cxx
1 // Copyright (C) 2007-2013  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.
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),
67   myNbQuad(0), myNbLinQuad(0), myNbQuadQuad(0),
68   myNbFace(0), myNbLinFace(0), myNbQuadFace(0),
69   myNbPolyg(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),
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   if ( myFull )
106   {
107     // nodes
108     row = l->rowCount();         // retrieve current row count
109     // --
110     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
111     lab->setFont( bold );
112     l->addWidget( lab,           row, 0 );
113     // --
114     myNbNode = new QLabel( this );
115     l->addWidget( myNbNode,      row, 1 );
116
117     addSeparator(this);          // add separator
118
119     // 0D elements
120     row = l->rowCount();         // retrieve current row count
121     // --
122     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
123     lab->setFont( bold );
124     l->addWidget( lab,           row, 0 );
125     // --
126     my0DElem = new QLabel( this );
127     l->addWidget( my0DElem,      row, 1 );
128
129     addSeparator(this);          // add separator
130
131     // balls
132     row = l->rowCount();         // retrieve current row count
133     // --
134     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_BALLS")), this );
135     lab->setFont( bold );
136     l->addWidget( lab,           row, 0 );
137     // --
138     myBall = new QLabel( this );
139     l->addWidget( myBall,      row, 1 );
140
141     addSeparator(this);          // add separator
142
143     // edges
144     row = l->rowCount();         // retrieve current row count
145     // --
146     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
147     lab->setFont( bold );
148     l->addWidget( lab,           row, 0 );
149     // --
150     myNbEdge = new QLabel( this );
151     l->addWidget( myNbEdge,      row, 1 );
152     // --
153     myNbLinEdge = new QLabel( this );
154     l->addWidget( myNbLinEdge,   row, 2 );
155     // --
156     myNbQuadEdge = new QLabel( this );
157     l->addWidget( myNbQuadEdge,  row, 3 );
158
159     addSeparator(this);          // add separator
160
161     // faces
162     row = l->rowCount();         // retrieve current row count
163     // --
164     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
165     lab->setFont( bold );
166     l->addWidget( lab,           row, 0 );
167     // --
168     myNbFace     = new QLabel( this );
169     l->addWidget( myNbFace,      row, 1 );
170     // --
171     myNbLinFace  = new QLabel( this );
172     l->addWidget( myNbLinFace,   row, 2 );
173     // --
174     myNbQuadFace = new QLabel( this );
175     l->addWidget( myNbQuadFace,  row, 3 );
176     // --
177     row++;                       // increment row count
178     // ... triangles
179     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
180     l->addWidget( lab,           row, 0 );
181     // --
182     myNbTrai     = new QLabel( this );
183     l->addWidget( myNbTrai,      row, 1 );
184     // --
185     myNbLinTrai  = new QLabel( this );
186     l->addWidget( myNbLinTrai,   row, 2 );
187     // --
188     myNbQuadTrai = new QLabel( this );
189     l->addWidget( myNbQuadTrai,  row, 3 );
190     // --
191     row++;                       // increment row count
192     // ... quadrangles
193     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
194     l->addWidget( lab,           row, 0 );
195     // --
196     myNbQuad     = new QLabel( this );
197     l->addWidget( myNbQuad,      row, 1 );
198     // --
199     myNbLinQuad  = new QLabel( this );
200     l->addWidget( myNbLinQuad,   row, 2 );
201     // --
202     myNbQuadQuad = new QLabel( this );
203     l->addWidget( myNbQuadQuad,  row, 3 );
204     // --
205     row++;                       // increment row count
206     // ... poligones
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 );
211
212     addSeparator(this);          // add separator
213
214     // volumes
215     row = l->rowCount();         // retrieve current row count
216     // --
217     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
218     lab->setFont( bold );
219     l->addWidget( lab,           row, 0 );
220     // --
221     myNbVolum     = new QLabel( this );
222     l->addWidget( myNbVolum,     row, 1 );
223     // --
224     myNbLinVolum  = new QLabel( this );
225     l->addWidget( myNbLinVolum,  row, 2 );
226     // --
227     myNbQuadVolum = new QLabel( this );
228     l->addWidget( myNbQuadVolum, row, 3 );
229     // --
230     row++;                       // increment row count
231     // ... tetras
232     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
233     l->addWidget( lab,           row, 0 );
234     // --
235     myNbTetra     = new QLabel( this );
236     l->addWidget( myNbTetra,     row, 1 );
237     // --
238     myNbLinTetra  = new QLabel( this );
239     l->addWidget( myNbLinTetra,  row, 2 );
240     // --
241     myNbQuadTetra = new QLabel( this );
242     l->addWidget( myNbQuadTetra, row, 3 );
243     // --
244     row++;                       // increment row count
245     // ... hexas
246     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
247     l->addWidget( lab,           row, 0 );
248     // --
249     myNbHexa      = new QLabel( this );
250     l->addWidget( myNbHexa,      row, 1 );
251     // --
252     myNbLinHexa   = new QLabel( this );
253     l->addWidget( myNbLinHexa,   row, 2 );
254     // --
255     myNbQuadHexa  = new QLabel( this );
256     l->addWidget( myNbQuadHexa,  row, 3 );
257     // --
258     row++;                       // increment row count
259     // ... pyras
260     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
261     l->addWidget( lab,           row, 0 );
262     // --
263     myNbPyra      = new QLabel( this );
264     l->addWidget( myNbPyra,      row, 1 );
265     // --
266     myNbLinPyra   = new QLabel( this );
267     l->addWidget( myNbLinPyra,   row, 2 );
268     // --
269     myNbQuadPyra  = new QLabel( this );
270     l->addWidget( myNbQuadPyra,  row, 3 );
271     // --
272     row++;                       // increment row count
273     // ... prisms
274     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
275     l->addWidget( lab,           row, 0 );
276     // --
277     myNbPrism     = new QLabel( this );
278     l->addWidget( myNbPrism,     row, 1 );
279     // --
280     myNbLinPrism  = new QLabel( this );
281     l->addWidget( myNbLinPrism,  row, 2 );
282     // --
283     myNbQuadPrism = new QLabel( this );
284     l->addWidget( myNbQuadPrism, row, 3 );
285     // --
286     row++;                       // increment row count
287     // ... hexa prisms
288     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAPRISM")), this );
289     l->addWidget( lab,           row, 0 );
290     // --
291     myNbHexaPrism     = new QLabel( this );
292     l->addWidget( myNbHexaPrism, row, 1 );
293     // --
294     row++;                       // increment row count
295     // ... polyedres
296     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
297     l->addWidget( lab,           row, 0 );
298     // --
299     myNbPolyh     = new QLabel( this );
300     l->addWidget( myNbPolyh,     row, 1 );
301   }
302   else
303   {
304     // nodes
305     row = l->rowCount();         // retrieve current row count
306     // --
307     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
308     l->addWidget( lab,           row, 0 );
309     // --
310     myNbNode      = new QLabel( this );
311     l->addWidget( myNbNode,      row, 1 );
312
313     // 0D elements
314     row = l->rowCount();         // retrieve current row count
315     // --
316     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
317     l->addWidget( lab,           row, 0 );
318     // --
319     my0DElem = new QLabel( this );
320     l->addWidget( my0DElem,      row, 1 );
321
322     // balls
323     row = l->rowCount();         // retrieve current row count
324     // --
325     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_BALLS")), this );
326     l->addWidget( lab,           row, 0 );
327     // --
328     myBall = new QLabel( this );
329     l->addWidget( myBall,        row, 1 );
330
331     addSeparator(this);          // add separator
332
333     // edges
334     row = l->rowCount();         // retrieve current row count
335     // --
336     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
337     l->addWidget( lab,           row, 0 );
338     // --
339     myNbEdge      = new QLabel( this );
340     l->addWidget( myNbEdge,      row, 1 );
341     // --
342     myNbLinEdge   = new QLabel( this );
343     l->addWidget( myNbLinEdge,   row, 2 );
344     // --
345     myNbQuadEdge  = new QLabel( this );
346     l->addWidget( myNbQuadEdge,  row, 3 );
347
348     // faces
349     row = l->rowCount();         // retrieve current row count
350     // --
351     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
352     l->addWidget( lab,           row, 0 );
353     // --
354     myNbFace      = new QLabel( this );
355     l->addWidget( myNbFace,      row, 1 );
356     // --
357     myNbLinFace   = new QLabel( this );
358     l->addWidget( myNbLinFace,   row, 2 );
359     // --
360     myNbQuadFace  = new QLabel( this );
361     l->addWidget( myNbQuadFace,  row, 3 );
362
363     // volumes
364     row = l->rowCount();         // retrieve current row count
365     // --
366     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
367     l->addWidget( lab,           row, 0 );
368     // --
369     myNbVolum     = new QLabel( this );
370     l->addWidget( myNbVolum,     row, 1 );
371     // --
372     myNbLinVolum  = new QLabel( this );
373     l->addWidget( myNbLinVolum,  row, 2 );
374     // --
375     myNbQuadVolum = new QLabel( this );
376     l->addWidget( myNbQuadVolum, row, 3 );
377   }
378 }
379
380 // =========================================================================================
381 /*!
382  * \brief Set mesh info
383  */
384 // =========================================================================================
385
386 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
387 {
388   // nodes
389   myNbNode     ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
390
391   //0D elements
392   my0DElem     ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
393
394   //balls
395   myBall       ->setText( QString("%1").arg( theInfo[SMDSEntity_Ball] ));
396
397   // edges
398   myNbEdge     ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] +
399                                              theInfo[SMDSEntity_Quad_Edge] ));
400   myNbLinEdge  ->setText( QString("%1").arg( theInfo[SMDSEntity_Edge] ));
401   myNbQuadEdge ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Edge] ));
402
403   // faces
404   myNbFace     ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
405                                              theInfo[SMDSEntity_Quad_Triangle] +
406                                              theInfo[SMDSEntity_Quadrangle] +
407                                              theInfo[SMDSEntity_Quad_Quadrangle] +
408                                              theInfo[SMDSEntity_BiQuad_Quadrangle] +
409                                              theInfo[SMDSEntity_Polygon] ));
410   myNbLinFace  ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
411                                              theInfo[SMDSEntity_Quadrangle] +
412                                              theInfo[SMDSEntity_Polygon] ));
413   myNbQuadFace ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] +
414                                              theInfo[SMDSEntity_Quad_Quadrangle] +
415                                              theInfo[SMDSEntity_BiQuad_Quadrangle] ));
416
417   // volumes
418   myNbVolum    ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
419                                              theInfo[SMDSEntity_Quad_Tetra] +
420                                              theInfo[SMDSEntity_Pyramid] +
421                                              theInfo[SMDSEntity_Quad_Pyramid] +
422                                              theInfo[SMDSEntity_Hexa] +
423                                              theInfo[SMDSEntity_Quad_Hexa] +
424                                              theInfo[SMDSEntity_TriQuad_Hexa] +
425                                              theInfo[SMDSEntity_Penta] +
426                                              theInfo[SMDSEntity_Quad_Penta] +
427                                              theInfo[SMDSEntity_Hexagonal_Prism] +
428                                              theInfo[SMDSEntity_Polyhedra] ));
429   myNbLinVolum ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
430                                              theInfo[SMDSEntity_Pyramid] +
431                                              theInfo[SMDSEntity_Hexa] +
432                                              theInfo[SMDSEntity_Penta] +
433                                              theInfo[SMDSEntity_Polyhedra] ));
434   myNbQuadVolum->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] +
435                                              theInfo[SMDSEntity_Quad_Pyramid] +
436                                              theInfo[SMDSEntity_Quad_Hexa] +
437                                              theInfo[SMDSEntity_TriQuad_Hexa] +
438                                              theInfo[SMDSEntity_Quad_Penta] ));
439
440   if ( myFull )
441   {
442     // triangles
443     myNbTrai     ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] +
444                                                theInfo[SMDSEntity_Quad_Triangle] ));
445     myNbLinTrai  ->setText( QString("%1").arg( theInfo[SMDSEntity_Triangle] ));
446     myNbQuadTrai ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Triangle] ));
447     // quadrangles
448     myNbQuad     ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] +
449                                                theInfo[SMDSEntity_Quad_Quadrangle] +
450                                                theInfo[SMDSEntity_BiQuad_Quadrangle] ));
451     myNbLinQuad  ->setText( QString("%1").arg( theInfo[SMDSEntity_Quadrangle] ));
452     myNbQuadQuad ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Quadrangle] +
453                                                theInfo[SMDSEntity_BiQuad_Quadrangle]));
454     // poligones
455     myNbPolyg    ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
456
457     // tetras
458     myNbTetra    ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] +
459                                                theInfo[SMDSEntity_Quad_Tetra] ));
460     myNbLinTetra ->setText( QString("%1").arg( theInfo[SMDSEntity_Tetra] ));
461     myNbQuadTetra->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Tetra] ));
462     // hexas
463     myNbHexa     ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] +
464                                                theInfo[SMDSEntity_TriQuad_Hexa],
465                                                theInfo[SMDSEntity_Quad_Hexa] ));
466     myNbLinHexa  ->setText( QString("%1").arg( theInfo[SMDSEntity_Hexa] ));
467     myNbQuadHexa ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Hexa] +
468                                                theInfo[SMDSEntity_TriQuad_Hexa] ));
469     // pyras
470     myNbPyra     ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] +
471                                                theInfo[SMDSEntity_Quad_Pyramid] ));
472     myNbLinPyra  ->setText( QString("%1").arg( theInfo[SMDSEntity_Pyramid] ));
473     myNbQuadPyra ->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Pyramid] ));
474     // prisms
475     myNbPrism    ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] +
476                                                theInfo[SMDSEntity_Quad_Penta] ));
477     myNbLinPrism ->setText( QString("%1").arg( theInfo[SMDSEntity_Penta] ));
478     myNbQuadPrism->setText( QString("%1").arg( theInfo[SMDSEntity_Quad_Penta] ));
479     // octahedra
480     myNbHexaPrism->setText( QString("%1").arg( theInfo[ SMDSEntity_Hexagonal_Prism ]));
481     // polyedres
482     myNbPolyh    ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));
483   }
484 }