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;
139 bool isEditMode = !CORBA::is_nil( myGroupOnGeom );
140 myHelpFileName = isEditMode ? "/files/editing_groups.htm" : "/files/creating_groups.htm";
143 //=================================================================================
144 // function : SMESHGUI_GroupDlg()
146 //=================================================================================
147 void SMESHGUI_GroupDlg::initDialog(bool create)
151 myCurrentLineEdit = 0;
153 QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
156 setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
158 setCaption(tr("SMESH_EDIT_GROUP_TITLE"));
160 setSizeGripEnabled(TRUE);
162 QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6);
164 /***************************************************************/
165 QLabel* meshGroupLab = new QLabel(this, "mesh/group label");
167 meshGroupLab->setText(tr("SMESH_MESH"));
169 meshGroupLab->setText(tr("SMESH_GROUP"));
170 myMeshGroupBtn = new QPushButton(this, "mesh/group button");
171 myMeshGroupBtn->setPixmap(image0);
172 myMeshGroupLine = new QLineEdit(this, "mesh/group line");
173 myMeshGroupLine->setReadOnly(true);
175 /***************************************************************/
176 myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
177 myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
178 myTypeGroup->setExclusive(true);
181 types.append(tr("MESH_NODE"));
182 types.append(tr("SMESH_EDGE"));
183 types.append(tr("SMESH_FACE"));
184 types.append(tr("SMESH_VOLUME"));
186 for (int i = 0; i < types.count(); i++) {
187 rb = new QRadioButton(types[i], myTypeGroup);
189 myTypeGroup->setEnabled(create);
192 /***************************************************************/
193 QLabel* aName = new QLabel(this, "name label");
194 aName->setText(tr("SMESH_NAME"));
195 aName->setMinimumSize(50,0);
196 myName = new QLineEdit(this, "name");
198 /***************************************************************/
199 myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group");
200 myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE"));
201 myGrpTypeGroup->setExclusive(true);
202 QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup);
203 QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"), myGrpTypeGroup);
204 myGrpTypeGroup->setEnabled(create);
207 /***************************************************************/
208 myWGStack = new QWidgetStack( this, "widget stack");
209 QWidget* wg1 = new QFrame( myWGStack, "first widget" );
210 QWidget* wg2 = new QFrame( myWGStack, "second widget" );
212 /***************************************************************/
213 QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box");
214 aContentBox->setTitle(tr("SMESH_CONTENT"));
215 QFrame* aContent = new QFrame(aContentBox, "content");
216 QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
217 aLayout->setSpacing(6);
218 aLayout->setAutoAdd(false);
220 QLabel* aLabel = new QLabel(aContent, "elements label");
221 aLabel->setText(tr("SMESH_ID_ELEMENTS"));
222 myElements = new QListBox(aContent, "elements list");
223 myElements->setSelectionMode(QListBox::Extended);
225 myFilter = new QPushButton(aContent, "filter");
226 myFilter->setText(tr("SMESH_BUT_FILTER"));
227 QPushButton* aAddBtn = new QPushButton(aContent, "add");
228 aAddBtn->setText(tr("SMESH_BUT_ADD"));
229 QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
230 aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
231 QPushButton* aSortBtn = new QPushButton(aContent, "sort");
232 aSortBtn->setText(tr("SMESH_BUT_SORT"));
234 aLayout->addWidget(aLabel, 0, 0);
235 aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
236 aLayout->addWidget(myFilter, 1, 2);
237 aLayout->addWidget(aAddBtn, 3, 2);
238 aLayout->addWidget(aRemoveBtn, 4, 2);
239 aLayout->addWidget(aSortBtn, 6, 2);
241 aLayout->setColStretch(0, 1);
242 aLayout->addColSpacing(1, 20);
243 aLayout->addColSpacing(3, 20);
244 aLayout->setRowStretch(2, 1);
245 aLayout->setRowStretch(5, 1);
247 /***************************************************************/
248 QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box");
249 aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
251 mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
252 mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
253 mySelectSubMesh->setMinimumSize(50, 0);
254 mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
255 mySubMeshBtn->setText("");
256 mySubMeshBtn->setPixmap(image0);
257 mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
258 mySubMeshLine->setReadOnly(true);
259 onSelectSubMesh(false);
261 mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
262 mySelectGroup->setText(tr("SMESH_GROUP"));
263 mySelectGroup->setMinimumSize(50, 0);
264 myGroupBtn = new QPushButton(aSelectBox, "group button");
265 myGroupBtn->setText("");
266 myGroupBtn->setPixmap(image0);
267 myGroupLine = new QLineEdit(aSelectBox, "group line");
268 myGroupLine->setReadOnly(true);
269 onSelectGroup(false);
271 /***************************************************************/
272 QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
273 wg1Layout->addWidget(aContentBox, 0, 0);
274 wg1Layout->addWidget(aSelectBox, 1, 0);
275 wg1Layout->setRowStretch(2, 5);
277 /***************************************************************/
278 QLabel* geomObject = new QLabel(wg2, "geometry object label");
279 geomObject->setText(tr("SMESH_OBJECT_GEOM"));
280 myGeomGroupBtn = new QPushButton(wg2, "geometry group button");
281 myGeomGroupBtn->setText("");
282 myGeomGroupBtn->setPixmap(image0);
283 myGeomGroupLine = new QLineEdit(wg2, "geometry group line");
284 myGeomGroupLine->setReadOnly(true); //VSR ???
285 onSelectGeomGroup(false);
289 myGeomGroupBtn->setEnabled(false);
290 myGeomGroupLine->setEnabled(false);
293 /***************************************************************/
294 QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
295 wg2Layout->addWidget(geomObject, 0, 0);
296 wg2Layout->addWidget(myGeomGroupBtn, 0, 1);
297 wg2Layout->addWidget(myGeomGroupLine,0, 2);
298 wg2Layout->setRowStretch(1, 5);
300 /***************************************************************/
301 QVBoxLayout* dumb = new QVBoxLayout(myWGStack);
302 dumb->addWidget(wg1);
303 dumb->addWidget(wg2);
304 myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) );
305 myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
307 /***************************************************************/
308 QGroupBox* aColorBox = new QGroupBox(2, Qt::Horizontal, this, "color box");
309 aColorBox->setTitle(tr("SMESH_SET_COLOR"));
311 mySelectColorGroup = new QCheckBox(aColorBox, "color checkbox");
312 mySelectColorGroup->setText(tr("SMESH_CHECK_COLOR"));
314 myColorSpinBox = new QtxIntSpinBox( aColorBox );
315 myColorSpinBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
316 myColorSpinBox->setMinValue( 0 );
317 myColorSpinBox->setMaxValue( 9999 );
319 onSelectColorGroup(false);
321 /***************************************************************/
323 QFrame* aButtons = new QFrame(this, "button box");
324 aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
325 QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
326 aBtnLayout->setAutoAdd(false);
328 QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
329 aOKBtn->setText(tr("SMESH_BUT_OK"));
330 aOKBtn->setAutoDefault(true);
331 aOKBtn->setDefault(true);
332 QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
333 aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
334 aApplyBtn->setAutoDefault(true);
335 QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
336 aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
337 aCloseBtn->setAutoDefault(true);
338 QPushButton* aHelpBtn = new QPushButton(aButtons, "help");
339 aHelpBtn->setText(tr("SMESH_BUT_HELP"));
340 aHelpBtn->setAutoDefault(true);
342 aBtnLayout->addWidget(aOKBtn);
343 aBtnLayout->addWidget(aApplyBtn);
344 aBtnLayout->addStretch();
345 aBtnLayout->addWidget(aCloseBtn);
346 aBtnLayout->addWidget(aHelpBtn);
348 /***************************************************************/
349 aMainLayout->addWidget(meshGroupLab, 0, 0);
350 aMainLayout->addWidget(myMeshGroupBtn, 0, 1);
351 aMainLayout->addWidget(myMeshGroupLine, 0, 2);
352 aMainLayout->addMultiCellWidget(myTypeGroup, 1, 1, 0, 2);
353 aMainLayout->addWidget(aName, 2, 0);
354 aMainLayout->addWidget(myName, 2, 2);
355 aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
356 aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2);
357 aMainLayout->setRowStretch( 5, 5 );
358 aMainLayout->addMultiCellWidget(aColorBox, 6, 6, 0, 2);
359 aMainLayout->addMultiCellWidget(aButtons, 7, 7, 0, 2);
361 /* signals and slots connections */
362 connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
364 connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int)));
366 connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
368 connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
369 connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
371 connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
372 connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
373 connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
374 connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
376 connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
377 connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
378 connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
379 connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
380 connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
381 connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool)));
382 connect(myColorSpinBox, SIGNAL(valueChanged(const QString&)), this, SLOT(onNbColorsChanged(const QString&)));
384 connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
385 connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
386 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
387 connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
390 mySMESHGUI->SetActiveDialogBox(this);
391 mySMESHGUI->SetState(800);
393 mySelectionMode = -1;
394 myMeshFilter = new SMESH_TypeFilter(MESH);
395 mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
396 myGroupFilter = new SMESH_TypeFilter(GROUP);
398 connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
399 connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
400 connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
402 myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
403 onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
405 if (myMesh->_is_nil() )
406 myTypeGroup->setButton(0);
411 //=================================================================================
412 // function : ~SMESHGUI_GroupDlg()
413 // purpose : Destroys the object and frees any allocated resources
414 //=================================================================================
415 SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
417 // no need to delete child widgets, Qt does it all for us
418 if ( myFilterDlg != 0 )
420 myFilterDlg->reparent( 0, QPoint() );
425 //=================================================================================
428 //=================================================================================
429 void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
431 mySelectionMgr->installFilter(myMeshFilter);
433 /* init data from current selection */
434 myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
435 myGroup = SMESH::SMESH_Group::_nil();
436 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
438 myActor = SMESH::FindActorByObject(myMesh);
439 SMESH::SetPickable(myActor);
442 mySelectionMgr->selectedObjects( aList );
443 if( !aList.IsEmpty() )
445 QString aName = aList.First()->getName();
446 myMeshGroupLine->setText(aName) ;
447 myMeshGroupLine->home( false );
450 myCurrentLineEdit = 0;
452 myTypeGroup->setButton(0);
456 //=================================================================================
459 //=================================================================================
460 void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
462 myMesh = theGroup->GetMesh();
464 myName->setText(theGroup->GetName());
467 myColorSpinBox->setValue( theGroup->GetColorNumber() );
469 myMeshGroupLine->setText(theGroup->GetName());
472 switch(theGroup->GetType()) {
473 case SMESH::NODE: aType= 0; break;
474 case SMESH::EDGE: aType = 1; break;
475 case SMESH::FACE: aType = 2; break;
476 case SMESH::VOLUME: aType = 3; break;
478 myTypeGroup->setButton(aType);
480 myGroup = SMESH::SMESH_Group::_narrow( theGroup );
482 if ( !myGroup->_is_nil() )
484 myGrpTypeGroup->setButton(0);
487 myActor = SMESH::FindActorByObject(myMesh);
489 myActor = SMESH::FindActorByObject(myGroup);
490 SMESH::SetPickable(myActor);
492 myCurrentLineEdit = 0;
494 setSelectionMode(aType);
498 if (!myGroup->IsEmpty()) {
499 SMESH::long_array_var anElements = myGroup->GetListOfID();
500 int k = anElements->length();
501 for (int i = 0; i < k; i++) {
502 myIdList.append(anElements[i]);
503 myElements->insertItem(QString::number(anElements[i]));
505 myElements->selectAll(true);
510 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
512 if ( !myGroupOnGeom->_is_nil() )
514 myGrpTypeGroup->setButton(1);
517 myActor = SMESH::FindActorByObject(myMesh);
519 myActor = SMESH::FindActorByObject(myGroup);
520 SMESH::SetPickable(myActor);
522 QString aShapeName("");
523 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
524 GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
525 if (!aGroupShape->_is_nil())
527 _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
528 aShapeName = aGroupShapeSO->GetName().c_str();
530 myGeomGroupLine->setText( aShapeName );
535 //=================================================================================
536 // function : updateButtons()
538 //=================================================================================
539 void SMESHGUI_GroupDlg::updateButtons()
543 if (myGrpTypeId == 0)
544 enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0;
545 else if (myGrpTypeId == 1)
547 bool isEditMode = !CORBA::is_nil( myGroupOnGeom );
548 enable = !myName->text().stripWhiteSpace().isEmpty() && (!CORBA::is_nil( myGeomGroup ) || isEditMode);
551 aBtn = (QPushButton*) child("ok", "QPushButton");
552 if (aBtn) aBtn->setEnabled(enable);
553 aBtn = (QPushButton*) child("apply", "QPushButton");
554 if (aBtn) aBtn->setEnabled(enable);
557 //=================================================================================
558 // function : onNameChanged()
560 //=================================================================================
561 void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
566 //=================================================================================
567 // function : onNbColorsChanged()
569 //=================================================================================
570 void SMESHGUI_GroupDlg::onNbColorsChanged (const QString& text)
575 //=================================================================================
576 // function : onTypeChanged()
577 // purpose : Group elements type radio button management
578 //=================================================================================
579 void SMESHGUI_GroupDlg::onTypeChanged (int id)
581 if (myTypeId != id) {
583 if (myCurrentLineEdit == 0)
584 setSelectionMode(id);
589 //=================================================================================
590 // function : onGrpTypeChanged()
591 // purpose : Group type radio button management
592 //=================================================================================
593 void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
595 if (myGrpTypeId != id) {
596 myWGStack->raiseWidget( id );
597 onSelectGeomGroup(id == 1);
602 //=================================================================================
603 // function : setSelectionMode()
604 // purpose : Radio button management
605 //=================================================================================
606 void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
609 if (myMesh->_is_nil())
612 if (mySelectionMode != theMode) {
613 // [PAL10408] mySelectionMgr->clearSelected();
614 mySelectionMgr->clearFilters();
615 SMESH::SetPointRepresentation(false);
620 myActor->SetPointRepresentation(true);
622 SMESH::SetPointRepresentation(true);
623 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
624 aViewWindow->SetSelectionMode(NodeSelection);
627 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
628 aViewWindow->SetSelectionMode(EdgeSelection);
631 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
632 aViewWindow->SetSelectionMode(FaceSelection);
635 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
636 aViewWindow->SetSelectionMode(VolumeSelection);
640 mySelectionMgr->installFilter(mySubMeshFilter);
641 else if (theMode == 5)
642 mySelectionMgr->installFilter(myGroupFilter);
643 else if (theMode == 6)
644 mySelectionMgr->installFilter(myMeshFilter);
645 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
646 aViewWindow->SetSelectionMode(ActorSelection);
648 mySelectionMode = theMode;
652 //=================================================================================
653 // function : onApply()
655 //=================================================================================
656 bool SMESHGUI_GroupDlg::onApply()
658 if (mySMESHGUI->isActiveStudyLocked())
661 if (myGrpTypeId == 0 &&
662 !myName->text().stripWhiteSpace().isEmpty() &&
663 myElements->count() > 0) {
664 mySelectionMgr->clearSelected();
665 if (myGroup->_is_nil()) {
666 SMESH::ElementType aType = SMESH::ALL;
668 case 0: aType = SMESH::NODE; break;
669 case 1: aType = SMESH::EDGE; break;
670 case 2: aType = SMESH::FACE; break;
671 case 3: aType = SMESH::VOLUME; break;
673 SMESH::long_array_var anIdList = new SMESH::long_array;
674 int i, k = myElements->count();
676 QListBoxItem* anItem;
677 for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
678 anIdList[i] = anItem->text().toInt();
681 myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
682 myGroup->Add(anIdList.inout());
684 int aColorNumber = myColorSpinBox->value();
685 myGroup->SetColorNumber(aColorNumber);
687 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
689 SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
691 SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
693 /* init for next operation */
695 myColorSpinBox->setValue(0);
697 myGroup = SMESH::SMESH_Group::_nil();
700 myGroup->SetName(myName->text());
702 int aColorNumber = myColorSpinBox->value();
703 myGroup->SetColorNumber(aColorNumber);
705 QValueList<int> aAddList;
706 QValueList<int>::iterator anIt;
707 QListBoxItem* anItem;
709 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
710 int anId = anItem->text().toInt();
711 if ((anIt = myIdList.find(anId)) == myIdList.end())
712 aAddList.append(anId);
714 myIdList.remove(anIt);
716 if (!aAddList.empty()) {
717 SMESH::long_array_var anIdList = new SMESH::long_array;
718 anIdList->length(aAddList.count());
720 for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
722 myGroup->Add(anIdList.inout());
724 if (!myIdList.empty()) {
725 SMESH::long_array_var anIdList = new SMESH::long_array;
726 anIdList->length(myIdList.count());
728 for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
730 myGroup->Remove(anIdList.inout());
732 /* init for next operation */
734 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
735 myIdList.append(anItem->text().toInt());
738 mySMESHGUI->updateObjBrowser(true);
739 SMESH::UpdateView(); // asv: fix of BUG PAL5515
740 mySelectionMgr->clearSelected();
742 } else if (myGrpTypeId == 1 &&
743 !myName->text().stripWhiteSpace().isEmpty() &&
744 (!CORBA::is_nil(myGeomGroup) || !CORBA::is_nil(myGroupOnGeom)))
746 if (myGroupOnGeom->_is_nil()) {
747 SMESH::ElementType aType = SMESH::ALL;
749 case 0: aType = SMESH::NODE; break;
750 case 1: aType = SMESH::EDGE; break;
751 case 2: aType = SMESH::FACE; break;
752 case 3: aType = SMESH::VOLUME; break;
755 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
756 GEOM::GEOM_IGroupOperations_var aGroupOp =
757 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
759 myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup);
761 int aColorNumber = myColorSpinBox->value();
762 myGroupOnGeom->SetColorNumber(aColorNumber);
764 _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
766 SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
768 SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
770 /* init for next operation */
772 myColorSpinBox->setValue(0);
773 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
777 myGroupOnGeom->SetName(myName->text());
779 int aColorNumber = myColorSpinBox->value();
780 myGroupOnGeom->SetColorNumber(aColorNumber);
783 mySMESHGUI->updateObjBrowser(true);
784 mySelectionMgr->clearSelected();
791 //=================================================================================
794 //=================================================================================
795 void SMESHGUI_GroupDlg::onOK()
801 //=================================================================================
802 // function : onListSelectionChanged()
803 // purpose : Called when selection in element list is changed
804 //=================================================================================
805 void SMESHGUI_GroupDlg::onListSelectionChanged()
807 // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
808 if( myIsBusy || !myActor) return;
811 if (myCurrentLineEdit == 0) {
812 mySelectionMgr->clearSelected();
813 TColStd_MapOfInteger aIndexes;
814 QListBoxItem* anItem;
815 for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
816 if (anItem->isSelected()) {
817 int anId = anItem->text().toInt();
821 mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
823 aList.Append(myActor->getIO());
824 mySelectionMgr->setSelectedObjects(aList,false);
829 //=================================================================================
830 // function : onObjectSelectionChanged()
831 // purpose : Called when selection in 3D view or ObjectBrowser is changed
832 //=================================================================================
833 void SMESHGUI_GroupDlg::onObjectSelectionChanged()
835 if ( myIsBusy || !isEnabled()) return;
839 mySelectionMgr->selectedObjects( aList );
841 int aNbSel = aList.Extent();
842 myElements->clearSelection();
844 if (myCurrentLineEdit) {
845 myCurrentLineEdit->setText("");
846 QString aString = "";
848 if (myCurrentLineEdit == myMeshGroupLine) {
849 mySelectSubMesh->setEnabled(false);
850 mySelectGroup->setEnabled(false);
851 myGroupLine->setText("");
852 mySubMeshLine->setText("");
854 myGeomGroupBtn->setEnabled(false);
855 myGeomGroupLine->setEnabled(false);
856 myGeomGroupLine->setText("");
863 myGroup = SMESH::SMESH_Group::_nil();
864 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
865 myMesh = SMESH::SMESH_Mesh::_nil();
869 Handle(SALOME_InteractiveObject) IO = aList.First();
872 myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
873 if (myMesh->_is_nil())
878 myGroup = SMESH::SMESH_Group::_nil();
880 myActor = SMESH::FindActorByObject(myMesh);
881 SMESH::SetPickable(myActor);
883 aString = aList.First()->getName();
884 myMeshGroupLine->setText(aString) ;
885 myMeshGroupLine->home( false );
887 mySelectSubMesh->setEnabled(true);
888 mySelectGroup->setEnabled(true);
889 myGeomGroupBtn->setEnabled(true);
890 myGeomGroupLine->setEnabled(true);
893 SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
894 if (aGroup->_is_nil())
900 myCurrentLineEdit = 0;
902 myGroup = SMESH::SMESH_Group::_nil();
903 myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
907 mySelectSubMesh->setEnabled(true);
908 mySelectGroup->setEnabled(true);
910 myCurrentLineEdit = 0;
919 setSelectionMode(myTypeId);
925 } else if (myCurrentLineEdit == myGeomGroupLine) {
927 myGeomGroup = GEOM::GEOM_Object::_nil();
932 Standard_Boolean testResult = Standard_False;
933 myGeomGroup = GEOMBase::ConvertIOinGEOMObject(aList.First(), testResult);
935 // Check if the object is a geometry group
936 if (!testResult || CORBA::is_nil(myGeomGroup)) {
937 myGeomGroup = GEOM::GEOM_Object::_nil();
941 // Check if group constructed on the same shape as a mesh or on its child
942 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
943 GEOM::GEOM_IGroupOperations_var anOp =
944 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
946 // The main shape of the group
947 GEOM::GEOM_Object_var aGroupMainShape;
948 if (myGeomGroup->GetType() == 37)
949 aGroupMainShape = anOp->GetMainShape(myGeomGroup);
951 aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup);
952 _PTR(SObject) aGroupMainShapeSO =
953 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
954 aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
957 _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
959 myGeomGroup = GEOM::GEOM_Object::_nil();
963 _PTR(SObject) anObj, aRef;
964 bool isRefOrSubShape = false;
965 if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
966 //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
967 if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
968 isRefOrSubShape = true;
970 _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
971 _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
972 //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
973 while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
974 //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
975 if (aRef->GetID() == aFather->GetID())
976 isRefOrSubShape = true;
978 aFather = aFather->GetFather();
982 if (!isRefOrSubShape) {
983 myGeomGroup = GEOM::GEOM_Object::_nil();
991 if(myCurrentLineEdit == mySubMeshLine)
992 aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
993 else if(myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine)
994 aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
996 aString = aList.First()->getName();
1000 myCurrentLineEdit->setText(aString);
1001 myCurrentLineEdit->home(false);
1006 if (aNbSel == 1 && myActor ) {
1007 QString aListStr = "";
1009 if (myTypeId == 0) {
1010 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1012 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1015 QStringList anElements = QStringList::split(" ", aListStr);
1016 QListBoxItem* anItem = 0;
1017 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1018 anItem = myElements->findItem(*it, Qt::ExactMatch);
1019 if (anItem) myElements->setSelected(anItem, true);
1026 if (!myGroup->_is_nil())
1027 myActor = SMESH::FindActorByObject(myGroup);
1028 else if(!myGroupOnGeom->_is_nil())
1029 myActor = SMESH::FindActorByObject(myGroupOnGeom);
1031 myActor = SMESH::FindActorByObject(myMesh);
1037 //=================================================================================
1038 // function : onSelectSubMesh()
1039 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1040 //=================================================================================
1041 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1044 if (mySelectGroup->isChecked()) {
1045 mySelectGroup->setChecked(false);
1047 //VSR: else if (mySelectGeomGroup->isChecked()) {
1048 //VSR: mySelectGeomGroup->setChecked(false);
1050 myCurrentLineEdit = mySubMeshLine;
1051 setSelectionMode(4);
1054 mySubMeshLine->setText("");
1055 myCurrentLineEdit = 0;
1057 setSelectionMode(myTypeId);
1059 mySubMeshBtn->setEnabled(on);
1060 mySubMeshLine->setEnabled(on);
1064 //=================================================================================
1065 // function : (onSelectGroup)
1066 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1067 //=================================================================================
1068 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1071 if (mySelectSubMesh->isChecked()) {
1072 mySelectSubMesh->setChecked(false);
1074 myCurrentLineEdit = myGroupLine;
1075 setSelectionMode(5);
1078 myGroupLine->setText("");
1079 myCurrentLineEdit = 0;
1081 setSelectionMode(myTypeId);
1083 myGroupBtn->setEnabled(on);
1084 myGroupLine->setEnabled(on);
1088 //=================================================================================
1089 // function : (onSelectGeomGroup)
1090 // purpose : Called when selection in 3D view or ObjectBrowser is changed
1091 //=================================================================================
1092 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1095 if (mySelectSubMesh->isChecked()) {
1096 mySelectSubMesh->setChecked(false);
1098 else if (mySelectGroup->isChecked()) {
1099 mySelectGroup->setChecked(false);
1101 myCurrentLineEdit = myGeomGroupLine;
1102 setSelectionMode(7);
1105 myGeomGroupLine->setText("");
1106 myCurrentLineEdit = 0;
1108 setSelectionMode(myTypeId);
1112 //=================================================================================
1113 // function : (onSelectColorGroup)
1114 // purpose : Called when setting a color on group
1115 //=================================================================================
1116 void SMESHGUI_GroupDlg::onSelectColorGroup(bool on)
1119 setSelectionMode(7);
1122 myColorSpinBox->setValue(0);
1123 myCurrentLineEdit = 0;
1125 setSelectionMode(myTypeId);
1127 myColorSpinBox->setEnabled(on);
1130 //=================================================================================
1131 // function : setCurrentSelection()
1133 //=================================================================================
1134 void SMESHGUI_GroupDlg::setCurrentSelection()
1136 QPushButton* send = (QPushButton*)sender();
1137 myCurrentLineEdit = 0;
1138 if (send == myMeshGroupBtn) {
1139 myCurrentLineEdit = myMeshGroupLine;
1141 setSelectionMode(6);
1143 setSelectionMode(5);
1144 onObjectSelectionChanged();
1146 else if (send == mySubMeshBtn) {
1147 myCurrentLineEdit = mySubMeshLine;
1148 onObjectSelectionChanged();
1150 else if (send == myGroupBtn) {
1151 myCurrentLineEdit = myGroupLine;
1152 onObjectSelectionChanged();
1154 else if (send == myGeomGroupBtn) {
1155 myCurrentLineEdit = myGeomGroupLine;
1156 setSelectionMode(7);
1157 onObjectSelectionChanged();
1162 //=================================================================================
1163 // function : setFilters()
1164 // purpose : SLOT. Called when "Filter" button pressed.
1165 //=================================================================================
1166 void SMESHGUI_GroupDlg::setFilters()
1168 SMESH::ElementType aType = SMESH::ALL;
1171 case 0 : aType = SMESH::NODE; break;
1172 case 1 : aType = SMESH::EDGE; break;
1173 case 2 : aType = SMESH::FACE; break;
1174 case 3 : aType = SMESH::VOLUME; break;
1178 if ( myFilterDlg == 0 )
1180 myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1181 connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1184 myFilterDlg->Init( aType );
1186 myFilterDlg->SetSelection();
1187 myFilterDlg->SetMesh( myMesh );
1188 myFilterDlg->SetSourceWg( myElements );
1190 myFilterDlg->show();
1193 //=================================================================================
1194 // function : onFilterAccepted()
1195 // purpose : SLOT. Called when Filter dlg closed with OK button.
1196 // Uncheck "Select submesh" and "Select group" checkboxes
1197 //=================================================================================
1198 void SMESHGUI_GroupDlg::onFilterAccepted()
1200 if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1202 mySelectionMode = myTypeId;
1203 mySelectSubMesh->setChecked( false );
1204 mySelectGroup->setChecked( false );
1208 //=================================================================================
1209 // function : onAdd()
1211 //=================================================================================
1212 void SMESHGUI_GroupDlg::onAdd()
1214 SALOME_ListIO aList;
1215 mySelectionMgr->selectedObjects( aList );
1217 int aNbSel = aList.Extent();
1219 if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1223 SMESH::ElementType aType = SMESH::ALL;
1226 aType = SMESH::NODE;
1227 mySelector->SetSelectionMode(NodeSelection);
1230 aType = SMESH::EDGE;
1231 mySelector->SetSelectionMode(EdgeSelection);
1234 aType = SMESH::FACE;
1235 mySelector->SetSelectionMode(FaceSelection);
1238 aType = SMESH::VOLUME;
1239 mySelector->SetSelectionMode(VolumeSelection);
1242 mySelector->SetSelectionMode(ActorSelection);
1246 if (myCurrentLineEdit == 0) {
1247 //if (aNbSel != 1) { myIsBusy = false; return; }
1248 QString aListStr = "";
1250 if (myTypeId == 0) {
1251 aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1254 aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1257 QStringList anElements = QStringList::split(" ", aListStr);
1258 QListBoxItem* anItem = 0;
1259 for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1260 anItem = myElements->findItem(*it, Qt::ExactMatch);
1262 anItem = new QListBoxText(*it);
1263 myElements->insertItem(anItem);
1265 myElements->setSelected(anItem, true);
1268 } else if (myCurrentLineEdit == mySubMeshLine) {
1269 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1271 SALOME_ListIO aList;
1272 mySelectionMgr->selectedObjects( aList );
1274 SALOME_ListIteratorOfListIO anIt (aList);
1275 for (; anIt.More(); anIt.Next()) {
1276 SMESH::SMESH_subMesh_var aSubMesh =
1277 SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1278 if (!aSubMesh->_is_nil()) {
1279 // check if mesh is the same
1280 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1282 SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1283 int k = anElements->length();
1284 QListBoxItem* anItem = 0;
1285 for (int i = 0; i < k; i++) {
1286 QString aText = QString::number(anElements[i]);
1287 anItem = myElements->findItem(aText, Qt::ExactMatch);
1289 anItem = new QListBoxText(aText);
1290 myElements->insertItem(anItem);
1292 myElements->setSelected(anItem, true);
1295 catch (const SALOME::SALOME_Exception& ex) {
1296 SalomeApp_Tools::QtCatchCorbaException(ex);
1301 mySelectSubMesh->setChecked(false);
1303 onListSelectionChanged();
1305 } else if (myCurrentLineEdit == myGroupLine) {
1306 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1307 SALOME_ListIO aList;
1308 mySelectionMgr->selectedObjects( aList );
1310 SALOME_ListIteratorOfListIO anIt (aList);
1311 for (; anIt.More(); anIt.Next()) {
1312 SMESH::SMESH_Group_var aGroup =
1313 SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1314 if (!aGroup->_is_nil()) {
1315 // check if mesh is the same
1316 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1317 SMESH::long_array_var anElements = aGroup->GetListOfID();
1318 int k = anElements->length();
1319 QListBoxItem* anItem = 0;
1320 for (int i = 0; i < k; i++) {
1321 QString aText = QString::number(anElements[i]);
1322 anItem = myElements->findItem(aText, Qt::ExactMatch);
1324 anItem = new QListBoxText(aText);
1325 myElements->insertItem(anItem);
1327 myElements->setSelected(anItem, true);
1332 mySelectGroup->setChecked(false);
1334 onListSelectionChanged();
1336 } else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) {
1337 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1338 GEOM::GEOM_IGroupOperations_var aGroupOp =
1339 SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1341 SMESH::ElementType aGroupType = SMESH::ALL;
1342 switch(aGroupOp->GetType(myGeomGroup)) {
1343 case 7: aGroupType = SMESH::NODE; break;
1344 case 6: aGroupType = SMESH::EDGE; break;
1345 case 4: aGroupType = SMESH::FACE; break;
1346 case 2: aGroupType = SMESH::VOLUME; break;
1347 default: myIsBusy = false; return;
1350 if (aGroupType == aType) {
1351 _PTR(SObject) aGroupSO =
1352 //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1353 aStudy->FindObjectID(myGeomGroup->GetStudyEntry());
1355 SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1356 SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1357 SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1358 aBelongToGeom->SetGeom(myGeomGroup);
1359 aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1360 aBelongToGeom->SetElementType(aType);
1361 aFilter->SetPredicate(aBelongToGeom);
1363 SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1365 int k = anElements->length();
1366 QListBoxItem* anItem = 0;
1367 for (int i = 0; i < k; i++) {
1368 QString aText = QString::number(anElements[i]);
1369 anItem = myElements->findItem(aText, Qt::ExactMatch);
1371 anItem = new QListBoxText(aText);
1372 myElements->insertItem(anItem);
1374 myElements->setSelected(anItem, true);
1378 //VSR: mySelectGeomGroup->setChecked(false);
1380 onListSelectionChanged();
1383 // mySelectionMgr->clearSelected();
1387 //=================================================================================
1388 // function : onRemove()
1390 //=================================================================================
1391 void SMESHGUI_GroupDlg::onRemove()
1394 if (myCurrentLineEdit == 0) {
1395 for (int i = myElements->count(); i > 0; i--) {
1396 if (myElements->isSelected(i-1)) {
1397 myElements->removeItem(i-1);
1401 SALOME_ListIO aList;
1402 mySelectionMgr->selectedObjects( aList );
1404 int aNbSel = aList.Extent();
1406 if (aNbSel == 0) { myIsBusy = false; return; }
1408 SMESH::ElementType aType = SMESH::ALL;
1410 case 0: aType = SMESH::NODE; break;
1411 case 1: aType = SMESH::EDGE; break;
1412 case 2: aType = SMESH::FACE; break;
1413 case 3: aType = SMESH::VOLUME; break;
1416 if (myCurrentLineEdit == mySubMeshLine) {
1417 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1418 SALOME_ListIO aList;
1419 mySelectionMgr->selectedObjects( aList );
1421 SALOME_ListIteratorOfListIO anIt (aList);
1422 for (; anIt.More(); anIt.Next()) {
1423 SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1424 if (!aSubMesh->_is_nil()) {
1425 // check if mesh is the same
1426 if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1427 if (aType == SMESH::NODE) {
1429 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1430 int k = anElements->length();
1431 QListBoxItem* anItem = 0;
1432 for (int i = 0; i < k; i++) {
1433 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1434 if (anItem) delete anItem;
1437 catch (const SALOME::SALOME_Exception& ex) {
1438 SalomeApp_Tools::QtCatchCorbaException(ex);
1443 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1444 int k = anElements->length();
1445 QListBoxItem* anItem = 0;
1446 for (int i = 0; i < k; i++) {
1447 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1448 if (anItem) delete anItem;
1451 catch (const SALOME::SALOME_Exception& ex) {
1452 SalomeApp_Tools::QtCatchCorbaException(ex);
1459 else if (myCurrentLineEdit == myGroupLine) {
1460 Standard_Boolean aRes;
1461 //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1462 SALOME_ListIO aList;
1463 mySelectionMgr->selectedObjects( aList );
1465 SALOME_ListIteratorOfListIO anIt (aList);
1466 for (; anIt.More(); anIt.Next()) {
1467 SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1468 if (aRes && !aGroup->_is_nil()) {
1469 // check if mesh is the same
1470 if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1471 SMESH::long_array_var anElements = aGroup->GetListOfID();
1472 int k = anElements->length();
1473 QListBoxItem* anItem = 0;
1474 for (int i = 0; i < k; i++) {
1475 anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1476 if (anItem) delete anItem;
1487 //=================================================================================
1488 // function : onSort()
1490 //=================================================================================
1491 void SMESHGUI_GroupDlg::onSort()
1493 // PAL5412: sorts items in ascending by "string" value
1494 // myElements->sort(true);
1495 // myElements->update();
1496 int i, k = myElements->count();
1499 QStringList aSelected;
1500 std::vector<int> anArray(k);
1501 // QMemArray<int> anArray(k);
1502 QListBoxItem* anItem;
1504 for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1505 anArray[i] = anItem->text().toInt();
1506 if (anItem->isSelected())
1507 aSelected.append(anItem->text());
1509 // sort & update list
1510 std::sort(anArray.begin(), anArray.end());
1512 myElements->clear();
1513 for (i = 0; i < k; i++) {
1514 myElements->insertItem(QString::number(anArray[i]));
1516 for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1517 anItem = myElements->findItem(*it, Qt::ExactMatch);
1518 if (anItem) myElements->setSelected(anItem, true);
1524 //=================================================================================
1525 // function : closeEvent()
1527 //=================================================================================
1528 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1533 //=================================================================================
1534 // function : SMESHGUI_GroupDlg::onClose
1535 // purpose : SLOT called when "Close" button pressed. Close dialog
1536 //=================================================================================
1537 void SMESHGUI_GroupDlg::onClose()
1539 if (SMESH::GetCurrentVtkView()) {
1540 SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1541 SMESH::SetPointRepresentation(false);
1542 SMESH::SetPickable();
1545 mySelectionMgr->clearSelected();
1546 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1547 aViewWindow->SetSelectionMode(ActorSelection);
1548 mySelectionMgr->clearFilters();
1549 mySMESHGUI->ResetState();
1554 //=================================================================================
1555 // function : onHelp()
1557 //=================================================================================
1558 void SMESHGUI_GroupDlg::onHelp()
1560 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1562 app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
1564 SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
1565 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1566 arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
1567 QObject::tr("BUT_OK"));
1571 //=================================================================================
1572 // function : SMESHGUI_GroupDlg::onDeactivate
1573 // purpose : SLOT called when dialog must be deativated
1574 //=================================================================================
1575 void SMESHGUI_GroupDlg::onDeactivate()
1577 mySMESHGUI->ResetState();
1581 //=================================================================================
1582 // function : SMESHGUI_GroupDlg::enterEvent
1583 // purpose : Event filter
1584 //=================================================================================
1585 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1588 mySMESHGUI->EmitSignalDeactivateDialog();
1590 mySelectionMode = -1;
1591 setSelectionMode(myTypeId);
1592 //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1593 mySMESHGUI->SetActiveDialogBox(this);
1594 mySMESHGUI->SetState(800);
1598 //=================================================================================
1599 // function : hideEvent
1600 // purpose : caused by ESC key
1601 //=================================================================================
1602 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)