0021858: EDF 2171 SMESH : Add an information about the groups an element or node belongs to

This commit is contained in:
vsr 2012-12-20 14:44:56 +00:00
parent b31f9cd66a
commit 5e7fae6a20
5 changed files with 237 additions and 14 deletions

View File

@ -81,6 +81,7 @@
<parameter name="auto_groups" value="false"/> <parameter name="auto_groups" value="false"/>
<parameter name="show_result_notification" value="2"/> <parameter name="show_result_notification" value="2"/>
<parameter name="mesh_elem_info" value="1"/> <parameter name="mesh_elem_info" value="1"/>
<parameter name="elem_info_grp_details" value="false"/>
<parameter name="info_groups_nodes_limit" value="100000"/> <parameter name="info_groups_nodes_limit" value="100000"/>
<parameter name="info_dump_base" value="true" /> <parameter name="info_dump_base" value="true" />
<parameter name="info_dump_elem" value="true" /> <parameter name="info_dump_elem" value="true" />

View File

@ -4750,6 +4750,7 @@ void SMESHGUI::createPreferences()
setPreferenceProperty( nodesLim, "max", 10000000 ); setPreferenceProperty( nodesLim, "max", 10000000 );
setPreferenceProperty( nodesLim, "step", 10000 ); setPreferenceProperty( nodesLim, "step", 10000 );
setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) ); setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" ); addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" ); addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" ); addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );

View File

