Salome HOME
additional fix to IPAL 22046 TC5.1.5: Modify the Location - impossible to select...
[modules/geom.git] / src / TransformationGUI / TransformationGUI_PositionDlg.cxx
1 //  Copyright (C) 2007-2010  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.
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_PositionDlg.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
26 //
27 #include "TransformationGUI_PositionDlg.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 <SalomeApp_Application.h>
36 #include <LightApp_SelectionMgr.h>
37 #include <TColStd_IndexedMapOfInteger.hxx>
38
39 // OCCT Includes
40 #include <TColStd_MapOfInteger.hxx>
41
42 #include <GEOMImpl_Types.hxx>
43
44 //=================================================================================
45 // class    : TransformationGUI_PositionDlg()
46 // purpose  : Constructs a TransformationGUI_PositionDlg which is a child of 'parent', with the
47 //            name 'name' and widget flags set to 'f'.
48 //            The dialog will by default be modeless, unless you set 'modal' to
49 //            TRUE to construct a modal dialog.
50 //=================================================================================
51 TransformationGUI_PositionDlg::TransformationGUI_PositionDlg
52 (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
53   : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
54     myInitial(true)
55 {
56   SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
57   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION")));
58   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION2")));
59   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION3")));
60   QPixmap imageselect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
61
62   setWindowTitle(tr("GEOM_POSITION_TITLE"));
63
64   /***************************************************************/
65   mainFrame()->GroupConstructors->setTitle(tr("GEOM_POSITION"));
66   mainFrame()->RadioButton1->setIcon(image0);
67   mainFrame()->RadioButton2->setIcon(image1);
68   mainFrame()->RadioButton3->setIcon(image2);
69
70   Group1 = new DlgRef_4Sel1Spin3Check(centralWidget());
71   Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
72   Group1->TextLabel1->setText(tr("GEOM_OBJECTS"));
73   Group1->TextLabel2->setText(tr("GEOM_START_LCS"));
74   Group1->TextLabel3->setText(tr("GEOM_DISTANCE"));
75   Group1->TextLabel4->setText(tr("GEOM_END_LCS"));
76   Group1->TextLabel5->setText(tr("GEOM_PATH_OBJECT"));
77   Group1->PushButton1->setIcon(imageselect);
78   Group1->PushButton2->setIcon(imageselect);
79   Group1->PushButton4->setIcon(imageselect);
80   Group1->PushButton5->setIcon(imageselect);
81   Group1->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
82   Group1->CheckButton2->setText(tr("SELECT_UNPUBLISHED_EDGES"));
83   Group1->CheckButton3->setText(tr("GEOM_REVERSE_DIRECTION"));
84
85   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
86   layout->setMargin(0); layout->setSpacing(6);
87   layout->addWidget(Group1);
88   /***************************************************************/
89
90   setHelpFileName("modify_location_operation_page.html");
91
92   // Activate Create a Copy mode
93   Group1->CheckButton1->setChecked(true);
94   Group1->CheckButton1->setChecked(false);
95   CreateCopyModeChanged(true);
96
97   Init();
98 }
99
100 //=================================================================================
101 // function : ~TransformationGUI_PositionDlg()
102 // purpose  : Destroys the object and frees any allocated resources
103 //=================================================================================
104 TransformationGUI_PositionDlg::~TransformationGUI_PositionDlg()
105 {
106   // no need to delete child widgets, Qt does it all for us
107 }
108
109 //=================================================================================
110 // function : Init()
111 // purpose  :
112 //=================================================================================
113 void TransformationGUI_PositionDlg::Init()
114 {
115   // init variables
116   Group1->LineEdit1->setReadOnly(true);
117   Group1->LineEdit2->setReadOnly(true);
118   Group1->LineEdit4->setReadOnly(true);
119   Group1->LineEdit5->setReadOnly(true);
120
121   Group1->LineEdit1->setText("");
122   Group1->LineEdit2->setText("");
123   Group1->LineEdit4->setText("");
124   Group1->LineEdit5->setText("");
125
126   initSpinBox(Group1->SpinBox_DX, 0, 1, 0.05, "parametric_precision" );
127   Group1->SpinBox_DX->setValue(0);
128
129   Group1->CheckButton2->setEnabled(false);
130
131   myStartLCS = myEndLCS = GEOM::GEOM_Object::_nil();
132
133   mainFrame()->GroupBoxPublish->show();
134
135   // signals and slots connections
136   connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
137   connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
138
139   connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
140
141   connect(Group1->PushButton1, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
142   connect(Group1->PushButton2, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
143   connect(Group1->PushButton4, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
144   connect(Group1->PushButton5, SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));
145
146   connect(Group1->LineEdit1,   SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
147   connect(Group1->LineEdit2,   SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
148   connect(Group1->LineEdit4,   SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
149   connect(Group1->LineEdit5,   SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
150
151   connect(Group1->CheckButton1,   SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
152   connect(Group1->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
153
154   connect(Group1->CheckButton2,   SIGNAL(toggled(bool)), this, SLOT(SelectionTypeButtonClicked()));
155   connect(Group1->CheckButton3,   SIGNAL(toggled(bool)), this, SLOT(ValueChangedInSpinBox()));
156
157   initName(tr("GEOM_POSITION"));
158
159   ConstructorsClicked(0);
160 }
161
162 //=================================================================================
163 // function : ConstructorsClicked()
164 // purpose  : Radio button management
165 //=================================================================================
166 void TransformationGUI_PositionDlg::ConstructorsClicked (int constructorId)
167 {
168   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
169
170   Group1->LineEdit2->clear();
171   Group1->LineEdit4->clear();
172   Group1->LineEdit5->clear();
173   myStartLCS = GEOM::GEOM_Object::_nil();
174   myEndLCS = GEOM::GEOM_Object::_nil();
175   myPath = GEOM::GEOM_Object::_nil();
176
177   switch (constructorId) {
178   case 0:
179     {
180       Group1->LineEdit2->hide();
181       Group1->TextLabel2->hide();
182       Group1->PushButton2->hide();
183
184       Group1->LineEdit5->hide();
185       Group1->TextLabel5->hide();
186       Group1->PushButton5->hide();
187
188       Group1->SpinBox_DX->hide();
189       Group1->TextLabel3->hide();
190
191       Group1->LineEdit4->show();
192       Group1->TextLabel4->show();
193       Group1->PushButton4->show();
194
195       Group1->PushButton1->click();
196
197       Group1->CheckButton2->hide();
198       Group1->CheckButton3->hide();
199     }
200     break;
201   case 1:
202     {
203       Group1->LineEdit2->show();
204       Group1->TextLabel2->show();
205       Group1->PushButton2->show();
206
207       Group1->LineEdit5->hide();
208       Group1->TextLabel5->hide();
209       Group1->PushButton5->hide();
210
211       Group1->SpinBox_DX->hide();
212       Group1->TextLabel3->hide();
213
214       Group1->PushButton1->click();
215
216       Group1->CheckButton2->hide();
217       Group1->CheckButton3->hide();
218     }
219     break;
220   case 2:
221     {
222       Group1->LineEdit4->hide();
223       Group1->TextLabel4->hide();
224       Group1->PushButton4->hide();
225
226       Group1->LineEdit2->hide();
227       Group1->TextLabel2->hide();
228       Group1->PushButton2->hide();
229
230       Group1->LineEdit5->show();
231       Group1->TextLabel5->show();
232       Group1->PushButton5->show();
233
234       Group1->SpinBox_DX->show();
235       Group1->TextLabel3->show();
236
237       Group1->PushButton1->click();
238
239       Group1->CheckButton2->show();
240       Group1->CheckButton3->show();
241     }
242     break;
243   }
244
245   qApp->processEvents();
246   updateGeometry();
247   resize(minimumSizeHint());
248
249   if (myInitial) {
250     myInitial = false;
251     SelectionIntoArgument();
252   }
253   else {
254     displayPreview();
255   }
256 }
257
258 //=================================================================================
259 // function : SelectionBittonClicked()
260 // purpose  : Selection type Radio button management
261 //=================================================================================
262 void TransformationGUI_PositionDlg::SelectionTypeButtonClicked()
263 {
264   if ( Group1->CheckButton2->isChecked() ) {
265     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
266   } else {
267     TColStd_MapOfInteger aMap;
268     aMap.Add(GEOM_WIRE);
269     aMap.Add(GEOM_LINE);
270     globalSelection(aMap);
271   }
272 }
273
274 //=================================================================================
275 // function : ValueChangedInSpinBox()
276 // purpose  :
277 //=================================================================================
278 void TransformationGUI_PositionDlg::ValueChangedInSpinBox()
279 {
280   displayPreview();
281 }
282
283 //=================================================================================
284 // function : ClickOnOk()
285 // purpose  :
286 //=================================================================================
287 void TransformationGUI_PositionDlg::ClickOnOk()
288 {
289   if (ClickOnApply())
290     ClickOnCancel();
291 }
292
293 //=================================================================================
294 // function : ClickOnApply()
295 // purpose  :
296 //=================================================================================
297 bool TransformationGUI_PositionDlg::ClickOnApply()
298 {
299   if (!onAccept(Group1->CheckButton1->isChecked()))
300     return false;
301
302   initName();
303
304   myObjects.length(0);
305   myEditCurrentArgument = Group1->LineEdit1;
306   myEditCurrentArgument->setText("");
307   myGeomGUI->getApp()->selectionMgr()->clearSelected();
308
309   // activate selection and connect selection manager
310   ConstructorsClicked(getConstructorId());
311   return true;
312 }
313
314 //=================================================================================
315 // function : SelectionIntoArgument()
316 // purpose  : Called when selection is changed or on dialog initialization or activation
317 //=================================================================================
318 void TransformationGUI_PositionDlg::SelectionIntoArgument()
319 {
320   erasePreview();
321   myEditCurrentArgument->setText("");
322
323   if (myEditCurrentArgument == Group1->LineEdit1)
324     myObjects.length(0);
325   else if (myEditCurrentArgument == Group1->LineEdit2)
326     myStartLCS = GEOM::GEOM_Object::_nil();
327   else if (myEditCurrentArgument == Group1->LineEdit4)
328     myEndLCS = GEOM::GEOM_Object::_nil();
329   else if (myEditCurrentArgument == Group1->LineEdit5)
330     myPath = GEOM::GEOM_Object::_nil();
331
332   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
333   SALOME_ListIO aSelList;
334   aSelMgr->selectedObjects(aSelList);
335
336   QString aName;
337
338   if (myEditCurrentArgument == Group1->LineEdit1) {
339     int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
340     if (aNbSel < 1)
341       return;
342
343     GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
344     if (!myObjects.length())
345       return;
346     else
347       myEditCurrentArgument->setText(aName);
348
349     /*    if (getConstructorId() == 2)
350           Group1->PushButton5->click();*/
351   }
352   else if (myEditCurrentArgument == Group1->LineEdit2) {
353     if (aSelList.Extent() != 1)
354       return;
355
356     // nbSel == 1
357     Standard_Boolean testResult = Standard_False;
358     myStartLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
359     if (!testResult || CORBA::is_nil(myStartLCS))
360       return;
361
362     aName = GEOMBase::GetName(myStartLCS);
363     myEditCurrentArgument->setText(aName);
364
365     if (!myStartLCS->_is_nil() && myEndLCS->_is_nil())
366       Group1->PushButton4->click();
367   }
368   else if (myEditCurrentArgument == Group1->LineEdit4) {
369     myEndLCS = GEOM::GEOM_Object::_nil();
370     if (aSelList.Extent() != 1)
371       return;
372
373     Standard_Boolean testResult = Standard_False;
374     myEndLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
375     if (!testResult || CORBA::is_nil(myEndLCS))
376       return;
377
378     aName = GEOMBase::GetName(myEndLCS);
379     myEditCurrentArgument->setText(aName);
380
381     if (!myEndLCS->_is_nil() && !myObjects.length())
382       Group1->PushButton1->click();
383   }
384   else if (myEditCurrentArgument == Group1->LineEdit5) {
385     myPath = GEOM::GEOM_Object::_nil();
386     if (aSelList.Extent() != 1)
387       return;
388
389     Standard_Boolean testResult = Standard_False;
390     GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
391     if (!testResult || aSelectedObject->_is_nil())
392       return;
393
394     aName = GEOMBase::GetName(myPath);
395     // Local Selection
396     TopoDS_Shape S;
397     if (!GEOMBase::GetShape(aSelectedObject, S))
398       return;
399     
400     TColStd_IndexedMapOfInteger aMap;
401     aSelMgr->GetIndexes(aSelList.First(), aMap);
402     aName = GEOMBase::GetName(aSelectedObject);
403     if (aMap.Extent() == 1) {
404       int anIndex = aMap(1);
405       aName.append(":edge_" + QString::number(anIndex));
406       
407       //Find SubShape Object in Father
408       GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
409       
410       if (aFindedObject->_is_nil()) { // Object not found in study
411         GEOM::GEOM_IShapesOperations_var aShapesOp =
412           getGeomEngine()->GetIShapesOperations(getStudyId());
413         aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
414       }
415       else { // get Object from study
416         aSelectedObject = aFindedObject;
417       }
418     }
419     else {
420       if (S.ShapeType() != TopAbs_EDGE && S.ShapeType() != TopAbs_WIRE) {
421         aSelectedObject = GEOM::GEOM_Object::_nil();
422         aName = "";
423         return;
424       }
425     }
426     
427     myEditCurrentArgument->setText(aName);
428     myPath = aSelectedObject;
429
430     if (!myPath->_is_nil() && !myObjects.length())
431       Group1->PushButton1->click();
432   }
433
434   // clear selection
435   /*  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
436   myGeomGUI->getApp()->selectionMgr()->clearSelected();
437   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
438   this, SLOT(SelectionIntoArgument()));*/
439   // here commented, because multiple objects can be selected IPAL 21437
440
441   displayPreview();
442 }
443
444 //=================================================================================
445 // function : SetEditCurrentArgument()
446 // purpose  :
447 //=================================================================================
448 void TransformationGUI_PositionDlg::SetEditCurrentArgument()
449 {
450   QPushButton* send = (QPushButton*)sender();
451
452   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
453   if (send == Group1->PushButton1) {
454     myEditCurrentArgument = Group1->LineEdit1;
455
456     globalSelection();
457
458     Group1->PushButton2->setDown(false);
459     Group1->PushButton4->setDown(false);
460     Group1->PushButton5->setDown(false);
461     Group1->LineEdit2->setEnabled(false);
462     Group1->LineEdit4->setEnabled(false);
463     Group1->LineEdit5->setEnabled(false);
464
465     Group1->CheckButton2->setEnabled(false);
466   }
467   else if (send == Group1->PushButton2) {
468     myEditCurrentArgument = Group1->LineEdit2;
469
470     TColStd_MapOfInteger aMap;
471     aMap.Add(GEOM_PLANE);
472     aMap.Add(GEOM_MARKER);
473     globalSelection(aMap);
474
475     Group1->PushButton1->setDown(false);
476     Group1->PushButton4->setDown(false);
477     Group1->PushButton5->setDown(false);
478     Group1->LineEdit1->setEnabled(false);
479     Group1->LineEdit4->setEnabled(false);
480     Group1->LineEdit5->setEnabled(false);
481
482     Group1->CheckButton2->setEnabled(false);
483   }
484   else if (send == Group1->PushButton4) {
485     myEditCurrentArgument = Group1->LineEdit4;
486
487     TColStd_MapOfInteger aMap;
488     aMap.Add(GEOM_PLANE);
489     aMap.Add(GEOM_MARKER);
490     globalSelection(aMap);
491
492     Group1->PushButton1->setDown(false);
493     Group1->PushButton2->setDown(false);
494     Group1->PushButton5->setDown(false);
495     Group1->LineEdit1->setEnabled(false);
496     Group1->LineEdit2->setEnabled(false);
497     Group1->LineEdit5->setEnabled(false);
498
499     Group1->CheckButton2->setEnabled(false);
500   }
501   else if (send == Group1->PushButton5) {
502     myEditCurrentArgument = Group1->LineEdit5;
503
504     Group1->CheckButton2->setEnabled(true);
505
506     if ( Group1->CheckButton2->isChecked() ) {
507       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
508     } else {
509       TColStd_MapOfInteger aMap;
510       aMap.Add(GEOM_WIRE);
511       aMap.Add(GEOM_LINE);
512       globalSelection(aMap);
513     }
514
515     Group1->PushButton1->setDown(false);
516     Group1->PushButton2->setDown(false);
517     Group1->PushButton4->setDown(false);
518     Group1->LineEdit1->setEnabled(false);
519     Group1->LineEdit2->setEnabled(false);
520     Group1->LineEdit4->setEnabled(false);
521   }
522   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
523           this, SLOT(SelectionIntoArgument()));
524
525   // enable line edit
526   myEditCurrentArgument->setEnabled(true);
527   myEditCurrentArgument->setFocus();
528   // after setFocus(), because it will be setDown(false) when loses focus
529   send->setDown(true);
530
531   // seems we need it only to avoid preview disappearing, caused by selection mode change
532   displayPreview();
533 }
534
535 //=================================================================================
536 // function : LineEditReturnPressed()
537 // purpose  :
538 //=================================================================================
539 void TransformationGUI_PositionDlg::LineEditReturnPressed()
540 {
541   QLineEdit* send = (QLineEdit*)sender();
542   if (send == Group1->LineEdit1 ||
543       send == Group1->LineEdit2 ||
544       send == Group1->LineEdit4 ||
545       send == Group1->LineEdit5 ) {
546     myEditCurrentArgument = send;
547     GEOMBase_Skeleton::LineEditReturnPressed();
548   }
549
550   if (send == Group1->LineEdit5)
551     Group1->CheckButton2->setEnabled(true);
552   else
553     Group1->CheckButton2->setEnabled(false);
554 }
555
556 //=================================================================================
557 // function : ActivateThisDialog()
558 // purpose  :
559 //=================================================================================
560 void TransformationGUI_PositionDlg::ActivateThisDialog()
561 {
562   GEOMBase_Skeleton::ActivateThisDialog();
563   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
564            this, SLOT( SelectionIntoArgument() ) );
565
566   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
567            this, SLOT( SelectionIntoArgument() ) );
568
569   ConstructorsClicked( getConstructorId() );
570 }
571
572 //=================================================================================
573 // function : enterEvent()
574 // purpose  : when mouse enter onto the QWidget
575 //=================================================================================
576 void TransformationGUI_PositionDlg::enterEvent (QEvent*)
577 {
578   if (!mainFrame()->GroupConstructors->isEnabled())
579     ActivateThisDialog();
580 }
581
582 //=================================================================================
583 // function : createOperation
584 // purpose  :
585 //=================================================================================
586 GEOM::GEOM_IOperations_ptr TransformationGUI_PositionDlg::createOperation()
587 {
588   return getGeomEngine()->GetITransformOperations(getStudyId());
589 }
590
591 //=================================================================================
592 // function : isValid
593 // purpose  :
594 //=================================================================================
595 bool TransformationGUI_PositionDlg::isValid (QString& /*msg*/)
596 {
597   bool res;
598   if (getConstructorId() == 0)
599     res = !(myObjects.length() == 0 || myEndLCS->_is_nil());
600   else if ( getConstructorId() == 1 )
601     res = !(myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil());
602   else if ( getConstructorId() == 2 )
603     res = !(myObjects.length() == 0 || myPath->_is_nil());
604
605   return res;
606 }
607
608 //=================================================================================
609 // function : execute
610 // purpose  :
611 //=================================================================================
612 bool TransformationGUI_PositionDlg::execute (ObjectList& objects)
613 {
614   bool res = false;
615   bool toCreateCopy = IsPreview() || Group1->CheckButton1->isChecked();
616   GEOM::GEOM_Object_var anObj;
617
618   GEOM::GEOM_ITransformOperations_var anOper = GEOM::GEOM_ITransformOperations::_narrow(getOperation());
619
620   switch (getConstructorId()) {
621   case 0:
622     {
623       for (int i = 0; i < myObjects.length(); i++) {
624         anObj = toCreateCopy ? 
625           anOper->PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS) :
626           anOper->PositionShape(myObjects[i], myObjects[i], myEndLCS);
627
628         if (!anObj->_is_nil())
629           objects.push_back(anObj._retn());
630       }
631       res = true;
632       break;
633     }
634   case 1:
635     {
636       for (int i = 0; i < myObjects.length(); i++) {
637           anObj = toCreateCopy ? 
638             anOper->PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS) :
639             anOper->PositionShape(myObjects[i], myStartLCS, myEndLCS);
640         if (!anObj->_is_nil())
641           objects.push_back(anObj._retn());
642       }
643       res = true;
644       break;
645     }
646   case 2:
647     {
648       double aDistance = Group1->SpinBox_DX->value();
649       bool toReverse = Group1->CheckButton3->isChecked();
650       for (int i = 0; i < myObjects.length(); i++) {
651         anObj = anOper->PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse);
652         if (!anObj->_is_nil())
653           objects.push_back(anObj._retn());
654       }
655       res = true;
656       break;
657     }
658   }
659
660   return res;
661 }
662
663 //=================================================================================
664 // function : restoreSubShapes
665 // purpose  :
666 //=================================================================================
667 void TransformationGUI_PositionDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStudy,
668                                                       SALOMEDS::SObject_ptr theSObject)
669 {
670   if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
671     // empty list of arguments means that all arguments should be restored
672     getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
673                                         /*theFindMethod=*/GEOM::FSM_Transformed,
674                                         /*theInheritFirstArg=*/true,
675                                         mainFrame()->CheckBoxAddPrefix->isChecked());
676   }
677 }
678
679 //=================================================================================
680 // function :  CreateCopyModeChanged()
681 // purpose  :
682 //=================================================================================
683 void TransformationGUI_PositionDlg::CreateCopyModeChanged (bool isCreateCopy)
684 {
685   mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
686 }
687
688 //=================================================================================
689 // function : addSubshapeToStudy
690 // purpose  : virtual method to add new SubObjects if local selection
691 //=================================================================================
692 void TransformationGUI_PositionDlg::addSubshapesToStudy()
693 {
694   QMap<QString, GEOM::GEOM_Object_var> objMap;
695
696   objMap[Group1->LineEdit5->text()] = myPath;
697
698   addSubshapesToFather(objMap);
699 }