Salome HOME
Replace oe by ?
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_TranslationDlg.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 //  SMESH SMESHGUI : GUI for SMESH component
23 //  File   : SMESHGUI_TranslationDlg.cxx
24 //  Author : Michael ZORIN, Open CASCADE S.A.S.
25 //  SMESH includes
26
27 #include "SMESHGUI_TranslationDlg.h"
28
29 #include "SMESHGUI.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_FilterDlg.h"
36 #include "SMESHGUI_MeshEditPreview.h"
37
38 #include <SMESH_Actor.h>
39 #include <SMESH_TypeFilter.hxx>
40 #include <SMESH_LogicalFilter.hxx>
41 #include <SMDS_Mesh.hxx>
42
43 // SALOME GUI includes
44 #include <SUIT_Desktop.h>
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
47 #include <SUIT_MessageBox.h>
48 #include <SUIT_OverrideCursor.h>
49
50 #include <LightApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52
53 #include <SVTK_ViewModel.h>
54 #include <SVTK_ViewWindow.h>
55 #include <SALOME_ListIO.hxx>
56
57 // SALOME KERNEL includes
58 #include <SALOMEDSClient_SObject.hxx>
59
60 // OCCT includes
61 #include <TColStd_MapOfInteger.hxx>
62
63 // Qt includes
64 #include <QApplication>
65 #include <QButtonGroup>
66 #include <QGroupBox>
67 #include <QLabel>
68 #include <QLineEdit>
69 #include <QPushButton>
70 #include <QRadioButton>
71 #include <QCheckBox>
72 #include <QHBoxLayout>
73 #include <QVBoxLayout>
74 #include <QGridLayout>
75 #include <QSpinBox>
76 #include <QKeyEvent>
77
78 // IDL includes
79 #include <SALOMEconfig.h>
80 #include CORBA_SERVER_HEADER(SMESH_Group)
81 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
82
83 enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action type
84
85 /*!
86   \class BusyLocker
87   \brief Simple 'busy state' flag locker.
88   \internal
89 */
90
91 class BusyLocker
92 {
93 public:
94   //! Constructor. Sets passed boolean flag to \c true.
95   BusyLocker( bool& busy ) : myBusy( busy ) { myBusy = true; }
96   //! Destructor. Clear external boolean flag passed as parameter to the constructor to \c false.
97   ~BusyLocker() { myBusy = false; }
98 private:
99   bool& myBusy; //! External 'busy state' boolean flag
100 };
101
102 #define SPACING 6
103 #define MARGIN  11
104
105 //To disable automatic genericobj management, the following line should be commented.
106 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
107 #define WITHGENERICOBJ
108
109 //=================================================================================
110 // class    : SMESHGUI_TranslationDlg()
111 // purpose  :
112 //=================================================================================
113 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule ) : 
114   SMESHGUI_PreviewDlg( theModule ),
115   mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
116   myFilterDlg(0),
117   mySelectedObject(SMESH::SMESH_IDSource::_nil())
118 {
119   QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS")));
120   QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR")));
121   QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
122
123   setModal(false);
124   setAttribute(Qt::WA_DeleteOnClose, true);
125   setWindowTitle(tr("SMESH_TRANSLATION"));
126   setSizeGripEnabled(true);
127
128   QVBoxLayout* SMESHGUI_TranslationDlgLayout = new QVBoxLayout(this);
129   SMESHGUI_TranslationDlgLayout->setSpacing(SPACING);
130   SMESHGUI_TranslationDlgLayout->setMargin(MARGIN);
131
132   /***************************************************************/
133   ConstructorsBox = new QGroupBox(tr("SMESH_TRANSLATION"), this);
134   GroupConstructors = new QButtonGroup(this);
135   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
136   ConstructorsBoxLayout->setSpacing(SPACING);
137   ConstructorsBoxLayout->setMargin(MARGIN);
138
139   RadioButton1= new QRadioButton(ConstructorsBox);
140   RadioButton1->setIcon(image0);
141   RadioButton2= new QRadioButton(ConstructorsBox);
142   RadioButton2->setIcon(image1);
143
144   ConstructorsBoxLayout->addWidget(RadioButton1);
145   ConstructorsBoxLayout->addWidget(RadioButton2);
146   GroupConstructors->addButton(RadioButton1, 0);
147   GroupConstructors->addButton(RadioButton2, 1);
148
149   /***************************************************************/
150   GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
151   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
152   GroupArgumentsLayout->setSpacing(SPACING);
153   GroupArgumentsLayout->setMargin(MARGIN);
154
155   myIdValidator = new SMESHGUI_IdValidator(this);
156
157   // Controls for elements selection
158   TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
159   SelectElementsButton = new QPushButton(GroupArguments);
160   SelectElementsButton->setIcon(image2);
161   LineEditElements = new QLineEdit(GroupArguments);
162   LineEditElements->setValidator(myIdValidator);
163   LineEditElements->setMaxLength(-1);
164   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
165   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
166
167   // Control for the whole mesh selection
168   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
169
170   // Controls for vector and points selection
171   TextLabel1 = new QLabel(GroupArguments);
172   SelectButton1 = new QPushButton(GroupArguments);
173   SelectButton1->setIcon(image2);
174
175   TextLabel1_1 = new QLabel(GroupArguments);
176   SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments);
177   TextLabel1_2 = new QLabel(GroupArguments);
178   SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments);
179   TextLabel1_3 = new QLabel(GroupArguments);
180   SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments);
181
182   TextLabel2 = new QLabel(tr("SMESH_POINT_2"), GroupArguments);
183   SelectButton2  = new QPushButton(GroupArguments);
184   SelectButton2->setIcon(image2);
185
186   TextLabel2_1 = new QLabel(tr("SMESH_X"), GroupArguments);
187   SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments);
188   TextLabel2_2 = new QLabel(tr("SMESH_Y"), GroupArguments);
189   SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments);
190   TextLabel2_3 = new QLabel(tr("SMESH_Z"), GroupArguments);
191   SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments);
192
193   // switch of action type
194   ActionBox = new QGroupBox(GroupArguments);
195   ActionGroup = new QButtonGroup(GroupArguments);
196   QVBoxLayout* ActionBoxLayout = new QVBoxLayout(ActionBox);
197   ActionBoxLayout->addSpacing(SPACING);
198   ActionBoxLayout->setMargin(MARGIN);
199
200   QRadioButton* aMoveElements = new QRadioButton(tr("SMESH_MOVE_ELEMENTS"), ActionBox);
201   QRadioButton* aCopyElements = new QRadioButton(tr("SMESH_COPY_ELEMENTS"), ActionBox);
202   QRadioButton* aCreateMesh   = new QRadioButton(tr("SMESH_CREATE_MESH"),   ActionBox);
203
204   ActionBoxLayout->addWidget(aMoveElements);
205   ActionBoxLayout->addWidget(aCopyElements);
206   ActionBoxLayout->addWidget(aCreateMesh);
207   ActionGroup->addButton(aMoveElements, MOVE_ELEMS_BUTTON);
208   ActionGroup->addButton(aCopyElements, COPY_ELEMS_BUTTON);
209   ActionGroup->addButton(aCreateMesh,   MAKE_MESH_BUTTON);
210
211   // CheckBox for groups generation
212   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
213   MakeGroupsCheck->setChecked(false);
214
215   // Name of a mesh to create
216   LineEditNewMesh = new QLineEdit(GroupArguments);
217
218   //Preview check box
219   myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
220
221   // layout
222   GroupArgumentsLayout->addWidget(TextLabelElements,    0, 0);
223   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
224   GroupArgumentsLayout->addWidget(LineEditElements,     0, 2, 1, 5);
225   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 7);
226   GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 8);
227   GroupArgumentsLayout->addWidget(TextLabel1,           2, 0);
228   GroupArgumentsLayout->addWidget(SelectButton1,        2, 1);
229   GroupArgumentsLayout->addWidget(TextLabel1_1,         2, 2);
230   GroupArgumentsLayout->addWidget(SpinBox1_1,           2, 3);
231   GroupArgumentsLayout->addWidget(TextLabel1_2,         2, 4);
232   GroupArgumentsLayout->addWidget(SpinBox1_2,           2, 5);
233   GroupArgumentsLayout->addWidget(TextLabel1_3,         2, 6);
234   GroupArgumentsLayout->addWidget(SpinBox1_3,           2, 7);
235   GroupArgumentsLayout->addWidget(TextLabel2,           3, 0);
236   GroupArgumentsLayout->addWidget(SelectButton2,        3, 1);
237   GroupArgumentsLayout->addWidget(TextLabel2_1,         3, 2);
238   GroupArgumentsLayout->addWidget(SpinBox2_1,           3, 3);
239   GroupArgumentsLayout->addWidget(TextLabel2_2,         3, 4);
240   GroupArgumentsLayout->addWidget(SpinBox2_2,           3, 5);
241   GroupArgumentsLayout->addWidget(TextLabel2_3,         3, 6);
242   GroupArgumentsLayout->addWidget(SpinBox2_3,           3, 7);
243   GroupArgumentsLayout->addWidget(ActionBox,            4, 0, 3, 4);
244   GroupArgumentsLayout->addWidget(MakeGroupsCheck,      5, 5, 1, 4);
245   GroupArgumentsLayout->addWidget(LineEditNewMesh,      6, 5, 1, 4);
246   GroupArgumentsLayout->addWidget(myPreviewCheckBox,    7, 0);
247
248   /***************************************************************/
249   GroupButtons = new QGroupBox(this);
250   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
251   GroupButtonsLayout->setSpacing(SPACING);
252   GroupButtonsLayout->setMargin(MARGIN);
253
254   buttonOk = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
255   buttonOk->setAutoDefault(true);
256   buttonOk->setDefault(true);
257   buttonApply = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons);
258   buttonApply->setAutoDefault(true);
259   buttonCancel = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
260   buttonCancel->setAutoDefault(true);
261   buttonHelp = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
262   buttonHelp->setAutoDefault(true);
263
264   GroupButtonsLayout->addWidget(buttonOk);
265   GroupButtonsLayout->addSpacing(10);
266   GroupButtonsLayout->addWidget(buttonApply);
267   GroupButtonsLayout->addSpacing(10);
268   GroupButtonsLayout->addStretch();
269   GroupButtonsLayout->addWidget(buttonCancel);
270   GroupButtonsLayout->addWidget(buttonHelp);
271
272   /***************************************************************/
273   SMESHGUI_TranslationDlgLayout->addWidget(ConstructorsBox);
274   SMESHGUI_TranslationDlgLayout->addWidget(GroupArguments);
275   SMESHGUI_TranslationDlgLayout->addWidget(GroupButtons);
276
277   /* Initialisations */
278   SpinBox1_1->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
279   SpinBox1_2->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
280   SpinBox1_3->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
281   SpinBox2_1->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
282   SpinBox2_2->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
283   SpinBox2_3->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
284
285   RadioButton1->setChecked(true);
286
287   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
288
289   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
290
291   // Costruction of the logical filter
292   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
293   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
294
295   QList<SUIT_SelectionFilter*> aListOfFilters;
296   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
297   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
298
299   myMeshOrSubMeshOrGroupFilter =
300     new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR);
301
302   myHelpFileName = "translation_page.html";
303
304   Init();
305
306   /* signals and slots connections */
307   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
308   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
309   connect(buttonApply,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
310   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
311   connect(GroupConstructors, SIGNAL(buttonClicked(int)), SLOT(ConstructorsClicked(int)));
312
313   connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
314   connect(SelectButton1,        SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
315   connect(SelectButton2,        SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
316
317   connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
318   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),   this, SLOT(SelectionIntoArgument()));
319   /* to close dialog if study change */
320   connect(mySMESHGUI,       SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
321   connect(LineEditElements, SIGNAL(textChanged(const QString&)),    SLOT(onTextChange(const QString&)));
322   connect(CheckBoxMesh,     SIGNAL(toggled(bool)),                  SLOT(onSelectMesh(bool)));
323   connect(ActionGroup,      SIGNAL(buttonClicked(int)),             SLOT(onActionClicked(int)));
324
325   connect(SpinBox1_1,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
326   connect(SpinBox1_2,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
327   connect(SpinBox1_3,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
328
329   connect(SpinBox2_1,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
330   connect(SpinBox2_2,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
331   connect(SpinBox2_3,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
332   connect(SpinBox2_3,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
333
334   
335   //To Connect preview check box
336   connectPreviewControl();
337
338   ConstructorsClicked(0);
339   SelectionIntoArgument();
340   onActionClicked(MOVE_ELEMS_BUTTON);
341 }
342
343 //=================================================================================
344 // function : ~SMESHGUI_TranslationDlg()
345 // purpose  : Destroys the object and frees any allocated resources
346 //=================================================================================
347 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
348 {
349   if ( myFilterDlg ) {
350     myFilterDlg->setParent( 0 );
351     delete myFilterDlg;
352     myFilterDlg = 0;
353   }
354 }
355
356 //=================================================================================
357 // function : Init()
358 // purpose  :
359 //=================================================================================
360 void SMESHGUI_TranslationDlg::Init (bool ResetControls)
361 {
362   myBusy = false;
363
364   myEditCurrentArgument = 0;
365   LineEditElements->clear();
366   myElementsId = "";
367   myNbOkElements = 0;
368
369   buttonOk->setEnabled(false);
370   buttonApply->setEnabled(false);
371
372   myActor = 0;
373   myMesh = SMESH::SMESH_Mesh::_nil();
374
375   if (ResetControls) {
376     SpinBox1_1->SetValue(0.0);
377     SpinBox1_2->SetValue(0.0);
378     SpinBox1_3->SetValue(0.0);
379     SpinBox2_1->SetValue(0.0);
380     SpinBox2_2->SetValue(0.0);
381     SpinBox2_3->SetValue(0.0);
382
383     ActionGroup->button( MOVE_ELEMS_BUTTON )->setChecked(true);
384     CheckBoxMesh->setChecked(false);
385 //     MakeGroupsCheck->setChecked(false);
386 //     MakeGroupsCheck->setEnabled(false);
387     myPreviewCheckBox->setChecked(false);
388     onDisplaySimulation(false);
389     onSelectMesh(false);
390   }
391 }
392
393 //=================================================================================
394 // function : ConstructorsClicked()
395 // purpose  : Radio button management
396 //=================================================================================
397 void SMESHGUI_TranslationDlg::ConstructorsClicked (int constructorId)
398 {
399   disconnect(mySelectionMgr, 0, this, 0);
400
401   switch (constructorId) {
402   case 0:
403     {
404       TextLabel1->setText(tr("SMESH_POINT_1"));
405       TextLabel1_1->setText(tr("SMESH_X"));
406       TextLabel1_2->setText(tr("SMESH_Y"));
407       TextLabel1_3->setText(tr("SMESH_Z"));
408
409       SelectButton1->show();
410       TextLabel2->show();
411       SelectButton2->show();
412       TextLabel2_1->show();
413       SpinBox2_1->show();
414       TextLabel2_2->show();
415       SpinBox2_2->show();
416       TextLabel2_3->show();
417       SpinBox2_3->show();
418       break;
419     }
420   case 1:
421     {
422       TextLabel1->setText(tr("SMESH_VECTOR"));
423       TextLabel1_1->setText(tr("SMESH_DX"));
424       TextLabel1_2->setText(tr("SMESH_DY"));
425       TextLabel1_3->setText(tr("SMESH_DZ"));
426
427       SelectButton1->hide();
428       TextLabel2->hide();
429       SelectButton2->hide();
430       TextLabel2_1->hide();
431       SpinBox2_1->hide();
432       TextLabel2_2->hide();
433       SpinBox2_2->hide();
434       TextLabel2_3->hide();
435       SpinBox2_3->hide();
436       break;
437     }
438   }
439
440   if (myEditCurrentArgument != (QWidget*)LineEditElements) {
441     SMESH::SetPointRepresentation(false);
442     if (!CheckBoxMesh->isChecked())
443       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
444         aViewWindow->SetSelectionMode( CellSelection );
445   }
446
447   myEditCurrentArgument = (QWidget*)LineEditElements;
448   LineEditElements->setFocus();
449
450   if (CheckBoxMesh->isChecked())
451     onSelectMesh(true);
452
453   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
454
455   onDisplaySimulation(true);
456
457   QApplication::instance()->processEvents();
458   updateGeometry();
459   resize(100,100);
460 }
461
462 //=================================================================================
463 // function : ClickOnApply()
464 // purpose  :
465 //=================================================================================
466 bool SMESHGUI_TranslationDlg::ClickOnApply()
467 {
468   if (mySMESHGUI->isActiveStudyLocked())
469     return false;
470
471   if( !isValid() )
472     return false;
473
474   if (myNbOkElements) {
475     QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
476
477     SMESH::long_array_var anElementsId = new SMESH::long_array;
478
479     anElementsId->length(aListElementsId.count());
480     for (int i = 0; i < aListElementsId.count(); i++)
481       anElementsId[i] = aListElementsId[i].toInt();
482
483     SMESH::DirStruct aVector;
484     if (GetConstructorId() == 0) {
485       aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
486       aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
487       aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
488     } else if (GetConstructorId() == 1) {
489       aVector.PS.x = SpinBox1_1->GetValue();
490       aVector.PS.y = SpinBox1_2->GetValue();
491       aVector.PS.z = SpinBox1_3->GetValue();
492     }
493
494     QStringList aParameters;
495     aParameters << SpinBox1_1->text();
496     if (GetConstructorId() == 0)
497       aParameters << SpinBox2_1->text();
498     aParameters << SpinBox1_2->text();
499     if (GetConstructorId() == 0)
500       aParameters << SpinBox2_2->text();
501     aParameters << SpinBox1_3->text();
502     if (GetConstructorId() == 0)
503       aParameters << SpinBox2_3->text();
504
505     int actionButton = ActionGroup->checkedId();
506     bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
507     QStringList anEntryList;
508     try {
509       SUIT_OverrideCursor aWaitCursor;
510       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
511       switch ( actionButton ) {
512       case MOVE_ELEMS_BUTTON:
513         if(CheckBoxMesh->isChecked())
514           aMeshEditor->TranslateObject(mySelectedObject, aVector, false);
515         else
516           aMeshEditor->Translate(anElementsId, aVector, false);
517         if( !myMesh->_is_nil())
518           myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
519         break;
520       case COPY_ELEMS_BUTTON:
521         if ( makeGroups ) {
522           SMESH::ListOfGroups_var groups;
523           if(CheckBoxMesh->isChecked())
524             groups = aMeshEditor->TranslateObjectMakeGroups(mySelectedObject,aVector);
525           else
526             groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector);
527         }
528         else {
529           if(CheckBoxMesh->isChecked())
530             aMeshEditor->TranslateObject(mySelectedObject, aVector, true);
531           else
532             aMeshEditor->Translate(anElementsId, aVector, true);
533         }
534         if( !myMesh->_is_nil())
535           myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
536         break;
537       case MAKE_MESH_BUTTON:
538         SMESH::SMESH_Mesh_var mesh;
539         if (CheckBoxMesh->isChecked())
540           mesh = aMeshEditor->TranslateObjectMakeMesh(mySelectedObject, aVector, makeGroups,
541                                                       LineEditNewMesh->text().toLatin1().data());
542         else
543           mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
544                                                 LineEditNewMesh->text().toLatin1().data());
545         if (!mesh->_is_nil()) {
546           mesh->SetParameters(aParameters.join(":").toLatin1().constData());
547           if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
548             anEntryList.append( aSObject->GetID().c_str() );
549 #ifdef WITHGENERICOBJ
550           // obj has been published in study. Its refcount has been incremented.
551           // It is safe to decrement its refcount
552           // so that it will be destroyed when the entry in study will be removed
553           mesh->UnRegister();
554 #endif
555         }
556       }
557     } catch (...) {
558     }
559
560     SMESH::UpdateView();
561     if ( ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) ||
562          actionButton == MAKE_MESH_BUTTON ) {
563       mySMESHGUI->updateObjBrowser(true); // new groups may appear
564       if( LightApp_Application* anApp =
565           dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
566         anApp->browseObjects( anEntryList, isApplyAndClose() );
567     }
568       
569     Init(false);
570     ConstructorsClicked(GetConstructorId());
571     mySelectedObject = SMESH::SMESH_IDSource::_nil();
572     SelectionIntoArgument();
573
574     SMESHGUI::Modified();
575   }
576
577   return true;
578 }
579
580 //=================================================================================
581 // function : ClickOnOk()
582 // purpose  :
583 //=================================================================================
584 void SMESHGUI_TranslationDlg::ClickOnOk()
585 {
586   setIsApplyAndClose( true );
587   if( ClickOnApply() )
588     ClickOnCancel();
589 }
590
591 //=================================================================================
592 // function : ClickOnCancel()
593 // purpose  :
594 //=================================================================================
595 void SMESHGUI_TranslationDlg::ClickOnCancel()
596 {
597   disconnect(mySelectionMgr, 0, this, 0);
598   mySelectionMgr->clearFilters();
599   //mySelectionMgr->clearSelected();
600   if (SMESH::GetCurrentVtkView()) {
601     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
602     SMESH::SetPointRepresentation(false);
603   }
604   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
605     aViewWindow->SetSelectionMode( ActorSelection );
606   mySMESHGUI->ResetState();
607   reject();
608 }
609
610 //=================================================================================
611 // function : ClickOnHelp()
612 // purpose  :
613 //=================================================================================
614 void SMESHGUI_TranslationDlg::ClickOnHelp()
615 {
616   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
617   if (app)
618     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
619   else {
620     QString platform;
621 #ifdef WIN32
622     platform = "winapplication";
623 #else
624     platform = "application";
625 #endif
626     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
627                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
628                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
629                                                                  platform)).
630                              arg(myHelpFileName));
631   }
632 }
633
634 //=======================================================================
635 // function : onTextChange()
636 // purpose  :
637 //=======================================================================
638 void SMESHGUI_TranslationDlg::onTextChange (const QString& theNewText)
639 {
640   QLineEdit* send = (QLineEdit*)sender();
641
642   if (myBusy) return;
643   BusyLocker lock( myBusy );
644
645   if (send == LineEditElements)
646     myNbOkElements = 0;
647
648   buttonOk->setEnabled(false);
649   buttonApply->setEnabled(false);
650
651   // hilight entered elements
652   SMDS_Mesh* aMesh = 0;
653   if (myActor)
654     aMesh = myActor->GetObject()->GetMesh();
655
656   if (aMesh) {
657     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
658
659     TColStd_MapOfInteger newIndices;
660
661     QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
662
663     if (send == LineEditElements) {
664       for (int i = 0; i < aListId.count(); i++) {
665         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
666         if (e)
667           newIndices.Add(e->GetID());
668         myNbOkElements++;
669       }
670     }
671
672     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
673     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
674       aViewWindow->highlight( anIO, true, true );
675
676     myElementsId = theNewText;
677   }
678
679   if (myNbOkElements) {
680     buttonOk->setEnabled(true);
681     buttonApply->setEnabled(true);
682   }
683 }
684
685 //=================================================================================
686 // function : SelectionIntoArgument()
687 // purpose  : Called when selection as changed or other case
688 //=================================================================================
689 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
690 {
691   if (myBusy) return;
692   BusyLocker lock( myBusy );
693   // clear
694   myActor = 0;
695   QString aString = "";
696
697   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
698     LineEditElements->setText(aString);
699     myNbOkElements = 0;
700     buttonOk->setEnabled(false);
701     buttonApply->setEnabled(false);
702   }
703
704   if (!GroupButtons->isEnabled()) // inactive
705     return;
706
707   // get selected mesh
708   SALOME_ListIO aList;
709   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
710
711   int nbSel = aList.Extent();
712   if (nbSel != 1)
713     return;
714
715   Handle(SALOME_InteractiveObject) IO = aList.First();
716   myMesh = SMESH::GetMeshByIO(IO);
717   if (myMesh->_is_nil())
718     return;
719
720   myActor = SMESH::FindActorByObject(myMesh);
721   if (!myActor)
722     myActor = SMESH::FindActorByEntry(IO->getEntry());
723
724   if (!myActor && !CheckBoxMesh->isChecked())
725       return;
726
727   int aNbUnits = 0;
728
729   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
730     myElementsId = "";
731
732     // MakeGroups is available if there are groups and "Copy"
733     if ( myMesh->NbGroups() == 0 ) {
734       MakeGroupsCheck->setChecked(false);
735       MakeGroupsCheck->setEnabled(false);
736     }
737     else if ( ActionGroup->checkedId() != MOVE_ELEMS_BUTTON ) {
738       MakeGroupsCheck->setEnabled(true);
739     }
740
741     if (CheckBoxMesh->isChecked()) {
742       SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
743
744       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH, SUBMESH, OR GROUP
745         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
746       }
747       else
748         return;
749         // get IDs from mesh
750         /*
751         SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
752         if (!aSMDSMesh)
753           return;
754
755         for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
756           const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
757           if (e) {
758             myElementsId += QString(" %1").arg(i);
759             aNbUnits++;
760           }
761         }
762       } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
763         // get submesh
764         SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
765
766         // get IDs from submesh
767         SMESH::long_array_var anElementsIds = new SMESH::long_array;
768         anElementsIds = aSubMesh->GetElementsId();
769         for (int i = 0; i < anElementsIds->length(); i++) {
770           myElementsId += QString(" %1").arg(anElementsIds[i]);
771         }
772         aNbUnits = anElementsIds->length();
773       } else { // GROUP
774         // get smesh group
775         SMESH::SMESH_GroupBase_var aGroup =
776           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
777         if (aGroup->_is_nil())
778           return;
779
780         // get IDs from smesh group
781         SMESH::long_array_var anElementsIds = new SMESH::long_array;
782         anElementsIds = aGroup->GetListOfID();
783         for (int i = 0; i < anElementsIds->length(); i++) {
784           myElementsId += QString(" %1").arg(anElementsIds[i]);
785         }
786         aNbUnits = anElementsIds->length();
787       }
788         */
789     } else {
790       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
791       myElementsId = aString;
792       if (aNbUnits < 1)
793         return;
794     }
795
796     myNbOkElements = true;
797   } else {
798     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
799     if (aNbUnits != 1)
800       return;
801
802     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
803     if (!aMesh)
804       return;
805
806     const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
807     if (!n)
808       return;
809
810     double x = n->X();
811     double y = n->Y();
812     double z = n->Z();
813
814     if (myEditCurrentArgument == (QWidget*)SpinBox1_1) {
815       SpinBox1_1->SetValue(x);
816       SpinBox1_2->SetValue(y);
817       SpinBox1_3->SetValue(z);
818     } else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) {
819       SpinBox2_1->SetValue(x);
820       SpinBox2_2->SetValue(y);
821       SpinBox2_3->SetValue(z);
822     }
823   }
824
825   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
826     LineEditElements->setText(aString);
827     LineEditElements->repaint();
828     LineEditElements->setEnabled(false); // to fully update lineedit IPAL 19809
829     LineEditElements->setEnabled(true);
830     setNewMeshName();
831   }
832
833   // OK
834   if (myNbOkElements) {
835     buttonOk->setEnabled(true);
836     buttonApply->setEnabled(true);
837   }
838   onDisplaySimulation(true);
839 }
840
841 //=================================================================================
842 // function : SetEditCurrentArgument()
843 // purpose  :
844 //=================================================================================
845 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
846 {
847   QPushButton* send = (QPushButton*)sender();
848
849   disconnect(mySelectionMgr, 0, this, 0);
850   mySelectionMgr->clearSelected();
851   mySelectionMgr->clearFilters();
852   
853   if (send == SelectElementsButton) {
854     myEditCurrentArgument = (QWidget*)LineEditElements;
855     SMESH::SetPointRepresentation(false);
856     if (CheckBoxMesh->isChecked()) {
857       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
858         aViewWindow->SetSelectionMode( ActorSelection );
859       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
860     } else {
861
862       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
863         aViewWindow->SetSelectionMode( CellSelection );
864     }
865   } else if (send == SelectButton1) {
866     myEditCurrentArgument = (QWidget*)SpinBox1_1;
867     SMESH::SetPointRepresentation(true);
868
869     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
870       aViewWindow->SetSelectionMode( NodeSelection );
871   } else if (send == SelectButton2) {
872     myEditCurrentArgument = (QWidget*)SpinBox2_1;
873     SMESH::SetPointRepresentation(true);
874
875     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
876       aViewWindow->SetSelectionMode( NodeSelection );
877   }
878
879   myEditCurrentArgument->setFocus();
880   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
881   SelectionIntoArgument();
882 }
883
884 //=================================================================================
885 // function : DeactivateActiveDialog()
886 // purpose  :
887 //=================================================================================
888 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
889 {
890   if (ConstructorsBox->isEnabled()) {
891     ConstructorsBox->setEnabled(false);
892     GroupArguments->setEnabled(false);
893     GroupButtons->setEnabled(false);
894     mySMESHGUI->ResetState();
895     mySMESHGUI->SetActiveDialogBox(0);
896   }
897 }
898
899 //=================================================================================
900 // function : ActivateThisDialog()
901 // purpose  :
902 //=================================================================================
903 void SMESHGUI_TranslationDlg::ActivateThisDialog()
904 {
905   /* Emit a signal to deactivate the active dialog */
906   mySMESHGUI->EmitSignalDeactivateDialog();
907   ConstructorsBox->setEnabled(true);
908   GroupArguments->setEnabled(true);
909   GroupButtons->setEnabled(true);
910
911   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
912
913   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
914     aViewWindow->SetSelectionMode( CellSelection );
915
916   SelectionIntoArgument();
917 }
918
919 //=================================================================================
920 // function : enterEvent()
921 // purpose  :
922 //=================================================================================
923 void SMESHGUI_TranslationDlg::enterEvent (QEvent*)
924 {
925   if (!ConstructorsBox->isEnabled())
926     ActivateThisDialog();
927 }
928
929 //=================================================================================
930 // function : closeEvent()
931 // purpose  :
932 //=================================================================================
933 void SMESHGUI_TranslationDlg::closeEvent (QCloseEvent*)
934 {
935   /* same than click on cancel button */
936   ClickOnCancel();
937 }
938
939 //=======================================================================
940 //function : hideEvent
941 //purpose  : caused by ESC key
942 //=======================================================================
943 void SMESHGUI_TranslationDlg::hideEvent (QHideEvent*)
944 {
945   if (!isMinimized())
946     ClickOnCancel();
947 }
948
949 //=======================================================================
950 //function : onSelectMesh
951 //purpose  :
952 //=======================================================================
953 void SMESHGUI_TranslationDlg::onSelectMesh (bool toSelectMesh)
954 {
955   if (toSelectMesh)
956     TextLabelElements->setText(tr("SMESH_NAME"));
957   else
958     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
959   myFilterBtn->setEnabled(!toSelectMesh);
960
961   if (myEditCurrentArgument != LineEditElements) {
962     LineEditElements->clear();
963     return;
964   }
965
966   mySelectionMgr->clearFilters();
967   SMESH::SetPointRepresentation(false);
968
969   if (toSelectMesh) {
970     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
971       aViewWindow->SetSelectionMode( ActorSelection );
972     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
973     LineEditElements->setReadOnly(true);
974     LineEditElements->setValidator(0);
975   } else {
976     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
977       aViewWindow->SetSelectionMode( CellSelection );
978     LineEditElements->setReadOnly(false);
979     LineEditElements->setValidator(myIdValidator);
980     onTextChange(LineEditElements->text());
981     hidePreview();
982   }
983
984   SelectionIntoArgument();
985 }
986
987 //=======================================================================
988 //function : onActionClicked
989 //purpose  : slot called when an action type changed
990 //=======================================================================
991
992 void SMESHGUI_TranslationDlg::onActionClicked(int button)
993 {
994   switch ( button ) {
995   case MOVE_ELEMS_BUTTON:
996     MakeGroupsCheck->setEnabled(false);
997     LineEditNewMesh->setEnabled(false);
998     break;
999   case COPY_ELEMS_BUTTON:
1000     LineEditNewMesh->setEnabled(false);
1001     MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
1002     if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
1003       MakeGroupsCheck->setEnabled(true);
1004     else
1005       MakeGroupsCheck->setEnabled(false);
1006     break;
1007   case MAKE_MESH_BUTTON:
1008     LineEditNewMesh->setEnabled(true);
1009     MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
1010     if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
1011       MakeGroupsCheck->setEnabled(true);
1012     else
1013       MakeGroupsCheck->setEnabled(false);
1014     break;
1015   }
1016   setNewMeshName();
1017   toDisplaySimulation();
1018 }
1019
1020 //=======================================================================
1021 //function : setNewMeshName
1022 //purpose  : update contents of LineEditNewMesh
1023 //=======================================================================
1024
1025 void SMESHGUI_TranslationDlg::setNewMeshName()
1026 {
1027   LineEditNewMesh->setText("");
1028   if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) {
1029     QString name;
1030     if ( CheckBoxMesh->isChecked() ) {
1031       name = LineEditElements->text();
1032     }
1033     else {
1034       _PTR(SObject) meshSO = SMESH::FindSObject( myMesh );
1035       name = meshSO->GetName().c_str();
1036     }
1037     if ( !name.isEmpty() )
1038       LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "translated"));
1039   }
1040 }
1041
1042 //=================================================================================
1043 // function : GetConstructorId()
1044 // purpose  :
1045 //=================================================================================
1046 int SMESHGUI_TranslationDlg::GetConstructorId()
1047 {
1048   return GroupConstructors->checkedId();
1049 }
1050
1051 //=================================================================================
1052 // function : keyPressEvent()
1053 // purpose  :
1054 //=================================================================================
1055 void SMESHGUI_TranslationDlg::keyPressEvent( QKeyEvent* e )
1056 {
1057   QDialog::keyPressEvent( e );
1058   if ( e->isAccepted() )
1059     return;
1060
1061   if ( e->key() == Qt::Key_F1 ) {
1062     e->accept();
1063     ClickOnHelp();
1064   }
1065 }
1066
1067 //=================================================================================
1068 // function : setFilters()
1069 // purpose  : SLOT. Called when "Filter" button pressed.
1070 //=================================================================================
1071 void SMESHGUI_TranslationDlg::setFilters()
1072 {
1073   if(myMesh->_is_nil()) {
1074     SUIT_MessageBox::critical(this,
1075                               tr("SMESH_ERROR"),
1076                               tr("NO_MESH_SELECTED"));
1077    return;
1078   }
1079   if ( !myFilterDlg )
1080     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
1081
1082   myFilterDlg->SetSelection();
1083   myFilterDlg->SetMesh( myMesh );
1084   myFilterDlg->SetSourceWg( LineEditElements );
1085
1086   myFilterDlg->show();
1087 }
1088
1089 //=================================================================================
1090 // function : isValid
1091 // purpose  :
1092 //=================================================================================
1093 bool SMESHGUI_TranslationDlg::isValid()
1094 {
1095   bool ok = true;
1096   QString msg;
1097
1098   ok = SpinBox1_1->isValid( msg, true ) && ok;
1099   ok = SpinBox1_2->isValid( msg, true ) && ok;
1100   ok = SpinBox1_3->isValid( msg, true ) && ok;
1101   if (GetConstructorId() == 0) {
1102     ok = SpinBox2_1->isValid( msg, true ) && ok;
1103     ok = SpinBox2_2->isValid( msg, true ) && ok;
1104     ok = SpinBox2_3->isValid( msg, true ) && ok;
1105   }
1106
1107   if( !ok ) {
1108     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1109     if ( !msg.isEmpty() )
1110       str += "\n" + msg;
1111     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1112     return false;
1113   }
1114   return true;
1115 }
1116
1117 //=================================================================================
1118 // function : onDisplaySimulation
1119 // purpose  : Show/Hide preview
1120 //=================================================================================
1121 void SMESHGUI_TranslationDlg::onDisplaySimulation( bool toDisplayPreview ) {
1122   if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
1123     
1124     if (isValid() && myNbOkElements) {
1125       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1126       
1127       SMESH::long_array_var anElementsId = new SMESH::long_array;
1128
1129       anElementsId->length(aListElementsId.count());
1130       for (int i = 0; i < aListElementsId.count(); i++)
1131         anElementsId[i] = aListElementsId[i].toInt();
1132
1133       SMESH::DirStruct aVector;
1134       if (GetConstructorId() == 0) {
1135         aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
1136         aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
1137         aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
1138       } else if (GetConstructorId() == 1) {
1139         aVector.PS.x = SpinBox1_1->GetValue();
1140         aVector.PS.y = SpinBox1_2->GetValue();
1141         aVector.PS.z = SpinBox1_3->GetValue();
1142       }
1143
1144       try {
1145         bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON ||
1146                       ActionGroup->checkedId() == MAKE_MESH_BUTTON );
1147         SUIT_OverrideCursor aWaitCursor;
1148         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1149         if(CheckBoxMesh->isChecked())
1150           aMeshEditor->TranslateObject(mySelectedObject, aVector, copy);
1151         else
1152           aMeshEditor->Translate(anElementsId, aVector, copy);
1153         
1154         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1155         mySimulation->SetData(aMeshPreviewStruct._retn());      
1156       } catch (...) {
1157         
1158       }
1159     }
1160     else {
1161       hidePreview();
1162     }
1163   } else {
1164     hidePreview();
1165   }
1166 }