@ -1057,7 +1057,8 @@ void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
clearInternal(); clearInternal();
if ( actor() ) { if ( actor() ) {
int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 ); int grp_details = SMESHGUI::resourceMgr()->booleanValue( "SMESH", "elem_info_grp_details", false );
int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
int cprecision = -1; int cprecision = -1;
if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) ) if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) )
cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 ); cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 );
@ -1136,6 +1137,59 @@ void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
} }
} }
} }
// groups node belongs to
SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
if ( !CORBA::is_nil( aMesh ) ) {
SMESH::ListOfGroups_var groups = aMesh->GetGroups();
myInfo->append( "" ); // separator
bool top_created = false;
for ( int i = 0; i < groups->length(); i++ ) {
SMESH::SMESH_GroupBase_var aGrp = groups[i];
if ( CORBA::is_nil( aGrp ) ) continue;
QString aName = aGrp->GetName();
if ( aGrp->GetType() == SMESH::NODE && !aName.isEmpty() && aGrp->Contains( id ) ) {
if ( !top_created ) {
myInfo->append( QString( "<b>%1:</b>" ).arg( SMESHGUI_AddInfo::tr( "GROUPS" ) ) );
top_created = true;
}
myInfo->append( QString( "+ <b>%1:</b>" ).arg( aName ) );
if ( grp_details ) {
SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( aGrp );
SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGrp );
SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGrp );
// type : group on geometry, standalone group, group on filter
if ( !CORBA::is_nil( aStdGroup ) ) {
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ).
arg( SMESHGUI_AddInfo::tr( "STANDALONE_GROUP" ) ) );
}
else if ( !CORBA::is_nil( aGeomGroup ) ) {
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ).
arg( SMESHGUI_AddInfo::tr( "GROUP_ON_GEOMETRY" ) ) );
GEOM::GEOM_Object_var gobj = aGeomGroup->GetShape();
_PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
if ( sobj ) {
myInfo->append( QString( " - <b>%1:</b> %2: %3" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ).
arg( SMESHGUI_AddInfo::tr( "GEOM_OBJECT" ) ).arg( sobj->GetName().c_str() ) );
}
}
else if ( !CORBA::is_nil( aFltGroup ) ) {
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ).
arg( SMESHGUI_AddInfo::tr( "GROUP_ON_FILTER" ) ) );
}
// size
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "SIZE" ) ).
arg( QString::number( aGrp->Size() ) ) );
// color
SALOMEDS::Color color = aGrp->GetColor();
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "COLOR" ) ).
arg( QColor( color.R*255., color.G*255., color.B*255. ).name() ) );
}
}
}
}
} }
else { else {
// //
@ -1252,7 +1306,7 @@ void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
// separator // separator
myInfo->append( "" ); myInfo->append( "" );
//controls //controls
myInfo->append( QString( "<b>%1:</b>" ).arg( tr( "CONTROLS" ) ) ); myInfo->append( QString( "<b>%1:</b>" ).arg( SMESHGUI_ElemInfo::tr( "CONTROLS" ) ) );
//Length //Length
if ( e->GetType() == SMDSAbs_Edge ) { if ( e->GetType() == SMDSAbs_Edge ) {
afunctor.reset( new SMESH::Controls::Length() ); afunctor.reset( new SMESH::Controls::Length() );
@ -1330,6 +1384,58 @@ void SMESHGUI_SimpleElemInfo::information( const QList<long>& ids )
} }
} }
} }
// groups element belongs to
SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
if ( !CORBA::is_nil( aMesh ) ) {
SMESH::ListOfGroups_var groups = aMesh->GetGroups();
myInfo->append( "" ); // separator
bool top_created = false;
for ( int i = 0; i < groups->length(); i++ ) {
SMESH::SMESH_GroupBase_var aGrp = groups[i];
if ( CORBA::is_nil( aGrp ) ) continue;
QString aName = aGrp->GetName();
if ( aGrp->GetType() != SMESH::NODE && !aName.isEmpty() && aGrp->Contains( id ) ) {
if ( !top_created ) {
myInfo->append( QString( "<b>%1:</b>" ).arg( SMESHGUI_AddInfo::tr( "GROUPS" ) ) );
top_created = true;
}
myInfo->append( QString( "+ <b>%1:</b>" ).arg( aName ) );
if ( grp_details ) {
SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( aGrp );
SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGrp );
SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGrp );
// type : group on geometry, standalone group, group on filter
if ( !CORBA::is_nil( aStdGroup ) ) {
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ).
arg( SMESHGUI_AddInfo::tr( "STANDALONE_GROUP" ) ) );
}
else if ( !CORBA::is_nil( aGeomGroup ) ) {
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ).
arg( SMESHGUI_AddInfo::tr( "GROUP_ON_GEOMETRY" ) ) );
GEOM::GEOM_Object_var gobj = aGeomGroup->GetShape();
_PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
if ( sobj ) {
myInfo->append( QString( " - <b>%1:</b> %2: %3" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ).
arg( SMESHGUI_AddInfo::tr( "GEOM_OBJECT" ) ).arg( sobj->GetName().c_str() ) );
}
}
else if ( !CORBA::is_nil( aFltGroup ) ) {
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ).
arg( SMESHGUI_AddInfo::tr( "GROUP_ON_FILTER" ) ) );
}
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "SIZE" ) ).
arg( QString::number( aGrp->Size() ) ) );
// color
SALOMEDS::Color color = aGrp->GetColor();
myInfo->append( QString( " - <b>%1:</b> %2" ).arg( SMESHGUI_AddInfo::tr( "COLOR" ) ).
arg( QColor( color.R*255., color.G*255., color.B*255. ).name() ) );
}
}
}
}
} }
// separator // separator
if ( ids.count() > 1 ) { if ( ids.count() > 1 ) {
@ -1423,7 +1529,8 @@ void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
clearInternal(); clearInternal();
if ( actor() ) { if ( actor() ) {
int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 ); int grp_details = SMESHGUI::resourceMgr()->booleanValue( "SMESH", "elem_info_grp_details", false );
int precision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "length_precision", 6 );
int cprecision = -1; int cprecision = -1;
if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) ) if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) )
cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 ); cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 );
@ -1530,6 +1637,61 @@ void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
} }
} }
} }
// groups node belongs to
SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
if ( !CORBA::is_nil( aMesh ) ) {
SMESH::ListOfGroups_var groups = aMesh->GetGroups();
QTreeWidgetItem* groupsItem = 0;
for ( int i = 0; i < groups->length(); i++ ) {
SMESH::SMESH_GroupBase_var aGrp = groups[i];
if ( CORBA::is_nil( aGrp ) ) continue;
QString aName = aGrp->GetName();
if ( aGrp->GetType() == SMESH::NODE && !aName.isEmpty() && aGrp->Contains( id ) ) {
if ( !groupsItem ) {
groupsItem = createItem( nodeItem, Bold );
groupsItem->setText( 0, SMESHGUI_AddInfo::tr( "GROUPS" ) );
}
QTreeWidgetItem* it = createItem( groupsItem, Bold );
it->setText( 0, aName );
if ( grp_details ) {
SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( aGrp );
SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGrp );
SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGrp );
// type : group on geometry, standalone group, group on filter
QTreeWidgetItem* typeItem = createItem( it );
typeItem->setText( 0, SMESHGUI_AddInfo::tr( "TYPE" ) );
if ( !CORBA::is_nil( aStdGroup ) ) {
typeItem->setText( 1, SMESHGUI_AddInfo::tr( "STANDALONE_GROUP" ) );
}
else if ( !CORBA::is_nil( aGeomGroup ) ) {
typeItem->setText( 1, SMESHGUI_AddInfo::tr( "GROUP_ON_GEOMETRY" ) );
GEOM::GEOM_Object_var gobj = aGeomGroup->GetShape();
_PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
if ( sobj ) {
QTreeWidgetItem* gobjItem = createItem( typeItem );
gobjItem->setText( 0, SMESHGUI_AddInfo::tr( "GEOM_OBJECT" ) );
gobjItem->setText( 1, sobj->GetName().c_str() );
}
}
else if ( !CORBA::is_nil( aFltGroup ) ) {
typeItem->setText( 1, SMESHGUI_AddInfo::tr( "GROUP_ON_FILTER" ) );
}
// size
QTreeWidgetItem* sizeItem = createItem( it );
sizeItem->setText( 0, SMESHGUI_AddInfo::tr( "SIZE" ) );
sizeItem->setText( 1, QString::number( aGrp->Size() ) );
// color
SALOMEDS::Color color = aGrp->GetColor();
QTreeWidgetItem* colorItem = createItem( it );
colorItem->setText( 0, SMESHGUI_AddInfo::tr( "COLOR" ) );
colorItem->setBackground( 1, QBrush( QColor( color.R*255., color.G*255., color.B*255.) ) );
}
}
}
}
} }
else { else {
// //
@ -1793,6 +1955,61 @@ void SMESHGUI_TreeElemInfo::information( const QList<long>& ids )
} }
} }
} }
// groups element belongs to
SMESH::SMESH_Mesh_ptr aMesh = actor()->GetObject()->GetMeshServer();
if ( !CORBA::is_nil( aMesh ) ) {
SMESH::ListOfGroups_var groups = aMesh->GetGroups();
QTreeWidgetItem* groupsItem = 0;
for ( int i = 0; i < groups->length(); i++ ) {
SMESH::SMESH_GroupBase_var aGrp = groups[i];
if ( CORBA::is_nil( aGrp ) ) continue;
QString aName = aGrp->GetName();
if ( aGrp->GetType() != SMESH::NODE && !aName.isEmpty() && aGrp->Contains( id ) ) {
if ( !groupsItem ) {
groupsItem = createItem( elemItem, Bold );
groupsItem->setText( 0, SMESHGUI_AddInfo::tr( "GROUPS" ) );
}
QTreeWidgetItem* it = createItem( groupsItem, Bold );
it->setText( 0, aName );
if ( grp_details ) {
SMESH::SMESH_Group_var aStdGroup = SMESH::SMESH_Group::_narrow( aGrp );
SMESH::SMESH_GroupOnGeom_var aGeomGroup = SMESH::SMESH_GroupOnGeom::_narrow( aGrp );
SMESH::SMESH_GroupOnFilter_var aFltGroup = SMESH::SMESH_GroupOnFilter::_narrow( aGrp );
// type : group on geometry, standalone group, group on filter
QTreeWidgetItem* typeItem = createItem( it );
typeItem->setText( 0, SMESHGUI_AddInfo::tr( "TYPE" ) );
if ( !CORBA::is_nil( aStdGroup ) ) {
typeItem->setText( 1, SMESHGUI_AddInfo::tr( "STANDALONE_GROUP" ) );
}
else if ( !CORBA::is_nil( aGeomGroup ) ) {
typeItem->setText( 1, SMESHGUI_AddInfo::tr( "GROUP_ON_GEOMETRY" ) );
GEOM::GEOM_Object_var gobj = aGeomGroup->GetShape();
_PTR(SObject) sobj = SMESH::ObjectToSObject( gobj );
if ( sobj ) {
QTreeWidgetItem* gobjItem = createItem( typeItem );
gobjItem->setText( 0, SMESHGUI_AddInfo::tr( "GEOM_OBJECT" ) );
gobjItem->setText( 1, sobj->GetName().c_str() );
}
}
else if ( !CORBA::is_nil( aFltGroup ) ) {
typeItem->setText( 1, SMESHGUI_AddInfo::tr( "GROUP_ON_FILTER" ) );
}
// size
QTreeWidgetItem* sizeItem = createItem( it );
sizeItem->setText( 0, SMESHGUI_AddInfo::tr( "SIZE" ) );
sizeItem->setText( 1, QString::number( aGrp->Size() ) );
// color
SALOMEDS::Color color = aGrp->GetColor();
QTreeWidgetItem* colorItem = createItem( it );
colorItem->setText( 0, SMESHGUI_AddInfo::tr( "COLOR" ) );
colorItem->setBackground( 1, QBrush( QColor( color.R*255., color.G*255., color.B*255.) ) );
}
}
}
}
} }
} }
} }
@ -1867,18 +2084,14 @@ void SMESHGUI_TreeElemInfo::saveInfo( QTextStream &out )
out << SMESHGUI_ElemInfo::tr( "ELEM_INFO" ) << "\n"; out << SMESHGUI_ElemInfo::tr( "ELEM_INFO" ) << "\n";
out << QString( 12, '-' ) << "\n"; out << QString( 12, '-' ) << "\n";
int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 ); QTreeWidgetItemIterator it( myInfo );
mode = qMin( 1, qMax( 0, mode ) ); while ( *it ) {
if ( mode == 1 ) { if ( !( *it )->text(0).isEmpty() ) {
QTreeWidgetItemIterator it( myInfo ); out << QString( SPACING_INFO * itemDepth( *it ), ' ' ) << ( *it )->text(0);
while ( *it ) { if ( !( *it )->text(1).isEmpty() ) out << ": " << ( *it )->text(1);
if ( !( *it )->text(0).isEmpty() ) { out << "\n";
out << QString( SPACING_INFO * itemDepth( *it ), ' ' ) << ( *it )->text(0);
if ( !( *it )->text(1).isEmpty() ) out << ": " << ( *it )->text(1);
out << "\n";
}
++it;
} }
++it;
} }
out << "\n"; out << "\n";
} }

