Version: 6.3.1

src/SMESHGUI/SMESHGUI_MeshInfo.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 <QVector>
00037 
00038 #include <SALOMEconfig.h>
00039 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00040 
00041 class QButtonGroup;
00042 class QLabel;
00043 class QLineEdit;
00044 class QPushButton;
00045 class QTabWidget;
00046 class QTextBrowser;
00047 class QTreeWidget;
00048 class QTreeWidgetItem;
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     i3DPolyhedrons,
00084     i3DEnd,
00085     iElementsEnd   = i3DEnd
00086   };
00087 
00088   enum {
00089     iSingle = 1,
00090     iTotal  = iSingle,
00091     iLinear,
00092     iQuadratic
00093   };
00094 
00095   typedef QList<QWidget*> wlist;
00096   typedef QVector<wlist>  iwlist;
00097 
00098 public:
00099   SMESHGUI_MeshInfo( QWidget* = 0 );
00100   ~SMESHGUI_MeshInfo();
00101 
00102   void     showInfo( SMESH::SMESH_IDSource_ptr );
00103   void     clear();
00104 
00105 private:
00106   enum { Bold = 0x01, Italic = 0x02 };
00107 
00108   QLabel*  createField();
00109   QWidget* createLine();
00110   void     setFontAttributes( QWidget*, int, bool = true );
00111   void     setFieldsVisible( int, int, bool );
00112 
00113 private:
00114   iwlist   myWidgets;
00115 };
00116 
00117 class SMESHGUI_EXPORT SMESHGUI_ElemInfo : public QWidget
00118 {
00119   Q_OBJECT;
00120 
00121 public:
00122   SMESHGUI_ElemInfo( QWidget* = 0 );
00123   ~SMESHGUI_ElemInfo();
00124 
00125   void         setSource( SMESH_Actor* );
00126   void         showInfo( long, bool );
00127   void         showInfo( QSet<long>, bool );
00128   void         clear();
00129 
00130 protected:
00131   struct XYZ
00132   {
00133     double myX, myY, myZ;
00134     XYZ() { myX = myY = myZ = 0.0; }
00135     void add( double x, double y, double z ) { myX += x; myY += y; myZ += z; }
00136     void divide( double a ) { if ( a != 0.) { myX /= a; myY /= a; myZ /= a; } }
00137     double x() const  { return myX; }
00138     double y() const  { return myY; }
00139     double z() const  { return myZ; }
00140   };
00141   typedef QMap< int, QList<int> > Connectivity;
00142 
00143   QWidget*     frame() const;
00144   SMESH_Actor* actor() const;
00145   bool         isElements() const;
00146 
00147   virtual void information( const QList<long>& ) = 0;
00148   virtual void clearInternal();
00149 
00150   Connectivity nodeConnectivity( const SMDS_MeshNode* );
00151   QString      formatConnectivity( Connectivity, int );
00152   XYZ          gravityCenter( const SMDS_MeshElement* );
00153 
00154 private slots:
00155   void         showPrevious();
00156   void         showNext();
00157   void         updateControls();
00158 
00159 private:
00160   SMESH_Actor*     myActor;
00161   QList<long>      myIDs;
00162   int              myIsElement;
00163   QWidget*         myFrame;
00164   QWidget*         myExtra;
00165   QLabel*          myCurrent;
00166   QPushButton*     myPrev;
00167   QPushButton*     myNext;
00168   int              myIndex;
00169 };
00170 
00171 class SMESHGUI_EXPORT SMESHGUI_SimpleElemInfo : public SMESHGUI_ElemInfo
00172 {
00173 public:
00174   SMESHGUI_SimpleElemInfo( QWidget* = 0 );
00175 
00176 protected:
00177   void          information( const QList<long>& );
00178   void          clearInternal();
00179 
00180 private:
00181   QTextBrowser* myInfo;
00182 };
00183 
00184 class SMESHGUI_EXPORT SMESHGUI_TreeElemInfo : public SMESHGUI_ElemInfo
00185 {
00186   class ItemDelegate;
00187 
00188 public:
00189   SMESHGUI_TreeElemInfo( QWidget* = 0 );
00190 
00191 protected:
00192   void             information( const QList<long>& );
00193   void             clearInternal();
00194 
00195 private:
00196   QTreeWidgetItem* createItem( QTreeWidgetItem* = 0, int = 100 );
00197   
00198 private:
00199   QTreeWidget*     myInfo;
00200 };
00201 
00202 class SMESHGUI_EXPORT SMESHGUI_MeshInfoDlg : public QDialog
00203 { 
00204   Q_OBJECT;
00205 
00206   enum { NodeMode, ElemMode };
00207 
00208 public:
00210   enum { 
00211     BaseInfo,  
00212     ElemInfo   
00213   };
00214 
00215   SMESHGUI_MeshInfoDlg( QWidget* = 0, int = BaseInfo );
00216   ~SMESHGUI_MeshInfoDlg();
00217 
00218   void showInfo( const Handle(SALOME_InteractiveObject)& );
00219   void reject();
00220 
00221 protected:
00222   void keyPressEvent( QKeyEvent* );
00223   void enterEvent( QEvent* );
00224 
00225 private slots:
00226   void help();
00227   void updateSelection();
00228   void updateInfo();
00229   void activate();
00230   void deactivate();
00231   void modeChanged();
00232   void idChanged();
00233 
00234 private:
00235   QTabWidget*        myTabWidget;
00236   SMESHGUI_MeshInfo* myBaseInfo;
00237   QButtonGroup*      myMode;
00238   QLineEdit*         myID;
00239   SMESHGUI_ElemInfo* myElemInfo;   
00240   SMESH_Actor*       myActor;
00241 };
00242 
00243 #endif // SMESHGUI_MESHINFO_H
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS