1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org or email : webmaster.salome@opencascade.org
24 // File : SMESHGUI_GroupDlg.cxx
25 // Author : Natalia KOPNOVA
29 #include "SMESHGUI_GroupDlg.h"
30 #include "SMESHGUI_FilterDlg.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_GroupUtils.h"
37 #include "SMESHGUI_FilterUtils.h"
38 #include "SMESHGUI_GEOMGenUtils.h"
40 #include "SMESH_TypeFilter.hxx"
41 #include "SMESH_Actor.h"
44 #include "SUIT_Desktop.h"
45 #include "SUIT_ResourceMgr.h"
47 #include "SalomeApp_Tools.h"
48 #include "SALOMEDSClient_Study.hxx"
49 #include "SALOME_ListIO.hxx"
50 #include "SALOME_ListIteratorOfListIO.hxx"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_Selector.h"
55 #include "utilities.h"
58 #include <TColStd_MapOfInteger.hxx>
61 #include <qbuttongroup.h>
62 #include <qgroupbox.h>
65 #include <qlineedit.h>
66 #include <qpushbutton.h>
67 #include <qradiobutton.h>
68 #include <qcheckbox.h>
73 #include <qmemarray.h>
74 #include <qwidgetstack.h>
82 //=================================================================================
83 // function : SMESHGUI_GroupDlg()
85 //=================================================================================
86 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
87 SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl)
88 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
89 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
90 mySMESHGUI( theModule ),
91 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
92 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
96 if (!name) setName("SMESHGUI_GroupDlg");
98 if (!theMesh->_is_nil())
101 mySelectSubMesh->setEnabled(false);
102 mySelectGroup->setEnabled(false);
103 myGeomGroupBtn->setEnabled(false);
104 myGeomGroupLine->setEnabled(false);
108 //=================================================================================
109 // function : SMESHGUI_GroupDlg()
111 //=================================================================================
112 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
113 SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl)
114 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
115 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
116 mySMESHGUI( theModule ),
117 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
118 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
121 if (!name) setName("SMESHGUI_GroupDlg");
124 if (!theGroup->_is_nil())
127 mySelectSubMesh->setEnabled(false);
128 mySelectGroup->setEnabled(false);
130 myCurrentLineEdit = myMeshGroupLine;
135 //=================================================================================
136 // function : SMESHGUI_GroupDlg()
138 //=================================================================================
139 void SMESHGUI_GroupDlg::initDialog(bool create)
143 myCurrentLineEdit = 0;
145 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
148 setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
150 setCaption(tr("SMESH_EDIT_GROUP_TITLE"));
152 setSizeGripEnabled(TRUE);
154 QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6);
156 /***************************************************************/
157 QLabel* meshGroupLab = new QLabel(this, "mesh/group label");
159 meshGroupLab->setText(tr("SMESH_MESH"));
161 meshGroupLab->setText(tr("SMESH_GROUP"));
162 myMeshGroupBtn = new QPushButton(this, "mesh/group button");
163 myMeshGroupBtn->setPixmap(image0);
164 myMeshGroupLine = new QLineEdit(this, "mesh/group line");
165 myMeshGroupLine->setReadOnly(true);
167 /***************************************************************/
168 myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
169 myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
170 myTypeGroup->setExclusive(true);
173 types.append(tr("MESH_NODE"));
174 types.append(tr("SMESH_EDGE"));
175 types.append(tr("SMESH_FACE"));
176 types.append(tr("SMESH_VOLUME"));
178 for (int i = 0; i < types.count(); i++) {
179 rb = new QRadioButton(types[i], myTypeGroup);
181 myTypeGroup->setEnabled(create);
184 /***************************************************************/
185 QLabel* aName = new QLabel(this, "name label");
186 aName->setText(tr("SMESH_NAME"));
187 aName->setMinimumSize(50,0);
188 myName = new QLineEdit(this, "name");
190 /***************************************************************/
191 myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group");
192 myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE"));
193 myGrpTypeGroup->setExclusive(true);
194 QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup);
195 QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"), myGrpTypeGroup);
196 myGrpTypeGroup->setEnabled(create);
199 /***************************************************************/
200 myWGStack = new QWidgetStack( this, "widget stack");
201 QWidget* wg1 = new QFrame( myWGStack, "first widget" );
202 QWidget* wg2 = new QFrame( myWGStack, "second widget" );
204 /***************************************************************/
205 QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box");
206 aContentBox->setTitle(tr("SMESH_CONTENT"));
207 QFrame* aContent = new QFrame(aContentBox, "content");
208 QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
209 aLayout->setSpacing(6);
210 aLayout->setAutoAdd(false);
212 QLabel* aLabel = new QLabel(aContent, "elements label");
213 aLabel->setText(tr("SMESH_ID_ELEMENTS"));
214 myElements = new QListBox(aContent, "elements list");
215 myElements->setSelectionMode(QListBox::Extended);
217 myFilter = new QPushButton(aContent, "filter");
218 myFilter->setText(tr("SMESH_BUT_FILTER"));
219 QPushButton* aAddBtn = new QPushButton(aContent, "add");
220 aAddBtn->setText(tr("SMESH_BUT_ADD"));
221 QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
222 aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
223 QPushButton* aSortBtn = new QPushButton(aContent, "sort");
224 aSortBtn->setText(tr("SMESH_BUT_SORT"));
226 aLayout->addWidget(aLabel, 0, 0);
227 aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
228 aLayout->addWidget(myFilter, 1, 2);
229 aLayout->addWidget(aAddBtn, 3, 2);
230 aLayout->addWidget(aRemoveBtn, 4, 2);
231 aLayout->addWidget(aSortBtn, 6, 2);
233 aLayout->setColStretch(0, 1);
234 aLayout->addColSpacing(1, 20);
235 aLayout->addColSpacing(3, 20);
236 aLayout->setRowStretch(2, 1);
237 aLayout->setRowStretch(5, 1);
239 /***************************************************************/
240 QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box");
241 aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
243 mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
244 mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
245 mySelectSubMesh->setMinimumSize(50, 0);
246 mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
247 mySubMeshBtn->setText("");
248 mySubMeshBtn->setPixmap(image0);
249 mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
250 mySubMeshLine->setReadOnly(true);
251 onSelectSubMesh(false);
253 mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
254 mySelectGroup->setText(tr("SMESH_GROUP"));
255 mySelectGroup->setMinimumSize(50, 0);
256 myGroupBtn = new QPushButton(aSelectBox, "group button");
257 myGroupBtn->setText("");
258 myGroupBtn->setPixmap(image0);
259 myGroupLine = new QLineEdit(aSelectBox, "group line");
260 myGroupLine->setReadOnly(true);
261 onSelectGroup(false);
263 /***************************************************************/
264 QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
265 wg1Layout->addWidget(aContentBox, 0, 0);
266 wg1Layout->addWidget(aSelectBox, 1, 0);
267 wg1Layout->setRowStretch(2, 5);
269 /***************************************************************/
270 QLabel* geomObject = new QLabel(wg2, "geometry object label");
271 geomObject->setText(tr("SMESH_OBJECT_GEOM"));
272 myGeomGroupBtn = new QPushButton(wg2, "geometry group button");
273 myGeomGroupBtn->setText("");
274 myGeomGroupBtn->setPixmap(image0);
275 myGeomGroupLine = new QLineEdit(wg2, "geometry group line");
276 myGeomGroupLine->setReadOnly(true); //VSR ???
277 onSelectGeomGroup(false);
281 myGeomGroupBtn->setEnabled(false);
282 myGeomGroupLine->setEnabled(false);
285 /***************************************************************/
286 QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
287 wg2Layout->addWidget(geomObject, 0, 0);
288 wg2Layout->addWidget(myGeomGroupBtn, 0, 1);
289 wg2Layout->addWidget(myGeomGroupLine,0, 2);
290 wg2Layout->setRowStretch(1, 5);
292 /***************************************************************/
293 QVBoxLayout* dumb = new QVBoxLayout(myWGStack);
294 dumb->addWidget(wg1);
295 dumb->addWidget(wg2);
296 myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) );
297 myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
299 /***************************************************************/
300 QGroupBox* aColorBox = new QGroupBox(this, "color box");
301 aColorBox->setTitle(tr("SMESH_SET_COLOR"));
303 mySelectColorGroup = new QCheckBox(aColorBox, "color checkbox");
304 mySelectColorGroup->setText(tr("SMESH_CHECK_COLOR"));
305 mySelectColorGroup->setMinimumSize(50, 0);
307 myColorGroupLine = new QLineEdit(aColorBox, "color line");
308 myColorGroupLine->setReadOnly(false);
309 onSelectColorGroup(false);
311 /***************************************************************/
312 QHBoxLayout* aColorLayout = new QHBoxLayout(aColorBox, 15, 20);
313 aColorLayout->setAutoAdd(false);
315 aColorLayout->addWidget(mySelectColorGroup);
316 aColorLayout->addWidget(myColorGroupLine);
318 /***************************************************************/
320 QFrame* aButtons = new QFrame(this, "button box");
321 aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
322 QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
323 aBtnLayout->setAutoAdd(false);
325 QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
326 aOKBtn->setText(tr("SMESH_BUT_OK"));
327 aOKBtn->setAutoDefault(true);
328 aOKBtn->setDefault(true);
329 QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
330 aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
331 aApplyBtn->setAutoDefault(true);
332 QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
333 aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
334 aCloseBtn->setAutoDefault(true);
336 aBtnLayout->addWidget(aOKBtn);
337 aBtnLayout->addWidget(aApplyBtn);
338 aBtnLayout->addStretch();
339 aBtnLayout->addWidget(aCloseBtn);
341 /***************************************************************/
342 aMainLayout->addWidget(meshGroupLab, 0, 0);
343 aMainLayout->addWidget(myMeshGroupBtn, 0, 1);
344 aMainLayout->addWidget(myMeshGroupLine, 0, 2);
345 aMainLayout->addMultiCellWidget(myTypeGroup, 1, 1, 0, 2);
346 aMainLayout->addWidget(aName, 2, 0);
347 aMainLayout->addWidget(myName, 2, 2);
348 aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
349 aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2);
350 aMainLayout->setRowStretch( 5, 5 );
351 aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2);
352 aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2);
354 /* signals and slots connections */
355 connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
357 connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int)));
359 connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
361 connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
362 connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
364 connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
365 connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
366 connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
367 connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
369 connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
370 connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
371 connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
372 connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
373 connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
374 connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool)));
375 connect(myColorGroupLine, SIGNAL(textChanged(const QString&)), this, SLOT(onNbColorsChanged(const QString&)));
377 connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
378 connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
379 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
382 mySMESHGUI->SetActiveDialogBox(this);
383 mySMESHGUI->SetState(800);
385 mySelectionMode = -1;
386 myMeshFilter = new SMESH_TypeFilter(MESH);
387 mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
388 myGroupFilter = new SMESH_TypeFilter(GROUP);
390 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
391 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
392 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
394 myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
395 onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
397 if (myMesh->_is_nil() )
398 myTypeGroup->setButton(0);
403 //=================================================================================
404 // function : ~SMESHGUI_GroupDlg()
405 // purpose : Destroys the object and frees any allocated resources
406 //=================================================================================
407 SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
409 // no need to delete child widgets, Qt does it all for us
410 if ( myFilterDlg != 0 )
412 myFilterDlg->reparent( 0, QPoint() );
417 //=================================================================================
420 //=================================================================================
421 void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
423 mySelectionMgr->installFilter(myMeshFilter);
425 /* init data from current selection */
426 myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
427 myGroup = SMESH::SMESH_Group::_nil();
428 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
430 myActor = SMESH::FindActorByObject(myMesh);
431 SMESH::SetPickable(myActor);
434 mySelectionMgr->selectedObjects( aList );
435 if( !aList.IsEmpty() )
437 QString aName = aList.First()->getName();
438 myMeshGroupLine->setText(aName) ;
439 myMeshGroupLine->home( false );
442 myCurrentLineEdit = 0;
444 myTypeGroup->setButton(0);
448 //=================================================================================
451 //=================================================================================
452 void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
454 myMesh = theGroup->GetMesh();
456 myName->setText(theGroup->GetName());
459 myColorGroupLine->setText(QString::number(theGroup->GetColorNumber()));
460 myColorGroupLine->home(false);
462 myMeshGroupLine->setText(theGroup->GetName());
465 switch(theGroup->GetType()) {
466 case SMESH::NODE: aType= 0; break;
467 case SMESH::EDGE: aType = 1; break;
468 case SMESH::FACE: aType = 2; break;
469 case SMESH::VOLUME: aType = 3; break;
471 myTypeGroup->setButton(aType);
473 myGroup = SMESH::SMESH_Group::_narrow( theGroup );
475 if ( !myGroup->_is_nil() )
477 myGrpTypeGroup->setButton(0);
480 myActor = SMESH::FindActorByObject(myMesh);
482 myActor = SMESH::FindActorByObject(myGroup);
483 SMESH::SetPickable(myActor);
485 myCurrentLineEdit = 0;
487 setSelectionMode(aType);
491 if (!myGroup->IsEmpty()) {
492 SMESH::long_array_var anElements = myGroup->GetListOfID();
493 int k = anElements->length();
494 for (int i = 0; i < k; i++) {
495 myIdList.append(anElements[i]);
496 myElements->insertItem(QString::number(anElements[i]));
498 myElements->selectAll(true);
503 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
505 if ( !myGroupOnGeom->_is_nil() )
507 myGrpTypeGroup->setButton(1);
510 myActor = SMESH::FindActorByObject(myMesh);
512 myActor = SMESH::FindActorByObject(myGroup);
513 SMESH::SetPickable(myActor);
515 QString aShapeName("");
516 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
517 GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
518 if (!aGroupShape->_is_nil())
520 _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
521 aShapeName = aGroupShapeSO->GetName().c_str();
523 myGeomGroupLine->setText( aShapeName );
528 //=================================================================================
529 // function : updateButtons()
531 //=================================================================================
532 void SMESHGUI_GroupDlg::updateButtons()
536 if (myGrpTypeId == 0)
537 enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0;
538 else if (myGrpTypeId == 1)
540 bool isEditMode = !CORBA::is_nil( myGroupOnGeom );
541 enable = !myName->text().stripWhiteSpace().isEmpty() && (!CORBA::is_nil( myGeomGroup ) || isEditMode);
544 aBtn = (QPushButton*) child("ok", "QPushButton");
545 if (aBtn) aBtn->setEnabled(enable);
546 aBtn = (QPushButton*) child("apply", "QPushButton");
547 if (aBtn) aBtn->setEnabled(enable);
550 //=================================================================================
551 // function : onNameChanged()
553 //=================================================================================
554 void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
559 //=================================================================================
560 // function : onNbColorsChanged()
562 //=================================================================================
563 void SMESHGUI_GroupDlg::onNbColorsChanged (const QString& text)
568 //=================================================================================
569 // function : onTypeChanged()
570 // purpose : Group elements type radio button management
571 //=================================================================================
572 void SMESHGUI_GroupDlg::onTypeChanged (int id)
574 if (myTypeId != id) {
576 if (myCurrentLineEdit == 0)
577 setSelectionMode(id);
582 //=================================================================================
583 // function : onGrpTypeChanged()
584 // purpose : Group type radio button management
585 //=================================================================================
586 void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
588 if (myGrpTypeId != id) {
589 myWGStack->raiseWidget( id );
590 onSelectGeomGroup(id == 1);
595 //=================================================================================
596 // function : setSelectionMode()
597 // purpose : Radio button management
598 //=================================================================================
599 void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
602 if (myMesh->_is_nil())
605 if (mySelectionMode != theMode) {
606 // [PAL10408] mySelectionMgr->clearSelected();
607 mySelectionMgr->clearFilters();
608 SMESH::SetPointRepresentation(false);
613 myActor->SetPointRepresentation(true);
615 SMESH::SetPointRepresentation(true);
616 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
617 aViewWindow->SetSelectionMode(NodeSelection);
620 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
621 aViewWindow->SetSelectionMode(EdgeSelection);
624 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
625 aViewWindow->SetSelectionMode(FaceSelection);
628 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
629 aViewWindow->SetSelectionMode(VolumeSelection);
633 mySelectionMgr->installFilter(mySubMeshFilter);
634 else if (theMode == 5)
635 mySelectionMgr->installFilter(myGroupFilter);
636 else if (theMode == 6)
637 mySelectionMgr->installFilter(myMeshFilter);
638 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
639 aViewWindow->SetSelectionMode(ActorSelection);
641 mySelectionMode = theMode;
645 //=================================================================================
646 // function : onApply()
648 //=================================================================================
649 bool SMESHGUI_GroupDlg::onApply()
651 if (mySMESHGUI->isActiveStudyLocked())
654 if (myGrpTypeId == 0 &&
655 !myName->text().stripWhiteSpace().isEmpty() &&
656 myElements->count() > 0) {
657 mySelectionMgr->clearSelected();
658 if (myGroup->_is_nil()) {
659 SMESH::ElementType aType = SMESH::ALL;
661 case 0: aType = SMESH::NODE; break;
662 case 1: aType = SMESH::EDGE; break;
663 case 2: aType = SMESH::FACE; break;
664 case 3: aType = SMESH::VOLUME; break;
666 SMESH::long_array_var anIdList = new SMESH::long_array;
667 int i, k = myElements->count();
669 QListBoxItem* anItem;
670 for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
671 anIdList[i] = anItem->text().toInt();
674 myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
675 myGroup->Add(anIdList.inout());
677 int aColorNumber = myColorGroupLine->text().toInt();
678 myGroup->SetColorNumber(aColorNumber);
680 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
682 SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text());
684 SMESH::setFileType (aMeshGroupSO,"COULEURGROUP");
686 /* init for next operation */
688 myColorGroupLine->setText("");
690 myGroup = SMESH::SMESH_Group::_nil();
693 myGroup->SetName(myName->text());
695 int aColorNumber = myColorGroupLine->text().toInt();
696 myGroup->SetColorNumber(aColorNumber);
698 QValueList<int> aAddList;
699 QValueList<int>::iterator anIt;
700 QListBoxItem* anItem;
702 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
703 int anId = anItem->text().toInt();
704 if ((anIt = myIdList.find(anId)) == myIdList.end())
705 aAddList.append(anId);
707 myIdList.remove(anIt);
709 if (!aAddList.empty()) {
710 SMESH::long_array_var anIdList = new SMESH::long_array;
711 anIdList->length(aAddList.count());
713 for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
715 myGroup->Add(anIdList.inout());
717 if (!myIdList.empty()) {
718 SMESH::long_array_var anIdList = new SMESH::long_array;
719 anIdList->length(myIdList.count());
721 for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
723 myGroup->Remove(anIdList.inout());
725 /* init for next operation */
727 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
728 myIdList.append(anItem->text().toInt());
731 mySMESHGUI->updateObjBrowser(true);
732 SMESH::UpdateView(); // asv: fix of BUG PAL5515
733 mySelectionMgr->clearSelected();
735 } else if (myGrpTypeId == 1 &&
736 !myName->text().stripWhiteSpace().isEmpty() &&
737 (!CORBA::is_nil(myGeomGroup) || !CORBA::is_nil(myGroupOnGeom)))
739 if (myGroupOnGeom->_is_nil()) {
740 SMESH::ElementType aType = SMESH::ALL;
742 case 0: aType = SMESH::NODE; break;
743 case 1: aType = SMESH::EDGE; break;
744 case 2: aType = SMESH::FACE; break;
745 case 3: aType = SMESH::VOLUME; break;
748 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
749 GEOM::GEOM_IGroupOperations_var aGroupOp =
750 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
752 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup);
754 int aColorNumber = myColorGroupLine->text().toInt();
755 myGroupOnGeom->SetColorNumber(aColorNumber);
757 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
759 SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text());
761 SMESH::setFileType (aMeshGroupSO,"COULEURGROUP");
763 /* init for next operation */
765 myColorGroupLine->setText("");
766 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
770 myGroupOnGeom->SetName(myName->text());
772 int aColorNumber = myColorGroupLine->text().toInt();
773 myGroupOnGeom->SetColorNumber(aColorNumber);
776 mySMESHGUI->updateObjBrowser(true);
777 mySelectionMgr->clearSelected();
784 //=================================================================================
787 //=================================================================================
788 void SMESHGUI_GroupDlg::onOK()
794 //=================================================================================
795 // function : onListSelectionChanged()
796 // purpose : Called when selection in element list is changed
797 //=================================================================================
798 void SMESHGUI_GroupDlg::onListSelectionChanged()
800 // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
801 if( myIsBusy || !myActor) return;
804 if (myCurrentLineEdit == 0) {
805 mySelectionMgr->clearSelected();
806 TColStd_MapOfInteger aIndexes;
807 QListBoxItem* anItem;
808 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
809 if (anItem->isSelected()) {
810 int anId = anItem->text().toInt();
814 mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
816 aList.Append(myActor->getIO());
817 mySelectionMgr->setSelectedObjects(aList,false);
822 //=================================================================================
823 // function : onObjectSelectionChanged()
824 // purpose : Called when selection in 3D view or ObjectBrowser is changed
825 //=================================================================================
826 void SMESHGUI_GroupDlg::onObjectSelectionChanged()
828 if ( myIsBusy || !isEnabled()) return;
832 mySelectionMgr->selectedObjects( aList );
834 int aNbSel = aList.Extent();
835 myElements->clearSelection();
837 if (myCurrentLineEdit) {
838 myCurrentLineEdit->setText("");
839 QString aString = "";
841 if (myCurrentLineEdit == myMeshGroupLine) {
842 mySelectSubMesh->setEnabled(false);
843 mySelectGroup->setEnabled(false);
844 myGroupLine->setText("");
845 mySubMeshLine->setText("");
847 myGeomGroupBtn->setEnabled(false);
848 myGeomGroupLine->setEnabled(false);
849 myGeomGroupLine->setText("");
856 myGroup = SMESH::SMESH_Group::_nil();
857 myMesh = SMESH::SMESH_Mesh::_nil();
861 Handle(SALOME_InteractiveObject) IO = aList.First();
864 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
865 if (myMesh->_is_nil())
870 myGroup = SMESH::SMESH_Group::_nil();
872 myActor = SMESH::FindActorByObject(myMesh);
873 SMESH::SetPickable(myActor);
875 aString = aList.First()->getName();
876 myMeshGroupLine->setText(aString) ;
877 myMeshGroupLine->home( false );
879 mySelectSubMesh->setEnabled(true);
880 mySelectGroup->setEnabled(true);
881 myGeomGroupBtn->setEnabled(true);
882 myGeomGroupLine->setEnabled(true);
885 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
886 if (aGroup->_is_nil())
892 myCurrentLineEdit = 0;
895 mySelectSubMesh->setEnabled(true);
896 mySelectGroup->setEnabled(true);
897 myGeomGroupBtn->setEnabled(true);
898 myGeomGroupLine->setEnabled(true);
900 myCurrentLineEdit = 0;
909 setSelectionMode(myTypeId);
915 } else if (myCurrentLineEdit == myGeomGroupLine) {
917 myGeomGroup = GEOM::GEOM_Object::_nil();
922 Standard_Boolean testResult = Standard_False;
923 myGeomGroup = GEOMBase::ConvertIOinGEOMObject(aList.First(), testResult);
925 // Check if the object is a geometry group
926 if (!testResult || CORBA::is_nil(myGeomGroup)) {
927 myGeomGroup = GEOM::GEOM_Object::_nil();
931 // Check if group constructed on the same shape as a mesh or on its child
932 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
933 GEOM::GEOM_IGroupOperations_var anOp =
934 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
936 // The main shape of the group
937 GEOM::GEOM_Object_var aGroupMainShape;
938 if (myGeomGroup->GetType() == 37)
939 aGroupMainShape = anOp->GetMainShape(myGeomGroup);
941 aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup);
942 _PTR(SObject) aGroupMainShapeSO =
943 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
944 aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
947 _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
949 myGeomGroup = GEOM::GEOM_Object::_nil();
953 _PTR(SObject) anObj, aRef;
954 bool isRefOrSubShape = false;
955 if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
956 //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
957 if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
958 isRefOrSubShape = true;
960 _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
961 _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
962 //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
963 while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
964 //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
965 if (aRef->GetID() == aFather->GetID())
966 isRefOrSubShape = true;
968 aFather = aFather->GetFather();
972 if (!isRefOrSubShape) {
973 myGeomGroup = GEOM::GEOM_Object::_nil();
981 if(myCurrentLineEdit == mySubMeshLine)
982 aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
983 else if(myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine)
984 aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
986 aString = aList.First()->getName();
990 myCurrentLineEdit->setText(aString);
991 myCurrentLineEdit->home(false);
996 if (aNbSel == 1 && myActor ) {
997 QString aListStr = "";
1000 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1002 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1005 QStringList anElements = QStringList::split(" ", aListStr);
1006 QListBoxItem* anItem = 0;
1007 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1008 anItem = myElements->findItem(*it, Qt::ExactMatch);
1009 if (anItem) myElements->setSelected(anItem, true);
1016 if (!myGroup->_is_nil())
1017 myActor = SMESH::FindActorByObject(myGroup);
1018 else if(!myGroupOnGeom->_is_nil())
1019 myActor = SMESH::FindActorByObject(myGroupOnGeom);
1021 myActor = SMESH::FindActorByObject(myMesh);
1027 //=================================================================================
1028 // function : onSelectSubMesh()
1029 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1030 //=================================================================================
1031 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1034 if (mySelectGroup->isChecked()) {
1035 mySelectGroup->setChecked(false);
1037 //VSR: else if (mySelectGeomGroup->isChecked()) {
1038 //VSR: mySelectGeomGroup->setChecked(false);
1040 myCurrentLineEdit = mySubMeshLine;
1041 setSelectionMode(4);
1044 mySubMeshLine->setText("");
1045 myCurrentLineEdit = 0;
1047 setSelectionMode(myTypeId);
1049 mySubMeshBtn->setEnabled(on);
1050 mySubMeshLine->setEnabled(on);
1054 //=================================================================================
1055 // function : (onSelectGroup)
1056 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1057 //=================================================================================
1058 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1061 if (mySelectSubMesh->isChecked()) {
1062 mySelectSubMesh->setChecked(false);
1064 myCurrentLineEdit = myGroupLine;
1065 setSelectionMode(5);
1068 myGroupLine->setText("");
1069 myCurrentLineEdit = 0;
1071 setSelectionMode(myTypeId);
1073 myGroupBtn->setEnabled(on);
1074 myGroupLine->setEnabled(on);
1078 //=================================================================================
1079 // function : (onSelectGeomGroup)
1080 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1081 //=================================================================================
1082 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1085 if (mySelectSubMesh->isChecked()) {
1086 mySelectSubMesh->setChecked(false);
1088 else if (mySelectGroup->isChecked()) {
1089 mySelectGroup->setChecked(false);
1091 myCurrentLineEdit = myGeomGroupLine;
1092 setSelectionMode(7);
1095 myGeomGroupLine->setText("");
1096 myCurrentLineEdit = 0;
1098 setSelectionMode(myTypeId);
1102 //=================================================================================
1103 // function : (onSelectColorGroup)
1104 // purpose : Called when setting a color on group
1105 //=================================================================================
1106 void SMESHGUI_GroupDlg::onSelectColorGroup(bool on)
1109 setSelectionMode(7);
1112 myColorGroupLine->setText("");
1113 myCurrentLineEdit = 0;
1115 setSelectionMode(myTypeId);
1117 myColorGroupLine->setEnabled(on);
1120 //=================================================================================
1121 // function : setCurrentSelection()
1123 //=================================================================================
1124 void SMESHGUI_GroupDlg::setCurrentSelection()
1126 QPushButton* send = (QPushButton*)sender();
1127 myCurrentLineEdit = 0;
1128 if (send == myMeshGroupBtn) {
1129 myCurrentLineEdit = myMeshGroupLine;
1131 setSelectionMode(6);
1133 setSelectionMode(5);
1134 onObjectSelectionChanged();
1136 else if (send == mySubMeshBtn) {
1137 myCurrentLineEdit = mySubMeshLine;
1138 onObjectSelectionChanged();
1140 else if (send == myGroupBtn) {
1141 myCurrentLineEdit = myGroupLine;
1142 onObjectSelectionChanged();
1144 else if (send == myGeomGroupBtn) {
1145 myCurrentLineEdit = myGeomGroupLine;
1146 setSelectionMode(7);
1147 onObjectSelectionChanged();
1152 //=================================================================================
1153 // function : setFilters()
1154 // purpose : SLOT. Called when "Filter" button pressed.
1155 //=================================================================================
1156 void SMESHGUI_GroupDlg::setFilters()
1158 SMESH::ElementType aType = SMESH::ALL;
1161 case 0 : aType = SMESH::NODE; break;
1162 case 1 : aType = SMESH::EDGE; break;
1163 case 2 : aType = SMESH::FACE; break;
1164 case 3 : aType = SMESH::VOLUME; break;
1168 if ( myFilterDlg == 0 )
1170 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1171 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1174 myFilterDlg->Init( aType );
1176 myFilterDlg->SetSelection();
1177 myFilterDlg->SetMesh( myMesh );
1178 myFilterDlg->SetSourceWg( myElements );
1180 myFilterDlg->show();
1183 //=================================================================================
1184 // function : onFilterAccepted()
1185 // purpose : SLOT. Called when Filter dlg closed with OK button.
1186 // Uncheck "Select submesh" and "Select group" checkboxes
1187 //=================================================================================
1188 void SMESHGUI_GroupDlg::onFilterAccepted()
1190 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1192 mySelectionMode = myTypeId;
1193 mySelectSubMesh->setChecked( false );
1194 mySelectGroup->setChecked( false );
1198 //=================================================================================
1199 // function : onAdd()
1201 //=================================================================================
1202 void SMESHGUI_GroupDlg::onAdd()
1204 SALOME_ListIO aList;
1205 mySelectionMgr->selectedObjects( aList );
1207 int aNbSel = aList.Extent();
1209 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1213 SMESH::ElementType aType = SMESH::ALL;
1216 aType = SMESH::NODE;
1217 mySelector->SetSelectionMode(NodeSelection);
1220 aType = SMESH::EDGE;
1221 mySelector->SetSelectionMode(EdgeSelection);
1224 aType = SMESH::FACE;
1225 mySelector->SetSelectionMode(FaceSelection);
1228 aType = SMESH::VOLUME;
1229 mySelector->SetSelectionMode(VolumeSelection);
1232 mySelector->SetSelectionMode(ActorSelection);
1236 if (myCurrentLineEdit == 0) {
1237 //if (aNbSel != 1) { myIsBusy = false; return; }
1238 QString aListStr = "";
1240 if (myTypeId == 0) {
1241 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1244 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1247 QStringList anElements = QStringList::split(" ", aListStr);
1248 QListBoxItem* anItem = 0;
1249 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1250 anItem = myElements->findItem(*it, Qt::ExactMatch);
1252 anItem = new QListBoxText(*it);
1253 myElements->insertItem(anItem);
1255 myElements->setSelected(anItem, true);
1258 } else if (myCurrentLineEdit == mySubMeshLine) {
1259 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1261 SALOME_ListIO aList;
1262 mySelectionMgr->selectedObjects( aList );
1264 SALOME_ListIteratorOfListIO anIt (aList);
1265 for (; anIt.More(); anIt.Next()) {
1266 SMESH::SMESH_subMesh_var aSubMesh =
1267 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1268 if (!aSubMesh->_is_nil()) {
1269 // check if mesh is the same
1270 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1272 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1273 int k = anElements->length();
1274 QListBoxItem* anItem = 0;
1275 for (int i = 0; i < k; i++) {
1276 QString aText = QString::number(anElements[i]);
1277 anItem = myElements->findItem(aText, Qt::ExactMatch);
1279 anItem = new QListBoxText(aText);
1280 myElements->insertItem(anItem);
1282 myElements->setSelected(anItem, true);
1285 catch (const SALOME::SALOME_Exception& ex) {
1286 SalomeApp_Tools::QtCatchCorbaException(ex);
1291 mySelectSubMesh->setChecked(false);
1293 onListSelectionChanged();
1295 } else if (myCurrentLineEdit == myGroupLine) {
1296 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1297 SALOME_ListIO aList;
1298 mySelectionMgr->selectedObjects( aList );
1300 SALOME_ListIteratorOfListIO anIt (aList);
1301 for (; anIt.More(); anIt.Next()) {
1302 SMESH::SMESH_Group_var aGroup =
1303 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1304 if (!aGroup->_is_nil()) {
1305 // check if mesh is the same
1306 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1307 SMESH::long_array_var anElements = aGroup->GetListOfID();
1308 int k = anElements->length();
1309 QListBoxItem* anItem = 0;
1310 for (int i = 0; i < k; i++) {
1311 QString aText = QString::number(anElements[i]);
1312 anItem = myElements->findItem(aText, Qt::ExactMatch);
1314 anItem = new QListBoxText(aText);
1315 myElements->insertItem(anItem);
1317 myElements->setSelected(anItem, true);
1322 mySelectGroup->setChecked(false);
1324 onListSelectionChanged();
1326 } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) {
1327 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1328 GEOM::GEOM_IGroupOperations_var aGroupOp =
1329 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1331 SMESH::ElementType aGroupType = SMESH::ALL;
1332 switch(aGroupOp->GetType(myGeomGroup)) {
1333 case 7: aGroupType = SMESH::NODE; break;
1334 case 6: aGroupType = SMESH::EDGE; break;
1335 case 4: aGroupType = SMESH::FACE; break;
1336 case 2: aGroupType = SMESH::VOLUME; break;
1337 default: myIsBusy = false; return;
1340 if (aGroupType == aType) {
1341 _PTR(SObject) aGroupSO =
1342 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1343 aStudy->FindObjectID(myGeomGroup->GetStudyEntry());
1345 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1346 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1347 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1348 aBelongToGeom->SetGeom(myGeomGroup);
1349 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1350 aBelongToGeom->SetElementType(aType);
1351 aFilter->SetPredicate(aBelongToGeom);
1353 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1355 int k = anElements->length();
1356 QListBoxItem* anItem = 0;
1357 for (int i = 0; i < k; i++) {
1358 QString aText = QString::number(anElements[i]);
1359 anItem = myElements->findItem(aText, Qt::ExactMatch);
1361 anItem = new QListBoxText(aText);
1362 myElements->insertItem(anItem);
1364 myElements->setSelected(anItem, true);
1368 //VSR: mySelectGeomGroup->setChecked(false);
1370 onListSelectionChanged();
1373 // mySelectionMgr->clearSelected();
1377 //=================================================================================
1378 // function : onRemove()
1380 //=================================================================================
1381 void SMESHGUI_GroupDlg::onRemove()
1384 if (myCurrentLineEdit == 0) {
1385 for (int i = myElements->count(); i > 0; i--) {
1386 if (myElements->isSelected(i-1)) {
1387 myElements->removeItem(i-1);
1391 SALOME_ListIO aList;
1392 mySelectionMgr->selectedObjects( aList );
1394 int aNbSel = aList.Extent();
1396 if (aNbSel == 0) { myIsBusy = false; return; }
1398 SMESH::ElementType aType = SMESH::ALL;
1400 case 0: aType = SMESH::NODE; break;
1401 case 1: aType = SMESH::EDGE; break;
1402 case 2: aType = SMESH::FACE; break;
1403 case 3: aType = SMESH::VOLUME; break;
1406 if (myCurrentLineEdit == mySubMeshLine) {
1407 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1408 SALOME_ListIO aList;
1409 mySelectionMgr->selectedObjects( aList );
1411 SALOME_ListIteratorOfListIO anIt (aList);
1412 for (; anIt.More(); anIt.Next()) {
1413 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1414 if (!aSubMesh->_is_nil()) {
1415 // check if mesh is the same
1416 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1417 if (aType == SMESH::NODE) {
1419 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1420 int k = anElements->length();
1421 QListBoxItem* anItem = 0;
1422 for (int i = 0; i < k; i++) {
1423 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1424 if (anItem) delete anItem;
1427 catch (const SALOME::SALOME_Exception& ex) {
1428 SalomeApp_Tools::QtCatchCorbaException(ex);
1433 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1434 int k = anElements->length();
1435 QListBoxItem* anItem = 0;
1436 for (int i = 0; i < k; i++) {
1437 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1438 if (anItem) delete anItem;
1441 catch (const SALOME::SALOME_Exception& ex) {
1442 SalomeApp_Tools::QtCatchCorbaException(ex);
1449 else if (myCurrentLineEdit == myGroupLine) {
1450 Standard_Boolean aRes;
1451 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1452 SALOME_ListIO aList;
1453 mySelectionMgr->selectedObjects( aList );
1455 SALOME_ListIteratorOfListIO anIt (aList);
1456 for (; anIt.More(); anIt.Next()) {
1457 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1458 if (aRes && !aGroup->_is_nil()) {
1459 // check if mesh is the same
1460 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1461 SMESH::long_array_var anElements = aGroup->GetListOfID();
1462 int k = anElements->length();
1463 QListBoxItem* anItem = 0;
1464 for (int i = 0; i < k; i++) {
1465 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1466 if (anItem) delete anItem;
1477 //=================================================================================
1478 // function : onSort()
1480 //=================================================================================
1481 void SMESHGUI_GroupDlg::onSort()
1483 // PAL5412: sorts items in ascending by "string" value
1484 // myElements->sort(true);
1485 // myElements->update();
1486 int i, k = myElements->count();
1489 QStringList aSelected;
1490 std::vector<int> anArray(k);
1491 // QMemArray<int> anArray(k);
1492 QListBoxItem* anItem;
1494 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1495 anArray[i] = anItem->text().toInt();
1496 if (anItem->isSelected())
1497 aSelected.append(anItem->text());
1499 // sort & update list
1500 std::sort(anArray.begin(), anArray.end());
1502 myElements->clear();
1503 for (i = 0; i < k; i++) {
1504 myElements->insertItem(QString::number(anArray[i]));
1506 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1507 anItem = myElements->findItem(*it, Qt::ExactMatch);
1508 if (anItem) myElements->setSelected(anItem, true);
1514 //=================================================================================
1515 // function : closeEvent()
1517 //=================================================================================
1518 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1523 //=================================================================================
1524 // function : SMESHGUI_GroupDlg::onClose
1525 // purpose : SLOT called when "Close" button pressed. Close dialog
1526 //=================================================================================
1527 void SMESHGUI_GroupDlg::onClose()
1529 if (SMESH::GetCurrentVtkView()) {
1530 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1531 SMESH::SetPointRepresentation(false);
1532 SMESH::SetPickable();
1535 mySelectionMgr->clearSelected();
1536 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1537 aViewWindow->SetSelectionMode(ActorSelection);
1538 mySelectionMgr->clearFilters();
1539 mySMESHGUI->ResetState();
1544 //=================================================================================
1545 // function : SMESHGUI_GroupDlg::onDeactivate
1546 // purpose : SLOT called when dialog must be deativated
1547 //=================================================================================
1548 void SMESHGUI_GroupDlg::onDeactivate()
1550 mySMESHGUI->ResetState();
1554 //=================================================================================
1555 // function : SMESHGUI_GroupDlg::enterEvent
1556 // purpose : Event filter
1557 //=================================================================================
1558 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1561 mySMESHGUI->EmitSignalDeactivateDialog();
1563 mySelectionMode = -1;
1564 setSelectionMode(myTypeId);
1565 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1566 mySMESHGUI->SetActiveDialogBox(this);
1567 mySMESHGUI->SetState(800);
1571 //=================================================================================
1572 // function : hideEvent
1573 // purpose : caused by ESC key
1574 //=================================================================================
1575 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)