]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/SMESHGUI/SMESHGUI_MeshInfo.cxx
Salome HOME
Imp: show element position in a mesh information dialog box
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshInfo.cxx
index 0e5fb950be7362f34668350e71441346d1525fd9..c3c87893dea15bd11ab3ce803517e603b94f5227 100644 (file)
@@ -34,6 +34,7 @@
 #include "SMDS_BallElement.hxx"
 #include "SMDS_EdgePosition.hxx"
 #include "SMDS_FacePosition.hxx"
+#include "SMESHDS_Mesh.hxx"
 #include "SMESH_ControlsDef.hxx"
 
 #include <LightApp_SelectionMgr.h>
@@ -1102,6 +1103,39 @@ void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
         else {
           myInfo->append( QString( "<b>%1</b>" ).arg( SMESHGUI_ElemInfo::tr( "FREE_NODE" ) ).arg( id ) );
         }
+        // node position
+        int shapeID = node->getshapeId();
+        if ( shapeID > 0 )
+        {
+          SMDS_PositionPtr        pos = node->GetPosition();
+          SMDS_TypeOfPosition posType = pos->GetTypeOfPosition();
+          QString shapeType;
+          double u,v;
+          switch ( posType ) {
+          case SMDS_TOP_EDGE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" );
+            u = static_cast<SMDS_EdgePosition*>( pos )->GetUParameter();
+            break;
+          case SMDS_TOP_FACE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" );
+            u = static_cast<SMDS_FacePosition*>( pos )->GetUParameter();
+            v = static_cast<SMDS_FacePosition*>( pos )->GetVParameter();
+            break;
+          case SMDS_TOP_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" );
+           break;
+          default:              shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" );
+           break;
+          }
+         // separator
+         myInfo->append( "" );
+          myInfo->append( QString( "<b>%1: #%2</b>" ).arg( SMESHGUI_ElemInfo::tr( "POSITION" ) ).arg( shapeID ) );
+          if ( posType == SMDS_TOP_EDGE || posType == SMDS_TOP_FACE ) {
+           myInfo->append( QString( "- <b>%1: #%2</b>" ).arg( SMESHGUI_ElemInfo::tr( "U_POSITION" ) ).
+                           arg( QString::number( u, precision > 0 ? 'f' : 'g', qAbs( precision )) ) );
+            if ( posType == SMDS_TOP_FACE ) {
+             myInfo->append( QString( "- <b>%1: #%2</b>" ).arg( SMESHGUI_ElemInfo::tr( "V_POSITION" ) ).
+                             arg( QString::number( v, precision > 0 ? 'f' : 'g', qAbs( precision )) ) );
+            }
+          }
+        }
       }
       else {
         //
@@ -1275,24 +1309,27 @@ void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
           afunctor->SetMesh( actor()->GetObject()->GetMesh() );
           myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_3D" ) ).arg( afunctor->GetValue( id ) ) );
         }
-       /*
-        if( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
-          // separator
-          myInfo->append( "" );
-          //shapeID
-          int shapeID = e->getshapeId();
-          if ( shapeID > 0 ) {     
-            QString shapeType;
-            switch ( actor()->GetObject()->GetMesh()->FindElement( shapeID )->GetType() ) {
-            case SMDS_TOP_EDGE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" ); break;
-            case SMDS_TOP_FACE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" ); break;
-            case SMDS_TOP_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); break;
-            default:              shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" );
-            }     
-            myInfo->append( QString( "<b>%1:</b> %2 #%3" ).arg( SMESHGUI_ElemInfo::tr( "POSITION" ) ).arg( shapeType ).arg( shapeID ) );
-          }
-        }
-       */
+       // position (only in collocate mode)
+       if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
+         SMESHDS_Mesh* aMesh = dynamic_cast<SMESHDS_Mesh*>( actor()->GetObject()->GetMesh() );
+         int shapeID = e->getshapeId();
+         if ( aMesh && shapeID > 0 ) {
+           const TopoDS_Shape& aShape = aMesh->IndexToShape( shapeID );
+           if ( !aShape.IsNull() ) {
+             myInfo->append( "" ); // separator
+             QString shapeType;
+             switch ( aShape.ShapeType() ) {
+             case TopAbs_EDGE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" );   break;
+             case TopAbs_FACE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" );   break;
+             case TopAbs_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); break;
+             case TopAbs_SOLID:  shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" );  break;
+             case TopAbs_SHELL:  shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHELL" );  break;
+             default:            shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHAPE" );  break;
+             }
+             myInfo->append( QString( "<b>%1:</b> %2 #%3" ).arg( SMESHGUI_ElemInfo::tr( "POSITION" ) ).arg( shapeType ).arg( shapeID ) );
+           }
+         }
+       }
       }
       // separator
       if ( ids.count() > 1 ) {
@@ -1480,7 +1517,7 @@ void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
            break;
           }
           QTreeWidgetItem* posItem = createItem( nodeItem, Bold );
-          posItem->setText( 0, SMESHGUI_ElemInfo::tr("NODE_POSITION") );
+          posItem->setText( 0, SMESHGUI_ElemInfo::tr("POSITION") );
           posItem->setText( 1, (shapeType + " #%1").arg( shapeID ));
           if ( posType == SMDS_TOP_EDGE || posType == SMDS_TOP_FACE ) {
             QTreeWidgetItem* uItem = createItem( posItem );
@@ -1734,24 +1771,28 @@ void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
           diam3Item->setText( 0, tr( "MAX_ELEMENT_LENGTH_3D" ) );
           diam3Item->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );     
         }
-       /*
-        if( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
-          //shapeID
-          int shapeID = e->getshapeId();
-          if ( shapeID > 0 ) {
-            QTreeWidgetItem* shItem = createItem( elemItem, Bold );
-            QString shapeType;
-            switch ( actor()->GetObject()->GetMesh()->FindElement( shapeID )->GetType() ) {
-            case SMDS_TOP_EDGE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" ); break;
-            case SMDS_TOP_FACE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" ); break;
-            case SMDS_TOP_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); break;
-            default:              shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" );
-            }
-            shItem->setText( 0, SMESHGUI_ElemInfo::tr( "POSITION" ) );
-            shItem->setText( 1, QString( "%1 #%2" ).arg(shapeType).arg( shapeID ) );
-          }
-        }
-       */
+       // position (only in collocate mode)
+       if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
+         SMESHDS_Mesh* aMesh = dynamic_cast<SMESHDS_Mesh*>( actor()->GetObject()->GetMesh() );
+         int shapeID = e->getshapeId();
+         if ( aMesh && shapeID > 0 ) {
+           const TopoDS_Shape& aShape = aMesh->IndexToShape( shapeID );
+           if ( !aShape.IsNull() ) {
+             QTreeWidgetItem* shItem = createItem( elemItem, Bold );
+             QString shapeType;
+             switch ( aShape.ShapeType() ) {
+             case TopAbs_EDGE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" );   break;
+             case TopAbs_FACE:   shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" );   break;
+             case TopAbs_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); break;
+             case TopAbs_SOLID:  shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" );  break;
+             case TopAbs_SHELL:  shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHELL" );  break;
+             default:            shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHAPE" );  break;
+             }
+             shItem->setText( 0, SMESHGUI_ElemInfo::tr( "POSITION" ) );
+             shItem->setText( 1, QString( "%1 #%2" ).arg( shapeType ).arg( shapeID ) );
+           }
+         }
+       }
       }
     }
   }