Salome HOME
Replace oe by ?
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SymmetryDlg.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  SMESH SMESHGUI : GUI for SMESH component
23 //  File   : SMESHGUI_SymmetryDlg.cxx
24 //  Author : Michael ZORIN, Open CASCADE S.A.S.
25 //  SMESH includes
26
27 #include "SMESHGUI_SymmetryDlg.h"
28
29 #include "SMESHGUI.h"
30 #include "SMESHGUI_SpinBox.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_MeshUtils.h"
34 #include "SMESHGUI_IdValidator.h"
35 #include "SMESHGUI_FilterDlg.h"
36 #include "SMESHGUI_MeshEditPreview.h"
37
38 #include <SMESH_Actor.h>
39 #include <SMESH_TypeFilter.hxx>
40 #include <SMESH_LogicalFilter.hxx>
41 #include <SMDS_Mesh.hxx>
42
43 // SALOME GUI includes
44 #include <SUIT_Desktop.h>
45 #include <SUIT_ResourceMgr.h>
46 #include <SUIT_Session.h>
47 #include <SUIT_MessageBox.h>
48 #include <SUIT_OverrideCursor.h>
49
50 #include <LightApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52
53 #include <SVTK_ViewModel.h>
54 #include <SVTK_ViewWindow.h>
55 #include <SALOME_ListIO.hxx>
56
57 // SALOME KERNEL includes
58 #include <SALOMEDSClient_SObject.hxx>
59
60 // OCCT includes
61 #include <TColStd_MapOfInteger.hxx>
62
63 // Qt includes
64 #include <QApplication>
65 #include <QButtonGroup>
66 #include <QGroupBox>
67 #include <QLabel>
68 #include <QLineEdit>
69 #include <QPushButton>
70 #include <QRadioButton>
71 #include <QCheckBox>
72 #include <QHBoxLayout>
73 #include <QVBoxLayout>
74 #include <QGridLayout>
75 #include <QKeyEvent>
76
77 // IDL includes
78 #include <SALOMEconfig.h>
79 #include CORBA_SERVER_HEADER(SMESH_Group)
80 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
81
82 enum { MOVE_ELEMS_BUTTON = 0, COPY_ELEMS_BUTTON, MAKE_MESH_BUTTON }; //!< action type
83
84 #define SPACING 6
85 #define MARGIN  11
86
87 //To disable automatic genericobj management, the following line should be commented.
88 //Otherwise, it should be uncommented. Refer to KERNEL_SRC/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx
89 #define WITHGENERICOBJ
90
91 //=================================================================================
92 // class    : SMESHGUI_SymmetryDlg()
93 // purpose  :
94 //=================================================================================
95
96 SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( SMESHGUI* theModule )
97   : SMESHGUI_PreviewDlg( theModule ),
98     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
99     myFilterDlg(0),
100     mySelectedObject(SMESH::SMESH_IDSource::_nil())
101 {
102   QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_POINT")));
103   QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_AXIS")));
104   QPixmap image2 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SMESH_SYMMETRY_PLANE")));
105   QPixmap image3 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
106
107   setModal(false);
108   setAttribute(Qt::WA_DeleteOnClose, true);
109   setWindowTitle(tr("SMESH_SYMMETRY"));
110   setSizeGripEnabled(true);
111
112   QVBoxLayout* SMESHGUI_SymmetryDlgLayout = new QVBoxLayout(this);
113   SMESHGUI_SymmetryDlgLayout->setSpacing(SPACING);
114   SMESHGUI_SymmetryDlgLayout->setMargin(MARGIN);
115
116   /***************************************************************/
117   ConstructorsBox = new QGroupBox(tr("SMESH_SYMMETRY"), this);
118   GroupConstructors = new QButtonGroup(this);
119   QHBoxLayout* ConstructorsBoxLayout = new QHBoxLayout(ConstructorsBox);
120   ConstructorsBoxLayout->setSpacing(SPACING);
121   ConstructorsBoxLayout->setMargin(MARGIN);
122
123   RadioButton1 = new QRadioButton(ConstructorsBox);
124   RadioButton1->setIcon(image0);
125   RadioButton2 = new QRadioButton(ConstructorsBox);
126   RadioButton2->setIcon(image1);
127   RadioButton3 = new QRadioButton(ConstructorsBox);
128   RadioButton3->setIcon(image2);
129
130   ConstructorsBoxLayout->addWidget(RadioButton1);
131   ConstructorsBoxLayout->addWidget(RadioButton2);
132   ConstructorsBoxLayout->addWidget(RadioButton3);
133   GroupConstructors->addButton(RadioButton1, 0);
134   GroupConstructors->addButton(RadioButton2, 1);
135   GroupConstructors->addButton(RadioButton3, 2);
136
137   /***************************************************************/
138   GroupArguments = new QGroupBox(tr("SMESH_ARGUMENTS"), this);
139   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
140   GroupArgumentsLayout->setSpacing(SPACING);
141   GroupArgumentsLayout->setMargin(MARGIN);
142
143   myIdValidator = new SMESHGUI_IdValidator(this);
144
145   // Controls for elements selection
146   TextLabelElements = new QLabel(tr("SMESH_ID_ELEMENTS"), GroupArguments);
147   SelectElementsButton  = new QPushButton(GroupArguments);
148   SelectElementsButton->setIcon(image3);
149   LineEditElements = new QLineEdit(GroupArguments);
150   LineEditElements->setValidator(myIdValidator);
151   LineEditElements->setMaxLength(-1);
152   myFilterBtn = new QPushButton( tr( "SMESH_BUT_FILTER" ), GroupArguments );
153   connect(myFilterBtn,   SIGNAL(clicked()), this, SLOT(setFilters()));
154
155   // Control for the whole mesh selection
156   CheckBoxMesh = new QCheckBox(tr("SMESH_SELECT_WHOLE_MESH"), GroupArguments);
157
158   // Controls for mirror selection
159   GroupMirror = new QGroupBox(GroupArguments);
160   QGridLayout* GroupMirrorLayout = new QGridLayout(GroupMirror);
161   GroupMirrorLayout->setSpacing(SPACING);
162   GroupMirrorLayout->setMargin(MARGIN);
163
164   TextLabelPoint = new QLabel(tr("SMESH_POINT"), GroupMirror);
165   SelectPointButton  = new QPushButton(GroupMirror);
166   SelectPointButton->setIcon(image3);
167
168   TextLabelX = new QLabel(tr("SMESH_X"), GroupMirror);
169   SpinBox_X = new SMESHGUI_SpinBox(GroupMirror);
170   TextLabelY = new QLabel(tr("SMESH_Y"), GroupMirror);
171   SpinBox_Y = new SMESHGUI_SpinBox(GroupMirror);
172   TextLabelZ = new QLabel(tr("SMESH_Z"), GroupMirror);
173   SpinBox_Z = new SMESHGUI_SpinBox(GroupMirror);
174
175   TextLabelVector = new QLabel(GroupMirror);
176   SelectVectorButton = new QPushButton(GroupMirror);
177   SelectVectorButton->setIcon(image3);
178
179   TextLabelDX = new QLabel(tr("SMESH_DX"), GroupMirror);
180   SpinBox_DX = new SMESHGUI_SpinBox(GroupMirror);
181   TextLabelDY = new QLabel(tr("SMESH_DY"), GroupMirror);
182   SpinBox_DY = new SMESHGUI_SpinBox(GroupMirror);
183   TextLabelDZ = new QLabel(tr("SMESH_DZ"), GroupMirror);
184   SpinBox_DZ = new SMESHGUI_SpinBox(GroupMirror);
185
186   GroupMirrorLayout->addWidget(TextLabelPoint,     0, 0);
187   GroupMirrorLayout->addWidget(SelectPointButton,  0, 1);
188   GroupMirrorLayout->addWidget(TextLabelX,         0, 2);
189   GroupMirrorLayout->addWidget(SpinBox_X,          0, 3);
190   GroupMirrorLayout->addWidget(TextLabelY,         0, 4);
191   GroupMirrorLayout->addWidget(SpinBox_Y,          0, 5);
192   GroupMirrorLayout->addWidget(TextLabelZ,         0, 6);
193   GroupMirrorLayout->addWidget(SpinBox_Z,          0, 7);
194   GroupMirrorLayout->addWidget(TextLabelVector,    1, 0);
195   GroupMirrorLayout->addWidget(SelectVectorButton, 1, 1);
196   GroupMirrorLayout->addWidget(TextLabelDX,        1, 2);
197   GroupMirrorLayout->addWidget(SpinBox_DX,         1, 3);
198   GroupMirrorLayout->addWidget(TextLabelDY,        1, 4);
199   GroupMirrorLayout->addWidget(SpinBox_DY,         1, 5);
200   GroupMirrorLayout->addWidget(TextLabelDZ,        1, 6);
201   GroupMirrorLayout->addWidget(SpinBox_DZ,         1, 7);
202
203   // switch of action type
204   ActionBox = new QGroupBox(GroupArguments);
205   ActionGroup = new QButtonGroup(GroupArguments);
206   QVBoxLayout* ActionBoxLayout = new QVBoxLayout(ActionBox);
207   ActionBoxLayout->addSpacing(SPACING);
208   ActionBoxLayout->setMargin(MARGIN);
209
210   QRadioButton* aMoveElements = new QRadioButton(tr("SMESH_MOVE_ELEMENTS"), ActionBox);
211   QRadioButton* aCopyElements = new QRadioButton(tr("SMESH_COPY_ELEMENTS"), ActionBox);
212   QRadioButton* aCreateMesh   = new QRadioButton(tr("SMESH_CREATE_MESH"),   ActionBox);
213
214   ActionBoxLayout->addWidget(aMoveElements);
215   ActionBoxLayout->addWidget(aCopyElements);
216   ActionBoxLayout->addWidget(aCreateMesh);
217   ActionGroup->addButton(aMoveElements, MOVE_ELEMS_BUTTON);
218   ActionGroup->addButton(aCopyElements, COPY_ELEMS_BUTTON);
219   ActionGroup->addButton(aCreateMesh,   MAKE_MESH_BUTTON);
220
221   // CheckBox for groups generation
222   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
223   MakeGroupsCheck->setChecked(false);
224
225   // Name of a mesh to create
226   LineEditNewMesh = new QLineEdit(GroupArguments);
227
228
229   //Preview check box
230   myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
231
232   // layout
233   GroupArgumentsLayout->addWidget(TextLabelElements,    0, 0);
234   GroupArgumentsLayout->addWidget(SelectElementsButton, 0, 1);
235   GroupArgumentsLayout->addWidget(LineEditElements,     0, 2, 1, 1);
236   GroupArgumentsLayout->addWidget(myFilterBtn,          0, 3);
237   GroupArgumentsLayout->addWidget(CheckBoxMesh,         1, 0, 1, 4);
238   GroupArgumentsLayout->addWidget(GroupMirror,          2, 0, 1, 4);
239   GroupArgumentsLayout->addWidget(ActionBox,            3, 0, 3, 3);
240   GroupArgumentsLayout->addWidget(MakeGroupsCheck,      4, 3);
241   GroupArgumentsLayout->addWidget(LineEditNewMesh,      5, 3);
242   GroupArgumentsLayout->addWidget(myPreviewCheckBox,    6, 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_SymmetryDlgLayout->addWidget(ConstructorsBox);
270   SMESHGUI_SymmetryDlgLayout->addWidget(GroupArguments);
271   SMESHGUI_SymmetryDlgLayout->addWidget(GroupButtons);
272
273   /* Initialisations */
274   SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
275   SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
276   SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
277   SpinBox_DX->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
278   SpinBox_DY->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
279   SpinBox_DZ->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 (MESHorSUBMESH);
289   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (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 = "symmetry_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(ClickOnCancel()));
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(SelectPointButton,    SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
311   connect(SelectVectorButton,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
312
313   connect(SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
314   connect(SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
315   connect(SpinBox_DZ, SIGNAL(valueChanged(double)), this, SLOT(onVectorChanged()));
316
317   connect(mySMESHGUI,     SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
318   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),      this, SLOT(SelectionIntoArgument()));
319   /* to close dialog if study change */
320   connect(mySMESHGUI,       SIGNAL(SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
321   connect(LineEditElements, SIGNAL(textChanged(const QString&)),   SLOT(onTextChange(const QString&)));
322   connect(CheckBoxMesh,     SIGNAL(toggled(bool)),                 SLOT(onSelectMesh(bool)));
323   connect(ActionGroup,      SIGNAL(buttonClicked(int)),            SLOT(onActionClicked(int)));
324
325   connect(SpinBox_X,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
326   connect(SpinBox_Y,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
327   connect(SpinBox_Z,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
328   connect(SpinBox_DX,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
329   connect(SpinBox_DY,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
330   connect(SpinBox_DZ,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
331
332   //To Connect preview check box
333   connectPreviewControl();
334
335   ConstructorsClicked(0);
336   SelectionIntoArgument();
337   onActionClicked(MOVE_ELEMS_BUTTON);
338 }
339
340 //=================================================================================
341 // function : ~SMESHGUI_SymmetryDlg()
342 // purpose  : Destroys the object and frees any allocated resources
343 //=================================================================================
344 SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg()
345 {
346   if ( myFilterDlg != 0 ) {
347     myFilterDlg->setParent( 0 );
348     delete myFilterDlg;
349   }
350 }
351
352 //=================================================================================
353 // function : Init()
354 // purpose  :
355 //=================================================================================
356 void SMESHGUI_SymmetryDlg::Init (bool ResetControls)
357 {
358   myBusy = false;
359
360   myEditCurrentArgument = 0;
361   LineEditElements->clear();
362   myElementsId = "";
363   myNbOkElements = 0;
364
365   buttonOk->setEnabled(false);
366   buttonApply->setEnabled(false);
367
368   myActor = 0;
369   myMesh = SMESH::SMESH_Mesh::_nil();
370
371   if (ResetControls) {
372     SpinBox_X->SetValue(0.0);
373     SpinBox_Y->SetValue(0.0);
374     SpinBox_Z->SetValue(0.0);
375     SpinBox_DX->SetValue(0.0);
376     SpinBox_DY->SetValue(0.0);
377     SpinBox_DZ->SetValue(0.0);
378
379     ActionGroup->button( MOVE_ELEMS_BUTTON )->setChecked(true);
380     CheckBoxMesh->setChecked(false);
381     myPreviewCheckBox->setChecked(false);
382     onDisplaySimulation(false);
383
384 //     MakeGroupsCheck->setChecked(false);
385 //     MakeGroupsCheck->setEnabled(false);
386     onSelectMesh(false);
387   }
388 }
389
390 //=================================================================================
391 // function : ConstructorsClicked()
392 // purpose  : Radio button management
393 //=================================================================================
394 void SMESHGUI_SymmetryDlg::ConstructorsClicked (int constructorId)
395 {
396   disconnect(mySelectionMgr, 0, this, 0);
397
398   if (constructorId != 0 && !TextLabelVector->isVisible()) {
399     TextLabelVector->show();
400     SelectVectorButton->show();
401     TextLabelDX->show();
402     SpinBox_DX->show();
403     TextLabelDY->show();
404     SpinBox_DY->show();
405     TextLabelDZ->show();
406     SpinBox_DZ->show();
407   }
408
409   switch (constructorId) {
410   case 0:
411     {
412       GroupMirror->setTitle(tr("SMESH_POINT"));
413
414       TextLabelVector->hide();
415       SelectVectorButton->hide();
416       TextLabelDX->hide();
417       SpinBox_DX->hide();
418       TextLabelDY->hide();
419       SpinBox_DY->hide();
420       TextLabelDZ->hide();
421       SpinBox_DZ->hide();
422       break;
423     }
424   case 1:
425     {
426       GroupMirror->setTitle(tr("SMESH_AXIS"));
427       TextLabelVector->setText(tr("SMESH_VECTOR"));
428       break;
429     }
430   case 2:
431     {
432       GroupMirror->setTitle(tr("SMESH_PLANE"));
433       TextLabelVector->setText(tr("SMESH_NORMAL"));
434       break;
435     }
436   }
437
438   if (myEditCurrentArgument != (QWidget*)LineEditElements) {
439     SMESH::SetPointRepresentation(false);
440     if (!CheckBoxMesh->isChecked())
441       {
442         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
443           aViewWindow->SetSelectionMode(CellSelection);
444       }
445   }
446
447   myEditCurrentArgument = (QWidget*)LineEditElements;
448   LineEditElements->setFocus();
449
450   if (CheckBoxMesh->isChecked())
451     onSelectMesh(true);
452
453   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
454
455   onDisplaySimulation(true);
456
457   QApplication::instance()->processEvents();
458   updateGeometry();
459   resize(100,100);
460 }
461
462 //=================================================================================
463 // function : ClickOnApply()
464 // purpose  :
465 //=================================================================================
466 bool SMESHGUI_SymmetryDlg::ClickOnApply()
467 {
468   if (mySMESHGUI->isActiveStudyLocked())
469     return false;
470
471   if( !isValid() )
472     return false;
473
474   if (myNbOkElements && IsMirrorOk()) {
475     QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
476
477     SMESH::long_array_var anElementsId = new SMESH::long_array;
478
479     anElementsId->length(aListElementsId.count());
480     for (int i = 0; i < aListElementsId.count(); i++)
481       anElementsId[i] = aListElementsId[i].toInt();
482
483     SMESH::AxisStruct aMirror;
484     SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
485     getMirror(aMirror,aMirrorType);
486
487     QStringList aParameters;
488     aParameters << SpinBox_X->text();
489     aParameters << SpinBox_Y->text();
490     aParameters << SpinBox_Z->text();
491     aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DX->text() );
492     aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DY->text() );
493     aParameters << ( GetConstructorId() == 0 ? QString::number(0) : SpinBox_DZ->text() );
494
495     int actionButton = ActionGroup->checkedId();
496     bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
497     QStringList anEntryList;
498     try {
499       SUIT_OverrideCursor aWaitCursor;
500       SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
501
502       switch ( actionButton ) {
503       case MOVE_ELEMS_BUTTON: {
504         if(CheckBoxMesh->isChecked())
505           aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, false );
506         else
507           aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false );
508
509         if( !myMesh->_is_nil())
510           myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
511         break;
512       }
513       case COPY_ELEMS_BUTTON: {
514         SMESH::ListOfGroups_var groups;
515         if ( makeGroups ) {
516           if(CheckBoxMesh->isChecked())
517             groups = aMeshEditor->MirrorObjectMakeGroups(mySelectedObject, aMirror, aMirrorType);
518           else
519             groups = aMeshEditor->MirrorMakeGroups(anElementsId, aMirror, aMirrorType);
520         }
521         else {
522           if(CheckBoxMesh->isChecked())
523             aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, true);
524           else
525             aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, true);
526         }
527         if( !myMesh->_is_nil())
528           myMesh->SetParameters( aParameters.join(":").toLatin1().constData() );
529         break;
530         }
531       case MAKE_MESH_BUTTON: {
532         SMESH::SMESH_Mesh_var mesh;
533         if (CheckBoxMesh->isChecked())
534           mesh = aMeshEditor->MirrorObjectMakeMesh(mySelectedObject, aMirror, aMirrorType, makeGroups,
535                                                    LineEditNewMesh->text().toLatin1().data());
536         else
537           mesh = aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups,
538                                              LineEditNewMesh->text().toLatin1().data());
539         if (!mesh->_is_nil()) {
540           mesh->SetParameters(aParameters.join(":").toLatin1().constData());
541           if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
542             anEntryList.append( aSObject->GetID().c_str() );
543 #ifdef WITHGENERICOBJ
544           // obj has been published in study. Its refcount has been incremented.
545           // It is safe to decrement its refcount
546           // so that it will be destroyed when the entry in study will be removed
547           mesh->UnRegister();
548 #endif
549         }
550         break;
551       }
552       }
553     } catch (...) {
554     }
555
556     SMESH::UpdateView();
557     if ( ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) ||
558          actionButton == MAKE_MESH_BUTTON ) {
559       mySMESHGUI->updateObjBrowser(true); // new groups may appear
560       if( LightApp_Application* anApp =
561           dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
562         anApp->browseObjects( anEntryList, isApplyAndClose() );
563     }
564     Init(false);
565     ConstructorsClicked(GetConstructorId());
566     mySelectedObject = SMESH::SMESH_IDSource::_nil();
567     SelectionIntoArgument();
568
569     SMESHGUI::Modified();
570   }
571   return true;
572 }
573
574 //=================================================================================
575 // function : ClickOnOk()
576 // purpose  :
577 //=================================================================================
578 void SMESHGUI_SymmetryDlg::ClickOnOk()
579 {
580   setIsApplyAndClose( true );
581   if( ClickOnApply() )
582     ClickOnCancel();
583 }
584
585 //=================================================================================
586 // function : ClickOnCancel()
587 // purpose  :
588 //=================================================================================
589 void SMESHGUI_SymmetryDlg::ClickOnCancel()
590 {
591   disconnect(mySelectionMgr, 0, this, 0);
592   mySelectionMgr->clearFilters();
593   //mySelectionMgr->clearSelected();
594   if (SMESH::GetCurrentVtkView()) {
595     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
596     SMESH::SetPointRepresentation(false);
597   }
598   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
599     aViewWindow->SetSelectionMode(ActorSelection);
600   mySMESHGUI->ResetState();
601   reject();
602 }
603
604 //=================================================================================
605 // function : ClickOnHelp()
606 // purpose  :
607 //=================================================================================
608 void SMESHGUI_SymmetryDlg::ClickOnHelp()
609 {
610   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
611   if (app)
612     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
613   else {
614     QString platform;
615 #ifdef WIN32
616     platform = "winapplication";
617 #else
618     platform = "application";
619 #endif
620     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
621                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
622                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
623                                                                  platform)).
624                              arg(myHelpFileName));
625   }
626 }
627
628 //=======================================================================
629 // function : onTextChange()
630 // purpose  :
631 //=======================================================================
632 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
633 {
634   QLineEdit* send = (QLineEdit*)sender();
635
636   if (myBusy) return;
637   myBusy = true;
638
639   if (send == LineEditElements)
640     myNbOkElements = 0;
641
642   buttonOk->setEnabled(false);
643   buttonApply->setEnabled(false);
644
645   // hilight entered elements
646   SMDS_Mesh* aMesh = 0;
647   if (myActor)
648     aMesh = myActor->GetObject()->GetMesh();
649
650   if (aMesh) {
651     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
652
653     TColStd_MapOfInteger newIndices;
654
655     QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
656
657     if (send == LineEditElements) {
658       for (int i = 0; i < aListId.count(); i++) {
659         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
660         if (e)
661           newIndices.Add(e->GetID());
662         myNbOkElements++;
663       }
664
665       mySelector->AddOrRemoveIndex( anIO, newIndices, false );
666       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
667         aViewWindow->highlight( anIO, true, true );
668
669       myElementsId = theNewText;
670     }
671   }
672
673   if (myNbOkElements &&  IsMirrorOk()) {
674     buttonOk->setEnabled(true);
675     buttonApply->setEnabled(true);
676   }
677
678   myBusy = false;
679 }
680
681 //=================================================================================
682 // function : SelectionIntoArgument()
683 // purpose  : Called when selection as changed or other case
684 //=================================================================================
685 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
686 {
687   if (myBusy) return;
688
689   // clear
690   myActor = 0;
691   QString aString = "";
692
693   myBusy = true;
694   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
695     LineEditElements->setText(aString);
696     myNbOkElements = 0;
697     buttonOk->setEnabled(false);
698     buttonApply->setEnabled(false);
699   }
700   myBusy = false;
701
702   if (!GroupButtons->isEnabled()) // inactive
703     return;
704
705   // get selected mesh
706   SALOME_ListIO aList;
707   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
708
709   int nbSel = aList.Extent();
710   if (nbSel != 1)
711     return;
712
713   Handle(SALOME_InteractiveObject) IO = aList.First();
714   myMesh = SMESH::GetMeshByIO(IO);
715   if(myMesh->_is_nil())
716     return;
717
718   myActor = SMESH::FindActorByObject(myMesh);
719   if (!myActor)
720     myActor = SMESH::FindActorByEntry(IO->getEntry());
721   if (!myActor && !CheckBoxMesh->isChecked())
722     return;
723
724   int aNbUnits = 0;
725
726   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
727     myElementsId = "";
728
729     // MakeGroups is available if there are groups and "Copy"
730     if ( myMesh->NbGroups() == 0 ) {
731       MakeGroupsCheck->setChecked(false);
732       MakeGroupsCheck->setEnabled(false);
733     }
734     else if ( ActionGroup->checkedId() != MOVE_ELEMS_BUTTON ) {
735       MakeGroupsCheck->setEnabled(true);
736     }
737     if (CheckBoxMesh->isChecked()) {
738       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
739
740       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH
741         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
742       }
743       else
744         return;
745       // get IDs from mesh
746       /*
747         SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
748         if (!aSMDSMesh)
749           return;
750
751         for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
752           const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
753           if (e) {
754             myElementsId += QString(" %1").arg(i);
755             aNbUnits++;
756           }
757         }
758       } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
759         // get submesh
760         SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
761
762         // get IDs from submesh
763         /*
764         SMESH::long_array_var anElementsIds = new SMESH::long_array;
765         anElementsIds = aSubMesh->GetElementsId();
766         for (int i = 0; i < anElementsIds->length(); i++) {
767           myElementsId += QString(" %1").arg(anElementsIds[i]);
768         }
769         aNbUnits = anElementsIds->length();
770       } else { // GROUP
771         // get smesh group
772         SMESH::SMESH_GroupBase_var aGroup =
773           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
774         if (aGroup->_is_nil())
775           return;
776
777         // get IDs from smesh group
778         SMESH::long_array_var anElementsIds = new SMESH::long_array;
779         anElementsIds = aGroup->GetListOfID();
780         for (int i = 0; i < anElementsIds->length(); i++) {
781           myElementsId += QString(" %1").arg(anElementsIds[i]);
782         }
783         aNbUnits = anElementsIds->length();
784       }
785       */
786     } else {
787       aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, IO, aString);
788       myElementsId = aString;
789       if (aNbUnits < 1)
790         return;
791     }
792
793     myNbOkElements = true;
794   } else {
795     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
796     if (aNbUnits != 1)
797       return;
798
799     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
800     if (!aMesh)
801       return;
802
803     const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
804     if (!n)
805       return;
806
807     double x = n->X();
808     double y = n->Y();
809     double z = n->Z();
810
811     if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
812       SpinBox_X->SetValue(x);
813       SpinBox_Y->SetValue(y);
814       SpinBox_Z->SetValue(z);
815     } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
816       SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
817       SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
818       SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
819     }
820   }
821
822   myBusy = true;
823   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
824     LineEditElements->setText(aString);
825     LineEditElements->repaint();
826     LineEditElements->setEnabled(false); // to update lineedit IPAL 19809
827     LineEditElements->setEnabled(true);
828     setNewMeshName();
829   }
830   myBusy = false;
831
832   // OK
833   if (myNbOkElements && IsMirrorOk()) {
834     buttonOk->setEnabled(true);
835     buttonApply->setEnabled(true);
836   }
837   onDisplaySimulation(true);
838 }
839
840 //=================================================================================
841 // function : SetEditCurrentArgument()
842 // purpose  :
843 //=================================================================================
844 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
845 {
846   QPushButton* send = (QPushButton*)sender();
847
848   disconnect(mySelectionMgr, 0, this, 0);
849   mySelectionMgr->clearSelected();
850   mySelectionMgr->clearFilters();
851
852   if (send == SelectElementsButton) {
853     myEditCurrentArgument = (QWidget*)LineEditElements;
854     SMESH::SetPointRepresentation(false);
855     if (CheckBoxMesh->isChecked()) {
856       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
857         aViewWindow->SetSelectionMode(ActorSelection);
858       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
859     } else {
860       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
861         aViewWindow->SetSelectionMode(CellSelection);
862     }
863   } else if (send == SelectPointButton) {
864     myEditCurrentArgument = (QWidget*)SpinBox_X;
865     SMESH::SetPointRepresentation(true);
866     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
867       aViewWindow->SetSelectionMode(NodeSelection);
868   } else if (send == SelectVectorButton) {
869     myEditCurrentArgument = (QWidget*)SpinBox_DX;
870     SMESH::SetPointRepresentation(true);
871
872     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
873       aViewWindow->SetSelectionMode(NodeSelection);
874   } else {
875   }
876
877   myEditCurrentArgument->setFocus();
878   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
879   SelectionIntoArgument();
880 }
881
882 //=================================================================================
883 // function : DeactivateActiveDialog()
884 // purpose  :
885 //=================================================================================
886 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
887 {
888   if (ConstructorsBox->isEnabled()) {
889     ConstructorsBox->setEnabled(false);
890     GroupArguments->setEnabled(false);
891     GroupButtons->setEnabled(false);
892     mySMESHGUI->ResetState();
893     mySMESHGUI->SetActiveDialogBox(0);
894   }
895 }
896
897 //=================================================================================
898 // function : ActivateThisDialog()
899 // purpose  :
900 //=================================================================================
901 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
902 {
903   /* Emit a signal to deactivate the active dialog */
904   mySMESHGUI->EmitSignalDeactivateDialog();
905   ConstructorsBox->setEnabled(true);
906   GroupArguments->setEnabled(true);
907   GroupButtons->setEnabled(true);
908
909   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
910
911   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
912     aViewWindow->SetSelectionMode(CellSelection);
913   SelectionIntoArgument();
914 }
915
916 //=================================================================================
917 // function : enterEvent()
918 // purpose  :
919 //=================================================================================
920 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
921 {
922   if (!ConstructorsBox->isEnabled())
923     ActivateThisDialog();
924 }
925
926 //=================================================================================
927 // function : closeEvent()
928 // purpose  :
929 //=================================================================================
930 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
931 {
932   /* same than click on cancel button */
933   ClickOnCancel();
934 }
935
936 //=======================================================================
937 // function : hideEvent()
938 // purpose  : caused by ESC key
939 //=======================================================================
940 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
941 {
942   if (!isMinimized())
943     ClickOnCancel();
944 }
945
946 //=======================================================================
947 //function : onSelectMesh
948 //purpose  :
949 //=======================================================================
950 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
951 {
952   if (toSelectMesh)
953     TextLabelElements->setText(tr("SMESH_NAME"));
954   else
955     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
956   myFilterBtn->setEnabled(!toSelectMesh);
957
958   if (myEditCurrentArgument != LineEditElements) {
959     LineEditElements->clear();
960     return;
961   }
962
963   mySelectionMgr->clearFilters();
964   SMESH::SetPointRepresentation(false);
965
966   if (toSelectMesh) {
967     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
968       aViewWindow->SetSelectionMode(ActorSelection);
969     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
970     LineEditElements->setReadOnly(true);
971     LineEditElements->setValidator(0);
972   } else {
973     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
974       aViewWindow->SetSelectionMode(CellSelection);
975     LineEditElements->setReadOnly(false);
976     LineEditElements->setValidator(myIdValidator);
977     onTextChange(LineEditElements->text());
978     hidePreview();
979   }
980
981   SelectionIntoArgument();
982 }
983
984 //=================================================================================
985 // function : GetConstructorId()
986 // purpose  :
987 //=================================================================================
988 int SMESHGUI_SymmetryDlg::GetConstructorId()
989 {
990   return GroupConstructors->checkedId();
991 }
992
993 //=================================================================================
994 // function : IsMirrorOk()
995 // purpose  :
996 //=================================================================================
997 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
998 {
999   bool isOk = true;
1000
1001   if (GetConstructorId() != 0)
1002     isOk = (SpinBox_DX->GetValue() != 0 ||
1003             SpinBox_DY->GetValue() != 0 ||
1004             SpinBox_DZ->GetValue() != 0);
1005
1006   return isOk;
1007 }
1008
1009 //=================================================================================
1010 // function : onVectorChanged()
1011 // purpose  :
1012 //=================================================================================
1013 void SMESHGUI_SymmetryDlg::onVectorChanged()
1014 {
1015   if (IsMirrorOk()) {
1016     buttonOk->setEnabled(true);
1017     buttonApply->setEnabled(true);
1018   } else {
1019     buttonOk->setEnabled(false);
1020     buttonApply->setEnabled(false);
1021   }
1022 }
1023
1024 //=======================================================================
1025 //function : onActionClicked
1026 //purpose  : slot called when an action type changed
1027 //=======================================================================
1028
1029 void SMESHGUI_SymmetryDlg::onActionClicked(int button)
1030 {
1031   switch ( button ) {
1032   case MOVE_ELEMS_BUTTON:
1033     MakeGroupsCheck->setEnabled(false);
1034     LineEditNewMesh->setEnabled(false);
1035     break;
1036   case COPY_ELEMS_BUTTON:
1037     LineEditNewMesh->setEnabled(false);
1038     MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
1039     if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
1040       MakeGroupsCheck->setEnabled(true);
1041     else
1042       MakeGroupsCheck->setEnabled(false);
1043     break;
1044   case MAKE_MESH_BUTTON:
1045     LineEditNewMesh->setEnabled(true);
1046     MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
1047     if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
1048       MakeGroupsCheck->setEnabled(true);
1049     else
1050       MakeGroupsCheck->setEnabled(false);
1051     break;
1052   }
1053   setNewMeshName();
1054   toDisplaySimulation();
1055 }
1056
1057 //=======================================================================
1058 //function : setNewMeshName
1059 //purpose  : update contents of LineEditNewMesh
1060 //=======================================================================
1061
1062 void SMESHGUI_SymmetryDlg::setNewMeshName()
1063 {
1064   LineEditNewMesh->setText("");
1065   if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) {
1066     QString name;
1067     if ( CheckBoxMesh->isChecked() ) {
1068       name = LineEditElements->text();
1069     }
1070     else {
1071       _PTR(SObject) meshSO = SMESH::FindSObject( myMesh );
1072       name = meshSO->GetName().c_str();
1073     }
1074     if ( !name.isEmpty() )
1075       LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "mirrored"));
1076   }
1077 }
1078
1079 //=================================================================================
1080 // function : keyPressEvent()
1081 // purpose  :
1082 //=================================================================================
1083 void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e )
1084 {
1085   QDialog::keyPressEvent( e );
1086   if ( e->isAccepted() )
1087     return;
1088
1089   if ( e->key() == Qt::Key_F1 ) {
1090     e->accept();
1091     ClickOnHelp();
1092   }
1093 }
1094
1095 //=================================================================================
1096 // function : setFilters()
1097 // purpose  : SLOT. Called when "Filter" button pressed.
1098 //=================================================================================
1099 void SMESHGUI_SymmetryDlg::setFilters()
1100 {
1101   if(myMesh->_is_nil()) {
1102     SUIT_MessageBox::critical(this,
1103                               tr("SMESH_ERROR"),
1104                               tr("NO_MESH_SELECTED"));
1105    return;
1106   }
1107   if ( !myFilterDlg )
1108     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
1109
1110   myFilterDlg->SetSelection();
1111   myFilterDlg->SetMesh( myMesh );
1112   myFilterDlg->SetSourceWg( LineEditElements );
1113
1114   myFilterDlg->show();
1115 }
1116
1117 //=================================================================================
1118 // function : isValid
1119 // purpose  :
1120 //=================================================================================
1121 bool SMESHGUI_SymmetryDlg::isValid()
1122 {
1123   bool ok = true;
1124   QString msg;
1125
1126   ok = SpinBox_X->isValid( msg, true ) && ok;
1127   ok = SpinBox_Y->isValid( msg, true ) && ok;
1128   ok = SpinBox_Z->isValid( msg, true ) && ok;
1129   if (GetConstructorId() != 0) {
1130     ok = SpinBox_DX->isValid( msg, true ) && ok;
1131     ok = SpinBox_DY->isValid( msg, true ) && ok;
1132     ok = SpinBox_DZ->isValid( msg, true ) && ok;
1133   }
1134
1135   if( !ok ) {
1136     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1137     if ( !msg.isEmpty() )
1138       str += "\n" + msg;
1139     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1140     return false;
1141   }
1142   return true;
1143 }
1144
1145 //=================================================================================
1146 // function : onDisplaySimulation
1147 // purpose  : Show/Hide preview
1148 //=================================================================================
1149 void SMESHGUI_SymmetryDlg::onDisplaySimulation( bool toDisplayPreview ) {
1150   if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
1151     if ( myNbOkElements && isValid() && IsMirrorOk() ) {
1152       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);      
1153       SMESH::long_array_var anElementsId = new SMESH::long_array;
1154
1155       anElementsId->length(aListElementsId.count());
1156       for (int i = 0; i < aListElementsId.count(); i++)
1157         anElementsId[i] = aListElementsId[i].toInt();
1158
1159       SMESH::AxisStruct aMirror;
1160       SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
1161       
1162       getMirror(aMirror,aMirrorType);
1163
1164       try {
1165         bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON ||
1166                       ActionGroup->checkedId() == MAKE_MESH_BUTTON );
1167         SUIT_OverrideCursor aWaitCursor;
1168         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1169         if(CheckBoxMesh->isChecked())
1170           aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, copy );
1171         else
1172           aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, copy );
1173         
1174         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1175         mySimulation->SetData(aMeshPreviewStruct._retn());
1176       } catch (...) {
1177         hidePreview();
1178       }
1179     } else {
1180       hidePreview();
1181     } 
1182   } else {
1183     hidePreview();
1184   }
1185 }
1186
1187 //=================================================================================
1188 // function : getMirror
1189 // purpose  : return mirror parameters
1190 //=================================================================================
1191 void SMESHGUI_SymmetryDlg::getMirror(SMESH::AxisStruct& theMirror, SMESH::SMESH_MeshEditor::MirrorType& theMirrorType) {
1192   theMirror.x =  SpinBox_X->GetValue();
1193   theMirror.y =  SpinBox_Y->GetValue();
1194   theMirror.z =  SpinBox_Z->GetValue();
1195   if (GetConstructorId() == 0) {
1196     theMirror.vx = theMirror.vy = theMirror.vz = 0;
1197   } else {
1198     theMirror.vx = SpinBox_DX->GetValue();
1199     theMirror.vy = SpinBox_DY->GetValue();
1200     theMirror.vz = SpinBox_DZ->GetValue();
1201   }
1202   if (GetConstructorId() == 0)
1203     theMirrorType = SMESH::SMESH_MeshEditor::POINT;
1204   if (GetConstructorId() == 1)
1205     theMirrorType = SMESH::SMESH_MeshEditor::AXIS;
1206   if (GetConstructorId() == 2)
1207     theMirrorType = SMESH::SMESH_MeshEditor::PLANE;
1208 }