Correctly update mesh and group icons in the object browser

This commit is contained in:
jfa 2024-07-01 15:17:35 +01:00
parent 4998116b98
commit 53aee8c784
11 changed files with 136 additions and 73 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

BIN
doc/gui/images/image88.jpg Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
doc/gui/images/image89.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -210,6 +210,10 @@ When the Preview dialog is closed, the question about the storage of temporarily
These elements can be kept in the mesh. These elements can be kept in the mesh.
Since the mesh, its submesh(es) and group(s) are now not empty, their **Object Browser** icons will be updated accordingly.
.. image:: ../images/image89.jpg
:align: center
.. _submesh_order_anchor: .. _submesh_order_anchor:

View File

@ -410,9 +410,6 @@ namespace
{ {
_PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] ); _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshes[i] );
if ( aMeshSO ) { if ( aMeshSO ) {
_PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
_PTR(AttributePixMap) aPixmap = aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" );
aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" );
if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import if ( theCommandID == SMESHOp::OpImportUNV ) // mesh names aren't taken from the file for UNV import
SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() ); SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() );
@ -607,7 +604,7 @@ namespace
{ {
format = "CGNS"; format = "CGNS";
notSupportedElemTypes.push_back( SMESH::Entity_Ball ); notSupportedElemTypes.push_back( SMESH::Entity_Ball );
} }
else if ( isGMF ) else if ( isGMF )
{ {
format = "GMF"; format = "GMF";
@ -707,7 +704,7 @@ namespace
checkBoxes << QObject::tr( "CGNS_EXPORT_ELEMS_BY_TYPE" ) << QObject::tr("STRUCTUREDCGNS"); checkBoxes << QObject::tr( "CGNS_EXPORT_ELEMS_BY_TYPE" ) << QObject::tr("STRUCTUREDCGNS");
SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true ); SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg ( SMESHGUI::desktop(), false, checkBoxes, true, true );
fd->setWindowTitle( aTitle ); fd->setWindowTitle( aTitle );
fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" ); fd->setNameFilter( QObject::tr( "CGNS_FILES_FILTER" ) + " (*.cgns)" );
@ -717,18 +714,18 @@ namespace
SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd ); SMESHGUI_FileValidator* fv = new SMESHGUI_FileValidator( fd );
fd->setValidator( fv ); fd->setValidator( fv );
fd->SetChecked( option, 0 ); fd->SetChecked( option, 0 );
if ( fd->exec() ) if ( fd->exec() )
{ {
aFilename = fd->selectedFile(); aFilename = fd->selectedFile();
structureCGNS = fd->IsChecked( 1 ); structureCGNS = fd->IsChecked( 1 );
} }
toOverwrite = fv->isOverwrite( aFilename ); toOverwrite = fv->isOverwrite( aFilename );
option = fd->IsChecked( 0 ); option = fd->IsChecked( 0 );
SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option ); SMESHGUI::resourceMgr()->setValue("SMESH", theOptionResource, option );
toCreateGroups = option; toCreateGroups = option;
delete fd; delete fd;
} }
else if ( isUNV || isDAT ) // Export to [ UNV | DAT ] - one option else if ( isUNV || isDAT ) // Export to [ UNV | DAT ] - one option
@ -768,11 +765,11 @@ namespace
QStringList filters; QStringList filters;
aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 ); aFilterMap.insert( QObject::tr( "STL_ASCII_FILES_FILTER" ) + " (*.stl)", 1 );
aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 ); aFilterMap.insert( QObject::tr( "STL_BIN_FILES_FILTER" ) + " (*.stl)", 0 );
QMap<QString, int>::const_iterator it = aFilterMap.begin(); QMap<QString, int>::const_iterator it = aFilterMap.begin();
for ( ; it != aFilterMap.end(); ++it ) for ( ; it != aFilterMap.end(); ++it )
filters.push_back( it.key() ); filters.push_back( it.key() );
SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true ); SUIT_FileDlg* fd = new SUIT_FileDlg( SMESHGUI::desktop(), false, true, true );
fd->setWindowTitle( aTitle ); fd->setWindowTitle( aTitle );
fd->setNameFilters( filters ); fd->setNameFilters( filters );
@ -1031,7 +1028,7 @@ namespace
aFilename.toUtf8().data(), aFilename.toUtf8().data(),
toOverwrite && aMeshIndex == 0, toOverwrite && aMeshIndex == 0,
toCreateGroups ); toCreateGroups );
else else
aMeshItem->ExportStructuredCGNS( aMeshOrGroup, aMeshItem->ExportStructuredCGNS( aMeshOrGroup,
aFilename.toUtf8().data(), aFilename.toUtf8().data(),
toOverwrite && aMeshIndex == 0 ); toOverwrite && aMeshIndex == 0 );
@ -1069,11 +1066,11 @@ namespace
SUIT_MessageBox::warning(SMESHGUI::desktop(), SUIT_MessageBox::warning(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"), QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex)); QObject::tr("SMESH_EXPORT_FAILED") + SalomeApp_Tools::ExceptionToString(S_ex));
} }
else else
SUIT_MessageBox::warning(SMESHGUI::desktop(), SUIT_MessageBox::warning(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"), QObject::tr("SMESH_WRN_WARNING"),
SalomeApp_Tools::ExceptionToString(S_ex)); SalomeApp_Tools::ExceptionToString(S_ex));
wc.resume(); wc.resume();
} }
} }
@ -4196,7 +4193,7 @@ void SMESHGUI::createSMESHAction( const int id, const QString& po_id, const QStr
pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false ); pix = resMgr->loadPixmap( "SMESH", tr( QString( "ICON_%1" ).arg( po_id ).toLatin1().data() ), false );
if ( !pix.isNull() ) if ( !pix.isNull() )
icon = QIcon( pix ); icon = QIcon( pix );
QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ), QString tooltip = tr( QString( "TOP_%1" ).arg( po_id ).toLatin1().data() ),
menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ), menu = tr( QString( "MEN_%1" ).arg( po_id ).toLatin1().data() ),
status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() ); status_bar = tr( QString( "STB_%1" ).arg( po_id ).toLatin1().data() );

