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