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