Salome HOME
test integration for 0019050: EDF 521 GEOM SMESH : Improve selection process in the...
[modules/geom.git] / src / TransformationGUI / TransformationGUI_TranslationDlg.cxx
1 // GEOM GEOMGUI : GUI for Geometry 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 // File   : TransformationGUI_TranslationDlg.cxx
23 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
24 //
25
26 #include "TransformationGUI_TranslationDlg.h"
27
28 #include <DlgRef.h>
29 #include <GeometryGUI.h>
30 #include <GEOMBase.h>
31
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Session.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
36
37 #include <TopoDS_Shape.hxx>
38 #include <TopoDS_Edge.hxx>
39 #include <TopoDS.hxx>
40 #include <TopExp.hxx>
41 #include <TColStd_IndexedMapOfInteger.hxx>
42 #include <TopTools_IndexedMapOfShape.hxx>
43
44 #include <GEOMImpl_Types.hxx>
45
46 //=================================================================================
47 // class    : TransformationGUI_TranslationDlg()
48 // purpose  : Constructs a TransformationGUI_TranslationDlg which is a child of 'parent', with the 
49 //            name 'name' and widget flags set to 'f'.
50 //            The dialog will by default be modeless, unless you set 'modal' to
51 //            TRUE to construct a modal dialog.
52 //=================================================================================
53 TransformationGUI_TranslationDlg::TransformationGUI_TranslationDlg
54 ( GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl )
55   : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
56 {
57   SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
58   QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_TRANSLATION_DXYZ" ) ) );
59   QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_TRANSLATION_POINTS" ) ) );
60   QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_TRANSLATION_VECTOR" ) ) );
61   QPixmap image3( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
62
63   setWindowTitle( tr( "GEOM_TRANSLATION_TITLE" ) );
64
65   /***************************************************************/
66   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_TRANSLATION" ) );
67   mainFrame()->RadioButton1->setIcon( image0 );
68   mainFrame()->RadioButton2->setIcon( image1 );
69   mainFrame()->RadioButton3->setIcon( image2 );
70   mainFrame()->RadioButton1->setChecked( true );
71
72   GroupPoints = new DlgRef_3Sel3Spin2Check( centralWidget() );
73   GroupPoints->GroupBox1->setTitle( tr( "GEOM_ARGUMENTS" ) );
74   GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
75   GroupPoints->TextLabel3->setText( tr( "GEOM_POINT_I" ).arg( 2 ) );
76   GroupPoints->TextLabel4->setText( tr( "GEOM_DX" ) );
77   GroupPoints->TextLabel5->setText( tr( "GEOM_DY" ) );
78   GroupPoints->TextLabel6->setText( tr( "GEOM_DZ" ) );
79   GroupPoints->PushButton1->setIcon( image3 );
80   GroupPoints->PushButton2->setIcon( image3 );
81   GroupPoints->PushButton3->setIcon( image3 );
82   GroupPoints->CheckBox1->setText( tr( "Activate Distance" ) );
83   GroupPoints->CheckBox2->setText( tr( "GEOM_CREATE_COPY" ) );
84
85   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
86   layout->setMargin( 0 ); layout->setSpacing( 6 );
87   layout->addWidget( GroupPoints );
88   /***************************************************************/
89   
90   setHelpFileName( "translation_operation_page.html" );
91   
92   Init();
93 }
94
95
96 //=================================================================================
97 // function : ~TransformationGUI_TranslationDlg()
98 // purpose  : Destroys the object and frees any allocated resources
99 //=================================================================================
100 TransformationGUI_TranslationDlg::~TransformationGUI_TranslationDlg()
101 {
102   // no need to delete child widgets, Qt does it all for us
103 }
104
105
106 //=================================================================================
107 // function : Init()
108 // purpose  :
109 //=================================================================================
110 void TransformationGUI_TranslationDlg::Init()
111 {
112   /* init variables */
113   myEditCurrentArgument = GroupPoints->LineEdit1;
114   GroupPoints->LineEdit1->setReadOnly( true );
115   GroupPoints->LineEdit2->setReadOnly( true );
116   GroupPoints->LineEdit3->setReadOnly( true );
117   
118   myVector = myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
119   
120   // Activate Create a Copy mode
121   GroupPoints->CheckBox2->setChecked( true );
122   CreateCopyModeChanged( true );
123   
124   mainFrame()->GroupBoxPublish->show();
125
126   /* Get setting of step value from file configuration */
127   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
128   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100 );
129   
130   /* min, max, step and decimals for spin boxes & initial values */
131   initSpinBox( GroupPoints->SpinBox1, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
132   initSpinBox( GroupPoints->SpinBox2, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
133   initSpinBox( GroupPoints->SpinBox3, COORD_MIN, COORD_MAX, step, 3 ); // VSR: TODO: DBL_DIGITS_DISPLAY
134   
135   GroupPoints->SpinBox1->setValue( 0.0 );
136   GroupPoints->SpinBox2->setValue( 0.0 );
137   GroupPoints->SpinBox3->setValue( 0.0 );
138   
139   /* signals and slots connections */
140   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
141   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
142
143   connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
144
145   connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
146   connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
147   connect( GroupPoints->PushButton3, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
148
149   connect( GroupPoints->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); //@ Delete ?
150
151   connect( GroupPoints->SpinBox1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
152   connect( GroupPoints->SpinBox2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
153   connect( GroupPoints->SpinBox3, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox() ) );
154   
155   connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
156   
157   connect( GroupPoints->CheckBox1, SIGNAL( toggled( bool ) ), this, SLOT( ActivateDistanceChanged( bool ) ) );
158   connect( GroupPoints->CheckBox2, SIGNAL( toggled( bool ) ), this, SLOT( CreateCopyModeChanged( bool ) ) );
159   
160   connect( myGeomGUI->getApp()->selectionMgr(), 
161            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
162
163   initName( tr( "GEOM_TRANSLATION" ) );
164
165   ConstructorsClicked( 0 );
166 }
167
168
169 //=================================================================================
170 // function : SetDoubleSpinBoxStep()
171 // purpose  : Double spin box management
172 //=================================================================================
173 void TransformationGUI_TranslationDlg::SetDoubleSpinBoxStep( double step )
174 {
175   GroupPoints->SpinBox1->setSingleStep(step);
176   GroupPoints->SpinBox2->setSingleStep(step);
177   GroupPoints->SpinBox3->setSingleStep(step);
178 }
179
180 //=================================================================================
181 // function : ConstructorsClicked()
182 // purpose  : Radio button management
183 //=================================================================================
184 void TransformationGUI_TranslationDlg::ConstructorsClicked( int constructorId )
185 {
186   erasePreview();
187   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
188   
189   myEditCurrentArgument = GroupPoints->LineEdit1;
190   globalSelection();
191
192   switch ( constructorId ) {
193   case 0: /* translation an object by dx, dy, dz */
194     {    
195       GroupPoints->ShowRows( 1, 2, false );
196       GroupPoints->ShowRows( 3, 5, true );
197       GroupPoints->TextLabel6->setText( tr( "GEOM_DZ" ) );
198       GroupPoints->CheckBox1->hide();
199       GroupPoints->SpinBox3->setEnabled( true );
200       break;
201     }
202   case 1: /* translation an object by 2 points */
203     {
204       GroupPoints->ShowRows( 3, 5, false );
205       GroupPoints->ShowRows( 0, 2, true );
206       GroupPoints->CheckBox1->hide();
207       GroupPoints->TextLabel6->setText( tr( "GEOM_DZ" ) );
208       GroupPoints->TextLabel2->setText( tr( "GEOM_POINT_I" ).arg( 1 ) );
209       GroupPoints->LineEdit2->clear();
210       GroupPoints->LineEdit3->clear();
211       GroupPoints->SpinBox3->setEnabled( true );
212       myPoint1 = myPoint2 = GEOM::GEOM_Object::_nil();
213       break;
214     } 
215   case 2: /* translation an object by vector */
216     {
217       GroupPoints->ShowRows( 0, 1, true );
218       GroupPoints->ShowRows( 2, 4, false );
219       GroupPoints->ShowRows( 5, 5, true );
220       GroupPoints->CheckBox1->show();
221       GroupPoints->TextLabel6->setText( tr( "GEOM_DISTANCE" ) );
222       GroupPoints->SpinBox3->setValue( 0.0 );
223       GroupPoints->SpinBox3->setEnabled( false );
224       GroupPoints->TextLabel2->setText( tr( "GEOM_VECTOR" ) );
225       GroupPoints->LineEdit2->clear();
226       myVector = GEOM::GEOM_Object::_nil();
227       ActivateDistanceChanged( GroupPoints->CheckBox1->isChecked() );
228       break;
229     }
230   }
231   
232   qApp->processEvents();
233   updateGeometry();
234   resize( minimumSize() );
235
236   myEditCurrentArgument->setFocus();
237   connect( myGeomGUI->getApp()->selectionMgr(), 
238            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
239 }
240
241
242 //=================================================================================
243 // function : ClickOnOk()
244 // purpose  :
245 //=================================================================================
246 void TransformationGUI_TranslationDlg::ClickOnOk()
247 {
248   if ( ClickOnApply() )
249     ClickOnCancel();
250 }
251
252
253 //=================================================================================
254 // function : ClickOnApply()
255 // purpose  :
256 //=================================================================================
257 bool TransformationGUI_TranslationDlg::ClickOnApply()
258 {
259   if ( !onAccept(GroupPoints->CheckBox2->isChecked()) )
260     return false;
261   
262   initName();
263
264   return true;
265 }
266
267
268 //=================================================================================
269 // function : SelectionIntoArgument()
270 // purpose  : Called when selection as changed or other case
271 //=================================================================================
272 void TransformationGUI_TranslationDlg::SelectionIntoArgument()
273 {
274   myEditCurrentArgument->setText( "" );
275   QString aName;
276   
277   if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
278     int aNbSel = GEOMBase::GetNameOfSelectedIObjects( selectedIO(), aName );
279     
280     if ( aNbSel < 1 ) {
281       myObjects.length( 0 );
282           return;
283     }
284     GEOMBase::ConvertListOfIOInListOfGO( selectedIO(), myObjects );
285     if ( !myObjects.length() )
286       return;
287   }
288   else {
289     if ( IObjectCount() != 1 ) {
290       if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1 )
291         myPoint1 = GEOM::GEOM_Object::_nil();
292       else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 )
293         myVector = GEOM::GEOM_Object::_nil();
294       else if ( myEditCurrentArgument == GroupPoints->LineEdit3 )
295         myPoint2 = GEOM::GEOM_Object::_nil();
296       return;
297     }
298     
299     Standard_Boolean testResult = Standard_False;;
300     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
301     
302     if ( !testResult || CORBA::is_nil( aSelectedObject ) )
303       return;
304     
305     TopoDS_Shape aShape;
306     aName = GEOMBase::GetName( aSelectedObject );
307     if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
308     {
309       TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
310       if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 )
311         aNeedType = TopAbs_EDGE;
312
313       LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
314       TColStd_IndexedMapOfInteger aMap;
315       aSelMgr->GetIndexes( firstIObject(), aMap );
316       if ( aMap.Extent() == 1 )
317       {
318         int anIndex = aMap( 1 );
319         if ( aNeedType == TopAbs_EDGE )
320           aName += QString( ":edge_%1" ).arg( anIndex );
321         else
322           aName += QString( ":vertex_%1" ).arg( anIndex );
323
324         //Find SubShape Object in Father
325         GEOM::GEOM_Object_var aFindedObject = findObjectInFather( aSelectedObject, aName );
326         
327         if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
328           GEOM::GEOM_IShapesOperations_var aShapesOp =
329             getGeomEngine()->GetIShapesOperations( getStudyId() );
330           aSelectedObject = aShapesOp->GetSubShape( aSelectedObject, anIndex );
331         }
332         else
333           aSelectedObject = aFindedObject;
334       }
335       else // Global Selection
336       {
337         if ( aShape.ShapeType() != aNeedType ) {
338           aSelectedObject = GEOM::GEOM_Object::_nil();
339           aName = "";
340         }
341       }
342     }
343     
344     if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1 )
345       myPoint1 = aSelectedObject;
346     else if ( myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 2 )
347       myVector = aSelectedObject;
348     else if ( myEditCurrentArgument == GroupPoints->LineEdit3 )
349       myPoint2 = aSelectedObject;
350   }
351   
352   myEditCurrentArgument->setText( aName );
353   
354   displayPreview();
355 }
356
357
358 //=================================================================================
359 // function : LineEditReturnPressed()
360 // purpose  :
361 //=================================================================================
362 void TransformationGUI_TranslationDlg::LineEditReturnPressed()
363 {
364   QLineEdit* send = (QLineEdit*)sender();
365   if ( send == GroupPoints->LineEdit1 ) {
366     myEditCurrentArgument = send;
367     GEOMBase_Skeleton::LineEditReturnPressed();
368   }
369 }
370
371
372 //=================================================================================
373 // function : SetEditCurrentArgument()
374 // purpose  :
375 //=================================================================================
376 void TransformationGUI_TranslationDlg::SetEditCurrentArgument()
377 {    
378   QPushButton* send = (QPushButton*)sender();
379   globalSelection();
380   
381   if ( send == GroupPoints->PushButton1 ) {
382     myEditCurrentArgument = GroupPoints->LineEdit1;
383   }
384   else if ( send == GroupPoints->PushButton2 ) {
385     myEditCurrentArgument = GroupPoints->LineEdit2;
386     if ( getConstructorId() == 1 )
387       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
388     else 
389       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
390   }
391   else if ( send == GroupPoints->PushButton3 ) {
392     myEditCurrentArgument = GroupPoints->LineEdit3;
393     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
394   }
395   
396   myEditCurrentArgument->setFocus();
397   SelectionIntoArgument();
398 }
399
400
401 //=================================================================================
402 // function : ActivateThisDialog()
403 // purpose  :
404 //=================================================================================
405 void TransformationGUI_TranslationDlg::ActivateThisDialog()
406 {
407   GEOMBase_Skeleton::ActivateThisDialog();
408   
409   connect( myGeomGUI->getApp()->selectionMgr(), 
410            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
411
412   ConstructorsClicked( getConstructorId() );
413 }
414
415
416 //=================================================================================
417 // function : enterEvent()
418 // purpose  :
419 //=================================================================================
420 void TransformationGUI_TranslationDlg::enterEvent( QEvent* )
421 {
422   if ( !mainFrame()->GroupConstructors->isEnabled() )
423     ActivateThisDialog();
424 }
425
426
427 //=================================================================================
428 // function : ValueChangedInSpinBox()
429 // purpose  :
430 //=================================================================================
431 void TransformationGUI_TranslationDlg::ValueChangedInSpinBox()
432 {
433   displayPreview();
434 }
435
436
437 //=================================================================================
438 // function : createOperation
439 // purpose  :
440 //=================================================================================
441 GEOM::GEOM_IOperations_ptr TransformationGUI_TranslationDlg::createOperation()
442 {
443   return getGeomEngine()->GetITransformOperations( getStudyId() );
444 }
445
446
447 //=================================================================================
448 // function : isValid
449 // purpose  :
450 //=================================================================================
451 bool TransformationGUI_TranslationDlg::isValid( QString& /*msg*/ )
452 {
453   int aConstructorId = getConstructorId();
454   
455   switch ( aConstructorId ) {
456   case 0: 
457     {
458       Handle(SALOME_InteractiveObject) IO = firstIObject();
459       Standard_Boolean testResult;
460       GEOM::GEOM_Object_var anObject = GEOMBase::ConvertIOinGEOMObject( IO, testResult );
461       if ( !testResult || anObject->_is_nil() )
462         return false;
463       
464       return !( myObjects.length() == 0 );
465     }
466   case 1: 
467     return !( myObjects.length() == 0 || myPoint1->_is_nil() || myPoint2->_is_nil() );
468   case 2: 
469     return !( myObjects.length() == 0 || myVector->_is_nil() );
470   default: 
471     break;
472   }
473   return false;
474 }
475
476 //=================================================================================
477 // function : execute
478 // purpose  :
479 //=================================================================================
480 bool TransformationGUI_TranslationDlg::execute( ObjectList& objects )
481 {
482   bool res = false;
483   bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked();
484   
485   GEOM::GEOM_Object_var anObj;
486
487   switch ( getConstructorId() ) {
488   case 0:
489     {
490       double dx = GroupPoints->SpinBox1->value();
491       double dy = GroupPoints->SpinBox2->value();
492       double dz = GroupPoints->SpinBox3->value();
493       
494       if ( toCreateCopy ) {
495         for ( int i = 0; i < myObjects.length(); i++ ) {
496           myCurrObject = myObjects[i];
497           anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateDXDYDZCopy( myObjects[i], dx, dy, dz );
498           if ( !anObj->_is_nil() )
499             objects.push_back( anObj._retn() );
500         }
501       }
502       else {
503         for ( int i = 0; i < myObjects.length(); i++ ) {
504           myCurrObject = myObjects[i];
505           anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateDXDYDZ( myObjects[i], dx, dy, dz );
506           if ( !anObj->_is_nil() )
507             objects.push_back( anObj._retn() );
508         }
509       }
510       res = true;
511       break;
512     }
513   case 1:
514     {
515       if ( toCreateCopy ) {
516         for ( int i = 0; i < myObjects.length(); i++ ) {
517           myCurrObject = myObjects[i];
518           anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateTwoPointsCopy( myObjects[i], myPoint1, myPoint2 );
519           if ( !anObj->_is_nil() )
520             objects.push_back( anObj._retn() );
521         }
522       }
523       else {
524         for ( int i = 0; i < myObjects.length(); i++ ) {
525           myCurrObject = myObjects[i];
526           anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->TranslateTwoPoints( myObjects[i], myPoint1, myPoint2 );   
527           if ( !anObj->_is_nil() )
528             objects.push_back( anObj._retn() );
529         }
530       }
531       res = true;
532       break;
533     }
534   case 2:
535     {
536       bool byDistance = GroupPoints->CheckBox1->isChecked();
537       if ( byDistance ) {
538         double aDistance = GroupPoints->SpinBox3->value();
539         for ( int i = 0; i < myObjects.length(); i++ ) {
540           myCurrObject = myObjects[i];
541           anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
542             TranslateVectorDistance( myObjects[i], myVector, aDistance, toCreateCopy );
543           if ( !anObj->_is_nil() )
544             objects.push_back( anObj._retn() );
545         }
546       }
547       else {
548         if ( toCreateCopy ) {
549           for ( int i = 0; i < myObjects.length(); i++ ) {
550             myCurrObject = myObjects[i];
551             anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
552               TranslateVectorCopy( myObjects[i], myVector );
553             if ( !anObj->_is_nil() )
554               objects.push_back( anObj._retn() );
555             
556           }
557         }
558         else {
559           for (int i = 0; i < myObjects.length(); i++) {
560             myCurrObject = myObjects[i];
561             anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->
562               TranslateVector( myObjects[i], myVector );
563             if ( !anObj->_is_nil() )
564               objects.push_back( anObj._retn() );
565           }
566         }
567       }
568       res = true;
569       break;
570     }
571   }
572   return res;
573 }
574
575 //=================================================================================
576 // function : restoreSubShapes
577 // purpose  :
578 //=================================================================================
579 void TransformationGUI_TranslationDlg::restoreSubShapes( SALOMEDS::Study_ptr   theStudy,
580                                                          SALOMEDS::SObject_ptr theSObject )
581 {
582   if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
583     // we pass here the first operation argument (object) through the list of arguments
584     // because the rotation operation place its arguments in the data structure in another order,
585     // and we need to point the first argument directly
586     GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
587     anArgs->length( 1);
588     anArgs[0] = myCurrObject;
589     getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, anArgs,
590                                          /*theFindMethod=*/GEOM::FSM_Transformed,
591                                          /*theInheritFirstArg=*/true );
592   }
593 }
594
595 //=================================================================================
596 // function :  CreateCopyModeChanged()
597 // purpose  :
598 //=================================================================================
599 void TransformationGUI_TranslationDlg::CreateCopyModeChanged( bool isCreateCopy )
600 {
601   mainFrame()->GroupBoxName->setEnabled( isCreateCopy );
602 }
603
604 //=================================================================================
605 // function :  ActivateDistanceChanged()
606 // purpose  :
607 //=================================================================================
608 void TransformationGUI_TranslationDlg::ActivateDistanceChanged( bool theEnable )
609 {
610   GroupPoints->SpinBox3->setEnabled( theEnable );
611   displayPreview();
612 }
613
614 //=================================================================================
615 // function : addSubshapeToStudy
616 // purpose  : virtual method to add new SubObjects if local selection
617 //=================================================================================
618 void TransformationGUI_TranslationDlg::addSubshapesToStudy()
619 {
620   bool toCreateCopy = IsPreview() || GroupPoints->CheckBox2->isChecked();
621   if ( toCreateCopy ) {
622     QMap<QString, GEOM::GEOM_Object_var> objMap;
623
624     switch ( getConstructorId() ) {
625     case 0:
626       return;
627     case 1:
628       objMap[GroupPoints->LineEdit2->text()] = myPoint1;
629       objMap[GroupPoints->LineEdit3->text()] = myPoint2;
630       break;
631     case 2:
632       objMap[GroupPoints->LineEdit2->text()] = myVector;
633       break;
634     }
635     addSubshapesToFather( objMap );
636   }
637 }