1 // Copyright (C) 2007-2015 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 #ifndef DISABLE_PLOT2DVIEWER
32 #include <Plot2d_Histogram.h>
42 #include <QTreeWidget>
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)
50 #include <SALOME_InteractiveObject.hxx>
51 #include <SALOME_GenericObj_wrap.hxx>
53 class QAbstractButton;
55 class QContextMenuEvent;
64 class SMDS_MeshElement;
65 class SMESHGUI_SpinBox;
69 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
79 iElementsStart = iNodesEnd,
108 iElementsEnd = i3DEnd
119 typedef QList<QWidget*> wlist;
120 typedef QVector<wlist> iwlist;
123 SMESHGUI_MeshInfo( QWidget* = 0 );
124 ~SMESHGUI_MeshInfo();
126 void showInfo( SMESH::SMESH_IDSource_ptr );
128 void saveInfo( QTextStream &out );
131 enum { Bold = 0x01, Italic = 0x02 };
133 QLabel* createField();
134 QWidget* createLine();
135 void setFontAttributes( QWidget*, int, bool = true );
136 void setFieldsVisible( int, int, bool );
143 QPushButton* myLoadBtn;
146 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
151 SMESHGUI_ElemInfo( QWidget* = 0 );
152 ~SMESHGUI_ElemInfo();
154 void setSource( SMESH_Actor* );
155 void showInfo( long, bool );
156 void showInfo( QSet<long>, bool );
158 virtual void saveInfo( QTextStream &out ) = 0;
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; }
172 typedef QMap< int, QList<int> > Connectivity;
174 QWidget* frame() const;
175 SMESH_Actor* actor() const;
176 bool isElements() const;
178 virtual void information( const QList<long>& ) = 0;
179 virtual void clearInternal();
181 Connectivity nodeConnectivity( const SMDS_MeshNode* );
182 QString formatConnectivity( Connectivity, int );
183 XYZ gravityCenter( const SMDS_MeshElement* );
184 XYZ normal( const SMDS_MeshElement* );
187 void itemInfo( int );
188 void itemInfo( const QString& );
193 void updateControls();
196 SMESH_Actor* myActor;
200 ExtraWidget* myExtra;
204 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
209 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
210 void saveInfo( QTextStream &out );
213 void information( const QList<long>& );
214 void clearInternal();
217 QTextBrowser* myInfo;
220 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
226 enum { Bold = 0x01, All = 0x80 };
229 SMESHGUI_TreeElemInfo( QWidget* = 0 );
230 void saveInfo( QTextStream &out );
233 void contextMenuEvent( QContextMenuEvent* e );
234 void information( const QList<long>& );
235 void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
236 void clearInternal();
239 void itemDoubleClicked( QTreeWidgetItem*, int );
242 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
248 class GrpComputor: public QObject
253 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
254 QTreeWidgetItem* getItem() { return myItem; }
260 SMESH::SMESH_GroupBase_var myGroup;
261 QTreeWidgetItem* myItem;
264 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
268 enum { Bold = 0x01, All = 0x80 };
271 SMESHGUI_AddInfo( QWidget* = 0 );
274 void showInfo( SMESH::SMESH_IDSource_ptr );
276 void saveInfo( QTextStream &out );
279 void changeLoadToCompute();
280 void showPreviousGroups();
281 void showNextGroups();
282 void showPreviousSubMeshes();
283 void showNextSubMeshes();
286 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
287 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
288 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
289 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
292 void showSubMeshes();
295 QList<GrpComputor*> myComputors;
296 SMESH::ListOfGroups_var myGroups;
297 SMESH::submesh_array_var mySubMeshes;
300 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
305 SMESHGUI_CtrlInfo( QWidget* = 0 );
306 ~SMESHGUI_CtrlInfo();
308 void showInfo( SMESH::SMESH_IDSource_ptr );
309 void saveInfo( QTextStream &out );
312 enum ObjectType { Mesh, SubMesh, Group };
313 QLabel* createField();
314 QwtPlot* createPlot( QWidget* );
315 void setFontAttributes( QWidget* );
316 void clearInternal();
317 #ifndef DISABLE_PLOT2DVIEWER
318 Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor );
320 void computeNb( int ft, int iBut, int iWdg );
323 void computeAspectRatio();
324 void computeAspectRatio3D();
325 void computeFreeNodesInfo();
326 void computeDoubleNodesInfo();
327 void computeDoubleEdgesInfo();
328 void computeDoubleFacesInfo();
329 void computeOverConstrainedFacesInfo();
330 void computeDoubleVolumesInfo();
331 void computeOverConstrainedVolumesInfo();
332 void setTolerance( const double theTolerance );
336 typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
337 typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
338 SMESH::SMESH_IDSource_var myObject;
339 ObjectType myObjectType;
340 SMESHGUI_SpinBox* myToleranceWidget;
341 QList<QLabel*> myWidgets;
342 QGridLayout* myMainLayout;
345 QList<QAbstractButton*> myButtons;
346 QList<TPredicate> myPredicates;
347 TNumFunctor myAspectRatio, myAspectRatio3D;
350 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
354 enum { NodeMode, ElemMode };
359 BaseInfo, //!< base mesh information
360 ElemInfo, //!< mesh element information
361 AddInfo, //!< additional information
362 CtrlInfo //!< controls information
365 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
366 ~SMESHGUI_MeshInfoDlg();
368 void showInfo( const Handle(SALOME_InteractiveObject)& );
372 void keyPressEvent( QKeyEvent* );
373 void enterEvent( QEvent* );
377 void updateSelection();
383 void showItemInfo( int );
384 void showItemInfo( const QString& );
388 QTabWidget* myTabWidget;
389 SMESHGUI_MeshInfo* myBaseInfo;
390 QButtonGroup* myMode;
392 SMESHGUI_ElemInfo* myElemInfo;
393 SMESHGUI_AddInfo* myAddInfo;
394 SMESHGUI_CtrlInfo* myCtrlInfo;
395 SMESH_Actor* myActor;
398 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
403 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
404 ~SMESHGUI_CtrlInfoDlg();
406 void showInfo( const Handle(SALOME_InteractiveObject)& );
413 void updateSelection();
418 SMESHGUI_CtrlInfo* myCtrlInfo;
421 #endif // SMESHGUI_MESHINFO_H