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