0019970: create groups automatically

remove "Name" lineEdit
This commit is contained in:
eap 2008-10-01 12:04:32 +00:00
parent 6298ac0081
commit 043cbb6e60
4 changed files with 31 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -78,7 +78,7 @@ a new group of mesh elements will be created.
To create multiple groups on geometry of both nodes and elements of To create multiple groups on geometry of both nodes and elements of
any type at once, in the \b Mesh menu select <b>Create Groups from any type at once, in the \b Mesh menu select <b>Create Groups from
Geometry</b>.<br> Geometry</b>.<br>
Unique group names are generated by appending a number to \b Name. Group names are same as those of geometrical objects.
Type of group of mesh elements is defined automatically by Type of group of mesh elements is defined automatically by
<b>Geometrical object</b> nature. <b>Geometrical object</b> nature.

View File

@ -64,8 +64,8 @@ SMESHGUI_GroupOnShapeDlg::SMESHGUI_GroupOnShapeDlg()
aGrp->setInsideMargin( 0 ); aGrp->setInsideMargin( 0 );
// Name // Name
new QLabel( tr( "SMESH_NAME" ), aGrp ); new QLabel( "", aGrp ); //new QLabel( tr( "SMESH_NAME" ), aGrp ); new QLabel( "", aGrp );
myGrpNameLine = new QLineEdit( aGrp, "myGrpNameLine" ); //myGrpNameLine = new QLineEdit( aGrp, "myGrpNameLine" );
// Mesh // Mesh
new QLabel( tr( "SMESH_OBJECT_MESH" ), aGrp ); new QLabel( tr( "SMESH_OBJECT_MESH" ), aGrp );
@ -133,7 +133,7 @@ SMESHGUI_GroupOnShapeDlg::SMESHGUI_GroupOnShapeDlg()
void SMESHGUI_GroupOnShapeDlg::updateButtons() void SMESHGUI_GroupOnShapeDlg::updateButtons()
{ {
bool enable = bool enable =
!myGrpNameLine->text().isEmpty() && myElemGeomList->count() + myNodeGeomList->count(); /*!myGrpNameLine->text().isEmpty() &&*/ myElemGeomList->count() + myNodeGeomList->count();
button(Apply)->setEnabled( enable ); button(Apply)->setEnabled( enable );
button(OK)->setEnabled( enable ); button(OK)->setEnabled( enable );
@ -147,7 +147,7 @@ void SMESHGUI_GroupOnShapeDlg::updateButtons()
void SMESHGUI_GroupOnShapeDlg::init() void SMESHGUI_GroupOnShapeDlg::init()
{ {
myGrpNameLine->setText(""); //myGrpNameLine->setText("");
myMeshBtn->setOn( true ); myMeshBtn->setOn( true );
myMeshLine->setText(""); myMeshLine->setText("");
@ -270,7 +270,7 @@ void SMESHGUI_GroupOnShapeOp::startOperation()
connect(myDlg->myMeshBtn, SIGNAL(clicked()), this, SLOT(onButtonClick())); connect(myDlg->myMeshBtn, SIGNAL(clicked()), this, SLOT(onButtonClick()));
connect(myDlg->myElemGeomBtn, SIGNAL(clicked()), this, SLOT(onButtonClick())); connect(myDlg->myElemGeomBtn, SIGNAL(clicked()), this, SLOT(onButtonClick()));
connect(myDlg->myNodeGeomBtn, SIGNAL(clicked()), this, SLOT(onButtonClick())); connect(myDlg->myNodeGeomBtn, SIGNAL(clicked()), this, SLOT(onButtonClick()));
connect(myDlg->myGrpNameLine, SIGNAL(textChanged(const QString&)),myDlg,SLOT(updateButtons())); //connect(myDlg->myGrpNameLine, SIGNAL(textChanged(const QString&)),myDlg,SLOT(updateButtons()));
} }
SMESHGUI_SelectionOp::startOperation(); SMESHGUI_SelectionOp::startOperation();
@ -301,12 +301,15 @@ bool SMESHGUI_GroupOnShapeOp::onApply()
if ( mesh->_is_nil() ) return false; if ( mesh->_is_nil() ) return false;
// names of all existing groups // names of all existing groups
SMESH::ListOfGroups_var groups = mesh->GetGroups(); // QStringList groupNames;
QStringList groupNames; // QString givenName = myDlg->myGrpNameLine->text();
for ( int i = 0; i < groups->length(); ++i ) { // if ( !givenName.isEmpty() ) {
CORBA::String_var name = groups[i]->GetName(); // SMESH::ListOfGroups_var groups = mesh->GetGroups();
groupNames.append( name.in() ); // for ( int i = 0; i < groups->length(); ++i ) {
} // CORBA::String_var name = groups[i]->GetName();
// groupNames.append( name.in() );
// }
// }
// create groups // create groups
SMESH::SMESH_GroupOnGeom_var group; SMESH::SMESH_GroupOnGeom_var group;
@ -315,7 +318,7 @@ bool SMESHGUI_GroupOnShapeOp::onApply()
QStringList::iterator geomID = isNode ? myNodeGeoIDs.begin() : myElemGeoIDs.begin(); QStringList::iterator geomID = isNode ? myNodeGeoIDs.begin() : myElemGeoIDs.begin();
QStringList::iterator geomEnd = isNode ? myNodeGeoIDs.end() : myElemGeoIDs.end(); QStringList::iterator geomEnd = isNode ? myNodeGeoIDs.end() : myElemGeoIDs.end();
for ( ; geomID != geomEnd; ++geomID ) for (int i = 0 ; geomID != geomEnd; ++geomID, ++i )
{ {
// selected geom // selected geom
_PTR(SObject) geomSO = aStudy->FindObjectID( *geomID ); _PTR(SObject) geomSO = aStudy->FindObjectID( *geomID );
@ -327,13 +330,20 @@ bool SMESHGUI_GroupOnShapeOp::onApply()
if ( elemType == SMESH::ALL ) if ( elemType == SMESH::ALL )
continue; continue;
// make a unique name // group name
int nb = 1; QString name;
QString name = myDlg->myGrpNameLine->text() + "_" + QString::number(nb); //if ( givenName.isEmpty() ) { // use shape name
while ( groupNames.contains( name )) name = isNode ? myDlg->myNodeGeomList->text(i) : myDlg->myElemGeomList->text(i);
name = myDlg->myGrpNameLine->text() + "_" + QString::number(++nb); // }
groupNames.append( name ); // else { // make a unique name
// name = givenName;
// int nb = 0;
// if ( myNodeGeoIDs.size() + myElemGeoIDs.size() > 1 )
// name += "_" + QString::number(++nb);
// while ( groupNames.contains( name ))
// name = givenName + "_" + QString::number(++nb);
// groupNames.append( name );
// }
//printf( "apply() %s %s\n", (*geomID).latin1(), name.latin1() ); //printf( "apply() %s %s\n", (*geomID).latin1(), name.latin1() );
group = mesh->CreateGroupFromGEOM( elemType, name, geom ); group = mesh->CreateGroupFromGEOM( elemType, name, geom );
} }

View File

@ -123,7 +123,7 @@ public slots:
private: private:
QLineEdit* myGrpNameLine; //QLineEdit* myGrpNameLine;
QPushButton* myMeshBtn; QPushButton* myMeshBtn;
QLineEdit* myMeshLine; QLineEdit* myMeshLine;