Back to index

salome-smesh  6.5.0
SMESHGUI_MeshInfo.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 //  File   : SMESHGUI_MeshInfo.h
00023 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00024 
00025 #ifndef SMESHGUI_MESHINFO_H
00026 #define SMESHGUI_MESHINFO_H
00027 
00028 #include "SMESH_SMESHGUI.hxx"
00029 #include <SALOME_InteractiveObject.hxx>
00030 
00031 #include <QFrame>
00032 #include <QDialog>
00033 #include <QList>
00034 #include <QMap>
00035 #include <QSet>
00036 #include <QTreeWidget>
00037 #include <QVector>
00038 
00039 #include <SALOMEconfig.h>
00040 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00041 #include CORBA_SERVER_HEADER(SMESH_Group)
00042 
00043 class QButtonGroup;
00044 class QLabel;
00045 class QLineEdit;
00046 class QPushButton;
00047 class QTabWidget;
00048 class QTextBrowser;
00049 class SMESH_Actor;
00050 class SMDS_MeshNode;
00051 class SMDS_MeshElement;
00052 
00053 class SMESHGUI_EXPORT SMESHGUI_MeshInfo : public QFrame
00054 {
00055   Q_OBJECT;
00056   
00057   enum {
00058     iName,
00059     iObject,
00060     iNodesStart,
00061     iNodes,
00062     iNodesEnd,
00063     iElementsStart = iNodesEnd, 
00064     iElements,
00065     i0DStart,
00066     i0D,
00067     i0DEnd,
00068     i1DStart       = i0DEnd,
00069     i1D,
00070     i1DEnd,
00071     i2DStart       = i1DEnd,
00072     i2D,
00073     i2DTriangles,
00074     i2DQuadrangles,
00075     i2DPolygons,
00076     i2DEnd,
00077     i3DStart       = i2DEnd,
00078     i3D,
00079     i3DTetrahedrons,
00080     i3DHexahedrons,
00081     i3DPyramids,
00082     i3DPrisms,
00083     i3DHexaPrisms,
00084     i3DPolyhedrons,
00085     i3DEnd,
00086     iElementsEnd   = i3DEnd
00087   };
00088 
00089   enum {
00090     iSingle = 1,
00091     iTotal  = iSingle,
00092     iLinear,
00093     iQuadratic
00094   };
00095 
00096   typedef QList<QWidget*> wlist;
00097   typedef QVector<wlist>  iwlist;
00098 
00099 public:
00100   SMESHGUI_MeshInfo( QWidget* = 0 );
00101   ~SMESHGUI_MeshInfo();
00102 
00103   void     showInfo( SMESH::SMESH_IDSource_ptr );
00104   void     clear();
00105 
00106 private:
00107   enum { Bold = 0x01, Italic = 0x02 };
00108 
00109   QLabel*  createField();
00110   QWidget* createLine();
00111   void     setFontAttributes( QWidget*, int, bool = true );
00112   void     setFieldsVisible( int, int, bool );
00113 
00114 private slots:
00115   void loadMesh();
00116 
00117 private:
00118   iwlist       myWidgets;
00119   QPushButton* myLoadBtn;
00120 };
00121 
00122 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
00123 {
00124   Q_OBJECT;
00125 
00126 public:
00127   SMESHGUI_ElemInfo( QWidget* = 0 );
00128   ~SMESHGUI_ElemInfo();
00129 
00130   void         setSource( SMESH_Actor* );
00131   void         showInfo( long, bool );
00132   void         showInfo( QSet<long>, bool );
00133   void         clear();
00134 
00135 protected:
00136   struct XYZ
00137   {
00138     double myX, myY, myZ;
00139     XYZ() { myX = myY = myZ = 0.0; }
00140     void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
00141     void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
00142     double x() const  { return myX; }
00143     double y() const  { return myY; }
00144     double z() const  { return myZ; }
00145   };
00146   typedef QMap< int, QList<int> > Connectivity;
00147 
00148   QWidget*     frame() const;
00149   SMESH_Actor* actor() const;
00150   bool         isElements() const;
00151 
00152   virtual void information( const QList<long>& ) = 0;
00153   virtual void clearInternal();
00154 
00155   Connectivity nodeConnectivity( const SMDS_MeshNode* );
00156   QString      formatConnectivity( Connectivity, int );
00157   XYZ          gravityCenter( const SMDS_MeshElement* );
00158 
00159 private slots:
00160   void         showPrevious();
00161   void         showNext();
00162   void         updateControls();
00163 
00164 private:
00165   SMESH_Actor*     myActor;
00166   QList<long>      myIDs;
00167   int              myIsElement;
00168   QWidget*         myFrame;
00169   QWidget*         myExtra;
00170   QLabel*          myCurrent;
00171   QPushButton*     myPrev;
00172   QPushButton*     myNext;
00173   int              myIndex;
00174 };
00175 
00176 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
00177 {
00178 public:
00179   SMESHGUI_SimpleElemInfo( QWidget* = 0 );
00180 
00181 protected:
00182   void          information( const QList<long>& );
00183   void          clearInternal();
00184 
00185 private:
00186   QTextBrowser* myInfo;
00187 };
00188 
00189 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
00190 {
00191   class ItemDelegate;
00192 
00193   enum { Bold = 0x01, All = 0x80 };
00194 
00195 public:
00196   SMESHGUI_TreeElemInfo( QWidget* = 0 );
00197 
00198 protected:
00199   void             information( const QList<long>& );
00200   void             clearInternal();
00201 
00202 private:
00203   QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
00204   
00205 private:
00206   QTreeWidget*     myInfo;
00207 };
00208 
00209 class GrpComputor: public QObject
00210 {
00211   Q_OBJECT;
00212 
00213 public:
00214   GrpComputor( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem*, QObject* );
00215   QTreeWidgetItem* getItem() { return myItem; }
00216 
00217 public slots:
00218   void compute();
00219 
00220 private:
00221   SMESH::SMESH_GroupBase_var myGroup;
00222   QTreeWidgetItem*           myItem;
00223 };
00224 
00225 class SMESHGUI_EXPORT SMESHGUI_AddInfo : public QTreeWidget
00226 {
00227   Q_OBJECT;
00228 
00229   enum { Bold = 0x01, All = 0x80 };
00230 
00231 public:
00232   SMESHGUI_AddInfo( QWidget* = 0 );
00233   ~SMESHGUI_AddInfo();
00234 
00235   void             showInfo( SMESH::SMESH_IDSource_ptr );
00236   //  void             clear();
00237 private slots:
00238   void             changeLoadToCompute();
00239 
00240 private:
00241   QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 0 );
00242   void             meshInfo( SMESH::SMESH_Mesh_ptr, QTreeWidgetItem* );
00243   void             subMeshInfo( SMESH::SMESH_subMesh_ptr, QTreeWidgetItem* );
00244   void             groupInfo( SMESH::SMESH_GroupBase_ptr, QTreeWidgetItem* );
00245 
00246 private:
00247   QList<GrpComputor*> myComputors;
00248 };
00249 
00250 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
00251 { 
00252   Q_OBJECT;
00253 
00254   enum { NodeMode, ElemMode };
00255 
00256 public:
00258   enum { 
00259     BaseInfo,  
00260     ElemInfo,  
00261     AddInfo    
00262   };
00263 
00264   SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
00265   ~SMESHGUI_MeshInfoDlg();
00266 
00267   void showInfo( const Handle(SALOME_InteractiveObject)& );
00268   void reject();
00269 
00270 protected:
00271   void keyPressEvent( QKeyEvent* );
00272   void enterEvent( QEvent* );
00273 
00274 private slots:
00275   void help();
00276   void updateSelection();
00277   void updateInfo();
00278   void activate();
00279   void deactivate();
00280   void modeChanged();
00281   void idChanged();
00282 
00283 private:
00284   QTabWidget*        myTabWidget;
00285   SMESHGUI_MeshInfo* myBaseInfo;
00286   QButtonGroup*      myMode;
00287   QLineEdit*         myID;
00288   SMESHGUI_ElemInfo* myElemInfo;   
00289   SMESHGUI_AddInfo*  myAddInfo;
00290   SMESH_Actor*       myActor;
00291 };
00292 
00293 #endif // SMESHGUI_MESHINFO_H