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 <SALOME_InteractiveObject.hxx>
30 #include "SMESH_ControlsDef.hxx"
32 #include <Plot2d_Histogram.h>
39 #include <QTreeWidget>
42 #include <SALOMEconfig.h>
43 #include CORBA_SERVER_HEADER(SMESH_Mesh)
44 #include CORBA_SERVER_HEADER(SMESH_Group)
47 class QContextMenuEvent;
55 class SMDS_MeshElement;
59 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
69 iElementsStart = iNodesEnd,
108 typedef QList<QWidget*> wlist;
109 typedef QVector<wlist> iwlist;
112 SMESHGUI_MeshInfo( QWidget* = 0 );
113 ~SMESHGUI_MeshInfo();
115 void showInfo( SMESH::SMESH_IDSource_ptr );
117 void saveInfo( QTextStream &out );
120 enum { Bold = 0x01, Italic = 0x02 };
122 QLabel* createField();
123 QWidget* createLine();
124 void setFontAttributes( QWidget*, int, bool = true );
125 void setFieldsVisible( int, int, bool );
132 QPushButton* myLoadBtn;
135 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
140 SMESHGUI_ElemInfo( QWidget* = 0 );
141 ~SMESHGUI_ElemInfo();
143 void setSource( SMESH_Actor* );
144 void showInfo( long, bool );
145 void showInfo( QSet<long>, bool );
147 virtual void saveInfo( QTextStream &out ) = 0;
152 double myX, myY, myZ;
153 XYZ() { myX = myY = myZ = 0.0; }
154 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
155 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
156 double x() const { return myX; }
157 double y() const { return myY; }
158 double z() const { return myZ; }
160 typedef QMap< int, QList<int> > Connectivity;
162 QWidget* frame() const;
163 SMESH_Actor* actor() const;
164 bool isElements() const;
166 virtual void information( const QList<long>& ) = 0;
167 virtual void clearInternal();
169 Connectivity nodeConnectivity( const SMDS_MeshNode* );
170 QString formatConnectivity( Connectivity, int );
171 XYZ gravityCenter( const SMDS_MeshElement* );
174 void itemInfo( int );
175 void itemInfo( const QString& );
180 void updateControls();
183 SMESH_Actor* myActor;
187 ExtraWidget* myExtra;
191 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
196 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
197 void saveInfo( QTextStream &out );
200 void information( const QList<long>& );
201 void clearInternal();
204 QTextBrowser* myInfo;
207 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
213 enum { Bold = 0x01, All = 0x80 };
216 SMESHGUI_TreeElemInfo( QWidget* = 0 );
217 void saveInfo( QTextStream &out );
220 void contextMenuEvent( QContextMenuEvent* e );
221 void information( const QList<long>& );
222 void clearInternal();
225 void itemDoubleClicked( QTreeWidgetItem*, int );
228 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
234 class GrpComputor: public QObject
239 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
240 QTreeWidgetItem* getItem() { return myItem; }
246 SMESH::SMESH_GroupBase_var myGroup;
247 QTreeWidgetItem* myItem;
250 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
254 enum { Bold = 0x01, All = 0x80 };
257 SMESHGUI_AddInfo( QWidget* = 0 );
260 void showInfo( SMESH::SMESH_IDSource_ptr );
262 void saveInfo( QTextStream &out );
265 void changeLoadToCompute();
266 void showPreviousGroups();
267 void showNextGroups();
268 void showPreviousSubMeshes();
269 void showNextSubMeshes();
272 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
273 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
274 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
275 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
278 void showSubMeshes();
281 QList<GrpComputor*> myComputors;
282 SMESH::ListOfGroups_var myGroups;
283 SMESH::submesh_array_var mySubMeshes;
286 class SMESHGUI_EXPORT SMESHGUI_CtrlInfo : public QFrame
291 SMESHGUI_CtrlInfo( QWidget* = 0 );
292 ~SMESHGUI_CtrlInfo();
294 void showInfo( SMESH::SMESH_IDSource_ptr );
295 void saveInfo( QTextStream &out );
298 QLabel* createField();
299 QwtPlot* createPlot( QWidget* );
300 void setFontAttributes( QWidget* );
301 void clearInternal();
302 int nbElemsControl( SMESH::long_array_var&, SMESH::Controls::FunctorPtr );
303 Plot2d_Histogram* getHistogram( SMESH::long_array_var&, SMESH::Controls::NumericalFunctorPtr );
306 void computeFaceInfo();
307 void computeVolumeInfo();
310 QList<QLabel*> myWidgets;
313 QPushButton* myComputeFaceBtn;
314 QPushButton* myComputeVolumeBtn;
317 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
321 enum { NodeMode, ElemMode };
326 BaseInfo, //!< base mesh information
327 ElemInfo, //!< mesh element information
328 AddInfo, //!< additional information
329 CtrlInfo //!< controls information
332 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
333 ~SMESHGUI_MeshInfoDlg();
335 void showInfo( const Handle(SALOME_InteractiveObject)& );
339 void keyPressEvent( QKeyEvent* );
340 void enterEvent( QEvent* );
344 void updateSelection();
350 void showItemInfo( int );
351 void showItemInfo( const QString& );
355 QTabWidget* myTabWidget;
356 SMESHGUI_MeshInfo* myBaseInfo;
357 QButtonGroup* myMode;
359 SMESHGUI_ElemInfo* myElemInfo;
360 SMESHGUI_AddInfo* myAddInfo;
361 SMESHGUI_CtrlInfo* myCtrlInfo;
362 SMESH_Actor* myActor;
365 class SMESHGUI_EXPORT SMESHGUI_CtrlInfoDlg : public QDialog
370 SMESHGUI_CtrlInfoDlg( QWidget* = 0 );
371 ~SMESHGUI_CtrlInfoDlg();
373 void showInfo( const Handle(SALOME_InteractiveObject)& );
380 void updateSelection();
383 SMESHGUI_CtrlInfo* myCtrlInfo;
386 #endif // SMESHGUI_MESHINFO_H