From 5e7fae6a2045afc626aa427ffa71223520f3c1a8 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 20 Dec 2012 14:44:56 +0000 Subject: [PATCH] 0021858: EDF 2171 SMESH : Add an information about the groups an element or node belongs to --- resources/SalomeApp.xml.in | 1 + src/SMESHGUI/SMESHGUI.cxx | 1 + src/SMESHGUI/SMESHGUI_MeshInfo.cxx | 241 +++++++++++++++++++++++++++-- src/SMESHGUI/SMESH_msg_en.ts | 4 + src/SMESHGUI/SMESH_msg_fr.ts | 4 + 5 files changed, 237 insertions(+), 14 deletions(-) diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index e6ad79e28..b40da74b5 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -81,6 +81,7 @@ + diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 32521fcd5..c849da5b0 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -4750,6 +4750,7 @@ void SMESHGUI::createPreferences() setPreferenceProperty( nodesLim, "max", 10000000 ); setPreferenceProperty( nodesLim, "step", 10000 ); 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_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" ); addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" ); diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx index c3c87893d..a922697bf 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx @@ -1057,7 +1057,8 @@ void SMESHGUI_SimpleElemInfo::information( const QList& ids ) clearInternal(); 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; if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) ) cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 ); @@ -1136,6 +1137,59 @@ void SMESHGUI_SimpleElemInfo::information( const QList& 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( "%1:" ).arg( SMESHGUI_AddInfo::tr( "GROUPS" ) ) ); + top_created = true; + } + myInfo->append( QString( "+ %1:" ).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( " - %1: %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ). + arg( SMESHGUI_AddInfo::tr( "STANDALONE_GROUP" ) ) ); + } + else if ( !CORBA::is_nil( aGeomGroup ) ) { + myInfo->append( QString( " - %1: %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( " - %1: %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( " - %1: %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ). + arg( SMESHGUI_AddInfo::tr( "GROUP_ON_FILTER" ) ) ); + } + + // size + myInfo->append( QString( " - %1: %2" ).arg( SMESHGUI_AddInfo::tr( "SIZE" ) ). + arg( QString::number( aGrp->Size() ) ) ); + + // color + SALOMEDS::Color color = aGrp->GetColor(); + myInfo->append( QString( " - %1: %2" ).arg( SMESHGUI_AddInfo::tr( "COLOR" ) ). + arg( QColor( color.R*255., color.G*255., color.B*255. ).name() ) ); + } + } + } + } } else { // @@ -1252,7 +1306,7 @@ void SMESHGUI_SimpleElemInfo::information( const QList& ids ) // separator myInfo->append( "" ); //controls - myInfo->append( QString( "%1:" ).arg( tr( "CONTROLS" ) ) ); + myInfo->append( QString( "%1:" ).arg( SMESHGUI_ElemInfo::tr( "CONTROLS" ) ) ); //Length if ( e->GetType() == SMDSAbs_Edge ) { afunctor.reset( new SMESH::Controls::Length() ); @@ -1330,6 +1384,58 @@ void SMESHGUI_SimpleElemInfo::information( const QList& 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( "%1:" ).arg( SMESHGUI_AddInfo::tr( "GROUPS" ) ) ); + top_created = true; + } + myInfo->append( QString( "+ %1:" ).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( " - %1: %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ). + arg( SMESHGUI_AddInfo::tr( "STANDALONE_GROUP" ) ) ); + } + else if ( !CORBA::is_nil( aGeomGroup ) ) { + myInfo->append( QString( " - %1: %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( " - %1: %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( " - %1: %2" ).arg( SMESHGUI_AddInfo::tr( "TYPE" ) ). + arg( SMESHGUI_AddInfo::tr( "GROUP_ON_FILTER" ) ) ); + } + + myInfo->append( QString( " - %1: %2" ).arg( SMESHGUI_AddInfo::tr( "SIZE" ) ). + arg( QString::number( aGrp->Size() ) ) ); + + // color + SALOMEDS::Color color = aGrp->GetColor(); + myInfo->append( QString( " - %1: %2" ).arg( SMESHGUI_AddInfo::tr( "COLOR" ) ). + arg( QColor( color.R*255., color.G*255., color.B*255. ).name() ) ); + } + } + } + } } // separator if ( ids.count() > 1 ) { @@ -1423,7 +1529,8 @@ void SMESHGUI_TreeElemInfo::information( const QList& ids ) clearInternal(); 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; if ( SMESHGUI::resourceMgr()->booleanValue( "SMESH", "use_precision", false ) ) cprecision = SMESHGUI::resourceMgr()->integerValue( "SMESH", "controls_precision", -1 ); @@ -1530,6 +1637,61 @@ void SMESHGUI_TreeElemInfo::information( const QList& 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 { // @@ -1793,6 +1955,61 @@ void SMESHGUI_TreeElemInfo::information( const QList& 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 << QString( 12, '-' ) << "\n"; - int mode = SMESHGUI::resourceMgr()->integerValue( "SMESH", "mesh_elem_info", 1 ); - mode = qMin( 1, qMax( 0, mode ) ); - if ( mode == 1 ) { - QTreeWidgetItemIterator it( myInfo ); - while ( *it ) { - if ( !( *it )->text(0).isEmpty() ) { - out << QString( SPACING_INFO * itemDepth( *it ), ' ' ) << ( *it )->text(0); - if ( !( *it )->text(1).isEmpty() ) out << ": " << ( *it )->text(1); - out << "\n"; - } - ++it; + QTreeWidgetItemIterator it( myInfo ); + while ( *it ) { + if ( !( *it )->text(0).isEmpty() ) { + out << QString( SPACING_INFO * itemDepth( *it ), ' ' ) << ( *it )->text(0); + if ( !( *it )->text(1).isEmpty() ) out << ": " << ( *it )->text(1); + out << "\n"; } + ++it; } out << "\n"; } diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 3b9893b26..f3ab37947 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -4235,6 +4235,10 @@ Please, create VTK viewer and try again PREF_ELEM_INFO_TREE Tree + + PREF_ELEM_INFO_GRP_DETAILS + Show details on groups in element information tab + PREF_DUMP_BASE_INFO Dump base information diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 6cfae09fb..845d6a4c7 100755 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -4142,6 +4142,10 @@ Ouvrez une fenĂȘtre VTK et essayez de nouveau PREF_ELEM_INFO_TREE Arbre + + PREF_ELEM_INFO_GRP_DETAILS + Show details on groups in element information tab + PREF_DUMP_BASE_INFO Dump base information