1 // Copyright (C) 2007-2012 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;
55 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
65 iElementsStart = iNodesEnd,
101 typedef QList<QWidget*> wlist;
102 typedef QVector<wlist> iwlist;
105 SMESHGUI_MeshInfo( QWidget* = 0 );
106 ~SMESHGUI_MeshInfo();
108 void showInfo( SMESH::SMESH_IDSource_ptr );
112 enum { Bold = 0x01, Italic = 0x02 };
114 QLabel* createField();
115 QWidget* createLine();
116 void setFontAttributes( QWidget*, int, bool = true );
117 void setFieldsVisible( int, int, bool );
124 QPushButton* myLoadBtn;
127 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
132 SMESHGUI_ElemInfo( QWidget* = 0 );
133 ~SMESHGUI_ElemInfo();
135 void setSource( SMESH_Actor* );
136 void showInfo( long, bool );
137 void showInfo( QSet<long>, bool );
143 double myX, myY, myZ;
144 XYZ() { myX = myY = myZ = 0.0; }
145 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
146 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
147 double x() const { return myX; }
148 double y() const { return myY; }
149 double z() const { return myZ; }
151 typedef QMap< int, QList<int> > Connectivity;
153 QWidget* frame() const;
154 SMESH_Actor* actor() const;
155 bool isElements() const;
157 virtual void information( const QList<long>& ) = 0;
158 virtual void clearInternal();
160 Connectivity nodeConnectivity( const SMDS_MeshNode* );
161 QString formatConnectivity( Connectivity, int );
162 XYZ gravityCenter( const SMDS_MeshElement* );
167 void updateControls();
170 SMESH_Actor* myActor;
174 ExtraWidget* myExtra;
178 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
181 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
184 void information( const QList<long>& );
185 void clearInternal();
188 QTextBrowser* myInfo;
191 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
195 enum { Bold = 0x01, All = 0x80 };
198 SMESHGUI_TreeElemInfo( QWidget* = 0 );
201 void information( const QList<long>& );
202 void clearInternal();
205 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
211 class GrpComputor: public QObject
216 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
217 QTreeWidgetItem* getItem() { return myItem; }
223 SMESH::SMESH_GroupBase_var myGroup;
224 QTreeWidgetItem* myItem;
227 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
231 enum { Bold = 0x01, All = 0x80 };
234 SMESHGUI_AddInfo( QWidget* = 0 );
237 void showInfo( SMESH::SMESH_IDSource_ptr );
241 void changeLoadToCompute();
242 void showPreviousGroups();
243 void showNextGroups();
244 void showPreviousSubMeshes();
245 void showNextSubMeshes();
248 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
249 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
250 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
251 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
254 void showSubMeshes();
257 QList<GrpComputor*> myComputors;
258 SMESH::ListOfGroups_var myGroups;
259 SMESH::submesh_array_var mySubMeshes;
262 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
266 enum { NodeMode, ElemMode };
271 BaseInfo, //!< base mesh information
272 ElemInfo, //!< mesh element information
273 AddInfo //!< additional information
276 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
277 ~SMESHGUI_MeshInfoDlg();
279 void showInfo( const Handle(SALOME_InteractiveObject)& );
283 void keyPressEvent( QKeyEvent* );
284 void enterEvent( QEvent* );
288 void updateSelection();
296 QTabWidget* myTabWidget;
297 SMESHGUI_MeshInfo* myBaseInfo;
298 QButtonGroup* myMode;
300 SMESHGUI_ElemInfo* myElemInfo;
301 SMESHGUI_AddInfo* myAddInfo;
302 SMESH_Actor* myActor;
305 #endif // SMESHGUI_MESHINFO_H