Salome HOME
0020327: EDF 1018 GEOM : Missing MakeTangentPlaneOnFace in geompy
[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
25 //  Module : GEOM
26 //  $Header$
27 //
28 #include "TransformationGUI_MultiTranslationDlg.h"
29
30 #include "SUIT_Desktop.h"
31 #include "SUIT_Session.h"
32 #include "SalomeApp_Application.h"
33 #include "LightApp_SelectionMgr.h"
34
35 #include <TopoDS_Shape.hxx>
36 #include <TopoDS_Edge.hxx>
37 #include <TopoDS.hxx>
38 #include <TopExp.hxx>
39 #include <TColStd_IndexedMapOfInteger.hxx>
40 #include <TopTools_IndexedMapOfShape.hxx>
41
42 #include <qlabel.h>
43
44 #include "GEOMImpl_Types.hxx"
45
46 #include <qcheckbox.h>
47
48 #include "utilities.h"
49
50 using namespace std;
51
52 //=================================================================================
53 // class    : TransformationGUI_MultiTranslationDlg()
54 // purpose  : Constructs a TransformationGUI_MultiTranslationDlg which is a child of 'parent', with the
55 //            name 'name' and widget flags set to 'f'.
56 //            The dialog will by default be modeless, unless you set 'modal' to
57 //            TRUE to construct a modal dialog.
58 //=================================================================================
59 TransformationGUI_MultiTranslationDlg::TransformationGUI_MultiTranslationDlg
60   (GeometryGUI* theGeometryGUI, QWidget* parent,  const char* name, bool modal, WFlags fl)
61   :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
62                      WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
63 {
64   SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
65   QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_SIMPLE")));
66   QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_MULTITRANSLATION_DOUBLE")));
67   QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
68
69   setCaption(tr("GEOM_MULTITRANSLATION_TITLE"));
70
71   /***************************************************************/
72   GroupConstructors->setTitle(tr("GEOM_MULTITRANSLATION"));
73   RadioButton1->setPixmap(image0);
74   RadioButton2->setPixmap(image1);
75   RadioButton3->close(TRUE);
76
77   GroupPoints = new DlgRef_2Sel2Spin1Check(this, "GroupPoints");
78   GroupPoints->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_SIMPLE"));
79   GroupPoints->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
80   GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR_U"));
81   GroupPoints->TextLabel3->setText(tr("GEOM_STEP_U"));
82   GroupPoints->TextLabel4->setText(tr("GEOM_NB_TIMES_U"));
83   GroupPoints->CheckButton1->setText(tr("GEOM_REVERSE_U"));
84   GroupPoints->PushButton1->setPixmap(image2);
85   GroupPoints->PushButton2->setPixmap(image2);
86   GroupPoints->LineEdit1->setReadOnly(true);
87   GroupPoints->LineEdit2->setReadOnly(true);
88
89   GroupDimensions = new DlgRef_3Sel4Spin2Check(this, "GroupDimensions");
90   GroupDimensions->GroupBox1->setTitle(tr("GEOM_MULTITRANSLATION_DOUBLE"));
91   GroupDimensions->TextLabel1->setText(tr("GEOM_MAIN_OBJECT"));
92   GroupDimensions->TextLabel2->setText(tr("GEOM_VECTOR_U"));
93   GroupDimensions->TextLabel3->setText(tr("GEOM_VECTOR_V"));
94   GroupDimensions->TextLabel4->setText(tr("GEOM_STEP_U"));
95   GroupDimensions->TextLabel5->setText(tr("GEOM_NB_TIMES_U"));
96   GroupDimensions->TextLabel6->setText(tr("GEOM_STEP_V"));
97   GroupDimensions->TextLabel7->setText(tr("GEOM_NB_TIMES_V"));
98   GroupDimensions->CheckButton1->setText(tr("GEOM_REVERSE_U"));
99   GroupDimensions->CheckButton2->setText(tr("GEOM_REVERSE_V"));
100   GroupDimensions->PushButton1->setPixmap(image2);
101   GroupDimensions->PushButton2->setPixmap(image2);
102   GroupDimensions->PushButton3->setPixmap(image2);
103   GroupDimensions->LineEdit1->setReadOnly(true);
104   GroupDimensions->LineEdit2->setReadOnly(true);
105   GroupDimensions->LineEdit3->setReadOnly(true);
106
107   Layout1->addWidget(GroupPoints, 2, 0);
108   Layout1->addWidget(GroupDimensions, 2, 0);
109   /***************************************************************/
110
111   setHelpFileName("multi_translation_operation_page.html");
112
113   Init();
114 }
115
116
117 //=================================================================================
118 // function : ~TransformationGUI_MultiTranslationDlg()
119 // purpose  : Destroys the object and frees any allocated resources
120 //=================================================================================
121 TransformationGUI_MultiTranslationDlg::~TransformationGUI_MultiTranslationDlg()
122 {
123   // no need to delete child widgets, Qt does it all for us
124 }
125
126
127 //=================================================================================
128 // function : Init()
129 // purpose  :
130 //=================================================================================
131 void TransformationGUI_MultiTranslationDlg::Init()
132 {
133   /* Get setting of step value from file configuration */
134   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
135   double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100);
136
137   double SpecificStep = 1;
138   /* min, max, step and decimals for spin boxes & initial values */
139   GroupPoints->SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
140   GroupPoints->SpinBox_DY->RangeStepAndValidator(1.0, MAX_NUMBER, SpecificStep, 10);
141   GroupPoints->SpinBox_DX->SetValue(myStepU);
142   GroupPoints->SpinBox_DY->SetValue(myNbTimesU);
143
144   GroupDimensions->SpinBox_DX1->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
145   GroupDimensions->SpinBox_DY1->RangeStepAndValidator(1.0, MAX_NUMBER, SpecificStep, 10);
146   GroupDimensions->SpinBox_DX2->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, DBL_DIGITS_DISPLAY);
147   GroupDimensions->SpinBox_DY2->RangeStepAndValidator(1.0, MAX_NUMBER, SpecificStep, 10);
148   GroupDimensions->SpinBox_DX1->SetValue(myStepU);
149   GroupDimensions->SpinBox_DY1->SetValue(myNbTimesU);
150   GroupDimensions->SpinBox_DX2->SetValue(myStepV);
151   GroupDimensions->SpinBox_DY2->SetValue(myNbTimesV);
152
153   /* signals and slots connections */
154   connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
155   connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
156   connect(GroupConstructors, SIGNAL(clicked(int)), this, SLOT(ConstructorsClicked(int)));
157
158   connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
159   connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
160   connect(GroupDimensions->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
161   connect(GroupDimensions->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
162   connect(GroupDimensions->PushButton3, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
163
164   connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
165   connect(GroupPoints->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
166   connect(GroupDimensions->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
167   connect(GroupDimensions->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
168   connect(GroupDimensions->LineEdit3, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
169
170   connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
171   connect(GroupPoints->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
172   connect(GroupDimensions->SpinBox_DX1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
173   connect(GroupDimensions->SpinBox_DY1, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
174   connect(GroupDimensions->SpinBox_DX2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
175   connect(GroupDimensions->SpinBox_DY2, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double)));
176
177   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double)));
178   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DY, SLOT(SetStep(double)));
179   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX1, SLOT(SetStep(double)));
180   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY1, SLOT(SetStep(double)));
181   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DX2, SLOT(SetStep(double)));
182   connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupDimensions->SpinBox_DY2, SLOT(SetStep(double)));
183
184   connect(GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
185   connect(GroupDimensions->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(ReverseStepU()));
186   connect(GroupDimensions->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(ReverseStepV()));
187
188   connect(myGeomGUI->getApp()->selectionMgr(),
189           SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
190
191   initName( tr( "GEOM_MULTITRANSLATION" ) );
192   ConstructorsClicked( 0 );
193 }
194
195
196 //=================================================================================
197 // function : ConstructorsClicked()
198 // purpose  : Radio button management
199 //=================================================================================
200 void TransformationGUI_MultiTranslationDlg::ConstructorsClicked(int constructorId)
201 {
202   disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
203
204   myStepU = myStepV = 50.0;
205   myNbTimesU = myNbTimesV = 2;
206
207   globalSelection( GEOM_ALLSHAPES );
208
209   switch (constructorId)
210     {
211     case 0: /* Translate simple */
212       {
213         GroupDimensions->hide();
214         resize(0, 0);
215         GroupPoints->show();
216
217         myEditCurrentArgument = GroupPoints->LineEdit1;
218         GroupPoints->LineEdit1->setText("");
219         GroupPoints->LineEdit2->setText("");
220
221         GroupPoints->SpinBox_DX->SetValue(myStepU);
222         GroupPoints->SpinBox_DY->SetValue(myNbTimesU);
223         
224         break;
225       }
226     case 1: /* Translate double */
227       {
228         GroupPoints->hide();
229         resize(0, 0);
230         GroupDimensions->show();
231
232         myEditCurrentArgument = GroupDimensions->LineEdit1;
233         GroupDimensions->LineEdit1->setText("");
234         GroupDimensions->LineEdit2->setText("");
235         GroupDimensions->LineEdit3->setText("");
236
237         GroupDimensions->SpinBox_DX1->SetValue(myStepU);
238         GroupDimensions->SpinBox_DY1->SetValue(myNbTimesU);
239         GroupDimensions->SpinBox_DX2->SetValue(myStepV);
240         GroupDimensions->SpinBox_DY2->SetValue(myNbTimesV);
241         
242         myVectorV = GEOM::GEOM_Object::_nil();
243         break;
244       }
245     }
246
247   myEditCurrentArgument->setFocus();
248   myBase = myVectorU = GEOM::GEOM_Object::_nil();
249   connect(myGeomGUI->getApp()->selectionMgr(),
250           SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
251 }
252
253
254 //=================================================================================
255 // function : ClickOnOk()
256 // purpose  :
257 //=================================================================================
258 void TransformationGUI_MultiTranslationDlg::ClickOnOk()
259 {
260   if ( ClickOnApply() )
261     ClickOnCancel();
262 }
263
264
265 //=================================================================================
266 // function : ClickOnApply()
267 // purpose  :
268 //=================================================================================
269 bool TransformationGUI_MultiTranslationDlg::ClickOnApply()
270 {
271   if ( !onAccept() )
272     return false;
273
274   initName();
275   ConstructorsClicked( getConstructorId() );
276   return true;
277 }
278
279
280 //=================================================================================
281 // function : SelectionIntoArgument()
282 // purpose  : Called when selection as changed or other case
283 //=================================================================================
284 void TransformationGUI_MultiTranslationDlg::SelectionIntoArgument()
285 {
286   myEditCurrentArgument->setText("");
287
288   if (IObjectCount() != 1) {
289     if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
290         myEditCurrentArgument == GroupDimensions->LineEdit1)
291       myBase = GEOM::GEOM_Object::_nil();
292     else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
293              myEditCurrentArgument == GroupDimensions->LineEdit2)
294       myVectorU = GEOM::GEOM_Object::_nil();
295     else if (myEditCurrentArgument == GroupDimensions->LineEdit3)
296       myVectorV = GEOM::GEOM_Object::_nil();
297     return;
298   }
299
300   // nbSel == 1
301   Standard_Boolean testResult = Standard_False;;
302   GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject(firstIObject(), testResult );
303
304   if ( !testResult || CORBA::is_nil( aSelectedObject ) || !GEOMBase::IsShape( aSelectedObject ) )
305     return;
306
307   QString aName = GEOMBase::GetName( aSelectedObject );
308
309   if (myEditCurrentArgument == GroupPoints->LineEdit1 ||
310       myEditCurrentArgument == GroupDimensions->LineEdit1)
311     myBase = aSelectedObject;
312   else if (myEditCurrentArgument == GroupPoints->LineEdit2 ||
313            myEditCurrentArgument == GroupDimensions->LineEdit2 ||
314            myEditCurrentArgument == GroupDimensions->LineEdit3 ) {
315     if ( testResult && !aSelectedObject->_is_nil() )
316         {
317           TopoDS_Shape aShape;
318           
319           if ( GEOMBase::GetShape( aSelectedObject, aShape, TopAbs_SHAPE ) && !aShape.IsNull() )
320             {
321               LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
322               TColStd_IndexedMapOfInteger aMap;
323               aSelMgr->GetIndexes( firstIObject(), aMap );
324                 if ( aMap.Extent() == 1 )
325                   {
326                     int anIndex = aMap( 1 );
327                     aName += QString(":edge_%1").arg(anIndex);
328
329                     //Find SubShape Object in Father
330                     GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
331                     
332                     if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study
333                       GEOM::GEOM_IShapesOperations_var aShapesOp =
334                         getGeomEngine()->GetIShapesOperations( getStudyId() );
335                       if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
336                         myVectorV = aShapesOp->GetSubShape(aSelectedObject, anIndex);
337                       else
338                         myVectorU = aShapesOp->GetSubShape(aSelectedObject, anIndex);
339                     }
340                     else {
341                       if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
342                         myVectorV = aFindedObject;
343                       else
344                         myVectorU = aFindedObject;
345                     }
346                   }
347                 else {
348                   if (aShape.ShapeType() != TopAbs_EDGE) {
349                     aSelectedObject = GEOM::GEOM_Object::_nil();
350                     aName = "";
351                   }
352                   if ( myEditCurrentArgument == GroupDimensions->LineEdit3 )
353                     myVectorV = aSelectedObject;
354                   else
355                     myVectorU = aSelectedObject;
356                 }
357             }
358         }
359     }
360
361   myEditCurrentArgument->setText( aName );
362
363   displayPreview();     
364 }
365
366
367 //=================================================================================
368 // function : SetEditCurrentArgument()
369 // purpose  :
370 //=================================================================================
371 void TransformationGUI_MultiTranslationDlg::SetEditCurrentArgument()
372 {
373   QPushButton* send = (QPushButton*)sender();
374   globalSelection( GEOM_ALLSHAPES );
375
376   if(send == GroupPoints->PushButton1) {
377     myEditCurrentArgument = GroupPoints->LineEdit1;
378   }
379   else if(send == GroupPoints->PushButton2) {
380     myEditCurrentArgument = GroupPoints->LineEdit2;
381     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
382   }
383   else if(send == GroupDimensions->PushButton1) {
384     myEditCurrentArgument = GroupDimensions->LineEdit1;
385   }
386   else if(send == GroupDimensions->PushButton2) {
387     myEditCurrentArgument = GroupDimensions->LineEdit2;
388     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
389   }
390   else if(send == GroupDimensions->PushButton3) {
391     myEditCurrentArgument = GroupDimensions->LineEdit3;
392     localSelection( GEOM::GEOM_Object::_nil(), TopAbs_EDGE );
393   }
394
395   myEditCurrentArgument->setFocus();
396   SelectionIntoArgument();
397 }
398
399
400 //=================================================================================
401 // function : LineEditReturnPressed()
402 // purpose  :
403 //=================================================================================
404 void TransformationGUI_MultiTranslationDlg::LineEditReturnPressed()
405 {
406   QLineEdit* send = (QLineEdit*)sender();
407   if(send == GroupPoints->LineEdit1 || send == GroupDimensions->LineEdit1 ||
408      send == GroupPoints->LineEdit2 || send == GroupDimensions->LineEdit2 ||
409                                        send == GroupDimensions->LineEdit3)
410     {
411       myEditCurrentArgument = send;
412       GEOMBase_Skeleton::LineEditReturnPressed();
413     }
414 }
415
416
417 //=================================================================================
418 // function : ActivateThisDialog()
419 // purpose  :
420 //=================================================================================
421 void TransformationGUI_MultiTranslationDlg::ActivateThisDialog()
422 {
423   GEOMBase_Skeleton::ActivateThisDialog();
424   connect(myGeomGUI->getApp()->selectionMgr(),
425           SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
426
427   ConstructorsClicked( getConstructorId() );
428 }
429
430
431 //=================================================================================
432 // function : enterEvent()
433 // purpose  :
434 //=================================================================================
435 void TransformationGUI_MultiTranslationDlg::enterEvent(QEvent* e)
436 {
437   if(!GroupConstructors->isEnabled())
438     ActivateThisDialog();
439 }
440
441
442 //=================================================================================
443 // function : ValueChangedInSpinBox()
444 // purpose  :
445 //=================================================================================
446 void TransformationGUI_MultiTranslationDlg::ValueChangedInSpinBox(double newValue)
447 {
448   QObject* send = (QObject*)sender();
449
450   switch(getConstructorId())
451     {
452     case 0 :
453       { 
454         if(send == GroupPoints->SpinBox_DX)
455           myStepU = newValue;
456         else if(send == GroupPoints->SpinBox_DY)
457           myNbTimesU = (int)newValue;
458         break;
459       }
460     case 1 :
461       { 
462         if(send == GroupDimensions->SpinBox_DX1)
463           myStepU = newValue;
464         else if(send == GroupDimensions->SpinBox_DY1)
465           myNbTimesU = (int)newValue;
466         else if(send == GroupDimensions->SpinBox_DX2)
467           myStepV = newValue;
468         else if(send == GroupDimensions->SpinBox_DY2)
469           myNbTimesV = (int)newValue;
470         break;
471       }
472     }
473
474   displayPreview();
475 }
476
477
478 //=================================================================================
479 // function : ReverseStepU()
480 // purpose  : 'state' not used here
481 //=================================================================================
482 void TransformationGUI_MultiTranslationDlg::ReverseStepU()
483 {
484   myStepU = -myStepU;
485
486   int aConstructorId = getConstructorId();
487
488   if(aConstructorId == 0)
489     GroupPoints->SpinBox_DX->SetValue(myStepU);
490   else if(aConstructorId == 1)
491     GroupDimensions->SpinBox_DX1->SetValue(myStepU);
492
493   displayPreview();
494 }
495
496
497 //=================================================================================
498 // function : ReverseStepV
499 // purpose  : 'state' not used here
500 //=================================================================================
501 void TransformationGUI_MultiTranslationDlg::ReverseStepV()
502 {
503   myStepV = -myStepV;
504
505   GroupDimensions->SpinBox_DX2->SetValue(myStepV);
506
507   displayPreview();
508 }
509
510
511 //=================================================================================
512 // function : createOperation
513 // purpose  :
514 //=================================================================================
515 GEOM::GEOM_IOperations_ptr TransformationGUI_MultiTranslationDlg::createOperation()
516 {
517   return myGeomGUI->GetGeomGen()->GetITransformOperations( getStudyId() );
518 }
519
520
521 //=================================================================================
522 // function : isValid
523 // purpose  :
524 //=================================================================================
525 bool TransformationGUI_MultiTranslationDlg::isValid( QString& msg )
526 {
527   int aConstructorId = getConstructorId();
528
529   if(aConstructorId == 0)
530     return !(myBase->_is_nil() || myVectorU->_is_nil());
531   else if(aConstructorId == 1)
532     return !(myBase->_is_nil() || myVectorU->_is_nil() || myVectorV->_is_nil());
533   return 0;
534 }
535
536 //=================================================================================
537 // function : execute
538 // purpose  :
539 //=================================================================================
540 bool TransformationGUI_MultiTranslationDlg::execute( ObjectList& objects )
541 {
542   bool res = false;
543
544   GEOM::GEOM_Object_var anObj;
545
546   switch ( getConstructorId() )
547     {
548     case 0 :
549       {
550         if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVectorU ) ) {
551           anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiTranslate1D( myBase, myVectorU, myStepU, myNbTimesU );
552           res = true;
553         }
554         break;
555       }
556     case 1 :
557       {
558         if ( !CORBA::is_nil( myBase ) && !CORBA::is_nil( myVectorU ) && !CORBA::is_nil( myVectorV ) )
559           {
560             anObj = GEOM::GEOM_ITransformOperations::_narrow( getOperation() )->MultiTranslate2D( myBase, myVectorU, myStepU, myNbTimesU,
561                                                                                                           myVectorV, myStepV, myNbTimesV );
562             res = true;
563           }
564         break;
565       }
566     }
567
568   if ( !anObj->_is_nil() )
569     objects.push_back( anObj._retn() );
570
571   return res;
572 }
573
574
575 //=================================================================================
576 // function : closeEvent
577 // purpose  :
578 //=================================================================================
579 void  TransformationGUI_MultiTranslationDlg::closeEvent( QCloseEvent* e )
580 {
581   // myGeomGUI->SetState( -1 );
582   GEOMBase_Skeleton::closeEvent( e );
583 }
584
585 //=================================================================================
586 // function : addSubshapeToStudy
587 // purpose  : virtual method to add new SubObjects if local selection
588 //=================================================================================
589 void TransformationGUI_MultiTranslationDlg::addSubshapesToStudy()
590 {
591   QMap<QString, GEOM::GEOM_Object_var> objMap;
592   
593   switch (getConstructorId())
594     {
595     case 0:
596       objMap[GroupPoints->LineEdit2->text()] = myVectorU;
597       break;
598     case 1:
599       objMap[GroupDimensions->LineEdit2->text()] = myVectorU;
600       objMap[GroupDimensions->LineEdit3->text()] = myVectorV;
601       break;
602     }
603   addSubshapesToFather( objMap );
604 }