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 #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 XYZ(double x, double y, double z) { myX = x; myY = y; myZ = z; }
162 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
163 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
164 double x() const { return myX; }
165 double y() const { return myY; }
166 double z() const { return myZ; }
168 typedef QMap< int, QList<int> > Connectivity;
170 QWidget* frame() const;
171 SMESH_Actor* actor() const;
172 bool isElements() const;
174 virtual void information( const QList<long>& ) = 0;
175 virtual void clearInternal();
177 Connectivity nodeConnectivity( const SMDS_MeshNode* );
178 QString formatConnectivity( Connectivity, int );
179 XYZ gravityCenter( const SMDS_MeshElement* );
180 XYZ normal( const SMDS_MeshElement* );
183 void itemInfo( int );
184 void itemInfo( const QString& );
189 void updateControls();
192 SMESH_Actor* myActor;
196 ExtraWidget* myExtra;
200 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
205 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
206 void saveInfo( QTextStream &out );
209 void information( const QList<long>& );
210 void clearInternal();
213 QTextBrowser* myInfo;
216 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
222 enum { Bold = 0x01, All = 0x80 };
225 SMESHGUI_TreeElemInfo( QWidget* = 0 );
226 void saveInfo( QTextStream &out );
229 void contextMenuEvent( QContextMenuEvent* e );
230 void information( const QList<long>& );
231 void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
232 void clearInternal();
235 void itemDoubleClicked( QTreeWidgetItem*, int );
238 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
244 class GrpComputor: public QObject
249 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
250 QTreeWidgetItem* getItem() { return myItem; }
256 SMESH::SMESH_GroupBase_var myGroup;
257 QTreeWidgetItem* myItem;
260 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
264 enum { Bold = 0x01, All = 0x80 };
267 SMESHGUI_AddInfo( QWidget* = 0 );
270 void showInfo( SMESH::SMESH_IDSource_ptr );
272 void saveInfo( QTextStream &out );
275 void changeLoadToCompute();
276 void showPreviousGroups();
277 void showNextGroups();
278 void showPreviousSubMeshes();
279 void showNextSubMeshes();
282 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
283 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
284 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
285 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
288 void showSubMeshes();
291 QList<GrpComputor*> myComputors;
292 SMESH::ListOfGroups_var myGroups;
293 SMESH::submesh_array_var mySubMeshes;
296 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
301 SMESHGUI_CtrlInfo( QWidget* = 0 );
302 ~SMESHGUI_CtrlInfo();
304 void showInfo( SMESH::SMESH_IDSource_ptr );
305 void saveInfo( QTextStream &out );
308 enum ObjectType { Mesh, SubMesh, Group };
309 QLabel* createField();
310 QwtPlot* createPlot( QWidget* );
311 void setFontAttributes( QWidget* );
312 void clearInternal();
313 Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor );
314 void computeNb( int ft, int iBut, int iWdg );
317 void computeAspectRatio();
318 void computeAspectRatio3D();
319 void computeFreeNodesInfo();
320 void computeDoubleNodesInfo();
321 void computeDoubleEdgesInfo();
322 void computeDoubleFacesInfo();
323 void computeOverConstrainedFacesInfo();
324 void computeDoubleVolumesInfo();
325 void computeOverConstrainedVolumesInfo();
326 void setTolerance( const double theTolerance );
330 typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
331 typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
332 SMESH::SMESH_IDSource_var myObject;
333 ObjectType myObjectType;
334 SMESHGUI_SpinBox* myToleranceWidget;
335 QList<QLabel*> myWidgets;
336 QGridLayout* myMainLayout;
339 QList<QAbstractButton*> myButtons;
340 QList<TPredicate> myPredicates;
341 TNumFunctor myAspectRatio, myAspectRatio3D;
344 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
348 enum { NodeMode, ElemMode };
353 BaseInfo, //!< base mesh information
354 ElemInfo, //!< mesh element information
355 AddInfo, //!< additional information
356 CtrlInfo //!< controls information
359 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
360 ~SMESHGUI_MeshInfoDlg();
362 void showInfo( const Handle(SALOME_InteractiveObject)& );
366 void keyPressEvent( QKeyEvent* );
367 void enterEvent( QEvent* );
371 void updateSelection();
377 void showItemInfo( int );
378 void showItemInfo( const QString& );
382 QTabWidget* myTabWidget;
383 SMESHGUI_MeshInfo* myBaseInfo;
384 QButtonGroup* myMode;
386 SMESHGUI_ElemInfo* myElemInfo;
387 SMESHGUI_AddInfo* myAddInfo;
388 SMESHGUI_CtrlInfo* myCtrlInfo;
389 SMESH_Actor* myActor;
392 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
397 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
398 ~SMESHGUI_CtrlInfoDlg();
400 void showInfo( const Handle(SALOME_InteractiveObject)& );
407 void updateSelection();
412 SMESHGUI_CtrlInfo* myCtrlInfo;
415 #endif // SMESHGUI_MESHINFO_H