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