X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupDlg.cxx;h=d3438261aa117bb9d517a684701a8094ece2bec7;hb=86be227dee12b1a2d7dafc3308597f1566ef950f;hp=dae81ae51869e14980d5210b9efd1913efc42482;hpb=afef8ccaa79e91391ccd567bc2607e3584137d36;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index dae81ae51..d3438261a 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -74,6 +74,7 @@ #include // OCCT includes +#include #include // Qt includes @@ -522,19 +523,38 @@ QString SMESHGUI_GroupDlg::GetDefaultName(const QString& theOperation) return aName; } +//======================================================================= +//function : setDefaultName +//purpose : +//======================================================================= + void SMESHGUI_GroupDlg::setDefaultName() const { QString aResName; - int i=1; - QString aPrefix ="Group_"; - _PTR(SObject) anObj; - do + const QString aPrefix ="Group_"; + + if ( myMesh->_is_nil() ) { - aResName = aPrefix + QString::number( i++ ); - anObj = SMESH::getStudy()->FindObject( aResName.toUtf8().constData() ); + aResName = aPrefix + "1"; + } + else + { + SMESH::ListOfGroups_var allGroups = myMesh->GetGroups(); + TColStd_MapOfAsciiString allNames( allGroups->length() ); + for ( CORBA::ULong i = 0; i < allGroups->length(); ++i ) + { + CORBA::String_var name = allGroups[i]->GetName(); + allNames.Add( name.in() ); + } + int i = 1; + while ( true ) + { + aResName = aPrefix + QString::number( i++ ); + if ( !allNames.Contains( aResName.toUtf8().constData() )) + break; + } } - while ( anObj ); - myName->setText(aResName); + myName->setText(aResName); } //================================================================================= @@ -747,7 +767,7 @@ void SMESHGUI_GroupDlg::updateButtons() // function : onNameChanged() // purpose : //================================================================================= -void SMESHGUI_GroupDlg::onNameChanged (const QString& text) +void SMESHGUI_GroupDlg::onNameChanged (const QString& /*text*/) { myOldName = myName->text(); updateButtons(); @@ -794,7 +814,7 @@ void SMESHGUI_GroupDlg::onGrpTypeChanged (int id) // function : onColorChanged() // purpose : Color button management //================================================================================= -void SMESHGUI_GroupDlg::onColorChanged(QColor theColor) +void SMESHGUI_GroupDlg::onColorChanged(QColor /*theColor*/) { updateButtons(); } @@ -944,7 +964,8 @@ bool SMESHGUI_GroupDlg::onApply() if (myGroup->_is_nil()) { // creation or conversion // check if group on geometry is not null - if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil()) { + if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil()) + { if (myMesh->_is_nil()) return false; if ( myGroupOnGeom->_is_nil() ) @@ -958,7 +979,8 @@ bool SMESHGUI_GroupDlg::onApply() } } - if (myGroup->_is_nil()) { // creation + if (myGroup->_is_nil()) // creation + { if (myMesh->_is_nil()) return false; @@ -990,10 +1012,10 @@ bool SMESHGUI_GroupDlg::onApply() myGroup->Add(anIdList.inout()); } } + } - - } else { // edition - + else // edition + { resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup ); isCreation = false; @@ -1111,6 +1133,7 @@ bool SMESHGUI_GroupDlg::onApply() } anIsOk = true; } + if (myGrpTypeId == 2) // group on filter { if ( myFilter->_is_nil() ) return false; @@ -1170,7 +1193,7 @@ bool SMESHGUI_GroupDlg::onApply() Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); if ( isConversion ) { // need to reset TVisualObj and actor SMESH::RemoveVisualObjectWithActors( anIO->getEntry(), true ); - SMESH::Update( anIO,true); + SMESH::Update( anIO, true ); myActorsList.clear(); anActor = SMESH::FindActorByEntry( anIO->getEntry() ); if ( !anActor ) return false; @@ -1402,9 +1425,11 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() SALOME_ListIteratorOfListIO anIt (aList); for (; anIt.More(); anIt.Next()) { - aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value()); - + CORBA::Object_var aGroupObj = SMESH::IObjectToObject(anIt.Value()); + if (CORBA::is_nil(aGroupObj)) + continue; // Check if the object is a geometry group + aGeomGroup = GEOM::GEOM_Object::_narrow(aGroupObj); if (CORBA::is_nil(aGeomGroup)) continue;