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;
72 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
82 iElementsStart = iNodesEnd,
111 iElementsEnd = i3DEnd
122 typedef QList<QWidget*> wlist;
123 typedef QVector<wlist> iwlist;
126 SMESHGUI_MeshInfo( QWidget* = 0 );
127 ~SMESHGUI_MeshInfo();
129 void showInfo( SMESH::SMESH_IDSource_ptr );
131 void saveInfo( QTextStream &out );
134 enum { Bold = 0x01, Italic = 0x02 };
136 QLabel* createField();
137 QWidget* createLine();
138 void setFontAttributes( QWidget*, int, bool = true );
139 void setFieldsVisible( int, int, bool );
146 QPushButton* myLoadBtn;
149 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
154 SMESHGUI_ElemInfo( QWidget* = 0 );
155 ~SMESHGUI_ElemInfo();
157 void setSource( SMESH_Actor*, SMESH::SMESH_IDSource_var );
158 void showInfo( long, bool );
159 void showInfo( QSet<long>, bool );
160 void showInfo( SMESH::SMESH_GroupBase_ptr );
162 virtual void saveInfo( QTextStream &out ) = 0;
164 gp_XYZ getGravityCenter( const SMDS_MeshElement* e ) { return gravityCenter(e); }
169 double myX, myY, myZ;
170 XYZ() { myX = myY = myZ = 0.0; }
171 XYZ(double x, double y, double z) { myX = x; myY = y; myZ = z; }
172 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
173 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
174 double x() const { return myX; }
175 double y() const { return myY; }
176 double z() const { return myZ; }
177 operator gp_XYZ() const { return gp_XYZ( myX, myY, myZ ); }
179 typedef QMap< int, QList<int> > Connectivity;
181 QWidget* frame() const;
182 SMESH_Actor* actor() const;
183 bool isElements() const;
184 bool hasShapeToMesh() const { return myMeshHasShape; }
186 virtual void information( const QList<long>& ) = 0;
187 virtual void clearInternal();
189 Connectivity nodeConnectivity( const SMDS_MeshNode* );
190 QString formatConnectivity( Connectivity, int );
191 XYZ gravityCenter( const SMDS_MeshElement* );
192 XYZ normal( const SMDS_MeshElement* );
195 void itemInfo( int );
196 void itemInfo( const QString& );
201 void updateControls();
204 SMESH_Actor* myActor;
208 ExtraWidget* myExtra;
213 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
218 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
219 void saveInfo( QTextStream &out );
222 void information( const QList<long>& );
223 void clearInternal();
226 QTextBrowser* myInfo;
229 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
235 enum { Bold = 0x01, All = 0x80 };
238 SMESHGUI_TreeElemInfo( QWidget* = 0 );
239 void saveInfo( QTextStream &out );
242 void contextMenuEvent( QContextMenuEvent* e );
243 void information( const QList<long>& );
244 void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
245 void clearInternal();
248 void itemDoubleClicked( QTreeWidgetItem*, int );
249 void saveExpanded( QTreeWidgetItem* );
252 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
253 QString expandedResource( QTreeWidgetItem* );
259 class GrpComputor: public QObject
264 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject*, bool = false);
265 QTreeWidgetItem* getItem() { return myItem; }
271 SMESH::SMESH_GroupBase_var myGroup;
272 QTreeWidgetItem* myItem;
273 bool myToComputeSize;
276 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
280 enum { Bold = 0x01, All = 0x80 };
283 SMESHGUI_AddInfo( QWidget* = 0 );
286 void showInfo( SMESH::SMESH_IDSource_ptr );
288 void saveInfo( QTextStream &out );
291 void changeLoadToCompute();
292 void showPreviousGroups();
293 void showNextGroups();
294 void showPreviousSubMeshes();
295 void showNextSubMeshes();
298 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
299 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
300 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
301 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
304 void showSubMeshes();
307 QList<GrpComputor*> myComputors;
308 SMESH::ListOfGroups_var myGroups;
309 SMESH::submesh_array_var mySubMeshes;
312 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
317 SMESHGUI_CtrlInfo( QWidget* = 0 );
318 ~SMESHGUI_CtrlInfo();
320 void showInfo( SMESH::SMESH_IDSource_ptr );
321 void saveInfo( QTextStream &out );
324 enum ObjectType { Mesh, SubMesh, Group };
325 QLabel* createField();
326 QwtPlot* createPlot( QWidget* );
327 void setFontAttributes( QWidget* );
328 void clearInternal();
329 #ifndef DISABLE_PLOT2DVIEWER
330 Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor );
332 void computeNb( int ft, int iBut, int iWdg );
335 void computeAspectRatio();
336 void computeAspectRatio3D();
337 void computeFreeNodesInfo();
338 void computeNodesNbConnInfo();
339 void computeDoubleNodesInfo();
340 void computeDoubleEdgesInfo();
341 void computeDoubleFacesInfo();
342 void computeOverConstrainedFacesInfo();
343 void computeDoubleVolumesInfo();
344 void computeOverConstrainedVolumesInfo();
345 void setTolerance( const double theTolerance );
349 typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
350 typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
351 SMESH::SMESH_IDSource_var myObject;
352 ObjectType myObjectType;
353 SMESHGUI_SpinBox* myToleranceWidget;
354 QList<QLabel*> myWidgets;
355 QGridLayout* myMainLayout;
358 QList<QAbstractButton*> myButtons;
359 QList<TPredicate> myPredicates;
360 TNumFunctor myAspectRatio, myAspectRatio3D, myNodeConnFunctor;
363 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
367 enum { NodeMode, ElemMode, GroupMode };
372 BaseInfo, //!< base mesh information
373 ElemInfo, //!< mesh element information
374 AddInfo, //!< additional information
375 CtrlInfo //!< controls information
378 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
379 ~SMESHGUI_MeshInfoDlg();
381 void showInfo( const Handle(SALOME_InteractiveObject)& );
385 void keyPressEvent( QKeyEvent* );
386 void enterEvent( QEvent* );
389 void switchMode( int );
393 void updateSelection();
399 void idPreviewChange(bool);
400 void showItemInfo( int );
401 void showItemInfo( const QString& );
405 QTabWidget* myTabWidget;
406 SMESHGUI_MeshInfo* myBaseInfo;
407 QButtonGroup* myMode;
409 QCheckBox* myIDPreviewCheck;
410 GroupCombo* myGroups;
411 SMESHGUI_IdPreview* myIDPreview;
412 SMESHGUI_ElemInfo* myElemInfo;
413 SMESHGUI_AddInfo* myAddInfo;
414 SMESHGUI_CtrlInfo* myCtrlInfo;
415 SMESH_Actor* myActor;
416 Handle(SALOME_InteractiveObject) myIO;
419 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
424 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
425 ~SMESHGUI_CtrlInfoDlg();
427 void showInfo( const Handle(SALOME_InteractiveObject)& );
434 void updateSelection();
439 SMESHGUI_CtrlInfo* myCtrlInfo;
442 #endif // SMESHGUI_MESHINFO_H