0020752: EDF 1303 SMESH : Add a 'Select All' button in Create Group dialog box

This commit is contained in:
vsr 2010-06-22 15:24:40 +00:00
parent 946f0a4e5c
commit 8c1e153907
10 changed files with 263 additions and 141 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -26,7 +26,7 @@ SALOME Platform distinguishes between the two Group types:
\anchor standalone_group <br><h2>"Standalone Group"</h2> \anchor standalone_group <br><h2>"Standalone Group"</h2>
<b>Standalone Group</b> consists of mesh elements, which you can define in <b>Standalone Group</b> consists of mesh elements, which you can define in
two possible ways. the next possible ways:
<ul> <ul>
<li>Choosing them manually with the mouse in the 3D Viewer. You can <li>Choosing them manually with the mouse in the 3D Viewer. You can
click on an element in the 3D viewer and it will be highlighted. After click on an element in the 3D viewer and it will be highlighted. After
@ -36,6 +36,10 @@ the list.</li>
definite filter to selection of the elements of your group. See more definite filter to selection of the elements of your group. See more
about filters on the about filters on the
\ref selection_filter_library_page "Selection filter library" page.</li> \ref selection_filter_library_page "Selection filter library" page.</li>
<li>By adding all existing entities of the chosen type to the
group. For this purpose, it is necessary to turn on the <b>Select
All</b> check box. In this mode, all controls which allow selection of
the entities manually or by filters, are disabled.</li>
</ul> </ul>
To remove a selected element or elements from the list click the To remove a selected element or elements from the list click the
\b Remove button. The <b>Sort List</b> button allows to sort the list of IDs of \b Remove button. The <b>Sort List</b> button allows to sort the list of IDs of

View File

@ -19,7 +19,11 @@ aFilter = smesh.GetFilter(smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100.)
anIds = mesh.GetIdsFromFilter(aFilter) anIds = mesh.GetIdsFromFilter(aFilter)
# create a group consisting of faces with area > 100 # create a group consisting of faces with area > 100
aGroup = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds) aGroup1 = mesh.MakeGroupByIds("Area > 100", smesh.FACE, anIds)
# create a group that contains all nodes from the mesh
aGroup2 = mesh.CreateEmptyGroup(smesh.NODE, "all nodes")
aGroup2.AddFrom(mesh.mesh)
salome.sg.updateObjBrowser(1) salome.sg.updateObjBrowser(1)
\endcode \endcode

View File

@ -121,15 +121,25 @@ module SMESH
void Clear(); void Clear();
/*! /*!
* Adds elements to the group * Adds elements or nodes with specified identifiers to the group
*/ */
long Add( in long_array elem_ids ); long Add( in long_array elem_ids );
/*!
* Adds elements or nodes that match specified predicate to the group
*/
long AddByPredicate( in Predicate thePredicate ); long AddByPredicate( in Predicate thePredicate );
/*!
* Add all elements or nodes from the specified source to the group
*/
long AddFrom( in SMESH_IDSource theSource );
/*! /*!
* Removes elements from the group * Removes elements or nodes with specified identifiers from the group
*/ */
long Remove( in long_array elem_ids ); long Remove( in long_array elem_ids );
/*!
* Removes elements or nodes that match specified predicate from the group
*/
long RemoveByPredicate( in Predicate thePredicate ); long RemoveByPredicate( in Predicate thePredicate );
}; };

View File

