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;
55 class QContextMenuEvent;
64 class SMDS_MeshElement;
65 class SMESHGUI_SpinBox;
69 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
79 iElementsStart = iNodesEnd,
108 iElementsEnd = i3DEnd
119 typedef QList<QWidget*> wlist;
120 typedef QVector<wlist> iwlist;
123 SMESHGUI_MeshInfo( QWidget* = 0 );
124 ~SMESHGUI_MeshInfo();
126 void showInfo( SMESH::SMESH_IDSource_ptr );
128 void saveInfo( QTextStream &out );
131 enum { Bold = 0x01, Italic = 0x02 };
133 QLabel* createField();
134 QWidget* createLine();
135 void setFontAttributes( QWidget*, int, bool = true );
136 void setFieldsVisible( int, int, bool );
143 QPushButton* myLoadBtn;
146 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
151 SMESHGUI_ElemInfo( QWidget* = 0 );
152 ~SMESHGUI_ElemInfo();
154 void setSource( SMESH_Actor* );
155 void showInfo( long, bool );
156 void showInfo( QSet<long>, bool );
158 virtual void saveInfo( QTextStream &out ) = 0;
163 double myX, myY, myZ;
164 XYZ() { myX = myY = myZ = 0.0; }
165 XYZ(double x, double y, double z) { myX = x; myY = y; myZ = z; }
166 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
167 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
168 double x() const { return myX; }
169 double y() const { return myY; }
170 double z() const { return myZ; }
172 typedef QMap< int, QList<int> > Connectivity;
174 QWidget* frame() const;
175 SMESH_Actor* actor() const;
176 bool isElements() const;
178 virtual void information( const QList<long>& ) = 0;
179 virtual void clearInternal();
181 Connectivity nodeConnectivity( const SMDS_MeshNode* );
182 QString formatConnectivity( Connectivity, int );
183 XYZ gravityCenter( const SMDS_MeshElement* );
184 XYZ normal( const SMDS_MeshElement* );
187 void itemInfo( int );
188 void itemInfo( const QString& );
193 void updateControls();
196 SMESH_Actor* myActor;
200 ExtraWidget* myExtra;
204 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
209 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
210 void saveInfo( QTextStream &out );
213 void information( const QList<long>& );
214 void clearInternal();
217 QTextBrowser* myInfo;
220 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
226 enum { Bold = 0x01, All = 0x80 };
229 SMESHGUI_TreeElemInfo( QWidget* = 0 );
230 void saveInfo( QTextStream &out );
233 void contextMenuEvent( QContextMenuEvent* e );
234 void information( const QList<long>& );
235 void nodeInfo( const SMDS_MeshNode*, int, int, QTreeWidgetItem* );
236 void clearInternal();
239 void itemDoubleClicked( QTreeWidgetItem*, int );
242 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
248 class GrpComputor: public QObject
253 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject*, bool = false);
254 QTreeWidgetItem* getItem() { return myItem; }
260 SMESH::SMESH_GroupBase_var myGroup;
261 QTreeWidgetItem* myItem;
262 bool myToComputeSize;
265 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
269 enum { Bold = 0x01, All = 0x80 };
272 SMESHGUI_AddInfo( QWidget* = 0 );
275 void showInfo( SMESH::SMESH_IDSource_ptr );
277 void saveInfo( QTextStream &out );
280 void changeLoadToCompute();
281 void showPreviousGroups();
282 void showNextGroups();
283 void showPreviousSubMeshes();
284 void showNextSubMeshes();
287 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
288 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
289 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
290 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
293 void showSubMeshes();
296 QList<GrpComputor*> myComputors;
297 SMESH::ListOfGroups_var myGroups;
298 SMESH::submesh_array_var mySubMeshes;
301 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
306 SMESHGUI_CtrlInfo( QWidget* = 0 );
307 ~SMESHGUI_CtrlInfo();
309 void showInfo( SMESH::SMESH_IDSource_ptr );
310 void saveInfo( QTextStream &out );
313 enum ObjectType { Mesh, SubMesh, Group };
314 QLabel* createField();
315 QwtPlot* createPlot( QWidget* );
316 void setFontAttributes( QWidget* );
317 void clearInternal();
318 #ifndef DISABLE_PLOT2DVIEWER
319 Plot2d_Histogram* getHistogram( SMESH::NumericalFunctor_ptr functor );
321 void computeNb( int ft, int iBut, int iWdg );
324 void computeAspectRatio();
325 void computeAspectRatio3D();
326 void computeFreeNodesInfo();
327 void computeNodesNbConnInfo();
328 void computeDoubleNodesInfo();
329 void computeDoubleEdgesInfo();
330 void computeDoubleFacesInfo();
331 void computeOverConstrainedFacesInfo();
332 void computeDoubleVolumesInfo();
333 void computeOverConstrainedVolumesInfo();
334 void setTolerance( const double theTolerance );
338 typedef SALOME::GenericObj_wrap< SMESH::Predicate > TPredicate;
339 typedef SALOME::GenericObj_wrap< SMESH::NumericalFunctor > TNumFunctor;
340 SMESH::SMESH_IDSource_var myObject;
341 ObjectType myObjectType;
342 SMESHGUI_SpinBox* myToleranceWidget;
343 QList<QLabel*> myWidgets;
344 QGridLayout* myMainLayout;
347 QList<QAbstractButton*> myButtons;
348 QList<TPredicate> myPredicates;
349 TNumFunctor myAspectRatio, myAspectRatio3D, myNodeConnFunctor;
352 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
356 enum { NodeMode, ElemMode };
361 BaseInfo, //!< base mesh information
362 ElemInfo, //!< mesh element information
363 AddInfo, //!< additional information
364 CtrlInfo //!< controls information
367 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
368 ~SMESHGUI_MeshInfoDlg();
370 void showInfo( const Handle(SALOME_InteractiveObject)& );
374 void keyPressEvent( QKeyEvent* );
375 void enterEvent( QEvent* );
379 void updateSelection();
385 void showItemInfo( int );
386 void showItemInfo( const QString& );
390 QTabWidget* myTabWidget;
391 SMESHGUI_MeshInfo* myBaseInfo;
392 QButtonGroup* myMode;
394 SMESHGUI_ElemInfo* myElemInfo;
395 SMESHGUI_AddInfo* myAddInfo;
396 SMESHGUI_CtrlInfo* myCtrlInfo;
397 SMESH_Actor* myActor;
398 Handle(SALOME_InteractiveObject) myIO;
401 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
406 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
407 ~SMESHGUI_CtrlInfoDlg();
409 void showInfo( const Handle(SALOME_InteractiveObject)& );
416 void updateSelection();
421 SMESHGUI_CtrlInfo* myCtrlInfo;
424 #endif // SMESHGUI_MESHINFO_H