1 // Copyright (C) 2007-2011 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>
36 #include <QTreeWidget>
39 #include <SALOMEconfig.h>
40 #include CORBA_SERVER_HEADER(SMESH_Mesh)
41 #include CORBA_SERVER_HEADER(SMESH_Group)
51 class SMDS_MeshElement;
53 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
63 iElementsStart = iNodesEnd,
95 typedef QList<QWidget*> wlist;
96 typedef QVector<wlist> iwlist;
99 SMESHGUI_MeshInfo( QWidget* = 0 );
100 ~SMESHGUI_MeshInfo();
102 void showInfo( SMESH::SMESH_IDSource_ptr );
106 enum { Bold = 0x01, Italic = 0x02 };
108 QLabel* createField();
109 QWidget* createLine();
110 void setFontAttributes( QWidget*, int, bool = true );
111 void setFieldsVisible( int, int, bool );
117 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
122 SMESHGUI_ElemInfo( QWidget* = 0 );
123 ~SMESHGUI_ElemInfo();
125 void setSource( SMESH_Actor* );
126 void showInfo( long, bool );
127 void showInfo( QSet<long>, bool );
133 double myX, myY, myZ;
134 XYZ() { myX = myY = myZ = 0.0; }
135 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
136 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
137 double x() const { return myX; }
138 double y() const { return myY; }
139 double z() const { return myZ; }
141 typedef QMap< int, QList<int> > Connectivity;
143 QWidget* frame() const;
144 SMESH_Actor* actor() const;
145 bool isElements() const;
147 virtual void information( const QList<long>& ) = 0;
148 virtual void clearInternal();
150 Connectivity nodeConnectivity( const SMDS_MeshNode* );
151 QString formatConnectivity( Connectivity, int );
152 XYZ gravityCenter( const SMDS_MeshElement* );
157 void updateControls();
160 SMESH_Actor* myActor;
171 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
174 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
177 void information( const QList<long>& );
178 void clearInternal();
181 QTextBrowser* myInfo;
184 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
188 enum { Bold = 0x01, All = 0x80 };
191 SMESHGUI_TreeElemInfo( QWidget* = 0 );
194 void information( const QList<long>& );
195 void clearInternal();
198 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
204 class GrpComputor: public QObject
209 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
215 SMESH::SMESH_GroupBase_var myGroup;
216 QTreeWidgetItem* myItem;
219 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
223 enum { Bold = 0x01, All = 0x80 };
226 SMESHGUI_AddInfo( QWidget* = 0 );
229 void showInfo( SMESH::SMESH_IDSource_ptr );
233 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
234 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
235 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
236 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
239 QList<GrpComputor*> myComputors;
242 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
246 enum { NodeMode, ElemMode };
251 BaseInfo, //!< base mesh information
252 ElemInfo, //!< mesh element information
253 AddInfo //!< additional information
256 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
257 ~SMESHGUI_MeshInfoDlg();
259 void showInfo( const Handle(SALOME_InteractiveObject)& );
263 void keyPressEvent( QKeyEvent* );
264 void enterEvent( QEvent* );
268 void updateSelection();
276 QTabWidget* myTabWidget;
277 SMESHGUI_MeshInfo* myBaseInfo;
278 QButtonGroup* myMode;
280 SMESHGUI_ElemInfo* myElemInfo;
281 SMESHGUI_AddInfo* myAddInfo;
282 SMESH_Actor* myActor;
285 #endif // SMESHGUI_MESHINFO_H