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