1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI_MeshInfo.h
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 #ifndef SMESHGUI_MESHINFO_H
26 #define SMESHGUI_MESHINFO_H
28 #include "SMESH_SMESHGUI.hxx"
29 #include <SALOME_InteractiveObject.hxx>
30 #include "SMESH_ControlsDef.hxx"
32 #include <Plot2d_Histogram.h>
39 #include <QTreeWidget>
42 #include <SALOMEconfig.h>
43 #include CORBA_SERVER_HEADER(SMESH_Mesh)
44 #include CORBA_SERVER_HEADER(SMESH_Group)
46 class QAbstractButton;
48 class QContextMenuEvent;
57 class SMDS_MeshElement;
58 class SMESHGUI_SpinBox;
62 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
72 iElementsStart = iNodesEnd,
101 iElementsEnd = i3DEnd
111 typedef QList<QWidget*> wlist;
112 typedef QVector<wlist> iwlist;
115 SMESHGUI_MeshInfo( QWidget* = 0 );
116 ~SMESHGUI_MeshInfo();
118 void showInfo( SMESH::SMESH_IDSource_ptr );
120 void saveInfo( QTextStream &out );
123 enum { Bold = 0x01, Italic = 0x02 };
125 QLabel* createField();
126 QWidget* createLine();
127 void setFontAttributes( QWidget*, int, bool = true );
128 void setFieldsVisible( int, int, bool );
135 QPushButton* myLoadBtn;
138 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
143 SMESHGUI_ElemInfo( QWidget* = 0 );
144 ~SMESHGUI_ElemInfo();
146 void setSource( SMESH_Actor* );
147 void showInfo( long, bool );
148 void showInfo( QSet<long>, bool );
150 virtual void saveInfo( QTextStream &out ) = 0;
155 double myX, myY, myZ;
156 XYZ() { myX = myY = myZ = 0.0; }
157 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
158 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
159 double x() const { return myX; }
160 double y() const { return myY; }
161 double z() const { return myZ; }
163 typedef QMap< int, QList<int> > Connectivity;
165 QWidget* frame() const;
166 SMESH_Actor* actor() const;
167 bool isElements() const;
169 virtual void information( const QList<long>& ) = 0;
170 virtual void clearInternal();
172 Connectivity nodeConnectivity( const SMDS_MeshNode* );
173 QString formatConnectivity( Connectivity, int );
174 XYZ gravityCenter( const SMDS_MeshElement* );
177 void itemInfo( int );
178 void itemInfo( const QString& );
183 void updateControls();
186 SMESH_Actor* myActor;
190 ExtraWidget* myExtra;
194 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
199 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
200 void saveInfo( QTextStream &out );
203 void information( const QList<long>& );
204 void clearInternal();
207 QTextBrowser* myInfo;
210 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
216 enum { Bold = 0x01, All = 0x80 };
219 SMESHGUI_TreeElemInfo( QWidget* = 0 );
220 void saveInfo( QTextStream &out );
223 void contextMenuEvent( QContextMenuEvent* e );
224 void information( const QList<long>& );
225 void clearInternal();
228 void itemDoubleClicked( QTreeWidgetItem*, int );
231 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
237 class GrpComputor: public QObject
242 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
243 QTreeWidgetItem* getItem() { return myItem; }
249 SMESH::SMESH_GroupBase_var myGroup;
250 QTreeWidgetItem* myItem;
253 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
257 enum { Bold = 0x01, All = 0x80 };
260 SMESHGUI_AddInfo( QWidget* = 0 );
263 void showInfo( SMESH::SMESH_IDSource_ptr );
265 void saveInfo( QTextStream &out );
268 void changeLoadToCompute();
269 void showPreviousGroups();
270 void showNextGroups();
271 void showPreviousSubMeshes();
272 void showNextSubMeshes();
275 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
276 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
277 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
278 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
281 void showSubMeshes();
284 QList<GrpComputor*> myComputors;
285 SMESH::ListOfGroups_var myGroups;
286 SMESH::submesh_array_var mySubMeshes;
289 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
294 SMESHGUI_CtrlInfo( QWidget* = 0 );
295 ~SMESHGUI_CtrlInfo();
297 void showInfo( SMESH::SMESH_IDSource_ptr );
298 void saveInfo( QTextStream &out );
301 enum ObjectType { Mesh, SubMesh, Group };
302 QLabel* createField();
303 QwtPlot* createPlot( QWidget* );
304 void setFontAttributes( QWidget* );
305 void clearInternal();
306 SMESH::long_array_var getElementsByType( SMESH::ElementType theElementType );
307 int nbElemsControl( SMESH::long_array_var&, SMESH::Controls::FunctorPtr );
308 Plot2d_Histogram* getHistogram( SMESH::long_array_var&, SMESH::Controls::NumericalFunctorPtr );
311 void computeFaceInfo();
312 void computeVolumeInfo();
313 void computeFreeNodesInfo();
314 void computeDoubleNodesInfo();
315 void computeDoubleEdgesInfo();
316 void computeDoubleFacesInfo();
317 void computeOverConstrainedFacesInfo();
318 void computeDoubleVolumesInfo();
319 void computeOverConstrainedVolumesInfo();
320 void setTolerance( const double theTolerance );
323 SMESH_Actor* myActor;
324 ObjectType myObjectType;
325 SMESHGUI_SpinBox* myToleranceWidget;
326 QList<QLabel*> myWidgets;
327 QGridLayout* myMainLayout;
330 QList<QAbstractButton*> myButtons;
333 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
337 enum { NodeMode, ElemMode };
342 BaseInfo, //!< base mesh information
343 ElemInfo, //!< mesh element information
344 AddInfo, //!< additional information
345 CtrlInfo //!< controls information
348 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
349 ~SMESHGUI_MeshInfoDlg();
351 void showInfo( const Handle(SALOME_InteractiveObject)& );
355 void keyPressEvent( QKeyEvent* );
356 void enterEvent( QEvent* );
360 void updateSelection();
366 void showItemInfo( int );
367 void showItemInfo( const QString& );
371 QTabWidget* myTabWidget;
372 SMESHGUI_MeshInfo* myBaseInfo;
373 QButtonGroup* myMode;
375 SMESHGUI_ElemInfo* myElemInfo;
376 SMESHGUI_AddInfo* myAddInfo;
377 SMESHGUI_CtrlInfo* myCtrlInfo;
378 SMESH_Actor* myActor;
381 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
386 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
387 ~SMESHGUI_CtrlInfoDlg();
389 void showInfo( const Handle(SALOME_InteractiveObject)& );
396 void updateSelection();
399 SMESHGUI_CtrlInfo* myCtrlInfo;
402 #endif // SMESHGUI_MESHINFO_H