Salome HOME
Update from BR_V5_DEV 13Feb2009
[modules/geom.git] / src / TransformationGUI / TransformationGUI_PositionDlg.cxx
1 //  Copyright (C) 2007-2008  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 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : TransformationGUI_PositionDlg.cxx
24 // Author : Damien COQUERET, Open CASCADE S.A.S.
25 //
26 #include "TransformationGUI_PositionDlg.h"
27
28 #include <DlgRef.h>
29 #include <GeometryGUI.h>
30 #include <GEOMBase.h>
31
32 #include <SUIT_Session.h>
33 #include <SUIT_ResourceMgr.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
36 #include <TColStd_IndexedMapOfInteger.hxx>
37
38 // OCCT Includes
39 #include <TColStd_MapOfInteger.hxx>
40
41 #include <GEOMImpl_Types.hxx>
42
43 //=================================================================================
44 // class    : TransformationGUI_PositionDlg()
45 // purpose  : Constructs a TransformationGUI_PositionDlg which is a child of 'parent', with the
46 //            name 'name' and widget flags set to 'f'.
47 //            The dialog will by default be modeless, unless you set 'modal' to
48 //            TRUE to construct a modal dialog.
49 //=================================================================================
50 TransformationGUI_PositionDlg::TransformationGUI_PositionDlg
51 (GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
52   : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl),
53     myInitial(true)
54 {
55   SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
56   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION")));
57   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION2")));
58   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_POSITION3")));
59   QPixmap imageselect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
60
61   setWindowTitle(tr("GEOM_POSITION_TITLE"));
62
63   /***************************************************************/
64   mainFrame()->GroupConstructors->setTitle(tr("GEOM_POSITION"));
65   mainFrame()->RadioButton1->setIcon(image0);
66   mainFrame()->RadioButton2->setIcon(image1);
67   mainFrame()->RadioButton3->setIcon(image2);
68
69   Group1 = new DlgRef_4Sel1Spin3Check(centralWidget());
70   Group1->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
71   Group1->TextLabel1->setText(tr("GEOM_OBJECTS"));
72   Group1->TextLabel2->setText(tr("GEOM_START_LCS"));
73   Group1->TextLabel3->setText(tr("GEOM_DISTANCE"));
74   Group1->TextLabel4->setText(tr("GEOM_END_LCS"));
75   Group1->TextLabel5->setText(tr("GEOM_PATH_OBJECT"));
76   Group1->PushButton1->setIcon(imageselect);
77   Group1->PushButton2->setIcon(imageselect);
78   Group1->PushButton4->setIcon(imageselect);
79   Group1->PushButton5->setIcon(imageselect);
80   Group1->CheckButton1->setText(tr("GEOM_CREATE_COPY"));
81   Group1->CheckButton2->setText(tr("SELECT_UNPUBLISHED_EDGES"));
82   Group1->CheckButton3->setText(tr("GEOM_REVERSE_DIRECTION"));
83
84   QVBoxLayout* layout = new QVBoxLayout(centralWidget());
85   layout->setMargin(0); layout->setSpacing(6);
86   layout->addWidget(Group1);
87   /***************************************************************/
88
89   setHelpFileName("modify_location_operation_page.html");
90
91   // Activate Create a Copy mode
92   Group1->CheckButton1->setChecked(true);
93   Group1->CheckButton1->setChecked(false);
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, 6); // VSR:TODO : DBL_DIGITS_DISPLAY
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   // activate selection and connect selection manager
303   ConstructorsClicked(getConstructorId());
304   return true;
305 }
306
307 //=================================================================================
308 // function : SelectionIntoArgument()
309 // purpose  : Called when selection is changed or on dialog initialization or activation
310 //=================================================================================
311 void TransformationGUI_PositionDlg::SelectionIntoArgument()
312 {
313   erasePreview();
314   myEditCurrentArgument->setText("");
315
316   if (myEditCurrentArgument == Group1->LineEdit1)
317     myObjects.length(0);
318   else if (myEditCurrentArgument == Group1->LineEdit2)
319     myStartLCS = GEOM::GEOM_Object::_nil();
320   else if (myEditCurrentArgument == Group1->LineEdit4)
321     myEndLCS = GEOM::GEOM_Object::_nil();
322   else if (myEditCurrentArgument == Group1->LineEdit5)
323     myPath = GEOM::GEOM_Object::_nil();
324
325   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
326   SALOME_ListIO aSelList;
327   aSelMgr->selectedObjects(aSelList);
328
329   QString aName;
330
331   if (myEditCurrentArgument == Group1->LineEdit1) {
332     int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
333     if (aNbSel < 1)
334       return;
335
336     GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
337     if (!myObjects.length())
338       return;
339     else
340       myEditCurrentArgument->setText(aName);
341
342     if (getConstructorId() == 2)
343       Group1->PushButton5->click();
344   }
345   else if (myEditCurrentArgument == Group1->LineEdit2) {
346     if (aSelList.Extent() != 1)
347       return;
348
349     // nbSel == 1
350     Standard_Boolean testResult = Standard_False;
351     myStartLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
352     if (!testResult || CORBA::is_nil(myStartLCS))
353       return;
354
355     aName = GEOMBase::GetName(myStartLCS);
356     myEditCurrentArgument->setText(aName);
357
358     if (!myStartLCS->_is_nil() && myEndLCS->_is_nil())
359       Group1->PushButton4->click();
360   }
361   else if (myEditCurrentArgument == Group1->LineEdit4) {
362     myEndLCS = GEOM::GEOM_Object::_nil();
363     if (aSelList.Extent() != 1)
364       return;
365
366     Standard_Boolean testResult = Standard_False;
367     myEndLCS = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
368     if (!testResult || CORBA::is_nil(myEndLCS))
369       return;
370
371     aName = GEOMBase::GetName(myEndLCS);
372     myEditCurrentArgument->setText(aName);
373
374     if (!myEndLCS->_is_nil() && !myObjects.length())
375       Group1->PushButton1->click();
376   }
377   else if (myEditCurrentArgument == Group1->LineEdit5) {
378     myPath = GEOM::GEOM_Object::_nil();
379     if (aSelList.Extent() != 1)
380       return;
381
382     Standard_Boolean testResult = Standard_False;
383     GEOM::GEOM_Object_ptr aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
384     if (!testResult || aSelectedObject->_is_nil())
385       return;
386
387     aName = GEOMBase::GetName(myPath);
388     // Local Selection
389     TopoDS_Shape S;
390     if (!GEOMBase::GetShape(aSelectedObject, S))
391       return;
392     
393     TColStd_IndexedMapOfInteger aMap;
394     aSelMgr->GetIndexes(aSelList.First(), aMap);
395     aName = GEOMBase::GetName(aSelectedObject);
396     if (aMap.Extent() == 1) {
397       int anIndex = aMap(1);
398       aName.append(":edge_" + QString::number(anIndex));
399       
400       //Find SubShape Object in Father
401       GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather(aSelectedObject, aName);
402       
403       if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
404         GEOM::GEOM_IShapesOperations_var aShapesOp =
405           getGeomEngine()->GetIShapesOperations(getStudyId());
406         aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
407       }
408       else { // get Object from study
409         aSelectedObject = aFindedObject;
410       }
411     }
412     else {
413       if (S.ShapeType() != TopAbs_EDGE && S.ShapeType() != TopAbs_WIRE) {
414         aSelectedObject = GEOM::GEOM_Object::_nil();
415         aName = "";
416         return;
417       }
418     }
419     
420     myEditCurrentArgument->setText(aName);
421     myPath = aSelectedObject;
422
423     if (!myPath->_is_nil() && !myObjects.length())
424       Group1->PushButton1->click();
425   }
426
427   // clear selection
428   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
429   myGeomGUI->getApp()->selectionMgr()->clearSelected();
430   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
431           this, SLOT(SelectionIntoArgument()));
432
433   displayPreview();
434 }
435
436 //=================================================================================
437 // function : SetEditCurrentArgument()
438 // purpose  :
439 //=================================================================================
440 void TransformationGUI_PositionDlg::SetEditCurrentArgument()
441 {
442   QPushButton* send = (QPushButton*)sender();
443
444   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
445   if (send == Group1->PushButton1) {
446     myEditCurrentArgument = Group1->LineEdit1;
447
448     globalSelection();
449
450     Group1->PushButton2->setDown(false);
451     Group1->PushButton4->setDown(false);
452     Group1->PushButton5->setDown(false);
453     Group1->LineEdit2->setEnabled(false);
454     Group1->LineEdit4->setEnabled(false);
455     Group1->LineEdit5->setEnabled(false);
456
457     Group1->CheckButton2->setEnabled(false);
458   }
459   else if (send == Group1->PushButton2) {
460     myEditCurrentArgument = Group1->LineEdit2;
461
462     TColStd_MapOfInteger aMap;
463     aMap.Add(GEOM_PLANE);
464     aMap.Add(GEOM_MARKER);
465     globalSelection(aMap);
466
467     Group1->PushButton1->setDown(false);
468     Group1->PushButton4->setDown(false);
469     Group1->PushButton5->setDown(false);
470     Group1->LineEdit1->setEnabled(false);
471     Group1->LineEdit4->setEnabled(false);
472     Group1->LineEdit5->setEnabled(false);
473
474     Group1->CheckButton2->setEnabled(false);
475   }
476   else if (send == Group1->PushButton4) {
477     myEditCurrentArgument = Group1->LineEdit4;
478
479     TColStd_MapOfInteger aMap;
480     aMap.Add(GEOM_PLANE);
481     aMap.Add(GEOM_MARKER);
482     globalSelection(aMap);
483
484     Group1->PushButton1->setDown(false);
485     Group1->PushButton2->setDown(false);
486     Group1->PushButton5->setDown(false);
487     Group1->LineEdit1->setEnabled(false);
488     Group1->LineEdit2->setEnabled(false);
489     Group1->LineEdit5->setEnabled(false);
490
491     Group1->CheckButton2->setEnabled(false);
492   }
493   else if (send == Group1->PushButton5) {
494     myEditCurrentArgument = Group1->LineEdit5;
495
496     Group1->CheckButton2->setEnabled(true);
497
498     if ( Group1->CheckButton2->isChecked() ) {
499       localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
500     } else {
501       TColStd_MapOfInteger aMap;
502       aMap.Add(GEOM_WIRE);
503       aMap.Add(GEOM_LINE);
504       globalSelection(aMap);
505     }
506
507     Group1->PushButton1->setDown(false);
508     Group1->PushButton2->setDown(false);
509     Group1->PushButton4->setDown(false);
510     Group1->LineEdit1->setEnabled(false);
511     Group1->LineEdit2->setEnabled(false);
512     Group1->LineEdit4->setEnabled(false);
513   }
514   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
515           this, SLOT(SelectionIntoArgument()));
516
517   // enable line edit
518   myEditCurrentArgument->setEnabled(true);
519   myEditCurrentArgument->setFocus();
520   // after setFocus(), because it will be setDown(false) when loses focus
521   send->setDown(true);
522
523   // seems we need it only to avoid preview disappearing, caused by selection mode change
524   displayPreview();
525 }
526
527 //=================================================================================
528 // function : LineEditReturnPressed()
529 // purpose  :
530 //=================================================================================
531 void TransformationGUI_PositionDlg::LineEditReturnPressed()
532 {
533   QLineEdit* send = (QLineEdit*)sender();
534   if (send == Group1->LineEdit1 ||
535       send == Group1->LineEdit2 ||
536       send == Group1->LineEdit4 ||
537       send == Group1->LineEdit5 ) {
538     myEditCurrentArgument = send;
539     GEOMBase_Skeleton::LineEditReturnPressed();
540   }
541
542   if (send == Group1->LineEdit5)
543     Group1->CheckButton2->setEnabled(true);
544   else
545     Group1->CheckButton2->setEnabled(false);
546 }
547
548 //=================================================================================
549 // function : ActivateThisDialog()
550 // purpose  :
551 //=================================================================================
552 void TransformationGUI_PositionDlg::ActivateThisDialog()
553 {
554   GEOMBase_Skeleton::ActivateThisDialog();
555   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
556            this, SLOT( SelectionIntoArgument() ) );
557
558   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
559            this, SLOT( SelectionIntoArgument() ) );
560
561   ConstructorsClicked( getConstructorId() );
562 }
563
564 //=================================================================================
565 // function : enterEvent()
566 // purpose  : when mouse enter onto the QWidget
567 //=================================================================================
568 void TransformationGUI_PositionDlg::enterEvent (QEvent*)
569 {
570   if (!mainFrame()->GroupConstructors->isEnabled())
571     ActivateThisDialog();
572 }
573
574 //=================================================================================
575 // function : createOperation
576 // purpose  :
577 //=================================================================================
578 GEOM::GEOM_IOperations_ptr TransformationGUI_PositionDlg::createOperation()
579 {
580   return getGeomEngine()->GetITransformOperations(getStudyId());
581 }
582
583 //=================================================================================
584 // function : isValid
585 // purpose  :
586 //=================================================================================
587 bool TransformationGUI_PositionDlg::isValid (QString& /*msg*/)
588 {
589   bool res;
590   if (getConstructorId() == 0)
591     res = !(myObjects.length() == 0 || myEndLCS->_is_nil());
592   else if ( getConstructorId() == 1 )
593     res = !(myObjects.length() == 0 || myStartLCS->_is_nil() || myEndLCS->_is_nil());
594   else if ( getConstructorId() == 2 )
595     res = !(myObjects.length() == 0 || myPath->_is_nil());
596
597   return res;
598 }
599
600 //=================================================================================
601 // function : execute
602 // purpose  :
603 //=================================================================================
604 bool TransformationGUI_PositionDlg::execute (ObjectList& objects)
605 {
606   bool res = false;
607   bool toCreateCopy = IsPreview() || Group1->CheckButton1->isChecked();
608   GEOM::GEOM_Object_var anObj;
609
610   switch (getConstructorId()) {
611   case 0:
612     {
613       for (int i = 0; i < myObjects.length(); i++) {
614         if (toCreateCopy)
615           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
616             PositionShapeCopy(myObjects[i], myObjects[i], myEndLCS);
617         else
618           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
619             PositionShape(myObjects[i], myObjects[i], myEndLCS);
620
621         if (!anObj->_is_nil())
622           objects.push_back(anObj._retn());
623       }
624       res = true;
625       break;
626     }
627   case 1:
628     {
629       for (int i = 0; i < myObjects.length(); i++) {
630         if (toCreateCopy)
631           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
632             PositionShapeCopy(myObjects[i], myStartLCS, myEndLCS);
633         else
634           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
635             PositionShape(myObjects[i], myStartLCS, myEndLCS);
636         if (!anObj->_is_nil())
637           objects.push_back(anObj._retn());
638       }
639       res = true;
640       break;
641     }
642   case 2:
643     {
644       double aDistance = Group1->SpinBox_DX->value();
645       bool toReverse = Group1->CheckButton3->isChecked();
646       for (int i = 0; i < myObjects.length(); i++) {
647         anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
648           PositionAlongPath(myObjects[i], myPath, aDistance, toCreateCopy, toReverse);
649         if (!anObj->_is_nil())
650           objects.push_back(anObj._retn());
651       }
652       res = true;
653       break;
654     }
655   }
656
657   return res;
658 }
659
660 //=================================================================================
661 // function : restoreSubShapes
662 // purpose  :
663 //=================================================================================
664 void TransformationGUI_PositionDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStudy,
665                                                       SALOMEDS::SObject_ptr theSObject)
666 {
667   if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
668     // empty list of arguments means that all arguments should be restored
669     getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
670                                         /*theFindMethod=*/GEOM::FSM_Transformed,
671                                         /*theInheritFirstArg=*/true);
672   }
673 }
674
675 //=================================================================================
676 // function :  CreateCopyModeChanged()
677 // purpose  :
678 //=================================================================================
679 void TransformationGUI_PositionDlg::CreateCopyModeChanged (bool isCreateCopy)
680 {
681   mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
682 }
683
684 //=================================================================================
685 // function : addSubshapeToStudy
686 // purpose  : virtual method to add new SubObjects if local selection
687 //=================================================================================
688 void TransformationGUI_PositionDlg::addSubshapesToStudy()
689 {
690   QMap<QString, GEOM::GEOM_Object_var> objMap;
691
692   objMap[Group1->LineEdit5->text()] = myPath;
693
694   addSubshapesToFather(objMap);
695 }