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