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