Salome HOME
untabify
[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     try {
508       SUIT_OverrideCursor aWaitCursor;
509       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
510       switch ( actionButton ) {
511       case MOVE_ELEMS_BUTTON:
512         if(CheckBoxMesh->isChecked())
513           aMeshEditor->TranslateObject(mySelectedObject, aVector, false);
514         else
515           aMeshEditor->Translate(anElementsId, aVector, false);
516         if( !myMesh->_is_nil())
517           myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
518         break;
519       case COPY_ELEMS_BUTTON:
520         if ( makeGroups ) {
521           SMESH::ListOfGroups_var groups;
522           if(CheckBoxMesh->isChecked())
523             groups = aMeshEditor->TranslateObjectMakeGroups(mySelectedObject,aVector);
524           else
525             groups = aMeshEditor->TranslateMakeGroups(anElementsId, aVector);
526         }
527         else {
528           if(CheckBoxMesh->isChecked())
529             aMeshEditor->TranslateObject(mySelectedObject, aVector, true);
530           else
531             aMeshEditor->Translate(anElementsId, aVector, true);
532         }
533         if( !myMesh->_is_nil())
534           myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
535         break;
536       case MAKE_MESH_BUTTON:
537         SMESH::SMESH_Mesh_var mesh;
538         if (CheckBoxMesh->isChecked())
539           mesh = aMeshEditor->TranslateObjectMakeMesh(mySelectedObject, aVector, makeGroups,
540                                                       LineEditNewMesh->text().toLatin1().data());
541         else
542           mesh = aMeshEditor->TranslateMakeMesh(anElementsId, aVector, makeGroups,
543                                                 LineEditNewMesh->text().toLatin1().data());
544         if (!mesh->_is_nil()) {
545           mesh->SetParameters(aParameters.join(":").toLatin1().constData());
546 #ifdef WITHGENERICOBJ
547           // obj has been published in study. Its refcount has been incremented.
548           // It is safe to decrement its refcount
549           // so that it will be destroyed when the entry in study will be removed
550           mesh->UnRegister();
551 #endif
552         }
553       }
554     } catch (...) {
555     }
556
557     SMESH::UpdateView();
558     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ||
559          actionButton == MAKE_MESH_BUTTON )
560       mySMESHGUI->updateObjBrowser(true); // new groups may appear
561     Init(false);
562     ConstructorsClicked(GetConstructorId());
563     mySelectedObject = SMESH::SMESH_IDSource::_nil();
564     SelectionIntoArgument();
565
566     SMESHGUI::Modified();
567   }
568
569   return true;
570 }
571
572 //=================================================================================
573 // function : ClickOnOk()
574 // purpose  :
575 //=================================================================================
576 void SMESHGUI_TranslationDlg::ClickOnOk()
577 {
578   if( ClickOnApply() )
579     ClickOnCancel();
580 }
581
582 //=================================================================================
583 // function : ClickOnCancel()
584 // purpose  :
585 //=================================================================================
586 void SMESHGUI_TranslationDlg::ClickOnCancel()
587 {
588   disconnect(mySelectionMgr, 0, this, 0);
589   mySelectionMgr->clearFilters();
590   //mySelectionMgr->clearSelected();
591   if (SMESH::GetCurrentVtkView()) {
592     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
593     SMESH::SetPointRepresentation(false);
594   }
595   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
596     aViewWindow->SetSelectionMode( ActorSelection );
597   mySMESHGUI->ResetState();
598   reject();
599 }
600
601 //=================================================================================
602 // function : ClickOnHelp()
603 // purpose  :
604 //=================================================================================
605 void SMESHGUI_TranslationDlg::ClickOnHelp()
606 {
607   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
608   if (app)
609     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
610   else {
611     QString platform;
612 #ifdef WIN32
613     platform = "winapplication";
614 #else
615     platform = "application";
616 #endif
617     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
618                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
619                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
620                                                                  platform)).
621                              arg(myHelpFileName));
622   }
623 }
624
625 //=======================================================================
626 // function : onTextChange()
627 // purpose  :
628 //=======================================================================
629 void SMESHGUI_TranslationDlg::onTextChange (const QString& theNewText)
630 {
631   QLineEdit* send = (QLineEdit*)sender();
632
633   if (myBusy) return;
634   BusyLocker lock( myBusy );
635
636   if (send == LineEditElements)
637     myNbOkElements = 0;
638
639   buttonOk->setEnabled(false);
640   buttonApply->setEnabled(false);
641
642   // hilight entered elements
643   SMDS_Mesh* aMesh = 0;
644   if (myActor)
645     aMesh = myActor->GetObject()->GetMesh();
646
647   if (aMesh) {
648     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
649
650     TColStd_MapOfInteger newIndices;
651
652     QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
653
654     if (send == LineEditElements) {
655       for (int i = 0; i < aListId.count(); i++) {
656         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
657         if (e)
658           newIndices.Add(e->GetID());
659         myNbOkElements++;
660       }
661     }
662
663     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
664     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
665       aViewWindow->highlight( anIO, true, true );
666
667     myElementsId = theNewText;
668   }
669
670   if (myNbOkElements) {
671     buttonOk->setEnabled(true);
672     buttonApply->setEnabled(true);
673   }
674 }
675
676 //=================================================================================
677 // function : SelectionIntoArgument()
678 // purpose  : Called when selection as changed or other case
679 //=================================================================================
680 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
681 {
682   if (myBusy) return;
683   BusyLocker lock( myBusy );
684   // clear
685   myActor = 0;
686   QString aString = "";
687
688   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
689     LineEditElements->setText(aString);
690     myNbOkElements = 0;
691     buttonOk->setEnabled(false);
692     buttonApply->setEnabled(false);
693   }
694
695   if (!GroupButtons->isEnabled()) // inactive
696     return;
697
698   // get selected mesh
699   SALOME_ListIO aList;
700   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
701
702   int nbSel = aList.Extent();
703   if (nbSel != 1)
704     return;
705
706   Handle(SALOME_InteractiveObject) IO = aList.First();
707   myMesh = SMESH::GetMeshByIO(IO);
708   if (myMesh->_is_nil())
709     return;
710
711   myActor = SMESH::FindActorByObject(myMesh);
712   if (!myActor)
713     myActor = SMESH::FindActorByEntry(IO->getEntry());
714
715   if (!myActor && !CheckBoxMesh->isChecked())
716       return;
717
718   int aNbUnits = 0;
719
720   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
721     myElementsId = "";
722
723     // MakeGroups is available if there are groups and "Copy"
724     if ( myMesh->NbGroups() == 0 ) {
725       MakeGroupsCheck->setChecked(false);
726       MakeGroupsCheck->setEnabled(false);
727     }
728     else if ( ActionGroup->checkedId() != MOVE_ELEMS_BUTTON ) {
729       MakeGroupsCheck->setEnabled(true);
730     }
731
732     if (CheckBoxMesh->isChecked()) {
733       SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
734
735       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH, SUBMESH, OR GROUP
736         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
737       }
738       else
739         return;
740         // get IDs from mesh
741         /*
742         SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
743         if (!aSMDSMesh)
744           return;
745
746         for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
747           const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
748           if (e) {
749             myElementsId += QString(" %1").arg(i);
750             aNbUnits++;
751           }
752         }
753       } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
754         // get submesh
755         SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
756
757         // get IDs from submesh
758         SMESH::long_array_var anElementsIds = new SMESH::long_array;
759         anElementsIds = aSubMesh->GetElementsId();
760         for (int i = 0; i < anElementsIds->length(); i++) {
761           myElementsId += QString(" %1").arg(anElementsIds[i]);
762         }
763         aNbUnits = anElementsIds->length();
764       } else { // GROUP
765         // get smesh group
766         SMESH::SMESH_GroupBase_var aGroup =
767           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
768         if (aGroup->_is_nil())
769           return;
770
771         // get IDs from smesh group
772         SMESH::long_array_var anElementsIds = new SMESH::long_array;
773         anElementsIds = aGroup->GetListOfID();
774         for (int i = 0; i < anElementsIds->length(); i++) {
775           myElementsId += QString(" %1").arg(anElementsIds[i]);
776         }
777         aNbUnits = anElementsIds->length();
778       }
779         */
780     } else {
781       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
782       myElementsId = aString;
783       if (aNbUnits < 1)
784         return;
785     }
786
787     myNbOkElements = true;
788   } else {
789     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
790     if (aNbUnits != 1)
791       return;
792
793     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
794     if (!aMesh)
795       return;
796
797     const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
798     if (!n)
799       return;
800
801     double x = n->X();
802     double y = n->Y();
803     double z = n->Z();
804
805     if (myEditCurrentArgument == (QWidget*)SpinBox1_1) {
806       SpinBox1_1->SetValue(x);
807       SpinBox1_2->SetValue(y);
808       SpinBox1_3->SetValue(z);
809     } else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) {
810       SpinBox2_1->SetValue(x);
811       SpinBox2_2->SetValue(y);
812       SpinBox2_3->SetValue(z);
813     }
814   }
815
816   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
817     LineEditElements->setText(aString);
818     LineEditElements->repaint();
819     LineEditElements->setEnabled(false); // to fully update lineedit IPAL 19809
820     LineEditElements->setEnabled(true);
821     setNewMeshName();
822   }
823
824   // OK
825   if (myNbOkElements) {
826     buttonOk->setEnabled(true);
827     buttonApply->setEnabled(true);
828   }
829   onDisplaySimulation(true);
830 }
831
832 //=================================================================================
833 // function : SetEditCurrentArgument()
834 // purpose  :
835 //=================================================================================
836 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
837 {
838   QPushButton* send = (QPushButton*)sender();
839
840   disconnect(mySelectionMgr, 0, this, 0);
841   mySelectionMgr->clearSelected();
842   mySelectionMgr->clearFilters();
843   
844   if (send == SelectElementsButton) {
845     myEditCurrentArgument = (QWidget*)LineEditElements;
846     SMESH::SetPointRepresentation(false);
847     if (CheckBoxMesh->isChecked()) {
848       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
849         aViewWindow->SetSelectionMode( ActorSelection );
850       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
851     } else {
852
853       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
854         aViewWindow->SetSelectionMode( CellSelection );
855     }
856   } else if (send == SelectButton1) {
857     myEditCurrentArgument = (QWidget*)SpinBox1_1;
858     SMESH::SetPointRepresentation(true);
859
860     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
861       aViewWindow->SetSelectionMode( NodeSelection );
862   } else if (send == SelectButton2) {
863     myEditCurrentArgument = (QWidget*)SpinBox2_1;
864     SMESH::SetPointRepresentation(true);
865
866     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
867       aViewWindow->SetSelectionMode( NodeSelection );
868   }
869
870   myEditCurrentArgument->setFocus();
871   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
872   SelectionIntoArgument();
873 }
874
875 //=================================================================================
876 // function : DeactivateActiveDialog()
877 // purpose  :
878 //=================================================================================
879 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
880 {
881   if (ConstructorsBox->isEnabled()) {
882     ConstructorsBox->setEnabled(false);
883     GroupArguments->setEnabled(false);
884     GroupButtons->setEnabled(false);
885     mySMESHGUI->ResetState();
886     mySMESHGUI->SetActiveDialogBox(0);
887   }
888 }
889
890 //=================================================================================
891 // function : ActivateThisDialog()
892 // purpose  :
893 //=================================================================================
894 void SMESHGUI_TranslationDlg::ActivateThisDialog()
895 {
896   /* Emit a signal to deactivate the active dialog */
897   mySMESHGUI->EmitSignalDeactivateDialog();
898   ConstructorsBox->setEnabled(true);
899   GroupArguments->setEnabled(true);
900   GroupButtons->setEnabled(true);
901
902   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
903
904   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
905     aViewWindow->SetSelectionMode( CellSelection );
906
907   SelectionIntoArgument();
908 }
909
910 //=================================================================================
911 // function : enterEvent()
912 // purpose  :
913 //=================================================================================
914 void SMESHGUI_TranslationDlg::enterEvent (QEvent*)
915 {
916   if (!ConstructorsBox->isEnabled())
917     ActivateThisDialog();
918 }
919
920 //=================================================================================
921 // function : closeEvent()
922 // purpose  :
923 //=================================================================================
924 void SMESHGUI_TranslationDlg::closeEvent (QCloseEvent*)
925 {
926   /* same than click on cancel button */
927   ClickOnCancel();
928 }
929
930 //=======================================================================
931 //function : hideEvent
932 //purpose  : caused by ESC key
933 //=======================================================================
934 void SMESHGUI_TranslationDlg::hideEvent (QHideEvent*)
935 {
936   if (!isMinimized())
937     ClickOnCancel();
938 }
939
940 //=======================================================================
941 //function : onSelectMesh
942 //purpose  :
943 //=======================================================================
944 void SMESHGUI_TranslationDlg::onSelectMesh (bool toSelectMesh)
945 {
946   if (toSelectMesh)
947     TextLabelElements->setText(tr("SMESH_NAME"));
948   else
949     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
950   myFilterBtn->setEnabled(!toSelectMesh);
951
952   if (myEditCurrentArgument != LineEditElements) {
953     LineEditElements->clear();
954     return;
955   }
956
957   mySelectionMgr->clearFilters();
958   SMESH::SetPointRepresentation(false);
959
960   if (toSelectMesh) {
961     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
962       aViewWindow->SetSelectionMode( ActorSelection );
963     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
964     LineEditElements->setReadOnly(true);
965     LineEditElements->setValidator(0);
966   } else {
967     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
968       aViewWindow->SetSelectionMode( CellSelection );
969     LineEditElements->setReadOnly(false);
970     LineEditElements->setValidator(myIdValidator);
971     onTextChange(LineEditElements->text());
972     hidePreview();
973   }
974
975   SelectionIntoArgument();
976 }
977
978 //=======================================================================
979 //function : onActionClicked
980 //purpose  : slot called when an action type changed
981 //=======================================================================
982
983 void SMESHGUI_TranslationDlg::onActionClicked(int button)
984 {
985   switch ( button ) {
986   case MOVE_ELEMS_BUTTON:
987     MakeGroupsCheck->setEnabled(false);
988     LineEditNewMesh->setEnabled(false);
989     break;
990   case COPY_ELEMS_BUTTON:
991     LineEditNewMesh->setEnabled(false);
992     MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
993     if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
994       MakeGroupsCheck->setEnabled(true);
995     else
996       MakeGroupsCheck->setEnabled(false);
997     break;
998   case MAKE_MESH_BUTTON:
999     LineEditNewMesh->setEnabled(true);
1000     MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
1001     if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
1002       MakeGroupsCheck->setEnabled(true);
1003     else
1004       MakeGroupsCheck->setEnabled(false);
1005     break;
1006   }
1007   setNewMeshName();
1008 }
1009
1010 //=======================================================================
1011 //function : setNewMeshName
1012 //purpose  : update contents of LineEditNewMesh
1013 //=======================================================================
1014
1015 void SMESHGUI_TranslationDlg::setNewMeshName()
1016 {
1017   LineEditNewMesh->setText("");
1018   if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) {
1019     QString name;
1020     if ( CheckBoxMesh->isChecked() ) {
1021       name = LineEditElements->text();
1022     }
1023     else {
1024       _PTR(SObject) meshSO = SMESH::FindSObject( myMesh );
1025       name = meshSO->GetName().c_str();
1026     }
1027     if ( !name.isEmpty() )
1028       LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "translated"));
1029   }
1030 }
1031
1032 //=================================================================================
1033 // function : GetConstructorId()
1034 // purpose  :
1035 //=================================================================================
1036 int SMESHGUI_TranslationDlg::GetConstructorId()
1037 {
1038   return GroupConstructors->checkedId();
1039 }
1040
1041 //=================================================================================
1042 // function : keyPressEvent()
1043 // purpose  :
1044 //=================================================================================
1045 void SMESHGUI_TranslationDlg::keyPressEvent( QKeyEvent* e )
1046 {
1047   QDialog::keyPressEvent( e );
1048   if ( e->isAccepted() )
1049     return;
1050
1051   if ( e->key() == Qt::Key_F1 ) {
1052     e->accept();
1053     ClickOnHelp();
1054   }
1055 }
1056
1057 //=================================================================================
1058 // function : setFilters()
1059 // purpose  : SLOT. Called when "Filter" button pressed.
1060 //=================================================================================
1061 void SMESHGUI_TranslationDlg::setFilters()
1062 {
1063   if(myMesh->_is_nil()) {
1064     SUIT_MessageBox::critical(this,
1065                               tr("SMESH_ERROR"),
1066                               tr("NO_MESH_SELECTED"));
1067    return;
1068   }
1069   if ( !myFilterDlg )
1070     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
1071
1072   myFilterDlg->SetSelection();
1073   myFilterDlg->SetMesh( myMesh );
1074   myFilterDlg->SetSourceWg( LineEditElements );
1075
1076   myFilterDlg->show();
1077 }
1078
1079 //=================================================================================
1080 // function : isValid
1081 // purpose  :
1082 //=================================================================================
1083 bool SMESHGUI_TranslationDlg::isValid()
1084 {
1085   bool ok = true;
1086   QString msg;
1087
1088   ok = SpinBox1_1->isValid( msg, true ) && ok;
1089   ok = SpinBox1_2->isValid( msg, true ) && ok;
1090   ok = SpinBox1_3->isValid( msg, true ) && ok;
1091   if (GetConstructorId() == 0) {
1092     ok = SpinBox2_1->isValid( msg, true ) && ok;
1093     ok = SpinBox2_2->isValid( msg, true ) && ok;
1094     ok = SpinBox2_3->isValid( msg, true ) && ok;
1095   }
1096
1097   if( !ok ) {
1098     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1099     if ( !msg.isEmpty() )
1100       str += "\n" + msg;
1101     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1102     return false;
1103   }
1104   return true;
1105 }
1106
1107 //=================================================================================
1108 // function : onDisplaySimulation
1109 // purpose  : Show/Hide preview
1110 //=================================================================================
1111 void SMESHGUI_TranslationDlg::onDisplaySimulation( bool toDisplayPreview ) {
1112   if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
1113     
1114     if (isValid() && myNbOkElements) {
1115       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1116       
1117       SMESH::long_array_var anElementsId = new SMESH::long_array;
1118
1119       anElementsId->length(aListElementsId.count());
1120       for (int i = 0; i < aListElementsId.count(); i++)
1121         anElementsId[i] = aListElementsId[i].toInt();
1122
1123       SMESH::DirStruct aVector;
1124       if (GetConstructorId() == 0) {
1125         aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
1126         aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
1127         aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
1128       } else if (GetConstructorId() == 1) {
1129         aVector.PS.x = SpinBox1_1->GetValue();
1130         aVector.PS.y = SpinBox1_2->GetValue();
1131         aVector.PS.z = SpinBox1_3->GetValue();
1132       }
1133
1134       try {
1135         bool copy = ActionGroup->checkedId() == COPY_ELEMS_BUTTON;
1136         SUIT_OverrideCursor aWaitCursor;
1137         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1138         if(CheckBoxMesh->isChecked())
1139           aMeshEditor->TranslateObject(mySelectedObject, aVector, copy);
1140         else
1141           aMeshEditor->Translate(anElementsId, aVector, copy);
1142         
1143         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1144         mySimulation->SetData(aMeshPreviewStruct._retn());      
1145       } catch (...) {
1146         
1147       }
1148     }
1149     else {
1150       hidePreview();
1151     }
1152   } else {
1153     hidePreview();
1154   }
1155 }