]> SALOME platform Git repositories - modules/smesh.git/blob - src/SMESHGUI/SMESHGUI_MeshInfosBox.cxx
Salome HOME
fix a comment
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshInfosBox.cxx
1 // Copyright (C) 2007-2011  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), 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),
68   myNbPolyh(0)
69 {
70   QGridLayout* l = new QGridLayout(this);
71   l->setMargin( MARGIN );
72   l->setSpacing( SPACING );
73
74   QFont italic = font(); italic.setItalic(true);
75   QFont bold   = font(); bold.setBold(true);
76
77   QLabel* lab;
78   int row = 0;
79
80   // title
81   lab = new QLabel( this );
82   lab->setMinimumWidth(100); lab->setFont( italic );
83   l->addWidget( lab, row, 0 );
84   // --
85   lab = new QLabel(tr("SMESH_MESHINFO_ORDER0"), this );
86   lab->setMinimumWidth(100); lab->setFont( italic );
87   l->addWidget( lab, row, 1 );
88   // --
89   lab = new QLabel(tr("SMESH_MESHINFO_ORDER1"), this );
90   lab->setMinimumWidth(100); lab->setFont( italic );
91   l->addWidget( lab, row, 2 );
92   // --
93   lab = new QLabel(tr("SMESH_MESHINFO_ORDER2"), this );
94   lab->setMinimumWidth(100); lab->setFont( italic );
95   l->addWidget( lab, row, 3 );
96
97   if ( myFull )
98   {
99     // nodes
100     row = l->rowCount();         // retrieve current row count
101     // --
102     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
103     lab->setFont( bold );
104     l->addWidget( lab,           row, 0 );
105     // --
106     myNbNode = new QLabel( this );
107     l->addWidget( myNbNode,      row, 1 );
108
109     addSeparator(this);          // add separator
110
111     // 0D elements
112     row = l->rowCount();         // retrieve current row count
113     // --
114     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
115     lab->setFont( bold );
116     l->addWidget( lab,           row, 0 );
117     // --
118     my0DElem = new QLabel( this );
119     l->addWidget( my0DElem,      row, 1 );
120
121     addSeparator(this);          // add separator
122
123     // edges
124     row = l->rowCount();         // retrieve current row count
125     // --
126     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
127     lab->setFont( bold );
128     l->addWidget( lab,           row, 0 );
129     // --
130     myNbEdge = new QLabel( this );
131     l->addWidget( myNbEdge,      row, 1 );
132     // --
133     myNbLinEdge = new QLabel( this );
134     l->addWidget( myNbLinEdge,   row, 2 );
135     // --
136     myNbQuadEdge = new QLabel( this );
137     l->addWidget( myNbQuadEdge,  row, 3 );
138
139     addSeparator(this);          // add separator
140
141     // faces
142     row = l->rowCount();         // retrieve current row count
143     // --
144     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
145     lab->setFont( bold );
146     l->addWidget( lab,           row, 0 );
147     // --
148     myNbFace     = new QLabel( this );
149     l->addWidget( myNbFace,      row, 1 );
150     // --
151     myNbLinFace  = new QLabel( this );
152     l->addWidget( myNbLinFace,   row, 2 );
153     // --
154     myNbQuadFace = new QLabel( this );
155     l->addWidget( myNbQuadFace,  row, 3 );
156     // --
157     row++;                       // increment row count
158     // ... triangles
159     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TRIANGLES")), this );
160     l->addWidget( lab,           row, 0 );
161     // --
162     myNbTrai     = new QLabel( this );
163     l->addWidget( myNbTrai,      row, 1 );
164     // --
165     myNbLinTrai  = new QLabel( this );
166     l->addWidget( myNbLinTrai,   row, 2 );
167     // --
168     myNbQuadTrai = new QLabel( this );
169     l->addWidget( myNbQuadTrai,  row, 3 );
170     // --
171     row++;                       // increment row count
172     // ... quadrangles
173     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_QUADRANGLES")), this );
174     l->addWidget( lab,           row, 0 );
175     // --
176     myNbQuad     = new QLabel( this );
177     l->addWidget( myNbQuad,      row, 1 );
178     // --
179     myNbLinQuad  = new QLabel( this );
180     l->addWidget( myNbLinQuad,   row, 2 );
181     // --
182     myNbQuadQuad = new QLabel( this );
183     l->addWidget( myNbQuadQuad,  row, 3 );
184     // --
185     row++;                       // increment row count
186     // ... poligones
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 );
191
192     addSeparator(this);          // add separator
193
194     // volumes
195     row = l->rowCount();         // retrieve current row count
196     // --
197     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
198     lab->setFont( bold );
199     l->addWidget( lab,           row, 0 );
200     // --
201     myNbVolum     = new QLabel( this );
202     l->addWidget( myNbVolum,     row, 1 );
203     // --
204     myNbLinVolum  = new QLabel( this );
205     l->addWidget( myNbLinVolum,  row, 2 );
206     // --
207     myNbQuadVolum = new QLabel( this );
208     l->addWidget( myNbQuadVolum, row, 3 );
209     // --
210     row++;                       // increment row count
211     // ... tetras
212     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_TETRAS")), this );
213     l->addWidget( lab,           row, 0 );
214     // --
215     myNbTetra     = new QLabel( this );
216     l->addWidget( myNbTetra,     row, 1 );
217     // --
218     myNbLinTetra  = new QLabel( this );
219     l->addWidget( myNbLinTetra,  row, 2 );
220     // --
221     myNbQuadTetra = new QLabel( this );
222     l->addWidget( myNbQuadTetra, row, 3 );
223     // --
224     row++;                       // increment row count
225     // ... hexas
226     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_HEXAS")), this );
227     l->addWidget( lab,           row, 0 );
228     // --
229     myNbHexa      = new QLabel( this );
230     l->addWidget( myNbHexa,      row, 1 );
231     // --
232     myNbLinHexa   = new QLabel( this );
233     l->addWidget( myNbLinHexa,   row, 2 );
234     // --
235     myNbQuadHexa  = new QLabel( this );
236     l->addWidget( myNbQuadHexa,  row, 3 );
237     // --
238     row++;                       // increment row count
239     // ... pyras
240     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PYRAS")), this );
241     l->addWidget( lab,           row, 0 );
242     // --
243     myNbPyra      = new QLabel( this );
244     l->addWidget( myNbPyra,      row, 1 );
245     // --
246     myNbLinPyra   = new QLabel( this );
247     l->addWidget( myNbLinPyra,   row, 2 );
248     // --
249     myNbQuadPyra  = new QLabel( this );
250     l->addWidget( myNbQuadPyra,  row, 3 );
251     // --
252     row++;                       // increment row count
253     // ... prisms
254     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_PRISMS")), this );
255     l->addWidget( lab,           row, 0 );
256     // --
257     myNbPrism     = new QLabel( this );
258     l->addWidget( myNbPrism,     row, 1 );
259     // --
260     myNbLinPrism  = new QLabel( this );
261     l->addWidget( myNbLinPrism,  row, 2 );
262     // --
263     myNbQuadPrism = new QLabel( this );
264     l->addWidget( myNbQuadPrism, row, 3 );
265     // --
266     row++;                       // increment row count
267     // ... polyedres
268     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_POLYEDRES")), this );
269     l->addWidget( lab,           row, 0 );
270     // --
271     myNbPolyh     = new QLabel( this );
272     l->addWidget( myNbPolyh,     row, 1 );
273   }
274   else
275   {
276     // nodes
277     row = l->rowCount();         // retrieve current row count
278     // --
279     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_NODES")), this );
280     l->addWidget( lab,           row, 0 );
281     // --
282     myNbNode      = new QLabel( this );
283     l->addWidget( myNbNode,      row, 1 );
284
285     // 0D elements
286     row = l->rowCount();         // retrieve current row count
287     // --
288     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_0DELEMS")), this );
289     l->addWidget( lab,           row, 0 );
290     // --
291     my0DElem = new QLabel( this );
292     l->addWidget( my0DElem,      row, 1 );
293
294     addSeparator(this);          // add separator
295
296     // edges
297     row = l->rowCount();         // retrieve current row count
298     // --
299     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_EDGES")), this );
300     l->addWidget( lab,           row, 0 );
301     // --
302     myNbEdge      = new QLabel( this );
303     l->addWidget( myNbEdge,      row, 1 );
304     // --
305     myNbLinEdge   = new QLabel( this );
306     l->addWidget( myNbLinEdge,   row, 2 );
307     // --
308     myNbQuadEdge  = new QLabel( this );
309     l->addWidget( myNbQuadEdge,  row, 3 );
310
311     // faces
312     row = l->rowCount();         // retrieve current row count
313     // --
314     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_FACES")), this);
315     l->addWidget( lab,           row, 0 );
316     // --
317     myNbFace      = new QLabel( this );
318     l->addWidget( myNbFace,      row, 1 );
319     // --
320     myNbLinFace   = new QLabel( this );
321     l->addWidget( myNbLinFace,   row, 2 );
322     // --
323     myNbQuadFace  = new QLabel( this );
324     l->addWidget( myNbQuadFace,  row, 3 );
325
326     // volumes
327     row = l->rowCount();         // retrieve current row count
328     // --
329     lab = new QLabel(COLONIZE(tr("SMESH_MESHINFO_VOLUMES")), this);
330     l->addWidget( lab,           row, 0 );
331     // --
332     myNbVolum     = new QLabel( this );
333     l->addWidget( myNbVolum,     row, 1 );
334     // --
335     myNbLinVolum  = new QLabel( this );
336     l->addWidget( myNbLinVolum,  row, 2 );
337     // --
338     myNbQuadVolum = new QLabel( this );
339     l->addWidget( myNbQuadVolum, row, 3 );
340   }
341 }
342
343 // =========================================================================================
344 /*!
345  * \brief Set mesh info
346  */
347 // =========================================================================================
348
349 void SMESHGUI_MeshInfosBox::SetMeshInfo(const SMESH::long_array& theInfo)
350 {
351   // nodes
352   myNbNode     ->setText( QString("%1").arg( theInfo[SMDSEntity_Node] ));
353   
354   //0D elements
355   my0DElem     ->setText( QString("%1").arg( theInfo[SMDSEntity_0D] ));
356
357   // edges
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] ));
362
363   // faces
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] ));
374
375   // volumes
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] ));
394
395   if ( myFull )
396   {
397     // triangles
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] ));
402     // quadrangles
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] ));
407     // poligones
408     myNbPolyg    ->setText( QString("%1").arg( theInfo[SMDSEntity_Polygon] ));
409
410     // tetras
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] ));
415     // hexas
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] ));
420     // pyras
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] ));
425     // prisms
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] ));
430     // polyedres
431     myNbPolyh    ->setText( QString("%1").arg( theInfo[SMDSEntity_Polyhedra] ));
432   }
433 }