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"
46 #include "SUIT_Session.h"
47 #include "SUIT_MessageBox.h"
49 #include "SalomeApp_Tools.h"
50 #include "LightApp_Application.h"
51 #include "SALOMEDSClient_Study.hxx"
52 #include "SALOME_ListIO.hxx"
53 #include "SALOME_ListIteratorOfListIO.hxx"
55 #include "SVTK_ViewWindow.h"
56 #include "SVTK_Selector.h"
58 #include "utilities.h"
61 #include <TColStd_MapOfInteger.hxx>
64 #include <qbuttongroup.h>
65 #include <qgroupbox.h>
68 #include <qlineedit.h>
69 #include <qpushbutton.h>
70 #include <qradiobutton.h>
71 #include <qcheckbox.h>
76 #include <qmemarray.h>
77 #include <qwidgetstack.h>
79 #include <QtxIntSpinBox.h>
87 //=================================================================================
88 // function : SMESHGUI_GroupDlg()
90 //=================================================================================
91 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
92 SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl)
93 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
94 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
95 mySMESHGUI( theModule ),
96 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
97 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
101 if (!name) setName("SMESHGUI_GroupDlg");
103 if (!theMesh->_is_nil())
106 mySelectSubMesh->setEnabled(false);
107 mySelectGroup->setEnabled(false);
108 myGeomGroupBtn->setEnabled(false);
109 myGeomGroupLine->setEnabled(false);
113 //=================================================================================
114 // function : SMESHGUI_GroupDlg()
116 //=================================================================================
117 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
118 SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl)
119 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
120 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
121 mySMESHGUI( theModule ),
122 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
123 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
126 if (!name) setName("SMESHGUI_GroupDlg");
129 if (!theGroup->_is_nil())
132 mySelectSubMesh->setEnabled(false);
133 mySelectGroup->setEnabled(false);
135 myCurrentLineEdit = myMeshGroupLine;
140 //=================================================================================
141 // function : SMESHGUI_GroupDlg()
143 //=================================================================================
144 void SMESHGUI_GroupDlg::initDialog(bool create)
148 myCurrentLineEdit = 0;
150 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
153 setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
154 myHelpFileName = "/files/creating_groups.htm";
157 setCaption(tr("SMESH_EDIT_GROUP_TITLE"));
158 myHelpFileName = "/files/editing_groups.htm";
161 setSizeGripEnabled(TRUE);
163 QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6);
165 /***************************************************************/
166 QLabel* meshGroupLab = new QLabel(this, "mesh/group label");
168 meshGroupLab->setText(tr("SMESH_MESH"));
170 meshGroupLab->setText(tr("SMESH_GROUP"));
171 myMeshGroupBtn = new QPushButton(this, "mesh/group button");
172 myMeshGroupBtn->setPixmap(image0);
173 myMeshGroupLine = new QLineEdit(this, "mesh/group line");
174 myMeshGroupLine->setReadOnly(true);
176 /***************************************************************/
177 myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
178 myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
179 myTypeGroup->setExclusive(true);
182 types.append(tr("MESH_NODE"));
183 types.append(tr("SMESH_EDGE"));
184 types.append(tr("SMESH_FACE"));
185 types.append(tr("SMESH_VOLUME"));
187 for (int i = 0; i < types.count(); i++) {
188 rb = new QRadioButton(types[i], myTypeGroup);
190 myTypeGroup->setEnabled(create);
193 /***************************************************************/
194 QLabel* aName = new QLabel(this, "name label");
195 aName->setText(tr("SMESH_NAME"));
196 aName->setMinimumSize(50,0);
197 myName = new QLineEdit(this, "name");
199 /***************************************************************/
200 myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group");
201 myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE"));
202 myGrpTypeGroup->setExclusive(true);
203 QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup);
204 QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"), myGrpTypeGroup);
205 myGrpTypeGroup->setEnabled(create);
208 /***************************************************************/
209 myWGStack = new QWidgetStack( this, "widget stack");
210 QWidget* wg1 = new QFrame( myWGStack, "first widget" );
211 QWidget* wg2 = new QFrame( myWGStack, "second widget" );
213 /***************************************************************/
214 QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box");
215 aContentBox->setTitle(tr("SMESH_CONTENT"));
216 QFrame* aContent = new QFrame(aContentBox, "content");
217 QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
218 aLayout->setSpacing(6);
219 aLayout->setAutoAdd(false);
221 QLabel* aLabel = new QLabel(aContent, "elements label");
222 aLabel->setText(tr("SMESH_ID_ELEMENTS"));
223 myElements = new QListBox(aContent, "elements list");
224 myElements->setSelectionMode(QListBox::Extended);
226 myFilter = new QPushButton(aContent, "filter");
227 myFilter->setText(tr("SMESH_BUT_FILTER"));
228 QPushButton* aAddBtn = new QPushButton(aContent, "add");
229 aAddBtn->setText(tr("SMESH_BUT_ADD"));
230 QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
231 aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
232 QPushButton* aSortBtn = new QPushButton(aContent, "sort");
233 aSortBtn->setText(tr("SMESH_BUT_SORT"));
235 aLayout->addWidget(aLabel, 0, 0);
236 aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
237 aLayout->addWidget(myFilter, 1, 2);
238 aLayout->addWidget(aAddBtn, 3, 2);
239 aLayout->addWidget(aRemoveBtn, 4, 2);
240 aLayout->addWidget(aSortBtn, 6, 2);
242 aLayout->setColStretch(0, 1);
243 aLayout->addColSpacing(1, 20);
244 aLayout->addColSpacing(3, 20);
245 aLayout->setRowStretch(2, 1);
246 aLayout->setRowStretch(5, 1);
248 /***************************************************************/
249 QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box");
250 aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
252 mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
253 mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
254 mySelectSubMesh->setMinimumSize(50, 0);
255 mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
256 mySubMeshBtn->setText("");
257 mySubMeshBtn->setPixmap(image0);
258 mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
259 mySubMeshLine->setReadOnly(true);
260 onSelectSubMesh(false);
262 mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
263 mySelectGroup->setText(tr("SMESH_GROUP"));
264 mySelectGroup->setMinimumSize(50, 0);
265 myGroupBtn = new QPushButton(aSelectBox, "group button");
266 myGroupBtn->setText("");
267 myGroupBtn->setPixmap(image0);
268 myGroupLine = new QLineEdit(aSelectBox, "group line");
269 myGroupLine->setReadOnly(true);
270 onSelectGroup(false);
272 /***************************************************************/
273 QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
274 wg1Layout->addWidget(aContentBox, 0, 0);
275 wg1Layout->addWidget(aSelectBox, 1, 0);
276 wg1Layout->setRowStretch(2, 5);
278 /***************************************************************/
279 QLabel* geomObject = new QLabel(wg2, "geometry object label");
280 geomObject->setText(tr("SMESH_OBJECT_GEOM"));
281 myGeomGroupBtn = new QPushButton(wg2, "geometry group button");
282 myGeomGroupBtn->setText("");
283 myGeomGroupBtn->setPixmap(image0);
284 myGeomGroupLine = new QLineEdit(wg2, "geometry group line");
285 myGeomGroupLine->setReadOnly(true); //VSR ???
286 onSelectGeomGroup(false);
290 myGeomGroupBtn->setEnabled(false);
291 myGeomGroupLine->setEnabled(false);
294 /***************************************************************/
295 QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
296 wg2Layout->addWidget(geomObject, 0, 0);
297 wg2Layout->addWidget(myGeomGroupBtn, 0, 1);
298 wg2Layout->addWidget(myGeomGroupLine,0, 2);
299 wg2Layout->setRowStretch(1, 5);
301 /***************************************************************/
302 QVBoxLayout* dumb = new QVBoxLayout(myWGStack);
303 dumb->addWidget(wg1);
304 dumb->addWidget(wg2);
305 myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) );
306 myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
308 /***************************************************************/
309 QGroupBox* aColorBox = new QGroupBox(2, Qt::Horizontal, this, "color box");
310 aColorBox->setTitle(tr("SMESH_SET_COLOR"));
312 mySelectColorGroup = new QCheckBox(aColorBox, "color checkbox");
313 mySelectColorGroup->setText(tr("SMESH_CHECK_COLOR"));
315 myColorSpinBox = new QtxIntSpinBox( aColorBox );
316 myColorSpinBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
317 myColorSpinBox->setMinValue( 0 );
318 myColorSpinBox->setMaxValue( 9999 );
320 onSelectColorGroup(false);
322 /***************************************************************/
324 QFrame* aButtons = new QFrame(this, "button box");
325 aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
326 QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
327 aBtnLayout->setAutoAdd(false);
329 QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
330 aOKBtn->setText(tr("SMESH_BUT_OK"));
331 aOKBtn->setAutoDefault(true);
332 aOKBtn->setDefault(true);
333 QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
334 aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
335 aApplyBtn->setAutoDefault(true);
336 QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
337 aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
338 aCloseBtn->setAutoDefault(true);
339 QPushButton* aHelpBtn = new QPushButton(aButtons, "help");
340 aHelpBtn->setText(tr("SMESH_BUT_HELP"));
341 aHelpBtn->setAutoDefault(true);
343 aBtnLayout->addWidget(aOKBtn);
344 aBtnLayout->addWidget(aApplyBtn);
345 aBtnLayout->addStretch();
346 aBtnLayout->addWidget(aCloseBtn);
347 aBtnLayout->addWidget(aHelpBtn);
349 /***************************************************************/
350 aMainLayout->addWidget(meshGroupLab, 0, 0);
351 aMainLayout->addWidget(myMeshGroupBtn, 0, 1);
352 aMainLayout->addWidget(myMeshGroupLine, 0, 2);
353 aMainLayout->addMultiCellWidget(myTypeGroup, 1, 1, 0, 2);
354 aMainLayout->addWidget(aName, 2, 0);
355 aMainLayout->addWidget(myName, 2, 2);
356 aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
357 aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2);
358 aMainLayout->setRowStretch( 5, 5 );
359 aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2);
360 aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2);
362 /* signals and slots connections */
363 connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
365 connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int)));
367 connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
369 connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
370 connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
372 connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
373 connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
374 connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
375 connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
377 connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
378 connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
379 connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
380 connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
381 connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
382 connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool)));
383 connect(myColorSpinBox, SIGNAL(valueChanged(const QString&)), this, SLOT(onNbColorsChanged(const QString&)));
385 connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
386 connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
387 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
388 connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
391 mySMESHGUI->SetActiveDialogBox(this);
392 mySMESHGUI->SetState(800);
394 mySelectionMode = -1;
395 myMeshFilter = new SMESH_TypeFilter(MESH);
396 mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
397 myGroupFilter = new SMESH_TypeFilter(GROUP);
399 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
400 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
401 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
403 myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
404 onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
406 if (myMesh->_is_nil() )
407 myTypeGroup->setButton(0);
412 //=================================================================================
413 // function : ~SMESHGUI_GroupDlg()
414 // purpose : Destroys the object and frees any allocated resources
415 //=================================================================================
416 SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
418 // no need to delete child widgets, Qt does it all for us
419 if ( myFilterDlg != 0 )
421 myFilterDlg->reparent( 0, QPoint() );
426 //=================================================================================
429 //=================================================================================
430 void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
432 mySelectionMgr->installFilter(myMeshFilter);
434 /* init data from current selection */
435 myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
436 myGroup = SMESH::SMESH_Group::_nil();
437 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
439 myActor = SMESH::FindActorByObject(myMesh);
440 SMESH::SetPickable(myActor);
443 mySelectionMgr->selectedObjects( aList );
444 if( !aList.IsEmpty() )
446 QString aName = aList.First()->getName();
447 myMeshGroupLine->setText(aName) ;
448 myMeshGroupLine->home( false );
451 myCurrentLineEdit = 0;
453 myTypeGroup->setButton(0);
457 //=================================================================================
460 //=================================================================================
461 void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
463 myMesh = theGroup->GetMesh();
465 myName->setText(theGroup->GetName());
468 myColorSpinBox->setValue( theGroup->GetColorNumber() );
470 myMeshGroupLine->setText(theGroup->GetName());
473 switch(theGroup->GetType()) {
474 case SMESH::NODE: aType= 0; break;
475 case SMESH::EDGE: aType = 1; break;
476 case SMESH::FACE: aType = 2; break;
477 case SMESH::VOLUME: aType = 3; break;
479 myTypeGroup->setButton(aType);
481 myGroup = SMESH::SMESH_Group::_narrow( theGroup );
483 if ( !myGroup->_is_nil() )
485 myGrpTypeGroup->setButton(0);
488 myActor = SMESH::FindActorByObject(myMesh);
490 myActor = SMESH::FindActorByObject(myGroup);
491 SMESH::SetPickable(myActor);
493 myCurrentLineEdit = 0;
495 setSelectionMode(aType);
499 if (!myGroup->IsEmpty()) {
500 SMESH::long_array_var anElements = myGroup->GetListOfID();
501 int k = anElements->length();
502 for (int i = 0; i < k; i++) {
503 myIdList.append(anElements[i]);
504 myElements->insertItem(QString::number(anElements[i]));
506 myElements->selectAll(true);
511 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
513 if ( !myGroupOnGeom->_is_nil() )
515 myGrpTypeGroup->setButton(1);
518 myActor = SMESH::FindActorByObject(myMesh);
520 myActor = SMESH::FindActorByObject(myGroup);
521 SMESH::SetPickable(myActor);
523 QString aShapeName("");
524 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
525 GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
526 if (!aGroupShape->_is_nil())
528 _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
529 aShapeName = aGroupShapeSO->GetName().c_str();
531 myGeomGroupLine->setText( aShapeName );
536 //=================================================================================
537 // function : updateButtons()
539 //=================================================================================
540 void SMESHGUI_GroupDlg::updateButtons()
544 if (myGrpTypeId == 0)
545 enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0;
546 else if (myGrpTypeId == 1)
548 bool isEditMode = !CORBA::is_nil( myGroupOnGeom );
549 enable = !myName->text().stripWhiteSpace().isEmpty() && (!CORBA::is_nil( myGeomGroup ) || isEditMode);
552 aBtn = (QPushButton*) child("ok", "QPushButton");
553 if (aBtn) aBtn->setEnabled(enable);
554 aBtn = (QPushButton*) child("apply", "QPushButton");
555 if (aBtn) aBtn->setEnabled(enable);
558 //=================================================================================
559 // function : onNameChanged()
561 //=================================================================================
562 void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
567 //=================================================================================
568 // function : onNbColorsChanged()
570 //=================================================================================
571 void SMESHGUI_GroupDlg::onNbColorsChanged (const QString& text)
576 //=================================================================================
577 // function : onTypeChanged()
578 // purpose : Group elements type radio button management
579 //=================================================================================
580 void SMESHGUI_GroupDlg::onTypeChanged (int id)
582 if (myTypeId != id) {
584 if (myCurrentLineEdit == 0)
585 setSelectionMode(id);
590 //=================================================================================
591 // function : onGrpTypeChanged()
592 // purpose : Group type radio button management
593 //=================================================================================
594 void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
596 if (myGrpTypeId != id) {
597 myWGStack->raiseWidget( id );
598 onSelectGeomGroup(id == 1);
603 //=================================================================================
604 // function : setSelectionMode()
605 // purpose : Radio button management
606 //=================================================================================
607 void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
610 if (myMesh->_is_nil())
613 if (mySelectionMode != theMode) {
614 // [PAL10408] mySelectionMgr->clearSelected();
615 mySelectionMgr->clearFilters();
616 SMESH::SetPointRepresentation(false);
621 myActor->SetPointRepresentation(true);
623 SMESH::SetPointRepresentation(true);
624 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
625 aViewWindow->SetSelectionMode(NodeSelection);
628 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
629 aViewWindow->SetSelectionMode(EdgeSelection);
632 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
633 aViewWindow->SetSelectionMode(FaceSelection);
636 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
637 aViewWindow->SetSelectionMode(VolumeSelection);
641 mySelectionMgr->installFilter(mySubMeshFilter);
642 else if (theMode == 5)
643 mySelectionMgr->installFilter(myGroupFilter);
644 else if (theMode == 6)
645 mySelectionMgr->installFilter(myMeshFilter);
646 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
647 aViewWindow->SetSelectionMode(ActorSelection);
649 mySelectionMode = theMode;
653 //=================================================================================
654 // function : onApply()
656 //=================================================================================
657 bool SMESHGUI_GroupDlg::onApply()
659 if (mySMESHGUI->isActiveStudyLocked())
662 if (myGrpTypeId == 0 &&
663 !myName->text().stripWhiteSpace().isEmpty() &&
664 myElements->count() > 0) {
665 mySelectionMgr->clearSelected();
666 if (myGroup->_is_nil()) {
667 SMESH::ElementType aType = SMESH::ALL;
669 case 0: aType = SMESH::NODE; break;
670 case 1: aType = SMESH::EDGE; break;
671 case 2: aType = SMESH::FACE; break;
672 case 3: aType = SMESH::VOLUME; break;
674 SMESH::long_array_var anIdList = new SMESH::long_array;
675 int i, k = myElements->count();
677 QListBoxItem* anItem;
678 for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
679 anIdList[i] = anItem->text().toInt();
682 myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
683 myGroup->Add(anIdList.inout());
685 int aColorNumber = myColorSpinBox->value();
686 myGroup->SetColorNumber(aColorNumber);
688 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
690 SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
692 SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
694 /* init for next operation */
696 myColorSpinBox->setValue(0);
698 myGroup = SMESH::SMESH_Group::_nil();
701 myGroup->SetName(myName->text());
703 int aColorNumber = myColorSpinBox->value();
704 myGroup->SetColorNumber(aColorNumber);
706 QValueList<int> aAddList;
707 QValueList<int>::iterator anIt;
708 QListBoxItem* anItem;
710 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
711 int anId = anItem->text().toInt();
712 if ((anIt = myIdList.find(anId)) == myIdList.end())
713 aAddList.append(anId);
715 myIdList.remove(anIt);
717 if (!aAddList.empty()) {
718 SMESH::long_array_var anIdList = new SMESH::long_array;
719 anIdList->length(aAddList.count());
721 for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
723 myGroup->Add(anIdList.inout());
725 if (!myIdList.empty()) {
726 SMESH::long_array_var anIdList = new SMESH::long_array;
727 anIdList->length(myIdList.count());
729 for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
731 myGroup->Remove(anIdList.inout());
733 /* init for next operation */
735 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
736 myIdList.append(anItem->text().toInt());
739 mySMESHGUI->updateObjBrowser(true);
740 SMESH::UpdateView(); // asv: fix of BUG PAL5515
741 mySelectionMgr->clearSelected();
743 } else if (myGrpTypeId == 1 &&
744 !myName->text().stripWhiteSpace().isEmpty() &&
745 (!CORBA::is_nil(myGeomGroup) || !CORBA::is_nil(myGroupOnGeom)))
747 if (myGroupOnGeom->_is_nil()) {
748 SMESH::ElementType aType = SMESH::ALL;
750 case 0: aType = SMESH::NODE; break;
751 case 1: aType = SMESH::EDGE; break;
752 case 2: aType = SMESH::FACE; break;
753 case 3: aType = SMESH::VOLUME; break;
756 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
757 GEOM::GEOM_IGroupOperations_var aGroupOp =
758 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
760 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup);
762 int aColorNumber = myColorSpinBox->value();
763 myGroupOnGeom->SetColorNumber(aColorNumber);
765 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
767 SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
769 SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
771 /* init for next operation */
773 myColorSpinBox->setValue(0);
774 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
778 myGroupOnGeom->SetName(myName->text());
780 int aColorNumber = myColorSpinBox->value();
781 myGroupOnGeom->SetColorNumber(aColorNumber);
784 mySMESHGUI->updateObjBrowser(true);
785 mySelectionMgr->clearSelected();
792 //=================================================================================
795 //=================================================================================
796 void SMESHGUI_GroupDlg::onOK()
802 //=================================================================================
803 // function : onListSelectionChanged()
804 // purpose : Called when selection in element list is changed
805 //=================================================================================
806 void SMESHGUI_GroupDlg::onListSelectionChanged()
808 // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
809 if( myIsBusy || !myActor) return;
812 if (myCurrentLineEdit == 0) {
813 mySelectionMgr->clearSelected();
814 TColStd_MapOfInteger aIndexes;
815 QListBoxItem* anItem;
816 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
817 if (anItem->isSelected()) {
818 int anId = anItem->text().toInt();
822 mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
824 aList.Append(myActor->getIO());
825 mySelectionMgr->setSelectedObjects(aList,false);
830 //=================================================================================
831 // function : onObjectSelectionChanged()
832 // purpose : Called when selection in 3D view or ObjectBrowser is changed
833 //=================================================================================
834 void SMESHGUI_GroupDlg::onObjectSelectionChanged()
836 if ( myIsBusy || !isEnabled()) return;
840 mySelectionMgr->selectedObjects( aList );
842 int aNbSel = aList.Extent();
843 myElements->clearSelection();
845 if (myCurrentLineEdit) {
846 myCurrentLineEdit->setText("");
847 QString aString = "";
849 if (myCurrentLineEdit == myMeshGroupLine) {
850 mySelectSubMesh->setEnabled(false);
851 mySelectGroup->setEnabled(false);
852 myGroupLine->setText("");
853 mySubMeshLine->setText("");
855 myGeomGroupBtn->setEnabled(false);
856 myGeomGroupLine->setEnabled(false);
857 myGeomGroupLine->setText("");
864 myGroup = SMESH::SMESH_Group::_nil();
865 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
866 myMesh = SMESH::SMESH_Mesh::_nil();
870 Handle(SALOME_InteractiveObject) IO = aList.First();
873 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
874 if (myMesh->_is_nil())
879 myGroup = SMESH::SMESH_Group::_nil();
881 myActor = SMESH::FindActorByObject(myMesh);
882 SMESH::SetPickable(myActor);
884 aString = aList.First()->getName();
885 myMeshGroupLine->setText(aString) ;
886 myMeshGroupLine->home( false );
888 mySelectSubMesh->setEnabled(true);
889 mySelectGroup->setEnabled(true);
890 myGeomGroupBtn->setEnabled(true);
891 myGeomGroupLine->setEnabled(true);
894 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
895 if (aGroup->_is_nil())
901 myCurrentLineEdit = 0;
903 myGroup = SMESH::SMESH_Group::_nil();
904 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
908 mySelectSubMesh->setEnabled(true);
909 mySelectGroup->setEnabled(true);
911 myCurrentLineEdit = 0;
920 setSelectionMode(myTypeId);
926 } else if (myCurrentLineEdit == myGeomGroupLine) {
928 myGeomGroup = GEOM::GEOM_Object::_nil();
933 Standard_Boolean testResult = Standard_False;
934 myGeomGroup = GEOMBase::ConvertIOinGEOMObject(aList.First(), testResult);
936 // Check if the object is a geometry group
937 if (!testResult || CORBA::is_nil(myGeomGroup)) {
938 myGeomGroup = GEOM::GEOM_Object::_nil();
942 // Check if group constructed on the same shape as a mesh or on its child
943 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
944 GEOM::GEOM_IGroupOperations_var anOp =
945 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
947 // The main shape of the group
948 GEOM::GEOM_Object_var aGroupMainShape;
949 if (myGeomGroup->GetType() == 37)
950 aGroupMainShape = anOp->GetMainShape(myGeomGroup);
952 aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup);
953 _PTR(SObject) aGroupMainShapeSO =
954 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
955 aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
958 _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
960 myGeomGroup = GEOM::GEOM_Object::_nil();
964 _PTR(SObject) anObj, aRef;
965 bool isRefOrSubShape = false;
966 if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
967 //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
968 if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
969 isRefOrSubShape = true;
971 _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
972 _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
973 //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
974 while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
975 //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
976 if (aRef->GetID() == aFather->GetID())
977 isRefOrSubShape = true;
979 aFather = aFather->GetFather();
983 if (!isRefOrSubShape) {
984 myGeomGroup = GEOM::GEOM_Object::_nil();
992 if(myCurrentLineEdit == mySubMeshLine)
993 aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
994 else if(myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine)
995 aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
997 aString = aList.First()->getName();
1001 myCurrentLineEdit->setText(aString);
1002 myCurrentLineEdit->home(false);
1007 if (aNbSel == 1 && myActor ) {
1008 QString aListStr = "";
1010 if (myTypeId == 0) {
1011 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1013 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1016 QStringList anElements = QStringList::split(" ", aListStr);
1017 QListBoxItem* anItem = 0;
1018 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1019 anItem = myElements->findItem(*it, Qt::ExactMatch);
1020 if (anItem) myElements->setSelected(anItem, true);
1027 if (!myGroup->_is_nil())
1028 myActor = SMESH::FindActorByObject(myGroup);
1029 else if(!myGroupOnGeom->_is_nil())
1030 myActor = SMESH::FindActorByObject(myGroupOnGeom);
1032 myActor = SMESH::FindActorByObject(myMesh);
1038 //=================================================================================
1039 // function : onSelectSubMesh()
1040 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1041 //=================================================================================
1042 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1045 if (mySelectGroup->isChecked()) {
1046 mySelectGroup->setChecked(false);
1048 //VSR: else if (mySelectGeomGroup->isChecked()) {
1049 //VSR: mySelectGeomGroup->setChecked(false);
1051 myCurrentLineEdit = mySubMeshLine;
1052 setSelectionMode(4);
1055 mySubMeshLine->setText("");
1056 myCurrentLineEdit = 0;
1058 setSelectionMode(myTypeId);
1060 mySubMeshBtn->setEnabled(on);
1061 mySubMeshLine->setEnabled(on);
1065 //=================================================================================
1066 // function : (onSelectGroup)
1067 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1068 //=================================================================================
1069 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1072 if (mySelectSubMesh->isChecked()) {
1073 mySelectSubMesh->setChecked(false);
1075 myCurrentLineEdit = myGroupLine;
1076 setSelectionMode(5);
1079 myGroupLine->setText("");
1080 myCurrentLineEdit = 0;
1082 setSelectionMode(myTypeId);
1084 myGroupBtn->setEnabled(on);
1085 myGroupLine->setEnabled(on);
1089 //=================================================================================
1090 // function : (onSelectGeomGroup)
1091 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1092 //=================================================================================
1093 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1096 if (mySelectSubMesh->isChecked()) {
1097 mySelectSubMesh->setChecked(false);
1099 else if (mySelectGroup->isChecked()) {
1100 mySelectGroup->setChecked(false);
1102 myCurrentLineEdit = myGeomGroupLine;
1103 setSelectionMode(7);
1106 myGeomGroupLine->setText("");
1107 myCurrentLineEdit = 0;
1109 setSelectionMode(myTypeId);
1113 //=================================================================================
1114 // function : (onSelectColorGroup)
1115 // purpose : Called when setting a color on group
1116 //=================================================================================
1117 void SMESHGUI_GroupDlg::onSelectColorGroup(bool on)
1120 setSelectionMode(7);
1123 myColorSpinBox->setValue(0);
1124 myCurrentLineEdit = 0;
1126 setSelectionMode(myTypeId);
1128 myColorSpinBox->setEnabled(on);
1131 //=================================================================================
1132 // function : setCurrentSelection()
1134 //=================================================================================
1135 void SMESHGUI_GroupDlg::setCurrentSelection()
1137 QPushButton* send = (QPushButton*)sender();
1138 myCurrentLineEdit = 0;
1139 if (send == myMeshGroupBtn) {
1140 myCurrentLineEdit = myMeshGroupLine;
1142 setSelectionMode(6);
1144 setSelectionMode(5);
1145 onObjectSelectionChanged();
1147 else if (send == mySubMeshBtn) {
1148 myCurrentLineEdit = mySubMeshLine;
1149 onObjectSelectionChanged();
1151 else if (send == myGroupBtn) {
1152 myCurrentLineEdit = myGroupLine;
1153 onObjectSelectionChanged();
1155 else if (send == myGeomGroupBtn) {
1156 myCurrentLineEdit = myGeomGroupLine;
1157 setSelectionMode(7);
1158 onObjectSelectionChanged();
1163 //=================================================================================
1164 // function : setFilters()
1165 // purpose : SLOT. Called when "Filter" button pressed.
1166 //=================================================================================
1167 void SMESHGUI_GroupDlg::setFilters()
1169 SMESH::ElementType aType = SMESH::ALL;
1172 case 0 : aType = SMESH::NODE; break;
1173 case 1 : aType = SMESH::EDGE; break;
1174 case 2 : aType = SMESH::FACE; break;
1175 case 3 : aType = SMESH::VOLUME; break;
1179 if ( myFilterDlg == 0 )
1181 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1182 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1185 myFilterDlg->Init( aType );
1187 myFilterDlg->SetSelection();
1188 myFilterDlg->SetMesh( myMesh );
1189 myFilterDlg->SetSourceWg( myElements );
1191 myFilterDlg->show();
1194 //=================================================================================
1195 // function : onFilterAccepted()
1196 // purpose : SLOT. Called when Filter dlg closed with OK button.
1197 // Uncheck "Select submesh" and "Select group" checkboxes
1198 //=================================================================================
1199 void SMESHGUI_GroupDlg::onFilterAccepted()
1201 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1203 mySelectionMode = myTypeId;
1204 mySelectSubMesh->setChecked( false );
1205 mySelectGroup->setChecked( false );
1209 //=================================================================================
1210 // function : onAdd()
1212 //=================================================================================
1213 void SMESHGUI_GroupDlg::onAdd()
1215 SALOME_ListIO aList;
1216 mySelectionMgr->selectedObjects( aList );
1218 int aNbSel = aList.Extent();
1220 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1224 SMESH::ElementType aType = SMESH::ALL;
1227 aType = SMESH::NODE;
1228 mySelector->SetSelectionMode(NodeSelection);
1231 aType = SMESH::EDGE;
1232 mySelector->SetSelectionMode(EdgeSelection);
1235 aType = SMESH::FACE;
1236 mySelector->SetSelectionMode(FaceSelection);
1239 aType = SMESH::VOLUME;
1240 mySelector->SetSelectionMode(VolumeSelection);
1243 mySelector->SetSelectionMode(ActorSelection);
1247 if (myCurrentLineEdit == 0) {
1248 //if (aNbSel != 1) { myIsBusy = false; return; }
1249 QString aListStr = "";
1251 if (myTypeId == 0) {
1252 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1255 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1258 QStringList anElements = QStringList::split(" ", aListStr);
1259 QListBoxItem* anItem = 0;
1260 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1261 anItem = myElements->findItem(*it, Qt::ExactMatch);
1263 anItem = new QListBoxText(*it);
1264 myElements->insertItem(anItem);
1266 myElements->setSelected(anItem, true);
1269 } else if (myCurrentLineEdit == mySubMeshLine) {
1270 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1272 SALOME_ListIO aList;
1273 mySelectionMgr->selectedObjects( aList );
1275 SALOME_ListIteratorOfListIO anIt (aList);
1276 for (; anIt.More(); anIt.Next()) {
1277 SMESH::SMESH_subMesh_var aSubMesh =
1278 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1279 if (!aSubMesh->_is_nil()) {
1280 // check if mesh is the same
1281 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1283 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1284 int k = anElements->length();
1285 QListBoxItem* anItem = 0;
1286 for (int i = 0; i < k; i++) {
1287 QString aText = QString::number(anElements[i]);
1288 anItem = myElements->findItem(aText, Qt::ExactMatch);
1290 anItem = new QListBoxText(aText);
1291 myElements->insertItem(anItem);
1293 myElements->setSelected(anItem, true);
1296 catch (const SALOME::SALOME_Exception& ex) {
1297 SalomeApp_Tools::QtCatchCorbaException(ex);
1302 mySelectSubMesh->setChecked(false);
1304 onListSelectionChanged();
1306 } else if (myCurrentLineEdit == myGroupLine) {
1307 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1308 SALOME_ListIO aList;
1309 mySelectionMgr->selectedObjects( aList );
1311 SALOME_ListIteratorOfListIO anIt (aList);
1312 for (; anIt.More(); anIt.Next()) {
1313 SMESH::SMESH_Group_var aGroup =
1314 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1315 if (!aGroup->_is_nil()) {
1316 // check if mesh is the same
1317 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1318 SMESH::long_array_var anElements = aGroup->GetListOfID();
1319 int k = anElements->length();
1320 QListBoxItem* anItem = 0;
1321 for (int i = 0; i < k; i++) {
1322 QString aText = QString::number(anElements[i]);
1323 anItem = myElements->findItem(aText, Qt::ExactMatch);
1325 anItem = new QListBoxText(aText);
1326 myElements->insertItem(anItem);
1328 myElements->setSelected(anItem, true);
1333 mySelectGroup->setChecked(false);
1335 onListSelectionChanged();
1337 } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) {
1338 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1339 GEOM::GEOM_IGroupOperations_var aGroupOp =
1340 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1342 SMESH::ElementType aGroupType = SMESH::ALL;
1343 switch(aGroupOp->GetType(myGeomGroup)) {
1344 case 7: aGroupType = SMESH::NODE; break;
1345 case 6: aGroupType = SMESH::EDGE; break;
1346 case 4: aGroupType = SMESH::FACE; break;
1347 case 2: aGroupType = SMESH::VOLUME; break;
1348 default: myIsBusy = false; return;
1351 if (aGroupType == aType) {
1352 _PTR(SObject) aGroupSO =
1353 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1354 aStudy->FindObjectID(myGeomGroup->GetStudyEntry());
1356 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1357 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1358 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1359 aBelongToGeom->SetGeom(myGeomGroup);
1360 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1361 aBelongToGeom->SetElementType(aType);
1362 aFilter->SetPredicate(aBelongToGeom);
1364 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1366 int k = anElements->length();
1367 QListBoxItem* anItem = 0;
1368 for (int i = 0; i < k; i++) {
1369 QString aText = QString::number(anElements[i]);
1370 anItem = myElements->findItem(aText, Qt::ExactMatch);
1372 anItem = new QListBoxText(aText);
1373 myElements->insertItem(anItem);
1375 myElements->setSelected(anItem, true);
1379 //VSR: mySelectGeomGroup->setChecked(false);
1381 onListSelectionChanged();
1384 // mySelectionMgr->clearSelected();
1388 //=================================================================================
1389 // function : onRemove()
1391 //=================================================================================
1392 void SMESHGUI_GroupDlg::onRemove()
1395 if (myCurrentLineEdit == 0) {
1396 for (int i = myElements->count(); i > 0; i--) {
1397 if (myElements->isSelected(i-1)) {
1398 myElements->removeItem(i-1);
1402 SALOME_ListIO aList;
1403 mySelectionMgr->selectedObjects( aList );
1405 int aNbSel = aList.Extent();
1407 if (aNbSel == 0) { myIsBusy = false; return; }
1409 SMESH::ElementType aType = SMESH::ALL;
1411 case 0: aType = SMESH::NODE; break;
1412 case 1: aType = SMESH::EDGE; break;
1413 case 2: aType = SMESH::FACE; break;
1414 case 3: aType = SMESH::VOLUME; break;
1417 if (myCurrentLineEdit == mySubMeshLine) {
1418 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1419 SALOME_ListIO aList;
1420 mySelectionMgr->selectedObjects( aList );
1422 SALOME_ListIteratorOfListIO anIt (aList);
1423 for (; anIt.More(); anIt.Next()) {
1424 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1425 if (!aSubMesh->_is_nil()) {
1426 // check if mesh is the same
1427 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1428 if (aType == SMESH::NODE) {
1430 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1431 int k = anElements->length();
1432 QListBoxItem* anItem = 0;
1433 for (int i = 0; i < k; i++) {
1434 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1435 if (anItem) delete anItem;
1438 catch (const SALOME::SALOME_Exception& ex) {
1439 SalomeApp_Tools::QtCatchCorbaException(ex);
1444 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1445 int k = anElements->length();
1446 QListBoxItem* anItem = 0;
1447 for (int i = 0; i < k; i++) {
1448 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1449 if (anItem) delete anItem;
1452 catch (const SALOME::SALOME_Exception& ex) {
1453 SalomeApp_Tools::QtCatchCorbaException(ex);
1460 else if (myCurrentLineEdit == myGroupLine) {
1461 Standard_Boolean aRes;
1462 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1463 SALOME_ListIO aList;
1464 mySelectionMgr->selectedObjects( aList );
1466 SALOME_ListIteratorOfListIO anIt (aList);
1467 for (; anIt.More(); anIt.Next()) {
1468 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1469 if (aRes && !aGroup->_is_nil()) {
1470 // check if mesh is the same
1471 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1472 SMESH::long_array_var anElements = aGroup->GetListOfID();
1473 int k = anElements->length();
1474 QListBoxItem* anItem = 0;
1475 for (int i = 0; i < k; i++) {
1476 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1477 if (anItem) delete anItem;
1488 //=================================================================================
1489 // function : onSort()
1491 //=================================================================================
1492 void SMESHGUI_GroupDlg::onSort()
1494 // PAL5412: sorts items in ascending by "string" value
1495 // myElements->sort(true);
1496 // myElements->update();
1497 int i, k = myElements->count();
1500 QStringList aSelected;
1501 std::vector<int> anArray(k);
1502 // QMemArray<int> anArray(k);
1503 QListBoxItem* anItem;
1505 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1506 anArray[i] = anItem->text().toInt();
1507 if (anItem->isSelected())
1508 aSelected.append(anItem->text());
1510 // sort & update list
1511 std::sort(anArray.begin(), anArray.end());
1513 myElements->clear();
1514 for (i = 0; i < k; i++) {
1515 myElements->insertItem(QString::number(anArray[i]));
1517 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1518 anItem = myElements->findItem(*it, Qt::ExactMatch);
1519 if (anItem) myElements->setSelected(anItem, true);
1525 //=================================================================================
1526 // function : closeEvent()
1528 //=================================================================================
1529 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1534 //=================================================================================
1535 // function : SMESHGUI_GroupDlg::onClose
1536 // purpose : SLOT called when "Close" button pressed. Close dialog
1537 //=================================================================================
1538 void SMESHGUI_GroupDlg::onClose()
1540 if (SMESH::GetCurrentVtkView()) {
1541 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1542 SMESH::SetPointRepresentation(false);
1543 SMESH::SetPickable();
1546 mySelectionMgr->clearSelected();
1547 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1548 aViewWindow->SetSelectionMode(ActorSelection);
1549 mySelectionMgr->clearFilters();
1550 mySMESHGUI->ResetState();
1555 //=================================================================================
1556 // function : onHelp()
1558 //=================================================================================
1559 void SMESHGUI_GroupDlg::onHelp()
1561 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1563 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
1565 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
1566 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1567 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
1568 QObject::tr("BUT_OK"));
1572 //=================================================================================
1573 // function : SMESHGUI_GroupDlg::onDeactivate
1574 // purpose : SLOT called when dialog must be deativated
1575 //=================================================================================
1576 void SMESHGUI_GroupDlg::onDeactivate()
1578 mySMESHGUI->ResetState();
1582 //=================================================================================
1583 // function : SMESHGUI_GroupDlg::enterEvent
1584 // purpose : Event filter
1585 //=================================================================================
1586 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1589 mySMESHGUI->EmitSignalDeactivateDialog();
1591 mySelectionMode = -1;
1592 setSelectionMode(myTypeId);
1593 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1594 mySMESHGUI->SetActiveDialogBox(this);
1595 mySMESHGUI->SetState(800);
1599 //=================================================================================
1600 // function : hideEvent
1601 // purpose : caused by ESC key
1602 //=================================================================================
1603 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)