Back to index

salome-smesh  6.5.0
SMESHGUI_MeshInfo.cxx
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.cxx
00023 //  Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
00024 
00025 #include "SMESHGUI_MeshInfo.h"
00026 
00027 #include "SMESH_Actor.h"
00028 #include "SMESHGUI.h"
00029 #include "SMESHGUI_IdValidator.h"
00030 #include "SMESHGUI_Utils.h"
00031 #include "SMESHGUI_VTKUtils.h"
00032 #include "SMDSAbs_ElementType.hxx"
00033 #include "SMDS_Mesh.hxx"
00034 
00035 #include <LightApp_SelectionMgr.h>
00036 #include <SUIT_OverrideCursor.h>
00037 #include <SUIT_ResourceMgr.h>
00038 #include <SVTK_ViewWindow.h>
00039 
00040 #include <SALOMEDSClient_Study.hxx>
00041 
00042 #include <QApplication>
00043 #include <QButtonGroup>
00044 #include <QGridLayout>
00045 #include <QHBoxLayout>
00046 #include <QHeaderView>
00047 #include <QItemDelegate>
00048 #include <QKeyEvent>
00049 #include <QLabel>
00050 #include <QLineEdit>
00051 #include <QPushButton>
00052 #include <QRadioButton>
00053 #include <QTabWidget>
00054 #include <QTextBrowser>
00055 #include <QVBoxLayout>
00056 
00057 #include "utilities.h"
00058 
00059 #include <SALOMEconfig.h>
00060 #include CORBA_SERVER_HEADER(GEOM_Gen)
00061 
00062 const int SPACING  = 6;
00063 const int MARGIN   = 9;
00064 const int MAXITEMS = 10;
00065 
00077 SMESHGUI_MeshInfo::SMESHGUI_MeshInfo( QWidget* parent )
00078   : QFrame( parent ), myWidgets( iElementsEnd )
00079 {
00080   setFrameStyle( StyledPanel | Sunken );
00081 
00082   QGridLayout* l = new QGridLayout( this );
00083   l->setMargin( MARGIN );
00084   l->setSpacing( SPACING );
00085 
00086   // object
00087   QLabel* aNameLab     = new QLabel( tr( "NAME_LAB" ), this );
00088   QLabel* aName        = createField();
00089   aName->setMinimumWidth( 150 );
00090   QLabel* aObjLab      = new QLabel( tr( "OBJECT_LAB" ), this );
00091   QLabel* aObj         = createField();
00092   aObj->setMinimumWidth( 150 );
00093   myWidgets[0] << aNameLab << aName;
00094   myWidgets[1] << aObjLab  << aObj;
00095 
00096   // nodes
00097   QWidget* aNodesLine  = createLine();
00098   QLabel*  aNodesLab   = new QLabel( tr( "NODES_LAB" ), this );
00099   QLabel*  aNodes      = createField();
00100   myWidgets[2] << aNodesLine;
00101   myWidgets[3] << aNodesLab << aNodes;
00102 
00103   // elements
00104   QWidget* aElemLine   = createLine();
00105   QLabel*  aElemLab    = new QLabel( tr( "ELEMENTS_LAB" ),  this );
00106   QLabel*  aElemTotal  = new QLabel( tr( "TOTAL_LAB" ),     this );
00107   QLabel*  aElemLin    = new QLabel( tr( "LINEAR_LAB" ),    this );
00108   QLabel*  aElemQuad   = new QLabel( tr( "QUADRATIC_LAB" ), this );
00109   myWidgets[4] << aElemLine;
00110   myWidgets[5] << aElemLab << aElemTotal << aElemLin << aElemQuad;
00111 
00112   // ... 0D elements
00113   QWidget* a0DLine     = createLine();
00114   QLabel*  a0DLab      = new QLabel( tr( "0D_LAB" ), this );
00115   QLabel*  a0DTotal    = createField();
00116   myWidgets[6] << a0DLine;
00117   myWidgets[7] << a0DLab << a0DTotal;
00118 
00119   // ... 1D elements
00120   QWidget* a1DLine     = createLine();
00121   QLabel*  a1DLab      = new QLabel( tr( "1D_LAB" ), this );
00122   QLabel*  a1DTotal    = createField();
00123   QLabel*  a1DLin      = createField();
00124   QLabel*  a1DQuad     = createField();
00125   myWidgets[8] << a1DLine;
00126   myWidgets[9] << a1DLab << a1DTotal << a1DLin << a1DQuad;
00127 
00128   // ... 2D elements
00129   QWidget* a2DLine     = createLine();
00130   QLabel*  a2DLab      = new QLabel( tr( "2D_LAB" ), this );
00131   QLabel*  a2DTotal    = createField();
00132   QLabel*  a2DLin      = createField();
00133   QLabel*  a2DQuad     = createField();
00134   QLabel*  a2DTriLab   = new QLabel( tr( "TRIANGLES_LAB" ), this );
00135   QLabel*  a2DTriTotal = createField();
00136   QLabel*  a2DTriLin   = createField();
00137   QLabel*  a2DTriQuad  = createField();
00138   QLabel*  a2DQuaLab   = new QLabel( tr( "QUADRANGLES_LAB" ), this );
00139   QLabel*  a2DQuaTotal = createField();
00140   QLabel*  a2DQuaLin   = createField();
00141   QLabel*  a2DQuaQuad  = createField();
00142   QLabel*  a2DPolLab   = new QLabel( tr( "POLYGONS_LAB" ), this );
00143   QLabel*  a2DPolTotal = createField();
00144   myWidgets[10] << a2DLine;
00145   myWidgets[11] << a2DLab    << a2DTotal    << a2DLin    << a2DQuad;
00146   myWidgets[12] << a2DTriLab << a2DTriTotal << a2DTriLin << a2DTriQuad;
00147   myWidgets[13] << a2DQuaLab << a2DQuaTotal << a2DQuaLin << a2DQuaQuad;
00148   myWidgets[14] << a2DPolLab << a2DPolTotal;
00149 
00150   // ... 3D elements
00151   QWidget* a3DLine     = createLine();
00152   QLabel*  a3DLab      = new QLabel( tr( "3D_LAB" ), this );
00153   QLabel*  a3DTotal    = createField();
00154   QLabel*  a3DLin      = createField();
00155   QLabel*  a3DQuad     = createField();
00156   QLabel*  a3DTetLab   = new QLabel( tr( "TETRAHEDRONS_LAB" ), this );
00157   QLabel*  a3DTetTotal = createField();
00158   QLabel*  a3DTetLin   = createField();
00159   QLabel*  a3DTetQuad  = createField();
00160   QLabel*  a3DHexLab   = new QLabel( tr( "HEXAHEDONRS_LAB" ), this );
00161   QLabel*  a3DHexTotal = createField();
00162   QLabel*  a3DHexLin   = createField();
00163   QLabel*  a3DHexQuad  = createField();
00164   QLabel*  a3DPyrLab   = new QLabel( tr( "PYRAMIDS_LAB" ), this );
00165   QLabel*  a3DPyrTotal = createField();
00166   QLabel*  a3DPyrLin   = createField();
00167   QLabel*  a3DPyrQuad  = createField();
00168   QLabel*  a3DPriLab   = new QLabel( tr( "PRISMS_LAB" ), this );
00169   QLabel*  a3DPriTotal = createField();
00170   QLabel*  a3DPriLin   = createField();
00171   QLabel*  a3DPriQuad  = createField();
00172   QLabel*  a3DHexPriLab   = new QLabel( tr( "HEX_PRISMS_LAB" ), this );
00173   QLabel*  a3DHexPriTotal = createField();
00174   QLabel*  a3DPolLab   = new QLabel( tr( "POLYHEDRONS_LAB" ), this );
00175   QLabel*  a3DPolTotal = createField();
00176   myWidgets[15] << a3DLine;
00177   myWidgets[16] << a3DLab    << a3DTotal    << a3DLin    << a3DQuad;
00178   myWidgets[17] << a3DTetLab << a3DTetTotal << a3DTetLin << a3DTetQuad;
00179   myWidgets[18] << a3DHexLab << a3DHexTotal << a3DHexLin << a3DHexQuad;
00180   myWidgets[19] << a3DPyrLab << a3DPyrTotal << a3DPyrLin << a3DPyrQuad;
00181   myWidgets[20] << a3DPriLab << a3DPriTotal << a3DPriLin << a3DPriQuad;
00182   myWidgets[21] << a3DHexPriLab << a3DHexPriTotal;
00183   myWidgets[22] << a3DPolLab << a3DPolTotal;
00184 
00185   myLoadBtn = new QPushButton( tr( "BUT_LOAD_MESH" ), this );
00186   myLoadBtn->setAutoDefault( true );
00187   connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( loadMesh() ) );
00188   
00189   setFontAttributes( aNameLab,   Bold );
00190   setFontAttributes( aObjLab,    Bold );
00191   setFontAttributes( aNodesLab,  Bold );
00192   setFontAttributes( aElemLab,   Bold );
00193   setFontAttributes( aElemTotal, Italic );
00194   setFontAttributes( aElemLin,   Italic );
00195   setFontAttributes( aElemQuad,  Italic );
00196   setFontAttributes( a0DLab,     Bold );
00197   setFontAttributes( a1DLab,     Bold );
00198   setFontAttributes( a2DLab,     Bold );
00199   setFontAttributes( a3DLab,     Bold );
00200 
00201   l->addWidget( aNameLab,     0, 0 );
00202   l->addWidget( aName,        0, 1, 1, 3 );
00203   l->addWidget( aObjLab,      1, 0 );
00204   l->addWidget( aObj,         1, 1, 1, 3 );
00205   l->addWidget( aNodesLine,   2, 0, 1, 4 );
00206   l->addWidget( aNodesLab,    3, 0 );
00207   l->addWidget( aNodes,       3, 1 );
00208   l->addWidget( aElemLine,    4, 0, 1, 4 );
00209   l->addWidget( aElemLab,     5, 0 );
00210   l->addWidget( aElemTotal,   5, 1 );
00211   l->addWidget( aElemLin,     5, 2 );
00212   l->addWidget( aElemQuad,    5, 3 );
00213   l->addWidget( a0DLine,      6, 1, 1, 3 );
00214   l->addWidget( a0DLab,       7, 0 );
00215   l->addWidget( a0DTotal,     7, 1 );
00216   l->addWidget( a1DLine,      8, 1, 1, 3 );
00217   l->addWidget( a1DLab,       9, 0 );
00218   l->addWidget( a1DTotal,     9, 1 );
00219   l->addWidget( a1DLin,       9, 2 );
00220   l->addWidget( a1DQuad,      9, 3 );
00221   l->addWidget( a2DLine,     10, 1, 1, 3 );
00222   l->addWidget( a2DLab,      11, 0 );
00223   l->addWidget( a2DTotal,    11, 1 );
00224   l->addWidget( a2DLin,      11, 2 );
00225   l->addWidget( a2DQuad,     11, 3 );
00226   l->addWidget( a2DTriLab,   12, 0 );
00227   l->addWidget( a2DTriTotal, 12, 1 );
00228   l->addWidget( a2DTriLin,   12, 2 );
00229   l->addWidget( a2DTriQuad,  12, 3 );
00230   l->addWidget( a2DQuaLab,   13, 0 );
00231   l->addWidget( a2DQuaTotal, 13, 1 );
00232   l->addWidget( a2DQuaLin,   13, 2 );
00233   l->addWidget( a2DQuaQuad,  13, 3 );
00234   l->addWidget( a2DPolLab,   14, 0 );
00235   l->addWidget( a2DPolTotal, 14, 1 );
00236   l->addWidget( a3DLine,     15, 1, 1, 3 );
00237   l->addWidget( a3DLab,      16, 0 );
00238   l->addWidget( a3DTotal,    16, 1 );
00239   l->addWidget( a3DLin,      16, 2 );
00240   l->addWidget( a3DQuad,     16, 3 );
00241   l->addWidget( a3DTetLab,   17, 0 );
00242   l->addWidget( a3DTetTotal, 17, 1 );
00243   l->addWidget( a3DTetLin,   17, 2 );
00244   l->addWidget( a3DTetQuad,  17, 3 );
00245   l->addWidget( a3DHexLab,   18, 0 );
00246   l->addWidget( a3DHexTotal, 18, 1 );
00247   l->addWidget( a3DHexLin,   18, 2 );
00248   l->addWidget( a3DHexQuad,  18, 3 );
00249   l->addWidget( a3DPyrLab,   19, 0 );
00250   l->addWidget( a3DPyrTotal, 19, 1 );
00251   l->addWidget( a3DPyrLin,   19, 2 );
00252   l->addWidget( a3DPyrQuad,  19, 3 );
00253   l->addWidget( a3DPriLab,   20, 0 );
00254   l->addWidget( a3DPriTotal, 20, 1 );
00255   l->addWidget( a3DPriLin,   20, 2 );
00256   l->addWidget( a3DPriQuad,  20, 3 );
00257   l->addWidget( a3DHexPriLab,   21, 0 );
00258   l->addWidget( a3DHexPriTotal, 21, 1 );
00259   l->addWidget( a3DPolLab,   22, 0 );
00260   l->addWidget( a3DPolTotal, 22, 1 );
00261   l->addWidget( myLoadBtn,   23, 1, 1, 3 );
00262   l->setColumnStretch( 0, 0 );
00263   l->setColumnStretch( 1, 5 );
00264   l->setColumnStretch( 2, 5 );
00265   l->setColumnStretch( 3, 5 );
00266   l->setRowStretch( 23, 5 );
00267 
00268   clear();
00269 }
00270 
00274 SMESHGUI_MeshInfo::~SMESHGUI_MeshInfo()
00275 {
00276 }
00277 
00282 void SMESHGUI_MeshInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
00283 {
00284   clear();
00285   if ( !CORBA::is_nil( obj ) ) {
00286     _PTR(SObject) sobj = SMESH::ObjectToSObject( obj );
00287     if ( sobj ) 
00288       myWidgets[iName][iSingle]->setProperty( "text", sobj->GetName().c_str() );
00289     SMESH::SMESH_Mesh_var      aMesh    = SMESH::SMESH_Mesh::_narrow( obj );
00290     SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
00291     SMESH::SMESH_GroupBase_var aGroup   = SMESH::SMESH_GroupBase::_narrow( obj );
00292     if ( !aMesh->_is_nil() ) {
00293       myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_MESH" ) );
00294     }
00295     else if ( !aSubMesh->_is_nil() ) {
00296       myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_SUBMESH" ) );
00297     }
00298     else if ( !aGroup->_is_nil() ) {
00299       QString objType;
00300       switch( aGroup->GetType() ) {
00301       case SMESH::NODE:
00302         objType = tr( "OBJECT_GROUP_NODES" );
00303         break;
00304       case SMESH::EDGE:
00305         objType = tr( "OBJECT_GROUP_EDGES" );
00306         break;
00307       case SMESH::FACE:
00308         objType = tr( "OBJECT_GROUP_FACES" );
00309         break;
00310       case SMESH::VOLUME:
00311         objType = tr( "OBJECT_GROUP_VOLUMES" );
00312         break;
00313       case SMESH::ELEM0D:
00314         objType = tr( "OBJECT_GROUP_0DELEMS" );
00315         break;
00316       default:
00317         objType = tr( "OBJECT_GROUP" );
00318         break;
00319       }
00320       myWidgets[iObject][iSingle]->setProperty( "text", objType );
00321     }
00322     SMESH::long_array_var info = obj->GetMeshInfo();
00323     myWidgets[iNodes][iTotal] ->setProperty( "text", QString::number( info[SMDSEntity_Node] ) );
00324     myWidgets[i0D][iTotal]    ->setProperty( "text", QString::number( info[SMDSEntity_0D] ) );
00325     long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
00326     myWidgets[i1D][iTotal]    ->setProperty( "text", QString::number( nbEdges ) );
00327     myWidgets[i1D][iLinear]   ->setProperty( "text", QString::number( info[SMDSEntity_Edge] ) );
00328     myWidgets[i1D][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Edge] ) );
00329     long nbTriangles   = info[SMDSEntity_Triangle]   + info[SMDSEntity_Quad_Triangle];
00330     long nbQuadrangles = info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle];
00331     long nb2DLinear    = info[SMDSEntity_Triangle] + info[SMDSEntity_Quadrangle] + info[SMDSEntity_Polygon];
00332     long nb2DQuadratic = info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle];
00333     myWidgets[i2D][iTotal]               ->setProperty( "text", QString::number( nb2DLinear + nb2DQuadratic ) );
00334     myWidgets[i2D][iLinear]              ->setProperty( "text", QString::number( nb2DLinear ) );
00335     myWidgets[i2D][iQuadratic]           ->setProperty( "text", QString::number( nb2DQuadratic ) );
00336     myWidgets[i2DTriangles][iTotal]      ->setProperty( "text", QString::number( nbTriangles ) );
00337     myWidgets[i2DTriangles][iLinear]     ->setProperty( "text", QString::number( info[SMDSEntity_Triangle] ) );
00338     myWidgets[i2DTriangles][iQuadratic]  ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Triangle] ) );
00339     myWidgets[i2DQuadrangles][iTotal]    ->setProperty( "text", QString::number( nbQuadrangles ) );
00340     myWidgets[i2DQuadrangles][iLinear]   ->setProperty( "text", QString::number( info[SMDSEntity_Quadrangle] ) );
00341     myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Quadrangle] + info[SMDSEntity_BiQuad_Quadrangle] ));
00342     myWidgets[i2DPolygons][iTotal]       ->setProperty( "text", QString::number( info[SMDSEntity_Polygon] ) );
00343     long nbTetrahedrons = info[SMDSEntity_Tetra]   + info[SMDSEntity_Quad_Tetra];
00344     long nbHexahedrons  = info[SMDSEntity_Hexa]    + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa];
00345     long nbPyramids     = info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid];
00346     long nbPrisms       = info[SMDSEntity_Penta]   + info[SMDSEntity_Quad_Penta];
00347     long nb3DLinear     = info[SMDSEntity_Tetra] + info[SMDSEntity_Hexa] + info[SMDSEntity_Pyramid] + info[SMDSEntity_Penta] + info[SMDSEntity_Polyhedra] + info[SMDSEntity_Hexagonal_Prism];
00348     long nb3DQuadratic  = info[SMDSEntity_Quad_Tetra] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] + info[SMDSEntity_Quad_Pyramid] + info[SMDSEntity_Quad_Penta];
00349     myWidgets[i3D][iTotal]                ->setProperty( "text", QString::number( nb3DLinear + nb3DQuadratic ) );
00350     myWidgets[i3D][iLinear]               ->setProperty( "text", QString::number( nb3DLinear ) );
00351     myWidgets[i3D][iQuadratic]            ->setProperty( "text", QString::number( nb3DQuadratic ) );
00352     myWidgets[i3DTetrahedrons][iTotal]    ->setProperty( "text", QString::number( nbTetrahedrons ) );
00353     myWidgets[i3DTetrahedrons][iLinear]   ->setProperty( "text", QString::number( info[SMDSEntity_Tetra] ) );
00354     myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Tetra] ) );
00355     myWidgets[i3DHexahedrons][iTotal]     ->setProperty( "text", QString::number( nbHexahedrons ) );
00356     myWidgets[i3DHexahedrons][iLinear]    ->setProperty( "text", QString::number( info[SMDSEntity_Hexa] ) );
00357     myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_TriQuad_Hexa] ) );
00358     myWidgets[i3DPyramids][iTotal]        ->setProperty( "text", QString::number( nbPyramids ) );
00359     myWidgets[i3DPyramids][iLinear]       ->setProperty( "text", QString::number( info[SMDSEntity_Pyramid] ) );
00360     myWidgets[i3DPyramids][iQuadratic]    ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Pyramid] ) );
00361     myWidgets[i3DPrisms][iTotal]          ->setProperty( "text", QString::number( nbPrisms ) );
00362     myWidgets[i3DPrisms][iLinear]         ->setProperty( "text", QString::number( info[SMDSEntity_Penta] ) );
00363     myWidgets[i3DPrisms][iQuadratic]      ->setProperty( "text", QString::number( info[SMDSEntity_Quad_Penta] ) );
00364     myWidgets[i3DHexaPrisms][iTotal]      ->setProperty( "text", QString::number( info[SMDSEntity_Hexagonal_Prism] ) );
00365     myWidgets[i3DPolyhedrons][iTotal]     ->setProperty( "text", QString::number( info[SMDSEntity_Polyhedra] ) );
00366 
00367     // before full loading from study file, type of elements in a sub-mesh can't be defined
00368     // in some cases
00369     bool infoOK = obj->IsMeshInfoCorrect();
00370     myLoadBtn->setVisible( !infoOK );
00371     if ( !infoOK )
00372     {
00373       // two options:
00374       // 1. Type of 2D or 3D elements is unknown but their nb is OK (for a sub-mesh)
00375       // 2. No info at all (for a group on geom or filter)
00376       bool hasAnyInfo = false;
00377       for ( size_t i = 0; i < info->length() && !hasAnyInfo; ++i )
00378         hasAnyInfo = info[i];
00379       if ( hasAnyInfo ) // believe it is a sub-mesh
00380       {
00381         if ( nb2DLinear + nb2DQuadratic > 0 )
00382         {
00383           myWidgets[i2D][iLinear]              ->setProperty( "text", "?" );
00384           myWidgets[i2D][iQuadratic]           ->setProperty( "text", "?" );
00385           myWidgets[i2DTriangles][iTotal]      ->setProperty( "text", "?" );
00386           myWidgets[i2DTriangles][iLinear]     ->setProperty( "text", "?" );
00387           myWidgets[i2DTriangles][iQuadratic]  ->setProperty( "text", "?" );
00388           myWidgets[i2DQuadrangles][iTotal]    ->setProperty( "text", "?" );
00389           myWidgets[i2DQuadrangles][iLinear]   ->setProperty( "text", "?" );
00390           myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", "?" );
00391           myWidgets[i2DPolygons][iTotal]       ->setProperty( "text", "?" );
00392         }
00393         else if ( nb3DLinear + nb3DQuadratic > 0 )
00394         {
00395           myWidgets[i3D][iLinear]               ->setProperty( "text", "?" );
00396           myWidgets[i3D][iQuadratic]            ->setProperty( "text", "?" );
00397           myWidgets[i3DTetrahedrons][iTotal]    ->setProperty( "text", "?" );
00398           myWidgets[i3DTetrahedrons][iLinear]   ->setProperty( "text", "?" );
00399           myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", "?" );
00400           myWidgets[i3DHexahedrons][iTotal]     ->setProperty( "text", "?" );
00401           myWidgets[i3DHexahedrons][iLinear]    ->setProperty( "text", "?" );
00402           myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", "?" );
00403           myWidgets[i3DPyramids][iTotal]        ->setProperty( "text", "?" );
00404           myWidgets[i3DPyramids][iLinear]       ->setProperty( "text", "?" );
00405           myWidgets[i3DPyramids][iQuadratic]    ->setProperty( "text", "?" );
00406           myWidgets[i3DPrisms][iTotal]          ->setProperty( "text", "?" );
00407           myWidgets[i3DPrisms][iLinear]         ->setProperty( "text", "?" );
00408           myWidgets[i3DPrisms][iQuadratic]      ->setProperty( "text", "?" );
00409           myWidgets[i3DHexaPrisms][iTotal]      ->setProperty( "text", "?" );
00410           myWidgets[i3DPolyhedrons][iTotal]     ->setProperty( "text", "?" );
00411         }
00412       }
00413       else
00414       {
00415         myWidgets[iNodes][iTotal]             ->setProperty( "text", "?" );
00416         myWidgets[i0D][iTotal]                ->setProperty( "text", "?" );
00417         myWidgets[i1D][iTotal]                ->setProperty( "text", "?" );
00418         myWidgets[i1D][iLinear]               ->setProperty( "text", "?" );
00419         myWidgets[i1D][iQuadratic]            ->setProperty( "text", "?" );
00420         myWidgets[i2D][iTotal]                ->setProperty( "text", "?" );
00421         myWidgets[i2D][iLinear]               ->setProperty( "text", "?" );
00422         myWidgets[i2D][iQuadratic]            ->setProperty( "text", "?" );
00423         myWidgets[i2DTriangles][iTotal]       ->setProperty( "text", "?" );
00424         myWidgets[i2DTriangles][iLinear]      ->setProperty( "text", "?" );
00425         myWidgets[i2DTriangles][iQuadratic]   ->setProperty( "text", "?" );
00426         myWidgets[i2DQuadrangles][iTotal]     ->setProperty( "text", "?" );
00427         myWidgets[i2DQuadrangles][iLinear]    ->setProperty( "text", "?" );
00428         myWidgets[i2DQuadrangles][iQuadratic] ->setProperty( "text", "?" );
00429         myWidgets[i2DPolygons][iTotal]        ->setProperty( "text", "?" );
00430         myWidgets[i3D][iTotal]                ->setProperty( "text", "?" );
00431         myWidgets[i3D][iLinear]               ->setProperty( "text", "?" );
00432         myWidgets[i3D][iQuadratic]            ->setProperty( "text", "?" );
00433         myWidgets[i3DTetrahedrons][iTotal]    ->setProperty( "text", "?" );
00434         myWidgets[i3DTetrahedrons][iLinear]   ->setProperty( "text", "?" );
00435         myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", "?" );
00436         myWidgets[i3DHexahedrons][iTotal]     ->setProperty( "text", "?" );
00437         myWidgets[i3DHexahedrons][iLinear]    ->setProperty( "text", "?" );
00438         myWidgets[i3DHexahedrons][iQuadratic] ->setProperty( "text", "?" );
00439         myWidgets[i3DPyramids][iTotal]        ->setProperty( "text", "?" );
00440         myWidgets[i3DPyramids][iLinear]       ->setProperty( "text", "?" );
00441         myWidgets[i3DPyramids][iQuadratic]    ->setProperty( "text", "?" );
00442         myWidgets[i3DPrisms][iTotal]          ->setProperty( "text", "?" );
00443         myWidgets[i3DPrisms][iLinear]         ->setProperty( "text", "?" );
00444         myWidgets[i3DPrisms][iQuadratic]      ->setProperty( "text", "?" );
00445         myWidgets[i3DHexaPrisms][iTotal]      ->setProperty( "text", "?" );
00446         myWidgets[i3DPolyhedrons][iTotal]     ->setProperty( "text", "?" );
00447       }
00448     }
00449   }
00450 }
00451 
00455 void SMESHGUI_MeshInfo::loadMesh()
00456 {
00457   SUIT_OverrideCursor wc;
00458 
00459   SALOME_ListIO selected;
00460   SMESHGUI::selectionMgr()->selectedObjects( selected );
00461 
00462   if ( selected.Extent() == 1 ) {
00463     Handle(SALOME_InteractiveObject) IO = selected.First();
00464     SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
00465     if ( !CORBA::is_nil( obj ) ) {
00466       SMESH::SMESH_Mesh_var mesh = obj->GetMesh();
00467       if ( !mesh->_is_nil() )
00468       {
00469         mesh->Load();
00470         showInfo( obj );
00471       }
00472     }
00473   }
00474 }
00475 
00479 void SMESHGUI_MeshInfo::clear()
00480 {
00481   myWidgets[iName][iSingle]->setProperty( "text", QString() );
00482   myWidgets[iObject][iSingle]->setProperty( "text", QString() );
00483   myWidgets[iNodes][iTotal]->setProperty( "text", QString::number( 0 ) );
00484   myWidgets[i0D][iTotal]->setProperty( "text", QString::number( 0 ) );
00485   myWidgets[i1D][iTotal]->setProperty( "text", QString::number( 0 ) );
00486   myWidgets[i1D][iLinear]->setProperty( "text", QString::number( 0 ) );
00487   myWidgets[i1D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00488   myWidgets[i2D][iTotal]->setProperty( "text", QString::number( 0 ) );
00489   myWidgets[i2D][iLinear]->setProperty( "text", QString::number( 0 ) );
00490   myWidgets[i2D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00491   myWidgets[i2DTriangles][iTotal]->setProperty( "text", QString::number( 0 ) );
00492   myWidgets[i2DTriangles][iLinear]->setProperty( "text", QString::number( 0 ) );
00493   myWidgets[i2DTriangles][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00494   myWidgets[i2DQuadrangles][iTotal]->setProperty( "text", QString::number( 0 ) );
00495   myWidgets[i2DQuadrangles][iLinear]->setProperty( "text", QString::number( 0 ) );
00496   myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00497   myWidgets[i2DPolygons][iTotal]->setProperty( "text", QString::number( 0 ) );
00498   myWidgets[i3D][iTotal]->setProperty( "text", QString::number( 0 ) );
00499   myWidgets[i3D][iLinear]->setProperty( "text", QString::number( 0 ) );
00500   myWidgets[i3D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00501   myWidgets[i3DTetrahedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
00502   myWidgets[i3DTetrahedrons][iLinear]->setProperty( "text", QString::number( 0 ) );
00503   myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00504   myWidgets[i3DHexahedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
00505   myWidgets[i3DHexahedrons][iLinear]->setProperty( "text", QString::number( 0 ) );
00506   myWidgets[i3DHexahedrons][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00507   myWidgets[i3DPyramids][iTotal]->setProperty( "text", QString::number( 0 ) );
00508   myWidgets[i3DPyramids][iLinear]->setProperty( "text", QString::number( 0 ) );
00509   myWidgets[i3DPyramids][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00510   myWidgets[i3DPrisms][iTotal]->setProperty( "text", QString::number( 0 ) );
00511   myWidgets[i3DPrisms][iLinear]->setProperty( "text", QString::number( 0 ) );
00512   myWidgets[i3DPrisms][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00513   myWidgets[i3DHexaPrisms][iTotal]->setProperty( "text", QString::number( 0 ) );
00514   myWidgets[i3DPolyhedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
00515 }
00516 
00521 QLabel* SMESHGUI_MeshInfo::createField()
00522 {
00523   QLabel* lab = new QLabel( this );
00524   lab->setFrameStyle( StyledPanel | Sunken );
00525   lab->setAlignment( Qt::AlignCenter );
00526   lab->setAutoFillBackground( true );
00527   QPalette pal = lab->palette();
00528   pal.setColor( QPalette::Window, QApplication::palette().color( QPalette::Active, QPalette::Base ) );
00529   lab->setPalette( pal );
00530   lab->setMinimumWidth( 70 );
00531   return lab;
00532 }
00533 
00538 QWidget* SMESHGUI_MeshInfo::createLine()
00539 {
00540   QFrame* line = new QFrame( this );
00541   line->setFrameStyle( HLine | Sunken );
00542   return line;
00543 }
00544 
00551 void SMESHGUI_MeshInfo::setFontAttributes( QWidget* w, int attr, bool val )
00552 {
00553   if ( w && attr ) {
00554     QFont f = w->font();
00555     if ( attr & Bold   ) f.setBold( val );
00556     if ( attr & Italic ) f.setItalic( val );
00557     w->setFont( f );
00558   }
00559 }
00560 
00567 void SMESHGUI_MeshInfo::setFieldsVisible( int start, int end, bool on )
00568 {
00569   start = qMax( 0, start );
00570   end   = qMin( end, (int)iElementsEnd );
00571   for ( int i = start; i < end; i++ ) {
00572     wlist wl = myWidgets[i];
00573     foreach ( QWidget* w, wl ) w->setVisible( on );
00574   }
00575 }
00576 
00586 SMESHGUI_ElemInfo::SMESHGUI_ElemInfo( QWidget* parent )
00587 : QWidget( parent ), myActor( 0 ), myIsElement( -1 )
00588 {
00589   myFrame = new QWidget( this );
00590   myExtra = new QWidget( this );
00591   myCurrent = new QLabel( "10/43 items shown", myExtra );
00592   myCurrent->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00593   myPrev = new QPushButton( tr( "<<" ), myExtra );
00594   myNext = new QPushButton( tr( ">>" ), myExtra );
00595   QHBoxLayout* hbl = new QHBoxLayout( myExtra );
00596   hbl->setContentsMargins( 0, SPACING, 0, 0 );
00597   hbl->setSpacing( SPACING );
00598   hbl->addStretch();
00599   hbl->addWidget( myCurrent );
00600   hbl->addWidget( myPrev );
00601   hbl->addWidget( myNext );
00602   QVBoxLayout* vbl = new QVBoxLayout( this );
00603   vbl->setMargin( 0 );
00604   vbl->setSpacing( 0 );
00605   vbl->addWidget( myFrame );
00606   vbl->addWidget( myExtra );
00607   connect( myPrev, SIGNAL( clicked() ), this, SLOT( showPrevious() ) );
00608   connect( myNext, SIGNAL( clicked() ), this, SLOT( showNext() ) );
00609   clear();
00610 }
00611 
00615 SMESHGUI_ElemInfo::~SMESHGUI_ElemInfo()
00616 {
00617 }
00618 
00623 void SMESHGUI_ElemInfo::setSource( SMESH_Actor* actor )
00624 {
00625   if ( myActor != actor ) {
00626     myActor = actor;
00627     myIsElement = -1;
00628     clear();
00629   }
00630 }
00631 
00637 void SMESHGUI_ElemInfo::showInfo( long id, bool isElem )
00638 {
00639   QSet<long> ids;
00640   ids << id;
00641   showInfo( ids, isElem );
00642 }
00643 
00649 void SMESHGUI_ElemInfo::showInfo( QSet<long> ids, bool isElem )
00650 {
00651   QList<long> newIds = ids.toList();
00652   qSort( newIds );
00653   if ( myIDs == newIds && myIsElement == isElem ) return;
00654 
00655   myIDs = newIds;
00656   myIsElement = isElem;
00657   myIndex = 0;
00658   updateControls();
00659   information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
00660 }
00661 
00665 void SMESHGUI_ElemInfo::clear()
00666 {
00667   myIDs.clear();
00668   myIndex = 0;
00669   clearInternal();
00670   updateControls();
00671 }
00672 
00677 QWidget* SMESHGUI_ElemInfo::frame() const
00678 {
00679   return myFrame;
00680 }
00681 
00686 SMESH_Actor* SMESHGUI_ElemInfo::actor() const
00687 {
00688   return myActor;
00689 }
00690 
00695 bool SMESHGUI_ElemInfo::isElements() const
00696 {
00697   return myIsElement;
00698 }
00699 
00712 void SMESHGUI_ElemInfo::clearInternal()
00713 {
00714 }
00715 
00721 SMESHGUI_ElemInfo::Connectivity SMESHGUI_ElemInfo::nodeConnectivity( const SMDS_MeshNode* node )
00722 {
00723   Connectivity elmap;
00724   if ( node ) {
00725     SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
00726     while ( it && it->more() ) {
00727       const SMDS_MeshElement* ne = it->next();
00728       elmap[ ne->GetType() ] << ne->GetID();
00729     }
00730   }
00731   return elmap;
00732 }
00733 
00740 QString SMESHGUI_ElemInfo::formatConnectivity( Connectivity connectivity, int type )
00741 {
00742   QStringList str;
00743   if ( connectivity.contains( type ) ) {
00744     QList<int> elements = connectivity[ type ];
00745     qSort( elements );
00746     foreach( int id, elements )
00747       str << QString::number( id );
00748   }
00749   return str.join( " " );
00750 }
00751 
00756 SMESHGUI_ElemInfo::XYZ SMESHGUI_ElemInfo::gravityCenter( const SMDS_MeshElement* element )
00757 {
00758   XYZ xyz;
00759   if ( element ) {
00760     SMDS_ElemIteratorPtr nodeIt = element->nodesIterator();
00761     while ( nodeIt->more() ) {
00762       const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
00763       xyz.add( node->X(), node->Y(), node->Z() );
00764     }
00765     xyz.divide( element->NbNodes() );
00766   }
00767   return xyz;
00768 }
00769 
00774 void SMESHGUI_ElemInfo::showPrevious()
00775 {
00776   myIndex = qMax( 0, myIndex-1 );
00777   updateControls();
00778   information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
00779 }
00780 
00785 void SMESHGUI_ElemInfo::showNext()
00786 {
00787   myIndex = qMin( myIndex+1, myIDs.count() / MAXITEMS );
00788   updateControls();
00789   information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
00790 }
00791 
00795 void SMESHGUI_ElemInfo::updateControls()
00796 {
00797   myExtra->setVisible( myIDs.count() > MAXITEMS );
00798   myCurrent->setText( tr( "X_FROM_Y_ITEMS_SHOWN" ).arg( myIndex*MAXITEMS+1 ).arg(qMin(myIndex*MAXITEMS+MAXITEMS, myIDs.count())).arg( myIDs.count() ) );
00799   myPrev->setEnabled( myIndex > 0 );
00800   myNext->setEnabled( (myIndex+1)*MAXITEMS < myIDs.count() );
00801 }
00802 
00812 SMESHGUI_SimpleElemInfo::SMESHGUI_SimpleElemInfo( QWidget* parent )
00813 : SMESHGUI_ElemInfo( parent )
00814 {
00815   myInfo = new QTextBrowser( frame() );
00816   QVBoxLayout* l = new QVBoxLayout( frame() );
00817   l->setMargin( 0 );
00818   l->addWidget( myInfo );
00819 }
00820 
00825 void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
00826 {
00827   clearInternal();
00828   
00829   if ( actor() ) {
00830     int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
00831     foreach ( long id, ids ) {
00832       if ( !isElements() ) {
00833         //
00834         // show node info
00835         //
00836         const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
00837         if ( !e ) return;
00838         const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
00839         
00840         // node ID
00841         myInfo->append( QString( "<b>%1 #%2</b>" ).arg( tr( "NODE" ) ).arg( id ) );
00842         // separator
00843         myInfo->append( "" );
00844         // coordinates
00845         myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
00846                         arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
00847                         arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
00848                         arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
00849         // separator
00850         myInfo->append( "" );
00851         // connectivity
00852         Connectivity connectivity = nodeConnectivity( node );
00853         if ( !connectivity.isEmpty() ) {
00854           myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
00855           QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
00856           if ( !con.isEmpty() )
00857             myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
00858           con = formatConnectivity( connectivity, SMDSAbs_Edge );
00859           if ( !con.isEmpty() )
00860             myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
00861           con = formatConnectivity( connectivity, SMDSAbs_Face );
00862           if ( !con.isEmpty() )
00863             myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
00864           con = formatConnectivity( connectivity, SMDSAbs_Volume );
00865           if ( !con.isEmpty() )
00866             myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
00867         }
00868         else {
00869           myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
00870         }
00871       }
00872       else {
00873         //
00874         // show element info
00875         // 
00876         const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
00877         if ( !e ) return;
00878         
00879         // element ID && type
00880         QString stype;
00881         switch( e->GetType() ) {
00882         case SMDSAbs_0DElement:
00883           stype = tr( "0D ELEMENT" ); break;
00884         case SMDSAbs_Edge:
00885           stype = tr( "EDGE" ); break;
00886         case SMDSAbs_Face:
00887           stype = tr( "FACE" ); break;
00888         case SMDSAbs_Volume:
00889           stype = tr( "VOLUME" ); break;
00890         default: 
00891           break;
00892         }
00893         if ( stype.isEmpty() ) return;
00894         myInfo->append( QString( "<b>%1 #%2</b>" ).arg( stype ).arg( id ) );
00895         // separator
00896         myInfo->append( "" );
00897         // geometry type
00898         QString gtype;
00899         switch( e->GetEntityType() ) {
00900         case SMDSEntity_Triangle:
00901         case SMDSEntity_Quad_Triangle:
00902           gtype = tr( "TRIANGLE" ); break;
00903         case SMDSEntity_Quadrangle:
00904         case SMDSEntity_Quad_Quadrangle:
00905         case SMDSEntity_BiQuad_Quadrangle:
00906           gtype = tr( "QUADRANGLE" ); break;
00907         case SMDSEntity_Polygon:
00908         case SMDSEntity_Quad_Polygon:
00909           gtype = tr( "POLYGON" ); break;
00910         case SMDSEntity_Tetra:
00911         case SMDSEntity_Quad_Tetra:
00912           gtype = tr( "TETRAHEDRON" ); break;
00913         case SMDSEntity_Pyramid:
00914         case SMDSEntity_Quad_Pyramid:
00915           gtype = tr( "PYRAMID" ); break;
00916         case SMDSEntity_Hexa:
00917         case SMDSEntity_Quad_Hexa:
00918         case SMDSEntity_TriQuad_Hexa:
00919           gtype = tr( "HEXAHEDRON" ); break;
00920         case SMDSEntity_Penta:
00921         case SMDSEntity_Quad_Penta:
00922           gtype = tr( "PRISM" ); break;
00923         case SMDSEntity_Hexagonal_Prism:
00924           gtype = tr( "HEX_PRISM" ); break;
00925         case SMDSEntity_Polyhedra:
00926         case SMDSEntity_Quad_Polyhedra:
00927           gtype = tr( "POLYHEDRON" ); break;
00928         default: 
00929           break;
00930         }
00931         if ( !gtype.isEmpty() )
00932           myInfo->append( QString( "<b>%1:</b> %2" ).arg( tr( "TYPE" ) ).arg( gtype ) );
00933         // quadratic flag and gravity center (any element except 0D)
00934         if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Last ) {
00935           // quadratic flag
00936           myInfo->append( QString( "<b>%1?</b> %2" ).arg( tr( "QUADRATIC" ) ).arg( e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) ) );
00937           // separator
00938           myInfo->append( "" );
00939           // gravity center
00940           XYZ gc = gravityCenter( e );
00941           myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "GRAVITY_CENTER" ) ).arg( gc.x() ).arg( gc.y() ).arg( gc.z() ) );
00942         }
00943         // separator
00944         myInfo->append( "" );
00945         // connectivity
00946         SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
00947         for ( int idx = 1; nodeIt->more(); idx++ ) {
00948           const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
00949           // node number and ID
00950           myInfo->append( QString( "<b>%1 %2/%3</b> - #%4" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ).arg( node->GetID() ) );
00951           // node coordinates
00952           myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
00953                           arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
00954                           arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
00955                           arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
00956           // node connectivity
00957           Connectivity connectivity = nodeConnectivity( node );
00958           if ( !connectivity.isEmpty() ) {
00959             myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
00960             QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
00961             if ( !con.isEmpty() )
00962               myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
00963             con = formatConnectivity( connectivity, SMDSAbs_Edge );
00964             if ( !con.isEmpty() )
00965               myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
00966             con = formatConnectivity( connectivity, SMDSAbs_Face );
00967             if ( !con.isEmpty() )
00968               myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
00969             con = formatConnectivity( connectivity, SMDSAbs_Volume );
00970             if ( !con.isEmpty() )
00971               myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
00972           }
00973           else {
00974             myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
00975           }
00976         }
00977       }
00978       // separator
00979       if ( ids.count() > 1 ) {
00980         myInfo->append( "" );
00981         myInfo->append( "------" );
00982         myInfo->append( "" );
00983       }
00984     }
00985   }
00986 }
00987 
00991 void SMESHGUI_SimpleElemInfo::clearInternal()
00992 {
00993   myInfo->clear();
00994 }
00995 
01001 class SMESHGUI_TreeElemInfo::ItemDelegate : public QItemDelegate
01002 {
01003 public:
01004   ItemDelegate( QObject* );
01005   QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
01006 };
01007 
01012 SMESHGUI_TreeElemInfo::ItemDelegate::ItemDelegate( QObject* parent ) : QItemDelegate( parent )
01013 {
01014 }
01015 
01020 QWidget* SMESHGUI_TreeElemInfo::ItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
01021 {
01022   QWidget* w = index.column() == 0 ? 0: QItemDelegate::createEditor( parent, option, index );
01023   if ( qobject_cast<QLineEdit*>( w ) ) qobject_cast<QLineEdit*>( w )->setReadOnly(  true );
01024   return w;
01025 }
01026 
01036 SMESHGUI_TreeElemInfo::SMESHGUI_TreeElemInfo( QWidget* parent )
01037 : SMESHGUI_ElemInfo( parent )
01038 {
01039   myInfo = new QTreeWidget( frame() );
01040   myInfo->setColumnCount( 2 );
01041   myInfo->setHeaderLabels( QStringList() << tr( "PROPERTY" ) << tr( "VALUE" ) );
01042   myInfo->header()->setStretchLastSection( true );
01043   myInfo->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
01044   myInfo->setItemDelegate( new ItemDelegate( myInfo ) );
01045   QVBoxLayout* l = new QVBoxLayout( frame() );
01046   l->setMargin( 0 );
01047   l->addWidget( myInfo );
01048 }
01049 
01054 void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
01055 {
01056   clearInternal();
01057 
01058   if ( actor() ) {
01059     int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
01060     foreach ( long id, ids ) {
01061       if ( !isElements() ) {
01062         //
01063         // show node info
01064         //
01065         const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
01066         if ( !e ) return;
01067         const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
01068       
01069         // node ID
01070         QTreeWidgetItem* nodeItem = createItem( 0, Bold | All );
01071         nodeItem->setText( 0, tr( "NODE" ) );
01072         nodeItem->setText( 1, QString( "#%1" ).arg( id ) );
01073         // coordinates
01074         QTreeWidgetItem* coordItem = createItem( nodeItem, Bold );
01075         coordItem->setText( 0, tr( "COORDINATES" ) );
01076         QTreeWidgetItem* xItem = createItem( coordItem );
01077         xItem->setText( 0, "X" );
01078         xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01079         QTreeWidgetItem* yItem = createItem( coordItem );
01080         yItem->setText( 0, "Y" );
01081         yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01082         QTreeWidgetItem* zItem = createItem( coordItem );
01083         zItem->setText( 0, "Z" );
01084         zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01085         // connectivity
01086         QTreeWidgetItem* conItem = createItem( nodeItem, Bold );
01087         conItem->setText( 0, tr( "CONNECTIVITY" ) );
01088         Connectivity connectivity = nodeConnectivity( node );
01089         if ( !connectivity.isEmpty() ) {
01090           QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
01091           if ( !con.isEmpty() ) {
01092             QTreeWidgetItem* i = createItem( conItem );
01093             i->setText( 0, tr( "0D_ELEMENTS" ) );
01094             i->setText( 1, con );
01095           }
01096           con = formatConnectivity( connectivity, SMDSAbs_Edge );
01097           if ( !con.isEmpty() ) {
01098             QTreeWidgetItem* i = createItem( conItem );
01099             i->setText( 0, tr( "EDGES" ) );
01100             i->setText( 1, con );
01101           }
01102           con = formatConnectivity( connectivity, SMDSAbs_Face );
01103           if ( !con.isEmpty() ) {
01104             QTreeWidgetItem* i = createItem( conItem );
01105             i->setText( 0, tr( "FACES" ) );
01106             i->setText( 1, con );
01107           }
01108           con = formatConnectivity( connectivity, SMDSAbs_Volume );
01109           if ( !con.isEmpty() ) {
01110             QTreeWidgetItem* i = createItem( conItem );
01111             i->setText( 0, tr( "VOLUMES" ) );
01112             i->setText( 1, con );
01113           }
01114         }
01115         else {
01116           conItem->setText( 1, tr( "FREE_NODE" ) );
01117         }
01118       }
01119       else {
01120         //
01121         // show element info
01122         // 
01123         const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
01124         if ( !e ) return;
01125         
01126         // element ID && type
01127         QString stype;
01128         switch( e->GetType() ) {
01129         case SMDSAbs_0DElement:
01130           stype = tr( "0D ELEMENT" ); break;
01131         case SMDSAbs_Edge:
01132           stype = tr( "EDGE" ); break;
01133         case SMDSAbs_Face:
01134           stype = tr( "FACE" ); break;
01135         case SMDSAbs_Volume:
01136           stype = tr( "VOLUME" ); break;
01137         default: 
01138           break;
01139         }
01140         if ( stype.isEmpty() ) return;
01141         QTreeWidgetItem* elemItem = createItem( 0, Bold | All );
01142         elemItem->setText( 0, stype );
01143         elemItem->setText( 1, QString( "#%1" ).arg( id ) );
01144         // geometry type
01145         QString gtype;
01146         switch( e->GetEntityType() ) {
01147         case SMDSEntity_Triangle:
01148         case SMDSEntity_Quad_Triangle:
01149           gtype = tr( "TRIANGLE" ); break;
01150         case SMDSEntity_Quadrangle:
01151         case SMDSEntity_Quad_Quadrangle:
01152         case SMDSEntity_BiQuad_Quadrangle:
01153           gtype = tr( "QUADRANGLE" ); break;
01154         case SMDSEntity_Polygon:
01155         case SMDSEntity_Quad_Polygon:
01156           gtype = tr( "POLYGON" ); break;
01157         case SMDSEntity_Tetra:
01158         case SMDSEntity_Quad_Tetra:
01159           gtype = tr( "TETRAHEDRON" ); break;
01160         case SMDSEntity_Pyramid:
01161         case SMDSEntity_Quad_Pyramid:
01162           gtype = tr( "PYRAMID" ); break;
01163         case SMDSEntity_Hexa:
01164         case SMDSEntity_Quad_Hexa:
01165         case SMDSEntity_TriQuad_Hexa:
01166           gtype = tr( "HEXAHEDRON" ); break;
01167         case SMDSEntity_Penta:
01168         case SMDSEntity_Quad_Penta:
01169           gtype = tr( "PRISM" ); break;
01170         case SMDSEntity_Hexagonal_Prism:
01171           gtype = tr( "HEX_PRISM" ); break;
01172         case SMDSEntity_Polyhedra:
01173         case SMDSEntity_Quad_Polyhedra:
01174           gtype = tr( "POLYHEDRON" ); break;
01175         default: 
01176           break;
01177         }
01178         if ( !gtype.isEmpty() ) {
01179           QTreeWidgetItem* typeItem = createItem( elemItem, Bold );
01180           typeItem->setText( 0, tr( "TYPE" ) );
01181           typeItem->setText( 1, gtype );
01182         }
01183         // quadratic flag and gravity center (any element except 0D)
01184         if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Last ) {
01185           // quadratic flag
01186           QTreeWidgetItem* quadItem = createItem( elemItem, Bold );
01187           quadItem->setText( 0, tr( "QUADRATIC" ) );
01188           quadItem->setText( 1, e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) );
01189           // gravity center
01190           XYZ gc = gravityCenter( e );
01191           QTreeWidgetItem* gcItem = createItem( elemItem, Bold );
01192           gcItem->setText( 0, tr( "GRAVITY_CENTER" ) );
01193           QTreeWidgetItem* xItem = createItem( gcItem );
01194           xItem->setText( 0, "X" );
01195           xItem->setText( 1, QString::number( gc.x(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01196           QTreeWidgetItem* yItem = createItem( gcItem );
01197           yItem->setText( 0, "Y" );
01198           yItem->setText( 1, QString::number( gc.y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01199           QTreeWidgetItem* zItem = createItem( gcItem );
01200           zItem->setText( 0, "Z" );
01201           zItem->setText( 1, QString::number( gc.z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01202         }
01203         // connectivity
01204         QTreeWidgetItem* conItem = createItem( elemItem, Bold );
01205         conItem->setText( 0, tr( "CONNECTIVITY" ) );
01206         SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
01207         for ( int idx = 1; nodeIt->more(); idx++ ) {
01208           const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
01209           // node number and ID
01210           QTreeWidgetItem* nodeItem = createItem( conItem, Bold );
01211           nodeItem->setText( 0, QString( "%1 %2 / %3" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ) );
01212           nodeItem->setText( 1, QString( "#%1" ).arg( node->GetID() ) );
01213           nodeItem->setExpanded( false );
01214           // node coordinates
01215           QTreeWidgetItem* coordItem = createItem( nodeItem );
01216           coordItem->setText( 0, tr( "COORDINATES" ) );
01217           QTreeWidgetItem* xItem = createItem( coordItem );
01218           xItem->setText( 0, "X" );
01219           xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01220           QTreeWidgetItem* yItem = createItem( coordItem );
01221           yItem->setText( 0, "Y" );
01222           yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01223           QTreeWidgetItem* zItem = createItem( coordItem );
01224           zItem->setText( 0, "Z" );
01225           zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01226           // node connectivity
01227           QTreeWidgetItem* nconItem = createItem( nodeItem );
01228           nconItem->setText( 0, tr( "CONNECTIVITY" ) );
01229           Connectivity connectivity = nodeConnectivity( node );
01230           if ( !connectivity.isEmpty() ) {
01231             QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
01232             if ( !con.isEmpty() ) {
01233               QTreeWidgetItem* i = createItem( nconItem );
01234               i->setText( 0, tr( "0D_ELEMENTS" ) );
01235               i->setText( 1, con );
01236             }
01237             con = formatConnectivity( connectivity, SMDSAbs_Edge );
01238             if ( !con.isEmpty() ) {
01239               QTreeWidgetItem* i = createItem( nconItem );
01240               i->setText( 0, tr( "EDGES" ) );
01241               i->setText( 1, con );
01242             }
01243             con = formatConnectivity( connectivity, SMDSAbs_Face );
01244             if ( !con.isEmpty() ) {
01245               QTreeWidgetItem* i = createItem( nconItem );
01246               i->setText( 0, tr( "FACES" ) );
01247               i->setText( 1, con );
01248             }
01249             con = formatConnectivity( connectivity, SMDSAbs_Volume );
01250             if ( !con.isEmpty() ) {
01251               QTreeWidgetItem* i = createItem( nconItem );
01252               i->setText( 0, tr( "VOLUMES" ) );
01253               i->setText( 1, con );
01254             }
01255           }
01256         }
01257       }
01258     }
01259   }
01260 }
01261 
01265 void SMESHGUI_TreeElemInfo::clearInternal()
01266 {
01267   myInfo->clear();
01268   myInfo->repaint();
01269 }
01270 
01277 QTreeWidgetItem* SMESHGUI_TreeElemInfo::createItem( QTreeWidgetItem* parent, int flags )
01278 {
01279   QTreeWidgetItem* item;
01280   if ( parent )
01281     item = new QTreeWidgetItem( parent );
01282   else
01283     item = new QTreeWidgetItem( myInfo );
01284 
01285   item->setFlags( item->flags() | Qt::ItemIsEditable );
01286 
01287   QFont f = item->font( 0 );
01288   f.setBold( true );
01289   for ( int i = 0; i < myInfo->columnCount(); i++ ) {
01290     if ( ( flags & Bold ) && ( i == 0 || flags & All ) )
01291       item->setFont( i, f );
01292   }
01293 
01294   item->setExpanded( true );
01295   return item;
01296 }
01297 
01310 GrpComputor::GrpComputor( SMESH::SMESH_GroupBase_ptr grp, QTreeWidgetItem* item, QObject* parent )
01311   : QObject( parent ), myItem( item )
01312 {
01313   myGroup = SMESH::SMESH_GroupBase::_narrow( grp );
01314 }
01315 
01319 void GrpComputor::compute()
01320 {
01321   if ( !CORBA::is_nil( myGroup ) && myItem ) {
01322     QTreeWidgetItem* item = myItem;
01323     myItem = 0;
01324     int nbNodes = myGroup->GetNumberOfNodes();
01325     item->treeWidget()->removeItemWidget( item, 1 );
01326     item->setText( 1, QString::number( nbNodes ));
01327   }
01328 }
01329 
01339 SMESHGUI_AddInfo::SMESHGUI_AddInfo( QWidget* parent )
01340 : QTreeWidget( parent )
01341 {
01342   setColumnCount( 2 );
01343   header()->setStretchLastSection( true );
01344   header()->setResizeMode( 0, QHeaderView::ResizeToContents );
01345   header()->hide();
01346 }
01347 
01351 SMESHGUI_AddInfo::~SMESHGUI_AddInfo()
01352 {
01353 }
01354 
01359 void SMESHGUI_AddInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
01360 {
01361   myComputors.clear();
01362 
01363   clear();
01364 
01365   if ( CORBA::is_nil( obj ) ) return;
01366 
01367   _PTR(SObject) sobj = SMESH::ObjectToSObject( obj );
01368   if ( !sobj ) return;
01369 
01370   // name
01371   QTreeWidgetItem* nameItem = createItem( 0, Bold | All );
01372   nameItem->setText( 0, tr( "NAME" ) );
01373   nameItem->setText( 1, sobj->GetName().c_str() );
01374   
01375   SMESH::SMESH_Mesh_var      aMesh    = SMESH::SMESH_Mesh::_narrow( obj );
01376   SMESH::SMESH_subMesh_var   aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
01377   SMESH::SMESH_GroupBase_var aGroup   = SMESH::SMESH_GroupBase::_narrow( obj );
01378   
01379   if ( !aMesh->_is_nil() )
01380     meshInfo( aMesh, nameItem );
01381   else if ( !aSubMesh->_is_nil() )
01382     subMeshInfo( aSubMesh, nameItem );
01383   else if ( !aGroup->_is_nil() )
01384     groupInfo( aGroup.in(), nameItem );
01385 }
01386 
01393 QTreeWidgetItem* SMESHGUI_AddInfo::createItem( QTreeWidgetItem* parent, int flags )
01394 {
01395   QTreeWidgetItem* item;
01396 
01397   if ( parent )
01398     item = new QTreeWidgetItem( parent );
01399   else
01400     item = new QTreeWidgetItem( this );
01401 
01402   //item->setFlags( item->flags() | Qt::ItemIsEditable );
01403 
01404   QFont f = item->font( 0 );
01405   f.setBold( true );
01406   for ( int i = 0; i < columnCount(); i++ ) {
01407     if ( ( flags & Bold ) && ( i == 0 || flags & All ) )
01408       item->setFont( i, f );
01409   }
01410 
01411   item->setExpanded( true );
01412   return item;
01413 }
01414 
01420 void SMESHGUI_AddInfo::meshInfo( SMESH::SMESH_Mesh_ptr mesh, QTreeWidgetItem* parent )
01421 {
01422   // type
01423   GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh();
01424   SALOME_MED::MedFileInfo* inf = mesh->GetMEDFileInfo();
01425   QTreeWidgetItem* typeItem = createItem( parent, Bold );
01426   typeItem->setText( 0, tr( "TYPE" ) );
01427   if ( !CORBA::is_nil( shape ) ) {
01428     typeItem->setText( 1, tr( "MESH_ON_GEOMETRY" ) );
01429     _PTR(SObject) sobj = SMESH::ObjectToSObject( shape );
01430     if ( sobj ) {
01431       QTreeWidgetItem* gobjItem = createItem( typeItem );
01432       gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
01433       gobjItem->setText( 1, sobj->GetName().c_str() );
01434     }
01435   }
01436   else if ( strlen( (char*)inf->fileName ) > 0 ) {
01437     typeItem->setText( 1, tr( "MESH_FROM_FILE" ) );
01438     QTreeWidgetItem* fileItem = createItem( typeItem );
01439     fileItem->setText( 0, tr( "FILE_NAME" ) );
01440     fileItem->setText( 1, (char*)inf->fileName );
01441   }
01442   else {
01443     typeItem->setText( 1, tr( "STANDALONE_MESH" ) );
01444   }
01445   
01446   // groups
01447   SMESH::ListOfGroups_var groups = mesh->GetGroups();
01448   QTreeWidgetItem* itemGroups  = 0;
01449   QMap<int, QTreeWidgetItem*> grpItems;
01450   for ( int i = 0; i < groups->length(); i++ ) {
01451     SMESH::SMESH_GroupBase_var grp = groups[i];
01452     if ( CORBA::is_nil( grp ) ) continue;
01453     _PTR(SObject) grpSObj = SMESH::ObjectToSObject( grp );
01454     if ( !grpSObj ) continue;
01455 
01456     int grpType = grp->GetType();
01457 
01458     if ( !itemGroups ) {
01459       itemGroups = createItem( parent, Bold | All );
01460       itemGroups->setText( 0, tr( "GROUPS" ) );
01461     }
01462 
01463     if ( grpItems.find( grpType ) == grpItems.end() ) {
01464       grpItems[ grpType ] = createItem( itemGroups, Bold | All );
01465       grpItems[ grpType ]->setText( 0, tr( QString( "GROUPS_%1" ).arg( grpType ).toLatin1().constData() ) );
01466       itemGroups->insertChild( grpType-1, grpItems[ grpType ] );
01467     }
01468   
01469     // group name
01470     QTreeWidgetItem* grpNameItem = createItem( grpItems[ grpType ] );
01471     grpNameItem->setText( 0, grpSObj->GetName().c_str() );
01472 
01473     // group info
01474     groupInfo( grp.in(), grpNameItem );
01475   }
01476 
01477   // sub-meshes
01478   SMESH::submesh_array_var subMeshes = mesh->GetSubMeshes();
01479   QTreeWidgetItem* itemSubMeshes = 0;
01480   QMap<int, QTreeWidgetItem*> smItems;
01481   for ( int i = 0; i < subMeshes->length(); i++ ) {
01482     SMESH::SMESH_subMesh_var sm = subMeshes[i];
01483     if ( CORBA::is_nil( sm ) ) continue;
01484     _PTR(SObject) smSObj = SMESH::ObjectToSObject( sm );
01485     if ( !smSObj ) continue;
01486     
01487     GEOM::GEOM_Object_var gobj = sm->GetSubShape();
01488     if ( CORBA::is_nil(gobj ) ) continue;
01489     
01490     int smType = gobj->GetShapeType();
01491     if ( smType == GEOM::COMPSOLID ) smType = GEOM::COMPOUND;
01492 
01493     if ( !itemSubMeshes ) {
01494       itemSubMeshes = createItem( parent, Bold | All );
01495       itemSubMeshes->setText( 0, tr( "SUBMESHES" ) );
01496     }
01497          
01498     if ( smItems.find( smType ) == smItems.end() ) {
01499       smItems[ smType ] = createItem( itemSubMeshes, Bold | All );
01500       smItems[ smType ]->setText( 0, tr( QString( "SUBMESHES_%1" ).arg( smType ).toLatin1().constData() ) );
01501       itemSubMeshes->insertChild( smType, smItems[ smType ] );
01502     }
01503     
01504     // submesh name
01505     QTreeWidgetItem* smNameItem = createItem( smItems[ smType ] );
01506     smNameItem->setText( 0, smSObj->GetName().c_str() );
01507     
01508     // submesh info
01509     subMeshInfo( sm.in(), smNameItem );
01510   }
01511 }
01512 
01518 void SMESHGUI_AddInfo::subMeshInfo( SMESH::SMESH_subMesh_ptr subMesh, QTreeWidgetItem* parent )
01519 {
01520   bool isShort = parent->parent() != 0;
01521 
01522   if ( !isShort ) {
01523     // parent mesh
01524     _PTR(SObject) sobj = SMESH::ObjectToSObject( subMesh->GetFather() );
01525     if ( sobj ) {
01526       QTreeWidgetItem* nameItem = createItem( parent, Bold );
01527       nameItem->setText( 0, tr( "PARENT_MESH" ) );
01528       nameItem->setText( 1, sobj->GetName().c_str() );
01529     }
01530   }
01531   
01532   // shape
01533   GEOM::GEOM_Object_var gobj = subMesh->GetSubShape();
01534   _PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
01535   if ( sobj ) {
01536     QTreeWidgetItem* gobjItem = createItem( parent, Bold );
01537     gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
01538     gobjItem->setText( 1, sobj->GetName().c_str() );
01539   }
01540 }
01541 
01547 void SMESHGUI_AddInfo::groupInfo( SMESH::SMESH_GroupBase_ptr grp, QTreeWidgetItem* parent )
01548 {
01549   bool isShort = parent->parent() != 0;
01550 
01551   SMESH::SMESH_Group_var         aStdGroup  = SMESH::SMESH_Group::_narrow( grp );
01552   SMESH::SMESH_GroupOnGeom_var   aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( grp );
01553   SMESH::SMESH_GroupOnFilter_var aFltGroup  = SMESH::SMESH_GroupOnFilter::_narrow( grp );
01554 
01555   if ( !isShort ) {
01556     // parent mesh
01557     _PTR(SObject) sobj = SMESH::ObjectToSObject( grp->GetMesh() );
01558     if ( sobj ) {
01559       QTreeWidgetItem* nameItem = createItem( parent, Bold );
01560       nameItem->setText( 0, tr( "PARENT_MESH" ) );
01561       nameItem->setText( 1, sobj->GetName().c_str() );
01562     }
01563   }
01564 
01565   // type : group on geometry, standalone group, group on filter
01566   QTreeWidgetItem* typeItem = createItem( parent, Bold );
01567   typeItem->setText( 0, tr( "TYPE" ) );
01568   if ( !CORBA::is_nil( aStdGroup ) ) {
01569     typeItem->setText( 1, tr( "STANDALONE_GROUP" ) );
01570   }
01571   else if ( !CORBA::is_nil( aGeomGroup ) ) {
01572     typeItem->setText( 1, tr( "GROUP_ON_GEOMETRY" ) );
01573     GEOM::GEOM_Object_var gobj = aGeomGroup->GetShape();
01574     _PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
01575     if ( sobj ) {
01576       QTreeWidgetItem* gobjItem = createItem( typeItem );
01577       gobjItem->setText( 0, tr( "GEOM_OBJECT" ) );
01578       gobjItem->setText( 1, sobj->GetName().c_str() );
01579     }
01580   }
01581   else if ( !CORBA::is_nil( aFltGroup ) ) {
01582     typeItem->setText( 1, tr( "GROUP_ON_FILTER" ) );
01583   }
01584 
01585   if ( !isShort ) {
01586     // entity type
01587     QString etype = tr( "UNKNOWN" );
01588     switch( grp->GetType() ) {
01589     case SMESH::NODE:
01590       etype = tr( "NODE" );
01591       break;
01592     case SMESH::EDGE:
01593       etype = tr( "EDGE" );
01594       break;
01595     case SMESH::FACE:
01596       etype = tr( "FACE" );
01597       break;
01598     case SMESH::VOLUME:
01599       etype = tr( "VOLUME" );
01600       break;
01601     case SMESH::ELEM0D:
01602       etype = tr( "0DELEM" );
01603       break;
01604     default:
01605       break;
01606     }
01607     QTreeWidgetItem* etypeItem = createItem( parent, Bold );
01608     etypeItem->setText( 0, tr( "ENTITY_TYPE" ) );
01609     etypeItem->setText( 1, etype );
01610   }
01611 
01612   // size
01613   QTreeWidgetItem* sizeItem = createItem( parent, Bold );
01614   sizeItem->setText( 0, tr( "SIZE" ) );
01615   sizeItem->setText( 1, QString::number( grp->Size() ) );
01616 
01617   // color
01618   SALOMEDS::Color color = grp->GetColor();
01619   QTreeWidgetItem* colorItem = createItem( parent, Bold );
01620   colorItem->setText( 0, tr( "COLOR" ) );
01621   colorItem->setBackground( 1, QBrush( QColor( color.R*255., color.G*255., color.B*255.) ) );
01622 
01623   // nb of underlying nodes
01624   if ( grp->GetType() != SMESH::NODE) {
01625     QTreeWidgetItem* nodesItem = createItem( parent, Bold );
01626     nodesItem->setText( 0, tr( "NB_NODES" ) );
01627     int nbNodesLimit = SMESHGUI::resourceMgr()->integerValue( "SMESH", "info_groups_nodes_limit", 100000 );
01628     SMESH::SMESH_Mesh_var mesh = grp->GetMesh();
01629     bool meshLoaded = mesh->IsLoaded();
01630     bool toShowNodes = ( grp->IsNodeInfoAvailable() || nbNodesLimit <= 0 || grp->Size() <= nbNodesLimit );
01631     if ( toShowNodes && meshLoaded ) {
01632       // already calculated and up-to-date
01633       nodesItem->setText( 1, QString::number( grp->GetNumberOfNodes() ) );
01634     }
01635     else {
01636       QPushButton* btn = new QPushButton( tr( meshLoaded ? "COMPUTE" : "LOAD"), this );
01637       setItemWidget( nodesItem, 1, btn );
01638       GrpComputor* comp = new GrpComputor( grp, nodesItem, this ); 
01639       connect( btn, SIGNAL( clicked() ), comp, SLOT( compute() ) );
01640       myComputors.append( comp );
01641       if ( !meshLoaded )
01642         connect( btn, SIGNAL( clicked() ), this, SLOT( changeLoadToCompute() ) );
01643     }
01644   }
01645 }
01646 
01650 void SMESHGUI_AddInfo::changeLoadToCompute()
01651 {
01652   for ( int i = 0; i < myComputors.count(); ++i )
01653   {
01654     if ( QTreeWidgetItem* item = myComputors[i]->getItem() )
01655     {
01656       if ( QPushButton* btn = qobject_cast<QPushButton*>( itemWidget ( item, 1 )))
01657         btn->setText( tr("COMPUTE"));
01658     }
01659   }
01660 }
01661 
01672 SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page )
01673 : QDialog( parent ), myActor( 0 )
01674 {
01675   setModal( false );
01676   setAttribute( Qt::WA_DeleteOnClose, true );
01677   setWindowTitle( tr( "MESH_INFO" ) );
01678   setSizeGripEnabled( true );
01679 
01680   myTabWidget = new QTabWidget( this );
01681 
01682   // base info 
01683 
01684   myBaseInfo = new SMESHGUI_MeshInfo( myTabWidget );
01685   myTabWidget->addTab( myBaseInfo, tr( "BASE_INFO" ) );
01686 
01687   // elem info 
01688   
01689   QWidget* w = new QWidget( myTabWidget );
01690 
01691   myMode = new QButtonGroup( this );
01692   myMode->addButton( new QRadioButton( tr( "NODE_MODE" ), w ), NodeMode );
01693   myMode->addButton( new QRadioButton( tr( "ELEM_MODE" ), w ), ElemMode );
01694   myMode->button( NodeMode )->setChecked( true );
01695   myID = new QLineEdit( w );
01696   myID->setValidator( new SMESHGUI_IdValidator( this ) );
01697 
01698   int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 );
01699   mode = qMin( 1, qMax( 0, mode ) );
01700   
01701   if ( mode == 0 ) 
01702     myElemInfo = new SMESHGUI_SimpleElemInfo( w );
01703   else
01704     myElemInfo = new SMESHGUI_TreeElemInfo( w );
01705 
01706   QGridLayout* elemLayout = new QGridLayout( w );
01707   elemLayout->setMargin( MARGIN );
01708   elemLayout->setSpacing( SPACING );
01709   elemLayout->addWidget( myMode->button( NodeMode ), 0, 0 );
01710   elemLayout->addWidget( myMode->button( ElemMode ), 0, 1 );
01711   elemLayout->addWidget( myID, 0, 2 );
01712   elemLayout->addWidget( myElemInfo, 1, 0, 1, 3 );
01713   
01714   myTabWidget->addTab( w, tr( "ELEM_INFO" ) );
01715 
01716   // additional info
01717 
01718   myAddInfo = new SMESHGUI_AddInfo( myTabWidget );
01719   myTabWidget->addTab( myAddInfo, tr( "ADDITIONAL_INFO" ) );
01720 
01721   // buttons
01722 
01723   QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this );
01724   okBtn->setAutoDefault( true );
01725   okBtn->setDefault( true );
01726   okBtn->setFocus();
01727   QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
01728   helpBtn->setAutoDefault( true );
01729 
01730   QHBoxLayout* btnLayout = new QHBoxLayout;
01731   btnLayout->setSpacing( SPACING );
01732   btnLayout->setMargin( 0 );
01733 
01734   btnLayout->addWidget( okBtn );
01735   btnLayout->addStretch( 10 );
01736   btnLayout->addWidget( helpBtn );
01737 
01738   QVBoxLayout* l = new QVBoxLayout ( this );
01739   l->setMargin( MARGIN );
01740   l->setSpacing( SPACING );
01741   l->addWidget( myTabWidget );
01742   l->addLayout( btnLayout );
01743 
01744   myTabWidget->setCurrentIndex( qMax( (int)BaseInfo, qMin( (int)ElemInfo, page ) ) );
01745 
01746   connect( okBtn,       SIGNAL( clicked() ),              this, SLOT( reject() ) );
01747   connect( helpBtn,     SIGNAL( clicked() ),              this, SLOT( help() ) );
01748   connect( myTabWidget, SIGNAL( currentChanged( int  ) ), this, SLOT( updateSelection() ) );
01749   connect( myMode,      SIGNAL( buttonClicked( int  ) ),  this, SLOT( modeChanged() ) );
01750   connect( myID,        SIGNAL( textEdited( QString  ) ), this, SLOT( idChanged() ) );
01751   connect( SMESHGUI::GetSMESHGUI(),  SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() ) );
01752   connect( SMESHGUI::GetSMESHGUI(),  SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( reject() ) );
01753 
01754   updateSelection();
01755 }
01756 
01760 SMESHGUI_MeshInfoDlg::~SMESHGUI_MeshInfoDlg()
01761 {
01762 }
01763 
01768 void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO )
01769 {
01770   SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
01771   if ( !CORBA::is_nil( obj ) ) {
01772     myBaseInfo->showInfo( obj );
01773     myAddInfo->showInfo( obj );
01774 
01775     myActor = SMESH::FindActorByEntry( IO->getEntry() );
01776     SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
01777     QString ID;
01778     int nb = 0;
01779     if ( myActor && selector ) {
01780       nb = myMode->checkedId() == NodeMode ? 
01781         SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
01782         SMESH::GetNameOfSelectedNodes( selector, IO, ID );
01783     }
01784     myElemInfo->setSource( myActor ) ;
01785     if ( nb > 0 ) {
01786       myID->setText( ID.trimmed() );
01787       QSet<long> ids;
01788       QStringList idTxt = ID.split( " ", QString::SkipEmptyParts );
01789       foreach ( ID, idTxt )
01790         ids << ID.trimmed().toLong();
01791       myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
01792     }
01793     else {
01794       myID->clear();
01795       myElemInfo->clear();
01796     }
01797   }
01798 }
01799 
01803 void SMESHGUI_MeshInfoDlg::reject()
01804 {
01805   LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
01806   selMgr->clearFilters();
01807   SMESH::SetPointRepresentation( false );
01808   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01809     aViewWindow->SetSelectionMode( ActorSelection );
01810   QDialog::reject();
01811 }
01812 
01817 void SMESHGUI_MeshInfoDlg::keyPressEvent( QKeyEvent* e )
01818 {
01819   QDialog::keyPressEvent( e );
01820   if ( !e->isAccepted() && e->key() == Qt::Key_F1 ) {
01821     e->accept();
01822     help();
01823   }
01824 }
01825 
01829 void SMESHGUI_MeshInfoDlg::enterEvent( QEvent* )
01830 {
01831   activate();
01832 }
01833 
01837 void SMESHGUI_MeshInfoDlg::updateSelection()
01838 {
01839   LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
01840 
01841   disconnect( selMgr, 0, this, 0 );
01842   selMgr->clearFilters();
01843 
01844   if ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) {
01845     SMESH::SetPointRepresentation( false );
01846     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01847       aViewWindow->SetSelectionMode( ActorSelection );
01848   }
01849   else {
01850     if ( myMode->checkedId() == NodeMode ) {
01851       SMESH::SetPointRepresentation( true );
01852       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01853         aViewWindow->SetSelectionMode( NodeSelection );
01854     }
01855     else {
01856       SMESH::SetPointRepresentation( false );
01857       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01858         aViewWindow->SetSelectionMode( CellSelection );
01859     }
01860   }
01861 
01862   QString oldID = myID->text().trimmed();
01863   SMESH_Actor* oldActor = myActor;
01864   myID->clear();
01865   
01866   connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
01867   updateInfo();
01868   
01869   if ( oldActor == myActor && myActor && !oldID.isEmpty() ) {
01870     myID->setText( oldID );
01871     idChanged();
01872   }
01873 }
01874 
01878 void SMESHGUI_MeshInfoDlg::help()
01879 {
01880   SMESH::ShowHelpFile( ( myTabWidget->currentIndex() == BaseInfo || myTabWidget->currentIndex() == AddInfo ) ?
01881                        "mesh_infos_page.html#advanced_mesh_infos_anchor" : 
01882                        "mesh_infos_page.html#mesh_element_info_anchor" );
01883 }
01884 
01888 void SMESHGUI_MeshInfoDlg::updateInfo()
01889 {
01890   SUIT_OverrideCursor wc;
01891 
01892   SALOME_ListIO selected;
01893   SMESHGUI::selectionMgr()->selectedObjects( selected );
01894 
01895   if ( selected.Extent() == 1 ) {
01896     Handle(SALOME_InteractiveObject) IO = selected.First();
01897     showInfo( IO );
01898   }
01899 //   else {
01900 //     myBaseInfo->clear();
01901 //     myElemInfo->clear();
01902 //     myAddInfo->clear();
01903 //   }
01904 }
01905 
01909 void SMESHGUI_MeshInfoDlg::activate()
01910 {
01911   SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
01912   SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this );
01913   myTabWidget->setEnabled( true );
01914   updateSelection();
01915 }
01916 
01920 void SMESHGUI_MeshInfoDlg::deactivate()
01921 {
01922   myTabWidget->setEnabled( false );
01923   disconnect( SMESHGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
01924 }
01925 
01929 void SMESHGUI_MeshInfoDlg::modeChanged()
01930 {
01931   myID->clear();
01932   updateSelection();
01933 }
01934 
01938 void SMESHGUI_MeshInfoDlg::idChanged()
01939 {
01940   SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
01941   if ( myActor && selector ) {
01942     Handle(SALOME_InteractiveObject) IO = myActor->getIO();
01943     TColStd_MapOfInteger ID;
01944     QSet<long> ids;
01945     QStringList idTxt = myID->text().split( " ", QString::SkipEmptyParts );
01946     foreach ( QString tid, idTxt ) {
01947       long id = tid.trimmed().toLong();
01948       const SMDS_MeshElement* e = myMode->checkedId() == ElemMode ? 
01949         myActor->GetObject()->GetMesh()->FindElement( id ) :
01950         myActor->GetObject()->GetMesh()->FindNode( id );
01951       if ( e ) {
01952         ID.Add( id );
01953         ids << id;
01954       }
01955     }
01956     selector->AddOrRemoveIndex( IO, ID, false );
01957     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01958       aViewWindow->highlight( IO, true, true );
01959     myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
01960   }
01961 }