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