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