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 myColorSpinBox->setValue(0);
1122 myColorSpinBox->setEnabled(on);
1125 //=================================================================================
1126 // function : setCurrentSelection()
1128 //=================================================================================
1129 void SMESHGUI_GroupDlg::setCurrentSelection()
1131 QPushButton* send = (QPushButton*)sender();
1132 myCurrentLineEdit = 0;
1133 if (send == myMeshGroupBtn) {
1134 myCurrentLineEdit = myMeshGroupLine;
1136 setSelectionMode(6);
1138 setSelectionMode(5);
1139 onObjectSelectionChanged();
1141 else if (send == mySubMeshBtn) {
1142 myCurrentLineEdit = mySubMeshLine;
1143 onObjectSelectionChanged();
1145 else if (send == myGroupBtn) {
1146 myCurrentLineEdit = myGroupLine;
1147 onObjectSelectionChanged();
1149 else if (send == myGeomGroupBtn) {
1150 myCurrentLineEdit = myGeomGroupLine;
1151 setSelectionMode(7);
1152 onObjectSelectionChanged();
1157 //=================================================================================
1158 // function : setFilters()
1159 // purpose : SLOT. Called when "Filter" button pressed.
1160 //=================================================================================
1161 void SMESHGUI_GroupDlg::setFilters()
1163 SMESH::ElementType aType = SMESH::ALL;
1166 case 0 : aType = SMESH::NODE; break;
1167 case 1 : aType = SMESH::EDGE; break;
1168 case 2 : aType = SMESH::FACE; break;
1169 case 3 : aType = SMESH::VOLUME; break;
1173 if ( myFilterDlg == 0 )
1175 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1176 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1179 myFilterDlg->Init( aType );
1181 myFilterDlg->SetSelection();
1182 myFilterDlg->SetMesh( myMesh );
1183 myFilterDlg->SetSourceWg( myElements );
1185 myFilterDlg->show();
1188 //=================================================================================
1189 // function : onFilterAccepted()
1190 // purpose : SLOT. Called when Filter dlg closed with OK button.
1191 // Uncheck "Select submesh" and "Select group" checkboxes
1192 //=================================================================================
1193 void SMESHGUI_GroupDlg::onFilterAccepted()
1195 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1197 mySelectionMode = myTypeId;
1198 mySelectSubMesh->setChecked( false );
1199 mySelectGroup->setChecked( false );
1203 //=================================================================================
1204 // function : onAdd()
1206 //=================================================================================
1207 void SMESHGUI_GroupDlg::onAdd()
1209 SALOME_ListIO aList;
1210 mySelectionMgr->selectedObjects( aList );
1212 int aNbSel = aList.Extent();
1214 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1218 SMESH::ElementType aType = SMESH::ALL;
1221 aType = SMESH::NODE;
1222 mySelector->SetSelectionMode(NodeSelection);
1225 aType = SMESH::EDGE;
1226 mySelector->SetSelectionMode(EdgeSelection);
1229 aType = SMESH::FACE;
1230 mySelector->SetSelectionMode(FaceSelection);
1233 aType = SMESH::VOLUME;
1234 mySelector->SetSelectionMode(VolumeSelection);
1237 mySelector->SetSelectionMode(ActorSelection);
1241 if (myCurrentLineEdit == 0) {
1242 //if (aNbSel != 1) { myIsBusy = false; return; }
1243 QString aListStr = "";
1245 if (myTypeId == 0) {
1246 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1249 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1252 QStringList anElements = QStringList::split(" ", aListStr);
1253 QListBoxItem* anItem = 0;
1254 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1255 anItem = myElements->findItem(*it, Qt::ExactMatch);
1257 anItem = new QListBoxText(*it);
1258 myElements->insertItem(anItem);
1260 myElements->setSelected(anItem, true);
1263 } else if (myCurrentLineEdit == mySubMeshLine) {
1264 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1266 SALOME_ListIO aList;
1267 mySelectionMgr->selectedObjects( aList );
1269 SALOME_ListIteratorOfListIO anIt (aList);
1270 for (; anIt.More(); anIt.Next()) {
1271 SMESH::SMESH_subMesh_var aSubMesh =
1272 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1273 if (!aSubMesh->_is_nil()) {
1274 // check if mesh is the same
1275 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1277 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1278 int k = anElements->length();
1279 QListBoxItem* anItem = 0;
1280 for (int i = 0; i < k; i++) {
1281 QString aText = QString::number(anElements[i]);
1282 anItem = myElements->findItem(aText, Qt::ExactMatch);
1284 anItem = new QListBoxText(aText);
1285 myElements->insertItem(anItem);
1287 myElements->setSelected(anItem, true);
1290 catch (const SALOME::SALOME_Exception& ex) {
1291 SalomeApp_Tools::QtCatchCorbaException(ex);
1296 mySelectSubMesh->setChecked(false);
1298 onListSelectionChanged();
1300 } else if (myCurrentLineEdit == myGroupLine) {
1301 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1302 SALOME_ListIO aList;
1303 mySelectionMgr->selectedObjects( aList );
1305 SALOME_ListIteratorOfListIO anIt (aList);
1306 for (; anIt.More(); anIt.Next()) {
1307 SMESH::SMESH_Group_var aGroup =
1308 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1309 if (!aGroup->_is_nil()) {
1310 // check if mesh is the same
1311 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1312 SMESH::long_array_var anElements = aGroup->GetListOfID();
1313 int k = anElements->length();
1314 QListBoxItem* anItem = 0;
1315 for (int i = 0; i < k; i++) {
1316 QString aText = QString::number(anElements[i]);
1317 anItem = myElements->findItem(aText, Qt::ExactMatch);
1319 anItem = new QListBoxText(aText);
1320 myElements->insertItem(anItem);
1322 myElements->setSelected(anItem, true);
1327 mySelectGroup->setChecked(false);
1329 onListSelectionChanged();
1331 } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) {
1332 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1333 GEOM::GEOM_IGroupOperations_var aGroupOp =
1334 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1336 SMESH::ElementType aGroupType = SMESH::ALL;
1337 switch(aGroupOp->GetType(myGeomGroup)) {
1338 case 7: aGroupType = SMESH::NODE; break;
1339 case 6: aGroupType = SMESH::EDGE; break;
1340 case 4: aGroupType = SMESH::FACE; break;
1341 case 2: aGroupType = SMESH::VOLUME; break;
1342 default: myIsBusy = false; return;
1345 if (aGroupType == aType) {
1346 _PTR(SObject) aGroupSO =
1347 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1348 aStudy->FindObjectID(myGeomGroup->GetStudyEntry());
1350 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1351 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1352 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1353 aBelongToGeom->SetGeom(myGeomGroup);
1354 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1355 aBelongToGeom->SetElementType(aType);
1356 aFilter->SetPredicate(aBelongToGeom);
1358 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1360 int k = anElements->length();
1361 QListBoxItem* anItem = 0;
1362 for (int i = 0; i < k; i++) {
1363 QString aText = QString::number(anElements[i]);
1364 anItem = myElements->findItem(aText, Qt::ExactMatch);
1366 anItem = new QListBoxText(aText);
1367 myElements->insertItem(anItem);
1369 myElements->setSelected(anItem, true);
1373 //VSR: mySelectGeomGroup->setChecked(false);
1375 onListSelectionChanged();
1378 // mySelectionMgr->clearSelected();
1382 //=================================================================================
1383 // function : onRemove()
1385 //=================================================================================
1386 void SMESHGUI_GroupDlg::onRemove()
1389 if (myCurrentLineEdit == 0) {
1390 for (int i = myElements->count(); i > 0; i--) {
1391 if (myElements->isSelected(i-1)) {
1392 myElements->removeItem(i-1);
1396 SALOME_ListIO aList;
1397 mySelectionMgr->selectedObjects( aList );
1399 int aNbSel = aList.Extent();
1401 if (aNbSel == 0) { myIsBusy = false; return; }
1403 SMESH::ElementType aType = SMESH::ALL;
1405 case 0: aType = SMESH::NODE; break;
1406 case 1: aType = SMESH::EDGE; break;
1407 case 2: aType = SMESH::FACE; break;
1408 case 3: aType = SMESH::VOLUME; break;
1411 if (myCurrentLineEdit == mySubMeshLine) {
1412 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1413 SALOME_ListIO aList;
1414 mySelectionMgr->selectedObjects( aList );
1416 SALOME_ListIteratorOfListIO anIt (aList);
1417 for (; anIt.More(); anIt.Next()) {
1418 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1419 if (!aSubMesh->_is_nil()) {
1420 // check if mesh is the same
1421 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1422 if (aType == SMESH::NODE) {
1424 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1425 int k = anElements->length();
1426 QListBoxItem* anItem = 0;
1427 for (int i = 0; i < k; i++) {
1428 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1429 if (anItem) delete anItem;
1432 catch (const SALOME::SALOME_Exception& ex) {
1433 SalomeApp_Tools::QtCatchCorbaException(ex);
1438 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1439 int k = anElements->length();
1440 QListBoxItem* anItem = 0;
1441 for (int i = 0; i < k; i++) {
1442 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1443 if (anItem) delete anItem;
1446 catch (const SALOME::SALOME_Exception& ex) {
1447 SalomeApp_Tools::QtCatchCorbaException(ex);
1454 else if (myCurrentLineEdit == myGroupLine) {
1455 Standard_Boolean aRes;
1456 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1457 SALOME_ListIO aList;
1458 mySelectionMgr->selectedObjects( aList );
1460 SALOME_ListIteratorOfListIO anIt (aList);
1461 for (; anIt.More(); anIt.Next()) {
1462 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1463 if (aRes && !aGroup->_is_nil()) {
1464 // check if mesh is the same
1465 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1466 SMESH::long_array_var anElements = aGroup->GetListOfID();
1467 int k = anElements->length();
1468 QListBoxItem* anItem = 0;
1469 for (int i = 0; i < k; i++) {
1470 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1471 if (anItem) delete anItem;
1482 //=================================================================================
1483 // function : onSort()
1485 //=================================================================================
1486 void SMESHGUI_GroupDlg::onSort()
1488 // PAL5412: sorts items in ascending by "string" value
1489 // myElements->sort(true);
1490 // myElements->update();
1491 int i, k = myElements->count();
1494 QStringList aSelected;
1495 std::vector<int> anArray(k);
1496 // QMemArray<int> anArray(k);
1497 QListBoxItem* anItem;
1499 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1500 anArray[i] = anItem->text().toInt();
1501 if (anItem->isSelected())
1502 aSelected.append(anItem->text());
1504 // sort & update list
1505 std::sort(anArray.begin(), anArray.end());
1507 myElements->clear();
1508 for (i = 0; i < k; i++) {
1509 myElements->insertItem(QString::number(anArray[i]));
1511 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1512 anItem = myElements->findItem(*it, Qt::ExactMatch);
1513 if (anItem) myElements->setSelected(anItem, true);
1519 //=================================================================================
1520 // function : closeEvent()
1522 //=================================================================================
1523 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1528 //=================================================================================
1529 // function : SMESHGUI_GroupDlg::onClose
1530 // purpose : SLOT called when "Close" button pressed. Close dialog
1531 //=================================================================================
1532 void SMESHGUI_GroupDlg::onClose()
1534 if (SMESH::GetCurrentVtkView()) {
1535 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1536 SMESH::SetPointRepresentation(false);
1537 SMESH::SetPickable();
1540 mySelectionMgr->clearSelected();
1541 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1542 aViewWindow->SetSelectionMode(ActorSelection);
1543 mySelectionMgr->clearFilters();
1544 mySMESHGUI->ResetState();
1549 //=================================================================================
1550 // function : onHelp()
1552 //=================================================================================
1553 void SMESHGUI_GroupDlg::onHelp()
1555 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1557 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
1559 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
1560 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1561 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
1562 QObject::tr("BUT_OK"));
1566 //=================================================================================
1567 // function : SMESHGUI_GroupDlg::onDeactivate
1568 // purpose : SLOT called when dialog must be deativated
1569 //=================================================================================
1570 void SMESHGUI_GroupDlg::onDeactivate()
1572 mySMESHGUI->ResetState();
1576 //=================================================================================
1577 // function : SMESHGUI_GroupDlg::enterEvent
1578 // purpose : Event filter
1579 //=================================================================================
1580 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1583 mySMESHGUI->EmitSignalDeactivateDialog();
1585 mySelectionMode = -1;
1586 setSelectionMode(myTypeId);
1587 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1588 mySMESHGUI->SetActiveDialogBox(this);
1589 mySMESHGUI->SetState(800);
1593 //=================================================================================
1594 // function : hideEvent
1595 // purpose : caused by ESC key
1596 //=================================================================================
1597 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)