Salome HOME
IPAL52827: Very few filtering criteria available in filter dialog called from Remove...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshInfo.h
1 // Copyright (C) 2007-2015  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 //  File   : SMESHGUI_MeshInfo.h
23 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
24
25 #ifndef SMESHGUI_MESHINFO_H
26 #define SMESHGUI_MESHINFO_H
27
28 #include "SMESH_SMESHGUI.hxx"
29 #include "SMESH_ControlsDef.hxx"
30
31 #ifndef DISABLE_PLOT2DVIEWER
32   #include <Plot2d_Histogram.h>
33 #else
34   #include <qwt_plot.h>
35 #endif
36
37 #include <QFrame>
38 #include <QDialog>
39 #include <QList>
40 #include <QMap>
41 #include <QSet>
42 #include <QTreeWidget>
43 #include <QVector>
44
45 #include <SALOMEconfig.h>
46 #include CORBA_SERVER_HEADER(SMESH_Mesh)
47 #include CORBA_SERVER_HEADER(SMESH_Group)
48 #include CORBA_SERVER_HEADER(SMESH_Filter)
49
50 #include <SALOME_InteractiveObject.hxx>
51 #include <SALOME_GenericObj_wrap.hxx>
52
53 class QAbstractButton;
54 class QButtonGroup;
55 class QContextMenuEvent;
56 class QLabel;
57 class QLineEdit;
58 class QPushButton;
59 class QTabWidget;
60 class QTextBrowser;
61 class QGridLayout;
62 class SMESH_Actor;
63 class SMDS_MeshNode;
64 class SMDS_MeshElement;
65 class SMESHGUI_SpinBox;
66
67 class ExtraWidget;
68
69 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
70 {
71   Q_OBJECT;
72   
73   enum {
74     iName,
75     iObject,
76     iNodesStart,
77     iNodes,
78     iNodesEnd,
79     iElementsStart = iNodesEnd, 
80     iElements,
81     iNbStart,
82     iNb,
83     iNbEnd,
84     i0DStart = iNbEnd,
85     i0D,
86     i0DEnd,
87     iBallsStart = i0DEnd,
88     iBalls,
89     iBallsEnd,
90     i1DStart       = iBallsEnd,
91     i1D,
92     i1DEnd,
93     i2DStart       = i1DEnd,
94     i2D,
95     i2DTriangles,
96     i2DQuadrangles,
97     i2DPolygons,
98     i2DEnd,
99     i3DStart       = i2DEnd,
100     i3D,
101     i3DTetrahedrons,
102     i3DHexahedrons,
103     i3DPyramids,
104     i3DPrisms,
105     i3DHexaPrisms,
106     i3DPolyhedrons,
107     i3DEnd,
108     iElementsEnd   = i3DEnd
109   };
110
111   enum {
112     iSingle = 1,
113     iTotal  = iSingle,
114     iLinear,
115     iQuadratic,
116     iBiQuadratic
117   };
118
119   typedef QList<QWidget*> wlist;
120   typedef QVector<wlist>  iwlist;
121
122 public:
123   SMESHGUI_MeshInfo( QWidget* = 0 );
124   ~SMESHGUI_MeshInfo();
125
126   void     showInfo( SMESH::SMESH_IDSource_ptr );
127   void     clear();
128   void     saveInfo( QTextStream &out );
129
130 private:
131   enum { Bold = 0x01, Italic = 0x02 };
132
133   QLabel*  createField();
134   QWidget* createLine();
135   void     setFontAttributes( QWidget*, int, bool = true );
136   void     setFieldsVisible( int, int, bool );
137
138 private slots:
139   void loadMesh();
140
141 private:
142   iwlist       myWidgets;
143   QPushButton* myLoadBtn;
144 };
145
146 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
147 {
148   Q_OBJECT;
149
150 public:
151   SMESHGUI_ElemInfo( QWidget* = 0 );
152   ~SMESHGUI_ElemInfo();
153
154   void         setSource( SMESH_Actor* );
155   void         showInfo( long, bool );
156   void         showInfo( QSet<long>, bool );
157   void         clear();
158   virtual void saveInfo( QTextStream &out ) = 0;
159
160 protected:
161   struct XYZ
162   {
163     double myX, myY, myZ;
164     XYZ() { myX = myY = myZ = 0.0; }
165     XYZ(double x, double y, double z) { myX = x; myY = y; myZ = z; }
166     void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
167     void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
168     double x() const  { return myX; }
169     double y() const  { return myY; }
170     double z() const  { return myZ; }
171   };
172   typedef QMap< int, QList<int> > Connectivity;
173
174   QWidget*     frame() const;
175   SMESH_Actor* actor() const;
176   bool         isElements() const;
177
178   virtual void information( const QList<long>& ) = 0;
179   virtual void clearInternal();
180
181   Connectivity nodeConnectivity( const SMDS_MeshNode* );
182   QString      formatConnectivity( Connectivity, int );
183   XYZ          gravityCenter( const SMDS_MeshElement* );
184   XYZ          normal( const SMDS_MeshElement* );
185
186 signals:
187   void         itemInfo( int );
188   void         itemInfo( const QString& );
189
190 private slots:
191   void         showPrevious();
192   void         showNext();
193   void         updateControls();
194
195 private:
196   SMESH_Actor*     myActor;
197   QList<long>      myIDs;
198   int              myIsElement;
199   QWidget*         myFrame;
200   ExtraWidget*     myExtra;
201   int              myIndex;
202 };
203
204 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
205 {
206   Q_OBJECT
207
208 public:
209   SMESHGUI_SimpleElemInfo( QWidget* = 0 );
210   void          saveInfo( QTextStream &out );
211
212 protected:
213   void          information( const QList<long>& );
214   void          clearInternal();
215
216 private:
217   QTextBrowser* myInfo;
218 };
219
220 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
221 {
222   Q_OBJECT;
223
224   class ItemDelegate;
225
226   enum { Bold = 0x01, All = 0x80 };
227
228 public:
229   SMESHGUI_TreeElemInfo( QWidget* = 0 );
230   void             saveInfo( QTextStream &out );
231
232 protected:
233   void             contextMenuEvent( QContextMenuEvent* e );
234   void             information( const QList<long>& );
235   void             nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
236   void             clearInternal();
237
238 private slots:
239   void             itemDoubleClicked( QTreeWidgetItem*, int );
240   
241 private:
242   QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
243   
244 private:
245   QTreeWidget*     myInfo;
246 };
247
248 class GrpComputor: public QObject
249 {
250   Q_OBJECT;
251
252 public:
253   GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject*, bool = false);
254   QTreeWidgetItem* getItem() { return myItem; }
255
256 public slots:
257   void compute();
258
259 private:
260   SMESH::SMESH_GroupBase_var myGroup;
261   QTreeWidgetItem*           myItem;
262   bool                       myToComputeSize;
263 };
264
265 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
266 {
267   Q_OBJECT;
268
269   enum { Bold = 0x01, All = 0x80 };
270
271 public:
272   SMESHGUI_AddInfo( QWidget* = 0 );
273   ~SMESHGUI_AddInfo();
274
275   void             showInfo( SMESH::SMESH_IDSource_ptr );
276   //  void             clear();
277   void             saveInfo( QTextStream &out );
278
279 private slots:
280   void             changeLoadToCompute();
281   void             showPreviousGroups();
282   void             showNextGroups();
283   void             showPreviousSubMeshes();
284   void             showNextSubMeshes();
285
286 private:
287   QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
288   void             meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
289   void             subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
290   void             groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
291
292   void             showGroups();
293   void             showSubMeshes();
294
295 private:
296   QList<GrpComputor*>      myComputors;
297   SMESH::ListOfGroups_var  myGroups;
298   SMESH::submesh_array_var mySubMeshes;
299 };
300
301 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
302 {
303   Q_OBJECT;
304
305 public:
306   SMESHGUI_CtrlInfo( QWidget* = 0 );
307   ~SMESHGUI_CtrlInfo();
308
309   void                  showInfo( SMESH::SMESH_IDSource_ptr );
310   void                  saveInfo( QTextStream &out );
311
312 private:
313   enum ObjectType { Mesh, SubMesh, Group };
314   QLabel*               createField();
315   QwtPlot*              createPlot( QWidget* );
316   void                  setFontAttributes( QWidget* );
317   void                  clearInternal();
318 #ifndef DISABLE_PLOT2DVIEWER
319   Plot2d_Histogram*     getHistogram( SMESH::NumericalFunctor_ptr functor );
320 #endif
321   void                  computeNb( int ft, int iBut, int iWdg );
322
323 private slots:
324   void                  computeAspectRatio();
325   void                  computeAspectRatio3D();
326   void                  computeFreeNodesInfo();
327   void                  computeDoubleNodesInfo();
328   void                  computeDoubleEdgesInfo();
329   void                  computeDoubleFacesInfo();
330   void                  computeOverConstrainedFacesInfo();
331   void                  computeDoubleVolumesInfo();
332   void                  computeOverConstrainedVolumesInfo();
333   void                  setTolerance( const double theTolerance );
334   
335
336 private:
337   typedef SALOME::GenericObj_wrap< SMESH::Predicate >        TPredicate;
338   typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
339   SMESH::SMESH_IDSource_var myObject;
340   ObjectType                myObjectType;
341   SMESHGUI_SpinBox*         myToleranceWidget;
342   QList<QLabel*>            myWidgets;
343   QGridLayout*              myMainLayout;
344   QwtPlot*                  myPlot;
345   QwtPlot*                  myPlot3D;
346   QList<QAbstractButton*>   myButtons;
347   QList<TPredicate>         myPredicates;
348   TNumFunctor               myAspectRatio, myAspectRatio3D;
349 };
350
351 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
352
353   Q_OBJECT;
354
355   enum { NodeMode, ElemMode };
356
357 public:
358   //! Information type
359   enum { 
360     BaseInfo,  //!< base mesh information
361     ElemInfo,  //!< mesh element information
362     AddInfo,   //!< additional information
363     CtrlInfo //!< controls information
364   };
365
366   SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
367   ~SMESHGUI_MeshInfoDlg();
368
369   void showInfo( const Handle(SALOME_InteractiveObject)& );
370   void reject();
371
372 protected:
373   void keyPressEvent( QKeyEvent* );
374   void enterEvent( QEvent* );
375
376 private slots:
377   void help();
378   void updateSelection();
379   void updateInfo();
380   void activate();
381   void deactivate();
382   void modeChanged();
383   void idChanged();
384   void showItemInfo( int );
385   void showItemInfo( const QString& );
386   void dump();
387
388 private:
389   QTabWidget*        myTabWidget;
390   SMESHGUI_MeshInfo* myBaseInfo;
391   QButtonGroup*      myMode;
392   QLineEdit*         myID;
393   SMESHGUI_ElemInfo* myElemInfo;   
394   SMESHGUI_AddInfo*  myAddInfo;
395   SMESHGUI_CtrlInfo* myCtrlInfo;
396   SMESH_Actor*       myActor;
397 };
398
399 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
400
401   Q_OBJECT;
402
403 public:
404   SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
405   ~SMESHGUI_CtrlInfoDlg();
406
407   void showInfo( const Handle(SALOME_InteractiveObject)& );
408   void reject();
409
410 private slots:
411   void updateInfo();
412   void activate();
413   void deactivate();
414   void updateSelection();
415   void help();
416   void dump();
417
418 private:
419   SMESHGUI_CtrlInfo*  myCtrlInfo;
420 };
421
422 #endif // SMESHGUI_MESHINFO_H