Salome HOME
Merging with WPdev
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_GroupDlg.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SMESHGUI_GroupDlg.cxx
25 //  Author : Natalia KOPNOVA
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESHGUI_GroupDlg.h"
30 #include "SMESHGUI_FilterDlg.h"
31 #include "SMESHGUI_ShapeByMeshDlg.h"
32
33 #include "SMESHGUI.h"
34 #include "SMESHGUI_Utils.h"
35 #include "SMESHGUI_VTKUtils.h"
36 #include "SMESHGUI_MeshUtils.h"
37 #include "SMESHGUI_GroupUtils.h"
38 #include "SMESHGUI_FilterUtils.h"
39 #include "SMESHGUI_GEOMGenUtils.h"
40
41 #include "SMESH_TypeFilter.hxx"
42 #include "SMESH_Actor.h"
43
44 #include "GEOMBase.h"
45 #include "GEOM_SelectionFilter.h"
46
47 #include "SUIT_Desktop.h"
48 #include "SUIT_ResourceMgr.h"
49 #include "SUIT_Session.h"
50 #include "SUIT_MessageBox.h"
51
52 #include "SalomeApp_Tools.h"
53 #include "SalomeApp_Application.h"
54 #include "SalomeApp_Study.h"
55 #include "LightApp_Application.h"
56 #include "SALOMEDSClient_Study.hxx"
57 #include "SALOME_ListIO.hxx"
58 #include "SALOME_ListIteratorOfListIO.hxx"
59
60 #include "SVTK_ViewWindow.h"
61 #include "SVTK_Selector.h"
62
63 #include "utilities.h"
64
65 // OCCT Includes
66 #include <TColStd_MapOfInteger.hxx>
67
68 // QT Includes
69 #include <qbuttongroup.h>
70 #include <qcursor.h>
71 #include <qgroupbox.h>
72 #include <qhbox.h>
73 #include <qlabel.h>
74 #include <qlineedit.h>
75 #include <qpushbutton.h>
76 #include <qtoolbutton.h>
77 #include <qradiobutton.h>
78 #include <qcheckbox.h>
79 #include <qlayout.h>
80 #include <qlistbox.h>
81 #include <qimage.h>
82 #include <qpixmap.h>
83 #include <qmemarray.h>
84 #include <qwidgetstack.h>
85
86 #include <QtxIntSpinBox.h>
87
88 // STL includes
89 #include <vector>
90 #include <algorithm>
91
92 using namespace std;
93
94 //=================================================================================
95 // function : SMESHGUI_GroupDlg()
96 // purpose  :
97 //=================================================================================
98 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
99                                       SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl)
100      : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
101                 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
102      mySMESHGUI( theModule ),
103      mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
104      mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
105      myIsBusy( false ),
106      myActor( 0 )
107 {
108   if (!name) setName("SMESHGUI_GroupDlg");
109   initDialog(true);
110   if (!theMesh->_is_nil())
111     init(theMesh);
112   else {
113     mySelectSubMesh->setEnabled(false);
114     mySelectGroup->setEnabled(false);
115     myGeomGroupBtn->setEnabled(false);
116     myGeomGroupLine->setEnabled(false);
117   }
118 }
119
120 //=================================================================================
121 // function : SMESHGUI_GroupDlg()
122 // purpose  :
123 //=================================================================================
124 SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( SMESHGUI* theModule, const char* name,
125                                       SMESH::SMESH_GroupBase_ptr theGroup, bool modal, WFlags fl)
126      : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
127                 WStyle_Title | WStyle_SysMenu | WDestructiveClose),
128      mySMESHGUI( theModule ),
129      mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
130      mySelector(SMESH::GetViewWindow( theModule )->GetSelector()),
131      myIsBusy( false )
132 {
133   if (!name) setName("SMESHGUI_GroupDlg");
134
135   initDialog(false);
136   if (!theGroup->_is_nil())
137     init(theGroup);
138   else {
139     mySelectSubMesh->setEnabled(false);
140     mySelectGroup->setEnabled(false);
141
142     myCurrentLineEdit = myMeshGroupLine;
143     setSelectionMode(5);
144   }
145 }
146
147 //=================================================================================
148 // function : SMESHGUI_GroupDlg()
149 // purpose  :
150 //=================================================================================
151 void SMESHGUI_GroupDlg::initDialog(bool create)
152 {
153   myFilterDlg = 0;
154   myCreate = create;
155   myCurrentLineEdit = 0;
156
157   myShapeByMeshOp = 0;
158   myGeomPopup = 0;
159   myGeomObjects = new GEOM::ListOfGO();
160   myGeomObjects->length(0);
161
162   QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
163
164   if (create) {
165     setCaption(tr("SMESH_CREATE_GROUP_TITLE"));
166     myHelpFileName = "/files/creating_groups.htm";
167   }
168   else {
169     setCaption(tr("SMESH_EDIT_GROUP_TITLE"));
170     myHelpFileName = "/files/editing_groups.htm";
171   }
172
173   setSizeGripEnabled(TRUE);
174
175   QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6);
176
177   /***************************************************************/
178   QLabel* meshGroupLab = new QLabel(this, "mesh/group label");
179   if (create)
180     meshGroupLab->setText(tr("SMESH_MESH"));
181   else
182     meshGroupLab->setText(tr("SMESH_GROUP"));
183   myMeshGroupBtn = new QPushButton(this, "mesh/group button");
184   myMeshGroupBtn->setPixmap(image0);
185   myMeshGroupLine = new QLineEdit(this, "mesh/group line");
186   myMeshGroupLine->setReadOnly(true);
187
188   /***************************************************************/
189   myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types");
190   myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE"));
191   myTypeGroup->setExclusive(true);
192
193   QStringList types;
194   types.append(tr("MESH_NODE"));
195   types.append(tr("SMESH_EDGE"));
196   types.append(tr("SMESH_FACE"));
197   types.append(tr("SMESH_VOLUME"));
198   QRadioButton* rb;
199   for (int i = 0; i < types.count(); i++) {
200     rb = new QRadioButton(types[i], myTypeGroup);
201   }
202   myTypeGroup->setEnabled(create);
203   myTypeId = -1;
204
205   /***************************************************************/
206   QLabel* aName = new QLabel(this, "name label");
207   aName->setText(tr("SMESH_NAME"));
208   aName->setMinimumSize(50,0);
209   myName = new QLineEdit(this, "name");
210
211   /***************************************************************/
212   myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group");
213   myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE"));
214   myGrpTypeGroup->setExclusive(true);
215   QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup);
216   QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"),   myGrpTypeGroup);
217   myGrpTypeGroup->setEnabled(create);
218   myGrpTypeId = -1;
219
220   /***************************************************************/
221   myWGStack = new QWidgetStack( this, "widget stack");
222   QWidget* wg1 = new QFrame( myWGStack, "first widget" );
223   QWidget* wg2 = new QFrame( myWGStack, "second widget" );
224
225   /***************************************************************/
226   QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box");
227   aContentBox->setTitle(tr("SMESH_CONTENT"));
228   QFrame* aContent = new QFrame(aContentBox, "content");
229   QGridLayout* aLayout = new QGridLayout(aContent, 7, 4);
230   aLayout->setSpacing(6);
231   aLayout->setAutoAdd(false);
232
233   QLabel* aLabel = new QLabel(aContent, "elements label");
234   aLabel->setText(tr("SMESH_ID_ELEMENTS"));
235   myElements = new QListBox(aContent, "elements list");
236   myElements->setSelectionMode(QListBox::Extended);
237
238   myFilter = new QPushButton(aContent, "filter");
239   myFilter->setText(tr("SMESH_BUT_FILTER"));
240   QPushButton* aAddBtn = new QPushButton(aContent, "add");
241   aAddBtn->setText(tr("SMESH_BUT_ADD"));
242   QPushButton* aRemoveBtn = new QPushButton(aContent, "remove");
243   aRemoveBtn->setText(tr("SMESH_BUT_REMOVE"));
244   QPushButton* aSortBtn = new QPushButton(aContent, "sort");
245   aSortBtn->setText(tr("SMESH_BUT_SORT"));
246
247   aLayout->addWidget(aLabel, 0, 0);
248   aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0);
249   aLayout->addWidget(myFilter, 1, 2);
250   aLayout->addWidget(aAddBtn, 3, 2);
251   aLayout->addWidget(aRemoveBtn, 4, 2);
252   aLayout->addWidget(aSortBtn, 6, 2);
253
254   aLayout->setColStretch(0, 1);
255   aLayout->addColSpacing(1, 20);
256   aLayout->addColSpacing(3, 20);
257   aLayout->setRowStretch(2, 1);
258   aLayout->setRowStretch(5, 1);
259
260   /***************************************************************/
261   QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box");
262   aSelectBox->setTitle(tr("SMESH_SELECT_FROM"));
263
264   mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox");
265   mySelectSubMesh->setText(tr("SMESH_SUBMESH"));
266   mySelectSubMesh->setMinimumSize(50, 0);
267   mySubMeshBtn = new QPushButton(aSelectBox, "submesh button");
268   mySubMeshBtn->setText("");
269   mySubMeshBtn->setPixmap(image0);
270   mySubMeshLine = new QLineEdit(aSelectBox, "submesh line");
271   mySubMeshLine->setReadOnly(true);
272   onSelectSubMesh(false);
273
274   mySelectGroup = new QCheckBox(aSelectBox, "group checkbox");
275   mySelectGroup->setText(tr("SMESH_GROUP"));
276   mySelectGroup->setMinimumSize(50, 0);
277   myGroupBtn = new QPushButton(aSelectBox, "group button");
278   myGroupBtn->setText("");
279   myGroupBtn->setPixmap(image0);
280   myGroupLine = new QLineEdit(aSelectBox, "group line");
281   myGroupLine->setReadOnly(true);
282   onSelectGroup(false);
283   
284   /***************************************************************/
285   QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 );
286   wg1Layout->addWidget(aContentBox, 0, 0);
287   wg1Layout->addWidget(aSelectBox, 1, 0);
288   wg1Layout->setRowStretch(2, 5);
289
290   /***************************************************************/
291   QLabel* geomObject = new QLabel(wg2, "geometry object label");
292   geomObject->setText(tr("SMESH_OBJECT_GEOM"));
293   myGeomGroupBtn = new QToolButton(wg2, "geometry group button");
294   myGeomGroupBtn->setIconSet( QIconSet(image0) );
295   myGeomGroupBtn->setToggleButton(true);
296   myGeomGroupLine = new QLineEdit(wg2, "geometry group line");
297   myGeomGroupLine->setReadOnly(true); //VSR ???
298   onSelectGeomGroup(false);
299   
300   if (!create)
301     {
302       myGeomGroupBtn->setEnabled(false);
303       myGeomGroupLine->setEnabled(false);
304     }
305    
306   /***************************************************************/
307   QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 );
308   wg2Layout->addWidget(geomObject,     0, 0);
309   wg2Layout->addWidget(myGeomGroupBtn, 0, 1);
310   wg2Layout->addWidget(myGeomGroupLine,0, 2);
311   wg2Layout->setRowStretch(1, 5);
312
313   /***************************************************************/
314   QVBoxLayout* dumb = new QVBoxLayout(myWGStack);
315   dumb->addWidget(wg1);
316   dumb->addWidget(wg2);
317   myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) );
318   myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) );
319
320   /***************************************************************/
321   QGroupBox* aColorBox = new QGroupBox(2, Qt::Horizontal, this, "color box");
322   aColorBox->setTitle(tr("SMESH_SET_COLOR"));
323
324   mySelectColorGroup = new QCheckBox(aColorBox, "color checkbox");
325   mySelectColorGroup->setText(tr("SMESH_CHECK_COLOR"));
326   
327   myColorSpinBox = new QtxIntSpinBox( aColorBox );
328   myColorSpinBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
329   myColorSpinBox->setMinValue( 0 );
330   myColorSpinBox->setMaxValue( 9999 );
331   
332   onSelectColorGroup(false);
333   
334   /***************************************************************/
335   
336   QFrame* aButtons = new QFrame(this, "button box");
337   aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken);
338   QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6);
339   aBtnLayout->setAutoAdd(false);
340
341   QPushButton* aOKBtn = new QPushButton(aButtons, "ok");
342   aOKBtn->setText(tr("SMESH_BUT_OK"));
343   aOKBtn->setAutoDefault(true);
344   aOKBtn->setDefault(true);
345   QPushButton* aApplyBtn = new QPushButton(aButtons, "apply");
346   aApplyBtn->setText(tr("SMESH_BUT_APPLY"));
347   aApplyBtn->setAutoDefault(true);
348   QPushButton* aCloseBtn = new QPushButton(aButtons, "close");
349   aCloseBtn->setText(tr("SMESH_BUT_CLOSE"));
350   aCloseBtn->setAutoDefault(true);
351   QPushButton* aHelpBtn = new QPushButton(aButtons, "help");
352   aHelpBtn->setText(tr("SMESH_BUT_HELP"));
353   aHelpBtn->setAutoDefault(true);
354
355   aBtnLayout->addWidget(aOKBtn);
356   aBtnLayout->addWidget(aApplyBtn);
357   aBtnLayout->addStretch();
358   aBtnLayout->addWidget(aCloseBtn);
359   aBtnLayout->addWidget(aHelpBtn);
360
361   /***************************************************************/
362   aMainLayout->addWidget(meshGroupLab,    0, 0);
363   aMainLayout->addWidget(myMeshGroupBtn,  0, 1);
364   aMainLayout->addWidget(myMeshGroupLine, 0, 2);
365   aMainLayout->addMultiCellWidget(myTypeGroup,    1, 1, 0, 2);
366   aMainLayout->addWidget(aName,      2, 0);
367   aMainLayout->addWidget(myName,     2, 2);
368   aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2);
369   aMainLayout->addMultiCellWidget(myWGStack,      4, 4, 0, 2);
370   aMainLayout->setRowStretch( 5, 5 );
371   aMainLayout->addMultiCellWidget(aColorBox,   6, 6, 0, 2);
372   aMainLayout->addMultiCellWidget(aButtons,       7, 7, 0, 2);
373
374   /* signals and slots connections */
375   connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
376
377   connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int)));
378
379   connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int)));
380
381   connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
382   connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged()));
383
384   connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters()));
385   connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd()));
386   connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove()));
387   connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort()));
388
389   connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool)));
390   connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool)));
391   connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
392   connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection()));
393   connect(myGeomGroupBtn, SIGNAL(toggled(bool)), this, SLOT(onGeomSelectionButton(bool)));
394   connect(mySelectColorGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectColorGroup(bool)));
395   connect(myColorSpinBox, SIGNAL(valueChanged(const QString&)), this, SLOT(onNbColorsChanged(const QString&)));
396   
397   connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK()));
398   connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply()));
399   connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose()));
400   connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp()));
401
402   /* Init selection */
403   mySMESHGUI->SetActiveDialogBox(this);
404   mySMESHGUI->SetState(800);
405
406   mySelectionMode = -1;
407   myMeshFilter = new SMESH_TypeFilter(MESH);
408   mySubMeshFilter = new SMESH_TypeFilter(SUBMESH);
409   myGroupFilter = new SMESH_TypeFilter(GROUP);
410   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( mySMESHGUI->application()->activeStudy() );
411   myGeomFilter = new GEOM_SelectionFilter( aStudy, true );
412   
413   connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate()));
414   connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose()));
415   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged()));
416
417   myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!!
418   onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!!
419
420   if (myMesh->_is_nil() )
421     myTypeGroup->setButton(0);
422
423   updateButtons();
424 }
425
426 //=================================================================================
427 // function : ~SMESHGUI_GroupDlg()
428 // purpose  : Destroys the object and frees any allocated resources
429 //=================================================================================
430 SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg()
431 {
432   // no need to delete child widgets, Qt does it all for us
433   if ( myFilterDlg != 0 )
434   {
435     myFilterDlg->reparent( 0, QPoint() );
436     delete myFilterDlg;
437   }
438 }
439
440 //=================================================================================
441 // function : Init()
442 // purpose  :
443 //=================================================================================
444 void SMESHGUI_GroupDlg::init (SMESH::SMESH_Mesh_ptr theMesh)
445 {
446   mySelectionMgr->installFilter(myMeshFilter);
447
448   /* init data from current selection */
449   myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh);
450   myGroup = SMESH::SMESH_Group::_nil();
451   myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
452
453   myActor = SMESH::FindActorByObject(myMesh);
454   SMESH::SetPickable(myActor);
455
456   SALOME_ListIO aList;
457   mySelectionMgr->selectedObjects( aList );
458   if( !aList.IsEmpty() )
459   {
460     QString aName = aList.First()->getName();
461     myMeshGroupLine->setText(aName) ;
462     myMeshGroupLine->home( false );
463   }
464
465   myCurrentLineEdit = 0;
466
467   myTypeGroup->setButton(0);
468   onTypeChanged(0);
469 }
470
471 //=================================================================================
472 // function : Init()
473 // purpose  :
474 //=================================================================================
475 void SMESHGUI_GroupDlg::init (SMESH::SMESH_GroupBase_ptr theGroup)
476 {
477   myMesh = theGroup->GetMesh();
478   
479   myName->setText(theGroup->GetName());
480   myName->home(false);
481
482   myColorSpinBox->setValue( theGroup->GetColorNumber() );
483   
484   myMeshGroupLine->setText(theGroup->GetName());
485
486   int aType = 0;
487   switch(theGroup->GetType()) {
488   case SMESH::NODE: aType= 0; break;
489   case SMESH::EDGE: aType = 1; break;
490   case SMESH::FACE: aType = 2; break;
491   case SMESH::VOLUME: aType = 3; break;
492   }
493   myTypeGroup->setButton(aType);
494   
495   myGroup = SMESH::SMESH_Group::_narrow( theGroup );
496
497   if ( !myGroup->_is_nil() )
498     {
499       myActor = SMESH::FindActorByObject(myMesh);
500       if ( !myActor )
501         myActor = SMESH::FindActorByObject(myGroup);
502       SMESH::SetPickable(myActor);
503
504       myGrpTypeGroup->setButton(0);
505       onGrpTypeChanged(0);
506       
507       myCurrentLineEdit = 0;
508       myElements->clear();
509       setSelectionMode(aType);
510       myTypeId = aType;
511       
512       myIdList.clear();
513       if (!myGroup->IsEmpty()) {
514         SMESH::long_array_var anElements = myGroup->GetListOfID();
515         int k = anElements->length();
516         for (int i = 0; i < k; i++) {
517           myIdList.append(anElements[i]);
518           myElements->insertItem(QString::number(anElements[i]));
519         }
520         myElements->selectAll(true);
521       }
522     }
523   else
524     {
525       myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_narrow( theGroup );
526       
527       if ( !myGroupOnGeom->_is_nil() )
528         {
529           myActor = SMESH::FindActorByObject(myMesh);
530           if ( !myActor )
531             myActor = SMESH::FindActorByObject(myGroup);
532           SMESH::SetPickable(myActor);
533
534           myGrpTypeGroup->setButton(1);
535           onGrpTypeChanged(1);
536           
537           QString aShapeName("");
538           _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
539           GEOM::GEOM_Object_var aGroupShape = myGroupOnGeom->GetShape();
540           if (!aGroupShape->_is_nil())
541             {
542               _PTR(SObject) aGroupShapeSO = aStudy->FindObjectID(aGroupShape->GetStudyEntry());
543               aShapeName = aGroupShapeSO->GetName().c_str();
544             }
545           myGeomGroupLine->setText( aShapeName );
546         }
547     }
548 }
549
550 //=================================================================================
551 // function : updateButtons()
552 // purpose  :
553 //=================================================================================
554 void SMESHGUI_GroupDlg::updateButtons()
555 {
556   bool enable;
557
558   if (myGrpTypeId == 0)
559     enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0;
560   else if (myGrpTypeId == 1)
561     {
562       bool isEditMode = !CORBA::is_nil( myGroupOnGeom );
563       enable = !myName->text().stripWhiteSpace().isEmpty() && (myGeomObjects->length() > 0 || isEditMode);
564     }
565   QPushButton* aBtn;
566   aBtn = (QPushButton*) child("ok", "QPushButton");
567   if (aBtn) aBtn->setEnabled(enable);
568   aBtn = (QPushButton*) child("apply", "QPushButton");
569   if (aBtn) aBtn->setEnabled(enable);
570 }
571
572 //=================================================================================
573 // function : onNameChanged()
574 // purpose  :
575 //=================================================================================
576 void SMESHGUI_GroupDlg::onNameChanged (const QString& text)
577 {
578   updateButtons();
579 }
580
581 //=================================================================================
582 // function : onNbColorsChanged()
583 // purpose  :
584 //=================================================================================
585 void SMESHGUI_GroupDlg::onNbColorsChanged (const QString& text)
586 {
587   updateButtons();
588 }
589
590 //=================================================================================
591 // function : onTypeChanged()
592 // purpose  : Group elements type radio button management
593 //=================================================================================
594 void SMESHGUI_GroupDlg::onTypeChanged (int id)
595 {
596   if (myTypeId != id) {
597     myElements->clear();
598     if (myCurrentLineEdit == 0)
599       setSelectionMode(id);
600   }
601   myTypeId = id;
602 }
603
604 //=================================================================================
605 // function : onGrpTypeChanged()
606 // purpose  : Group type radio button management
607 //=================================================================================
608 void SMESHGUI_GroupDlg::onGrpTypeChanged (int id)
609 {
610   if (myGrpTypeId != id) {
611     myWGStack->raiseWidget( id );
612     onSelectGeomGroup(id == 1);
613   }
614   myGrpTypeId = id;
615 }
616
617 //=================================================================================
618 // function : setSelectionMode()
619 // purpose  : Radio button management
620 //=================================================================================
621 void SMESHGUI_GroupDlg::setSelectionMode (int theMode)
622 {
623   // PAL7314
624   if (myMesh->_is_nil())
625     return;
626   if (mySelectionMode != theMode) {
627     // [PAL10408] mySelectionMgr->clearSelected();
628     mySelectionMgr->clearFilters();
629     if (myActor)
630       myActor->SetPointRepresentation(false);
631     else
632       SMESH::SetPointRepresentation(false);
633     if (theMode < 4) {
634       switch (theMode) {
635       case 0:
636         if (myActor)
637           myActor->SetPointRepresentation(true);
638         else
639           SMESH::SetPointRepresentation(true);
640         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
641           aViewWindow->SetSelectionMode(NodeSelection);
642         break;
643       case 1:
644         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
645           aViewWindow->SetSelectionMode(EdgeSelection);
646         break;
647       case 2:
648         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
649           aViewWindow->SetSelectionMode(FaceSelection);
650         break;
651       default:
652         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
653           aViewWindow->SetSelectionMode(VolumeSelection);
654       }
655     } else {
656       if (theMode == 4)
657         mySelectionMgr->installFilter(mySubMeshFilter);
658       else if (theMode == 5)
659         mySelectionMgr->installFilter(myGroupFilter);
660       else if (theMode == 6)
661         mySelectionMgr->installFilter(myMeshFilter);
662       else if (theMode == 7)
663         mySelectionMgr->installFilter(myGeomFilter);
664       
665       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
666         aViewWindow->SetSelectionMode(ActorSelection);
667     }
668     mySelectionMode = theMode;
669   } 
670 }
671
672 //=================================================================================
673 // function : onApply()
674 // purpose  :
675 //=================================================================================
676 bool SMESHGUI_GroupDlg::onApply()
677 {
678   if (mySMESHGUI->isActiveStudyLocked())
679     return false;
680
681   if (myGrpTypeId == 0 &&
682       !myName->text().stripWhiteSpace().isEmpty() &&
683       myElements->count() > 0) {
684     mySelectionMgr->clearSelected();
685     if (myGroup->_is_nil()) {
686       SMESH::ElementType aType = SMESH::ALL;
687       switch(myTypeId) {
688       case 0: aType = SMESH::NODE; break;
689       case 1: aType = SMESH::EDGE; break;
690       case 2: aType = SMESH::FACE; break;
691       case 3: aType = SMESH::VOLUME; break;
692       }
693       SMESH::long_array_var anIdList = new SMESH::long_array;
694       int i, k = myElements->count();
695       anIdList->length(k);
696       QListBoxItem* anItem;
697       for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) {
698         anIdList[i] = anItem->text().toInt();
699       }
700
701       myGroup = SMESH::AddGroup(myMesh, aType, myName->text());
702       myGroup->Add(anIdList.inout());
703       
704       int aColorNumber = myColorSpinBox->value();
705       myGroup->SetColorNumber(aColorNumber);
706       
707       _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroup);
708
709       SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
710       
711       SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
712       
713       /* init for next operation */
714       myName->setText("");
715       myColorSpinBox->setValue(0);
716       myElements->clear();
717       myGroup = SMESH::SMESH_Group::_nil();
718
719     } else {
720       myGroup->SetName(myName->text());
721         
722       int aColorNumber = myColorSpinBox->value();
723       myGroup->SetColorNumber(aColorNumber);
724
725       QValueList<int> aAddList;
726       QValueList<int>::iterator anIt;
727       QListBoxItem* anItem;
728
729       for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
730         int anId = anItem->text().toInt();
731         if ((anIt = myIdList.find(anId)) == myIdList.end())
732           aAddList.append(anId);
733         else
734           myIdList.remove(anIt);
735       }
736       if (!aAddList.empty()) {
737         SMESH::long_array_var anIdList = new SMESH::long_array;
738         anIdList->length(aAddList.count());
739         int i;
740         for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++)
741           anIdList[i] = *anIt;
742         myGroup->Add(anIdList.inout());
743       }
744       if (!myIdList.empty()) {
745         SMESH::long_array_var anIdList = new SMESH::long_array;
746         anIdList->length(myIdList.count());
747         int i;
748         for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++)
749           anIdList[i] = *anIt;
750         myGroup->Remove(anIdList.inout());
751       }
752       /* init for next operation */
753       myIdList.clear();
754       for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next())
755         myIdList.append(anItem->text().toInt());
756     }
757
758     mySMESHGUI->updateObjBrowser(true);
759     SMESH::UpdateView(); // asv: fix of BUG PAL5515
760     mySelectionMgr->clearSelected();
761     return true;
762   } else if (myGrpTypeId == 1 &&
763              !myName->text().stripWhiteSpace().isEmpty() &&
764              (myGeomObjects->length() > 0 || !CORBA::is_nil(myGroupOnGeom)))
765   {
766     if (myGroupOnGeom->_is_nil()) {
767       SMESH::ElementType aType = SMESH::ALL;
768       switch (myTypeId) {
769       case 0: aType = SMESH::NODE; break;
770       case 1: aType = SMESH::EDGE; break;
771       case 2: aType = SMESH::FACE; break;
772       case 3: aType = SMESH::VOLUME; break;
773       }
774       
775       _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
776       GEOM::GEOM_IGroupOperations_var aGroupOp =
777         SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
778       
779       if (myGeomObjects->length() == 1)
780         myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomObjects[0]);
781       else
782         {
783           SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
784           if ( aSMESHGen->_is_nil() )
785             return false;
786
787           // create a geometry group
788           GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
789           _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
790
791           if (geomGen->_is_nil() || !aStudy)
792             return false;
793
794           GEOM::GEOM_IGroupOperations_var op =
795             geomGen->GetIGroupOperations(aStudy->StudyId());
796           if (op->_is_nil())
797             return false;
798             
799           // check and add all selected GEOM objects: they must be
800           // a sub-shapes of the main GEOM and must be of one type
801           TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
802           for ( int i =0; i < myGeomObjects->length(); i++)
803             {
804               TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType();
805               if (i == 0)
806                 aGroupType = aSubShapeType;
807               else if (aSubShapeType != aGroupType)
808                 {
809                   aGroupType = TopAbs_SHAPE;
810                   break;
811                 }
812             }
813             
814           GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
815           GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
816           op->UnionList(aGroupVar, myGeomObjects);
817
818           if (op->IsDone()) {
819             // publish the GEOM group in study
820             QString aNewGeomGroupName ("Auto_group_for_");
821             aNewGeomGroupName += myName->text();
822             SALOMEDS::SObject_var aNewGroupSO =
823               geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGroupVar, aNewGeomGroupName, aMeshShape);
824           }
825           
826           myGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(), aGroupVar);
827         }
828       
829       int aColorNumber = myColorSpinBox->value();
830       myGroupOnGeom->SetColorNumber(aColorNumber);
831       
832       _PTR(SObject) aMeshGroupSO = SMESH::FindSObject(myGroupOnGeom);
833       
834       SMESH::setFileName ( aMeshGroupSO, QString::number(myColorSpinBox->value()) );
835       
836       SMESH::setFileType ( aMeshGroupSO,"COULEURGROUP" );
837       
838       /* init for next operation */
839       myName->setText("");
840       myColorSpinBox->setValue(0);
841       myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
842     }
843     else
844       {
845         myGroupOnGeom->SetName(myName->text());
846         
847         int aColorNumber = myColorSpinBox->value();
848         myGroupOnGeom->SetColorNumber(aColorNumber);
849       }
850     
851     mySMESHGUI->updateObjBrowser(true);
852     mySelectionMgr->clearSelected();
853     return true;
854   }
855   
856   return false;
857 }
858
859 //=================================================================================
860 // function : onOK()
861 // purpose  :
862 //=================================================================================
863 void SMESHGUI_GroupDlg::onOK()
864 {
865   if ( onApply() )
866     onClose();
867 }
868
869 //=================================================================================
870 // function : onListSelectionChanged()
871 // purpose  : Called when selection in element list is changed
872 //=================================================================================
873 void SMESHGUI_GroupDlg::onListSelectionChanged()
874 {
875   //  MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor);
876   if( myIsBusy || !myActor) return;
877     myIsBusy = true;
878
879   if (myCurrentLineEdit == 0) {
880     mySelectionMgr->clearSelected();
881     TColStd_MapOfInteger aIndexes;
882     QListBoxItem* anItem;
883     for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) {
884       if (anItem->isSelected()) {
885         int anId = anItem->text().toInt();
886         aIndexes.Add(anId);
887       }
888     }
889     mySelector->AddOrRemoveIndex(myActor->getIO(), aIndexes, false);
890     SALOME_ListIO aList;
891     aList.Append(myActor->getIO());
892     mySelectionMgr->setSelectedObjects(aList,false);
893   }
894   myIsBusy = false;
895 }
896
897 //=================================================================================
898 // function : onObjectSelectionChanged()
899 // purpose  : Called when selection in 3D view or ObjectBrowser is changed
900 //=================================================================================
901 void SMESHGUI_GroupDlg::onObjectSelectionChanged()
902 {
903   if ( myIsBusy || !isEnabled()) return;
904   if (myCurrentLineEdit == myGeomGroupLine && !myGeomGroupBtn->isOn()) return;
905
906   myIsBusy = true;
907
908   SALOME_ListIO aList;
909   mySelectionMgr->selectedObjects( aList );
910   
911   int aNbSel = aList.Extent();
912   myElements->clearSelection();
913
914   if (myCurrentLineEdit) {
915     myCurrentLineEdit->setText("");
916     QString aString = "";
917
918     if (myCurrentLineEdit == myMeshGroupLine) {
919       mySelectSubMesh->setEnabled(false);
920       mySelectGroup->setEnabled(false);
921       myGroupLine->setText("");
922       mySubMeshLine->setText("");
923
924       myGeomGroupBtn->setEnabled(false);
925       myGeomGroupLine->setEnabled(false);
926       myGeomGroupLine->setText("");
927       if (myGeomGroupBtn->isOn())
928         myGeomGroupBtn->setOn(false);
929       if (!myCreate)
930         myName->setText("");
931
932       myElements->clear();
933
934       if (aNbSel != 1 ) {
935         myGroup = SMESH::SMESH_Group::_nil();
936         myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil(); 
937         myMesh = SMESH::SMESH_Mesh::_nil();
938         updateGeomPopup();
939         myIsBusy = false;
940         return;
941       }
942       Handle(SALOME_InteractiveObject) IO = aList.First();
943
944       if (myCreate) {
945         myMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO);
946         updateGeomPopup();
947         if (myMesh->_is_nil())
948         {
949           myIsBusy = false;
950           return;
951         }
952         myGroup = SMESH::SMESH_Group::_nil();
953
954         myActor = SMESH::FindActorByObject(myMesh);
955         SMESH::SetPickable(myActor);
956
957         aString = aList.First()->getName();
958         myMeshGroupLine->setText(aString) ;
959         myMeshGroupLine->home( false );
960
961         mySelectSubMesh->setEnabled(true);
962         mySelectGroup->setEnabled(true);
963         myGeomGroupBtn->setEnabled(true);
964         myGeomGroupLine->setEnabled(true);
965         updateButtons();
966       } else {
967         SMESH::SMESH_GroupBase_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
968         if (aGroup->_is_nil())
969         {
970           myIsBusy = false;
971           return;
972         }
973         myIsBusy = false;
974         myCurrentLineEdit = 0;
975
976         myGroup = SMESH::SMESH_Group::_nil();
977         myGroupOnGeom = SMESH::SMESH_GroupOnGeom::_nil();
978         
979         init(aGroup);
980         myIsBusy = true;
981         mySelectSubMesh->setEnabled(true);
982         mySelectGroup->setEnabled(true);
983       }
984       myCurrentLineEdit = 0;
985       myIsBusy = false;
986       if (!myCreate)
987         return;
988
989       if (myGrpTypeId == 0)
990         {
991           if (myTypeId == -1)
992             onTypeChanged(0);
993           else
994             {
995               myElements->clear();
996               setSelectionMode(myTypeId);
997             }
998         }
999
1000       myIsBusy = false;
1001       return;
1002
1003     } else if (myCurrentLineEdit == myGeomGroupLine) {
1004       
1005       myGeomObjects = new GEOM::ListOfGO();
1006       
1007       // The mesh SObject
1008       _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
1009       
1010       if (aNbSel == 0 || !aMeshSO)
1011         {
1012           myGeomObjects->length(0);
1013           myIsBusy = false;
1014           return;
1015         }
1016       
1017       myGeomObjects->length(aNbSel);
1018
1019       GEOM::GEOM_Object_var aGeomGroup;
1020       Standard_Boolean testResult;
1021       int i = 0;
1022       
1023       SALOME_ListIteratorOfListIO anIt (aList);
1024       for (; anIt.More(); anIt.Next()) {
1025         
1026         testResult = Standard_False;
1027         aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value(), testResult);
1028
1029         // Check if the object is a geometry group
1030         if (!testResult || CORBA::is_nil(aGeomGroup))
1031           continue;
1032         
1033
1034         // Check if group constructed on the same shape as a mesh or on its child
1035         _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1036         GEOM::GEOM_IGroupOperations_var anOp =
1037           SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1038
1039         // The main shape of the group
1040         GEOM::GEOM_Object_var aGroupMainShape;
1041         if (aGeomGroup->GetType() == 37)
1042           aGroupMainShape = anOp->GetMainShape(aGeomGroup);
1043         else
1044           aGroupMainShape = GEOM::GEOM_Object::_duplicate(aGeomGroup);
1045         _PTR(SObject) aGroupMainShapeSO =
1046           //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(aGroupMainShape));
1047           aStudy->FindObjectID(aGroupMainShape->GetStudyEntry());
1048         
1049         _PTR(SObject) anObj, aRef;
1050         bool isRefOrSubShape = false;
1051         if (aMeshSO->FindSubObject(1, anObj) &&  anObj->ReferencedObject(aRef)) {
1052           //if (strcmp(aRef->GetID(), aGroupMainShapeSO->GetID()) == 0) {
1053           if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
1054             isRefOrSubShape = true;
1055           } else {
1056             _PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
1057             _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
1058             //while (!isRefOrSubShape && strcmp(aFather->GetID(), aComponent->GetID()) != 0) {
1059             while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
1060               //if (strcmp(aRef->GetID(), aFather->GetID()) == 0)
1061               if (aRef->GetID() == aFather->GetID())
1062                 isRefOrSubShape = true;
1063               else
1064                 aFather = aFather->GetFather();
1065             }
1066           }
1067         }
1068         if (isRefOrSubShape)
1069           myGeomObjects[i++] = aGeomGroup;
1070       }
1071       
1072       myGeomObjects->length(i);
1073       if ( i == 0 )
1074         {
1075           myIsBusy = false;
1076           return;
1077         }
1078       
1079       aNbSel = i;
1080     }
1081
1082     if(aNbSel >= 1) {
1083       if(aNbSel > 1) {
1084         if(myCurrentLineEdit == mySubMeshLine)
1085           aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel);
1086         else if(myCurrentLineEdit == myGroupLine)
1087           aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel);
1088         else if(myCurrentLineEdit == myGeomGroupLine)
1089           aString = tr("%1 Objects").arg(aNbSel);
1090       } else {
1091         aString = aList.First()->getName();
1092       }
1093     }
1094
1095     myCurrentLineEdit->setText(aString);
1096     myCurrentLineEdit->home(false);
1097
1098     updateButtons();
1099
1100   } else {
1101     if (aNbSel == 1 && myActor ) {
1102       QString aListStr = "";
1103       int aNbItems = 0;
1104       if (myTypeId == 0) {
1105         aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1106       } else {
1107         aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1108       }
1109       if (aNbItems > 0) {
1110         QStringList anElements = QStringList::split(" ", aListStr);
1111         QListBoxItem* anItem = 0;
1112         for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1113           anItem = myElements->findItem(*it, Qt::ExactMatch);
1114           if (anItem) myElements->setSelected(anItem, true);
1115         }
1116       }
1117     }
1118   }
1119
1120   if (!myActor) {
1121     if (!myGroup->_is_nil())
1122       myActor = SMESH::FindActorByObject(myGroup);
1123     else if(!myGroupOnGeom->_is_nil())
1124       myActor = SMESH::FindActorByObject(myGroupOnGeom);
1125     else
1126       myActor = SMESH::FindActorByObject(myMesh);
1127   }
1128
1129   myIsBusy = false;
1130 }
1131
1132 //=================================================================================
1133 // function : onSelectSubMesh()
1134 // purpose  : Called when selection in 3D view or ObjectBrowser is changed
1135 //=================================================================================
1136 void SMESHGUI_GroupDlg::onSelectSubMesh(bool on)
1137 {
1138   if (on) {
1139     if (mySelectGroup->isChecked()) {
1140       mySelectGroup->setChecked(false);
1141     }
1142     //VSR: else if (mySelectGeomGroup->isChecked()) {
1143     //VSR:   mySelectGeomGroup->setChecked(false);
1144     //VSR: }
1145     myCurrentLineEdit = mySubMeshLine;
1146     setSelectionMode(4);
1147   }
1148   else {
1149     mySubMeshLine->setText("");
1150     myCurrentLineEdit = 0;
1151     if (myTypeId != -1)
1152       setSelectionMode(myTypeId);
1153   }
1154   mySubMeshBtn->setEnabled(on);
1155   mySubMeshLine->setEnabled(on);
1156 }
1157
1158
1159 //=================================================================================
1160 // function : (onSelectGroup)
1161 // purpose  : Called when selection in 3D view or ObjectBrowser is changed
1162 //=================================================================================
1163 void SMESHGUI_GroupDlg::onSelectGroup(bool on)
1164 {
1165   if (on) {
1166     if (mySelectSubMesh->isChecked()) {
1167       mySelectSubMesh->setChecked(false);
1168     }
1169     myCurrentLineEdit = myGroupLine;
1170     setSelectionMode(5);
1171   }
1172   else {
1173     myGroupLine->setText("");
1174     myCurrentLineEdit = 0;
1175     if (myTypeId != -1)
1176       setSelectionMode(myTypeId);
1177   }
1178   myGroupBtn->setEnabled(on);
1179   myGroupLine->setEnabled(on);
1180 }
1181
1182
1183 //=================================================================================
1184 // function : (onSelectGeomGroup)
1185 // purpose  : Called when selection in 3D view or ObjectBrowser is changed
1186 //=================================================================================
1187 void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on)
1188 {
1189   if (on) {
1190     if (mySelectSubMesh->isChecked()) {
1191       mySelectSubMesh->setChecked(false);
1192     }
1193     else if (mySelectGroup->isChecked()) {
1194       mySelectGroup->setChecked(false);
1195     }
1196     myCurrentLineEdit = myGeomGroupLine;
1197     updateGeomPopup();
1198     setSelectionMode(8);
1199   }
1200   else {
1201     myGeomGroupBtn->setOn(false);
1202     myGeomObjects->length(0);
1203     myGeomGroupLine->setText("");
1204     myCurrentLineEdit = 0;
1205     if (myTypeId != -1)
1206       setSelectionMode(myTypeId);
1207   }
1208 }
1209
1210 //=================================================================================
1211 // function : (onSelectColorGroup)
1212 // purpose  : Called when setting a color on group
1213 //=================================================================================
1214 void SMESHGUI_GroupDlg::onSelectColorGroup(bool on)
1215 {
1216   if (!on)
1217     myColorSpinBox->setValue(0);
1218   
1219   myColorSpinBox->setEnabled(on);
1220 }
1221
1222 //=================================================================================
1223 // function : setCurrentSelection()
1224 // purpose  :
1225 //=================================================================================
1226 void SMESHGUI_GroupDlg::setCurrentSelection()
1227 {
1228   QPushButton* send = (QPushButton*)sender();
1229   myCurrentLineEdit = 0;
1230   if (send == myMeshGroupBtn) {
1231     myCurrentLineEdit = myMeshGroupLine;
1232     if (myCreate)
1233       setSelectionMode(6);
1234     else
1235       setSelectionMode(5);
1236     onObjectSelectionChanged();
1237   }
1238   else if (send == mySubMeshBtn) {
1239     myCurrentLineEdit = mySubMeshLine;
1240     onObjectSelectionChanged();
1241   }
1242   else if (send == myGroupBtn) {
1243     myCurrentLineEdit = myGroupLine;
1244     onObjectSelectionChanged();
1245   }
1246 }
1247
1248
1249 //=================================================================================
1250 // function : setFilters()
1251 // purpose  : SLOT. Called when "Filter" button pressed.
1252 //=================================================================================
1253 void SMESHGUI_GroupDlg::setFilters()
1254 {
1255   SMESH::ElementType aType = SMESH::ALL;
1256   switch ( myTypeId )
1257   {
1258     case 0 : aType = SMESH::NODE; break;
1259     case 1 : aType = SMESH::EDGE; break;
1260     case 2 : aType = SMESH::FACE; break;
1261     case 3 : aType = SMESH::VOLUME; break;
1262     default: return;
1263   }
1264
1265   if ( myFilterDlg == 0 )
1266   {
1267     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, aType );
1268     connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) );
1269   }
1270   else
1271     myFilterDlg->Init( aType );
1272
1273   myFilterDlg->SetSelection();
1274   myFilterDlg->SetMesh( myMesh );
1275   myFilterDlg->SetSourceWg( myElements );
1276
1277   myFilterDlg->show();
1278 }
1279
1280 //=================================================================================
1281 // function : onFilterAccepted()
1282 // purpose  : SLOT. Called when Filter dlg closed with OK button.
1283 //            Uncheck "Select submesh" and "Select group" checkboxes
1284 //=================================================================================
1285 void SMESHGUI_GroupDlg::onFilterAccepted()
1286 {
1287   if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() )
1288   {
1289     mySelectionMode = myTypeId;
1290     mySelectSubMesh->setChecked( false );
1291     mySelectGroup->setChecked( false );
1292   }
1293 }
1294
1295 //=================================================================================
1296 // function : onAdd()
1297 // purpose  :
1298 //=================================================================================
1299 void SMESHGUI_GroupDlg::onAdd()
1300 {
1301   SALOME_ListIO aList;
1302   mySelectionMgr->selectedObjects( aList );
1303
1304   int aNbSel = aList.Extent();
1305
1306   if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
1307
1308   myIsBusy = true;
1309
1310   SMESH::ElementType aType = SMESH::ALL;
1311   switch(myTypeId) {
1312   case 0: 
1313     aType = SMESH::NODE; 
1314     mySelector->SetSelectionMode(NodeSelection);
1315     break;
1316   case 1: 
1317     aType = SMESH::EDGE; 
1318     mySelector->SetSelectionMode(EdgeSelection);
1319     break;
1320   case 2: 
1321     aType = SMESH::FACE; 
1322     mySelector->SetSelectionMode(FaceSelection);
1323     break;
1324   case 3: 
1325     aType = SMESH::VOLUME; 
1326     mySelector->SetSelectionMode(VolumeSelection);
1327     break;
1328   default:
1329     mySelector->SetSelectionMode(ActorSelection);
1330   }
1331
1332
1333   if (myCurrentLineEdit == 0) {
1334     //if (aNbSel != 1) { myIsBusy = false; return; }
1335     QString aListStr = "";
1336     int aNbItems = 0;
1337     if (myTypeId == 0) {
1338       aNbItems = SMESH::GetNameOfSelectedNodes(mySelector, myActor->getIO(), aListStr);
1339     }
1340     else {
1341       aNbItems = SMESH::GetNameOfSelectedElements(mySelector, myActor->getIO(), aListStr);
1342     }
1343     if (aNbItems > 0) {
1344       QStringList anElements = QStringList::split(" ", aListStr);
1345       QListBoxItem* anItem = 0;
1346       for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) {
1347         anItem = myElements->findItem(*it, Qt::ExactMatch);
1348         if (!anItem) {
1349           anItem = new QListBoxText(*it);
1350           myElements->insertItem(anItem);
1351         }
1352         myElements->setSelected(anItem, true);
1353       }
1354     }
1355   } else if (myCurrentLineEdit == mySubMeshLine) {
1356     //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1357     
1358     SALOME_ListIO aList;
1359     mySelectionMgr->selectedObjects( aList );
1360
1361     SALOME_ListIteratorOfListIO anIt (aList);
1362     for (; anIt.More(); anIt.Next()) {
1363       SMESH::SMESH_subMesh_var aSubMesh =
1364         SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1365       if (!aSubMesh->_is_nil()) {
1366         // check if mesh is the same
1367         if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1368           try {
1369             SMESH::long_array_var anElements = aSubMesh->GetElementsByType(aType);
1370             int k = anElements->length();
1371             QListBoxItem* anItem = 0;
1372             for (int i = 0; i < k; i++) {
1373               QString aText = QString::number(anElements[i]);
1374               anItem = myElements->findItem(aText, Qt::ExactMatch);
1375               if (!anItem) {
1376                 anItem = new QListBoxText(aText);
1377                 myElements->insertItem(anItem);
1378               }
1379               myElements->setSelected(anItem, true);
1380             }
1381           }
1382           catch (const SALOME::SALOME_Exception& ex) {
1383             SalomeApp_Tools::QtCatchCorbaException(ex);
1384           }
1385         }
1386       }
1387     }
1388     mySelectSubMesh->setChecked(false);
1389     myIsBusy = false;
1390     onListSelectionChanged();
1391
1392   } else if (myCurrentLineEdit == myGroupLine) {
1393     //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1394     SALOME_ListIO aList;
1395     mySelectionMgr->selectedObjects( aList );
1396     
1397     SALOME_ListIteratorOfListIO anIt (aList);
1398     for (; anIt.More(); anIt.Next()) {
1399       SMESH::SMESH_Group_var aGroup =
1400         SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1401       if (!aGroup->_is_nil()) {
1402         // check if mesh is the same
1403         if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1404           SMESH::long_array_var anElements = aGroup->GetListOfID();
1405           int k = anElements->length();
1406           QListBoxItem* anItem = 0;
1407           for (int i = 0; i < k; i++) {
1408             QString aText = QString::number(anElements[i]);
1409             anItem = myElements->findItem(aText, Qt::ExactMatch);
1410             if (!anItem) {
1411               anItem = new QListBoxText(aText);
1412               myElements->insertItem(anItem);
1413             }
1414             myElements->setSelected(anItem, true);
1415           }
1416         }
1417       }
1418     }
1419     mySelectGroup->setChecked(false);
1420     myIsBusy = false;
1421     onListSelectionChanged();
1422
1423   } else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) {
1424     _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1425     GEOM::GEOM_IGroupOperations_var aGroupOp =
1426       SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId());
1427
1428     SMESH::ElementType aGroupType = SMESH::ALL;
1429     switch(aGroupOp->GetType(myGeomObjects[0])) {
1430     case 7: aGroupType = SMESH::NODE; break;
1431     case 6: aGroupType = SMESH::EDGE; break;
1432     case 4: aGroupType = SMESH::FACE; break;
1433     case 2: aGroupType = SMESH::VOLUME; break;
1434     default: myIsBusy = false; return;
1435     }
1436
1437     if (aGroupType == aType) {
1438       _PTR(SObject) aGroupSO =
1439         //aStudy->FindObjectIOR(aStudy->ConvertObjectToIOR(myGeomGroup));
1440         aStudy->FindObjectID(myGeomObjects[0]->GetStudyEntry());
1441       // Construct filter
1442       SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
1443       SMESH::Filter_var aFilter = aFilterMgr->CreateFilter();
1444       SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();;
1445       aBelongToGeom->SetGeom(myGeomObjects[0]);
1446       aBelongToGeom->SetShapeName(aGroupSO->GetName().c_str());
1447       aBelongToGeom->SetElementType(aType);
1448       aFilter->SetPredicate(aBelongToGeom);
1449
1450       SMESH::long_array_var anElements = aFilter->GetElementsId(myMesh);
1451
1452       int k = anElements->length();
1453       QListBoxItem* anItem = 0;
1454       for (int i = 0; i < k; i++) {
1455         QString aText = QString::number(anElements[i]);
1456         anItem = myElements->findItem(aText, Qt::ExactMatch);
1457         if (!anItem) {
1458           anItem = new QListBoxText(aText);
1459           myElements->insertItem(anItem);
1460         }
1461         myElements->setSelected(anItem, true);
1462       }
1463     }
1464
1465     //VSR: mySelectGeomGroup->setChecked(false);
1466     myIsBusy = false;
1467     onListSelectionChanged();
1468   }
1469   myIsBusy = false;
1470   //  mySelectionMgr->clearSelected();
1471   updateButtons();
1472 }
1473
1474 //=================================================================================
1475 // function : onRemove()
1476 // purpose  :
1477 //=================================================================================
1478 void SMESHGUI_GroupDlg::onRemove()
1479 {
1480   myIsBusy = true;
1481   if (myCurrentLineEdit == 0) {
1482     for (int i = myElements->count(); i > 0; i--) {
1483       if (myElements->isSelected(i-1)) {
1484         myElements->removeItem(i-1);
1485       }
1486     }
1487   } else {
1488     SALOME_ListIO aList;
1489     mySelectionMgr->selectedObjects( aList );
1490
1491     int aNbSel = aList.Extent();
1492
1493     if (aNbSel == 0) { myIsBusy = false; return; }
1494
1495     SMESH::ElementType aType = SMESH::ALL;
1496     switch(myTypeId) {
1497     case 0: aType = SMESH::NODE; break;
1498     case 1: aType = SMESH::EDGE; break;
1499     case 2: aType = SMESH::FACE; break;
1500     case 3: aType = SMESH::VOLUME; break;
1501     }
1502
1503     if (myCurrentLineEdit == mySubMeshLine) {
1504       //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1505       SALOME_ListIO aList;
1506       mySelectionMgr->selectedObjects( aList );
1507
1508       SALOME_ListIteratorOfListIO anIt (aList);
1509       for (; anIt.More(); anIt.Next()) {
1510         SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(anIt.Value());
1511         if (!aSubMesh->_is_nil()) {
1512           // check if mesh is the same
1513           if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) {
1514             if (aType == SMESH::NODE) {
1515               try {
1516                 SMESH::long_array_var anElements = aSubMesh->GetNodesId();
1517                 int k = anElements->length();
1518                 QListBoxItem* anItem = 0;
1519                 for (int i = 0; i < k; i++) {
1520                   anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1521                   if (anItem) delete anItem;
1522                 }
1523               }
1524               catch (const SALOME::SALOME_Exception& ex) {
1525                 SalomeApp_Tools::QtCatchCorbaException(ex);
1526               }
1527             }
1528             else {
1529               try {
1530                 SMESH::long_array_var anElements = aSubMesh->GetElementsId();
1531                 int k = anElements->length();
1532                 QListBoxItem* anItem = 0;
1533                 for (int i = 0; i < k; i++) {
1534                   anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1535                   if (anItem) delete anItem;
1536                 }
1537               }
1538               catch (const SALOME::SALOME_Exception& ex) {
1539                 SalomeApp_Tools::QtCatchCorbaException(ex);
1540               }
1541             }
1542           }
1543         }
1544       }
1545     }
1546     else if (myCurrentLineEdit == myGroupLine) {
1547       Standard_Boolean aRes;
1548       //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
1549       SALOME_ListIO aList;
1550       mySelectionMgr->selectedObjects( aList );
1551
1552       SALOME_ListIteratorOfListIO anIt (aList);
1553       for (; anIt.More(); anIt.Next()) {
1554         SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface<SMESH::SMESH_Group>(anIt.Value());
1555         if (aRes && !aGroup->_is_nil()) {
1556           // check if mesh is the same
1557           if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) {
1558             SMESH::long_array_var anElements = aGroup->GetListOfID();
1559             int k = anElements->length();
1560             QListBoxItem* anItem = 0;
1561             for (int i = 0; i < k; i++) {
1562               anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch);
1563               if (anItem) delete anItem;
1564             }
1565           }
1566         }
1567       }
1568     }
1569   }
1570   myIsBusy = false;
1571   updateButtons();
1572 }
1573
1574 //=================================================================================
1575 // function : onSort()
1576 // purpose  :
1577 //=================================================================================
1578 void SMESHGUI_GroupDlg::onSort()
1579 {
1580   // PAL5412: sorts items in ascending by "string" value
1581   // myElements->sort(true);
1582   // myElements->update();
1583   int i, k = myElements->count();
1584   if (k > 0) {
1585     myIsBusy = true;
1586     QStringList aSelected;
1587     std::vector<int> anArray(k);
1588     //    QMemArray<int> anArray(k);
1589     QListBoxItem* anItem;
1590     // fill the array
1591     for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) {
1592       anArray[i] = anItem->text().toInt();
1593       if (anItem->isSelected())
1594         aSelected.append(anItem->text());
1595     }
1596     // sort & update list
1597     std::sort(anArray.begin(), anArray.end());
1598     //    anArray.sort();
1599     myElements->clear();
1600     for (i = 0; i < k; i++) {
1601       myElements->insertItem(QString::number(anArray[i]));
1602     }
1603     for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) {
1604       anItem = myElements->findItem(*it, Qt::ExactMatch);
1605       if (anItem) myElements->setSelected(anItem, true);
1606     }
1607     myIsBusy = false;
1608   }
1609 }
1610
1611 //=================================================================================
1612 // function : closeEvent()
1613 // purpose  :
1614 //=================================================================================
1615 void SMESHGUI_GroupDlg::closeEvent (QCloseEvent*)
1616 {
1617   onClose();
1618 }
1619
1620 //=================================================================================
1621 // function : SMESHGUI_GroupDlg::onClose
1622 // purpose  : SLOT called when "Close" button pressed. Close dialog
1623 //=================================================================================
1624 void SMESHGUI_GroupDlg::onClose()
1625 {
1626   if (SMESH::GetCurrentVtkView()) {
1627     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
1628     SMESH::SetPointRepresentation(false);
1629     SMESH::SetPickable();
1630   }
1631
1632   mySelectionMgr->clearSelected();
1633   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
1634     aViewWindow->SetSelectionMode(ActorSelection);
1635   mySelectionMgr->clearFilters();
1636   mySMESHGUI->ResetState();
1637
1638   reject();
1639 }
1640
1641 //=================================================================================
1642 // function : onHelp()
1643 // purpose  :
1644 //=================================================================================
1645 void SMESHGUI_GroupDlg::onHelp()
1646 {
1647   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
1648   if (app) 
1649     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
1650   else {
1651                 QString platform;
1652 #ifdef WIN32
1653                 platform = "winapplication";
1654 #else
1655                 platform = "application";
1656 #endif
1657     SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
1658                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
1659                            arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
1660                            QObject::tr("BUT_OK"));
1661   }
1662 }
1663
1664 //=================================================================================
1665 // function : SMESHGUI_GroupDlg::onDeactivate
1666 // purpose  : SLOT called when dialog must be deativated
1667 //=================================================================================
1668 void SMESHGUI_GroupDlg::onDeactivate()
1669 {
1670   mySMESHGUI->ResetState();
1671   setEnabled(false);
1672 }
1673
1674 //=================================================================================
1675 // function : SMESHGUI_GroupDlg::enterEvent
1676 // purpose  : Event filter
1677 //=================================================================================
1678 void SMESHGUI_GroupDlg::enterEvent (QEvent*)
1679 {
1680   if (!isEnabled()) {
1681     mySMESHGUI->EmitSignalDeactivateDialog();
1682     setEnabled(true);
1683     mySelectionMode = -1;
1684     setSelectionMode(myTypeId);
1685     //mySMESHGUI->SetActiveDialogBox((QDialog*)this);
1686     mySMESHGUI->SetActiveDialogBox(this);
1687     mySMESHGUI->SetState(800);
1688   }
1689 }
1690
1691 //=================================================================================
1692 // function : hideEvent
1693 // purpose  : caused by ESC key
1694 //=================================================================================
1695 void SMESHGUI_GroupDlg::hideEvent (QHideEvent*)
1696 {
1697   if (!isMinimized() && !myIsBusy)
1698     onClose();
1699 }
1700
1701 //=================================================================================
1702 // function : keyPressEvent()
1703 // purpose  :
1704 //=================================================================================
1705 void SMESHGUI_GroupDlg::keyPressEvent( QKeyEvent* e )
1706 {
1707   QDialog::keyPressEvent( e );
1708   if ( e->isAccepted() )
1709     return;
1710
1711   if ( e->key() == Key_F1 )
1712     {
1713       e->accept();
1714       onHelp();
1715     }
1716 }
1717
1718 //================================================================================
1719 /*!
1720  * \brief Enable showing of the popup when Geometry selection btn is clicked
1721   * \param enable - true to enable
1722  */
1723 //================================================================================
1724
1725 enum { DIRECT_GEOM_INDEX = 0, GEOM_BY_MESH_INDEX };
1726
1727 void SMESHGUI_GroupDlg::updateGeomPopup()
1728 {
1729   bool enable = false;
1730
1731   if ( !myMesh->_is_nil() )
1732     enable = myMesh->NbEdges() > 0;
1733
1734   if ( myGeomGroupBtn )
1735   {
1736     disconnect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
1737     if ( enable ) {
1738       if ( !myGeomPopup ) {
1739         myGeomPopup = new QPopupMenu();
1740         myGeomPopup->insertItem( tr("DIRECT_GEOM_SELECTION"), DIRECT_GEOM_INDEX );
1741         myGeomPopup->insertItem( tr("GEOM_BY_MESH_ELEM_SELECTION"), GEOM_BY_MESH_INDEX );
1742         connect( myGeomPopup, SIGNAL( activated( int ) ), SLOT( onGeomPopup( int ) ) );
1743       }
1744       connect( myGeomGroupBtn, SIGNAL( toggled(bool) ), this, SLOT( onGeomSelectionButton(bool) ));
1745     }
1746   }
1747 }
1748
1749
1750 //=================================================================================
1751 // function : onGeomSelectionButton()
1752 // purpose  :
1753 //=================================================================================
1754 void SMESHGUI_GroupDlg::onGeomSelectionButton(bool isBtnOn)
1755 {
1756   if ( myGeomPopup && isBtnOn )
1757     {
1758       myCurrentLineEdit = myGeomGroupLine;
1759       int id = myGeomPopup->exec( QCursor::pos() );
1760       if (id == DIRECT_GEOM_INDEX || id == -1)
1761         setSelectionMode(7);
1762     }
1763   else if (!isBtnOn)
1764     {
1765       myCurrentLineEdit = 0;
1766       setSelectionMode(8);
1767     }
1768 }
1769
1770 //=================================================================================
1771 // function : onGeomPopup()
1772 // purpose  :
1773 //=================================================================================
1774 void SMESHGUI_GroupDlg::onGeomPopup( int index )
1775 {
1776   if ( index == GEOM_BY_MESH_INDEX )
1777     {
1778       mySelectionMode = -1;
1779       if ( !myShapeByMeshOp ) {
1780         myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp(true);
1781         connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
1782                 SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
1783         connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
1784                 SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
1785       }
1786       // set mesh object to SMESHGUI_ShapeByMeshOp and start it
1787       if ( !myMesh->_is_nil() ) {
1788         myIsBusy = true;
1789         hide(); // stop processing selection
1790         myIsBusy = false;
1791         myShapeByMeshOp->setModule( mySMESHGUI );
1792         myShapeByMeshOp->setStudy( 0 ); // it's really necessary
1793         myShapeByMeshOp->SetMesh( myMesh );
1794         myShapeByMeshOp->start();
1795       }
1796     }
1797 }
1798
1799 //================================================================================
1800 /*!
1801  * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
1802  */
1803 //================================================================================
1804
1805 void SMESHGUI_GroupDlg::onPublishShapeByMeshDlg(SUIT_Operation* op)
1806 {
1807   if ( myShapeByMeshOp == op ) {
1808     mySMESHGUI->getApp()->updateObjectBrowser();
1809     show();
1810     // Select a found geometry object
1811     GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
1812     if ( !aGeomVar->_is_nil() )
1813     {
1814       QString ID = aGeomVar->GetStudyEntry();
1815       _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1816       if ( _PTR(SObject) aGeomSO = aStudy->FindObjectID( ID.latin1() )) {
1817         SALOME_ListIO anIOList;
1818         Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
1819           ( aGeomSO->GetID().c_str(), "SMESH", aGeomSO->GetName().c_str() );
1820         anIOList.Append( anIO );
1821         mySelectionMgr->setSelectedObjects( anIOList, false );
1822         onObjectSelectionChanged();
1823       }
1824     }
1825   }
1826 }
1827
1828 //================================================================================
1829 /*!
1830  * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
1831  */
1832 //================================================================================
1833
1834 void SMESHGUI_GroupDlg::onCloseShapeByMeshDlg(SUIT_Operation* op)
1835 {
1836   if ( myShapeByMeshOp == op )
1837     {
1838       show();
1839       setSelectionMode(7);
1840     }
1841 }