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