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>
36 #include <QTreeWidget>
39 #include <SALOMEconfig.h>
40 #include CORBA_SERVER_HEADER(SMESH_Mesh)
41 #include CORBA_SERVER_HEADER(SMESH_Group)
44 class QContextMenuEvent;
52 class SMDS_MeshElement;
56 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
66 iElementsStart = iNodesEnd,
105 typedef QList<QWidget*> wlist;
106 typedef QVector<wlist> iwlist;
109 SMESHGUI_MeshInfo( QWidget* = 0 );
110 ~SMESHGUI_MeshInfo();
112 void showInfo( SMESH::SMESH_IDSource_ptr );
114 void saveInfo( QTextStream &out );
117 enum { Bold = 0x01, Italic = 0x02 };
119 QLabel* createField();
120 QWidget* createLine();
121 void setFontAttributes( QWidget*, int, bool = true );
122 void setFieldsVisible( int, int, bool );
129 QPushButton* myLoadBtn;
132 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
137 SMESHGUI_ElemInfo( QWidget* = 0 );
138 ~SMESHGUI_ElemInfo();
140 void setSource( SMESH_Actor* );
141 void showInfo( long, bool );
142 void showInfo( QSet<long>, bool );
144 virtual void saveInfo( QTextStream &out ) = 0;
149 double myX, myY, myZ;
150 XYZ() { myX = myY = myZ = 0.0; }
151 void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
152 void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
153 double x() const { return myX; }
154 double y() const { return myY; }
155 double z() const { return myZ; }
157 typedef QMap< int, QList<int> > Connectivity;
159 QWidget* frame() const;
160 SMESH_Actor* actor() const;
161 bool isElements() const;
163 virtual void information( const QList<long>& ) = 0;
164 virtual void clearInternal();
166 Connectivity nodeConnectivity( const SMDS_MeshNode* );
167 QString formatConnectivity( Connectivity, int );
168 XYZ gravityCenter( const SMDS_MeshElement* );
171 void itemInfo( int );
172 void itemInfo( const QString& );
177 void updateControls();
180 SMESH_Actor* myActor;
184 ExtraWidget* myExtra;
188 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
193 SMESHGUI_SimpleElemInfo( QWidget* = 0 );
194 void saveInfo( QTextStream &out );
197 void information( const QList<long>& );
198 void clearInternal();
201 QTextBrowser* myInfo;
204 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
210 enum { Bold = 0x01, All = 0x80 };
213 SMESHGUI_TreeElemInfo( QWidget* = 0 );
214 void saveInfo( QTextStream &out );
217 void contextMenuEvent( QContextMenuEvent* e );
218 void information( const QList<long>& );
219 void clearInternal();
222 void itemDoubleClicked( QTreeWidgetItem*, int );
225 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
231 class GrpComputor: public QObject
236 GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
237 QTreeWidgetItem* getItem() { return myItem; }
243 SMESH::SMESH_GroupBase_var myGroup;
244 QTreeWidgetItem* myItem;
247 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
251 enum { Bold = 0x01, All = 0x80 };
254 SMESHGUI_AddInfo( QWidget* = 0 );
257 void showInfo( SMESH::SMESH_IDSource_ptr );
259 void saveInfo( QTextStream &out );
262 void changeLoadToCompute();
263 void showPreviousGroups();
264 void showNextGroups();
265 void showPreviousSubMeshes();
266 void showNextSubMeshes();
269 QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
270 void meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
271 void subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
272 void groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
275 void showSubMeshes();
278 QList<GrpComputor*> myComputors;
279 SMESH::ListOfGroups_var myGroups;
280 SMESH::submesh_array_var mySubMeshes;
283 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
287 enum { NodeMode, ElemMode };
292 BaseInfo, //!< base mesh information
293 ElemInfo, //!< mesh element information
294 AddInfo //!< additional information
297 SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
298 ~SMESHGUI_MeshInfoDlg();
300 void showInfo( const Handle(SALOME_InteractiveObject)& );
304 void keyPressEvent( QKeyEvent* );
305 void enterEvent( QEvent* );
309 void updateSelection();
315 void showItemInfo( int );
316 void showItemInfo( const QString& );
320 QTabWidget* myTabWidget;
321 SMESHGUI_MeshInfo* myBaseInfo;
322 QButtonGroup* myMode;
324 SMESHGUI_ElemInfo* myElemInfo;
325 SMESHGUI_AddInfo* myAddInfo;
326 SMESH_Actor* myActor;
329 #endif // SMESHGUI_MESHINFO_H