@ -99,6 +99,19 @@
#define SPACING 6 #define SPACING 6
#define MARGIN 11 #define MARGIN 11
enum grpSelectionMode {
grpNoSelection = -1,
grpNodeSelection = 0,
grpEdgeSelection = 1,
grpFaceSelection = 2,
grpVolumeSelection = 3,
grpSubMeshSelection = 4,
grpGroupSelection = 5,
grpMeshSelection = 6,
grpGeomSelection = 7,
grpAllSelection = 8,
};
//================================================================================= //=================================================================================
// function : SMESHGUI_GroupDlg() // function : SMESHGUI_GroupDlg()
// purpose : // purpose :
@ -147,7 +160,7 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule,
mySelectGroup->setEnabled( false ); mySelectGroup->setEnabled( false );
myCurrentLineEdit = myMeshGroupLine; myCurrentLineEdit = myMeshGroupLine;
setSelectionMode( 5 ); setSelectionMode( grpGroupSelection );
} }
} }
@ -241,59 +254,62 @@ void SMESHGUI_GroupDlg::initDialog( bool create)
aContentBoxLayout->setMargin( MARGIN ); aContentBoxLayout->setMargin( MARGIN );
aContentBoxLayout->setSpacing( SPACING ); aContentBoxLayout->setSpacing( SPACING );
QLabel* aLabel = new QLabel( tr( "SMESH_ID_ELEMENTS" ), aContentBox ); mySelectAll = new QCheckBox( tr( "SELECT_ALL" ), aContentBox );
myElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), aContentBox );
myElements = new QListWidget( aContentBox ); myElements = new QListWidget( aContentBox );
myElements->setSelectionMode( QListWidget::ExtendedSelection ); myElements->setSelectionMode( QListWidget::ExtendedSelection );
myFilter = new QPushButton( tr( "SMESH_BUT_FILTER" ), aContentBox ); myFilter = new QPushButton( tr( "SMESH_BUT_FILTER" ), aContentBox );
QPushButton* aAddBtn = new QPushButton( tr( "SMESH_BUT_ADD" ), aContentBox ); myAddBtn = new QPushButton( tr( "SMESH_BUT_ADD" ), aContentBox );
QPushButton* aRemoveBtn = new QPushButton( tr( "SMESH_BUT_REMOVE" ), aContentBox ); myRemoveBtn = new QPushButton( tr( "SMESH_BUT_REMOVE" ), aContentBox );
QPushButton* aSortBtn = new QPushButton( tr( "SMESH_BUT_SORT" ), aContentBox ); mySortBtn = new QPushButton( tr( "SMESH_BUT_SORT" ), aContentBox );
aContentBoxLayout->addWidget( aLabel, 0, 0 ); aContentBoxLayout->addWidget( mySelectAll, 0, 0 );
aContentBoxLayout->addWidget( myElements, 1, 0, 6, 1 ); aContentBoxLayout->addWidget( myElementsLab, 1, 0 );
aContentBoxLayout->addWidget( myFilter, 1, 1 ); aContentBoxLayout->addWidget( myElements, 2, 0, 6, 1 );
aContentBoxLayout->addWidget( aAddBtn, 3, 1 ); aContentBoxLayout->addWidget( myFilter, 2, 1 );
aContentBoxLayout->addWidget( aRemoveBtn, 4, 1 ); aContentBoxLayout->addWidget( myAddBtn, 4, 1 );
aContentBoxLayout->addWidget( aSortBtn, 6, 1 ); aContentBoxLayout->addWidget( myRemoveBtn, 5, 1 );
aContentBoxLayout->addWidget( mySortBtn, 7, 1 );
aContentBoxLayout->setColumnStretch( 0, 1 ); aContentBoxLayout->setColumnStretch( 0, 1 );
aContentBoxLayout->setRowStretch( 2, 1 ); aContentBoxLayout->setRowStretch( 3, 1 );
aContentBoxLayout->setRowStretch( 5, 1 ); aContentBoxLayout->setRowStretch( 6, 1 );
/***************************************************************/ /***************************************************************/
QGroupBox* aSelectBox = new QGroupBox( tr( "SMESH_SELECT_FROM" ), wg1 ); mySelectBox = new QGroupBox( tr( "SMESH_SELECT_FROM" ), wg1 );
QGridLayout* aSelectBoxLayout = new QGridLayout( aSelectBox ); QGridLayout* mySelectBoxLayout = new QGridLayout( mySelectBox );
aSelectBoxLayout->setMargin( MARGIN ); mySelectBoxLayout->setMargin( MARGIN );
aSelectBoxLayout->setSpacing( SPACING ); mySelectBoxLayout->setSpacing( SPACING );
mySelectSubMesh = new QCheckBox( tr( "SMESH_SUBMESH" ), aSelectBox ); mySelectSubMesh = new QCheckBox( tr( "SMESH_SUBMESH" ), mySelectBox );
mySubMeshBtn = new QPushButton( aSelectBox ); mySubMeshBtn = new QPushButton( mySelectBox );
mySubMeshBtn->setIcon( image0 ); mySubMeshBtn->setIcon( image0 );
mySubMeshLine = new QLineEdit( aSelectBox ); mySubMeshLine = new QLineEdit( mySelectBox );
mySubMeshLine->setReadOnly( true ); mySubMeshLine->setReadOnly( true );
onSelectSubMesh( false ); onSelectSubMesh( false );
mySelectGroup = new QCheckBox( tr( "SMESH_GROUP" ), aSelectBox ); mySelectGroup = new QCheckBox( tr( "SMESH_GROUP" ), mySelectBox );
myGroupBtn = new QPushButton( aSelectBox ); myGroupBtn = new QPushButton( mySelectBox );
myGroupBtn->setIcon( image0 ); myGroupBtn->setIcon( image0 );
myGroupLine = new QLineEdit( aSelectBox ); myGroupLine = new QLineEdit( mySelectBox );
myGroupLine->setReadOnly( true ); myGroupLine->setReadOnly( true );
onSelectGroup( false ); onSelectGroup( false );
aSelectBoxLayout->addWidget( mySelectSubMesh, 0, 0 ); mySelectBoxLayout->addWidget( mySelectSubMesh, 0, 0 );
aSelectBoxLayout->addWidget( mySubMeshBtn, 0, 1 ); mySelectBoxLayout->addWidget( mySubMeshBtn, 0, 1 );
aSelectBoxLayout->addWidget( mySubMeshLine, 0, 2 ); mySelectBoxLayout->addWidget( mySubMeshLine, 0, 2 );
aSelectBoxLayout->addWidget( mySelectGroup, 1, 0 ); mySelectBoxLayout->addWidget( mySelectGroup, 1, 0 );
aSelectBoxLayout->addWidget( myGroupBtn, 1, 1 ); mySelectBoxLayout->addWidget( myGroupBtn, 1, 1 );
aSelectBoxLayout->addWidget( myGroupLine, 1, 2 ); mySelectBoxLayout->addWidget( myGroupLine, 1, 2 );
/***************************************************************/ /***************************************************************/
QVBoxLayout* wg1Layout = new QVBoxLayout( wg1 ); QVBoxLayout* wg1Layout = new QVBoxLayout( wg1 );
wg1Layout->setMargin( 0 ); wg1Layout->setMargin( 0 );
wg1Layout->setSpacing( SPACING ); wg1Layout->setSpacing( SPACING );
wg1Layout->addWidget( aContentBox ); wg1Layout->addWidget( aContentBox );
wg1Layout->addWidget( aSelectBox ); wg1Layout->addWidget( mySelectBox );
wg1Layout->setStretchFactor( aContentBox, 10 ); wg1Layout->setStretchFactor( aContentBox, 10 );
/***************************************************************/ /***************************************************************/
@ -374,36 +390,37 @@ void SMESHGUI_GroupDlg::initDialog( bool create)
aMainLayout->addWidget(aButtons, 6, 0, 1, 3); aMainLayout->addWidget(aButtons, 6, 0, 1, 3);
/* signals and slots connections */ /* signals and slots connections */
connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGrpTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onGrpTypeChanged(int))); connect(myGrpTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onGrpTypeChanged(int)));
connect(myTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onTypeChanged(int))); connect(myTypeGroup, SIGNAL(buttonClicked(int)), this, SLOT(onTypeChanged(int)));
connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&))); connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
connect(myElements, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged())); connect(myElements, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters())); connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd())); connect(mySelectAll, SIGNAL(toggled(bool)), this, SLOT(onSelectAll()));
connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove())); connect(myAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort())); connect(myRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
connect(mySortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool))); connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool))); connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool))); connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool)));
connect(myColorBtn, SIGNAL(changed( QColor )), this, SLOT(onColorChanged( QColor ))); connect(myColorBtn, SIGNAL(changed( QColor )), this, SLOT(onColorChanged( QColor )));
connect(myOKBtn, SIGNAL(clicked()), this, SLOT(onOK())); connect(myOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
connect(myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply())); connect(myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
connect(myCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); connect(myCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
connect(myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); connect(myHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
/* Init selection */ /* Init selection */
mySMESHGUI->SetActiveDialogBox(this); mySMESHGUI->SetActiveDialogBox(this);
mySMESHGUI->SetState(800); mySMESHGUI->SetState(800);
mySelectionMode = -1; mySelectionMode = grpNoSelection;
myMeshFilter = new SMESH_TypeFilter(MESH); myMeshFilter = new SMESH_TypeFilter(MESH);
mySubMeshFilter = new SMESH_TypeFilter(SUBMESH); mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
myGroupFilter = new SMESH_TypeFilter(GROUP); myGroupFilter = new SMESH_TypeFilter(GROUP);
@ -612,7 +629,7 @@ void SMESHGUI_GroupDlg::updateButtons()
bool enable = !myName->text().trimmed().isEmpty(); bool enable = !myName->text().trimmed().isEmpty();
if (myGrpTypeId == 0) { if (myGrpTypeId == 0) {
enable = enable && myElements->count() > 0; enable = enable && (mySelectAll->isChecked() || myElements->count() > 0);
enable = enable && (!myGroup->_is_nil() || !myMesh->_is_nil()); enable = enable && (!myGroup->_is_nil() || !myMesh->_is_nil());
} }
else if (myGrpTypeId == 1) { else if (myGrpTypeId == 1) {
@ -685,6 +702,8 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
// PAL7314 // PAL7314
if (myMesh->_is_nil()) if (myMesh->_is_nil())
return; return;
SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
bool isSelectAll = mySelectAll->isChecked();
if (mySelectionMode != theMode) { if (mySelectionMode != theMode) {
// [PAL10408] mySelectionMgr->clearSelected(); // [PAL10408] mySelectionMgr->clearSelected();
mySelectionMgr->clearFilters(); mySelectionMgr->clearFilters();
@ -693,46 +712,51 @@ void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
while ( it.hasNext() ) while ( it.hasNext() )
it.next()->SetPointRepresentation(false); it.next()->SetPointRepresentation(false);
} }
else else {
SMESH::SetPointRepresentation(false); SMESH::SetPointRepresentation(false);
if (theMode < 4) {
switch (theMode) {
case 0:
if (myActorsList.count() > 0) {
QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() )
it.next()->SetPointRepresentation(true);
}
else
SMESH::SetPointRepresentation(true);
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(NodeSelection);
break;
case 1:
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(EdgeSelection);
break;
case 2:
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(FaceSelection);
break;
default:
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(VolumeSelection);
}
} else {
if (theMode == 4)
mySelectionMgr->installFilter(mySubMeshFilter);
else if (theMode == 5)
mySelectionMgr->installFilter(myGroupFilter);
else if (theMode == 6)
mySelectionMgr->installFilter(myMeshFilter);
else if (theMode == 7)
mySelectionMgr->installFilter(myGeomFilter);
if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
aViewWindow->SetSelectionMode(ActorSelection);
} }
switch (theMode) {
case grpNodeSelection:
if (myActorsList.count() > 0) {
QListIterator<SMESH_Actor*> it( myActorsList );
while ( it.hasNext() )
it.next()->SetPointRepresentation(true);
}
else {
SMESH::SetPointRepresentation(true);
}
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : NodeSelection);
break;
case grpEdgeSelection:
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : EdgeSelection);
break;
case grpFaceSelection:
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : FaceSelection);
break;
case grpVolumeSelection:
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : VolumeSelection);
break;
case grpSubMeshSelection:
mySelectionMgr->installFilter(mySubMeshFilter);
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
case grpGroupSelection:
mySelectionMgr->installFilter(myGroupFilter);
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
case grpMeshSelection:
mySelectionMgr->installFilter(myMeshFilter);
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
case grpGeomSelection:
mySelectionMgr->installFilter(myGeomFilter);
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
default:
if ( aViewWindow ) aViewWindow->SetSelectionMode(ActorSelection);
break;
}
if ( aViewWindow ) aViewWindow->Repaint();
mySelectionMode = theMode; mySelectionMode = theMode;
} }
} }
@ -750,7 +774,7 @@ bool SMESHGUI_GroupDlg::onApply()
return false; return false;
if (myGrpTypeId == 0) { // on mesh elements if (myGrpTypeId == 0) { // on mesh elements
if (!myElements->count()) if (!mySelectAll->isChecked() && !myElements->count())
return false; return false;
mySelectionMgr->clearSelected(); mySelectionMgr->clearSelected();
@ -778,15 +802,23 @@ bool SMESHGUI_GroupDlg::onApply()
case 3: aType = SMESH::VOLUME; break; case 3: aType = SMESH::VOLUME; break;
} }
SMESH::long_array_var anIdList = new SMESH::long_array;
int i, k = myElements->count();
anIdList->length(k);
for (i = 0; i < k; i++) {
anIdList[i] = myElements->item(i)->text().toInt();
}
myGroup = SMESH::AddGroup(myMesh, aType, myName->text()); myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
myGroup->Add(anIdList.inout());
if ( mySelectAll->isChecked() ) {
// select all
myGroup->AddFrom(myMesh.in());
}
else {
// select manually
SMESH::long_array_var anIdList = new SMESH::long_array;
int i, k = myElements->count();
anIdList->length(k);
for (i = 0; i < k; i++) {
anIdList[i] = myElements->item(i)->text().toInt();
}
myGroup->Add(anIdList.inout());
}
SALOMEDS::Color aColor = getGroupColor(); SALOMEDS::Color aColor = getGroupColor();
myGroup->SetColor(aColor); myGroup->SetColor(aColor);
@ -818,37 +850,44 @@ bool SMESHGUI_GroupDlg::onApply()
} }
} }
QList<int> aAddList; if ( mySelectAll->isChecked() ) {
// select all
myGroup->Clear();
myGroup->AddFrom(myMesh.in());
}
else {
QList<int> aAddList;
int i, total = myElements->count(); int i, total = myElements->count();
for (i = 0; i < total; i++) { for (i = 0; i < total; i++) {
int anId = myElements->item(i)->text().toInt(); int anId = myElements->item(i)->text().toInt();
int idx = myIdList.indexOf(anId); int idx = myIdList.indexOf(anId);
if ( idx == -1 ) if ( idx == -1 )
aAddList.append(anId); aAddList.append(anId);
else else
myIdList.removeAt(idx); myIdList.removeAt(idx);
} }
if (!aAddList.empty()) { if (!aAddList.empty()) {
SMESH::long_array_var anIdList = new SMESH::long_array; SMESH::long_array_var anIdList = new SMESH::long_array;
int added = aAddList.count(); int added = aAddList.count();
anIdList->length(added); anIdList->length(added);
for (i = 0; i < added; i++) for (i = 0; i < added; i++)
anIdList[i] = aAddList[i]; anIdList[i] = aAddList[i];
myGroup->Add(anIdList.inout()); myGroup->Add(anIdList.inout());
} }
if (!myIdList.empty()) { if (!myIdList.empty()) {
SMESH::long_array_var anIdList = new SMESH::long_array; SMESH::long_array_var anIdList = new SMESH::long_array;
int removed = myIdList.count(); int removed = myIdList.count();
anIdList->length(removed); anIdList->length(removed);
for (i = 0; i < removed; i++) for (i = 0; i < removed; i++)
anIdList[i] = myIdList[i]; anIdList[i] = myIdList[i];
myGroup->Remove(anIdList.inout()); myGroup->Remove(anIdList.inout());
} }
/* init for next operation */ /* init for next operation */
myIdList.clear(); myIdList.clear();
for (i = 0; i < total; i++) { for (i = 0; i < total; i++) {
myIdList.append(myElements->item(i)->text().toInt()); myIdList.append(myElements->item(i)->text().toInt());
}
} }
} }
@ -1336,6 +1375,24 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
myIsBusy = false; myIsBusy = false;
} }
//=================================================================================
// function : onSelectSubMesh()
// purpose : Called when selection in 3D view or ObjectBrowser is changed
//=================================================================================
void SMESHGUI_GroupDlg::onSelectAll()
{
myElementsLab->setEnabled( !mySelectAll->isChecked() );
myElements->setEnabled( !mySelectAll->isChecked() );
myFilter->setEnabled( !mySelectAll->isChecked() );
myAddBtn->setEnabled( !mySelectAll->isChecked() );
myRemoveBtn->setEnabled( !mySelectAll->isChecked() );
mySortBtn->setEnabled( !mySelectAll->isChecked() );
mySelectBox->setEnabled( !mySelectAll->isChecked() );
int selMode = mySelectionMode;
mySelectionMode = grpNoSelection;
setSelectionMode( selMode );
}
//================================================================================= //=================================================================================
// function : onSelectSubMesh() // function : onSelectSubMesh()
// purpose : Called when selection in 3D view or ObjectBrowser is changed // purpose : Called when selection in 3D view or ObjectBrowser is changed
@ -1350,7 +1407,7 @@ void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
//VSR: mySelectGeomGroup->setChecked(false); //VSR: mySelectGeomGroup->setChecked(false);
//VSR: } //VSR: }
myCurrentLineEdit = mySubMeshLine; myCurrentLineEdit = mySubMeshLine;
setSelectionMode(4); setSelectionMode(grpSubMeshSelection);
} }
else { else {
mySubMeshLine->setText( "" ); mySubMeshLine->setText( "" );
@ -1374,7 +1431,7 @@ void SMESHGUI_GroupDlg::onSelectGroup(bool on)
mySelectSubMesh->setChecked(false); mySelectSubMesh->setChecked(false);
} }
myCurrentLineEdit = myGroupLine; myCurrentLineEdit = myGroupLine;
setSelectionMode(5); setSelectionMode(grpGroupSelection);
} }
else { else {
myGroupLine->setText( "" ); myGroupLine->setText( "" );
@ -1402,7 +1459,7 @@ void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
} }
myCurrentLineEdit = myGeomGroupLine; myCurrentLineEdit = myGeomGroupLine;
updateGeomPopup(); updateGeomPopup();
setSelectionMode(8); setSelectionMode(grpAllSelection);
} }
else { else {
myGeomGroupBtn->setChecked(false); myGeomGroupBtn->setChecked(false);
@ -1427,9 +1484,9 @@ void SMESHGUI_GroupDlg::setCurrentSelection()
disconnect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); disconnect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
mySelectionMgr->clearSelected(); mySelectionMgr->clearSelected();
if (myCreate) if (myCreate)
setSelectionMode(6); setSelectionMode(grpMeshSelection);
else else
setSelectionMode(5); setSelectionMode(grpGroupSelection);
connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
myCurrentLineEdit = myMeshGroupLine; myCurrentLineEdit = myMeshGroupLine;
onObjectSelectionChanged(); onObjectSelectionChanged();
@ -1960,7 +2017,7 @@ void SMESHGUI_GroupDlg::enterEvent (QEvent*)
if (!isEnabled()) { if (!isEnabled()) {
mySMESHGUI->EmitSignalDeactivateDialog(); mySMESHGUI->EmitSignalDeactivateDialog();
setEnabled(true); setEnabled(true);
mySelectionMode = -1; mySelectionMode = grpNoSelection;
setSelectionMode(myTypeId); setSelectionMode(myTypeId);
//mySMESHGUI->SetActiveDialogBox((QDialog*)this); //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
mySMESHGUI->SetActiveDialogBox(this); mySMESHGUI->SetActiveDialogBox(this);
@ -2038,12 +2095,12 @@ void SMESHGUI_GroupDlg::onGeomSelectionButton(bool isBtnOn)
myCurrentLineEdit = myGeomGroupLine; myCurrentLineEdit = myGeomGroupLine;
QAction* a = myGeomPopup->exec( QCursor::pos() ); QAction* a = myGeomPopup->exec( QCursor::pos() );
if (!a || myActions[a] == DIRECT_GEOM_INDEX) if (!a || myActions[a] == DIRECT_GEOM_INDEX)
setSelectionMode(7); setSelectionMode(grpGeomSelection);
} }
else if (!isBtnOn) else if (!isBtnOn)
{ {
myCurrentLineEdit = 0; myCurrentLineEdit = 0;
setSelectionMode(8); setSelectionMode(grpAllSelection);
} }
} }
@ -2056,7 +2113,7 @@ void SMESHGUI_GroupDlg::onGeomPopup( QAction* a )
int index = myActions[a]; int index = myActions[a];
if ( index == GEOM_BY_MESH_INDEX ) if ( index == GEOM_BY_MESH_INDEX )
{ {
mySelectionMode = -1; mySelectionMode = grpNoSelection;
if ( !myShapeByMeshOp ) { if ( !myShapeByMeshOp ) {
myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true); myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true);
connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)), connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
@ -2117,7 +2174,7 @@ void SMESHGUI_GroupDlg::onCloseShapeByMeshDlg(SUIT_Operation* op)
if ( myShapeByMeshOp == op ) if ( myShapeByMeshOp == op )
{ {
show(); show();
setSelectionMode(7); setSelectionMode(grpGeomSelection);
} }
} }

