]> SALOME platform Git repositories - modules/geom.git/blob - src/GroupGUI/GroupGUI_GroupDlg.cxx
Salome HOME
Merge with PAL/SALOME 2.1.0d
[modules/geom.git] / src / GroupGUI / GroupGUI_GroupDlg.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2004  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.org 
21 //
22 //
23 //
24 //  File   : GroupGUI_GroupDlg.cxx
25 //  Author : Sergey ANIKIN
26 //  Module : GEOM
27 //  $Header$
28
29 #include "GroupGUI_GroupDlg.h"
30
31 #include "GEOMBase.h"
32
33 #include "GEOMImpl_Types.hxx"
34
35 #include "QAD_Desktop.h"
36
37 #include <qlabel.h>
38 #include <qlistbox.h>
39 #include <qlineedit.h>
40 #include <qmap.h>
41
42 #include <TColStd_IndexedMapOfInteger.hxx>
43 #include <TColStd_MapOfInteger.hxx>
44
45 GroupGUI_GroupDlg::GroupGUI_GroupDlg(Mode mode, 
46                                      QWidget* parent, 
47                                      const char* name,
48                                      SALOME_Selection* Sel, 
49                                      bool modal, 
50                                      WFlags fl)
51   :GEOMBase_Skeleton( parent, "GroupGUI_GroupDlg", Sel, false,
52                      WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu),
53    myMode( mode ), 
54    myBusy( false )
55 {
56   QPixmap image0( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_VERTEX" ) ) );
57   QPixmap image1( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_EDGE" ) ) );
58   QPixmap image2( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_FACE" ) ) );
59   QPixmap image3( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_OBJBROWSER_SOLID" ) ) );
60   
61   QPixmap iconSelect( QAD_Desktop::getResourceManager()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
62
63   setCaption( myMode == CreateGroup ? tr( "CREATE_GROUP_TITLE" ) : tr( "EDIT_GROUP_TITLE" ) );
64
65   // Shape type button group
66   GroupConstructors->setEnabled( myMode == CreateGroup );
67   GroupConstructors->setTitle( tr( "SHAPE_TYPE" ) );
68   RadioButton1->setPixmap( image0 );
69   RadioButton2->setPixmap( image1 );
70   RadioButton3->setPixmap( image2 );
71   RadioButton4->setPixmap( image3 );
72   RadioButton4->show();
73
74   // Group name
75   GroupBoxName->setTitle( tr( "GROUP_NAME" ) );
76
77   // Main shape and sub-shapes
78   GroupMedium = new QGroupBox( 1, Qt::Vertical, tr( "MAIN_SUB_SHAPES" ), this );
79   GroupMedium->setInsideMargin( 10 );
80   Layout1->addWidget( GroupMedium, 2, 0 );
81
82   QWidget* aFrame = new QWidget( GroupMedium );
83   QGridLayout* aMedLayout = new QGridLayout( aFrame, 4, 4, 0, 6 );
84
85   QLabel* aMainLabel = new QLabel( tr( "MAIN_SHAPE" ), aFrame );
86
87   mySelBtn = new QPushButton( aFrame );
88   mySelBtn->setPixmap( iconSelect );
89   mySelBtn->setEnabled( myMode == CreateGroup );
90
91   myMainName = new QLineEdit( aFrame );
92   myMainName->setReadOnly( true );
93   myMainName->setEnabled( myMode == CreateGroup );
94   
95   mySelSubBtn = new QPushButton( tr( "SELECT_SUB_SHAPES" ), aFrame );  
96   mySelAllBtn = new QPushButton( tr( "SELECT_ALL" ), aFrame );  
97   myAddBtn    = new QPushButton( tr( "ADD" ), aFrame );  
98   myRemBtn    = new QPushButton( tr( "REMOVE" ), aFrame );  
99   myIdList    = new QListBox( aFrame );
100   
101   myIdList->setSelectionMode( QListBox::Extended );
102   myIdList->setRowMode( QListBox::FitToWidth );
103
104   aMedLayout->addWidget( aMainLabel, 0, 0 );
105   aMedLayout->addWidget( mySelBtn, 0, 1 );
106   aMedLayout->addMultiCellWidget( myMainName, 0, 0, 2, 3 );
107   aMedLayout->addMultiCellWidget( mySelSubBtn, 1, 1, 0, 2 );
108   aMedLayout->addWidget( mySelAllBtn, 1, 3 );
109   aMedLayout->addMultiCellWidget( myIdList, 2, 3, 0, 2 );
110   aMedLayout->addWidget( myAddBtn, 2, 3 );
111   aMedLayout->addWidget( myRemBtn, 3, 3 );
112
113   Init( Sel );
114 }
115
116 GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
117 {
118 }
119
120
121 //=================================================================================
122 // function : Init()
123 // purpose  :
124 //=================================================================================
125 void GroupGUI_GroupDlg::Init( SALOME_Selection* Sel )
126 {
127   mySelection = Sel;
128
129   // san -- TODO: clear selected sub-shapes...
130
131   if ( myMode == CreateGroup ) {
132     initName( tr( "GROUP_PREFIX" ) );
133
134     // Get ready for main shape selection
135     myEditCurrentArgument = myMainName;
136
137     connect( GroupConstructors, SIGNAL( clicked( int ) ),            this, SLOT( ConstructorsClicked( int ) ) );
138     connect( mySelBtn,          SIGNAL( clicked() ),                 this, SLOT(SetEditCurrentArgument()));
139   }
140   else if ( myMode == EditGroup && Sel->IObjectCount() ) {
141     Standard_Boolean aResult = Standard_False;
142     GEOM::GEOM_Object_var anObj =
143       GEOMBase::ConvertIOinGEOMObject( Sel->firstIObject(), aResult );
144     
145     if ( aResult && !CORBA::is_nil( anObj ) && anObj->GetType() == GEOM_GROUP ) {
146       myGroup = anObj;
147
148       ResultName->setText( GEOMBase::GetName( myGroup ) );
149
150       GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
151       myMainObj = anOp->GetMainShape( myGroup );
152       if ( !CORBA::is_nil( myMainObj ) )
153         myMainName->setText( GEOMBase::GetName( myMainObj ) );
154
155       setShapeType( (TopAbs_ShapeEnum)anOp->GetType( myGroup ) );
156
157       GEOM::ListOfLong_var aCurrList = anOp->GetObjects( myGroup );
158       QListBoxItem* anItem;
159       for ( int i = 0, n = aCurrList->length(); i < n; i++ ) {
160         anItem = new QListBoxText( QString( "%1" ).arg(aCurrList[i] ) );
161         myIdList->insertItem( anItem );
162       }
163
164       myEditCurrentArgument = 0;
165     }
166   }
167
168   connect( buttonOk   , SIGNAL( clicked() ), this, SLOT( ClickOnOk()    ) );
169   connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
170
171   connect( mySelSubBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
172   connect( mySelAllBtn, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
173   connect( mySelection,SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
174   connect( mySelAllBtn, SIGNAL( clicked() ), this, SLOT( selectAllSubShapes() ) );
175   connect( myAddBtn,    SIGNAL( clicked() ), this, SLOT( add() ) );
176   connect( myRemBtn,    SIGNAL( clicked() ), this, SLOT( remove() ) );
177   connect( myIdList,    SIGNAL( selectionChanged() ), this, SLOT( selectionChanged() ) );
178
179   activateSelection();
180 }
181
182 //=================================================================================
183 // function : enterEvent()
184 // purpose  :
185 //=================================================================================
186 void GroupGUI_GroupDlg::enterEvent( QEvent* e )
187 {
188   if ( !buttonCancel->isEnabled() )
189     this->ActivateThisDialog();
190 }
191
192 //=================================================================================
193 // function : ClickOnOk()
194 // purpose  :
195 //=================================================================================
196 void GroupGUI_GroupDlg::ClickOnOk()
197 {
198   if ( ClickOnApply() )
199     ClickOnCancel();
200 }
201
202
203 //=================================================================================
204 // function : ClickOnApply()
205 // purpose  :
206 //=================================================================================
207 bool GroupGUI_GroupDlg::ClickOnApply()
208 {
209   if ( !onAccept( myMode == CreateGroup, true ) )
210     return false;
211
212   if ( myMode == CreateGroup )
213     initName();
214   return true;
215 }
216
217
218 //=================================================================================
219 // function : ActivateThisDialog()
220 // purpose  :
221 //=================================================================================
222 void GroupGUI_GroupDlg::ActivateThisDialog()
223 {
224   GEOMBase_Skeleton::ActivateThisDialog();
225
226   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
227
228   activateSelection();
229 }
230
231 //=================================================================================
232 // function : LineEditReturnPressed()
233 // purpose  :
234 //=================================================================================
235 void GroupGUI_GroupDlg::LineEditReturnPressed()
236 {
237   QLineEdit* send = ( QLineEdit* )sender();
238   
239   if ( send == myMainName && !myEditCurrentArgument ) {
240     myEditCurrentArgument = myMainName;
241     activateSelection();
242   }
243   else
244     GEOMBase_Skeleton::LineEditReturnPressed();
245
246   updateState();
247 }
248
249
250 //=================================================================================
251 // function : SetEditCurrentArgument()
252 // purpose  :
253 //=================================================================================
254 void GroupGUI_GroupDlg::SetEditCurrentArgument()
255 {
256   QPushButton* send = (QPushButton*)sender();
257
258   if ( send == mySelBtn )
259     myEditCurrentArgument = myMainName;
260   else if ( send == mySelSubBtn || send == mySelAllBtn )
261     myEditCurrentArgument = 0;
262
263   activateSelection();
264   updateState();
265 }
266
267
268 //=================================================================================
269 // function : SelectionIntoArgument()
270 // purpose  : Called when selection has changed
271 //=================================================================================
272 void GroupGUI_GroupDlg::SelectionIntoArgument()
273 {
274   if ( myEditCurrentArgument ) {  // Selection of a main shape is active
275     myEditCurrentArgument->setText( "" );
276     
277     if ( mySelection->IObjectCount() == 1 ) {
278       Standard_Boolean aResult = Standard_False;
279       GEOM::GEOM_Object_var anObj =
280         GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
281
282       if ( aResult && !anObj->_is_nil() && GEOMBase::IsShape( anObj ) ) {
283         myMainObj = anObj;
284         myEditCurrentArgument->setText( GEOMBase::GetName( anObj ) );
285         updateState();
286         return;
287       }
288     }
289
290     myMainObj = GEOM::GEOM_Object::_nil();
291   }
292   else {  // an attempt to synchronize list box selection with 3d viewer
293     if ( myBusy )
294       return;
295
296     bool isBlocked = myIdList->signalsBlocked();
297     myIdList->blockSignals( true );
298     myIdList->clearSelection();
299
300     if ( mySelection->IObjectCount() == 1 ) {
301       Standard_Boolean aResult = Standard_False;
302       GEOM::GEOM_Object_var anObj =
303         GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
304       
305       if ( aResult && !anObj->_is_nil() ) {
306         QMap<int, int> aMap;
307         for ( int i = 0, n = myIdList->count(); i < n; i++ )
308           aMap.insert( myIdList->item( i )->text().toInt(), i );
309         
310         TColStd_IndexedMapOfInteger aMapIndex;
311         mySelection->GetIndex( mySelection->firstIObject(), aMapIndex );
312         for ( int ii = 1, nn = aMapIndex.Extent(); ii <= nn; ii++ ) {
313           if ( aMap.contains( aMapIndex( ii ) ) )
314             myIdList->setSelected( aMap[aMapIndex( ii )], true );
315         }
316       }
317     }
318
319     myIdList->blockSignals( isBlocked );
320   }
321
322   updateState();
323 }
324
325 //=================================================================================
326 // function : ConstructorsClicked()
327 // purpose  : Radio button management
328 //=================================================================================
329 void GroupGUI_GroupDlg::ConstructorsClicked( int constructorId )
330 {
331   myIdList->clear();
332   activateSelection();
333   updateState();
334 }
335
336 //=================================================================================
337 // function : selectAllSubShapes
338 // purpose  : 
339 //=================================================================================
340 void GroupGUI_GroupDlg::selectAllSubShapes()
341 {
342   if ( CORBA::is_nil( myMainObj ) )
343     return;
344
345   GEOM::GEOM_IShapesOperations_var aShOp = getGeomEngine()->GetIShapesOperations( getStudyId() );
346   GEOM::GEOM_ILocalOperations_var aLocOp = getGeomEngine()->GetILocalOperations( getStudyId() );
347
348   GEOM::ListOfGO_var aSubShapes = aShOp->MakeExplode( myMainObj, getShapeType(), false );
349   if ( !aShOp->IsDone() )
350     return;
351
352   bool isBlocked = myIdList->signalsBlocked();
353   myIdList->blockSignals( true );
354   myIdList->clear();
355   
356   QListBoxItem* anItem;
357   for ( int i = 0, n = aSubShapes->length(); i < n; i++ ) {
358     CORBA::Long anIndex = aLocOp->GetSubShapeIndex( myMainObj, aSubShapes[i] );
359     if ( anIndex < 0 )
360       continue;
361
362     anItem = new QListBoxText( QString( "%1" ).arg( anIndex ) );
363     myIdList->insertItem( anItem );
364     myIdList->setSelected( anItem, true );
365   }
366
367   myIdList->blockSignals( isBlocked );
368   highlightSubShapes();
369   updateState();
370 }
371
372 //=================================================================================
373 // function : add
374 // purpose  : 
375 //=================================================================================
376 void GroupGUI_GroupDlg::add()
377 {
378   TColStd_MapOfInteger aMap;
379   for ( int i = 0, n = myIdList->count(); i < n; i++ )
380     aMap.Add( myIdList->item( i )->text().toInt() );
381
382   if ( mySelection->IObjectCount() == 1 ) {
383     Standard_Boolean aResult = Standard_False;
384     GEOM::GEOM_Object_var anObj =
385       GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
386
387     if ( aResult && !anObj->_is_nil() ) {
388       TColStd_IndexedMapOfInteger aMapIndex;
389       mySelection->GetIndex( mySelection->firstIObject(), aMapIndex );
390       QListBoxItem* anItem;
391       bool isBlocked = myIdList->signalsBlocked();
392       myIdList->blockSignals( true );
393
394       for ( int i = 1, n = aMapIndex.Extent(); i <= n; i++ ) {
395         if ( aMap.Contains( aMapIndex( i ) ) )
396           continue;
397
398         anItem = new QListBoxText( QString( "%1" ).arg( aMapIndex( i ) ) );
399         myIdList->insertItem( anItem );
400         myIdList->setSelected( anItem, true );
401       }
402
403       myIdList->blockSignals( isBlocked );
404     }
405   }
406   updateState();
407 }
408
409 //=================================================================================
410 // function : remove
411 // purpose  : 
412 //=================================================================================
413 void GroupGUI_GroupDlg::remove()
414 {
415   for ( int i = myIdList->count() - 1; i >= 0; i-- ) {
416     if ( myIdList->isSelected( i ) ) 
417       myIdList->removeItem( i );
418   }
419   updateState();
420 }
421
422
423 //=================================================================================
424 // function : getConstructorId()
425 // purpose  :
426 //=================================================================================
427 int GroupGUI_GroupDlg::getConstructorId() const
428 {
429   return GroupConstructors->id( GroupConstructors->selected() );
430 }
431
432 //=================================================================================
433 // function : getShapeType()
434 // purpose  :
435 //=================================================================================
436 TopAbs_ShapeEnum GroupGUI_GroupDlg::getShapeType() const
437 {
438   switch ( getConstructorId() ) {
439   case 0:  return TopAbs_VERTEX;
440   case 1:  return TopAbs_EDGE;
441   case 2:  return TopAbs_FACE;
442   case 3:  return TopAbs_SOLID;
443   default: return TopAbs_SHAPE;
444   }
445 }
446
447 //=================================================================================
448 // function : setShapeType()
449 // purpose  :
450 //=================================================================================
451 void GroupGUI_GroupDlg::setShapeType( const TopAbs_ShapeEnum theType )
452 {
453   int anId = 0;
454   switch ( theType ) {
455   case TopAbs_VERTEX: anId = 0; break;
456   case TopAbs_EDGE:   anId = 1; break;
457   case TopAbs_FACE:   anId = 2; break;
458   case TopAbs_SOLID:  anId = 3; break;
459   }  
460   GroupConstructors->setButton( anId );
461 }
462
463
464 //=================================================================================
465 // function : activateSelection
466 // purpose  : Activate selection in accordance with myEditCurrentArgument
467 //=================================================================================
468 void GroupGUI_GroupDlg::activateSelection()
469 {
470   globalSelection( GEOM_ALLSHAPES );
471
472   if ( !myMainObj->_is_nil() && !myEditCurrentArgument ) {
473     localSelection( myMainObj, getShapeType() );
474   }
475
476   SelectionIntoArgument();
477 }
478
479 //=================================================================================
480 // function : updateState
481 // purpose  : 
482 //=================================================================================
483 void GroupGUI_GroupDlg::updateState()
484 {
485   bool isAdd = false;
486   if ( mySelection->IObjectCount() == 1 ) {
487     Standard_Boolean aResult = Standard_False;
488     GEOM::GEOM_Object_var anObj =
489       GEOMBase::ConvertIOinGEOMObject( mySelection->firstIObject(), aResult );
490
491     if ( aResult && !anObj->_is_nil() ) {
492       TColStd_IndexedMapOfInteger aMapIndex;
493       mySelection->GetIndex( mySelection->firstIObject(), aMapIndex );
494       isAdd = aMapIndex.Extent() > 0;
495     }
496   }
497   myAddBtn->setEnabled( !myEditCurrentArgument && !CORBA::is_nil( myMainObj ) && isAdd );
498   bool hasSel = false;
499   for ( int ii = 0, nn = myIdList->count(); !hasSel && ii < nn; ii++ )
500     hasSel =  myIdList->isSelected( ii );
501   myRemBtn->setEnabled( hasSel );
502   mySelSubBtn->setEnabled( !CORBA::is_nil( myMainObj ) );
503   mySelAllBtn->setEnabled( !CORBA::is_nil( myMainObj ) );
504 }
505
506 //=================================================================================
507 // function : selectionChanged
508 // purpose  :
509 //=================================================================================
510 void GroupGUI_GroupDlg::selectionChanged()
511 {
512   highlightSubShapes();
513 }
514
515 //=================================================================================
516 // function : highlightSubShapes
517 // purpose  :
518 //=================================================================================
519 void GroupGUI_GroupDlg::highlightSubShapes()
520 {
521   if ( CORBA::is_nil( myMainObj ) )
522     return;
523
524   Standard_Boolean isOk;
525   Handle(GEOM_AISShape) aSh = 
526     GEOMBase::ConvertIORinGEOMAISShape( GEOMBase::GetIORFromObject( myMainObj ), isOk, true );
527   if ( !isOk || aSh.IsNull() )
528     return;
529
530   TColStd_MapOfInteger anIds;
531
532   myBusy = true;
533
534   for ( int ii = 0, nn = myIdList->count(); ii < nn; ii++ )
535     if ( myIdList->isSelected( ii ) )
536       anIds.Add( myIdList->item( ii )->text().toInt() );    
537
538   mySelection->ClearIObjects();
539   mySelection->AddOrRemoveIndex( aSh->getIO(), anIds, false, true );
540
541   myBusy = false;
542
543   updateState();
544 }
545
546 //=================================================================================
547 // function : createOperation
548 // purpose  :
549 //=================================================================================
550 GEOM::GEOM_IOperations_ptr GroupGUI_GroupDlg::createOperation()
551 {
552   return getGeomEngine()->GetIGroupOperations( getStudyId() );
553 }
554
555 #define RETURN_WITH_MSG(a, b) \
556   if ( !(a) ) { \
557     theMessage += (b); \
558     return false; \
559   }
560
561 //=================================================================================
562 // function : isValid()
563 // purpose  : Verify validity of input data
564 //=================================================================================
565 bool GroupGUI_GroupDlg::isValid( QString& theMessage )
566 {
567   QAD_Study* study = getStudy();
568   ASSERT(study);
569   RETURN_WITH_MSG  ( !study->getStudyDocument()->GetProperties()->IsLocked(), tr( "GEOM_STUDY_LOCKED" ) )
570
571   if ( myMode == CreateGroup ) {
572     RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_MAIN_OBJ" ) )
573   }
574   else {
575     RETURN_WITH_MSG( !CORBA::is_nil( myMainObj ), tr( "NO_GROUP" ) )
576   }
577
578   const char* aName = getNewObjectName();
579   RETURN_WITH_MSG  ( aName && strlen( aName ), tr( "EMPTY_NAME" ) )
580
581   RETURN_WITH_MSG  ( myIdList->count(), tr( "EMPTY_LIST" ) )
582   return true;
583 }
584
585 //=================================================================================
586 // function : execute
587 // purpose  :
588 //=================================================================================
589 bool GroupGUI_GroupDlg::execute( ObjectList& objects )
590 {
591   GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
592   
593   GEOM::GEOM_Object_var aGroup;
594   if ( myMode == CreateGroup ) 
595     aGroup = anOp->CreateGroup( myMainObj, getShapeType() );
596   else if ( myMode == EditGroup )
597     aGroup = myGroup;
598
599   if ( CORBA::is_nil( aGroup ) || ( myMode == CreateGroup && !anOp->IsDone() ) )
600     return false;
601
602   GEOM::ListOfLong_var aCurrList = anOp->GetObjects( aGroup );
603   if ( !anOp->IsDone()  )
604     return false;
605
606   for ( int i = 0, n = aCurrList->length(); i < n; i++ ) {
607     anOp->RemoveObject( aGroup, aCurrList[i] );
608     if ( !anOp->IsDone()  )
609       return false;
610   }
611
612   for ( int ii = 0, nn = myIdList->count(); ii < nn; ii++ ) {
613     anOp->AddObject( aGroup, myIdList->item( ii )->text().toInt() );    
614     if ( !anOp->IsDone()  )
615       return false;
616   }
617
618   QAD_Study* study = getStudy();
619   if ( study ) {
620     string IOR = GEOMBase::GetIORFromObject( aGroup );
621     if ( IOR != "" ) {
622       SALOMEDS::SObject_var SO = study->getStudyDocument()->FindObjectIOR( IOR.c_str() );
623       if ( !SO->_is_nil() ) { 
624         SALOMEDS::StudyBuilder_var aBuilder = study->getStudyDocument()->NewBuilder();
625         aBuilder->SetName( SO, getNewObjectName() );
626       }
627     }
628   }
629
630   objects.push_back( aGroup._retn() );
631
632   return true;
633 }
634
635 //================================================================
636 // Function : getFather
637 // Purpose  : Get father object for object to be added in study
638 //            ( called with addInStudy method )
639 //================================================================
640 GEOM::GEOM_Object_ptr GroupGUI_GroupDlg::getFather( GEOM::GEOM_Object_ptr theObj )
641 {
642   GEOM::GEOM_Object_var aFatherObj;
643   if ( theObj->GetType() == GEOM_GROUP ) {
644     GEOM::GEOM_IGroupOperations_var anOp = GEOM::GEOM_IGroupOperations::_narrow( getOperation() );
645     aFatherObj = anOp->GetMainShape( theObj );
646   }
647   return aFatherObj._retn();
648 }