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