View File

@ -40,6 +40,8 @@
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Group)
class QGroupBox;
class QLabel;
class QLineEdit; class QLineEdit;
class QButtonGroup; class QButtonGroup;
class QListWidget; class QListWidget;
@ -96,6 +98,7 @@ private slots:
void onListSelectionChanged(); void onListSelectionChanged();
void onObjectSelectionChanged(); void onObjectSelectionChanged();
void onSelectAll();
void onSelectSubMesh( bool ); void onSelectSubMesh( bool );
void onSelectGroup( bool ); void onSelectGroup( bool );
void onSelectGeomGroup( bool ); void onSelectGeomGroup( bool );
@ -157,13 +160,18 @@ private:
QButtonGroup* myGrpTypeGroup; QButtonGroup* myGrpTypeGroup;
QStackedWidget* myWGStack; QStackedWidget* myWGStack;
QCheckBox* mySelectAll;
QLabel* myElementsLab;
QListWidget* myElements; QListWidget* myElements;
QPushButton* myFilter; QPushButton* myFilter;
QPushButton* myAddBtn;
QPushButton* myRemoveBtn;
QPushButton* mySortBtn;
QGroupBox* mySelectBox;
QCheckBox* mySelectSubMesh; QCheckBox* mySelectSubMesh;
QPushButton* mySubMeshBtn; QPushButton* mySubMeshBtn;
QLineEdit* mySubMeshLine; QLineEdit* mySubMeshLine;
QCheckBox* mySelectGroup; QCheckBox* mySelectGroup;
QPushButton* myGroupBtn; QPushButton* myGroupBtn;
QLineEdit* myGroupLine; QLineEdit* myGroupLine;

