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"
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;
56 class QContextMenuEvent;
63 class SMDS_MeshElement;
65 class SMESHGUI_IdPreview;
66 class SMESHGUI_SpinBox;
71 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
81 iElementsStart = iNodesEnd,
110 iElementsEnd = i3DEnd
121 typedef QList<QWidget*> wlist;
122 typedef QVector<wlist> iwlist;
125 SMESHGUI_MeshInfo( QWidget* = 0 );
126 ~SMESHGUI_MeshInfo();
128 void showInfo( SMESH::SMESH_IDSource_ptr );
130 void saveInfo( QTextStream &out );
133 enum { Bold = 0x01, Italic = 0x02 };
135 QLabel* createField();
136 QWidget* createLine();
137 void setFontAttributes( QWidget*, int, bool = true );
138 void setFieldsVisible( int, int, bool );
145 QPushButton* myLoadBtn;
148 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
153 SMESHGUI_ElemInfo( QWidget* = 0 );
154 ~SMESHGUI_ElemInfo();
156 void setSource( SMESH_Actor*, SMESH::SMESH_IDSource_var );
157 void showInfo( long, bool );
158 void showInfo( QSet<long>, bool );
160 virtual void saveInfo( QTextStream &out ) = 0;
162 gp_XYZ getGravityCenter( const SMDS_MeshElement* e ) { return gravityCenter(e); }
167 double myX, myY, myZ;
168 XYZ() { myX = myY = myZ = 0.0; }
169 XYZ(double x, double y, double z) { myX = x; myY = y; myZ = z; }
170 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
171 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
172 double x() const { return myX; }
173 double y() const { return myY; }
174 double z() const { return myZ; }
175 operator gp_XYZ() const { return gp_XYZ( myX, myY, myZ ); }
177 typedef QMap< int, QList<int> > Connectivity;
179 QWidget* frame() const;
180 SMESH_Actor* actor() const;
181 bool isElements() const;
182 bool hasShapeToMesh() const { return myMeshHasShape; }
184 virtual void information( const QList<long>& ) = 0;
185 virtual void clearInternal();
187 Connectivity nodeConnectivity( const SMDS_MeshNode* );
188 QString formatConnectivity( Connectivity, int );
189 XYZ gravityCenter( const SMDS_MeshElement* );
190 XYZ normal( const SMDS_MeshElement* );
193 void itemInfo( int );
194 void itemInfo( const QString& );
199 void updateControls();
202 SMESH_Actor* myActor;
206 ExtraWidget* myExtra;
211 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
216 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
217 void saveInfo( QTextStream &out );
220 void information( const QList<long>& );
221 void clearInternal();
224 QTextBrowser* myInfo;
227 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
233 enum { Bold = 0x01, All = 0x80 };
236 SMESHGUI_TreeElemInfo( QWidget* = 0 );
237 void saveInfo( QTextStream &out );
240 void contextMenuEvent( QContextMenuEvent* e );
241 void information( const QList<long>& );
242 void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
243 void clearInternal();
246 void itemDoubleClicked( QTreeWidgetItem*, int );
247 void saveExpanded( QTreeWidgetItem* );
250 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
251 QString expandedResource( QTreeWidgetItem* );
257 class GrpComputor: public QObject
262 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject*, bool = false);
263 QTreeWidgetItem* getItem() { return myItem; }
269 SMESH::SMESH_GroupBase_var myGroup;
270 QTreeWidgetItem* myItem;
271 bool myToComputeSize;
274 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
278 enum { Bold = 0x01, All = 0x80 };
281 SMESHGUI_AddInfo( QWidget* = 0 );
284 void showInfo( SMESH::SMESH_IDSource_ptr );
286 void saveInfo( QTextStream &out );
289 void changeLoadToCompute();
290 void showPreviousGroups();
291 void showNextGroups();
292 void showPreviousSubMeshes();
293 void showNextSubMeshes();
296 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
297 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
298 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
299 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
302 void showSubMeshes();
305 QList<GrpComputor*> myComputors;
306 SMESH::ListOfGroups_var myGroups;
307 SMESH::submesh_array_var mySubMeshes;
310 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
315 SMESHGUI_CtrlInfo( QWidget* = 0 );
316 ~SMESHGUI_CtrlInfo();
318 void showInfo( SMESH::SMESH_IDSource_ptr );
319 void saveInfo( QTextStream &out );
322 enum ObjectType { Mesh, SubMesh, Group };
323 QLabel* createField();
324 QwtPlot* createPlot( QWidget* );
325 void setFontAttributes( QWidget* );
326 void clearInternal();
327 #ifndef DISABLE_PLOT2DVIEWER
328 Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor );
330 void computeNb( int ft, int iBut, int iWdg );
333 void computeAspectRatio();
334 void computeAspectRatio3D();
335 void computeFreeNodesInfo();
336 void computeNodesNbConnInfo();
337 void computeDoubleNodesInfo();
338 void computeDoubleEdgesInfo();
339 void computeDoubleFacesInfo();
340 void computeOverConstrainedFacesInfo();
341 void computeDoubleVolumesInfo();
342 void computeOverConstrainedVolumesInfo();
343 void setTolerance( const double theTolerance );
347 typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
348 typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
349 SMESH::SMESH_IDSource_var myObject;
350 ObjectType myObjectType;
351 SMESHGUI_SpinBox* myToleranceWidget;
352 QList<QLabel*> myWidgets;
353 QGridLayout* myMainLayout;
356 QList<QAbstractButton*> myButtons;
357 QList<TPredicate> myPredicates;
358 TNumFunctor myAspectRatio, myAspectRatio3D, myNodeConnFunctor;
361 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
365 enum { NodeMode, ElemMode };
370 BaseInfo, //!< base mesh information
371 ElemInfo, //!< mesh element information
372 AddInfo, //!< additional information
373 CtrlInfo //!< controls information
376 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
377 ~SMESHGUI_MeshInfoDlg();
379 void showInfo( const Handle(SALOME_InteractiveObject)& );
383 void keyPressEvent( QKeyEvent* );
384 void enterEvent( QEvent* );
388 void updateSelection();
394 void idPreviewChange(bool);
395 void showItemInfo( int );
396 void showItemInfo( const QString& );
400 QTabWidget* myTabWidget;
401 SMESHGUI_MeshInfo* myBaseInfo;
402 QButtonGroup* myMode;
404 QCheckBox* myIDPreviewCheck;
405 SMESHGUI_IdPreview* myIDPreview;
406 SMESHGUI_ElemInfo* myElemInfo;
407 SMESHGUI_AddInfo* myAddInfo;
408 SMESHGUI_CtrlInfo* myCtrlInfo;
409 SMESH_Actor* myActor;
410 Handle(SALOME_InteractiveObject) myIO;
413 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
418 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
419 ~SMESHGUI_CtrlInfoDlg();
421 void showInfo( const Handle(SALOME_InteractiveObject)& );
428 void updateSelection();
433 SMESHGUI_CtrlInfo* myCtrlInfo;
436 #endif // SMESHGUI_MESHINFO_H