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 "SalomeApp_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>
85 //=================================================================================
86 // function : SMESHGUI_GroupDlg()
88 //=================================================================================
89 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
90 SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl)
91 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
92 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
93 mySMESHGUI( theModule ),
94 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
95 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
99 if (!name) setName("SMESHGUI_GroupDlg");
101 if (!theMesh->_is_nil())
104 mySelectSubMesh->setEnabled(false);
105 mySelectGroup->setEnabled(false);
106 myGeomGroupBtn->setEnabled(false);
107 myGeomGroupLine->setEnabled(false);
111 //=================================================================================
112 // function : SMESHGUI_GroupDlg()
114 //=================================================================================
115 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
116 SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl)
117 : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
118 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
119 mySMESHGUI( theModule ),
120 mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
121 mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
124 if (!name) setName("SMESHGUI_GroupDlg");
127 if (!theGroup->_is_nil())
130 mySelectSubMesh->setEnabled(false);
131 mySelectGroup->setEnabled(false);
133 myCurrentLineEdit = myMeshGroupLine;
137 bool isEditMode = !CORBA::is_nil( myGroupOnGeom );
138 myHelpFileName = isEditMode ? "/files/editing_groups.htm" : "/files/creating_groups.htm";
141 //=================================================================================
142 // function : SMESHGUI_GroupDlg()
144 //=================================================================================
145 void SMESHGUI_GroupDlg::initDialog(bool create)
149 myCurrentLineEdit = 0;
151 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
154 setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
156 setCaption(tr("SMESH_EDIT_GROUP_TITLE"));
158 setSizeGripEnabled(TRUE);
160 QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6);
162 /***************************************************************/
163 QLabel* meshGroupLab = new QLabel(this, "mesh/group label");
165 meshGroupLab->setText(tr("SMESH_MESH"));
167 meshGroupLab->setText(tr("SMESH_GROUP"));
168 myMeshGroupBtn = new QPushButton(this, "mesh/group button");
169 myMeshGroupBtn->setPixmap(image0);
170 myMeshGroupLine = new QLineEdit(this, "mesh/group line");
171 myMeshGroupLine->setReadOnly(true);
173 /***************************************************************/
174 myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
175 myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
176 myTypeGroup->setExclusive(true);
179 types.append(tr("MESH_NODE"));
180 types.append(tr("SMESH_EDGE"));
181 types.append(tr("SMESH_FACE"));
182 types.append(tr("SMESH_VOLUME"));
184 for (int i = 0; i < types.count(); i++) {
185 rb = new QRadioButton(types[i], myTypeGroup);
187 myTypeGroup->setEnabled(create);
190 /***************************************************************/
191 QLabel* aName = new QLabel(this, "name label");
192 aName->setText(tr("SMESH_NAME"));
193 aName->setMinimumSize(50,0);
194 myName = new QLineEdit(this, "name");
196 /***************************************************************/
197 myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group");
198 myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE"));
199 myGrpTypeGroup->setExclusive(true);
200 QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup);
201 QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"), myGrpTypeGroup);
202 myGrpTypeGroup->setEnabled(create);
205 /***************************************************************/
206 myWGStack = new QWidgetStack( this, "widget stack");
207 QWidget* wg1 = new QFrame( myWGStack, "first widget" );
208 QWidget* wg2 = new QFrame( myWGStack, "second widget" );
210 /***************************************************************/
211 QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box");
212 aContentBox->setTitle(tr("SMESH_CONTENT"));
213 QFrame* aContent = new QFrame(aContentBox, "content");
214 QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
215 aLayout->setSpacing(6);
216 aLayout->setAutoAdd(false);
218 QLabel* aLabel = new QLabel(aContent, "elements label");
219 aLabel->setText(tr("SMESH_ID_ELEMENTS"));
220 myElements = new QListBox(aContent, "elements list");
221 myElements->setSelectionMode(QListBox::Extended);
223 myFilter = new QPushButton(aContent, "filter");
224 myFilter->setText(tr("SMESH_BUT_FILTER"));
225 QPushButton* aAddBtn = new QPushButton(aContent, "add");
226 aAddBtn->setText(tr("SMESH_BUT_ADD"));
227 QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
228 aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
229 QPushButton* aSortBtn = new QPushButton(aContent, "sort");
230 aSortBtn->setText(tr("SMESH_BUT_SORT"));
232 aLayout->addWidget(aLabel, 0, 0);
233 aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
234 aLayout->addWidget(myFilter, 1, 2);
235 aLayout->addWidget(aAddBtn, 3, 2);
236 aLayout->addWidget(aRemoveBtn, 4, 2);
237 aLayout->addWidget(aSortBtn, 6, 2);
239 aLayout->setColStretch(0, 1);
240 aLayout->addColSpacing(1, 20);
241 aLayout->addColSpacing(3, 20);
242 aLayout->setRowStretch(2, 1);
243 aLayout->setRowStretch(5, 1);
245 /***************************************************************/
246 QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box");
247 aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
249 mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
250 mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
251 mySelectSubMesh->setMinimumSize(50, 0);
252 mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
253 mySubMeshBtn->setText("");
254 mySubMeshBtn->setPixmap(image0);
255 mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
256 mySubMeshLine->setReadOnly(true);
257 onSelectSubMesh(false);
259 mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
260 mySelectGroup->setText(tr("SMESH_GROUP"));
261 mySelectGroup->setMinimumSize(50, 0);
262 myGroupBtn = new QPushButton(aSelectBox, "group button");
263 myGroupBtn->setText("");
264 myGroupBtn->setPixmap(image0);
265 myGroupLine = new QLineEdit(aSelectBox, "group line");
266 myGroupLine->setReadOnly(true);
267 onSelectGroup(false);
269 /***************************************************************/
270 QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
271 wg1Layout->addWidget(aContentBox, 0, 0);
272 wg1Layout->addWidget(aSelectBox, 1, 0);
273 wg1Layout->setRowStretch(2, 5);
275 /***************************************************************/
276 QLabel* geomObject = new QLabel(wg2, "geometry object label");
277 geomObject->setText(tr("SMESH_OBJECT_GEOM"));
278 myGeomGroupBtn = new QPushButton(wg2, "geometry group button");
279 myGeomGroupBtn->setText("");
280 myGeomGroupBtn->setPixmap(image0);
281 myGeomGroupLine = new QLineEdit(wg2, "geometry group line");
282 myGeomGroupLine->setReadOnly(true); //VSR ???
283 onSelectGeomGroup(false);
287 myGeomGroupBtn->setEnabled(false);
288 myGeomGroupLine->setEnabled(false);
291 /***************************************************************/
292 QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
293 wg2Layout->addWidget(geomObject, 0, 0);
294 wg2Layout->addWidget(myGeomGroupBtn, 0, 1);
295 wg2Layout->addWidget(myGeomGroupLine,0, 2);
296 wg2Layout->setRowStretch(1, 5);
298 /***************************************************************/
299 QVBoxLayout* dumb = new QVBoxLayout(myWGStack);
300 dumb->addWidget(wg1);
301 dumb->addWidget(wg2);
302 myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) );
303 myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
305 /***************************************************************/
306 QGroupBox* aColorBox = new QGroupBox(this, "color box");
307 aColorBox->setTitle(tr("SMESH_SET_COLOR"));
309 mySelectColorGroup = new QCheckBox(aColorBox, "color checkbox");
310 mySelectColorGroup->setText(tr("SMESH_CHECK_COLOR"));
311 mySelectColorGroup->setMinimumSize(50, 0);
313 myColorGroupLine = new QLineEdit(aColorBox, "color line");
314 myColorGroupLine->setReadOnly(false);
315 onSelectColorGroup(false);
317 /***************************************************************/
318 QHBoxLayout* aColorLayout = new QHBoxLayout(aColorBox, 15, 20);
319 aColorLayout->setAutoAdd(false);
321 aColorLayout->addWidget(mySelectColorGroup);
322 aColorLayout->addWidget(myColorGroupLine);
324 /***************************************************************/
326 QFrame* aButtons = new QFrame(this, "button box");
327 aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
328 QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
329 aBtnLayout->setAutoAdd(false);
331 QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
332 aOKBtn->setText(tr("SMESH_BUT_OK"));
333 aOKBtn->setAutoDefault(true);
334 aOKBtn->setDefault(true);
335 QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
336 aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
337 aApplyBtn->setAutoDefault(true);
338 QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
339 aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
340 aCloseBtn->setAutoDefault(true);
341 QPushButton* aHelpBtn = new QPushButton(aButtons, "help");
342 aHelpBtn->setText(tr("SMESH_BUT_HELP"));
343 aHelpBtn->setAutoDefault(true);
345 aBtnLayout->addWidget(aOKBtn);
346 aBtnLayout->addWidget(aApplyBtn);
347 aBtnLayout->addStretch();
348 aBtnLayout->addWidget(aCloseBtn);
349 aBtnLayout->addWidget(aHelpBtn);
351 /***************************************************************/
352 aMainLayout->addWidget(meshGroupLab, 0, 0);
353 aMainLayout->addWidget(myMeshGroupBtn, 0, 1);
354 aMainLayout->addWidget(myMeshGroupLine, 0, 2);
355 aMainLayout->addMultiCellWidget(myTypeGroup, 1, 1, 0, 2);
356 aMainLayout->addWidget(aName, 2, 0);
357 aMainLayout->addWidget(myName, 2, 2);
358 aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
359 aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2);
360 aMainLayout->setRowStretch( 5, 5 );
361 aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2);
362 aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2);
364 /* signals and slots connections */
365 connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
367 connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int)));
369 connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
371 connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
372 connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
374 connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
375 connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
376 connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
377 connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
379 connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
380 connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
381 connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
382 connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
383 connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
384 connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool)));
385 connect(myColorGroupLine, SIGNAL(textChanged(const QString&)), this, SLOT(onNbColorsChanged(const QString&)));
387 connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
388 connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
389 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
390 connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
393 mySMESHGUI->SetActiveDialogBox(this);
394 mySMESHGUI->SetState(800);
396 mySelectionMode = -1;
397 myMeshFilter = new SMESH_TypeFilter(MESH);
398 mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
399 myGroupFilter = new SMESH_TypeFilter(GROUP);
401 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
402 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
403 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
405 myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
406 onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
408 if (myMesh->_is_nil() )
409 myTypeGroup->setButton(0);
414 //=================================================================================
415 // function : ~SMESHGUI_GroupDlg()
416 // purpose : Destroys the object and frees any allocated resources
417 //=================================================================================
418 SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
420 // no need to delete child widgets, Qt does it all for us
421 if ( myFilterDlg != 0 )
423 myFilterDlg->reparent( 0, QPoint() );
428 //=================================================================================
431 //=================================================================================
432 void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
434 mySelectionMgr->installFilter(myMeshFilter);
436 /* init data from current selection */
437 myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
438 myGroup = SMESH::SMESH_Group::_nil();
439 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
441 myActor = SMESH::FindActorByObject(myMesh);
442 SMESH::SetPickable(myActor);
445 mySelectionMgr->selectedObjects( aList );
446 if( !aList.IsEmpty() )
448 QString aName = aList.First()->getName();
449 myMeshGroupLine->setText(aName) ;
450 myMeshGroupLine->home( false );
453 myCurrentLineEdit = 0;
455 myTypeGroup->setButton(0);
459 //=================================================================================
462 //=================================================================================
463 void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
465 myMesh = theGroup->GetMesh();
467 myName->setText(theGroup->GetName());
470 myColorGroupLine->setText(QString::number(theGroup->GetColorNumber()));
471 myColorGroupLine->home(false);
473 myMeshGroupLine->setText(theGroup->GetName());
476 switch(theGroup->GetType()) {
477 case SMESH::NODE: aType= 0; break;
478 case SMESH::EDGE: aType = 1; break;
479 case SMESH::FACE: aType = 2; break;
480 case SMESH::VOLUME: aType = 3; break;
482 myTypeGroup->setButton(aType);
484 myGroup = SMESH::SMESH_Group::_narrow( theGroup );
486 if ( !myGroup->_is_nil() )
488 myGrpTypeGroup->setButton(0);
491 myActor = SMESH::FindActorByObject(myMesh);
493 myActor = SMESH::FindActorByObject(myGroup);
494 SMESH::SetPickable(myActor);
496 myCurrentLineEdit = 0;
498 setSelectionMode(aType);
502 if (!myGroup->IsEmpty()) {
503 SMESH::long_array_var anElements = myGroup->GetListOfID();
504 int k = anElements->length();
505 for (int i = 0; i < k; i++) {
506 myIdList.append(anElements[i]);
507 myElements->insertItem(QString::number(anElements[i]));
509 myElements->selectAll(true);
514 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
516 if ( !myGroupOnGeom->_is_nil() )
518 myGrpTypeGroup->setButton(1);
521 myActor = SMESH::FindActorByObject(myMesh);
523 myActor = SMESH::FindActorByObject(myGroup);
524 SMESH::SetPickable(myActor);
526 QString aShapeName("");
527 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
528 GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
529 if (!aGroupShape->_is_nil())
531 _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
532 aShapeName = aGroupShapeSO->GetName().c_str();
534 myGeomGroupLine->setText( aShapeName );
539 //=================================================================================
540 // function : updateButtons()
542 //=================================================================================
543 void SMESHGUI_GroupDlg::updateButtons()
547 if (myGrpTypeId == 0)
548 enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0;
549 else if (myGrpTypeId == 1)
551 bool isEditMode = !CORBA::is_nil( myGroupOnGeom );
552 enable = !myName->text().stripWhiteSpace().isEmpty() && (!CORBA::is_nil( myGeomGroup ) || isEditMode);
555 aBtn = (QPushButton*) child("ok", "QPushButton");
556 if (aBtn) aBtn->setEnabled(enable);
557 aBtn = (QPushButton*) child("apply", "QPushButton");
558 if (aBtn) aBtn->setEnabled(enable);
561 //=================================================================================
562 // function : onNameChanged()
564 //=================================================================================
565 void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
570 //=================================================================================
571 // function : onNbColorsChanged()
573 //=================================================================================
574 void SMESHGUI_GroupDlg::onNbColorsChanged (const QString& text)
579 //=================================================================================
580 // function : onTypeChanged()
581 // purpose : Group elements type radio button management
582 //=================================================================================
583 void SMESHGUI_GroupDlg::onTypeChanged (int id)
585 if (myTypeId != id) {
587 if (myCurrentLineEdit == 0)
588 setSelectionMode(id);
593 //=================================================================================
594 // function : onGrpTypeChanged()
595 // purpose : Group type radio button management
596 //=================================================================================
597 void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
599 if (myGrpTypeId != id) {
600 myWGStack->raiseWidget( id );
601 onSelectGeomGroup(id == 1);
606 //=================================================================================
607 // function : setSelectionMode()
608 // purpose : Radio button management
609 //=================================================================================
610 void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
613 if (myMesh->_is_nil())
616 if (mySelectionMode != theMode) {
617 // [PAL10408] mySelectionMgr->clearSelected();
618 mySelectionMgr->clearFilters();
619 SMESH::SetPointRepresentation(false);
624 myActor->SetPointRepresentation(true);
626 SMESH::SetPointRepresentation(true);
627 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
628 aViewWindow->SetSelectionMode(NodeSelection);
631 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
632 aViewWindow->SetSelectionMode(EdgeSelection);
635 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
636 aViewWindow->SetSelectionMode(FaceSelection);
639 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
640 aViewWindow->SetSelectionMode(VolumeSelection);
644 mySelectionMgr->installFilter(mySubMeshFilter);
645 else if (theMode == 5)
646 mySelectionMgr->installFilter(myGroupFilter);
647 else if (theMode == 6)
648 mySelectionMgr->installFilter(myMeshFilter);
649 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
650 aViewWindow->SetSelectionMode(ActorSelection);
652 mySelectionMode = theMode;
656 //=================================================================================
657 // function : onApply()
659 //=================================================================================
660 bool SMESHGUI_GroupDlg::onApply()
662 if (mySMESHGUI->isActiveStudyLocked())
665 if (myGrpTypeId == 0 &&
666 !myName->text().stripWhiteSpace().isEmpty() &&
667 myElements->count() > 0) {
668 mySelectionMgr->clearSelected();
669 if (myGroup->_is_nil()) {
670 SMESH::ElementType aType = SMESH::ALL;
672 case 0: aType = SMESH::NODE; break;
673 case 1: aType = SMESH::EDGE; break;
674 case 2: aType = SMESH::FACE; break;
675 case 3: aType = SMESH::VOLUME; break;
677 SMESH::long_array_var anIdList = new SMESH::long_array;
678 int i, k = myElements->count();
680 QListBoxItem* anItem;
681 for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
682 anIdList[i] = anItem->text().toInt();
685 myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
686 myGroup->Add(anIdList.inout());
688 int aColorNumber = myColorGroupLine->text().toInt();
689 myGroup->SetColorNumber(aColorNumber);
691 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
693 SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text());
695 SMESH::setFileType (aMeshGroupSO,"COULEURGROUP");
697 /* init for next operation */
699 myColorGroupLine->setText("");
701 myGroup = SMESH::SMESH_Group::_nil();
704 myGroup->SetName(myName->text());
706 int aColorNumber = myColorGroupLine->text().toInt();
707 myGroup->SetColorNumber(aColorNumber);
709 QValueList<int> aAddList;
710 QValueList<int>::iterator anIt;
711 QListBoxItem* anItem;
713 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
714 int anId = anItem->text().toInt();
715 if ((anIt = myIdList.find(anId)) == myIdList.end())
716 aAddList.append(anId);
718 myIdList.remove(anIt);
720 if (!aAddList.empty()) {
721 SMESH::long_array_var anIdList = new SMESH::long_array;
722 anIdList->length(aAddList.count());
724 for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
726 myGroup->Add(anIdList.inout());
728 if (!myIdList.empty()) {
729 SMESH::long_array_var anIdList = new SMESH::long_array;
730 anIdList->length(myIdList.count());
732 for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
734 myGroup->Remove(anIdList.inout());
736 /* init for next operation */
738 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
739 myIdList.append(anItem->text().toInt());
742 mySMESHGUI->updateObjBrowser(true);
743 SMESH::UpdateView(); // asv: fix of BUG PAL5515
744 mySelectionMgr->clearSelected();
746 } else if (myGrpTypeId == 1 &&
747 !myName->text().stripWhiteSpace().isEmpty() &&
748 (!CORBA::is_nil(myGeomGroup) || !CORBA::is_nil(myGroupOnGeom)))
750 if (myGroupOnGeom->_is_nil()) {
751 SMESH::ElementType aType = SMESH::ALL;
753 case 0: aType = SMESH::NODE; break;
754 case 1: aType = SMESH::EDGE; break;
755 case 2: aType = SMESH::FACE; break;
756 case 3: aType = SMESH::VOLUME; break;
759 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
760 GEOM::GEOM_IGroupOperations_var aGroupOp =
761 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
763 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup);
765 int aColorNumber = myColorGroupLine->text().toInt();
766 myGroupOnGeom->SetColorNumber(aColorNumber);
768 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
770 SMESH::setFileName (aMeshGroupSO, myColorGroupLine->text());
772 SMESH::setFileType (aMeshGroupSO,"COULEURGROUP");
774 /* init for next operation */
776 myColorGroupLine->setText("");
777 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
781 myGroupOnGeom->SetName(myName->text());
783 int aColorNumber = myColorGroupLine->text().toInt();
784 myGroupOnGeom->SetColorNumber(aColorNumber);
787 mySMESHGUI->updateObjBrowser(true);
788 mySelectionMgr->clearSelected();
795 //=================================================================================
798 //=================================================================================
799 void SMESHGUI_GroupDlg::onOK()
805 //=================================================================================
806 // function : onListSelectionChanged()
807 // purpose : Called when selection in element list is changed
808 //=================================================================================
809 void SMESHGUI_GroupDlg::onListSelectionChanged()
811 // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
812 if( myIsBusy || !myActor) return;
815 if (myCurrentLineEdit == 0) {
816 mySelectionMgr->clearSelected();
817 TColStd_MapOfInteger aIndexes;
818 QListBoxItem* anItem;
819 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
820 if (anItem->isSelected()) {
821 int anId = anItem->text().toInt();
825 mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
827 aList.Append(myActor->getIO());
828 mySelectionMgr->setSelectedObjects(aList,false);
833 //=================================================================================
834 // function : onObjectSelectionChanged()
835 // purpose : Called when selection in 3D view or ObjectBrowser is changed
836 //=================================================================================
837 void SMESHGUI_GroupDlg::onObjectSelectionChanged()
839 if ( myIsBusy || !isEnabled()) return;
843 mySelectionMgr->selectedObjects( aList );
845 int aNbSel = aList.Extent();
846 myElements->clearSelection();
848 if (myCurrentLineEdit) {
849 myCurrentLineEdit->setText("");
850 QString aString = "";
852 if (myCurrentLineEdit == myMeshGroupLine) {
853 mySelectSubMesh->setEnabled(false);
854 mySelectGroup->setEnabled(false);
855 myGroupLine->setText("");
856 mySubMeshLine->setText("");
858 myGeomGroupBtn->setEnabled(false);
859 myGeomGroupLine->setEnabled(false);
860 myGeomGroupLine->setText("");
867 myGroup = SMESH::SMESH_Group::_nil();
868 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
869 myMesh = SMESH::SMESH_Mesh::_nil();
873 Handle(SALOME_InteractiveObject) IO = aList.First();
876 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
877 if (myMesh->_is_nil())
882 myGroup = SMESH::SMESH_Group::_nil();
884 myActor = SMESH::FindActorByObject(myMesh);
885 SMESH::SetPickable(myActor);
887 aString = aList.First()->getName();
888 myMeshGroupLine->setText(aString) ;
889 myMeshGroupLine->home( false );
891 mySelectSubMesh->setEnabled(true);
892 mySelectGroup->setEnabled(true);
893 myGeomGroupBtn->setEnabled(true);
894 myGeomGroupLine->setEnabled(true);
897 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
898 if (aGroup->_is_nil())
904 myCurrentLineEdit = 0;
906 myGroup = SMESH::SMESH_Group::_nil();
907 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
911 mySelectSubMesh->setEnabled(true);
912 mySelectGroup->setEnabled(true);
914 myCurrentLineEdit = 0;
923 setSelectionMode(myTypeId);
929 } else if (myCurrentLineEdit == myGeomGroupLine) {
931 myGeomGroup = GEOM::GEOM_Object::_nil();
936 Standard_Boolean testResult = Standard_False;
937 myGeomGroup = GEOMBase::ConvertIOinGEOMObject(aList.First(), testResult);
939 // Check if the object is a geometry group
940 if (!testResult || CORBA::is_nil(myGeomGroup)) {
941 myGeomGroup = GEOM::GEOM_Object::_nil();
945 // Check if group constructed on the same shape as a mesh or on its child
946 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
947 GEOM::GEOM_IGroupOperations_var anOp =
948 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
950 // The main shape of the group
951 GEOM::GEOM_Object_var aGroupMainShape;
952 if (myGeomGroup->GetType() == 37)
953 aGroupMainShape = anOp->GetMainShape(myGeomGroup);
955 aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup);
956 _PTR(SObject) aGroupMainShapeSO =
957 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
958 aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
961 _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
963 myGeomGroup = GEOM::GEOM_Object::_nil();
967 _PTR(SObject) anObj, aRef;
968 bool isRefOrSubShape = false;
969 if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
970 //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
971 if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
972 isRefOrSubShape = true;
974 _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
975 _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
976 //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
977 while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
978 //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
979 if (aRef->GetID() == aFather->GetID())
980 isRefOrSubShape = true;
982 aFather = aFather->GetFather();
986 if (!isRefOrSubShape) {
987 myGeomGroup = GEOM::GEOM_Object::_nil();
995 if(myCurrentLineEdit == mySubMeshLine)
996 aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
997 else if(myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine)
998 aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
1000 aString = aList.First()->getName();
1004 myCurrentLineEdit->setText(aString);
1005 myCurrentLineEdit->home(false);
1010 if (aNbSel == 1 && myActor ) {
1011 QString aListStr = "";
1013 if (myTypeId == 0) {
1014 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1016 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1019 QStringList anElements = QStringList::split(" ", aListStr);
1020 QListBoxItem* anItem = 0;
1021 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1022 anItem = myElements->findItem(*it, Qt::ExactMatch);
1023 if (anItem) myElements->setSelected(anItem, true);
1030 if (!myGroup->_is_nil())
1031 myActor = SMESH::FindActorByObject(myGroup);
1032 else if(!myGroupOnGeom->_is_nil())
1033 myActor = SMESH::FindActorByObject(myGroupOnGeom);
1035 myActor = SMESH::FindActorByObject(myMesh);
1041 //=================================================================================
1042 // function : onSelectSubMesh()
1043 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1044 //=================================================================================
1045 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1048 if (mySelectGroup->isChecked()) {
1049 mySelectGroup->setChecked(false);
1051 //VSR: else if (mySelectGeomGroup->isChecked()) {
1052 //VSR: mySelectGeomGroup->setChecked(false);
1054 myCurrentLineEdit = mySubMeshLine;
1055 setSelectionMode(4);
1058 mySubMeshLine->setText("");
1059 myCurrentLineEdit = 0;
1061 setSelectionMode(myTypeId);
1063 mySubMeshBtn->setEnabled(on);
1064 mySubMeshLine->setEnabled(on);
1068 //=================================================================================
1069 // function : (onSelectGroup)
1070 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1071 //=================================================================================
1072 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1075 if (mySelectSubMesh->isChecked()) {
1076 mySelectSubMesh->setChecked(false);
1078 myCurrentLineEdit = myGroupLine;
1079 setSelectionMode(5);
1082 myGroupLine->setText("");
1083 myCurrentLineEdit = 0;
1085 setSelectionMode(myTypeId);
1087 myGroupBtn->setEnabled(on);
1088 myGroupLine->setEnabled(on);
1092 //=================================================================================
1093 // function : (onSelectGeomGroup)
1094 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1095 //=================================================================================
1096 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1099 if (mySelectSubMesh->isChecked()) {
1100 mySelectSubMesh->setChecked(false);
1102 else if (mySelectGroup->isChecked()) {
1103 mySelectGroup->setChecked(false);
1105 myCurrentLineEdit = myGeomGroupLine;
1106 setSelectionMode(7);
1109 myGeomGroupLine->setText("");
1110 myCurrentLineEdit = 0;
1112 setSelectionMode(myTypeId);
1116 //=================================================================================
1117 // function : (onSelectColorGroup)
1118 // purpose : Called when setting a color on group
1119 //=================================================================================
1120 void SMESHGUI_GroupDlg::onSelectColorGroup(bool on)
1123 setSelectionMode(7);
1126 myColorGroupLine->setText("");
1127 myCurrentLineEdit = 0;
1129 setSelectionMode(myTypeId);
1131 myColorGroupLine->setEnabled(on);
1134 //=================================================================================
1135 // function : setCurrentSelection()
1137 //=================================================================================
1138 void SMESHGUI_GroupDlg::setCurrentSelection()
1140 QPushButton* send = (QPushButton*)sender();
1141 myCurrentLineEdit = 0;
1142 if (send == myMeshGroupBtn) {
1143 myCurrentLineEdit = myMeshGroupLine;
1145 setSelectionMode(6);
1147 setSelectionMode(5);
1148 onObjectSelectionChanged();
1150 else if (send == mySubMeshBtn) {
1151 myCurrentLineEdit = mySubMeshLine;
1152 onObjectSelectionChanged();
1154 else if (send == myGroupBtn) {
1155 myCurrentLineEdit = myGroupLine;
1156 onObjectSelectionChanged();
1158 else if (send == myGeomGroupBtn) {
1159 myCurrentLineEdit = myGeomGroupLine;
1160 setSelectionMode(7);
1161 onObjectSelectionChanged();
1166 //=================================================================================
1167 // function : setFilters()
1168 // purpose : SLOT. Called when "Filter" button pressed.
1169 //=================================================================================
1170 void SMESHGUI_GroupDlg::setFilters()
1172 SMESH::ElementType aType = SMESH::ALL;
1175 case 0 : aType = SMESH::NODE; break;
1176 case 1 : aType = SMESH::EDGE; break;
1177 case 2 : aType = SMESH::FACE; break;
1178 case 3 : aType = SMESH::VOLUME; break;
1182 if ( myFilterDlg == 0 )
1184 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1185 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1188 myFilterDlg->Init( aType );
1190 myFilterDlg->SetSelection();
1191 myFilterDlg->SetMesh( myMesh );
1192 myFilterDlg->SetSourceWg( myElements );
1194 myFilterDlg->show();
1197 //=================================================================================
1198 // function : onFilterAccepted()
1199 // purpose : SLOT. Called when Filter dlg closed with OK button.
1200 // Uncheck "Select submesh" and "Select group" checkboxes
1201 //=================================================================================
1202 void SMESHGUI_GroupDlg::onFilterAccepted()
1204 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1206 mySelectionMode = myTypeId;
1207 mySelectSubMesh->setChecked( false );
1208 mySelectGroup->setChecked( false );
1212 //=================================================================================
1213 // function : onAdd()
1215 //=================================================================================
1216 void SMESHGUI_GroupDlg::onAdd()
1218 SALOME_ListIO aList;
1219 mySelectionMgr->selectedObjects( aList );
1221 int aNbSel = aList.Extent();
1223 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1227 SMESH::ElementType aType = SMESH::ALL;
1230 aType = SMESH::NODE;
1231 mySelector->SetSelectionMode(NodeSelection);
1234 aType = SMESH::EDGE;
1235 mySelector->SetSelectionMode(EdgeSelection);
1238 aType = SMESH::FACE;
1239 mySelector->SetSelectionMode(FaceSelection);
1242 aType = SMESH::VOLUME;
1243 mySelector->SetSelectionMode(VolumeSelection);
1246 mySelector->SetSelectionMode(ActorSelection);
1250 if (myCurrentLineEdit == 0) {
1251 //if (aNbSel != 1) { myIsBusy = false; return; }
1252 QString aListStr = "";
1254 if (myTypeId == 0) {
1255 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1258 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1261 QStringList anElements = QStringList::split(" ", aListStr);
1262 QListBoxItem* anItem = 0;
1263 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1264 anItem = myElements->findItem(*it, Qt::ExactMatch);
1266 anItem = new QListBoxText(*it);
1267 myElements->insertItem(anItem);
1269 myElements->setSelected(anItem, true);
1272 } else if (myCurrentLineEdit == mySubMeshLine) {
1273 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1275 SALOME_ListIO aList;
1276 mySelectionMgr->selectedObjects( aList );
1278 SALOME_ListIteratorOfListIO anIt (aList);
1279 for (; anIt.More(); anIt.Next()) {
1280 SMESH::SMESH_subMesh_var aSubMesh =
1281 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1282 if (!aSubMesh->_is_nil()) {
1283 // check if mesh is the same
1284 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1286 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1287 int k = anElements->length();
1288 QListBoxItem* anItem = 0;
1289 for (int i = 0; i < k; i++) {
1290 QString aText = QString::number(anElements[i]);
1291 anItem = myElements->findItem(aText, Qt::ExactMatch);
1293 anItem = new QListBoxText(aText);
1294 myElements->insertItem(anItem);
1296 myElements->setSelected(anItem, true);
1299 catch (const SALOME::SALOME_Exception& ex) {
1300 SalomeApp_Tools::QtCatchCorbaException(ex);
1305 mySelectSubMesh->setChecked(false);
1307 onListSelectionChanged();
1309 } else if (myCurrentLineEdit == myGroupLine) {
1310 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1311 SALOME_ListIO aList;
1312 mySelectionMgr->selectedObjects( aList );
1314 SALOME_ListIteratorOfListIO anIt (aList);
1315 for (; anIt.More(); anIt.Next()) {
1316 SMESH::SMESH_Group_var aGroup =
1317 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1318 if (!aGroup->_is_nil()) {
1319 // check if mesh is the same
1320 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1321 SMESH::long_array_var anElements = aGroup->GetListOfID();
1322 int k = anElements->length();
1323 QListBoxItem* anItem = 0;
1324 for (int i = 0; i < k; i++) {
1325 QString aText = QString::number(anElements[i]);
1326 anItem = myElements->findItem(aText, Qt::ExactMatch);
1328 anItem = new QListBoxText(aText);
1329 myElements->insertItem(anItem);
1331 myElements->setSelected(anItem, true);
1336 mySelectGroup->setChecked(false);
1338 onListSelectionChanged();
1340 } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) {
1341 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1342 GEOM::GEOM_IGroupOperations_var aGroupOp =
1343 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1345 SMESH::ElementType aGroupType = SMESH::ALL;
1346 switch(aGroupOp->GetType(myGeomGroup)) {
1347 case 7: aGroupType = SMESH::NODE; break;
1348 case 6: aGroupType = SMESH::EDGE; break;
1349 case 4: aGroupType = SMESH::FACE; break;
1350 case 2: aGroupType = SMESH::VOLUME; break;
1351 default: myIsBusy = false; return;
1354 if (aGroupType == aType) {
1355 _PTR(SObject) aGroupSO =
1356 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1357 aStudy->FindObjectID(myGeomGroup->GetStudyEntry());
1359 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1360 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1361 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1362 aBelongToGeom->SetGeom(myGeomGroup);
1363 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1364 aBelongToGeom->SetElementType(aType);
1365 aFilter->SetPredicate(aBelongToGeom);
1367 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1369 int k = anElements->length();
1370 QListBoxItem* anItem = 0;
1371 for (int i = 0; i < k; i++) {
1372 QString aText = QString::number(anElements[i]);
1373 anItem = myElements->findItem(aText, Qt::ExactMatch);
1375 anItem = new QListBoxText(aText);
1376 myElements->insertItem(anItem);
1378 myElements->setSelected(anItem, true);
1382 //VSR: mySelectGeomGroup->setChecked(false);
1384 onListSelectionChanged();
1387 // mySelectionMgr->clearSelected();
1391 //=================================================================================
1392 // function : onRemove()
1394 //=================================================================================
1395 void SMESHGUI_GroupDlg::onRemove()
1398 if (myCurrentLineEdit == 0) {
1399 for (int i = myElements->count(); i > 0; i--) {
1400 if (myElements->isSelected(i-1)) {
1401 myElements->removeItem(i-1);
1405 SALOME_ListIO aList;
1406 mySelectionMgr->selectedObjects( aList );
1408 int aNbSel = aList.Extent();
1410 if (aNbSel == 0) { myIsBusy = false; return; }
1412 SMESH::ElementType aType = SMESH::ALL;
1414 case 0: aType = SMESH::NODE; break;
1415 case 1: aType = SMESH::EDGE; break;
1416 case 2: aType = SMESH::FACE; break;
1417 case 3: aType = SMESH::VOLUME; break;
1420 if (myCurrentLineEdit == mySubMeshLine) {
1421 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1422 SALOME_ListIO aList;
1423 mySelectionMgr->selectedObjects( aList );
1425 SALOME_ListIteratorOfListIO anIt (aList);
1426 for (; anIt.More(); anIt.Next()) {
1427 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1428 if (!aSubMesh->_is_nil()) {
1429 // check if mesh is the same
1430 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1431 if (aType == SMESH::NODE) {
1433 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1434 int k = anElements->length();
1435 QListBoxItem* anItem = 0;
1436 for (int i = 0; i < k; i++) {
1437 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1438 if (anItem) delete anItem;
1441 catch (const SALOME::SALOME_Exception& ex) {
1442 SalomeApp_Tools::QtCatchCorbaException(ex);
1447 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1448 int k = anElements->length();
1449 QListBoxItem* anItem = 0;
1450 for (int i = 0; i < k; i++) {
1451 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1452 if (anItem) delete anItem;
1455 catch (const SALOME::SALOME_Exception& ex) {
1456 SalomeApp_Tools::QtCatchCorbaException(ex);
1463 else if (myCurrentLineEdit == myGroupLine) {
1464 Standard_Boolean aRes;
1465 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1466 SALOME_ListIO aList;
1467 mySelectionMgr->selectedObjects( aList );
1469 SALOME_ListIteratorOfListIO anIt (aList);
1470 for (; anIt.More(); anIt.Next()) {
1471 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1472 if (aRes && !aGroup->_is_nil()) {
1473 // check if mesh is the same
1474 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1475 SMESH::long_array_var anElements = aGroup->GetListOfID();
1476 int k = anElements->length();
1477 QListBoxItem* anItem = 0;
1478 for (int i = 0; i < k; i++) {
1479 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1480 if (anItem) delete anItem;
1491 //=================================================================================
1492 // function : onSort()
1494 //=================================================================================
1495 void SMESHGUI_GroupDlg::onSort()
1497 // PAL5412: sorts items in ascending by "string" value
1498 // myElements->sort(true);
1499 // myElements->update();
1500 int i, k = myElements->count();
1503 QStringList aSelected;
1504 std::vector<int> anArray(k);
1505 // QMemArray<int> anArray(k);
1506 QListBoxItem* anItem;
1508 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1509 anArray[i] = anItem->text().toInt();
1510 if (anItem->isSelected())
1511 aSelected.append(anItem->text());
1513 // sort & update list
1514 std::sort(anArray.begin(), anArray.end());
1516 myElements->clear();
1517 for (i = 0; i < k; i++) {
1518 myElements->insertItem(QString::number(anArray[i]));
1520 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1521 anItem = myElements->findItem(*it, Qt::ExactMatch);
1522 if (anItem) myElements->setSelected(anItem, true);
1528 //=================================================================================
1529 // function : closeEvent()
1531 //=================================================================================
1532 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1537 //=================================================================================
1538 // function : SMESHGUI_GroupDlg::onClose
1539 // purpose : SLOT called when "Close" button pressed. Close dialog
1540 //=================================================================================
1541 void SMESHGUI_GroupDlg::onClose()
1543 if (SMESH::GetCurrentVtkView()) {
1544 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1545 SMESH::SetPointRepresentation(false);
1546 SMESH::SetPickable();
1549 mySelectionMgr->clearSelected();
1550 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1551 aViewWindow->SetSelectionMode(ActorSelection);
1552 mySelectionMgr->clearFilters();
1553 mySMESHGUI->ResetState();
1558 //=================================================================================
1559 // function : onHelp()
1561 //=================================================================================
1562 void SMESHGUI_GroupDlg::onHelp()
1564 SalomeApp_Application* app = (SalomeApp_Application*)(SUIT_Session::session()->activeApplication());
1566 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
1568 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
1569 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1570 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
1571 QObject::tr("BUT_OK"));
1575 //=================================================================================
1576 // function : SMESHGUI_GroupDlg::onDeactivate
1577 // purpose : SLOT called when dialog must be deativated
1578 //=================================================================================
1579 void SMESHGUI_GroupDlg::onDeactivate()
1581 mySMESHGUI->ResetState();
1585 //=================================================================================
1586 // function : SMESHGUI_GroupDlg::enterEvent
1587 // purpose : Event filter
1588 //=================================================================================
1589 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1592 mySMESHGUI->EmitSignalDeactivateDialog();
1594 mySelectionMode = -1;
1595 setSelectionMode(myTypeId);
1596 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1597 mySMESHGUI->SetActiveDialogBox(this);
1598 mySMESHGUI->SetState(800);
1602 //=================================================================================
1603 // function : hideEvent
1604 // purpose : caused by ESC key
1605 //=================================================================================
1606 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)