1 // Copyright (C) 2007-2016 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"
30 #include "SMESHGUI_SelectionProxy.h"
32 #ifndef DISABLE_PLOT2DVIEWER
33 #include <Plot2d_Histogram.h>
43 #include <SALOMEconfig.h>
44 #include CORBA_SERVER_HEADER(SMESH_Mesh)
45 #include CORBA_SERVER_HEADER(SMESH_Group)
46 #include CORBA_SERVER_HEADER(SMESH_Filter)
48 #include <SALOME_InteractiveObject.hxx>
49 #include <SALOME_GenericObj_wrap.hxx>
51 class QAbstractButton;
54 class QContextMenuEvent;
60 class QTreeWidgetItem;
61 class SMDS_MeshElement;
63 class SMESHGUI_IdPreview;
64 class SMESHGUI_SpinBox;
69 class SMESHGUI_EXPORT SMESHGUI_Info : public QWidget
72 SMESHGUI_Info( QWidget* = 0 );
74 virtual void saveInfo( QTextStream& ) = 0;
77 enum { Bold = 0x01, Italic = 0x02, AllColumns = 0x80 };
78 QFont fontFromOptions( int );
79 void setFontAttributes( QWidget*, int );
80 void setFontAttributes( QTreeWidgetItem*, int );
81 QLabel* createLabel( QWidget*, int = 0 );
82 QLabel* createLabel( const QString&, QWidget*, int = 0 );
83 QLabel* createField( QWidget*, const QString& = QString() );
84 QLabel* createField( QWidget*, int, const QString& = QString() );
85 QWidget* createSeparator( QWidget*, Qt::Orientation = Qt::Horizontal );
88 class SMESHGUI_EXPORT SMESHGUI_BaseInfo : public SMESHGUI_Info
95 iObjectStart = iStart,
99 iNodesStart = iObjectEnd,
102 iElementsStart = iNodesEnd,
103 iElementsTitleStart = iElementsStart,
106 iElementsTotalStart = iElementsTitleEnd,
109 i0DStart = iElementsTotalEnd,
112 iBallsStart = i0DEnd,
115 i1DStart = iBallsEnd,
133 iElementsEnd = i3DEnd,
149 typedef QMap<int, QWidget*> wlist;
150 typedef QMap<int, wlist> iwlist;
153 SMESHGUI_BaseInfo( QWidget* = 0 );
154 ~SMESHGUI_BaseInfo();
156 void showInfo( const SMESHGUI_SelectionProxy& );
158 void saveInfo( QTextStream& );
161 QWidget* addWidget( QWidget*, int, int, int = 1 );
162 QWidget* widget( int, int ) const;
163 QString value( int, int ) const;
164 void setFieldsVisible( int, int, bool );
172 SMESHGUI_SelectionProxy myProxy;
175 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public SMESHGUI_Info
180 SMESHGUI_ElemInfo( QWidget* = 0 );
181 ~SMESHGUI_ElemInfo();
183 void showInfo( const SMESHGUI_SelectionProxy&, uint, bool );
184 void showInfo( const SMESHGUI_SelectionProxy&, QSet<uint>, bool );
185 void showInfo( const SMESHGUI_SelectionProxy& );
188 gp_XYZ getGravityCenter( const SMDS_MeshElement* );
191 enum { ShowNone, ShowNodes, ShowElements };
195 double myX, myY, myZ;
196 XYZ() { myX = myY = myZ = 0.0; }
197 XYZ(double x, double y, double z) { myX = x; myY = y; myZ = z; }
198 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
199 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
200 double x() const { return myX; }
201 double y() const { return myY; }
202 double z() const { return myZ; }
203 operator gp_XYZ() const { return gp_XYZ( myX, myY, myZ ); }
205 typedef QMap< int, QList<int> > Connectivity;
207 QWidget* frame() const;
210 SMESHGUI_SelectionProxy proxy() const;
212 virtual void information( const QList<uint>& ) = 0;
213 virtual void clearInternal();
215 Connectivity nodeConnectivity( const SMDS_MeshNode* );
216 QString formatConnectivity( Connectivity, int );
217 XYZ gravityCenter( const SMDS_MeshElement* );
218 XYZ normal( const SMDS_MeshElement* );
221 void itemInfo( int );
222 void itemInfo( const QString& );
227 void updateControls();
231 ExtraWidget* myExtra;
232 SMESHGUI_SelectionProxy myProxy;
238 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
243 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
244 void saveInfo( QTextStream& );
247 void information( const QList<uint>& );
248 void clearInternal();
251 QTextBrowser* myInfo;
254 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
261 SMESHGUI_TreeElemInfo( QWidget* = 0 );
262 void saveInfo( QTextStream& );
265 void contextMenuEvent( QContextMenuEvent* );
266 void information( const QList<uint>& );
267 void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
268 void clearInternal();
271 void itemDoubleClicked( QTreeWidgetItem*, int );
272 void saveExpanded( QTreeWidgetItem* );
275 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
276 QString expandedResource( QTreeWidgetItem* );
282 class InfoComputor: public QObject
287 enum { GrpSize, GrpNbNodes };
289 InfoComputor( QObject*, const SMESHGUI_SelectionProxy&, int );
298 SMESHGUI_SelectionProxy myProxy;
302 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public SMESHGUI_Info
307 SMESHGUI_AddInfo( QWidget* = 0 );
310 void showInfo( const SMESHGUI_SelectionProxy& );
312 void saveInfo( QTextStream& );
316 void showPreviousGroups();
317 void showNextGroups();
318 void showPreviousSubMeshes();
319 void showNextSubMeshes();
322 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
323 void meshInfo( const SMESHGUI_SelectionProxy&, QTreeWidgetItem* );
324 void subMeshInfo( const SMESHGUI_SelectionProxy&, QTreeWidgetItem* );
325 void groupInfo( const SMESHGUI_SelectionProxy&, QTreeWidgetItem* );
328 void showSubMeshes();
331 SMESHGUI_SelectionProxy myProxy;
333 QList<InfoComputor*> myComputors;
334 QList<SMESHGUI_SelectionProxy> myGroups;
335 QList<SMESHGUI_SelectionProxy> mySubMeshes;
338 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public SMESHGUI_Info
343 SMESHGUI_CtrlInfo( QWidget* = 0 );
344 ~SMESHGUI_CtrlInfo();
346 void showInfo( const SMESHGUI_SelectionProxy& );
347 void saveInfo( QTextStream& );
350 enum ObjectType { Mesh, SubMesh, Group };
351 QwtPlot* createPlot( QWidget* );
352 void clearInternal();
353 #ifndef DISABLE_PLOT2DVIEWER
354 Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr );
356 void computeNb( int, int, int );
359 void computeAspectRatio();
360 void computeAspectRatio3D();
361 void computeFreeNodesInfo();
362 void computeNodesNbConnInfo();
363 void computeDoubleNodesInfo();
364 void computeDoubleEdgesInfo();
365 void computeDoubleFacesInfo();
366 void computeOverConstrainedFacesInfo();
367 void computeDoubleVolumesInfo();
368 void computeOverConstrainedVolumesInfo();
369 void setTolerance( double );
372 typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
373 typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
374 SMESHGUI_SelectionProxy myProxy;
375 ObjectType myObjectType;
376 SMESHGUI_SpinBox* myToleranceWidget;
377 QList<QLabel*> myWidgets;
380 QList<QAbstractButton*> myButtons;
381 QList<TPredicate> myPredicates;
382 TNumFunctor myAspectRatio, myAspectRatio3D, myNodeConnFunctor;
385 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
389 enum { NodeMode, ElemMode, GroupMode };
395 BaseInfo, //!< base mesh information
396 ElemInfo, //!< mesh element information
397 AddInfo, //!< additional information
398 CtrlInfo //!< controls information
401 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
402 ~SMESHGUI_MeshInfoDlg();
404 void showInfo( const Handle(SALOME_InteractiveObject)& );
408 void keyPressEvent( QKeyEvent* );
411 void switchMode( int );
415 void updateSelection();
420 void idPreviewChange( bool );
421 void showItemInfo( int );
422 void showItemInfo( const QString& );
426 void showInfo( const SMESHGUI_SelectionProxy& );
428 SMESHGUI_SelectionProxy myProxy;
429 QTabWidget* myTabWidget;
430 SMESHGUI_BaseInfo* myBaseInfo;
431 SMESHGUI_ElemInfo* myElemInfo;
432 SMESHGUI_AddInfo* myAddInfo;
433 SMESHGUI_CtrlInfo* myCtrlInfo;
434 QButtonGroup* myMode;
436 QCheckBox* myIDPreviewCheck;
437 GroupCombo* myGroups;
438 SMESHGUI_IdPreview* myIDPreview;
441 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
446 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
447 ~SMESHGUI_CtrlInfoDlg();
449 void showInfo( const Handle(SALOME_InteractiveObject)& );
455 void updateSelection();
460 void showInfo( const SMESHGUI_SelectionProxy& );
462 SMESHGUI_SelectionProxy myProxy;
463 SMESHGUI_CtrlInfo* myCtrlInfo;
466 #endif // SMESHGUI_MESHINFO_H