Salome HOME
Update Help references (bug 17577)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_TranslationDlg.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SMESHGUI_TranslationDlg.cxx
25 //  Author : Michael ZORIN
26 //  Module : SMESH
27 //  $Header:
28
29 #include "SMESHGUI_TranslationDlg.h"
30
31 #include "SMESHGUI.h"
32 #include "SMESHGUI_SpinBox.h"
33 #include "SMESHGUI_Utils.h"
34 #include "SMESHGUI_VTKUtils.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_IdValidator.h"
37
38 #include "SMESH_Actor.h"
39 #include "SMESH_TypeFilter.hxx"
40 #include "SMESH_LogicalFilter.hxx"
41 #include "SMDS_Mesh.hxx"
42
43 #include "SUIT_Desktop.h"
44 #include "SUIT_ResourceMgr.h"
45 #include "SUIT_Session.h"
46 #include "SUIT_MessageBox.h"
47
48 #include "LightApp_Application.h"
49
50 #include "SVTK_ViewModel.h"
51 #include "SVTK_Selection.h"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_Selector.h"
54 #include "SALOME_ListIO.hxx"
55
56 #include "utilities.h"
57
58 // OCCT Includes
59 #include <TColStd_MapOfInteger.hxx>
60 #include <TColStd_IndexedMapOfInteger.hxx>
61
62 // QT Includes
63 #include <qapplication.h>
64 #include <qbuttongroup.h>
65 #include <qgroupbox.h>
66 #include <qlabel.h>
67 #include <qlineedit.h>
68 #include <qpushbutton.h>
69 #include <qradiobutton.h>
70 #include <qcheckbox.h>
71 #include <qlayout.h>
72 #include <qspinbox.h>
73 #include <qpixmap.h>
74
75 // IDL Headers
76 #include "SALOMEconfig.h"
77 #include CORBA_SERVER_HEADER(SMESH_Group)
78 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
79
80 using namespace std;
81
82 //=================================================================================
83 // class    : SMESHGUI_TranslationDlg()
84 // purpose  :
85 //=================================================================================
86 SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( SMESHGUI* theModule, const char* name,
87                                                   bool modal, WFlags fl)
88      : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
89                 WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
90      mySMESHGUI( theModule ),
91      mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
92 {
93   QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_POINTS")));
94   QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_TRANSLATION_VECTOR")));
95   QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
96
97   if (!name)
98     setName("SMESHGUI_TranslationDlg");
99   resize(303, 185);
100   setCaption(tr("SMESH_TRANSLATION"));
101   setSizeGripEnabled(TRUE);
102   SMESHGUI_TranslationDlgLayout = new QGridLayout(this);
103   SMESHGUI_TranslationDlgLayout->setSpacing(6);
104   SMESHGUI_TranslationDlgLayout->setMargin(11);
105
106   /***************************************************************/
107   GroupConstructors = new QButtonGroup(this, "GroupConstructors");
108   GroupConstructors->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth()));
109   GroupConstructors->setTitle(tr("SMESH_TRANSLATION" ));
110   GroupConstructors->setExclusive(TRUE);
111   GroupConstructors->setColumnLayout(0, Qt::Vertical);
112   GroupConstructors->layout()->setSpacing(0);
113   GroupConstructors->layout()->setMargin(0);
114   GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
115   GroupConstructorsLayout->setAlignment(Qt::AlignTop);
116   GroupConstructorsLayout->setSpacing(6);
117   GroupConstructorsLayout->setMargin(11);
118   RadioButton1= new QRadioButton(GroupConstructors, "RadioButton1");
119   RadioButton1->setText(tr("" ));
120   RadioButton1->setPixmap(image0);
121   GroupConstructorsLayout->addWidget(RadioButton1, 0, 0);
122   RadioButton2= new QRadioButton(GroupConstructors, "RadioButton2");
123   RadioButton2->setText(tr("" ));
124   RadioButton2->setPixmap(image1);
125   GroupConstructorsLayout->addWidget(RadioButton2, 0, 2 );
126   SMESHGUI_TranslationDlgLayout->addWidget(GroupConstructors, 0, 0);
127
128   /***************************************************************/
129   GroupButtons = new QGroupBox(this, "GroupButtons");
130   GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth()));
131   GroupButtons->setGeometry(QRect(10, 10, 281, 48));
132   GroupButtons->setTitle(tr("" ));
133   GroupButtons->setColumnLayout(0, Qt::Vertical);
134   GroupButtons->layout()->setSpacing(0);
135   GroupButtons->layout()->setMargin(0);
136   GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
137   GroupButtonsLayout->setAlignment(Qt::AlignTop);
138   GroupButtonsLayout->setSpacing(6);
139   GroupButtonsLayout->setMargin(11);
140   buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
141   buttonHelp->setText(tr("SMESH_BUT_HELP" ));
142   buttonHelp->setAutoDefault(TRUE);
143   GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
144   buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
145   buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
146   buttonCancel->setAutoDefault(TRUE);
147   GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
148   buttonApply = new QPushButton(GroupButtons, "buttonApply");
149   buttonApply->setText(tr("SMESH_BUT_APPLY" ));
150   buttonApply->setAutoDefault(TRUE);
151   GroupButtonsLayout->addWidget(buttonApply, 0, 1);
152   QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
153   GroupButtonsLayout->addItem(spacer_9, 0, 2);
154   buttonOk = new QPushButton(GroupButtons, "buttonOk");
155   buttonOk->setText(tr("SMESH_BUT_OK" ));
156   buttonOk->setAutoDefault(TRUE);
157   buttonOk->setDefault(TRUE);
158   GroupButtonsLayout->addWidget(buttonOk, 0, 0);
159   SMESHGUI_TranslationDlgLayout->addWidget(GroupButtons, 2, 0);
160
161   /***************************************************************/
162   GroupArguments = new QGroupBox(this, "GroupArguments");
163   GroupArguments->setTitle(tr("SMESH_ARGUMENTS"));
164   GroupArguments->setColumnLayout(0, Qt::Vertical);
165   GroupArguments->layout()->setSpacing(0);
166   GroupArguments->layout()->setMargin(0);
167   GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
168   GroupArgumentsLayout->setAlignment(Qt::AlignTop);
169   GroupArgumentsLayout->setSpacing(6);
170   GroupArgumentsLayout->setMargin(11);
171
172   // Controls for elements selection
173   TextLabelElements  = new QLabel(GroupArguments, "TextLabelElements");
174   TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
175   TextLabelElements->setFixedWidth(74);
176   GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
177
178   SelectElementsButton  = new QPushButton(GroupArguments, "SelectElementsButton");
179   SelectElementsButton->setText(tr("" ));
180   SelectElementsButton->setPixmap(image2);
181   SelectElementsButton->setToggleButton(FALSE);
182   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
183
184   LineEditElements  = new QLineEdit(GroupArguments, "LineEditElements");
185   LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
186   GroupArgumentsLayout->addMultiCellWidget(LineEditElements, 0, 0, 2, 7);
187
188   // Control for the whole mesh selection
189   CheckBoxMesh = new QCheckBox(GroupArguments, "CheckBoxMesh");
190   CheckBoxMesh->setText(tr("SMESH_SELECT_WHOLE_MESH" ));
191   GroupArgumentsLayout->addMultiCellWidget(CheckBoxMesh, 1, 1, 0, 7);
192
193   // Controls for vector and points selection
194   TextLabel1 = new QLabel(GroupArguments, "TextLabel1");
195   GroupArgumentsLayout->addWidget(TextLabel1, 2, 0);
196
197   SelectButton1  = new QPushButton(GroupArguments, "SelectButton1");
198   SelectButton1->setText(tr("" ));
199   SelectButton1->setPixmap(image2);
200   SelectButton1->setToggleButton(FALSE);
201   GroupArgumentsLayout->addWidget(SelectButton1, 2, 1);
202
203   TextLabel1_1 = new QLabel(GroupArguments, "TextLabel1_1");
204   TextLabel1_1->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
205   GroupArgumentsLayout->addWidget(TextLabel1_1, 2, 2);
206
207   SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1");
208   GroupArgumentsLayout->addWidget(SpinBox1_1, 2, 3);
209
210   TextLabel1_2 = new QLabel(GroupArguments, "TextLabel1_2");
211   TextLabel1_2->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
212   GroupArgumentsLayout->addWidget(TextLabel1_2, 2, 4);
213
214   SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2");
215   GroupArgumentsLayout->addWidget(SpinBox1_2, 2, 5);
216
217   TextLabel1_3 = new QLabel(GroupArguments, "TextLabel1_3");
218   TextLabel1_3->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
219   GroupArgumentsLayout->addWidget(TextLabel1_3, 2, 6);
220
221   SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3");
222   GroupArgumentsLayout->addWidget(SpinBox1_3, 2, 7);
223
224   TextLabel2 = new QLabel(GroupArguments, "TextLabel2");
225   TextLabel2->setText(tr("SMESH_POINT_2" ));
226   GroupArgumentsLayout->addWidget(TextLabel2, 3, 0);
227
228   SelectButton2  = new QPushButton(GroupArguments, "SelectButton2");
229   SelectButton2->setText(tr("" ));
230   SelectButton2->setPixmap(image2);
231   SelectButton2->setToggleButton(FALSE);
232   GroupArgumentsLayout->addWidget(SelectButton2, 3, 1);
233
234   TextLabel2_1 = new QLabel(GroupArguments, "TextLabel2_1");
235   TextLabel2_1->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
236   TextLabel2_1->setText(tr("SMESH_X" ));
237   GroupArgumentsLayout->addWidget(TextLabel2_1, 3, 2);
238
239   SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1");
240   GroupArgumentsLayout->addWidget(SpinBox2_1, 3, 3);
241
242   TextLabel2_2 = new QLabel(GroupArguments, "TextLabel2_2");
243   TextLabel2_2->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
244   TextLabel2_2->setText(tr("SMESH_Y" ));
245   GroupArgumentsLayout->addWidget(TextLabel2_2, 3, 4);
246
247   SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2");
248   GroupArgumentsLayout->addWidget(SpinBox2_2, 3, 5);
249
250   TextLabel2_3 = new QLabel(GroupArguments, "TextLabel2_3");
251   TextLabel2_3->setAlignment( Qt::AlignRight | Qt::AlignVCenter | Qt::ExpandTabs );
252   TextLabel2_3->setText(tr("SMESH_Z"));
253   GroupArgumentsLayout->addWidget(TextLabel2_3, 3, 6);
254
255   SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3");
256   GroupArgumentsLayout->addWidget(SpinBox2_3, 3, 7);
257
258   // Controls for "Create a copy" option
259   CheckBoxCopy = new QCheckBox(GroupArguments, "CheckBoxCopy");
260   CheckBoxCopy->setText(tr("SMESH_CREATE_COPY"));
261   GroupArgumentsLayout->addMultiCellWidget(CheckBoxCopy, 4, 4, 0, 2);
262
263   // CheckBox for groups generation
264   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
265   MakeGroupsCheck->setChecked(false);
266   GroupArgumentsLayout->addMultiCellWidget(MakeGroupsCheck, 5, 5, 0, 2);
267
268   SMESHGUI_TranslationDlgLayout->addWidget(GroupArguments, 1, 0);
269
270   /* Initialisations */
271   SpinBox1_1->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
272   SpinBox1_2->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
273   SpinBox1_3->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
274   SpinBox2_1->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
275   SpinBox2_2->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
276   SpinBox2_3->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, DBL_DIGITS_DISPLAY);
277
278   GroupArguments->show();
279   RadioButton1->setChecked(TRUE);
280
281   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
282
283   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
284
285   // Costruction of the logical filter
286   SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
287   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (GROUP);
288
289   QPtrList<SUIT_SelectionFilter> aListOfFilters;
290   if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
291   if (aSmeshGroupFilter)    aListOfFilters.append(aSmeshGroupFilter);
292
293   myMeshOrSubMeshOrGroupFilter =
294     new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR);
295
296   myHelpFileName = "translation_page.html";
297
298   Init();
299
300   /* signals and slots connections */
301   connect(buttonOk, SIGNAL(clicked()),     this, SLOT(ClickOnOk()));
302   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
303   connect(buttonApply, SIGNAL(clicked()),  this, SLOT(ClickOnApply()));
304   connect(buttonHelp, SIGNAL(clicked()),   this, SLOT(ClickOnHelp()));
305   connect(GroupConstructors, SIGNAL(clicked(int)), SLOT(ConstructorsClicked(int)));
306
307   connect(SelectElementsButton, SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
308   connect(SelectButton1,        SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
309   connect(SelectButton2,        SIGNAL (clicked()), this, SLOT(SetEditCurrentArgument()));
310
311   connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
312   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),   this, SLOT(SelectionIntoArgument()));
313   /* to close dialog if study change */
314   connect(mySMESHGUI,       SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
315   connect(LineEditElements, SIGNAL(textChanged(const QString&)),    SLOT(onTextChange(const QString&)));
316   connect(CheckBoxMesh,     SIGNAL(toggled(bool)),                  SLOT(onSelectMesh(bool)));
317   connect(CheckBoxCopy,     SIGNAL(toggled(bool)),                  SLOT(onCopyChecked(bool)));
318
319   this->show(); /* displays Dialog */
320
321   ConstructorsClicked(0);
322   SelectionIntoArgument();
323   resize(0,0); // ??
324 }
325
326 //=================================================================================
327 // function : ~SMESHGUI_TranslationDlg()
328 // purpose  : Destroys the object and frees any allocated resources
329 //=================================================================================
330 SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg()
331 {
332   // no need to delete child widgets, Qt does it all for us
333 }
334
335 //=================================================================================
336 // function : Init()
337 // purpose  :
338 //=================================================================================
339 void SMESHGUI_TranslationDlg::Init (bool ResetControls)
340 {
341   myBusy = false;
342
343   myEditCurrentArgument = 0;
344   LineEditElements->clear();
345   myElementsId = "";
346   myNbOkElements = 0;
347
348   buttonOk->setEnabled(false);
349   buttonApply->setEnabled(false);
350
351   myActor = 0;
352   myMesh = SMESH::SMESH_Mesh::_nil();
353
354   if (ResetControls) {
355     SpinBox1_1->SetValue(0.0);
356     SpinBox1_2->SetValue(0.0);
357     SpinBox1_3->SetValue(0.0);
358     SpinBox2_1->SetValue(0.0);
359     SpinBox2_2->SetValue(0.0);
360     SpinBox2_3->SetValue(0.0);
361
362     CheckBoxCopy->setChecked(false);
363     CheckBoxMesh->setChecked(false);
364     MakeGroupsCheck->setChecked(false);
365     MakeGroupsCheck->setEnabled(false);
366     onSelectMesh(false);
367   }
368 }
369
370 //=================================================================================
371 // function : ConstructorsClicked()
372 // purpose  : Radio button management
373 //=================================================================================
374 void SMESHGUI_TranslationDlg::ConstructorsClicked (int constructorId)
375 {
376   disconnect(mySelectionMgr, 0, this, 0);
377
378   switch (constructorId) {
379   case 0:
380     {
381       TextLabel1->setText(tr("SMESH_POINT_1"));
382       TextLabel1_1->setText(tr("SMESH_X"));
383       TextLabel1_2->setText(tr("SMESH_Y"));
384       TextLabel1_3->setText(tr("SMESH_Z"));
385
386       SelectButton1->show();
387       TextLabel2->show();
388       SelectButton2->show();
389       TextLabel2_1->show();
390       SpinBox2_1->show();
391       TextLabel2_2->show();
392       SpinBox2_2->show();
393       TextLabel2_3->show();
394       SpinBox2_3->show();
395       break;
396     }
397   case 1:
398     {
399       TextLabel1->setText(tr("SMESH_VECTOR"));
400       TextLabel1_1->setText(tr("SMESH_DX"));
401       TextLabel1_2->setText(tr("SMESH_DY"));
402       TextLabel1_3->setText(tr("SMESH_DZ"));
403
404       SelectButton1->hide();
405       TextLabel2->hide();
406       SelectButton2->hide();
407       TextLabel2_1->hide();
408       SpinBox2_1->hide();
409       TextLabel2_2->hide();
410       SpinBox2_2->hide();
411       TextLabel2_3->hide();
412       SpinBox2_3->hide();
413       break;
414     }
415   }
416
417   if (myEditCurrentArgument != (QWidget*)LineEditElements) {
418     SMESH::SetPointRepresentation(false);
419     if (!CheckBoxMesh->isChecked())
420       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
421         aViewWindow->SetSelectionMode( CellSelection );
422   }
423
424   myEditCurrentArgument = (QWidget*)LineEditElements;
425   LineEditElements->setFocus();
426
427   if (CheckBoxMesh->isChecked())
428     onSelectMesh(true);
429
430   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
431 }
432
433 //=================================================================================
434 // function : ClickOnApply()
435 // purpose  :
436 //=================================================================================
437 void SMESHGUI_TranslationDlg::ClickOnApply()
438 {
439   if (mySMESHGUI->isActiveStudyLocked())
440     return;
441
442   if (myNbOkElements) {
443     QStringList aListElementsId = QStringList::split(" ", myElementsId, false);
444
445     SMESH::long_array_var anElementsId = new SMESH::long_array;
446
447     anElementsId->length(aListElementsId.count());
448     for (int i = 0; i < aListElementsId.count(); i++)
449       anElementsId[i] = aListElementsId[i].toInt();
450
451     SMESH::DirStruct aVector;
452     if (GetConstructorId() == 0) {
453       aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue();
454       aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue();
455       aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue();
456     } else if (GetConstructorId() == 1) {
457       aVector.PS.x = SpinBox1_1->GetValue();
458       aVector.PS.y = SpinBox1_2->GetValue();
459       aVector.PS.z = SpinBox1_3->GetValue();
460     }
461
462     bool toCreateCopy = CheckBoxCopy->isChecked();
463
464     try {
465       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
466       QApplication::setOverrideCursor(Qt::waitCursor);
467       if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
468         SMESH::ListOfGroups_var groups = 
469           aMeshEditor->TranslateMakeGroups(anElementsId.inout(), aVector);
470       else
471         aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy);
472       QApplication::restoreOverrideCursor();
473     } catch (...) {
474     }
475
476     SMESH::UpdateView();
477     if ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() )
478       mySMESHGUI->updateObjBrowser(true); // new groups may appear
479     Init(false);
480     ConstructorsClicked(GetConstructorId());
481     SelectionIntoArgument();
482   }
483 }
484
485 //=================================================================================
486 // function : ClickOnOk()
487 // purpose  :
488 //=================================================================================
489 void SMESHGUI_TranslationDlg::ClickOnOk()
490 {
491   ClickOnApply();
492   ClickOnCancel();
493 }
494
495 //=================================================================================
496 // function : ClickOnCancel()
497 // purpose  :
498 //=================================================================================
499 void SMESHGUI_TranslationDlg::ClickOnCancel()
500 {
501   disconnect(mySelectionMgr, 0, this, 0);
502   mySelectionMgr->clearFilters();
503   //mySelectionMgr->clearSelected();
504   SMESH::SetPointRepresentation(false);
505   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
506     aViewWindow->SetSelectionMode( ActorSelection );
507   mySMESHGUI->ResetState();
508   reject();
509 }
510
511 //=================================================================================
512 // function : ClickOnHelp()
513 // purpose  :
514 //=================================================================================
515 void SMESHGUI_TranslationDlg::ClickOnHelp()
516 {
517   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
518   if (app) 
519     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
520   else {
521                 QString platform;
522 #ifdef WIN32
523                 platform = "winapplication";
524 #else
525                 platform = "application";
526 #endif
527     SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
528                            QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
529                            arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
530                            QObject::tr("BUT_OK"));
531   }
532 }
533
534 //=======================================================================
535 // function : onTextChange()
536 // purpose  :
537 //=======================================================================
538 void SMESHGUI_TranslationDlg::onTextChange (const QString& theNewText)
539 {
540   QLineEdit* send = (QLineEdit*)sender();
541
542   if (myBusy) return;
543   myBusy = true;
544
545   if (send == LineEditElements)
546     myNbOkElements = 0;
547
548   buttonOk->setEnabled(false);
549   buttonApply->setEnabled(false);
550
551   // hilight entered elements
552   SMDS_Mesh* aMesh = 0;
553   if (myActor)
554     aMesh = myActor->GetObject()->GetMesh();
555
556   if (aMesh) {
557     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
558     
559     TColStd_MapOfInteger newIndices;
560
561     QStringList aListId = QStringList::split(" ", theNewText, false);
562
563     if (send == LineEditElements) {
564       for (int i = 0; i < aListId.count(); i++) {
565         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
566         if (e)
567           newIndices.Add(e->GetID());
568         myNbOkElements++;
569       }
570     }
571
572     mySelector->AddOrRemoveIndex( anIO, newIndices, false );
573     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
574       aViewWindow->highlight( anIO, true, true );
575     
576     myElementsId = theNewText;
577   }
578
579   if (myNbOkElements) {
580     buttonOk->setEnabled(true);
581     buttonApply->setEnabled(true);
582   }
583
584   myBusy = false;
585 }
586
587 //=================================================================================
588 // function : SelectionIntoArgument()
589 // purpose  : Called when selection as changed or other case
590 //=================================================================================
591 void SMESHGUI_TranslationDlg::SelectionIntoArgument()
592 {
593   if (myBusy) return;
594
595   // clear
596   myActor = 0;
597   QString aString = "";
598
599   myBusy = true;
600   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
601     LineEditElements->setText(aString);
602     myNbOkElements = 0;
603     buttonOk->setEnabled(false);
604     buttonApply->setEnabled(false);
605   }
606   myBusy = false;
607
608   if (!GroupButtons->isEnabled()) // inactive
609     return;
610
611   // get selected mesh
612   SALOME_ListIO aList;
613   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
614
615   int nbSel = aList.Extent();
616   if (nbSel != 1)
617     return;
618
619   Handle(SALOME_InteractiveObject) IO = aList.First();
620   myMesh = SMESH::GetMeshByIO(IO);
621   if (myMesh->_is_nil())
622     return;
623
624   myActor = SMESH::FindActorByObject(myMesh);
625   if (!myActor)
626     myActor = SMESH::FindActorByEntry(IO->getEntry());
627   if (!myActor)
628     return;
629
630   int aNbUnits = 0;
631
632   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
633     myElementsId = "";
634
635     // MakeGroups is available if there are groups and "Copy"
636     if ( myMesh->NbGroups() == 0 ) {
637       MakeGroupsCheck->setChecked(false);
638       MakeGroupsCheck->setEnabled(false);
639     }
640     else if (CheckBoxCopy->isChecked() ) {
641       MakeGroupsCheck->setEnabled(true);
642     }
643
644     if (CheckBoxMesh->isChecked()) {
645       SMESH::GetNameOfSelectedIObjects( mySelectionMgr, aString );
646
647       if (!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) { //MESH
648         // get IDs from mesh
649         SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
650         if (!aSMDSMesh)
651           return;
652
653         for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
654           const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
655           if (e) {
656             myElementsId += QString(" %1").arg(i);
657             aNbUnits++;
658           }
659         }
660       } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
661         // get submesh
662         SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
663
664         // get IDs from submesh
665         SMESH::long_array_var anElementsIds = new SMESH::long_array;
666         anElementsIds = aSubMesh->GetElementsId();
667         for (int i = 0; i < anElementsIds->length(); i++) {
668           myElementsId += QString(" %1").arg(anElementsIds[i]);
669         }
670         aNbUnits = anElementsIds->length();
671       } else { // GROUP
672         // get smesh group
673         SMESH::SMESH_GroupBase_var aGroup =
674           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
675         if (aGroup->_is_nil())
676           return;
677
678         // get IDs from smesh group
679         SMESH::long_array_var anElementsIds = new SMESH::long_array;
680         anElementsIds = aGroup->GetListOfID();
681         for (int i = 0; i < anElementsIds->length(); i++) {
682           myElementsId += QString(" %1").arg(anElementsIds[i]);
683         }
684         aNbUnits = anElementsIds->length();
685       }
686     } else {
687       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
688       myElementsId = aString;
689     }
690
691     if (aNbUnits < 1)
692       return;
693
694     myNbOkElements = true;
695   } else {
696     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
697     if (aNbUnits != 1)
698       return;
699
700     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
701     if (!aMesh)
702       return;
703
704     const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
705     if (!n)
706       return;
707
708     double x = n->X();
709     double y = n->Y();
710     double z = n->Z();
711
712     if (myEditCurrentArgument == (QWidget*)SpinBox1_1) {
713       SpinBox1_1->SetValue(x);
714       SpinBox1_2->SetValue(y);
715       SpinBox1_3->SetValue(z);
716     } else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) {
717       SpinBox2_1->SetValue(x);
718       SpinBox2_2->SetValue(y);
719       SpinBox2_3->SetValue(z);
720     }
721   }
722
723   myBusy = true;
724   if (myEditCurrentArgument == (QWidget*)LineEditElements)
725     LineEditElements->setText(aString);
726   myBusy = false;
727
728   // OK
729   if (myNbOkElements) {
730     buttonOk->setEnabled(true);
731     buttonApply->setEnabled(true);
732   }
733 }
734
735 //=================================================================================
736 // function : SetEditCurrentArgument()
737 // purpose  :
738 //=================================================================================
739 void SMESHGUI_TranslationDlg::SetEditCurrentArgument()
740 {
741   QPushButton* send = (QPushButton*)sender();
742
743   disconnect(mySelectionMgr, 0, this, 0);
744   mySelectionMgr->clearSelected();
745   mySelectionMgr->clearFilters();
746
747   if (send == SelectElementsButton) {
748     myEditCurrentArgument = (QWidget*)LineEditElements;
749     SMESH::SetPointRepresentation(false);
750     if (CheckBoxMesh->isChecked()) {
751       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
752         aViewWindow->SetSelectionMode( ActorSelection );
753       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
754     } else {
755
756       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
757         aViewWindow->SetSelectionMode( CellSelection );
758     }
759   } else if (send == SelectButton1) {
760     myEditCurrentArgument = (QWidget*)SpinBox1_1;
761     SMESH::SetPointRepresentation(true);
762
763     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
764       aViewWindow->SetSelectionMode( NodeSelection );
765   } else if (send == SelectButton2) {
766     myEditCurrentArgument = (QWidget*)SpinBox2_1;
767     SMESH::SetPointRepresentation(true);
768
769     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
770       aViewWindow->SetSelectionMode( NodeSelection );
771   }
772
773   myEditCurrentArgument->setFocus();
774   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
775   SelectionIntoArgument();
776 }
777
778 //=================================================================================
779 // function : DeactivateActiveDialog()
780 // purpose  :
781 //=================================================================================
782 void SMESHGUI_TranslationDlg::DeactivateActiveDialog()
783 {
784   if (GroupConstructors->isEnabled()) {
785     GroupConstructors->setEnabled(false);
786     GroupArguments->setEnabled(false);
787     GroupButtons->setEnabled(false);
788     mySMESHGUI->ResetState();
789     mySMESHGUI->SetActiveDialogBox(0);
790   }
791 }
792
793 //=================================================================================
794 // function : ActivateThisDialog()
795 // purpose  :
796 //=================================================================================
797 void SMESHGUI_TranslationDlg::ActivateThisDialog()
798 {
799   /* Emit a signal to deactivate the active dialog */
800   mySMESHGUI->EmitSignalDeactivateDialog();
801   GroupConstructors->setEnabled(true);
802   GroupArguments->setEnabled(true);
803   GroupButtons->setEnabled(true);
804
805   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
806
807   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
808     aViewWindow->SetSelectionMode( CellSelection );
809
810   SelectionIntoArgument();
811 }
812
813 //=================================================================================
814 // function : enterEvent()
815 // purpose  :
816 //=================================================================================
817 void SMESHGUI_TranslationDlg::enterEvent (QEvent*)
818 {
819   if (!GroupConstructors->isEnabled())
820     ActivateThisDialog();
821 }
822
823 //=================================================================================
824 // function : closeEvent()
825 // purpose  :
826 //=================================================================================
827 void SMESHGUI_TranslationDlg::closeEvent (QCloseEvent*)
828 {
829   /* same than click on cancel button */
830   this->ClickOnCancel();
831 }
832
833 //=======================================================================
834 //function : hideEvent
835 //purpose  : caused by ESC key
836 //=======================================================================
837 void SMESHGUI_TranslationDlg::hideEvent (QHideEvent*)
838 {
839   if (!isMinimized())
840     ClickOnCancel();
841 }
842
843 //=======================================================================
844 //function : onSelectMesh
845 //purpose  :
846 //=======================================================================
847 void SMESHGUI_TranslationDlg::onSelectMesh (bool toSelectMesh)
848 {
849   if (toSelectMesh)
850     TextLabelElements->setText(tr("SMESH_NAME"));
851   else
852     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
853
854   if (myEditCurrentArgument != LineEditElements) {
855     LineEditElements->clear();
856     return;
857   }
858
859   mySelectionMgr->clearFilters();
860   SMESH::SetPointRepresentation(false);
861
862   if (toSelectMesh) {
863     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
864       aViewWindow->SetSelectionMode( ActorSelection );
865     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
866     LineEditElements->setReadOnly(true);
867   } else {
868     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
869       aViewWindow->SetSelectionMode( CellSelection );
870     LineEditElements->setReadOnly(false);
871     onTextChange(LineEditElements->text());
872   }
873
874   SelectionIntoArgument();
875 }
876
877 //=======================================================================
878 //function : onCopyChecked
879 //purpose  : slot called when Copy checkBox is checked
880 //=======================================================================
881
882 void SMESHGUI_TranslationDlg::onCopyChecked(bool isOn)
883 {
884   // enable "MakeGroupsCheck"
885   if ( !myMesh->_is_nil() && myMesh->NbGroups() == 0)
886     isOn = false;
887   MakeGroupsCheck->setEnabled(isOn);
888 }
889
890 //=================================================================================
891 // function : GetConstructorId()
892 // purpose  :
893 //=================================================================================
894 int SMESHGUI_TranslationDlg::GetConstructorId()
895 {
896   if (GroupConstructors != NULL && GroupConstructors->selected() != NULL)
897     return GroupConstructors->id(GroupConstructors->selected());
898   return -1;
899 }
900
901 //=================================================================================
902 // function : keyPressEvent()
903 // purpose  :
904 //=================================================================================
905 void SMESHGUI_TranslationDlg::keyPressEvent( QKeyEvent* e )
906 {
907   QDialog::keyPressEvent( e );
908   if ( e->isAccepted() )
909     return;
910
911   if ( e->key() == Key_F1 )
912     {
913       e->accept();
914       ClickOnHelp();
915     }
916 }