Version: 8.3.0
SMESHGUI_MeshInfo.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 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 QCheckBox;
56 class QContextMenuEvent;
57 class QGridLayout;
58 class QLabel;
59 class QLineEdit;
60 class QPushButton;
61 class QTabWidget;
62 class QTextBrowser;
63 class SMDS_MeshElement;
64 class SMDS_MeshNode;
65 class SMESHGUI_IdPreview;
66 class SMESHGUI_SpinBox;
67 class SMESH_Actor;
68 
69 class ExtraWidget;
70 
72 {
73  Q_OBJECT;
74 
75  enum {
81  iElementsStart = iNodesEnd,
84  iNb,
86  i0DStart = iNbEnd,
87  i0D,
89  iBallsStart = i0DEnd,
92  i1DStart = iBallsEnd,
93  i1D,
95  i2DStart = i1DEnd,
96  i2D,
101  i3DStart = i2DEnd,
110  iElementsEnd = i3DEnd
111  };
112 
113  enum {
114  iSingle = 1,
115  iTotal = iSingle,
118  iBiQuadratic
119  };
120 
121  typedef QList<QWidget*> wlist;
122  typedef QVector<wlist> iwlist;
123 
124 public:
125  SMESHGUI_MeshInfo( QWidget* = 0 );
127 
128  void showInfo( SMESH::SMESH_IDSource_ptr );
129  void clear();
130  void saveInfo( QTextStream &out );
131 
132 private:
133  enum { Bold = 0x01, Italic = 0x02 };
134 
135  QLabel* createField();
136  QWidget* createLine();
137  void setFontAttributes( QWidget*, int, bool = true );
138  void setFieldsVisible( int, int, bool );
139 
140 private slots:
141  void loadMesh();
142 
143 private:
145  QPushButton* myLoadBtn;
146 };
147 
149 {
150  Q_OBJECT;
151 
152 public:
153  SMESHGUI_ElemInfo( QWidget* = 0 );
155 
156  void setSource( SMESH_Actor* );
157  void showInfo( long, bool );
158  void showInfo( QSet<long>, bool );
159  void clear();
160  virtual void saveInfo( QTextStream &out ) = 0;
161 
162  gp_XYZ getGravityCenter( const SMDS_MeshElement* e ) { return gravityCenter(e); }
163 
164 protected:
165  struct XYZ
166  {
167  double myX, myY, myZ;
168  XYZ() { myX = myY = myZ = 0.0; }
169  XYZ(double x, double y, double z) { myX = x; myY = y; myZ = z; }
170  void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
171  void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
172  double x() const { return myX; }
173  double y() const { return myY; }
174  double z() const { return myZ; }
175  operator gp_XYZ() const { return gp_XYZ( myX, myY, myZ ); }
176  };
177  typedef QMap< int, QList<int> > Connectivity;
178 
179  QWidget* frame() const;
180  SMESH_Actor* actor() const;
181  bool isElements() const;
182 
183  virtual void information( const QList<long>& ) = 0;
184  virtual void clearInternal();
185 
186  Connectivity nodeConnectivity( const SMDS_MeshNode* );
187  QString formatConnectivity( Connectivity, int );
188  XYZ gravityCenter( const SMDS_MeshElement* );
189  XYZ normal( const SMDS_MeshElement* );
190 
191 signals:
192  void itemInfo( int );
193  void itemInfo( const QString& );
194 
195 private slots:
196  void showPrevious();
197  void showNext();
198  void updateControls();
199 
200 private:
202  QList<long> myIDs;
206  int myIndex;
207 };
208 
210 {
211  Q_OBJECT
212 
213 public:
215  void saveInfo( QTextStream &out );
216 
217 protected:
218  void information( const QList<long>& );
219  void clearInternal();
220 
221 private:
222  QTextBrowser* myInfo;
223 };
224 
226 {
227  Q_OBJECT;
228 
229  class ItemDelegate;
230 
231  enum { Bold = 0x01, All = 0x80 };
232 
233 public:
235  void saveInfo( QTextStream &out );
236 
237 protected:
238  void contextMenuEvent( QContextMenuEvent* e );
239  void information( const QList<long>& );
240  void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
241  void clearInternal();
242 
243 private slots:
244  void itemDoubleClicked( QTreeWidgetItem*, int );
245  void saveExpanded( QTreeWidgetItem* );
246 
247 private:
248  QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
249  QString expandedResource( QTreeWidgetItem* );
250 
251 private:
253 };
254 
255 class GrpComputor: public QObject
256 {
257  Q_OBJECT;
258 
259 public:
260  GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject*, bool = false);
261  QTreeWidgetItem* getItem() { return myItem; }
262 
263 public slots:
264  void compute();
265 
266 private:
267  SMESH::SMESH_GroupBase_var myGroup;
268  QTreeWidgetItem* myItem;
270 };
271 
273 {
274  Q_OBJECT;
275 
276  enum { Bold = 0x01, All = 0x80 };
277 
278 public:
279  SMESHGUI_AddInfo( QWidget* = 0 );
280  ~SMESHGUI_AddInfo();
281 
282  void showInfo( SMESH::SMESH_IDSource_ptr );
283  // void clear();
284  void saveInfo( QTextStream &out );
285 
286 private slots:
287  void changeLoadToCompute();
288  void showPreviousGroups();
289  void showNextGroups();
290  void showPreviousSubMeshes();
291  void showNextSubMeshes();
292 
293 private:
294  QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
295  void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
296  void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
297  void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
298 
299  void showGroups();
300  void showSubMeshes();
301 
302 private:
303  QList<GrpComputor*> myComputors;
304  SMESH::ListOfGroups_var myGroups;
305  SMESH::submesh_array_var mySubMeshes;
306 };
307 
309 {
310  Q_OBJECT;
311 
312 public:
313  SMESHGUI_CtrlInfo( QWidget* = 0 );
315 
316  void showInfo( SMESH::SMESH_IDSource_ptr );
317  void saveInfo( QTextStream &out );
318 
319 private:
320  enum ObjectType { Mesh, SubMesh, Group };
321  QLabel* createField();
322  QwtPlot* createPlot( QWidget* );
323  void setFontAttributes( QWidget* );
324  void clearInternal();
325 #ifndef DISABLE_PLOT2DVIEWER
326  Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor );
327 #endif
328  void computeNb( int ft, int iBut, int iWdg );
329 
330 private slots:
331  void computeAspectRatio();
332  void computeAspectRatio3D();
333  void computeFreeNodesInfo();
334  void computeNodesNbConnInfo();
335  void computeDoubleNodesInfo();
336  void computeDoubleEdgesInfo();
337  void computeDoubleFacesInfo();
338  void computeOverConstrainedFacesInfo();
339  void computeDoubleVolumesInfo();
340  void computeOverConstrainedVolumesInfo();
341  void setTolerance( const double theTolerance );
342 
343 
344 private:
345  typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
346  typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
347  SMESH::SMESH_IDSource_var myObject;
350  QList<QLabel*> myWidgets;
351  QGridLayout* myMainLayout;
354  QList<QAbstractButton*> myButtons;
355  QList<TPredicate> myPredicates;
356  TNumFunctor myAspectRatio, myAspectRatio3D, myNodeConnFunctor;
357 };
358 
360 {
361  Q_OBJECT;
362 
363  enum { NodeMode, ElemMode };
364 
365 public:
367  enum {
371  CtrlInfo
372  };
373 
374  SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
376 
377  void showInfo( const Handle(SALOME_InteractiveObject)& );
378  void reject();
379 
380 protected:
381  void keyPressEvent( QKeyEvent* );
382  void enterEvent( QEvent* );
383 
384 private slots:
385  void help();
386  void updateSelection();
387  void updateInfo();
388  void activate();
389  void deactivate();
390  void modeChanged();
391  void idChanged();
392  void idPreviewChange(bool);
393  void showItemInfo( int );
394  void showItemInfo( const QString& );
395  void dump();
396 
397 private:
398  QTabWidget* myTabWidget;
400  QButtonGroup* myMode;
401  QLineEdit* myID;
402  QCheckBox* myIDPreviewCheck;
408  Handle(SALOME_InteractiveObject) myIO;
409 };
410 
412 {
413  Q_OBJECT;
414 
415 public:
418 
419  void showInfo( const Handle(SALOME_InteractiveObject)& );
420  void reject();
421 
422 private slots:
423  void updateInfo();
424  void activate();
425  void deactivate();
426  void updateSelection();
427  void help();
428  void dump();
429 
430 private:
432 };
433 
434 #endif // SMESHGUI_MESHINFO_H