00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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 <QTreeWidget>
00056 #include <QVBoxLayout>
00057
00058 #include "utilities.h"
00059
00060 #include <SALOMEconfig.h>
00061 #include CORBA_SERVER_HEADER(SMESH_Group)
00062
00063 const int SPACING = 6;
00064 const int MARGIN = 9;
00065 const int MAXITEMS = 10;
00066
00078 SMESHGUI_MeshInfo::SMESHGUI_MeshInfo( QWidget* parent )
00079 : QFrame( parent ), myWidgets( iElementsEnd )
00080 {
00081 setFrameStyle( StyledPanel | Sunken );
00082
00083 QGridLayout* l = new QGridLayout( this );
00084 l->setMargin( MARGIN );
00085 l->setSpacing( SPACING );
00086
00087
00088 QLabel* aNameLab = new QLabel( tr( "NAME_LAB" ), this );
00089 QLabel* aName = createField();
00090 aName->setMinimumWidth( 150 );
00091 QLabel* aObjLab = new QLabel( tr( "OBJECT_LAB" ), this );
00092 QLabel* aObj = createField();
00093 aObj->setMinimumWidth( 150 );
00094 myWidgets[0] << aNameLab << aName;
00095 myWidgets[1] << aObjLab << aObj;
00096
00097
00098 QWidget* aNodesLine = createLine();
00099 QLabel* aNodesLab = new QLabel( tr( "NODES_LAB" ), this );
00100 QLabel* aNodes = createField();
00101 myWidgets[2] << aNodesLine;
00102 myWidgets[3] << aNodesLab << aNodes;
00103
00104
00105 QWidget* aElemLine = createLine();
00106 QLabel* aElemLab = new QLabel( tr( "ELEMENTS_LAB" ), this );
00107 QLabel* aElemTotal = new QLabel( tr( "TOTAL_LAB" ), this );
00108 QLabel* aElemLin = new QLabel( tr( "LINEAR_LAB" ), this );
00109 QLabel* aElemQuad = new QLabel( tr( "QUADRATIC_LAB" ), this );
00110 myWidgets[4] << aElemLine;
00111 myWidgets[5] << aElemLab << aElemTotal << aElemLin << aElemQuad;
00112
00113
00114 QWidget* a0DLine = createLine();
00115 QLabel* a0DLab = new QLabel( tr( "0D_LAB" ), this );
00116 QLabel* a0DTotal = createField();
00117 myWidgets[6] << a0DLine;
00118 myWidgets[7] << a0DLab << a0DTotal;
00119
00120
00121 QWidget* a1DLine = createLine();
00122 QLabel* a1DLab = new QLabel( tr( "1D_LAB" ), this );
00123 QLabel* a1DTotal = createField();
00124 QLabel* a1DLin = createField();
00125 QLabel* a1DQuad = createField();
00126 myWidgets[8] << a1DLine;
00127 myWidgets[9] << a1DLab << a1DTotal << a1DLin << a1DQuad;
00128
00129
00130 QWidget* a2DLine = createLine();
00131 QLabel* a2DLab = new QLabel( tr( "2D_LAB" ), this );
00132 QLabel* a2DTotal = createField();
00133 QLabel* a2DLin = createField();
00134 QLabel* a2DQuad = createField();
00135 QLabel* a2DTriLab = new QLabel( tr( "TRIANGLES_LAB" ), this );
00136 QLabel* a2DTriTotal = createField();
00137 QLabel* a2DTriLin = createField();
00138 QLabel* a2DTriQuad = createField();
00139 QLabel* a2DQuaLab = new QLabel( tr( "QUADRANGLES_LAB" ), this );
00140 QLabel* a2DQuaTotal = createField();
00141 QLabel* a2DQuaLin = createField();
00142 QLabel* a2DQuaQuad = createField();
00143 QLabel* a2DPolLab = new QLabel( tr( "POLYGONS_LAB" ), this );
00144 QLabel* a2DPolTotal = createField();
00145 myWidgets[10] << a2DLine;
00146 myWidgets[11] << a2DLab << a2DTotal << a2DLin << a2DQuad;
00147 myWidgets[12] << a2DTriLab << a2DTriTotal << a2DTriLin << a2DTriQuad;
00148 myWidgets[13] << a2DQuaLab << a2DQuaTotal << a2DQuaLin << a2DQuaQuad;
00149 myWidgets[14] << a2DPolLab << a2DPolTotal;
00150
00151
00152 QWidget* a3DLine = createLine();
00153 QLabel* a3DLab = new QLabel( tr( "3D_LAB" ), this );
00154 QLabel* a3DTotal = createField();
00155 QLabel* a3DLin = createField();
00156 QLabel* a3DQuad = createField();
00157 QLabel* a3DTetLab = new QLabel( tr( "TETRAHEDRONS_LAB" ), this );
00158 QLabel* a3DTetTotal = createField();
00159 QLabel* a3DTetLin = createField();
00160 QLabel* a3DTetQuad = createField();
00161 QLabel* a3DHexLab = new QLabel( tr( "HEXAHEDONRS_LAB" ), this );
00162 QLabel* a3DHexTotal = createField();
00163 QLabel* a3DHexLin = createField();
00164 QLabel* a3DHexQuad = createField();
00165 QLabel* a3DPyrLab = new QLabel( tr( "PYRAMIDS_LAB" ), this );
00166 QLabel* a3DPyrTotal = createField();
00167 QLabel* a3DPyrLin = createField();
00168 QLabel* a3DPyrQuad = createField();
00169 QLabel* a3DPriLab = new QLabel( tr( "PRISMS_LAB" ), this );
00170 QLabel* a3DPriTotal = createField();
00171 QLabel* a3DPriLin = createField();
00172 QLabel* a3DPriQuad = createField();
00173 QLabel* a3DPolLab = new QLabel( tr( "POLYHEDRONS_LAB" ), this );
00174 QLabel* a3DPolTotal = createField();
00175 myWidgets[15] << a3DLine;
00176 myWidgets[16] << a3DLab << a3DTotal << a3DLin << a3DQuad;
00177 myWidgets[17] << a3DTetLab << a3DTetTotal << a3DTetLin << a3DTetQuad;
00178 myWidgets[18] << a3DHexLab << a3DHexTotal << a3DHexLin << a3DHexQuad;
00179 myWidgets[19] << a3DPyrLab << a3DPyrTotal << a3DPyrLin << a3DPyrQuad;
00180 myWidgets[20] << a3DPriLab << a3DPriTotal << a3DPriLin << a3DPriQuad;
00181 myWidgets[21] << a3DPolLab << a3DPolTotal;
00182
00183 setFontAttributes( aNameLab, Bold );
00184 setFontAttributes( aObjLab, Bold );
00185 setFontAttributes( aNodesLab, Bold );
00186 setFontAttributes( aElemLab, Bold );
00187 setFontAttributes( aElemTotal, Italic );
00188 setFontAttributes( aElemLin, Italic );
00189 setFontAttributes( aElemQuad, Italic );
00190 setFontAttributes( a0DLab, Bold );
00191 setFontAttributes( a1DLab, Bold );
00192 setFontAttributes( a2DLab, Bold );
00193 setFontAttributes( a3DLab, Bold );
00194
00195 l->addWidget( aNameLab, 0, 0 );
00196 l->addWidget( aName, 0, 1, 1, 3 );
00197 l->addWidget( aObjLab, 1, 0 );
00198 l->addWidget( aObj, 1, 1, 1, 3 );
00199 l->addWidget( aNodesLine, 2, 0, 1, 4 );
00200 l->addWidget( aNodesLab, 3, 0 );
00201 l->addWidget( aNodes, 3, 1 );
00202 l->addWidget( aElemLine, 4, 0, 1, 4 );
00203 l->addWidget( aElemLab, 5, 0 );
00204 l->addWidget( aElemTotal, 5, 1 );
00205 l->addWidget( aElemLin, 5, 2 );
00206 l->addWidget( aElemQuad, 5, 3 );
00207 l->addWidget( a0DLine, 6, 1, 1, 3 );
00208 l->addWidget( a0DLab, 7, 0 );
00209 l->addWidget( a0DTotal, 7, 1 );
00210 l->addWidget( a1DLine, 8, 1, 1, 3 );
00211 l->addWidget( a1DLab, 9, 0 );
00212 l->addWidget( a1DTotal, 9, 1 );
00213 l->addWidget( a1DLin, 9, 2 );
00214 l->addWidget( a1DQuad, 9, 3 );
00215 l->addWidget( a2DLine, 10, 1, 1, 3 );
00216 l->addWidget( a2DLab, 11, 0 );
00217 l->addWidget( a2DTotal, 11, 1 );
00218 l->addWidget( a2DLin, 11, 2 );
00219 l->addWidget( a2DQuad, 11, 3 );
00220 l->addWidget( a2DTriLab, 12, 0 );
00221 l->addWidget( a2DTriTotal, 12, 1 );
00222 l->addWidget( a2DTriLin, 12, 2 );
00223 l->addWidget( a2DTriQuad, 12, 3 );
00224 l->addWidget( a2DQuaLab, 13, 0 );
00225 l->addWidget( a2DQuaTotal, 13, 1 );
00226 l->addWidget( a2DQuaLin, 13, 2 );
00227 l->addWidget( a2DQuaQuad, 13, 3 );
00228 l->addWidget( a2DPolLab, 14, 0 );
00229 l->addWidget( a2DPolTotal, 14, 1 );
00230 l->addWidget( a3DLine, 15, 1, 1, 3 );
00231 l->addWidget( a3DLab, 16, 0 );
00232 l->addWidget( a3DTotal, 16, 1 );
00233 l->addWidget( a3DLin, 16, 2 );
00234 l->addWidget( a3DQuad, 16, 3 );
00235 l->addWidget( a3DTetLab, 17, 0 );
00236 l->addWidget( a3DTetTotal, 17, 1 );
00237 l->addWidget( a3DTetLin, 17, 2 );
00238 l->addWidget( a3DTetQuad, 17, 3 );
00239 l->addWidget( a3DHexLab, 18, 0 );
00240 l->addWidget( a3DHexTotal, 18, 1 );
00241 l->addWidget( a3DHexLin, 18, 2 );
00242 l->addWidget( a3DHexQuad, 18, 3 );
00243 l->addWidget( a3DPyrLab, 19, 0 );
00244 l->addWidget( a3DPyrTotal, 19, 1 );
00245 l->addWidget( a3DPyrLin, 19, 2 );
00246 l->addWidget( a3DPyrQuad, 19, 3 );
00247 l->addWidget( a3DPriLab, 20, 0 );
00248 l->addWidget( a3DPriTotal, 20, 1 );
00249 l->addWidget( a3DPriLin, 20, 2 );
00250 l->addWidget( a3DPriQuad, 20, 3 );
00251 l->addWidget( a3DPolLab, 21, 0 );
00252 l->addWidget( a3DPolTotal, 21, 1 );
00253 l->setColumnStretch( 0, 0 );
00254 l->setColumnStretch( 1, 5 );
00255 l->setColumnStretch( 2, 5 );
00256 l->setColumnStretch( 3, 5 );
00257 l->setRowStretch( 22, 5 );
00258
00259 clear();
00260 }
00261
00265 SMESHGUI_MeshInfo::~SMESHGUI_MeshInfo()
00266 {
00267 }
00268
00273 void SMESHGUI_MeshInfo::showInfo( SMESH::SMESH_IDSource_ptr obj )
00274 {
00275 clear();
00276 if ( !CORBA::is_nil( obj ) ) {
00277 _PTR(SObject) sobj = ObjectToSObject( obj );
00278 if ( sobj )
00279 myWidgets[iName][iSingle]->setProperty( "text", sobj->GetName().c_str() );
00280 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( obj );
00281 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( obj );
00282 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( obj );
00283 if ( !aMesh->_is_nil() ) {
00284 myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_MESH" ) );
00285 }
00286 else if ( !aSubMesh->_is_nil() ) {
00287 myWidgets[iObject][iSingle]->setProperty( "text", tr( "OBJECT_SUBMESH" ) );
00288 }
00289 else if ( !aGroup->_is_nil() ) {
00290 QString objType;
00291 switch( aGroup->GetType() ) {
00292 case SMESH::NODE:
00293 objType = tr( "OBJECT_GROUP_NODES" );
00294 break;
00295 case SMESH::EDGE:
00296 objType = tr( "OBJECT_GROUP_EDGES" );
00297 break;
00298 case SMESH::FACE:
00299 objType = tr( "OBJECT_GROUP_FACES" );
00300 break;
00301 case SMESH::VOLUME:
00302 objType = tr( "OBJECT_GROUP_VOLUMES" );
00303 break;
00304 case SMESH::ELEM0D:
00305 objType = tr( "OBJECT_GROUP_0DELEMS" );
00306 break;
00307 default:
00308 objType = tr( "OBJECT_GROUP" );
00309 break;
00310 }
00311 myWidgets[iObject][iSingle]->setProperty( "text", objType );
00312 }
00313 SMESH::long_array_var info = obj->GetMeshInfo();
00314 myWidgets[iNodes][iTotal]->setProperty( "text", QString::number( info[SMDSEntity_Node] ) );
00315 myWidgets[i0D][iTotal]->setProperty( "text", QString::number( info[SMDSEntity_0D] ) );
00316 long nbEdges = info[SMDSEntity_Edge] + info[SMDSEntity_Quad_Edge];
00317 myWidgets[i1D][iTotal]->setProperty( "text", QString::number( nbEdges ) );
00318 myWidgets[i1D][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Edge] ) );
00319 myWidgets[i1D][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Edge] ) );
00320 long nbTriangles = info[SMDSEntity_Triangle] + info[SMDSEntity_Quad_Triangle];
00321 long nbQuadrangles = info[SMDSEntity_Quadrangle] + info[SMDSEntity_Quad_Quadrangle];
00322 long nb2DLinear = info[SMDSEntity_Triangle] + info[SMDSEntity_Quadrangle] + info[SMDSEntity_Polygon];
00323 long nb2DQuadratic = info[SMDSEntity_Quad_Triangle] + info[SMDSEntity_Quad_Quadrangle];
00324 myWidgets[i2D][iTotal]->setProperty( "text", QString::number( nb2DLinear + nb2DQuadratic ) );
00325 myWidgets[i2D][iLinear]->setProperty( "text", QString::number( nb2DLinear ) );
00326 myWidgets[i2D][iQuadratic]->setProperty( "text", QString::number( nb2DQuadratic ) );
00327 myWidgets[i2DTriangles][iTotal]->setProperty( "text", QString::number( nbTriangles ) );
00328 myWidgets[i2DTriangles][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Triangle] ) );
00329 myWidgets[i2DTriangles][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Triangle] ) );
00330 myWidgets[i2DQuadrangles][iTotal]->setProperty( "text", QString::number( nbQuadrangles ) );
00331 myWidgets[i2DQuadrangles][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Quadrangle] ) );
00332 myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Quadrangle] ) );
00333 myWidgets[i2DPolygons][iTotal]->setProperty( "text", QString::number( info[SMDSEntity_Polygon] ) );
00334 long nbTetrahedrons = info[SMDSEntity_Tetra] + info[SMDSEntity_Quad_Tetra];
00335 long nbHexahedrons = info[SMDSEntity_Hexa] + info[SMDSEntity_Quad_Hexa];
00336 long nbPyramids = info[SMDSEntity_Pyramid] + info[SMDSEntity_Quad_Pyramid];
00337 long nbPrisms = info[SMDSEntity_Penta] + info[SMDSEntity_Quad_Penta];
00338 long nb3DLinear = info[SMDSEntity_Tetra] + info[SMDSEntity_Hexa] + info[SMDSEntity_Pyramid] + info[SMDSEntity_Penta] + info[SMDSEntity_Polyhedra];
00339 long nb3DQuadratic = info[SMDSEntity_Quad_Tetra] + info[SMDSEntity_Quad_Hexa] + info[SMDSEntity_Quad_Pyramid] + info[SMDSEntity_Quad_Penta];
00340 myWidgets[i3D][iTotal]->setProperty( "text", QString::number( nb3DLinear + nb3DQuadratic ) );
00341 myWidgets[i3D][iLinear]->setProperty( "text", QString::number( nb3DLinear ) );
00342 myWidgets[i3D][iQuadratic]->setProperty( "text", QString::number( nb3DQuadratic ) );
00343 myWidgets[i3DTetrahedrons][iTotal]->setProperty( "text", QString::number( nbTetrahedrons ) );
00344 myWidgets[i3DTetrahedrons][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Tetra] ) );
00345 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Tetra] ) );
00346 myWidgets[i3DHexahedrons][iTotal]->setProperty( "text", QString::number( nbHexahedrons ) );
00347 myWidgets[i3DHexahedrons][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Hexa] ) );
00348 myWidgets[i3DHexahedrons][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Hexa] ) );
00349 myWidgets[i3DPyramids][iTotal]->setProperty( "text", QString::number( nbPyramids ) );
00350 myWidgets[i3DPyramids][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Pyramid] ) );
00351 myWidgets[i3DPyramids][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Pyramid] ) );
00352 myWidgets[i3DPrisms][iTotal]->setProperty( "text", QString::number( nbPrisms ) );
00353 myWidgets[i3DPrisms][iLinear]->setProperty( "text", QString::number( info[SMDSEntity_Penta] ) );
00354 myWidgets[i3DPrisms][iQuadratic]->setProperty( "text", QString::number( info[SMDSEntity_Quad_Penta] ) );
00355 myWidgets[i3DPolyhedrons][iTotal]->setProperty( "text", QString::number( info[SMDSEntity_Polyhedra] ) );
00356 }
00357 }
00358
00362 void SMESHGUI_MeshInfo::clear()
00363 {
00364 myWidgets[iName][iSingle]->setProperty( "text", QString() );
00365 myWidgets[iObject][iSingle]->setProperty( "text", QString() );
00366 myWidgets[iNodes][iTotal]->setProperty( "text", QString::number( 0 ) );
00367 myWidgets[i0D][iTotal]->setProperty( "text", QString::number( 0 ) );
00368 myWidgets[i1D][iTotal]->setProperty( "text", QString::number( 0 ) );
00369 myWidgets[i1D][iLinear]->setProperty( "text", QString::number( 0 ) );
00370 myWidgets[i1D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00371 myWidgets[i2D][iTotal]->setProperty( "text", QString::number( 0 ) );
00372 myWidgets[i2D][iLinear]->setProperty( "text", QString::number( 0 ) );
00373 myWidgets[i2D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00374 myWidgets[i2DTriangles][iTotal]->setProperty( "text", QString::number( 0 ) );
00375 myWidgets[i2DTriangles][iLinear]->setProperty( "text", QString::number( 0 ) );
00376 myWidgets[i2DTriangles][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00377 myWidgets[i2DQuadrangles][iTotal]->setProperty( "text", QString::number( 0 ) );
00378 myWidgets[i2DQuadrangles][iLinear]->setProperty( "text", QString::number( 0 ) );
00379 myWidgets[i2DQuadrangles][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00380 myWidgets[i2DPolygons][iTotal]->setProperty( "text", QString::number( 0 ) );
00381 myWidgets[i3D][iTotal]->setProperty( "text", QString::number( 0 ) );
00382 myWidgets[i3D][iLinear]->setProperty( "text", QString::number( 0 ) );
00383 myWidgets[i3D][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00384 myWidgets[i3DTetrahedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
00385 myWidgets[i3DTetrahedrons][iLinear]->setProperty( "text", QString::number( 0 ) );
00386 myWidgets[i3DTetrahedrons][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00387 myWidgets[i3DHexahedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
00388 myWidgets[i3DHexahedrons][iLinear]->setProperty( "text", QString::number( 0 ) );
00389 myWidgets[i3DHexahedrons][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00390 myWidgets[i3DPyramids][iTotal]->setProperty( "text", QString::number( 0 ) );
00391 myWidgets[i3DPyramids][iLinear]->setProperty( "text", QString::number( 0 ) );
00392 myWidgets[i3DPyramids][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00393 myWidgets[i3DPrisms][iTotal]->setProperty( "text", QString::number( 0 ) );
00394 myWidgets[i3DPrisms][iLinear]->setProperty( "text", QString::number( 0 ) );
00395 myWidgets[i3DPrisms][iQuadratic]->setProperty( "text", QString::number( 0 ) );
00396 myWidgets[i3DPolyhedrons][iTotal]->setProperty( "text", QString::number( 0 ) );
00397 }
00398
00403 QLabel* SMESHGUI_MeshInfo::createField()
00404 {
00405 QLabel* lab = new QLabel( this );
00406 lab->setFrameStyle( StyledPanel | Sunken );
00407 lab->setAlignment( Qt::AlignCenter );
00408 lab->setAutoFillBackground( true );
00409 QPalette pal = lab->palette();
00410 pal.setColor( QPalette::Window, QApplication::palette().color( QPalette::Active, QPalette::Base ) );
00411 lab->setPalette( pal );
00412 lab->setMinimumWidth( 70 );
00413 return lab;
00414 }
00415
00420 QWidget* SMESHGUI_MeshInfo::createLine()
00421 {
00422 QFrame* line = new QFrame( this );
00423 line->setFrameStyle( HLine | Sunken );
00424 return line;
00425 }
00426
00433 void SMESHGUI_MeshInfo::setFontAttributes( QWidget* w, int attr, bool val )
00434 {
00435 if ( w && attr ) {
00436 QFont f = w->font();
00437 if ( attr & Bold ) f.setBold( val );
00438 if ( attr & Italic ) f.setItalic( val );
00439 w->setFont( f );
00440 }
00441 }
00442
00449 void SMESHGUI_MeshInfo::setFieldsVisible( int start, int end, bool on )
00450 {
00451 start = qMax( 0, start );
00452 end = qMin( end, (int)iElementsEnd );
00453 for ( int i = start; i < end; i++ ) {
00454 wlist wl = myWidgets[i];
00455 foreach ( QWidget* w, wl ) w->setVisible( on );
00456 }
00457 }
00458
00468 SMESHGUI_ElemInfo::SMESHGUI_ElemInfo( QWidget* parent )
00469 : QWidget( parent ), myActor( 0 ), myIsElement( -1 )
00470 {
00471 myFrame = new QWidget( this );
00472 myExtra = new QWidget( this );
00473 myCurrent = new QLabel( "10/43 items shown", myExtra );
00474 myCurrent->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
00475 myPrev = new QPushButton( tr( "<<" ), myExtra );
00476 myNext = new QPushButton( tr( ">>" ), myExtra );
00477 QHBoxLayout* hbl = new QHBoxLayout( myExtra );
00478 hbl->setContentsMargins( 0, SPACING, 0, 0 );
00479 hbl->setSpacing( SPACING );
00480 hbl->addStretch();
00481 hbl->addWidget( myCurrent );
00482 hbl->addWidget( myPrev );
00483 hbl->addWidget( myNext );
00484 QVBoxLayout* vbl = new QVBoxLayout( this );
00485 vbl->setMargin( 0 );
00486 vbl->setSpacing( 0 );
00487 vbl->addWidget( myFrame );
00488 vbl->addWidget( myExtra );
00489 connect( myPrev, SIGNAL( clicked() ), this, SLOT( showPrevious() ) );
00490 connect( myNext, SIGNAL( clicked() ), this, SLOT( showNext() ) );
00491 clear();
00492 }
00493
00497 SMESHGUI_ElemInfo::~SMESHGUI_ElemInfo()
00498 {
00499 }
00500
00505 void SMESHGUI_ElemInfo::setSource( SMESH_Actor* actor )
00506 {
00507 if ( myActor != actor ) {
00508 myActor = actor;
00509 myIsElement = -1;
00510 clear();
00511 }
00512 }
00513
00519 void SMESHGUI_ElemInfo::showInfo( long id, bool isElem )
00520 {
00521 QSet<long> ids;
00522 ids << id;
00523 showInfo( ids, isElem );
00524 }
00525
00531 void SMESHGUI_ElemInfo::showInfo( QSet<long> ids, bool isElem )
00532 {
00533 QList<long> newIds = ids.toList();
00534 qSort( newIds );
00535 if ( myIDs == newIds && myIsElement == isElem ) return;
00536
00537 myIDs = newIds;
00538 myIsElement = isElem;
00539 myIndex = 0;
00540 updateControls();
00541 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
00542 }
00543
00547 void SMESHGUI_ElemInfo::clear()
00548 {
00549 myIDs.clear();
00550 myIndex = 0;
00551 clearInternal();
00552 updateControls();
00553 }
00554
00559 QWidget* SMESHGUI_ElemInfo::frame() const
00560 {
00561 return myFrame;
00562 }
00563
00568 SMESH_Actor* SMESHGUI_ElemInfo::actor() const
00569 {
00570 return myActor;
00571 }
00572
00577 bool SMESHGUI_ElemInfo::isElements() const
00578 {
00579 return myIsElement;
00580 }
00581
00594 void SMESHGUI_ElemInfo::clearInternal()
00595 {
00596 }
00597
00603 SMESHGUI_ElemInfo::Connectivity SMESHGUI_ElemInfo::nodeConnectivity( const SMDS_MeshNode* node )
00604 {
00605 Connectivity elmap;
00606 if ( node ) {
00607 SMDS_ElemIteratorPtr it = node->GetInverseElementIterator();
00608 while ( it && it->more() ) {
00609 const SMDS_MeshElement* ne = it->next();
00610 elmap[ ne->GetType() ] << ne->GetID();
00611 }
00612 }
00613 return elmap;
00614 }
00615
00622 QString SMESHGUI_ElemInfo::formatConnectivity( Connectivity connectivity, int type )
00623 {
00624 QStringList str;
00625 if ( connectivity.contains( type ) ) {
00626 QList<int> elements = connectivity[ type ];
00627 qSort( elements );
00628 foreach( int id, elements )
00629 str << QString::number( id );
00630 }
00631 return str.join( " " );
00632 }
00633
00638 SMESHGUI_ElemInfo::XYZ SMESHGUI_ElemInfo::gravityCenter( const SMDS_MeshElement* element )
00639 {
00640 XYZ xyz;
00641 if ( element ) {
00642 SMDS_ElemIteratorPtr nodeIt = element->nodesIterator();
00643 while ( nodeIt->more() ) {
00644 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
00645 xyz.add( node->X(), node->Y(), node->Z() );
00646 }
00647 xyz.divide( element->NbNodes() );
00648 }
00649 return xyz;
00650 }
00651
00656 void SMESHGUI_ElemInfo::showPrevious()
00657 {
00658 myIndex = qMax( 0, myIndex-1 );
00659 updateControls();
00660 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
00661 }
00662
00667 void SMESHGUI_ElemInfo::showNext()
00668 {
00669 myIndex = qMin( myIndex+1, myIDs.count() / MAXITEMS );
00670 updateControls();
00671 information( myIDs.mid( myIndex*MAXITEMS, MAXITEMS ) );
00672 }
00673
00677 void SMESHGUI_ElemInfo::updateControls()
00678 {
00679 myExtra->setVisible( myIDs.count() > MAXITEMS );
00680 myCurrent->setText( tr( "X_FROM_Y_ITEMS_SHOWN" ).arg( myIndex*MAXITEMS+1 ).arg(qMin(myIndex*MAXITEMS+MAXITEMS, myIDs.count())).arg( myIDs.count() ) );
00681 myPrev->setEnabled( myIndex > 0 );
00682 myNext->setEnabled( (myIndex+1)*MAXITEMS < myIDs.count() );
00683 }
00684
00694 SMESHGUI_SimpleElemInfo::SMESHGUI_SimpleElemInfo( QWidget* parent )
00695 : SMESHGUI_ElemInfo( parent )
00696 {
00697 myInfo = new QTextBrowser( frame() );
00698 QVBoxLayout* l = new QVBoxLayout( frame() );
00699 l->setMargin( 0 );
00700 l->addWidget( myInfo );
00701 }
00702
00707 void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
00708 {
00709 clearInternal();
00710
00711 if ( actor() ) {
00712 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
00713 foreach ( long id, ids ) {
00714 if ( !isElements() ) {
00715
00716
00717
00718 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
00719 if ( !e ) return;
00720 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
00721
00722
00723 myInfo->append( QString( "<b>%1 #%2</b>" ).arg( tr( "NODE" ) ).arg( id ) );
00724
00725 myInfo->append( "" );
00726
00727 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
00728 arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
00729 arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
00730 arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
00731
00732 myInfo->append( "" );
00733
00734 Connectivity connectivity = nodeConnectivity( node );
00735 if ( !connectivity.isEmpty() ) {
00736 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
00737 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
00738 if ( !con.isEmpty() )
00739 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
00740 con = formatConnectivity( connectivity, SMDSAbs_Edge );
00741 if ( !con.isEmpty() )
00742 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
00743 con = formatConnectivity( connectivity, SMDSAbs_Face );
00744 if ( !con.isEmpty() )
00745 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
00746 con = formatConnectivity( connectivity, SMDSAbs_Volume );
00747 if ( !con.isEmpty() )
00748 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
00749 }
00750 else {
00751 myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
00752 }
00753 }
00754 else {
00755
00756
00757
00758 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
00759 if ( !e ) return;
00760
00761
00762 QString stype;
00763 switch( e->GetType() ) {
00764 case SMDSAbs_0DElement:
00765 stype = tr( "0D ELEMENT" ); break;
00766 case SMDSAbs_Edge:
00767 stype = tr( "EDGE" ); break;
00768 case SMDSAbs_Face:
00769 stype = tr( "FACE" ); break;
00770 case SMDSAbs_Volume:
00771 stype = tr( "VOLUME" ); break;
00772 default:
00773 break;
00774 }
00775 if ( stype.isEmpty() ) return;
00776 myInfo->append( QString( "<b>%1 #%2</b>" ).arg( stype ).arg( id ) );
00777
00778 myInfo->append( "" );
00779
00780 QString gtype;
00781 switch( e->GetEntityType() ) {
00782 case SMDSEntity_Triangle:
00783 case SMDSEntity_Quad_Triangle:
00784 gtype = tr( "TRIANGLE" ); break;
00785 case SMDSEntity_Quadrangle:
00786 case SMDSEntity_Quad_Quadrangle:
00787 gtype = tr( "QUADRANGLE" ); break;
00788 case SMDSEntity_Polygon:
00789 case SMDSEntity_Quad_Polygon:
00790 gtype = tr( "POLYGON" ); break;
00791 case SMDSEntity_Tetra:
00792 case SMDSEntity_Quad_Tetra:
00793 gtype = tr( "TETRAHEDRON" ); break;
00794 case SMDSEntity_Pyramid:
00795 case SMDSEntity_Quad_Pyramid:
00796 gtype = tr( "PYRAMID" ); break;
00797 case SMDSEntity_Hexa:
00798 case SMDSEntity_Quad_Hexa:
00799 gtype = tr( "HEXAHEDRON" ); break;
00800 case SMDSEntity_Penta:
00801 case SMDSEntity_Quad_Penta:
00802 gtype = tr( "PRISM" ); break;
00803 case SMDSEntity_Polyhedra:
00804 case SMDSEntity_Quad_Polyhedra:
00805 gtype = tr( "POLYHEDRON" ); break;
00806 default:
00807 break;
00808 }
00809 if ( !gtype.isEmpty() )
00810 myInfo->append( QString( "<b>%1:</b> %2" ).arg( tr( "TYPE" ) ).arg( gtype ) );
00811
00812 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Last ) {
00813
00814 myInfo->append( QString( "<b>%1?</b> %2" ).arg( tr( "QUADRATIC" ) ).arg( e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) ) );
00815
00816 myInfo->append( "" );
00817
00818 XYZ gc = gravityCenter( e );
00819 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "GRAVITY_CENTER" ) ).arg( gc.x() ).arg( gc.y() ).arg( gc.z() ) );
00820 }
00821
00822 myInfo->append( "" );
00823
00824 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
00825 for ( int idx = 1; nodeIt->more(); idx++ ) {
00826 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
00827
00828 myInfo->append( QString( "<b>%1 %2/%3</b> - #%4" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ).arg( node->GetID() ) );
00829
00830 myInfo->append( QString( "<b>%1:</b> (%2, %3, %4)" ).arg( tr( "COORDINATES" ) ).
00831 arg( node->X(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
00832 arg( node->Y(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ).
00833 arg( node->Z(), 0, precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
00834
00835 Connectivity connectivity = nodeConnectivity( node );
00836 if ( !connectivity.isEmpty() ) {
00837 myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONNECTIVITY" ) ) );
00838 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
00839 if ( !con.isEmpty() )
00840 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "0D_ELEMENTS" ) ).arg( con ) );
00841 con = formatConnectivity( connectivity, SMDSAbs_Edge );
00842 if ( !con.isEmpty() )
00843 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "EDGES" ) ).arg( con ) );
00844 con = formatConnectivity( connectivity, SMDSAbs_Face );
00845 if ( !con.isEmpty() )
00846 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "FACES" ) ).arg( con ) );
00847 con = formatConnectivity( connectivity, SMDSAbs_Volume );
00848 if ( !con.isEmpty() )
00849 myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "VOLUMES" ) ).arg( con ) );
00850 }
00851 else {
00852 myInfo->append( QString( "<b>%1</b>" ).arg( tr( "FREE_NODE" ) ).arg( id ) );
00853 }
00854 }
00855 }
00856
00857 if ( ids.count() > 1 ) {
00858 myInfo->append( "" );
00859 myInfo->append( "------" );
00860 myInfo->append( "" );
00861 }
00862 }
00863 }
00864 }
00865
00869 void SMESHGUI_SimpleElemInfo::clearInternal()
00870 {
00871 myInfo->clear();
00872 }
00873
00879 class SMESHGUI_TreeElemInfo::ItemDelegate : public QItemDelegate
00880 {
00881 public:
00882 ItemDelegate( QObject* );
00883 QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
00884 };
00885
00890 SMESHGUI_TreeElemInfo::ItemDelegate::ItemDelegate( QObject* parent ) : QItemDelegate( parent )
00891 {
00892 }
00893
00898 QWidget* SMESHGUI_TreeElemInfo::ItemDelegate::createEditor( QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index ) const
00899 {
00900 QWidget* w = index.column() == 0 ? 0: QItemDelegate::createEditor( parent, option, index );
00901 if ( qobject_cast<QLineEdit*>( w ) ) qobject_cast<QLineEdit*>( w )->setReadOnly( true );
00902 return w;
00903 }
00904
00914 SMESHGUI_TreeElemInfo::SMESHGUI_TreeElemInfo( QWidget* parent )
00915 : SMESHGUI_ElemInfo( parent )
00916 {
00917 myInfo = new QTreeWidget( frame() );
00918 myInfo->setColumnCount( 2 );
00919 myInfo->setHeaderLabels( QStringList() << tr( "PROPERTY" ) << tr( "VALUE" ) );
00920 myInfo->header()->setStretchLastSection( true );
00921 myInfo->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
00922 myInfo->setItemDelegate( new ItemDelegate( myInfo ) );
00923 QVBoxLayout* l = new QVBoxLayout( frame() );
00924 l->setMargin( 0 );
00925 l->addWidget( myInfo );
00926 }
00927
00932 void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
00933 {
00934 clearInternal();
00935
00936 if ( actor() ) {
00937 int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
00938 foreach ( long id, ids ) {
00939 if ( !isElements() ) {
00940
00941
00942
00943 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindNode( id );
00944 if ( !e ) return;
00945 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( e );
00946
00947
00948 QTreeWidgetItem* nodeItem = createItem( 0, -1 );
00949 nodeItem->setText( 0, tr( "NODE" ) );
00950 nodeItem->setText( 1, QString( "#%1" ).arg( id ) );
00951 nodeItem->setExpanded( true );
00952
00953 QTreeWidgetItem* coordItem = createItem( nodeItem, 0 );
00954 coordItem->setText( 0, tr( "COORDINATES" ) );
00955 coordItem->setExpanded( true );
00956 QTreeWidgetItem* xItem = createItem( coordItem );
00957 xItem->setText( 0, "X" );
00958 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
00959 QTreeWidgetItem* yItem = createItem( coordItem );
00960 yItem->setText( 0, "Y" );
00961 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
00962 QTreeWidgetItem* zItem = createItem( coordItem );
00963 zItem->setText( 0, "Z" );
00964 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
00965
00966 QTreeWidgetItem* conItem = createItem( nodeItem, 0 );
00967 conItem->setText( 0, tr( "CONNECTIVITY" ) );
00968 conItem->setExpanded( true );
00969 Connectivity connectivity = nodeConnectivity( node );
00970 if ( !connectivity.isEmpty() ) {
00971 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
00972 if ( !con.isEmpty() ) {
00973 QTreeWidgetItem* i = createItem( conItem );
00974 i->setText( 0, tr( "0D_ELEMENTS" ) );
00975 i->setText( 1, con );
00976 }
00977 con = formatConnectivity( connectivity, SMDSAbs_Edge );
00978 if ( !con.isEmpty() ) {
00979 QTreeWidgetItem* i = createItem( conItem );
00980 i->setText( 0, tr( "EDGES" ) );
00981 i->setText( 1, con );
00982 }
00983 con = formatConnectivity( connectivity, SMDSAbs_Face );
00984 if ( !con.isEmpty() ) {
00985 QTreeWidgetItem* i = createItem( conItem );
00986 i->setText( 0, tr( "FACES" ) );
00987 i->setText( 1, con );
00988 }
00989 con = formatConnectivity( connectivity, SMDSAbs_Volume );
00990 if ( !con.isEmpty() ) {
00991 QTreeWidgetItem* i = createItem( conItem );
00992 i->setText( 0, tr( "VOLUMES" ) );
00993 i->setText( 1, con );
00994 }
00995 }
00996 else {
00997 conItem->setText( 1, tr( "FREE_NODE" ) );
00998 }
00999 }
01000 else {
01001
01002
01003
01004 const SMDS_MeshElement* e = actor()->GetObject()->GetMesh()->FindElement( id );
01005 if ( !e ) return;
01006
01007
01008 QString stype;
01009 switch( e->GetType() ) {
01010 case SMDSAbs_0DElement:
01011 stype = tr( "0D ELEMENT" ); break;
01012 case SMDSAbs_Edge:
01013 stype = tr( "EDGE" ); break;
01014 case SMDSAbs_Face:
01015 stype = tr( "FACE" ); break;
01016 case SMDSAbs_Volume:
01017 stype = tr( "VOLUME" ); break;
01018 default:
01019 break;
01020 }
01021 if ( stype.isEmpty() ) return;
01022 QTreeWidgetItem* elemItem = createItem( 0, -1 );
01023 elemItem->setText( 0, stype );
01024 elemItem->setText( 1, QString( "#%1" ).arg( id ) );
01025 elemItem->setExpanded( true );
01026
01027 QString gtype;
01028 switch( e->GetEntityType() ) {
01029 case SMDSEntity_Triangle:
01030 case SMDSEntity_Quad_Triangle:
01031 gtype = tr( "TRIANGLE" ); break;
01032 case SMDSEntity_Quadrangle:
01033 case SMDSEntity_Quad_Quadrangle:
01034 gtype = tr( "QUADRANGLE" ); break;
01035 case SMDSEntity_Polygon:
01036 case SMDSEntity_Quad_Polygon:
01037 gtype = tr( "POLYGON" ); break;
01038 case SMDSEntity_Tetra:
01039 case SMDSEntity_Quad_Tetra:
01040 gtype = tr( "TETRAHEDRON" ); break;
01041 case SMDSEntity_Pyramid:
01042 case SMDSEntity_Quad_Pyramid:
01043 gtype = tr( "PYRAMID" ); break;
01044 case SMDSEntity_Hexa:
01045 case SMDSEntity_Quad_Hexa:
01046 gtype = tr( "HEXAHEDRON" ); break;
01047 case SMDSEntity_Penta:
01048 case SMDSEntity_Quad_Penta:
01049 gtype = tr( "PRISM" ); break;
01050 case SMDSEntity_Polyhedra:
01051 case SMDSEntity_Quad_Polyhedra:
01052 gtype = tr( "POLYHEDRON" ); break;
01053 default:
01054 break;
01055 }
01056 if ( !gtype.isEmpty() ) {
01057 QTreeWidgetItem* typeItem = createItem( elemItem, 0 );
01058 typeItem->setText( 0, tr( "TYPE" ) );
01059 typeItem->setText( 1, gtype );
01060 }
01061
01062 if ( e->GetEntityType() > SMDSEntity_0D && e->GetEntityType() < SMDSEntity_Last ) {
01063
01064 QTreeWidgetItem* quadItem = createItem( elemItem, 0 );
01065 quadItem->setText( 0, tr( "QUADRATIC" ) );
01066 quadItem->setText( 1, e->IsQuadratic() ? tr( "YES" ) : tr( "NO" ) );
01067
01068 XYZ gc = gravityCenter( e );
01069 QTreeWidgetItem* gcItem = createItem( elemItem, 0 );
01070 gcItem->setText( 0, tr( "GRAVITY_CENTER" ) );
01071 gcItem->setExpanded( true );
01072 QTreeWidgetItem* xItem = createItem( gcItem );
01073 xItem->setText( 0, "X" );
01074 xItem->setText( 1, QString::number( gc.x(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01075 QTreeWidgetItem* yItem = createItem( gcItem );
01076 yItem->setText( 0, "Y" );
01077 yItem->setText( 1, QString::number( gc.y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01078 QTreeWidgetItem* zItem = createItem( gcItem );
01079 zItem->setText( 0, "Z" );
01080 zItem->setText( 1, QString::number( gc.z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01081 }
01082
01083 QTreeWidgetItem* conItem = createItem( elemItem, 0 );
01084 conItem->setText( 0, tr( "CONNECTIVITY" ) );
01085 conItem->setExpanded( true );
01086 SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
01087 for ( int idx = 1; nodeIt->more(); idx++ ) {
01088 const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
01089
01090 QTreeWidgetItem* nodeItem = createItem( conItem, 0 );
01091 nodeItem->setText( 0, QString( "%1 %2/%3" ).arg( tr( "NODE" ) ).arg( idx ).arg( e->NbNodes() ) );
01092 nodeItem->setText( 1, QString( "#%1" ).arg( node->GetID() ) );
01093
01094
01095 QTreeWidgetItem* coordItem = createItem( nodeItem );
01096 coordItem->setText( 0, tr( "COORDINATES" ) );
01097 coordItem->setExpanded( true );
01098 QTreeWidgetItem* xItem = createItem( coordItem );
01099 xItem->setText( 0, "X" );
01100 xItem->setText( 1, QString::number( node->X(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01101 QTreeWidgetItem* yItem = createItem( coordItem );
01102 yItem->setText( 0, "Y" );
01103 yItem->setText( 1, QString::number( node->Y(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01104 QTreeWidgetItem* zItem = createItem( coordItem );
01105 zItem->setText( 0, "Z" );
01106 zItem->setText( 1, QString::number( node->Z(), precision > 0 ? 'f' : 'g', qAbs( precision ) ) );
01107
01108 QTreeWidgetItem* nconItem = createItem( nodeItem );
01109 nconItem->setText( 0, tr( "CONNECTIVITY" ) );
01110 nconItem->setExpanded( true );
01111 Connectivity connectivity = nodeConnectivity( node );
01112 if ( !connectivity.isEmpty() ) {
01113 QString con = formatConnectivity( connectivity, SMDSAbs_0DElement );
01114 if ( !con.isEmpty() ) {
01115 QTreeWidgetItem* i = createItem( nconItem );
01116 i->setText( 0, tr( "0D_ELEMENTS" ) );
01117 i->setText( 1, con );
01118 }
01119 con = formatConnectivity( connectivity, SMDSAbs_Edge );
01120 if ( !con.isEmpty() ) {
01121 QTreeWidgetItem* i = createItem( nconItem );
01122 i->setText( 0, tr( "EDGES" ) );
01123 i->setText( 1, con );
01124 }
01125 con = formatConnectivity( connectivity, SMDSAbs_Face );
01126 if ( !con.isEmpty() ) {
01127 QTreeWidgetItem* i = createItem( nconItem );
01128 i->setText( 0, tr( "FACES" ) );
01129 i->setText( 1, con );
01130 }
01131 con = formatConnectivity( connectivity, SMDSAbs_Volume );
01132 if ( !con.isEmpty() ) {
01133 QTreeWidgetItem* i = createItem( nconItem );
01134 i->setText( 0, tr( "VOLUMES" ) );
01135 i->setText( 1, con );
01136 }
01137 }
01138 }
01139 }
01140 }
01141 }
01142 }
01143
01147 void SMESHGUI_TreeElemInfo::clearInternal()
01148 {
01149 myInfo->clear();
01150 myInfo->repaint();
01151 }
01152
01159 QTreeWidgetItem* SMESHGUI_TreeElemInfo::createItem( QTreeWidgetItem* parent, int column )
01160 {
01161 QTreeWidgetItem* item;
01162 if ( parent )
01163 item = new QTreeWidgetItem( parent );
01164 else
01165 item = new QTreeWidgetItem( myInfo );
01166
01167 item->setFlags( item->flags() | Qt::ItemIsEditable );
01168
01169 QFont f = item->font( 0 );
01170 f.setBold( true );
01171 if ( column >= 0 && column < myInfo->columnCount() ) {
01172 item->setFont( column, f );
01173 }
01174 else if ( column == -1 ) {
01175 for ( int i = 0; i < myInfo->columnCount(); i++ )
01176 item->setFont( i, f );
01177 }
01178 return item;
01179 }
01180
01191 SMESHGUI_MeshInfoDlg::SMESHGUI_MeshInfoDlg( QWidget* parent, int page )
01192 : QDialog( parent ), myActor( 0 )
01193 {
01194 setModal( false );
01195 setAttribute( Qt::WA_DeleteOnClose, true );
01196 setWindowTitle( tr( "MESH_INFO" ) );
01197 setSizeGripEnabled( true );
01198
01199 myTabWidget = new QTabWidget( this );
01200
01201
01202
01203 myBaseInfo = new SMESHGUI_MeshInfo( myTabWidget );
01204 myTabWidget->addTab( myBaseInfo, tr( "BASE_INFO" ) );
01205
01206
01207
01208 QWidget* w = new QWidget( myTabWidget );
01209
01210 myMode = new QButtonGroup( this );
01211 myMode->addButton( new QRadioButton( tr( "NODE_MODE" ), w ), NodeMode );
01212 myMode->addButton( new QRadioButton( tr( "ELEM_MODE" ), w ), ElemMode );
01213 myMode->button( NodeMode )->setChecked( true );
01214 myID = new QLineEdit( w );
01215 myID->setValidator( new SMESHGUI_IdValidator( this ) );
01216
01217 int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 );
01218 mode = qMin( 1, qMax( 0, mode ) );
01219
01220 if ( mode == 0 )
01221 myElemInfo = new SMESHGUI_SimpleElemInfo( w );
01222 else
01223 myElemInfo = new SMESHGUI_TreeElemInfo( w );
01224
01225 QGridLayout* elemLayout = new QGridLayout( w );
01226 elemLayout->setMargin( MARGIN );
01227 elemLayout->setSpacing( SPACING );
01228 elemLayout->addWidget( myMode->button( NodeMode ), 0, 0 );
01229 elemLayout->addWidget( myMode->button( ElemMode ), 0, 1 );
01230 elemLayout->addWidget( myID, 0, 2 );
01231 elemLayout->addWidget( myElemInfo, 1, 0, 1, 3 );
01232
01233 myTabWidget->addTab( w, tr( "ELEM_INFO" ) );
01234
01235 QPushButton* okBtn = new QPushButton( tr( "SMESH_BUT_OK" ), this );
01236 okBtn->setAutoDefault( true );
01237 okBtn->setDefault( true );
01238 okBtn->setFocus();
01239 QPushButton* helpBtn = new QPushButton( tr( "SMESH_BUT_HELP" ), this );
01240 helpBtn->setAutoDefault( true );
01241
01242 QHBoxLayout* btnLayout = new QHBoxLayout;
01243 btnLayout->setSpacing( SPACING );
01244 btnLayout->setMargin( 0 );
01245
01246 btnLayout->addWidget( okBtn );
01247 btnLayout->addStretch( 10 );
01248 btnLayout->addWidget( helpBtn );
01249
01250 QVBoxLayout* l = new QVBoxLayout ( this );
01251 l->setMargin( MARGIN );
01252 l->setSpacing( SPACING );
01253 l->addWidget( myTabWidget );
01254 l->addStretch();
01255 l->addLayout( btnLayout );
01256
01257 myTabWidget->setCurrentIndex( qMax( (int)BaseInfo, qMin( (int)ElemInfo, page ) ) );
01258
01259 connect( okBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
01260 connect( helpBtn, SIGNAL( clicked() ), this, SLOT( help() ) );
01261 connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( updateSelection() ) );
01262 connect( myMode, SIGNAL( buttonClicked( int ) ), this, SLOT( modeChanged() ) );
01263 connect( myID, SIGNAL( textEdited( QString ) ), this, SLOT( idChanged() ) );
01264 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( deactivate() ) );
01265 connect( SMESHGUI::GetSMESHGUI(), SIGNAL( SignalCloseAllDialogs() ), this, SLOT( reject() ) );
01266
01267 updateSelection();
01268 }
01269
01273 SMESHGUI_MeshInfoDlg::~SMESHGUI_MeshInfoDlg()
01274 {
01275 }
01276
01281 void SMESHGUI_MeshInfoDlg::showInfo( const Handle(SALOME_InteractiveObject)& IO )
01282 {
01283 SMESH::SMESH_IDSource_var obj = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
01284 if ( !CORBA::is_nil( obj ) ) {
01285 myBaseInfo->showInfo( obj );
01286
01287 myActor = SMESH::FindActorByEntry( IO->getEntry() );
01288 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
01289 QString ID;
01290 int nb = 0;
01291 if ( myActor && selector ) {
01292 nb = myMode->checkedId() == NodeMode ?
01293 SMESH::GetNameOfSelectedElements( selector, IO, ID ) :
01294 SMESH::GetNameOfSelectedNodes( selector, IO, ID );
01295 }
01296 myElemInfo->setSource( myActor ) ;
01297 if ( nb > 0 ) {
01298 myID->setText( ID.trimmed() );
01299 QSet<long> ids;
01300 QStringList idTxt = ID.split( " ", QString::SkipEmptyParts );
01301 foreach ( ID, idTxt )
01302 ids << ID.trimmed().toLong();
01303 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
01304 }
01305 else {
01306 myID->clear();
01307 myElemInfo->clear();
01308 }
01309 }
01310 }
01311
01315 void SMESHGUI_MeshInfoDlg::reject()
01316 {
01317 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
01318 selMgr->clearFilters();
01319 SMESH::SetPointRepresentation( false );
01320 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01321 aViewWindow->SetSelectionMode( ActorSelection );
01322 QDialog::reject();
01323 }
01324
01329 void SMESHGUI_MeshInfoDlg::keyPressEvent( QKeyEvent* e )
01330 {
01331 QDialog::keyPressEvent( e );
01332 if ( !e->isAccepted() && e->key() == Qt::Key_F1 ) {
01333 e->accept();
01334 help();
01335 }
01336 }
01337
01341 void SMESHGUI_MeshInfoDlg::enterEvent( QEvent* )
01342 {
01343 activate();
01344 }
01345
01349 void SMESHGUI_MeshInfoDlg::updateSelection()
01350 {
01351 LightApp_SelectionMgr* selMgr = SMESHGUI::selectionMgr();
01352
01353 disconnect( selMgr, 0, this, 0 );
01354 selMgr->clearFilters();
01355
01356 if ( myTabWidget->currentIndex() == BaseInfo ) {
01357 SMESH::SetPointRepresentation( false );
01358 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01359 aViewWindow->SetSelectionMode( ActorSelection );
01360 }
01361 else {
01362 if ( myMode->checkedId() == NodeMode ) {
01363 SMESH::SetPointRepresentation( true );
01364 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01365 aViewWindow->SetSelectionMode( NodeSelection );
01366 }
01367 else {
01368 SMESH::SetPointRepresentation( false );
01369 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01370 aViewWindow->SetSelectionMode( CellSelection );
01371 }
01372 }
01373
01374 QString oldID = myID->text().trimmed();
01375 SMESH_Actor* oldActor = myActor;
01376 myID->clear();
01377
01378 connect( selMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
01379 updateInfo();
01380
01381 if ( oldActor == myActor && myActor && !oldID.isEmpty() ) {
01382 myID->setText( oldID );
01383 idChanged();
01384 }
01385 }
01386
01390 void SMESHGUI_MeshInfoDlg::help()
01391 {
01392 SMESH::ShowHelpFile( myTabWidget->currentIndex() == BaseInfo ?
01393 "mesh_infos_page.html#advanced_mesh_infos_anchor" :
01394 "mesh_infos_page.html#mesh_element_info_anchor" );
01395 }
01396
01400 void SMESHGUI_MeshInfoDlg::updateInfo()
01401 {
01402 SUIT_OverrideCursor wc;
01403
01404 SALOME_ListIO selected;
01405 SMESHGUI::selectionMgr()->selectedObjects( selected );
01406
01407 if ( selected.Extent() == 1 ) {
01408 Handle(SALOME_InteractiveObject) IO = selected.First();
01409 showInfo( IO );
01410 }
01411
01412
01413
01414
01415 }
01416
01420 void SMESHGUI_MeshInfoDlg::activate()
01421 {
01422 SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog();
01423 SMESHGUI::GetSMESHGUI()->SetActiveDialogBox( this );
01424 myTabWidget->setEnabled( true );
01425 updateSelection();
01426 }
01427
01431 void SMESHGUI_MeshInfoDlg::deactivate()
01432 {
01433 myTabWidget->setEnabled( false );
01434 disconnect( SMESHGUI::selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( updateInfo() ) );
01435 }
01436
01440 void SMESHGUI_MeshInfoDlg::modeChanged()
01441 {
01442 myID->clear();
01443 updateSelection();
01444 }
01445
01449 void SMESHGUI_MeshInfoDlg::idChanged()
01450 {
01451 SVTK_Selector* selector = SMESH::GetViewWindow()->GetSelector();
01452 if ( myActor && selector ) {
01453 Handle(SALOME_InteractiveObject) IO = myActor->getIO();
01454 TColStd_MapOfInteger ID;
01455 QSet<long> ids;
01456 QStringList idTxt = myID->text().split( " ", QString::SkipEmptyParts );
01457 foreach ( QString tid, idTxt ) {
01458 long id = tid.trimmed().toLong();
01459 const SMDS_MeshElement* e = myMode->checkedId() == ElemMode ?
01460 myActor->GetObject()->GetMesh()->FindElement( id ) :
01461 myActor->GetObject()->GetMesh()->FindNode( id );
01462 if ( e ) {
01463 ID.Add( id );
01464 ids << id;
01465 }
01466 }
01467 selector->AddOrRemoveIndex( IO, ID, false );
01468 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow() )
01469 aViewWindow->highlight( IO, true, true );
01470 myElemInfo->showInfo( ids, myMode->checkedId() == ElemMode );
01471 }
01472 }