View File

@ -4365,6 +4365,13 @@ Please specify them and try again</translation>
<translation>Union of two groups</translation> <translation>Union of two groups</translation>
</message> </message>
</context> </context>
<context>
<name>SMESHGUI_GroupDlg</name>
<message>
<source>SELECT_ALL</source>
<translation>Select All</translation>
</message>
</context>
<context> <context>
<name>SMESHGUI_UnionGroupsDlg</name> <name>SMESHGUI_UnionGroupsDlg</name>
<message> <message>

View File

@ -347,6 +347,36 @@ RemoveByPredicate( SMESH::Predicate_ptr thePredicate )
return 0; return 0;
} }
CORBA::Long SMESH_Group_i::AddFrom( SMESH::SMESH_IDSource_ptr theSource )
{
long nbAdd = 0;
SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( GetGroupDS() );
if (aGroupDS) {
SMESH::long_array_var anIds;
if ( !CORBA::is_nil(SMESH::SMESH_GroupBase::_narrow(theSource)) &&
SMESH::SMESH_GroupBase::_narrow(theSource)->GetType() == GetType() ) {
anIds = theSource->GetIDs();
}
else if ( !CORBA::is_nil(SMESH::SMESH_Mesh::_narrow(theSource)) ) {
anIds = SMESH::SMESH_Mesh::_narrow(theSource)->GetElementsByType( GetType() );
}
else if ( !CORBA::is_nil(SMESH::SMESH_subMesh::_narrow(theSource)) ) {
anIds = SMESH::SMESH_subMesh::_narrow(theSource)->GetElementsByType( GetType() );
}
else {
anIds->length( 0 );
}
for ( int i = 0, total = anIds->length(); i < total; i++ ) {
if ( aGroupDS->Add((int)anIds[i]) ) nbAdd++;
}
}
// Update Python script
TPythonDump() << "nbAdd = " << _this() << ".AddFrom( " << theSource << " )";
return nbAdd;
}
//============================================================================= //=============================================================================
/*! /*!
* *

View File

@ -113,6 +113,8 @@ class SMESH_I_EXPORT SMESH_Group_i:
CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate ); CORBA::Long AddByPredicate( SMESH::Predicate_ptr thePredicate );
CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate ); CORBA::Long RemoveByPredicate( SMESH::Predicate_ptr thePredicate );
CORBA::Long AddFrom( SMESH::SMESH_IDSource_ptr theSource );
}; };
// ========================= // =========================