Imp: Mesh Info dialog box - show node/element position not only in colocated mode

This commit is contained in:
vsr 2012-12-28 14:49:43 +00:00
parent d95ba01c50
commit fe32ec275a

View File

@ -1105,38 +1105,47 @@ void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
myInfo->append( QString( "<b>%1</b>" ).arg( SMESHGUI_ElemInfo::tr( "FREE_NODE" ) ).arg( id ) ); myInfo->append( QString( "<b>%1</b>" ).arg( SMESHGUI_ElemInfo::tr( "FREE_NODE" ) ).arg( id ) );
} }
// node position // node position
int shapeID = node->getshapeId(); SMESH::SMESH_Mesh_ptr aMeshPtr = actor()->GetObject()->GetMeshServer();
if ( shapeID > 0 ) if ( !CORBA::is_nil( aMeshPtr ) ) {
{ SMESH::NodePosition_var pos = aMeshPtr->GetNodePosition( id );
SMDS_PositionPtr pos = node->GetPosition(); int shapeID = pos->shapeID;
SMDS_TypeOfPosition posType = pos->GetTypeOfPosition(); if ( shapeID > 0 ) {
QString shapeType; QString shapeType;
double u,v; double u, v;
switch ( posType ) { switch ( pos->shapeType ) {
case SMDS_TOP_EDGE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" ); case GEOM::EDGE:
u = static_cast<SMDS_EdgePosition*>( pos )->GetUParameter(); shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" );
break; if ( pos->params.length() == 1 )
case SMDS_TOP_FACE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" ); u = pos->params[0];
u = static_cast<SMDS_FacePosition*>( pos )->GetUParameter(); break;
v = static_cast<SMDS_FacePosition*>( pos )->GetVParameter(); case GEOM::FACE:
break; shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" );
case SMDS_TOP_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); if ( pos->params.length() == 2 ) {
break; u = pos->params[0];
default: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" ); v = pos->params[1];
break; }
} break;
// separator case GEOM::VERTEX:
myInfo->append( "" ); shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" );
myInfo->append( QString( "<b>%1: #%2</b>" ).arg( SMESHGUI_ElemInfo::tr( "POSITION" ) ).arg( shapeID ) ); break;
if ( posType == SMDS_TOP_EDGE || posType == SMDS_TOP_FACE ) { default:
myInfo->append( QString( "- <b>%1: #%2</b>" ).arg( SMESHGUI_ElemInfo::tr( "U_POSITION" ) ). shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" );
arg( QString::number( u, precision > 0 ? 'f' : 'g', qAbs( precision )) ) ); break;
if ( posType == SMDS_TOP_FACE ) { }
myInfo->append( QString( "- <b>%1: #%2</b>" ).arg( SMESHGUI_ElemInfo::tr( "V_POSITION" ) ). // separator
arg( QString::number( v, precision > 0 ? 'f' : 'g', qAbs( precision )) ) ); myInfo->append( "" );
} myInfo->append( QString( "<b>%1:" ).arg( SMESHGUI_ElemInfo::tr( "POSITION" ) ) );
} myInfo->append( QString( "- <b>%1: #%2</b>" ).arg( shapeType ).arg( shapeID ) );
} if ( pos->shapeType == GEOM::EDGE || pos->shapeType == GEOM::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 ( pos->shapeType == GEOM::FACE ) {
myInfo->append( QString( "- <b>%1: #%2</b>" ).arg( SMESHGUI_ElemInfo::tr( "V_POSITION" ) ).
arg( QString::number( v, precision > 0 ? 'f' : 'g', qAbs( precision )) ) );
}
}
}
}
// groups node belongs to // groups node belongs to
SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer(); SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
if ( !CORBA::is_nil( aMesh ) ) { if ( !CORBA::is_nil( aMesh ) ) {
@ -1363,22 +1372,22 @@ void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
afunctor->SetMesh( actor()->GetObject()->GetMesh() ); afunctor->SetMesh( actor()->GetObject()->GetMesh() );
myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_3D" ) ).arg( afunctor->GetValue( id ) ) ); myInfo->append( QString( "- <b>%1:</b> %2" ).arg( tr( "MAX_ELEMENT_LENGTH_3D" ) ).arg( afunctor->GetValue( id ) ) );
} }
// position (only in collocate mode) // element position
if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) { if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
SMESHDS_Mesh* aMesh = dynamic_cast<SMESHDS_Mesh*>( actor()->GetObject()->GetMesh() ); SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
int shapeID = e->getshapeId(); if ( !CORBA::is_nil( aMesh ) ) {
if ( aMesh && shapeID > 0 ) { SMESH::ElementPosition pos = aMesh->GetElementPosition( id );
const TopoDS_Shape& aShape = aMesh->IndexToShape( shapeID ); int shapeID = pos.shapeID;
if ( !aShape.IsNull() ) { if ( shapeID > 0 ) {
myInfo->append( "" ); // separator myInfo->append( "" ); // separator
QString shapeType; QString shapeType;
switch ( aShape.ShapeType() ) { switch ( pos.shapeType ) {
case TopAbs_EDGE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" ); break; case GEOM::EDGE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" ); break;
case TopAbs_FACE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" ); break; case GEOM::FACE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" ); break;
case TopAbs_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); break; case GEOM::VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); break;
case TopAbs_SOLID: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" ); break; case GEOM::SOLID: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" ); break;
case TopAbs_SHELL: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHELL" ); break; case GEOM::SHELL: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHELL" ); break;
default: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHAPE" ); 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 ) ); myInfo->append( QString( "<b>%1:</b> %2 #%3" ).arg( SMESHGUI_ElemInfo::tr( "POSITION" ) ).arg( shapeType ).arg( shapeID ) );
} }
@ -1603,40 +1612,48 @@ void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
conItem->setText( 1, SMESHGUI_ElemInfo::tr( "FREE_NODE" ) ); conItem->setText( 1, SMESHGUI_ElemInfo::tr( "FREE_NODE" ) );
} }
// node position // node position
int shapeID = node->getshapeId(); SMESH::SMESH_Mesh_ptr aMeshPtr = actor()->GetObject()->GetMeshServer();
if ( shapeID > 0 ) if ( !CORBA::is_nil( aMeshPtr ) ) {
{ SMESH::NodePosition_var pos = aMeshPtr->GetNodePosition( id );
SMDS_PositionPtr pos = node->GetPosition(); int shapeID = pos->shapeID;
SMDS_TypeOfPosition posType = pos->GetTypeOfPosition(); if ( shapeID > 0 ) {
QString shapeType; QString shapeType;
double u,v; double u, v;
switch ( posType ) { switch ( pos->shapeType ) {
case SMDS_TOP_EDGE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" ); case GEOM::EDGE:
u = static_cast<SMDS_EdgePosition*>( pos )->GetUParameter(); shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" );
break; if ( pos->params.length() == 1 )
case SMDS_TOP_FACE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" ); u = pos->params[0];
u = static_cast<SMDS_FacePosition*>( pos )->GetUParameter(); break;
v = static_cast<SMDS_FacePosition*>( pos )->GetVParameter(); case GEOM::FACE:
break; shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" );
case SMDS_TOP_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); if ( pos->params.length() == 2 ) {
break; u = pos->params[0];
default: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" ); v = pos->params[1];
break; }
} break;
QTreeWidgetItem* posItem = createItem( nodeItem, Bold ); case GEOM::VERTEX:
posItem->setText( 0, SMESHGUI_ElemInfo::tr("POSITION") ); shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" );
posItem->setText( 1, (shapeType + " #%1").arg( shapeID )); break;
if ( posType == SMDS_TOP_EDGE || posType == SMDS_TOP_FACE ) { default:
QTreeWidgetItem* uItem = createItem( posItem ); shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" );
uItem->setText( 0, SMESHGUI_ElemInfo::tr("U_POSITION") ); break;
uItem->setText( 1, QString::number( u, precision > 0 ? 'f' : 'g', qAbs( precision ))); }
if ( posType == SMDS_TOP_FACE ) { QTreeWidgetItem* posItem = createItem( nodeItem, Bold );
QTreeWidgetItem* vItem = createItem( posItem ); posItem->setText( 0, SMESHGUI_ElemInfo::tr("POSITION") );
vItem->setText( 0, SMESHGUI_ElemInfo::tr("V_POSITION") ); posItem->setText( 1, (shapeType + " #%1").arg( shapeID ));
vItem->setText( 1, QString::number( v, precision > 0 ? 'f' : 'g', qAbs( precision ))); if ( pos->shapeType == GEOM::EDGE || pos->shapeType == GEOM::FACE ) {
} QTreeWidgetItem* uItem = createItem( posItem );
} uItem->setText( 0, SMESHGUI_ElemInfo::tr("U_POSITION") );
} uItem->setText( 1, QString::number( u, precision > 0 ? 'f' : 'g', qAbs( precision )));
if ( pos->shapeType == GEOM::FACE ) {
QTreeWidgetItem* vItem = createItem( posItem );
vItem->setText( 0, SMESHGUI_ElemInfo::tr("V_POSITION") );
vItem->setText( 1, QString::number( v, precision > 0 ? 'f' : 'g', qAbs( precision )));
}
}
}
}
// groups node belongs to // groups node belongs to
SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer(); SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
if ( !CORBA::is_nil( aMesh ) ) { if ( !CORBA::is_nil( aMesh ) ) {
@ -1933,22 +1950,22 @@ void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
diam3Item->setText( 0, tr( "MAX_ELEMENT_LENGTH_3D" ) ); diam3Item->setText( 0, tr( "MAX_ELEMENT_LENGTH_3D" ) );
diam3Item->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) ); diam3Item->setText( 1, QString( "%1" ).arg( afunctor->GetValue( id ) ) );
} }
// position (only in collocate mode) // element position
if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) { if ( e->GetType() >= SMDSAbs_Edge && e->GetType() <= SMDSAbs_Volume ) {
SMESHDS_Mesh* aMesh = dynamic_cast<SMESHDS_Mesh*>( actor()->GetObject()->GetMesh() ); SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
int shapeID = e->getshapeId(); if ( !CORBA::is_nil( aMesh ) ) {
if ( aMesh && shapeID > 0 ) { SMESH::ElementPosition pos = aMesh->GetElementPosition( id );
const TopoDS_Shape& aShape = aMesh->IndexToShape( shapeID ); int shapeID = pos.shapeID;
if ( !aShape.IsNull() ) { if ( shapeID > 0 ) {
QTreeWidgetItem* shItem = createItem( elemItem, Bold ); QTreeWidgetItem* shItem = createItem( elemItem, Bold );
QString shapeType; QString shapeType;
switch ( aShape.ShapeType() ) { switch ( pos.shapeType ) {
case TopAbs_EDGE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" ); break; case GEOM::EDGE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_EDGE" ); break;
case TopAbs_FACE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" ); break; case GEOM::FACE: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_FACE" ); break;
case TopAbs_VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); break; case GEOM::VERTEX: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_VERTEX" ); break;
case TopAbs_SOLID: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" ); break; case GEOM::SOLID: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SOLID" ); break;
case TopAbs_SHELL: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHELL" ); break; case GEOM::SHELL: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHELL" ); break;
default: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHAPE" ); break; default: shapeType = SMESHGUI_ElemInfo::tr( "GEOM_SHAPE" ); break;
} }
shItem->setText( 0, SMESHGUI_ElemInfo::tr( "POSITION" ) ); shItem->setText( 0, SMESHGUI_ElemInfo::tr( "POSITION" ) );
shItem->setText( 1, QString( "%1 #%2" ).arg( shapeType ).arg( shapeID ) ); shItem->setText( 1, QString( "%1 #%2" ).arg( shapeType ).arg( shapeID ) );