Salome HOME
Update from BR_V5_DEV 13Feb2009
[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
267   QString aName;
268
269   if (myEditCurrentArgument == GroupPoints->LineEdit1) {
270     int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
271     if (aNbSel < 1)
272       return;
273
274     GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
275     if (!myObjects.length())
276       return;
277     else
278       myEditCurrentArgument->setText(aName);
279   }
280   else {
281     if (aSelList.Extent() != 1)
282       return;
283
284     // nbSel == 1
285     Standard_Boolean testResult = Standard_False;
286     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
287
288     if (!testResult || CORBA::is_nil(aSelectedObject))
289       return;
290
291     aName = GEOMBase::GetName(aSelectedObject);
292
293     // Get Selected object if selected subshape
294     TopoDS_Shape aShape;
295     if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
296     {
297       TopAbs_ShapeEnum aNeedType = TopAbs_VERTEX;
298       if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0)
299         aNeedType = TopAbs_EDGE;
300
301       TColStd_IndexedMapOfInteger aMap;
302       aSelMgr->GetIndexes(aSelList.First(), aMap);
303       if (aMap.Extent() == 1)
304       {
305         int anIndex = aMap(1);
306         if (aNeedType == TopAbs_EDGE)
307           aName += QString(":edge_%1").arg(anIndex);
308         else
309           aName += QString(":vertex_%1").arg(anIndex);
310
311         //Find SubShape Object in Father
312         GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
313
314         if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
315           GEOM::GEOM_IShapesOperations_var aShapesOp =
316             getGeomEngine()->GetIShapesOperations(getStudyId());
317           aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
318         }
319         else {
320           aSelectedObject = aFindedObject; // get Object from study
321         }
322       }
323       else // Global Selection
324       {
325         if (aShape.ShapeType() != aNeedType) {
326           aSelectedObject = GEOM::GEOM_Object::_nil();
327           aName = "";
328         }
329       }
330     }
331
332     myEditCurrentArgument->setText(aName);
333
334     if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 0) {
335       myAxis = aSelectedObject;
336       if (!myAxis->_is_nil() && !myObjects.length())
337         GroupPoints->PushButton1->click();
338     }
339     else if (myEditCurrentArgument == GroupPoints->LineEdit2 && getConstructorId() == 1) {
340       myCentPoint = aSelectedObject;
341       if (!myCentPoint->_is_nil() && myPoint1->_is_nil())
342         GroupPoints->PushButton4->click();
343     }
344     else if (myEditCurrentArgument == GroupPoints->LineEdit4) {
345       myPoint1 = aSelectedObject;
346       if (!myPoint1->_is_nil() && myPoint2->_is_nil())
347         GroupPoints->PushButton5->click();
348     }
349     else if (myEditCurrentArgument == GroupPoints->LineEdit5) {
350       myPoint2 = aSelectedObject;
351       if (!myPoint2->_is_nil() && !myObjects.length())
352         GroupPoints->PushButton1->click();
353     }
354   }
355
356   // clear selection
357   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
358   myGeomGUI->getApp()->selectionMgr()->clearSelected();
359   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
360           this, SLOT(SelectionIntoArgument()));
361
362   displayPreview();
363 }
364
365 //=================================================================================
366 // function : SetEditCurrentArgument()
367 // purpose  :
368 //=================================================================================
369 void TransformationGUI_RotationDlg::SetEditCurrentArgument()
370 {
371   QPushButton* send = (QPushButton*)sender();
372
373   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
374   globalSelection();
375
376   if (send == GroupPoints->PushButton1) {
377     myEditCurrentArgument = GroupPoints->LineEdit1;
378
379     GroupPoints->PushButton2->setDown(false);
380     GroupPoints->LineEdit2->setEnabled(false);
381   }
382   else if (send == GroupPoints->PushButton2) {
383     myEditCurrentArgument = GroupPoints->LineEdit2;
384
385     GroupPoints->PushButton1->setDown(false);
386     GroupPoints->PushButton4->setDown(false);
387     GroupPoints->PushButton5->setDown(false);
388     GroupPoints->LineEdit1->setEnabled(false);
389     GroupPoints->LineEdit4->setEnabled(false);
390     GroupPoints->LineEdit5->setEnabled(false);
391
392     if (getConstructorId() == 0)
393       localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
394     else
395       localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
396   }
397   else if (send == GroupPoints->PushButton4) {
398     myEditCurrentArgument = GroupPoints->LineEdit4;
399
400     GroupPoints->PushButton1->setDown(false);
401     GroupPoints->PushButton2->setDown(false);
402     GroupPoints->PushButton5->setDown(false);
403     GroupPoints->LineEdit1->setEnabled(false);
404     GroupPoints->LineEdit2->setEnabled(false);
405     GroupPoints->LineEdit5->setEnabled(false);
406
407     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
408   }
409   else if (send == GroupPoints->PushButton5) {
410     myEditCurrentArgument = GroupPoints->LineEdit5;
411
412     GroupPoints->PushButton1->setDown(false);
413     GroupPoints->PushButton2->setDown(false);
414     GroupPoints->PushButton4->setDown(false);
415     GroupPoints->LineEdit1->setEnabled(false);
416     GroupPoints->LineEdit2->setEnabled(false);
417     GroupPoints->LineEdit4->setEnabled(false);
418
419     localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
420   }
421   connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
422           this, SLOT(SelectionIntoArgument()));
423
424   // enable line edit
425   myEditCurrentArgument->setEnabled(true);
426   myEditCurrentArgument->setFocus();
427   // after setFocus(), because it will be setDown(false) when loses focus
428   send->setDown(true);
429
430   // seems we need it only to avoid preview disappearing, caused by selection mode change
431   displayPreview();
432 }
433
434 //=================================================================================
435 // function : LineEditReturnPressed()
436 // purpose  :
437 //=================================================================================
438 void TransformationGUI_RotationDlg::LineEditReturnPressed()
439 {
440   QLineEdit* send = (QLineEdit*)sender();
441   if (send == GroupPoints->LineEdit1 ||
442       send == GroupPoints->LineEdit2) {
443     myEditCurrentArgument = send;
444     GEOMBase_Skeleton::LineEditReturnPressed();
445   }
446 }
447
448 //=================================================================================
449 // function : ActivateThisDialog()
450 // purpose  :
451 //=================================================================================
452 void TransformationGUI_RotationDlg::ActivateThisDialog()
453 {
454   GEOMBase_Skeleton::ActivateThisDialog();
455   connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
456            this, SLOT( SelectionIntoArgument() ) );
457
458   ConstructorsClicked( getConstructorId() );
459 }
460
461 //=================================================================================
462 // function : enterEvent()
463 // purpose  :
464 //=================================================================================
465 void TransformationGUI_RotationDlg::enterEvent (QEvent*)
466 {
467   if (!mainFrame()->GroupConstructors->isEnabled())
468     ActivateThisDialog();
469 }
470
471 void TransformationGUI_RotationDlg::TextValueChangedInSpinBox( const QString& s)
472 {
473   bool isDigit = true;
474   s.toDouble(&isDigit);
475   if(!isDigit) {
476     GroupPoints->CheckButton2->setChecked(false);
477   }
478   GroupPoints->CheckButton2->setEnabled(isDigit); 
479 }
480
481 //=================================================================================
482 // function : ValueChangedInSpinBox()
483 // purpose  :
484 //=================================================================================
485 void TransformationGUI_RotationDlg::ValueChangedInSpinBox()
486 {
487   displayPreview();
488 }
489
490 //=================================================================================
491 // function : createOperation
492 // purpose  :
493 //=================================================================================
494 GEOM::GEOM_IOperations_ptr TransformationGUI_RotationDlg::createOperation()
495 {
496   return getGeomEngine()->GetITransformOperations(getStudyId());
497 }
498
499 //=================================================================================
500 // function : isValid
501 // purpose  :
502 //=================================================================================
503 bool TransformationGUI_RotationDlg::isValid (QString& msg)
504 {
505   switch (getConstructorId()) {
506   case 0: {
507     bool ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() );
508     return myObjects.length() > 0 && !(myAxis->_is_nil()) && ok;
509     break;
510   }
511   case 1:
512     return myObjects.length() > 0 && !(myCentPoint->_is_nil() || myPoint1->_is_nil() || myPoint2->_is_nil());
513     break;
514   default:
515     break;
516   }
517   return false;
518 }
519
520 //=================================================================================
521 // function : execute
522 // purpose  :
523 //=================================================================================
524 bool TransformationGUI_RotationDlg::execute (ObjectList& objects)
525 {
526   bool res = false;
527   bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
528
529   GEOM::GEOM_Object_var anObj;
530
531   switch (getConstructorId()) {
532   case 0:
533     {
534       QStringList aParameters;
535       aParameters<<GroupPoints->SpinBox_DX->text();
536       if (toCreateCopy) {
537         for (int i = 0; i < myObjects.length(); i++) {
538           myCurrObject = myObjects[i];
539           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
540             RotateCopy(myObjects[i], myAxis, GetAngle() * PI180);
541           if (!anObj->_is_nil()) {
542             if(!IsPreview()) {
543               anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
544             }
545             objects.push_back(anObj._retn());
546           }
547         }
548       }
549       else {
550         for (int i = 0; i < myObjects.length(); i++) {
551           myCurrObject = myObjects[i];
552           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
553             Rotate(myObjects[i], myAxis, GetAngle() * PI180);
554           if (!anObj->_is_nil()) {
555             if(!IsPreview()) {
556               anObj->SetParameters(GeometryGUI::JoinObjectParameters(aParameters));
557               updateAttributes(anObj, aParameters);
558             }
559             objects.push_back(anObj._retn());
560           }
561         }
562       }
563       res = true;
564       break;
565     }
566   case 1:
567     {
568       if (toCreateCopy) {
569         for (int i = 0; i < myObjects.length(); i++) {
570           myCurrObject = myObjects[i];
571           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
572             RotateThreePointsCopy(myObjects[i], myCentPoint, myPoint1, myPoint2);
573           if (!anObj->_is_nil())
574             objects.push_back(anObj._retn());
575         }
576       }
577       else {
578         for (int i = 0; i < myObjects.length(); i++) {
579           myCurrObject = myObjects[i];
580           anObj = GEOM::GEOM_ITransformOperations::_narrow(getOperation())->
581             RotateThreePoints(myObjects[i], myCentPoint, myPoint1, myPoint2);
582           if (!anObj->_is_nil())
583             objects.push_back(anObj._retn());
584         }
585       }
586       res = true;
587       break;
588     }
589   }
590
591   return res;
592 }
593
594 //=================================================================================
595 // function : restoreSubShapes
596 // purpose  :
597 //=================================================================================
598 void TransformationGUI_RotationDlg::restoreSubShapes (SALOMEDS::Study_ptr   theStudy,
599                                                       SALOMEDS::SObject_ptr theSObject)
600 {
601   if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
602     // we pass here the first operation argument (object) through the list of arguments
603     // because the rotation operation place its arguments in the data structure in another order,
604     // and we need to point the first argument directly
605     GEOM::ListOfGO_var anArgs = new GEOM::ListOfGO;
606     anArgs->length(1);
607     anArgs[0] = myCurrObject;
608     getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, anArgs,
609                                         /*theFindMethod=*/GEOM::FSM_Transformed,
610                                         /*theInheritFirstArg=*/true);
611   }
612 }
613
614 //=================================================================================
615 // function : GetAngle()
616 // purpose  :
617 //=================================================================================
618 double TransformationGUI_RotationDlg::GetAngle() const
619 {
620   return GroupPoints->SpinBox_DX->value();
621 }
622
623 //=================================================================================
624 // function :  CreateCopyModeChanged()
625 // purpose  :
626 //=================================================================================
627 void TransformationGUI_RotationDlg::CreateCopyModeChanged (bool isCreateCopy)
628 {
629   mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
630 }
631
632 //=================================================================================
633 // function :  onReverse()
634 // purpose  :
635 //=================================================================================
636 void TransformationGUI_RotationDlg::onReverse()
637 {
638   double anOldValue = GroupPoints->SpinBox_DX->value();
639   GroupPoints->SpinBox_DX->setValue(-anOldValue);
640 }
641
642 //=================================================================================
643 // function : addSubshapesToStudy
644 // purpose  : virtual method to add new SubObjects if local selection
645 //=================================================================================
646 void TransformationGUI_RotationDlg::addSubshapesToStudy()
647 {
648   bool toCreateCopy = IsPreview() || GroupPoints->CheckButton1->isChecked();
649   if (toCreateCopy) {
650     QMap<QString, GEOM::GEOM_Object_var> objMap;
651     switch (getConstructorId()) {
652     case 0:
653       objMap[GroupPoints->LineEdit2->text()] = myAxis;
654       break;
655     case 1:
656       objMap[GroupPoints->LineEdit2->text()] = myCentPoint;
657       objMap[GroupPoints->LineEdit4->text()] = myPoint1;
658       objMap[GroupPoints->LineEdit5->text()] = myPoint2;
659       break;
660     }
661     addSubshapesToFather(objMap);
662   }
663 }