View File

@ -1401,12 +1401,15 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName
checkFileReadable( theFileName ); checkFileReadable( theFileName );
SMESH::SMESH_Mesh_var aMesh = createMesh(); SMESH::SMESH_Mesh_var aMesh = createMesh();
string aFileName; string aFileName;
// publish mesh in the study // publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) { if ( CanPublishInStudy( aMesh ) ) {
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction aStudyBuilder->NewCommand(); // There is a transaction
SALOMEDS::SObject_wrap aSO = PublishMesh( aMesh.in(), aFileName.c_str() ); SALOMEDS::SObject_wrap aSO =
PublishMesh( aMesh.in(), aFileName.c_str(), "ICON_SMESH_TREE_MESH_IMPORTED" );
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
@ -1438,13 +1441,6 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char*
{ {
checkFileReadable( theFileName ); checkFileReadable( theFileName );
#ifdef WIN32
char bname[ _MAX_FNAME ];
_splitpath( theFileName, NULL, NULL, bname, NULL );
string aFileName = bname;
#else
string aFileName = basename( const_cast<char *>( theFileName ));
#endif
// Retrieve mesh names from the file // Retrieve mesh names from the file
DriverMED_R_SMESHDS_Mesh myReader; DriverMED_R_SMESHDS_Mesh myReader;
myReader.SetFile( theFileName ); myReader.SetFile( theFileName );
@ -1481,7 +1477,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char*
// publish mesh in the study // publish mesh in the study
SALOMEDS::SObject_wrap aSO; SALOMEDS::SObject_wrap aSO;
if ( CanPublishInStudy( mesh ) ) if ( CanPublishInStudy( mesh ) )
aSO = PublishMesh( mesh.in(), meshName.c_str() ); aSO = PublishMesh( mesh.in(), meshName.c_str(), "ICON_SMESH_TREE_MESH_IMPORTED" );
// Python Dump // Python Dump
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
@ -1529,7 +1525,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName
checkFileReadable( theFileName ); checkFileReadable( theFileName );
SMESH::SMESH_Mesh_var aMesh = createMesh(); SMESH::SMESH_Mesh_var aMesh = createMesh();
//string aFileName;
#ifdef WIN32 #ifdef WIN32
char bname[ _MAX_FNAME ]; char bname[ _MAX_FNAME ];
_splitpath( theFileName, NULL, NULL, bname, NULL ); _splitpath( theFileName, NULL, NULL, bname, NULL );
@ -1537,11 +1533,13 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName
#else #else
string aFileName = basename( const_cast<char *>(theFileName) ); string aFileName = basename( const_cast<char *>(theFileName) );
#endif #endif
// publish mesh in the study // publish mesh in the study
if ( CanPublishInStudy( aMesh ) ) { if ( CanPublishInStudy( aMesh ) ) {
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction aStudyBuilder->NewCommand(); // There is a transaction
SALOMEDS::SObject_wrap aSO = PublishInStudy( SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() ); SALOMEDS::SObject_wrap aSO =
PublishMesh( aMesh.in(), aFileName.c_str(), "ICON_SMESH_TREE_MESH_IMPORTED" );
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
@ -1616,7 +1614,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromCGNS( const char*
// publish mesh in the study // publish mesh in the study
SALOMEDS::SObject_wrap aSO; SALOMEDS::SObject_wrap aSO;
if ( CanPublishInStudy( mesh ) ) if ( CanPublishInStudy( mesh ) )
aSO = PublishMesh( mesh.in(), meshName.c_str() ); aSO = PublishMesh( mesh.in(), meshName.c_str(), "ICON_SMESH_TREE_MESH_IMPORTED" );
// Python Dump // Python Dump
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
@ -1667,7 +1665,8 @@ SMESH_Gen_i::CreateMeshesFromGMF( const char* theFileName,
if ( CanPublishInStudy( aMesh ) ) { if ( CanPublishInStudy( aMesh ) ) {
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->NewCommand(); // There is a transaction aStudyBuilder->NewCommand(); // There is a transaction
SALOMEDS::SObject_wrap aSO = PublishInStudy( SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() ); SALOMEDS::SObject_wrap aSO =
PublishMesh( aMesh.in(), aFileName.c_str(), "ICON_SMESH_TREE_MESH_IMPORTED" );
aStudyBuilder->CommitCommand(); aStudyBuilder->CommitCommand();
if ( !aSO->_is_nil() ) { if ( !aSO->_is_nil() ) {
// Update Python script // Update Python script
@ -1737,7 +1736,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMESHIO(const char* theFileName,
// publish mesh in the study // publish mesh in the study
SALOMEDS::SObject_wrap aSO; SALOMEDS::SObject_wrap aSO;
if (CanPublishInStudy(mesh)) if (CanPublishInStudy(mesh))
aSO = PublishMesh(mesh.in(), meshName.c_str()); aSO = PublishMesh(mesh.in(), meshName.c_str(), "ICON_SMESH_TREE_MESH_IMPORTED");
// Save SO to use in a python dump // Save SO to use in a python dump
sobjects.emplace_back(aSO); sobjects.emplace_back(aSO);

View File

@ -524,7 +524,8 @@ public:
// publishing methods // publishing methods
SALOMEDS::SComponent_ptr PublishComponent(); SALOMEDS::SComponent_ptr PublishComponent();
SALOMEDS::SObject_ptr PublishMesh (SMESH::SMESH_Mesh_ptr theMesh, SALOMEDS::SObject_ptr PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
const char* theName = 0); const char* theName = 0,
const char* thePixMap = 0);
SALOMEDS::SObject_ptr PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp, SALOMEDS::SObject_ptr PublishHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp,
const char* theName = 0); const char* theName = 0);
SALOMEDS::SObject_ptr PublishSubMesh (SMESH::SMESH_Mesh_ptr theMesh, SALOMEDS::SObject_ptr PublishSubMesh (SMESH::SMESH_Mesh_ptr theMesh,
@ -536,6 +537,7 @@ public:
GEOM::GEOM_Object_ptr theShapeObject, GEOM::GEOM_Object_ptr theShapeObject,
const char* theName = 0); const char* theName = 0);
void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh); void UpdateIcons(SMESH::SMESH_Mesh_ptr theMesh);
void UpdateGroupIcon(SMESH::SMESH_GroupBase_ptr theGroup);
void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid); void HighLightInvalid(CORBA::Object_ptr theObject, bool isInvalid);
bool IsInvalid(SALOMEDS::SObject_ptr theObject); bool IsInvalid(SALOMEDS::SObject_ptr theObject);
bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh, bool AddHypothesisToShape(SMESH::SMESH_Mesh_ptr theMesh,

View File

@ -607,7 +607,8 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent()
//======================================================================= //=======================================================================
SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SMESH::SMESH_Mesh_ptr theMesh, SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
const char* theName) const char* theName,
const char* thePixMap)
{ {
if ( !myIsEnablePublish ) if ( !myIsEnablePublish )
return SALOMEDS::SObject::_nil(); return SALOMEDS::SObject::_nil();
@ -631,7 +632,8 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SMESH::SMESH_Mesh_ptr theMesh,
else else
aTag++; aTag++;
aMeshSO = publish( theMesh, father, aTag, "ICON_SMESH_TREE_MESH_WARN" ); aMeshSO = publish( theMesh, father, aTag,
thePixMap ? thePixMap : "ICON_SMESH_TREE_MESH_WARN" );
if ( aMeshSO->_is_nil() ) if ( aMeshSO->_is_nil() )
return aMeshSO._retn(); return aMeshSO._retn();
} }
@ -977,18 +979,13 @@ void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh )
if ( idSrc->_is_nil() ) if ( idSrc->_is_nil() )
continue; continue;
SMESH::SMESH_GroupBase_var grp = SMESH::SMESH_GroupBase::_narrow( obj );
SMESH::SMESH_GroupOnFilter_var gof = SMESH::SMESH_GroupOnFilter::_narrow( obj );
const bool isGroup = !grp->_is_nil();
const bool isGroupOnFilter = !gof->_is_nil();
bool isEmpty = ( mesh_i->NbNodes() == 0 ); bool isEmpty = ( mesh_i->NbNodes() == 0 );
if ( !isEmpty ) if ( !isEmpty )
{ {
if ( isGroupOnFilter ) // GetTypes() can be very long on GroupOnFilter! SMESH::SMESH_GroupBase_var grp = SMESH::SMESH_GroupBase::_narrow( obj );
{ if ( !grp->_is_nil() ) {
SMESH::smIdType_array_var nbByType = mesh_i->GetNbElementsByType(); UpdateGroupIcon(grp);
isEmpty = ( nbByType[ grp->GetType() ] == 0 ); continue;
} }
else else
{ {
@ -1013,17 +1010,46 @@ void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh )
if ( isEmpty ) if ( isEmpty )
SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN"); SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN");
else if ( !isGroup )
SetPixMap( so, "ICON_SMESH_TREE_MESH" );
else if ( isGroupOnFilter )
SetPixMap( so, "ICON_SMESH_TREE_GROUP_ON_FILTER" );
else else
SetPixMap( so, "ICON_SMESH_TREE_GROUP" ); SetPixMap( so, "ICON_SMESH_TREE_MESH" );
} // loop on sub-meshes or groups } // loop on sub-meshes or groups
} // loop on roots } // loop on roots
} }
//=======================================================================
//function : UpdateGroupIcon
//purpose : update icon of a group
//=======================================================================
void SMESH_Gen_i::UpdateGroupIcon( SMESH::SMESH_GroupBase_ptr theGroup )
{
SALOMEDS::SObject_wrap so = ObjectToSObject( theGroup );
if ( so->_is_nil() )
return;
SMESH::SMESH_GroupOnFilter_var gof = SMESH::SMESH_GroupOnFilter::_narrow( theGroup );
const bool isGroupOnFilter = !gof->_is_nil();
bool isEmpty = false;
if ( isGroupOnFilter ) // GetTypes() can be very long on GroupOnFilter!
{
SMESH::smIdType_array_var nbByType = theGroup->GetMesh()->GetNbElementsByType();
isEmpty = ( nbByType[ theGroup->GetType() ] == 0 );
}
else
{
isEmpty = ( theGroup->Size() == 0 );
}
if ( isEmpty )
SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN");
else if ( isGroupOnFilter )
SetPixMap( so, "ICON_SMESH_TREE_GROUP_ON_FILTER" );
else
SetPixMap( so, "ICON_SMESH_TREE_GROUP" );
}
//======================================================================= //=======================================================================
//function : HighLightInvalid //function : HighLightInvalid
//purpose : change font color of a object in the Object Browser //purpose : change font color of a object in the Object Browser

View File

@ -261,16 +261,19 @@ void SMESH_Group_i::Clear()
if ( myPreMeshInfo ) if ( myPreMeshInfo )
myPreMeshInfo->FullLoadFromFile(); myPreMeshInfo->FullLoadFromFile();
SMESH::SMESH_Group_var me = _this();
// Update Python script // Update Python script
SMESH::TPythonDump() << SMESH::SMESH_Group_var(_this()) << ".Clear()"; SMESH::TPythonDump() << me << ".Clear()";
// Clear the group // Clear the group
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() ); SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
if (aGroupDS) { if (aGroupDS) {
aGroupDS->Clear(); aGroupDS->Clear();
return; SMESH_Gen_i* aGen = GetMeshServant()->GetGen();
aGen->UpdateGroupIcon(me);
Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
} }
Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
} }
//============================================================================= //=============================================================================
@ -301,20 +304,28 @@ SMESH::smIdType SMESH_Group_i::Add( const SMESH::smIdType_array& theIDs )
if ( myPreMeshInfo ) if ( myPreMeshInfo )
myPreMeshInfo->FullLoadFromFile(); myPreMeshInfo->FullLoadFromFile();
SMESH::SMESH_Group_var me = _this();
// Update Python script // Update Python script
SMESH::TPythonDump() << "nbAdd = " << SMESH::SMESH_Group_var(_this()) << ".Add( " << theIDs << " )"; SMESH::TPythonDump() << "nbAdd = " << me << ".Add( " << theIDs << " )";
// Add elements to the group // Add elements to the group
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() ); SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
if (aGroupDS) { if (aGroupDS) {
bool wasEmpty = aGroupDS->IsEmpty();
int nbAdd = 0; int nbAdd = 0;
for ( CORBA::ULong i = 0; i < theIDs.length(); i++) { for ( CORBA::ULong i = 0; i < theIDs.length(); i++) {
int anID = (int) theIDs[i]; int anID = (int) theIDs[i];
if ( aGroupDS->Add( anID )) if ( aGroupDS->Add( anID ))
nbAdd++; nbAdd++;
} }
if ( nbAdd ) if ( nbAdd ) {
Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
if (wasEmpty) {
SMESH_Gen_i* aGen = GetMeshServant()->GetGen();
aGen->UpdateGroupIcon(me);
}
}
return nbAdd; return nbAdd;
} }
MESSAGE("attempt to add elements to a vague group"); MESSAGE("attempt to add elements to a vague group");
@ -332,9 +343,10 @@ SMESH::smIdType SMESH_Group_i::Remove( const SMESH::smIdType_array& theIDs )
if ( myPreMeshInfo ) if ( myPreMeshInfo )
myPreMeshInfo->FullLoadFromFile(); myPreMeshInfo->FullLoadFromFile();
SMESH::SMESH_Group_var me = _this();
// Update Python script // Update Python script
SMESH::TPythonDump() << "nbDel = " << SMESH::SMESH_Group_var(_this()) SMESH::TPythonDump() << "nbDel = " << me << ".Remove( " << theIDs << " )";
<< ".Remove( " << theIDs << " )";
// Remove elements from the group // Remove elements from the group
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() ); SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
@ -345,8 +357,13 @@ SMESH::smIdType SMESH_Group_i::Remove( const SMESH::smIdType_array& theIDs )
if ( aGroupDS->Remove( anID )) if ( aGroupDS->Remove( anID ))
nbDel++; nbDel++;
} }
if ( nbDel ) if ( nbDel ) {
Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
if (aGroupDS->IsEmpty()) {
SMESH_Gen_i* aGen = GetMeshServant()->GetGen();
aGen->UpdateGroupIcon(me);
}
}
return nbDel; return nbDel;
} }
MESSAGE("attempt to remove elements from a vague group"); MESSAGE("attempt to remove elements from a vague group");
@ -361,24 +378,27 @@ SMESH::smIdType SMESH_Group_i::Remove( const SMESH::smIdType_array& theIDs )
typedef bool (SMESHDS_Group::*TFunChangeGroup)(const smIdType); typedef bool (SMESHDS_Group::*TFunChangeGroup)(const smIdType);
CORBA::Long CORBA::Long ChangeByPredicate( SMESH::Predicate_i* thePredicate,
ChangeByPredicate( SMESH::Predicate_i* thePredicate, SMESHDS_GroupBase* theGroupBase,
SMESHDS_GroupBase* theGroupBase, SMESH_GroupBase_i* theGroup,
SMESH::NotifyerAndWaiter* theGroupImpl, TFunChangeGroup theFun)
TFunChangeGroup theFun)
{ {
CORBA::Long aNb = 0; CORBA::Long aNb = 0;
if(SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>(theGroupBase)){ if (SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>(theGroupBase)) {
SMESH::Controls::Filter::TIdSequence aSequence; SMESH::Controls::Filter::TIdSequence aSequence;
const SMDS_Mesh* aMesh = theGroupBase->GetMesh(); const SMDS_Mesh* aMesh = theGroupBase->GetMesh();
SMESH::Filter_i::GetElementsId(thePredicate,aMesh,aSequence); SMESH::Filter_i::GetElementsId(thePredicate,aMesh,aSequence);
CORBA::Long i = 0, iEnd = aSequence.size(); CORBA::Long i = 0, iEnd = aSequence.size();
for(; i < iEnd; i++) for (; i < iEnd; i++)
if((aGroupDS->*theFun)(aSequence[i])) if ((aGroupDS->*theFun)(aSequence[i]))
aNb++; aNb++;
if ( aNb ) if ( aNb ) {
theGroupImpl->Modified(); theGroup->Modified();
SMESH_Gen_i* aGen = theGroup->GetMeshServant()->GetGen();
SMESH::SMESH_GroupBase_var aGroup = theGroup->_this();
aGen->UpdateGroupIcon(aGroup);
}
return aNb; return aNb;
} }
return aNb; return aNb;
@ -428,11 +448,16 @@ SMESH::smIdType SMESH_Group_i::AddFrom( SMESH::SMESH_IDSource_ptr theSource )
aGroupDS->SMDSGroup().Add( elemIt->next() ); aGroupDS->SMDSGroup().Add( elemIt->next() );
} }
// Update Python script SMESH::SMESH_Group_var me = _this();
pd << "nbAdd = " << SMESH::SMESH_Group_var(_this()) << ".AddFrom( " << theSource << " )";
if ( prevNb != Size() ) // Update Python script
pd << "nbAdd = " << me << ".AddFrom( " << theSource << " )";
if ( prevNb != Size() ) {
SMESH_Gen_i* aGen = GetMeshServant()->GetGen();
aGen->UpdateGroupIcon(me);
Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
}
return Size() - prevNb; return Size() - prevNb;
} }
@ -830,17 +855,18 @@ void SMESH_GroupOnFilter_i::SetFilter(SMESH::Filter_ptr theFilter)
myFilter->SetMesh( SMESH::SMESH_Mesh::_nil() ); // to UnRegister() the mesh myFilter->SetMesh( SMESH::SMESH_Mesh::_nil() ); // to UnRegister() the mesh
} }
SMESH_Gen_i* aGen = GetMeshServant()->GetGen();
SMESH::SMESH_GroupOnFilter_var me = _this();
if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() )) if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() ))
{ {
grDS->SetPredicate( GetPredicate( myFilter )); grDS->SetPredicate( GetPredicate( myFilter ));
aGen->UpdateGroupIcon(me);
Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion Modified(); // notify dependent Filter with FT_BelongToMeshGroup criterion
} }
SMESH::SMESH_GroupOnFilter_var me = _this();
// mark the group valid after edition // mark the group valid after edition
GetMeshServant()->GetGen()->HighLightInvalid( me, false ); aGen->HighLightInvalid( me, false );
SMESH::TPythonDump()<< me <<".SetFilter( "<< theFilter <<" )"; SMESH::TPythonDump()<< me <<".SetFilter( "<< theFilter <<" )";
} }
@ -1078,4 +1104,3 @@ void SMESH_GroupOnFilter_i::OnBaseObjModified(NotifyerAndWaiter* /*filter*/, boo
if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() )) if ( SMESHDS_GroupOnFilter* grDS = dynamic_cast< SMESHDS_GroupOnFilter*>( GetGroupDS() ))
grDS->SetPredicate( GetPredicate( myFilter )); // group resets its cache grDS->SetPredicate( GetPredicate( myFilter )); // group resets its cache
} }

