Salome HOME
#19765 EDF 21730 - long time to load med file file with huge amount of groups
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshInfo.h
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef SMESHGUI_MESHINFO_H
24 #define SMESHGUI_MESHINFO_H
25
26 #include "SMESH_SMESHGUI.hxx"
27 #include "SMESHGUI_SelectionProxy.h"
28
29 #ifndef DISABLE_PLOT2DVIEWER
30   #include <Plot2d_Histogram.h>
31 #else
32   #include <qwt_plot.h>
33 #endif
34
35 #include <QDialog>
36 #include <QList>
37 #include <QMap>
38 #include <QSet>
39
40 #include <SALOMEconfig.h>
41 #include CORBA_SERVER_HEADER(SMESH_Filter)
42
43 #include <SALOME_InteractiveObject.hxx>
44 #include <SALOME_GenericObj_wrap.hxx>
45
46 class QAbstractButton;
47 class QButtonGroup;
48 class QCheckBox;
49 class QContextMenuEvent;
50 class QLabel;
51 class QLineEdit;
52 class QTabWidget;
53 class QTextBrowser;
54 class QTreeWidget;
55 class QTreeWidgetItem;
56 class SMDS_MeshElement;
57 class SMDS_MeshNode;
58 class SMESHGUI_IdPreview;
59 class SMESHGUI_SpinBox;
60
61 class ExtraWidget;
62 class GroupCombo;
63 class InfoWriter;
64
65 class SMESHGUI_EXPORT SMESHGUI_Info : public QWidget
66 {
67 public:
68   SMESHGUI_Info( QWidget* = 0 );
69   virtual void saveInfo( QTextStream& ) = 0;
70 };
71
72 class SMESHGUI_EXPORT SMESHGUI_BaseInfo : public SMESHGUI_Info
73 {
74   Q_OBJECT;
75   
76   enum
77   {
78     iStart,
79     iObjectStart = iStart,
80     iName = iObjectStart,
81     iObject,
82     iObjectEnd,
83     iNodesStart = iObjectEnd,
84     iNodes,
85     iNodesEnd,
86     iElementsStart = iNodesEnd,
87     iElementsTitleStart = iElementsStart,
88     iElementsTitle,
89     iElementsTitleEnd,
90     iElementsTotalStart = iElementsTitleEnd,
91     iElementsTotal,
92     iElementsTotalEnd,
93     i0DStart = iElementsTotalEnd,
94     i0D,
95     i0DEnd,
96     iBallsStart = i0DEnd,
97     iBalls,
98     iBallsEnd,
99     i1DStart = iBallsEnd,
100     i1D,
101     i1DEnd,
102     i2DStart = i1DEnd,
103     i2D,
104     i2DTriangles,
105     i2DQuadrangles,
106     i2DPolygons,
107     i2DEnd,
108     i3DStart = i2DEnd,
109     i3D,
110     i3DTetrahedrons,
111     i3DHexahedrons,
112     i3DPyramids,
113     i3DPrisms,
114     i3DHexaPrisms,
115     i3DPolyhedrons,
116     i3DEnd,
117     iElementsEnd = i3DEnd,
118     iEnd,
119     iOther = iEnd
120   };
121
122   enum
123   {
124     iLabel,
125     iSingle,
126     iTotal = iSingle,
127     iLinear,
128     iQuadratic,
129     iBiQuadratic,
130     iNbColumns
131   };
132
133   typedef QMap<int, QWidget*> wlist;
134   typedef QMap<int, wlist> iwlist;
135
136 public:
137   SMESHGUI_BaseInfo( QWidget* = 0 );
138   ~SMESHGUI_BaseInfo();
139
140   void showInfo( const SMESH::SelectionProxy& );
141   void clear();
142   void saveInfo( QTextStream& );
143
144 private:
145   QWidget* addWidget( QWidget*, int, int, int = 1 );
146   QWidget* widget( int, int ) const;
147   QString value( int, int ) const;
148   void setFieldsVisible( int, int, bool );
149
150 private slots:
151   void updateInfo();
152   void loadMesh();
153
154 private:
155   iwlist myWidgets;
156   SMESH::SelectionProxy myProxy;
157 };
158
159 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public SMESHGUI_Info
160 {
161   Q_OBJECT;
162
163 public:
164   SMESHGUI_ElemInfo( QWidget* = 0 );
165   ~SMESHGUI_ElemInfo();
166
167   void showInfo( const SMESH::SelectionProxy&, uint, bool );
168   void showInfo( const SMESH::SelectionProxy&, QSet<uint>, bool );
169   void showInfo( const SMESH::SelectionProxy& );
170   void clear();
171   void saveInfo( QTextStream& );
172
173 protected:
174   enum { ShowNone, ShowNodes, ShowElements };
175
176   QWidget* centralWidget() const;
177
178   SMESH::SelectionProxy proxy() const;
179   int what() const;
180
181   QString type2str( int, bool = false );
182   QString stype2str( int );
183   QString etype2str( int );
184   QString ctrl2str( int );
185   void writeInfo( InfoWriter*, const QList<uint>& );
186   virtual void information( const QList<uint>& ) = 0;
187   virtual void clearInternal();
188
189 signals:
190   void itemInfo( int type, const QString& ids );
191
192 private slots:
193   void showPrevious();
194   void showNext();
195   void updateControls();
196
197 private:
198   QWidget* myFrame;
199   ExtraWidget* myExtra;
200   SMESH::SelectionProxy myProxy;
201   int myWhat;
202   QList<uint> myIDs;
203   int myIndex;
204 };
205
206 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
207 {
208   Q_OBJECT;
209
210 public:
211   SMESHGUI_SimpleElemInfo( QWidget* = 0 );
212
213 protected:
214   void information( const QList<uint>& );
215   void clearInternal();
216
217 private slots:
218   void connectivityClicked(const QUrl &);
219
220  private:
221   QTextBrowser* myInfo;
222 };
223
224 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
225 {
226   Q_OBJECT;
227
228   class ItemDelegate;
229   class ItemCreator;
230
231 public:
232   SMESHGUI_TreeElemInfo( QWidget* = 0 );
233
234 protected:
235   void contextMenuEvent( QContextMenuEvent* );
236   void information( const QList<uint>& );
237   void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
238   void clearInternal();
239
240 private slots:
241   void itemDoubleClicked( QTreeWidgetItem*, int );
242   void saveExpanded( QTreeWidgetItem* );
243
244 private:
245   QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
246   QString          expandedResource( QTreeWidgetItem* );
247   
248 private:
249   QTreeWidget* myInfo;
250 };
251
252 class InfoComputor: public QObject
253 {
254   Q_OBJECT;
255
256 public:
257   enum { GrpSize, GrpNbNodes };
258   
259   InfoComputor( QObject*, const SMESH::SelectionProxy&, int );
260
261 signals:
262   void computed();
263
264 public slots:
265   void compute();
266
267 private:
268   SMESH::SelectionProxy myProxy;
269   int myOperation;
270 };
271
272 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public SMESHGUI_Info
273 {
274   Q_OBJECT;
275
276 public:
277   SMESHGUI_AddInfo( QWidget* = 0 );
278   ~SMESHGUI_AddInfo();
279
280   void showInfo( const SMESH::SelectionProxy& );
281   void clear();
282   void saveInfo( QTextStream& );
283
284 private slots:
285   void updateInfo();
286   void showPreviousGroups();
287   void showNextGroups();
288   void showPreviousSubMeshes();
289   void showNextSubMeshes();
290
291 private:
292   QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
293   void meshInfo( const SMESH::SelectionProxy&, QTreeWidgetItem* );
294   void subMeshInfo( const SMESH::SelectionProxy&, QTreeWidgetItem* );
295   void groupInfo( const SMESH::SelectionProxy&, QTreeWidgetItem* );
296
297   void showGroups();
298   void showSubMeshes();
299
300 private:
301   SMESH::SelectionProxy myProxy;
302   QTreeWidget* myTree;
303   QList<InfoComputor*> myComputors;
304   QList<SMESH::SelectionProxy> myGroups;
305   QList<SMESH::SelectionProxy> mySubMeshes;
306 };
307
308 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public SMESHGUI_Info
309 {
310   Q_OBJECT;
311
312 public:
313   SMESHGUI_CtrlInfo( QWidget* = 0 );
314   ~SMESHGUI_CtrlInfo();
315
316   void showInfo( const SMESH::SelectionProxy& );
317   void saveInfo( QTextStream& );
318
319 private:
320   enum ObjectType { Mesh, SubMesh, Group };
321   QwtPlot* createPlot( QWidget* );
322   void clearInternal();
323 #ifndef DISABLE_PLOT2DVIEWER
324   Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr );
325 #endif
326   void computeNb( int, int, int );
327
328 private slots:
329   void computeAspectRatio();
330   void computeAspectRatio3D();
331   void computeFreeNodesInfo();
332   void computeNodesNbConnInfo();
333   void computeDoubleNodesInfo();
334   void computeDoubleEdgesInfo();
335   void computeDoubleFacesInfo();
336   void computeOverConstrainedFacesInfo();
337   void computeDoubleVolumesInfo();
338   void computeOverConstrainedVolumesInfo();
339   void setTolerance( double );
340
341 private:
342   typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
343   typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
344   SMESH::SelectionProxy myProxy;
345   ObjectType myObjectType;
346   SMESHGUI_SpinBox* myToleranceWidget;
347   QList<QLabel*> myWidgets;
348   QwtPlot* myPlot;
349   QwtPlot* myPlot3D;
350   QList<QAbstractButton*> myButtons;
351   QList<TPredicate> myPredicates;
352   TNumFunctor myAspectRatio, myAspectRatio3D, myNodeConnFunctor;
353 };
354
355 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
356
357   Q_OBJECT;
358
359   enum { NodeMode, ElemMode, GroupMode };
360
361 public:
362   //! Information type
363   enum
364   { 
365     BaseInfo,  //!< base mesh information
366     ElemInfo,  //!< mesh element information
367     AddInfo,   //!< additional information
368     CtrlInfo   //!< controls information
369   };
370
371   SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
372   ~SMESHGUI_MeshInfoDlg();
373
374   void showInfo( const Handle(SALOME_InteractiveObject)& );
375   void reject();
376
377 protected:
378   void keyPressEvent( QKeyEvent* );
379
380 signals:
381   void switchMode( int );
382
383 private slots:
384   void help();
385   void updateSelection();
386   void updateInfo();
387   void deactivate();
388   void modeChanged();
389   void idChanged();
390   void idPreviewChange( bool );
391   void showItemInfo( int type, const QString& ids );
392   void dump();
393
394 private:
395   void showInfo( const SMESH::SelectionProxy& );
396
397   SMESH::SelectionProxy myProxy;
398   QTabWidget* myTabWidget;
399   SMESHGUI_BaseInfo* myBaseInfo;
400   SMESHGUI_ElemInfo* myElemInfo;
401   SMESHGUI_AddInfo* myAddInfo;
402   SMESHGUI_CtrlInfo* myCtrlInfo;
403   QButtonGroup* myMode;
404   QLineEdit* myID;
405   QCheckBox* myIDPreviewCheck;
406   GroupCombo* myGroups;
407   SMESHGUI_IdPreview* myIDPreview;
408 };
409
410 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
411
412   Q_OBJECT;
413
414 public:
415   SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
416   ~SMESHGUI_CtrlInfoDlg();
417
418   void showInfo( const Handle(SALOME_InteractiveObject)& );
419   void reject();
420
421 private slots:
422   void updateInfo();
423   void deactivate();
424   void updateSelection();
425   void help();
426   void dump();
427
428 private:
429   void showInfo( const SMESH::SelectionProxy& );
430
431   SMESH::SelectionProxy myProxy;
432   SMESHGUI_CtrlInfo* myCtrlInfo;
433 };
434
435 #endif // SMESHGUI_MESHINFO_H