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