View File

@ -1414,6 +1414,9 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr
resGroupDS->SMDSGroup().Add( e ); resGroupDS->SMDSGroup().Add( e );
} }
} }
GetGen()->UpdateGroupIcon(aResGrp);
// Update Python script // Update Python script
pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var(_this()) << ".IntersectGroups( " pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var(_this()) << ".IntersectGroups( "
<< theGroup1 << ", " << theGroup2 << ", '" << theName << "')"; << theGroup1 << ", " << theGroup2 << ", '" << theName << "')";
@ -1500,6 +1503,8 @@ SMESH_Mesh_i::IntersectListOfGroups(const SMESH::ListOfGroups& theGroups,
resGroupDS->SMDSGroup().Add( e ); resGroupDS->SMDSGroup().Add( e );
} }
GetGen()->UpdateGroupIcon(aResGrp);
// Update Python script // Update Python script
pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var( _this() ) pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var( _this() )
<< ".IntersectListOfGroups( " << theGroups << ", '" << theName << "' )"; << ".IntersectListOfGroups( " << theGroups << ", '" << theName << "' )";
@ -1561,6 +1566,9 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr
resGroupDS->SMDSGroup().Add( e ); resGroupDS->SMDSGroup().Add( e );
} }
} }
GetGen()->UpdateGroupIcon(aResGrp);
// Update Python script // Update Python script
pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var(_this()) << ".CutGroups( " pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var(_this()) << ".CutGroups( "
<< theGroup1 << ", " << theGroup2 << ", '" << theName << "')"; << theGroup1 << ", " << theGroup2 << ", '" << theName << "')";
@ -1661,6 +1669,8 @@ SMESH_Mesh_i::CutListOfGroups(const SMESH::ListOfGroups& theMainGroups,
resGroupDS->SMDSGroup().Add( e ); resGroupDS->SMDSGroup().Add( e );
} }
GetGen()->UpdateGroupIcon(aResGrp);
// Update Python script // Update Python script
pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var( _this() ) pyDump << aResGrp << " = " << SMESH::SMESH_Mesh_var( _this() )
<< ".CutListOfGroups( " << theMainGroups << ", " << ".CutListOfGroups( " << theMainGroups << ", "
@ -4576,7 +4586,7 @@ void SMESH_Mesh_i::ExportStructuredCGNS( SMESH::SMESH_IDSource_ptr meshPart,
meshName = name.in(); meshName = name.in();
} }
SMESH_TRY; SMESH_TRY;
SMESH::SMESH_Mesh_var mesh = meshPart->GetMesh(); SMESH::SMESH_Mesh_var mesh = meshPart->GetMesh();
SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh ); SMESH_Mesh_i* mesh_i = SMESH::DownCast<SMESH_Mesh_i*>( mesh );
mesh_i->Load(); mesh_i->Load();