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 "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
114 typedef QList<QWidget*> wlist;
115 typedef QVector<wlist> iwlist;
118 SMESHGUI_MeshInfo( QWidget* = 0 );
119 ~SMESHGUI_MeshInfo();
121 void showInfo( SMESH::SMESH_IDSource_ptr );
123 void saveInfo( QTextStream &out );
126 enum { Bold = 0x01, Italic = 0x02 };
128 QLabel* createField();
129 QWidget* createLine();
130 void setFontAttributes( QWidget*, int, bool = true );
131 void setFieldsVisible( int, int, bool );
138 QPushButton* myLoadBtn;
141 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
146 SMESHGUI_ElemInfo( QWidget* = 0 );
147 ~SMESHGUI_ElemInfo();
149 void setSource( SMESH_Actor* );
150 void showInfo( long, bool );
151 void showInfo( QSet<long>, bool );
153 virtual void saveInfo( QTextStream &out ) = 0;
158 double myX, myY, myZ;
159 XYZ() { myX = myY = myZ = 0.0; }
160 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
161 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
162 double x() const { return myX; }
163 double y() const { return myY; }
164 double z() const { return myZ; }
166 typedef QMap< int, QList<int> > Connectivity;
168 QWidget* frame() const;
169 SMESH_Actor* actor() const;
170 bool isElements() const;
172 virtual void information( const QList<long>& ) = 0;
173 virtual void clearInternal();
175 Connectivity nodeConnectivity( const SMDS_MeshNode* );
176 QString formatConnectivity( Connectivity, int );
177 XYZ gravityCenter( const SMDS_MeshElement* );
180 void itemInfo( int );
181 void itemInfo( const QString& );
186 void updateControls();
189 SMESH_Actor* myActor;
193 ExtraWidget* myExtra;
197 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
202 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
203 void saveInfo( QTextStream &out );
206 void information( const QList<long>& );
207 void clearInternal();
210 QTextBrowser* myInfo;
213 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
219 enum { Bold = 0x01, All = 0x80 };
222 SMESHGUI_TreeElemInfo( QWidget* = 0 );
223 void saveInfo( QTextStream &out );
226 void contextMenuEvent( QContextMenuEvent* e );
227 void information( const QList<long>& );
228 void clearInternal();
231 void itemDoubleClicked( QTreeWidgetItem*, int );
234 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
240 class GrpComputor: public QObject
245 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
246 QTreeWidgetItem* getItem() { return myItem; }
252 SMESH::SMESH_GroupBase_var myGroup;
253 QTreeWidgetItem* myItem;
256 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
260 enum { Bold = 0x01, All = 0x80 };
263 SMESHGUI_AddInfo( QWidget* = 0 );
266 void showInfo( SMESH::SMESH_IDSource_ptr );
268 void saveInfo( QTextStream &out );
271 void changeLoadToCompute();
272 void showPreviousGroups();
273 void showNextGroups();
274 void showPreviousSubMeshes();
275 void showNextSubMeshes();
278 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
279 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
280 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
281 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
284 void showSubMeshes();
287 QList<GrpComputor*> myComputors;
288 SMESH::ListOfGroups_var myGroups;
289 SMESH::submesh_array_var mySubMeshes;
292 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
297 SMESHGUI_CtrlInfo( QWidget* = 0 );
298 ~SMESHGUI_CtrlInfo();
300 void showInfo( SMESH::SMESH_IDSource_ptr );
301 void saveInfo( QTextStream &out );
304 enum ObjectType { Mesh, SubMesh, Group };
305 QLabel* createField();
306 QwtPlot* createPlot( QWidget* );
307 void setFontAttributes( QWidget* );
308 void clearInternal();
309 Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor );
310 void computeNb( int ft, int iBut, int iWdg );
313 void computeAspectRatio();
314 void computeAspectRatio3D();
315 void computeFreeNodesInfo();
316 void computeDoubleNodesInfo();
317 void computeDoubleEdgesInfo();
318 void computeDoubleFacesInfo();
319 void computeOverConstrainedFacesInfo();
320 void computeDoubleVolumesInfo();
321 void computeOverConstrainedVolumesInfo();
322 void setTolerance( const double theTolerance );
326 typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
327 typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
328 SMESH::SMESH_IDSource_var myObject;
329 ObjectType myObjectType;
330 SMESHGUI_SpinBox* myToleranceWidget;
331 QList<QLabel*> myWidgets;
332 QGridLayout* myMainLayout;
335 QList<QAbstractButton*> myButtons;
336 QList<TPredicate> myPredicates;
337 TNumFunctor myAspectRatio, myAspectRatio3D;
340 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
344 enum { NodeMode, ElemMode };
349 BaseInfo, //!< base mesh information
350 ElemInfo, //!< mesh element information
351 AddInfo, //!< additional information
352 CtrlInfo //!< controls information
355 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
356 ~SMESHGUI_MeshInfoDlg();
358 void showInfo( const Handle(SALOME_InteractiveObject)& );
362 void keyPressEvent( QKeyEvent* );
363 void enterEvent( QEvent* );
367 void updateSelection();
373 void showItemInfo( int );
374 void showItemInfo( const QString& );
378 QTabWidget* myTabWidget;
379 SMESHGUI_MeshInfo* myBaseInfo;
380 QButtonGroup* myMode;
382 SMESHGUI_ElemInfo* myElemInfo;
383 SMESHGUI_AddInfo* myAddInfo;
384 SMESHGUI_CtrlInfo* myCtrlInfo;
385 SMESH_Actor* myActor;
388 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
393 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
394 ~SMESHGUI_CtrlInfoDlg();
396 void showInfo( const Handle(SALOME_InteractiveObject)& );
403 void updateSelection();
408 SMESHGUI_CtrlInfo* myCtrlInfo;
411 #endif // SMESHGUI_MESHINFO_H