1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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 "SMESH_ControlsDef.hxx"
31 #include <Plot2d_Histogram.h>
38 #include <QTreeWidget>
41 #include <SALOMEconfig.h>
42 #include CORBA_SERVER_HEADER(SMESH_Mesh)
43 #include CORBA_SERVER_HEADER(SMESH_Group)
44 #include CORBA_SERVER_HEADER(SMESH_Filter)
46 #include <SALOME_InteractiveObject.hxx>
47 #include <SALOME_GenericObj_wrap.hxx>
49 class QAbstractButton;
51 class QContextMenuEvent;
60 class SMDS_MeshElement;
61 class SMESHGUI_SpinBox;
65 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
75 iElementsStart = iNodesEnd,
104 iElementsEnd = i3DEnd
115 typedef QList<QWidget*> wlist;
116 typedef QVector<wlist> iwlist;
119 SMESHGUI_MeshInfo( QWidget* = 0 );
120 ~SMESHGUI_MeshInfo();
122 void showInfo( SMESH::SMESH_IDSource_ptr );
124 void saveInfo( QTextStream &out );
127 enum { Bold = 0x01, Italic = 0x02 };
129 QLabel* createField();
130 QWidget* createLine();
131 void setFontAttributes( QWidget*, int, bool = true );
132 void setFieldsVisible( int, int, bool );
139 QPushButton* myLoadBtn;
142 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
147 SMESHGUI_ElemInfo( QWidget* = 0 );
148 ~SMESHGUI_ElemInfo();
150 void setSource( SMESH_Actor* );
151 void showInfo( long, bool );
152 void showInfo( QSet<long>, bool );
154 virtual void saveInfo( QTextStream &out ) = 0;
159 double myX, myY, myZ;
160 XYZ() { myX = myY = myZ = 0.0; }
161 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
162 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
163 double x() const { return myX; }
164 double y() const { return myY; }
165 double z() const { return myZ; }
167 typedef QMap< int, QList<int> > Connectivity;
169 QWidget* frame() const;
170 SMESH_Actor* actor() const;
171 bool isElements() const;
173 virtual void information( const QList<long>& ) = 0;
174 virtual void clearInternal();
176 Connectivity nodeConnectivity( const SMDS_MeshNode* );
177 QString formatConnectivity( Connectivity, int );
178 XYZ gravityCenter( const SMDS_MeshElement* );
181 void itemInfo( int );
182 void itemInfo( const QString& );
187 void updateControls();
190 SMESH_Actor* myActor;
194 ExtraWidget* myExtra;
198 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
203 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
204 void saveInfo( QTextStream &out );
207 void information( const QList<long>& );
208 void clearInternal();
211 QTextBrowser* myInfo;
214 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
220 enum { Bold = 0x01, All = 0x80 };
223 SMESHGUI_TreeElemInfo( QWidget* = 0 );
224 void saveInfo( QTextStream &out );
227 void contextMenuEvent( QContextMenuEvent* e );
228 void information( const QList<long>& );
229 void clearInternal();
232 void itemDoubleClicked( QTreeWidgetItem*, int );
235 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
241 class GrpComputor: public QObject
246 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
247 QTreeWidgetItem* getItem() { return myItem; }
253 SMESH::SMESH_GroupBase_var myGroup;
254 QTreeWidgetItem* myItem;
257 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
261 enum { Bold = 0x01, All = 0x80 };
264 SMESHGUI_AddInfo( QWidget* = 0 );
267 void showInfo( SMESH::SMESH_IDSource_ptr );
269 void saveInfo( QTextStream &out );
272 void changeLoadToCompute();
273 void showPreviousGroups();
274 void showNextGroups();
275 void showPreviousSubMeshes();
276 void showNextSubMeshes();
279 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
280 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
281 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
282 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
285 void showSubMeshes();
288 QList<GrpComputor*> myComputors;
289 SMESH::ListOfGroups_var myGroups;
290 SMESH::submesh_array_var mySubMeshes;
293 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
298 SMESHGUI_CtrlInfo( QWidget* = 0 );
299 ~SMESHGUI_CtrlInfo();
301 void showInfo( SMESH::SMESH_IDSource_ptr );
302 void saveInfo( QTextStream &out );
305 enum ObjectType { Mesh, SubMesh, Group };
306 QLabel* createField();
307 QwtPlot* createPlot( QWidget* );
308 void setFontAttributes( QWidget* );
309 void clearInternal();
310 Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor );
311 void computeNb( int ft, int iBut, int iWdg );
314 void computeAspectRatio();
315 void computeAspectRatio3D();
316 void computeFreeNodesInfo();
317 void computeDoubleNodesInfo();
318 void computeDoubleEdgesInfo();
319 void computeDoubleFacesInfo();
320 void computeOverConstrainedFacesInfo();
321 void computeDoubleVolumesInfo();
322 void computeOverConstrainedVolumesInfo();
323 void setTolerance( const double theTolerance );
327 typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
328 typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
329 SMESH::SMESH_IDSource_var myObject;
330 ObjectType myObjectType;
331 SMESHGUI_SpinBox* myToleranceWidget;
332 QList<QLabel*> myWidgets;
333 QGridLayout* myMainLayout;
336 QList<QAbstractButton*> myButtons;
337 QList<TPredicate> myPredicates;
338 TNumFunctor myAspectRatio, myAspectRatio3D;
341 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
345 enum { NodeMode, ElemMode };
350 BaseInfo, //!< base mesh information
351 ElemInfo, //!< mesh element information
352 AddInfo, //!< additional information
353 CtrlInfo //!< controls information
356 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
357 ~SMESHGUI_MeshInfoDlg();
359 void showInfo( const Handle(SALOME_InteractiveObject)& );
363 void keyPressEvent( QKeyEvent* );
364 void enterEvent( QEvent* );
368 void updateSelection();
374 void showItemInfo( int );
375 void showItemInfo( const QString& );
379 QTabWidget* myTabWidget;
380 SMESHGUI_MeshInfo* myBaseInfo;
381 QButtonGroup* myMode;
383 SMESHGUI_ElemInfo* myElemInfo;
384 SMESHGUI_AddInfo* myAddInfo;
385 SMESHGUI_CtrlInfo* myCtrlInfo;
386 SMESH_Actor* myActor;
389 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
394 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
395 ~SMESHGUI_CtrlInfoDlg();
397 void showInfo( const Handle(SALOME_InteractiveObject)& );
404 void updateSelection();
409 SMESHGUI_CtrlInfo* myCtrlInfo;
412 #endif // SMESHGUI_MESHINFO_H