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 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
858 myMesh = SMESH::SMESH_Mesh::_nil();
862 Handle(SALOME_InteractiveObject) IO = aList.First();
865 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
866 if (myMesh->_is_nil())
871 myGroup = SMESH::SMESH_Group::_nil();
873 myActor = SMESH::FindActorByObject(myMesh);
874 SMESH::SetPickable(myActor);
876 aString = aList.First()->getName();
877 myMeshGroupLine->setText(aString) ;
878 myMeshGroupLine->home( false );
880 mySelectSubMesh->setEnabled(true);
881 mySelectGroup->setEnabled(true);
882 myGeomGroupBtn->setEnabled(true);
883 myGeomGroupLine->setEnabled(true);
886 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
887 if (aGroup->_is_nil())
893 myCurrentLineEdit = 0;
895 myGroup = SMESH::SMESH_Group::_nil();
896 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
900 mySelectSubMesh->setEnabled(true);
901 mySelectGroup->setEnabled(true);
903 myCurrentLineEdit = 0;
912 setSelectionMode(myTypeId);
918 } else if (myCurrentLineEdit == myGeomGroupLine) {
920 myGeomGroup = GEOM::GEOM_Object::_nil();
925 Standard_Boolean testResult = Standard_False;
926 myGeomGroup = GEOMBase::ConvertIOinGEOMObject(aList.First(), testResult);
928 // Check if the object is a geometry group
929 if (!testResult || CORBA::is_nil(myGeomGroup)) {
930 myGeomGroup = GEOM::GEOM_Object::_nil();
934 // Check if group constructed on the same shape as a mesh or on its child
935 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
936 GEOM::GEOM_IGroupOperations_var anOp =
937 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
939 // The main shape of the group
940 GEOM::GEOM_Object_var aGroupMainShape;
941 if (myGeomGroup->GetType() == 37)
942 aGroupMainShape = anOp->GetMainShape(myGeomGroup);
944 aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup);
945 _PTR(SObject) aGroupMainShapeSO =
946 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
947 aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
950 _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
952 myGeomGroup = GEOM::GEOM_Object::_nil();
956 _PTR(SObject) anObj, aRef;
957 bool isRefOrSubShape = false;
958 if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
959 //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
960 if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
961 isRefOrSubShape = true;
963 _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
964 _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
965 //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
966 while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
967 //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
968 if (aRef->GetID() == aFather->GetID())
969 isRefOrSubShape = true;
971 aFather = aFather->GetFather();
975 if (!isRefOrSubShape) {
976 myGeomGroup = GEOM::GEOM_Object::_nil();
984 if(myCurrentLineEdit == mySubMeshLine)
985 aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
986 else if(myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine)
987 aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
989 aString = aList.First()->getName();
993 myCurrentLineEdit->setText(aString);
994 myCurrentLineEdit->home(false);
999 if (aNbSel == 1 && myActor ) {
1000 QString aListStr = "";
1002 if (myTypeId == 0) {
1003 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1005 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1008 QStringList anElements = QStringList::split(" ", aListStr);
1009 QListBoxItem* anItem = 0;
1010 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1011 anItem = myElements->findItem(*it, Qt::ExactMatch);
1012 if (anItem) myElements->setSelected(anItem, true);
1019 if (!myGroup->_is_nil())
1020 myActor = SMESH::FindActorByObject(myGroup);
1021 else if(!myGroupOnGeom->_is_nil())
1022 myActor = SMESH::FindActorByObject(myGroupOnGeom);
1024 myActor = SMESH::FindActorByObject(myMesh);
1030 //=================================================================================
1031 // function : onSelectSubMesh()
1032 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1033 //=================================================================================
1034 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1037 if (mySelectGroup->isChecked()) {
1038 mySelectGroup->setChecked(false);
1040 //VSR: else if (mySelectGeomGroup->isChecked()) {
1041 //VSR: mySelectGeomGroup->setChecked(false);
1043 myCurrentLineEdit = mySubMeshLine;
1044 setSelectionMode(4);
1047 mySubMeshLine->setText("");
1048 myCurrentLineEdit = 0;
1050 setSelectionMode(myTypeId);
1052 mySubMeshBtn->setEnabled(on);
1053 mySubMeshLine->setEnabled(on);
1057 //=================================================================================
1058 // function : (onSelectGroup)
1059 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1060 //=================================================================================
1061 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1064 if (mySelectSubMesh->isChecked()) {
1065 mySelectSubMesh->setChecked(false);
1067 myCurrentLineEdit = myGroupLine;
1068 setSelectionMode(5);
1071 myGroupLine->setText("");
1072 myCurrentLineEdit = 0;
1074 setSelectionMode(myTypeId);
1076 myGroupBtn->setEnabled(on);
1077 myGroupLine->setEnabled(on);
1081 //=================================================================================
1082 // function : (onSelectGeomGroup)
1083 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1084 //=================================================================================
1085 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1088 if (mySelectSubMesh->isChecked()) {
1089 mySelectSubMesh->setChecked(false);
1091 else if (mySelectGroup->isChecked()) {
1092 mySelectGroup->setChecked(false);
1094 myCurrentLineEdit = myGeomGroupLine;
1095 setSelectionMode(7);
1098 myGeomGroupLine->setText("");
1099 myCurrentLineEdit = 0;
1101 setSelectionMode(myTypeId);
1105 //=================================================================================
1106 // function : (onSelectColorGroup)
1107 // purpose : Called when setting a color on group
1108 //=================================================================================
1109 void SMESHGUI_GroupDlg::onSelectColorGroup(bool on)
1112 setSelectionMode(7);
1115 myColorGroupLine->setText("");
1116 myCurrentLineEdit = 0;
1118 setSelectionMode(myTypeId);
1120 myColorGroupLine->setEnabled(on);
1123 //=================================================================================
1124 // function : setCurrentSelection()
1126 //=================================================================================
1127 void SMESHGUI_GroupDlg::setCurrentSelection()
1129 QPushButton* send = (QPushButton*)sender();
1130 myCurrentLineEdit = 0;
1131 if (send == myMeshGroupBtn) {
1132 myCurrentLineEdit = myMeshGroupLine;
1134 setSelectionMode(6);
1136 setSelectionMode(5);
1137 onObjectSelectionChanged();
1139 else if (send == mySubMeshBtn) {
1140 myCurrentLineEdit = mySubMeshLine;
1141 onObjectSelectionChanged();
1143 else if (send == myGroupBtn) {
1144 myCurrentLineEdit = myGroupLine;
1145 onObjectSelectionChanged();
1147 else if (send == myGeomGroupBtn) {
1148 myCurrentLineEdit = myGeomGroupLine;
1149 setSelectionMode(7);
1150 onObjectSelectionChanged();
1155 //=================================================================================
1156 // function : setFilters()
1157 // purpose : SLOT. Called when "Filter" button pressed.
1158 //=================================================================================
1159 void SMESHGUI_GroupDlg::setFilters()
1161 SMESH::ElementType aType = SMESH::ALL;
1164 case 0 : aType = SMESH::NODE; break;
1165 case 1 : aType = SMESH::EDGE; break;
1166 case 2 : aType = SMESH::FACE; break;
1167 case 3 : aType = SMESH::VOLUME; break;
1171 if ( myFilterDlg == 0 )
1173 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1174 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1177 myFilterDlg->Init( aType );
1179 myFilterDlg->SetSelection();
1180 myFilterDlg->SetMesh( myMesh );
1181 myFilterDlg->SetSourceWg( myElements );
1183 myFilterDlg->show();
1186 //=================================================================================
1187 // function : onFilterAccepted()
1188 // purpose : SLOT. Called when Filter dlg closed with OK button.
1189 // Uncheck "Select submesh" and "Select group" checkboxes
1190 //=================================================================================
1191 void SMESHGUI_GroupDlg::onFilterAccepted()
1193 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1195 mySelectionMode = myTypeId;
1196 mySelectSubMesh->setChecked( false );
1197 mySelectGroup->setChecked( false );
1201 //=================================================================================
1202 // function : onAdd()
1204 //=================================================================================
1205 void SMESHGUI_GroupDlg::onAdd()
1207 SALOME_ListIO aList;
1208 mySelectionMgr->selectedObjects( aList );
1210 int aNbSel = aList.Extent();
1212 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1216 SMESH::ElementType aType = SMESH::ALL;
1219 aType = SMESH::NODE;
1220 mySelector->SetSelectionMode(NodeSelection);
1223 aType = SMESH::EDGE;
1224 mySelector->SetSelectionMode(EdgeSelection);
1227 aType = SMESH::FACE;
1228 mySelector->SetSelectionMode(FaceSelection);
1231 aType = SMESH::VOLUME;
1232 mySelector->SetSelectionMode(VolumeSelection);
1235 mySelector->SetSelectionMode(ActorSelection);
1239 if (myCurrentLineEdit == 0) {
1240 //if (aNbSel != 1) { myIsBusy = false; return; }
1241 QString aListStr = "";
1243 if (myTypeId == 0) {
1244 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1247 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1250 QStringList anElements = QStringList::split(" ", aListStr);
1251 QListBoxItem* anItem = 0;
1252 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1253 anItem = myElements->findItem(*it, Qt::ExactMatch);
1255 anItem = new QListBoxText(*it);
1256 myElements->insertItem(anItem);
1258 myElements->setSelected(anItem, true);
1261 } else if (myCurrentLineEdit == mySubMeshLine) {
1262 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1264 SALOME_ListIO aList;
1265 mySelectionMgr->selectedObjects( aList );
1267 SALOME_ListIteratorOfListIO anIt (aList);
1268 for (; anIt.More(); anIt.Next()) {
1269 SMESH::SMESH_subMesh_var aSubMesh =
1270 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1271 if (!aSubMesh->_is_nil()) {
1272 // check if mesh is the same
1273 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1275 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1276 int k = anElements->length();
1277 QListBoxItem* anItem = 0;
1278 for (int i = 0; i < k; i++) {
1279 QString aText = QString::number(anElements[i]);
1280 anItem = myElements->findItem(aText, Qt::ExactMatch);
1282 anItem = new QListBoxText(aText);
1283 myElements->insertItem(anItem);
1285 myElements->setSelected(anItem, true);
1288 catch (const SALOME::SALOME_Exception& ex) {
1289 SalomeApp_Tools::QtCatchCorbaException(ex);
1294 mySelectSubMesh->setChecked(false);
1296 onListSelectionChanged();
1298 } else if (myCurrentLineEdit == myGroupLine) {
1299 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1300 SALOME_ListIO aList;
1301 mySelectionMgr->selectedObjects( aList );
1303 SALOME_ListIteratorOfListIO anIt (aList);
1304 for (; anIt.More(); anIt.Next()) {
1305 SMESH::SMESH_Group_var aGroup =
1306 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1307 if (!aGroup->_is_nil()) {
1308 // check if mesh is the same
1309 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1310 SMESH::long_array_var anElements = aGroup->GetListOfID();
1311 int k = anElements->length();
1312 QListBoxItem* anItem = 0;
1313 for (int i = 0; i < k; i++) {
1314 QString aText = QString::number(anElements[i]);
1315 anItem = myElements->findItem(aText, Qt::ExactMatch);
1317 anItem = new QListBoxText(aText);
1318 myElements->insertItem(anItem);
1320 myElements->setSelected(anItem, true);
1325 mySelectGroup->setChecked(false);
1327 onListSelectionChanged();
1329 } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) {
1330 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1331 GEOM::GEOM_IGroupOperations_var aGroupOp =
1332 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1334 SMESH::ElementType aGroupType = SMESH::ALL;
1335 switch(aGroupOp->GetType(myGeomGroup)) {
1336 case 7: aGroupType = SMESH::NODE; break;
1337 case 6: aGroupType = SMESH::EDGE; break;
1338 case 4: aGroupType = SMESH::FACE; break;
1339 case 2: aGroupType = SMESH::VOLUME; break;
1340 default: myIsBusy = false; return;
1343 if (aGroupType == aType) {
1344 _PTR(SObject) aGroupSO =
1345 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1346 aStudy->FindObjectID(myGeomGroup->GetStudyEntry());
1348 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1349 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1350 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1351 aBelongToGeom->SetGeom(myGeomGroup);
1352 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1353 aBelongToGeom->SetElementType(aType);
1354 aFilter->SetPredicate(aBelongToGeom);
1356 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1358 int k = anElements->length();
1359 QListBoxItem* anItem = 0;
1360 for (int i = 0; i < k; i++) {
1361 QString aText = QString::number(anElements[i]);
1362 anItem = myElements->findItem(aText, Qt::ExactMatch);
1364 anItem = new QListBoxText(aText);
1365 myElements->insertItem(anItem);
1367 myElements->setSelected(anItem, true);
1371 //VSR: mySelectGeomGroup->setChecked(false);
1373 onListSelectionChanged();
1376 // mySelectionMgr->clearSelected();
1380 //=================================================================================
1381 // function : onRemove()
1383 //=================================================================================
1384 void SMESHGUI_GroupDlg::onRemove()
1387 if (myCurrentLineEdit == 0) {
1388 for (int i = myElements->count(); i > 0; i--) {
1389 if (myElements->isSelected(i-1)) {
1390 myElements->removeItem(i-1);
1394 SALOME_ListIO aList;
1395 mySelectionMgr->selectedObjects( aList );
1397 int aNbSel = aList.Extent();
1399 if (aNbSel == 0) { myIsBusy = false; return; }
1401 SMESH::ElementType aType = SMESH::ALL;
1403 case 0: aType = SMESH::NODE; break;
1404 case 1: aType = SMESH::EDGE; break;
1405 case 2: aType = SMESH::FACE; break;
1406 case 3: aType = SMESH::VOLUME; break;
1409 if (myCurrentLineEdit == mySubMeshLine) {
1410 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1411 SALOME_ListIO aList;
1412 mySelectionMgr->selectedObjects( aList );
1414 SALOME_ListIteratorOfListIO anIt (aList);
1415 for (; anIt.More(); anIt.Next()) {
1416 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1417 if (!aSubMesh->_is_nil()) {
1418 // check if mesh is the same
1419 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1420 if (aType == SMESH::NODE) {
1422 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1423 int k = anElements->length();
1424 QListBoxItem* anItem = 0;
1425 for (int i = 0; i < k; i++) {
1426 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1427 if (anItem) delete anItem;
1430 catch (const SALOME::SALOME_Exception& ex) {
1431 SalomeApp_Tools::QtCatchCorbaException(ex);
1436 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1437 int k = anElements->length();
1438 QListBoxItem* anItem = 0;
1439 for (int i = 0; i < k; i++) {
1440 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1441 if (anItem) delete anItem;
1444 catch (const SALOME::SALOME_Exception& ex) {
1445 SalomeApp_Tools::QtCatchCorbaException(ex);
1452 else if (myCurrentLineEdit == myGroupLine) {
1453 Standard_Boolean aRes;
1454 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1455 SALOME_ListIO aList;
1456 mySelectionMgr->selectedObjects( aList );
1458 SALOME_ListIteratorOfListIO anIt (aList);
1459 for (; anIt.More(); anIt.Next()) {
1460 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1461 if (aRes && !aGroup->_is_nil()) {
1462 // check if mesh is the same
1463 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1464 SMESH::long_array_var anElements = aGroup->GetListOfID();
1465 int k = anElements->length();
1466 QListBoxItem* anItem = 0;
1467 for (int i = 0; i < k; i++) {
1468 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1469 if (anItem) delete anItem;
1480 //=================================================================================
1481 // function : onSort()
1483 //=================================================================================
1484 void SMESHGUI_GroupDlg::onSort()
1486 // PAL5412: sorts items in ascending by "string" value
1487 // myElements->sort(true);
1488 // myElements->update();
1489 int i, k = myElements->count();
1492 QStringList aSelected;
1493 std::vector<int> anArray(k);
1494 // QMemArray<int> anArray(k);
1495 QListBoxItem* anItem;
1497 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1498 anArray[i] = anItem->text().toInt();
1499 if (anItem->isSelected())
1500 aSelected.append(anItem->text());
1502 // sort & update list
1503 std::sort(anArray.begin(), anArray.end());
1505 myElements->clear();
1506 for (i = 0; i < k; i++) {
1507 myElements->insertItem(QString::number(anArray[i]));
1509 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1510 anItem = myElements->findItem(*it, Qt::ExactMatch);
1511 if (anItem) myElements->setSelected(anItem, true);
1517 //=================================================================================
1518 // function : closeEvent()
1520 //=================================================================================
1521 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1526 //=================================================================================
1527 // function : SMESHGUI_GroupDlg::onClose
1528 // purpose : SLOT called when "Close" button pressed. Close dialog
1529 //=================================================================================
1530 void SMESHGUI_GroupDlg::onClose()
1532 if (SMESH::GetCurrentVtkView()) {
1533 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1534 SMESH::SetPointRepresentation(false);
1535 SMESH::SetPickable();
1538 mySelectionMgr->clearSelected();
1539 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1540 aViewWindow->SetSelectionMode(ActorSelection);
1541 mySelectionMgr->clearFilters();
1542 mySMESHGUI->ResetState();
1547 //=================================================================================
1548 // function : SMESHGUI_GroupDlg::onDeactivate
1549 // purpose : SLOT called when dialog must be deativated
1550 //=================================================================================
1551 void SMESHGUI_GroupDlg::onDeactivate()
1553 mySMESHGUI->ResetState();
1557 //=================================================================================
1558 // function : SMESHGUI_GroupDlg::enterEvent
1559 // purpose : Event filter
1560 //=================================================================================
1561 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1564 mySMESHGUI->EmitSignalDeactivateDialog();
1566 mySelectionMode = -1;
1567 setSelectionMode(myTypeId);
1568 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1569 mySMESHGUI->SetActiveDialogBox(this);
1570 mySMESHGUI->SetState(800);
1574 //=================================================================================
1575 // function : hideEvent
1576 // purpose : caused by ESC key
1577 //=================================================================================
1578 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)