View File

@ -4235,6 +4235,10 @@ Please, create VTK viewer and try again</translation>
<source>PREF_ELEM_INFO_TREE</source> <source>PREF_ELEM_INFO_TREE</source>
<translation>Tree</translation> <translation>Tree</translation>
</message> </message>
<message>
<source>PREF_ELEM_INFO_GRP_DETAILS</source>
<translation>Show details on groups in element information tab</translation>
</message>
<message> <message>
<source>PREF_DUMP_BASE_INFO</source> <source>PREF_DUMP_BASE_INFO</source>
<translation>Dump base information</translation> <translation>Dump base information</translation>

View File

@ -4142,6 +4142,10 @@ Ouvrez une fenêtre VTK et essayez de nouveau</translation>
<source>PREF_ELEM_INFO_TREE</source> <source>PREF_ELEM_INFO_TREE</source>
<translation>Arbre</translation> <translation>Arbre</translation>
</message> </message>
<message>
<source>PREF_ELEM_INFO_GRP_DETAILS</source>
<translation type="unfinished">Show details on groups in element information tab</translation>
</message>
<message> <message>
<source>PREF_DUMP_BASE_INFO</source> <source>PREF_DUMP_BASE_INFO</source>
<translation type="unfinished">Dump base information</translation> <translation type="unfinished">Dump base information</translation>