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