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