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