Salome HOME
Merge from V5_1_2_BR branch (14 July 2009)
[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     }
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
367   displayPreview();
368 }
369
370 //=================================================================================
371 // function : SetEditCurrentArgument()
372 // purpose  :
373 //=================================================================================
374 void TransformationGUI_RotationDlg::SetEditCurrentArgument()
375 {
376   QPushButton* send = (QPushButton*)sender();
377
378   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
379   globalSelection();
380
381   if (send == GroupPoints->PushButton1) {
382     myEditCurrentArgument = GroupPoints->LineEdit1;
383
384     GroupPoints->PushButton2->setDown(false);
385     GroupPoints->PushButton4->setDown(false);
386     GroupPoints->PushButton5->setDown(false);
387     GroupPoints->LineEdit2->setEnabled(false);
388     GroupPoints->LineEdit4->setEnabled(false);
389     GroupPoints->LineEdit5->setEnabled(false);
390   }
391   else if (send == GroupPoints->PushButton2) {
392     myEditCurrentArgument = GroupPoints->LineEdit2;
393
394     GroupPoints->PushButton1->setDown(false);
395     GroupPoints->PushButton4->setDown(false);
396     GroupPoints->PushButton5->setDown(false);
397     GroupPoints->LineEdit1->setEnabled(false);
398     GroupPoints->LineEdit4->setEnabled(false);
399     GroupPoints->LineEdit5->setEnabled(false);
400
401     if (getConstructorId() == 0)
402       localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
403     else
404       localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
405   }
406   else if (send == GroupPoints->PushButton4) {
407     myEditCurrentArgument = GroupPoints->LineEdit4;
408
409     GroupPoints->PushButton1->setDown(false);
410     GroupPoints->PushButton2->setDown(false);
411     GroupPoints->PushButton5->setDown(false);
412     GroupPoints->LineEdit1->setEnabled(false);
413     GroupPoints->LineEdit2->setEnabled(false);
414     GroupPoints->LineEdit5->setEnabled(false);
415
416     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
417   }
418   else if (send == GroupPoints->PushButton5) {
419     myEditCurrentArgument = GroupPoints->LineEdit5;
420
421     GroupPoints->PushButton1->setDown(false);
422     GroupPoints->PushButton2->setDown(false);
423     GroupPoints->PushButton4->setDown(false);
424     GroupPoints->LineEdit1->setEnabled(false);
425     GroupPoints->LineEdit2->setEnabled(false);
426     GroupPoints->LineEdit4->setEnabled(false);
427
428     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
429   }
430   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
431           this, SLOT(SelectionIntoArgument()));
432
433   // enable line edit
434   myEditCurrentArgument->setEnabled(true);
435   myEditCurrentArgument->setFocus();
436   // after setFocus(), because it will be setDown(false) when loses focus
437   send->setDown(true);
438
439   // seems we need it only to avoid preview disappearing, caused by selection mode change
440   displayPreview();
441 }
442
443 //=================================================================================
444 // function : LineEditReturnPressed()
445 // purpose  :
446 //=================================================================================
447 void TransformationGUI_RotationDlg::LineEditReturnPressed()
448 {
449   QLineEdit* send = (QLineEdit*)sender();
450   if (send == GroupPoints->LineEdit1 ||
451       send == GroupPoints->LineEdit2) {
452     myEditCurrentArgument = send;
453     GEOMBase_Skeleton::LineEditReturnPressed();
454   }
455 }
456
457 //=================================================================================
458 // function : ActivateThisDialog()
459 // purpose  :
460 //=================================================================================
461 void TransformationGUI_RotationDlg::ActivateThisDialog()
462 {
463   GEOMBase_Skeleton::ActivateThisDialog();
464   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
465            this, SLOT( SelectionIntoArgument() ) );
466
467   ConstructorsClicked( getConstructorId() );
468 }
469
470 //=================================================================================
471 // function : enterEvent()
472 // purpose  :
473 //=================================================================================
474 void TransformationGUI_RotationDlg::enterEvent (QEvent*)
475 {
476   if (!mainFrame()->GroupConstructors->isEnabled())
477     ActivateThisDialog();
478 }
479
480 void TransformationGUI_RotationDlg::TextValueChangedInSpinBox( const QString& s)
481 {
482   bool isDigit = true;
483   s.toDouble(&isDigit);
484   if(!isDigit) {
485     GroupPoints->CheckButton2->setChecked(false);
486   }
487   GroupPoints->CheckButton2->setEnabled(isDigit); 
488 }
489
490 //=================================================================================
491 // function : ValueChangedInSpinBox()
492 // purpose  :
493 //=================================================================================
494 void TransformationGUI_RotationDlg::ValueChangedInSpinBox()
495 {
496   displayPreview();
497 }
498
499 //=================================================================================
500 // function : createOperation
501 // purpose  :
502 //=================================================================================
503 GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation()
504 {
505   return getGeomEngine()->GetITransformOperations(getStudyId());
506 }
507
508 //=================================================================================
509 // function : isValid
510 // purpose  :
511 //=================================================================================
512 bool TransformationGUI_RotationDlg::isValid (QString& msg)
513 {
514   switch (getConstructorId()) {
515   case 0: {
516     bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() );
517     return myObjects.length() > 0 && !(myAxis->_is_nil()) && ok;
518     break;
519   }
520   case 1:
521     return myObjects.length() > 0 && !(myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil());
522     break;
523   default:
524     break;
525   }
526   return false;
527 }
528
529 //=================================================================================
530 // function : execute
531 // purpose  :
532 //=================================================================================
533 bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
534 {
535   bool res = false;
536   bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
537
538   GEOM::GEOM_Object_var anObj;
539
540   switch (getConstructorId()) {
541   case 0:
542     {
543       QStringList aParameters;
544       aParameters<<GroupPoints->SpinBox_DX->text();
545       if (toCreateCopy) {
546         for (int i = 0; i < myObjects.length(); i++) {
547           myCurrObject = myObjects[i];
548           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
549             RotateCopy(myObjects[i], myAxis, GetAngle() * PI180);
550           if (!anObj->_is_nil()) {
551             if(!IsPreview()) {
552               anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
553             }
554             objects.push_back(anObj._retn());
555           }
556         }
557       }
558       else {
559         for (int i = 0; i < myObjects.length(); i++) {
560           myCurrObject = myObjects[i];
561           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
562             Rotate(myObjects[i], myAxis, GetAngle() * PI180);
563           if (!anObj->_is_nil()) {
564             if(!IsPreview()) {
565               anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
566               updateAttributes(anObj, aParameters);
567             }
568             objects.push_back(anObj._retn());
569           }
570         }
571       }
572       res = true;
573       break;
574     }
575   case 1:
576     {
577       if (toCreateCopy) {
578         for (int i = 0; i < myObjects.length(); i++) {
579           myCurrObject = myObjects[i];
580           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
581             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 = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
590             RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2);
591           if (!anObj->_is_nil())
592             objects.push_back(anObj._retn());
593         }
594       }
595       res = true;
596       break;
597     }
598   }
599
600   return res;
601 }
602
603 //=================================================================================
604 // function : restoreSubShapes
605 // purpose  :
606 //=================================================================================
607 void TransformationGUI_RotationDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStudy,
608                                                       SALOMEDS::SObject_ptr theSObject)
609 {
610   if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
611     // we pass here the first operation argument (object) through the list of arguments
612     // because the rotation operation place its arguments in the data structure in another order,
613     // and we need to point the first argument directly
614     GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
615     anArgs->length(1);
616     anArgs[0] = myCurrObject;
617     getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
618                                         /*theFindMethod=*/GEOM::FSM_Transformed,
619                                         /*theInheritFirstArg=*/true);
620   }
621 }
622
623 //=================================================================================
624 // function : GetAngle()
625 // purpose  :
626 //=================================================================================
627 double TransformationGUI_RotationDlg::GetAngle() const
628 {
629   return GroupPoints->SpinBox_DX->value();
630 }
631
632 //=================================================================================
633 // function :  CreateCopyModeChanged()
634 // purpose  :
635 //=================================================================================
636 void TransformationGUI_RotationDlg::CreateCopyModeChanged (bool isCreateCopy)
637 {
638   mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
639 }
640
641 //=================================================================================
642 // function :  onReverse()
643 // purpose  :
644 //=================================================================================
645 void TransformationGUI_RotationDlg::onReverse()
646 {
647   double anOldValue = GroupPoints->SpinBox_DX->value();
648   GroupPoints->SpinBox_DX->setValue(-anOldValue);
649 }
650
651 //=================================================================================
652 // function : addSubshapesToStudy
653 // purpose  : virtual method to add new SubObjects if local selection
654 //=================================================================================
655 void TransformationGUI_RotationDlg::addSubshapesToStudy()
656 {
657   bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
658   if (toCreateCopy) {
659     QMap<QString, GEOM::GEOM_Object_var> objMap;
660     switch (getConstructorId()) {
661     case 0:
662       objMap[GroupPoints->LineEdit2->text()] = myAxis;
663       break;
664     case 1:
665       objMap[GroupPoints->LineEdit2->text()] = myCentPoint;
666       objMap[GroupPoints->LineEdit4->text()] = myPoint1;
667       objMap[GroupPoints->LineEdit5->text()] = myPoint2;
668       break;
669     }
670     addSubshapesToFather(objMap);
671   }
672 }