Salome HOME
Merge from V6_main 13/12/2012
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_SymmetryDlg.cxx
1 // Copyright (C) 2007-2012  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 (SMESH::MESHorSUBMESH);
288   SMESH_TypeFilter* aSmeshGroupFilter    = new SMESH_TypeFilter (SMESH::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       myMesh->SetParameters(aParameters.join(":").toLatin1().constData());
502
503       switch ( actionButton ) {
504       case MOVE_ELEMS_BUTTON: {
505         if(CheckBoxMesh->isChecked())
506           aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, false );
507         else
508           aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, false );
509
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         break;
527         }
528       case MAKE_MESH_BUTTON: {
529         SMESH::SMESH_Mesh_var mesh;
530         if (CheckBoxMesh->isChecked())
531           mesh = aMeshEditor->MirrorObjectMakeMesh(mySelectedObject, aMirror, aMirrorType, makeGroups,
532                                                    LineEditNewMesh->text().toLatin1().data());
533         else
534           mesh = aMeshEditor->MirrorMakeMesh(anElementsId, aMirror, aMirrorType, makeGroups,
535                                              LineEditNewMesh->text().toLatin1().data());
536           if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( mesh ) )
537             anEntryList.append( aSObject->GetID().c_str() );
538 #ifdef WITHGENERICOBJ
539           // obj has been published in study. Its refcount has been incremented.
540           // It is safe to decrement its refcount
541           // so that it will be destroyed when the entry in study will be removed
542           mesh->UnRegister();
543 #endif
544         }
545         break;
546       }
547     } catch (...) {
548     }
549
550     SMESH::UpdateView();
551     if ( ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() ) ||
552          actionButton == MAKE_MESH_BUTTON ) {
553       mySMESHGUI->updateObjBrowser(true); // new groups may appear
554       if( LightApp_Application* anApp =
555           dynamic_cast<LightApp_Application*>( SUIT_Session::session()->activeApplication() ) )
556         anApp->browseObjects( anEntryList, isApplyAndClose() );
557     }
558     Init(false);
559     ConstructorsClicked(GetConstructorId());
560     mySelectedObject = SMESH::SMESH_IDSource::_nil();
561     SelectionIntoArgument();
562
563     SMESHGUI::Modified();
564   }
565   return true;
566 }
567
568 //=================================================================================
569 // function : ClickOnOk()
570 // purpose  :
571 //=================================================================================
572 void SMESHGUI_SymmetryDlg::ClickOnOk()
573 {
574   setIsApplyAndClose( true );
575   if( ClickOnApply() )
576     ClickOnCancel();
577 }
578
579 //=================================================================================
580 // function : ClickOnCancel()
581 // purpose  :
582 //=================================================================================
583 void SMESHGUI_SymmetryDlg::ClickOnCancel()
584 {
585   disconnect(mySelectionMgr, 0, this, 0);
586   mySelectionMgr->clearFilters();
587   //mySelectionMgr->clearSelected();
588   if (SMESH::GetCurrentVtkView()) {
589     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
590     SMESH::SetPointRepresentation(false);
591   }
592   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
593     aViewWindow->SetSelectionMode(ActorSelection);
594   mySMESHGUI->ResetState();
595   reject();
596 }
597
598 //=================================================================================
599 // function : ClickOnHelp()
600 // purpose  :
601 //=================================================================================
602 void SMESHGUI_SymmetryDlg::ClickOnHelp()
603 {
604   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
605   if (app)
606     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
607   else {
608     QString platform;
609 #ifdef WIN32
610     platform = "winapplication";
611 #else
612     platform = "application";
613 #endif
614     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
615                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
616                              arg(app->resourceMgr()->stringValue("ExternalBrowser",
617                                                                  platform)).
618                              arg(myHelpFileName));
619   }
620 }
621
622 //=======================================================================
623 // function : onTextChange()
624 // purpose  :
625 //=======================================================================
626 void SMESHGUI_SymmetryDlg::onTextChange (const QString& theNewText)
627 {
628   QLineEdit* send = (QLineEdit*)sender();
629
630   if (myBusy) return;
631   myBusy = true;
632
633   if (send == LineEditElements)
634     myNbOkElements = 0;
635
636   buttonOk->setEnabled(false);
637   buttonApply->setEnabled(false);
638
639   // hilight entered elements
640   SMDS_Mesh* aMesh = 0;
641   if (myActor)
642     aMesh = myActor->GetObject()->GetMesh();
643
644   if (aMesh) {
645     Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
646
647     TColStd_MapOfInteger newIndices;
648
649     QStringList aListId = theNewText.split(" ", QString::SkipEmptyParts);
650
651     if (send == LineEditElements) {
652       for (int i = 0; i < aListId.count(); i++) {
653         const SMDS_MeshElement * e = aMesh->FindElement(aListId[ i ].toInt());
654         if (e)
655           newIndices.Add(e->GetID());
656         myNbOkElements++;
657       }
658
659       mySelector->AddOrRemoveIndex( anIO, newIndices, false );
660       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
661         aViewWindow->highlight( anIO, true, true );
662
663       myElementsId = theNewText;
664     }
665   }
666
667   if (myNbOkElements &&  IsMirrorOk()) {
668     buttonOk->setEnabled(true);
669     buttonApply->setEnabled(true);
670   }
671
672   myBusy = false;
673 }
674
675 //=================================================================================
676 // function : SelectionIntoArgument()
677 // purpose  : Called when selection as changed or other case
678 //=================================================================================
679 void SMESHGUI_SymmetryDlg::SelectionIntoArgument()
680 {
681   if (myBusy) return;
682
683   // clear
684   myActor = 0;
685   QString aString = "";
686
687   myBusy = true;
688   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
689     LineEditElements->setText(aString);
690     myNbOkElements = 0;
691     buttonOk->setEnabled(false);
692     buttonApply->setEnabled(false);
693   }
694   myBusy = false;
695
696   if (!GroupButtons->isEnabled()) // inactive
697     return;
698
699   // get selected mesh
700   SALOME_ListIO aList;
701   mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
702
703   int nbSel = aList.Extent();
704   if (nbSel != 1)
705     return;
706
707   Handle(SALOME_InteractiveObject) IO = aList.First();
708   myMesh = SMESH::GetMeshByIO(IO);
709   if(myMesh->_is_nil())
710     return;
711
712   myActor = SMESH::FindActorByObject(myMesh);
713   if (!myActor)
714     myActor = SMESH::FindActorByEntry(IO->getEntry());
715   if (!myActor && !CheckBoxMesh->isChecked())
716     return;
717
718   int aNbUnits = 0;
719
720   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
721     myElementsId = "";
722
723     // MakeGroups is available if there are groups and "Copy"
724     if ( myMesh->NbGroups() == 0 ) {
725       MakeGroupsCheck->setChecked(false);
726       MakeGroupsCheck->setEnabled(false);
727     }
728     else if ( ActionGroup->checkedId() != MOVE_ELEMS_BUTTON ) {
729       MakeGroupsCheck->setEnabled(true);
730     }
731     if (CheckBoxMesh->isChecked()) {
732       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
733
734       if (!SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO)->_is_nil()) { //MESH
735         mySelectedObject = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
736       }
737       else
738         return;
739       // get IDs from mesh
740       /*
741         SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh();
742         if (!aSMDSMesh)
743           return;
744
745         for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++) {
746           const SMDS_MeshElement * e = aSMDSMesh->FindElement(i);
747           if (e) {
748             myElementsId += QString(" %1").arg(i);
749             aNbUnits++;
750           }
751         }
752       } else if (!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) { //SUBMESH
753         // get submesh
754         SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO);
755
756         // get IDs from submesh
757         /*
758         SMESH::long_array_var anElementsIds = new SMESH::long_array;
759         anElementsIds = aSubMesh->GetElementsId();
760         for (int i = 0; i < anElementsIds->length(); i++) {
761           myElementsId += QString(" %1").arg(anElementsIds[i]);
762         }
763         aNbUnits = anElementsIds->length();
764       } else { // GROUP
765         // get smesh group
766         SMESH::SMESH_GroupBase_var aGroup =
767           SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO);
768         if (aGroup->_is_nil())
769           return;
770
771         // get IDs from smesh group
772         SMESH::long_array_var anElementsIds = new SMESH::long_array;
773         anElementsIds = aGroup->GetListOfID();
774         for (int i = 0; i < anElementsIds->length(); i++) {
775           myElementsId += QString(" %1").arg(anElementsIds[i]);
776         }
777         aNbUnits = anElementsIds->length();
778       }
779       */
780     } else {
781       aNbUnits = SMESH::GetNameOfSelectedElements( mySelector, IO, aString);
782       myElementsId = aString;
783       if (aNbUnits < 1)
784         return;
785     }
786
787     myNbOkElements = true;
788   } else {
789     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
790     if (aNbUnits != 1)
791       return;
792
793     SMDS_Mesh* aMesh =  myActor->GetObject()->GetMesh();
794     if (!aMesh)
795       return;
796
797     const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
798     if (!n)
799       return;
800
801     double x = n->X();
802     double y = n->Y();
803     double z = n->Z();
804
805     if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
806       SpinBox_X->SetValue(x);
807       SpinBox_Y->SetValue(y);
808       SpinBox_Z->SetValue(z);
809     } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
810       SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
811       SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
812       SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
813     }
814   }
815
816   myBusy = true;
817   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
818     LineEditElements->setText(aString);
819     LineEditElements->repaint();
820     LineEditElements->setEnabled(false); // to update lineedit IPAL 19809
821     LineEditElements->setEnabled(true);
822     setNewMeshName();
823   }
824   myBusy = false;
825
826   // OK
827   if (myNbOkElements && IsMirrorOk()) {
828     buttonOk->setEnabled(true);
829     buttonApply->setEnabled(true);
830   }
831   onDisplaySimulation(true);
832 }
833
834 //=================================================================================
835 // function : SetEditCurrentArgument()
836 // purpose  :
837 //=================================================================================
838 void SMESHGUI_SymmetryDlg::SetEditCurrentArgument()
839 {
840   QPushButton* send = (QPushButton*)sender();
841
842   disconnect(mySelectionMgr, 0, this, 0);
843   mySelectionMgr->clearSelected();
844   mySelectionMgr->clearFilters();
845
846   if (send == SelectElementsButton) {
847     myEditCurrentArgument = (QWidget*)LineEditElements;
848     SMESH::SetPointRepresentation(false);
849     if (CheckBoxMesh->isChecked()) {
850       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
851         aViewWindow->SetSelectionMode(ActorSelection);
852       mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
853     } else {
854       if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
855         aViewWindow->SetSelectionMode(CellSelection);
856     }
857   } else if (send == SelectPointButton) {
858     myEditCurrentArgument = (QWidget*)SpinBox_X;
859     SMESH::SetPointRepresentation(true);
860     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
861       aViewWindow->SetSelectionMode(NodeSelection);
862   } else if (send == SelectVectorButton) {
863     myEditCurrentArgument = (QWidget*)SpinBox_DX;
864     SMESH::SetPointRepresentation(true);
865
866     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
867       aViewWindow->SetSelectionMode(NodeSelection);
868   } else {
869   }
870
871   myEditCurrentArgument->setFocus();
872   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
873   SelectionIntoArgument();
874 }
875
876 //=================================================================================
877 // function : DeactivateActiveDialog()
878 // purpose  :
879 //=================================================================================
880 void SMESHGUI_SymmetryDlg::DeactivateActiveDialog()
881 {
882   if (ConstructorsBox->isEnabled()) {
883     ConstructorsBox->setEnabled(false);
884     GroupArguments->setEnabled(false);
885     GroupButtons->setEnabled(false);
886     mySMESHGUI->ResetState();
887     mySMESHGUI->SetActiveDialogBox(0);
888   }
889 }
890
891 //=================================================================================
892 // function : ActivateThisDialog()
893 // purpose  :
894 //=================================================================================
895 void SMESHGUI_SymmetryDlg::ActivateThisDialog()
896 {
897   /* Emit a signal to deactivate the active dialog */
898   mySMESHGUI->EmitSignalDeactivateDialog();
899   ConstructorsBox->setEnabled(true);
900   GroupArguments->setEnabled(true);
901   GroupButtons->setEnabled(true);
902
903   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
904
905   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
906     aViewWindow->SetSelectionMode(CellSelection);
907   SelectionIntoArgument();
908 }
909
910 //=================================================================================
911 // function : enterEvent()
912 // purpose  :
913 //=================================================================================
914 void SMESHGUI_SymmetryDlg::enterEvent (QEvent*)
915 {
916   if (!ConstructorsBox->isEnabled())
917     ActivateThisDialog();
918 }
919
920 //=================================================================================
921 // function : closeEvent()
922 // purpose  :
923 //=================================================================================
924 void SMESHGUI_SymmetryDlg::closeEvent (QCloseEvent*)
925 {
926   /* same than click on cancel button */
927   ClickOnCancel();
928 }
929
930 //=======================================================================
931 // function : hideEvent()
932 // purpose  : caused by ESC key
933 //=======================================================================
934 void SMESHGUI_SymmetryDlg::hideEvent (QHideEvent*)
935 {
936   if (!isMinimized())
937     ClickOnCancel();
938 }
939
940 //=======================================================================
941 //function : onSelectMesh
942 //purpose  :
943 //=======================================================================
944 void SMESHGUI_SymmetryDlg::onSelectMesh (bool toSelectMesh)
945 {
946   if (toSelectMesh)
947     TextLabelElements->setText(tr("SMESH_NAME"));
948   else
949     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
950   myFilterBtn->setEnabled(!toSelectMesh);
951
952   if (myEditCurrentArgument != LineEditElements) {
953     LineEditElements->clear();
954     return;
955   }
956
957   mySelectionMgr->clearFilters();
958   SMESH::SetPointRepresentation(false);
959
960   if (toSelectMesh) {
961     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
962       aViewWindow->SetSelectionMode(ActorSelection);
963     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
964     LineEditElements->setReadOnly(true);
965     LineEditElements->setValidator(0);
966   } else {
967     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
968       aViewWindow->SetSelectionMode(CellSelection);
969     LineEditElements->setReadOnly(false);
970     LineEditElements->setValidator(myIdValidator);
971     onTextChange(LineEditElements->text());
972     hidePreview();
973   }
974
975   SelectionIntoArgument();
976 }
977
978 //=================================================================================
979 // function : GetConstructorId()
980 // purpose  :
981 //=================================================================================
982 int SMESHGUI_SymmetryDlg::GetConstructorId()
983 {
984   return GroupConstructors->checkedId();
985 }
986
987 //=================================================================================
988 // function : IsMirrorOk()
989 // purpose  :
990 //=================================================================================
991 bool SMESHGUI_SymmetryDlg::IsMirrorOk()
992 {
993   bool isOk = true;
994
995   if (GetConstructorId() != 0)
996     isOk = (SpinBox_DX->GetValue() != 0 ||
997             SpinBox_DY->GetValue() != 0 ||
998             SpinBox_DZ->GetValue() != 0);
999
1000   return isOk;
1001 }
1002
1003 //=================================================================================
1004 // function : onVectorChanged()
1005 // purpose  :
1006 //=================================================================================
1007 void SMESHGUI_SymmetryDlg::onVectorChanged()
1008 {
1009   if (IsMirrorOk()) {
1010     buttonOk->setEnabled(true);
1011     buttonApply->setEnabled(true);
1012   } else {
1013     buttonOk->setEnabled(false);
1014     buttonApply->setEnabled(false);
1015   }
1016 }
1017
1018 //=======================================================================
1019 //function : onActionClicked
1020 //purpose  : slot called when an action type changed
1021 //=======================================================================
1022
1023 void SMESHGUI_SymmetryDlg::onActionClicked(int button)
1024 {
1025   switch ( button ) {
1026   case MOVE_ELEMS_BUTTON:
1027     MakeGroupsCheck->setEnabled(false);
1028     LineEditNewMesh->setEnabled(false);
1029     break;
1030   case COPY_ELEMS_BUTTON:
1031     LineEditNewMesh->setEnabled(false);
1032     MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
1033     if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
1034       MakeGroupsCheck->setEnabled(true);
1035     else
1036       MakeGroupsCheck->setEnabled(false);
1037     break;
1038   case MAKE_MESH_BUTTON:
1039     LineEditNewMesh->setEnabled(true);
1040     MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
1041     if ( myMesh->_is_nil() || myMesh->NbGroups() > 0)
1042       MakeGroupsCheck->setEnabled(true);
1043     else
1044       MakeGroupsCheck->setEnabled(false);
1045     break;
1046   }
1047   setNewMeshName();
1048   toDisplaySimulation();
1049 }
1050
1051 //=======================================================================
1052 //function : setNewMeshName
1053 //purpose  : update contents of LineEditNewMesh
1054 //=======================================================================
1055
1056 void SMESHGUI_SymmetryDlg::setNewMeshName()
1057 {
1058   LineEditNewMesh->setText("");
1059   if ( LineEditNewMesh->isEnabled() && !myMesh->_is_nil() ) {
1060     QString name;
1061     if ( CheckBoxMesh->isChecked() ) {
1062       name = LineEditElements->text();
1063     }
1064     else {
1065       _PTR(SObject) meshSO = SMESH::FindSObject( myMesh );
1066       name = meshSO->GetName().c_str();
1067     }
1068     if ( !name.isEmpty() )
1069       LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "mirrored"));
1070   }
1071 }
1072
1073 //=================================================================================
1074 // function : keyPressEvent()
1075 // purpose  :
1076 //=================================================================================
1077 void SMESHGUI_SymmetryDlg::keyPressEvent( QKeyEvent* e )
1078 {
1079   QDialog::keyPressEvent( e );
1080   if ( e->isAccepted() )
1081     return;
1082
1083   if ( e->key() == Qt::Key_F1 ) {
1084     e->accept();
1085     ClickOnHelp();
1086   }
1087 }
1088
1089 //=================================================================================
1090 // function : setFilters()
1091 // purpose  : SLOT. Called when "Filter" button pressed.
1092 //=================================================================================
1093 void SMESHGUI_SymmetryDlg::setFilters()
1094 {
1095   if(myMesh->_is_nil()) {
1096     SUIT_MessageBox::critical(this,
1097                               tr("SMESH_ERROR"),
1098                               tr("NO_MESH_SELECTED"));
1099    return;
1100   }
1101   if ( !myFilterDlg )
1102     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
1103
1104   myFilterDlg->SetSelection();
1105   myFilterDlg->SetMesh( myMesh );
1106   myFilterDlg->SetSourceWg( LineEditElements );
1107
1108   myFilterDlg->show();
1109 }
1110
1111 //=================================================================================
1112 // function : isValid
1113 // purpose  :
1114 //=================================================================================
1115 bool SMESHGUI_SymmetryDlg::isValid()
1116 {
1117   bool ok = true;
1118   QString msg;
1119
1120   ok = SpinBox_X->isValid( msg, true ) && ok;
1121   ok = SpinBox_Y->isValid( msg, true ) && ok;
1122   ok = SpinBox_Z->isValid( msg, true ) && ok;
1123   if (GetConstructorId() != 0) {
1124     ok = SpinBox_DX->isValid( msg, true ) && ok;
1125     ok = SpinBox_DY->isValid( msg, true ) && ok;
1126     ok = SpinBox_DZ->isValid( msg, true ) && ok;
1127   }
1128
1129   if( !ok ) {
1130     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1131     if ( !msg.isEmpty() )
1132       str += "\n" + msg;
1133     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1134     return false;
1135   }
1136   return true;
1137 }
1138
1139 //=================================================================================
1140 // function : onDisplaySimulation
1141 // purpose  : Show/Hide preview
1142 //=================================================================================
1143 void SMESHGUI_SymmetryDlg::onDisplaySimulation( bool toDisplayPreview ) {
1144   if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
1145     if ( myNbOkElements && isValid() && IsMirrorOk() ) {
1146       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);      
1147       SMESH::long_array_var anElementsId = new SMESH::long_array;
1148
1149       anElementsId->length(aListElementsId.count());
1150       for (int i = 0; i < aListElementsId.count(); i++)
1151         anElementsId[i] = aListElementsId[i].toInt();
1152
1153       SMESH::AxisStruct aMirror;
1154       SMESH::SMESH_MeshEditor::MirrorType aMirrorType;
1155       
1156       getMirror(aMirror,aMirrorType);
1157
1158       try {
1159         bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON ||
1160                       ActionGroup->checkedId() == MAKE_MESH_BUTTON );
1161         SUIT_OverrideCursor aWaitCursor;
1162         SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditPreviewer();
1163         if(CheckBoxMesh->isChecked())
1164           aMeshEditor->MirrorObject(mySelectedObject, aMirror, aMirrorType, copy );
1165         else
1166           aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, copy );
1167         
1168         SMESH::MeshPreviewStruct_var aMeshPreviewStruct = aMeshEditor->GetPreviewData();
1169         mySimulation->SetData(aMeshPreviewStruct._retn());
1170       } catch (...) {
1171         hidePreview();
1172       }
1173     } else {
1174       hidePreview();
1175     } 
1176   } else {
1177     hidePreview();
1178   }
1179 }
1180
1181 //=================================================================================
1182 // function : getMirror
1183 // purpose  : return mirror parameters
1184 //=================================================================================
1185 void SMESHGUI_SymmetryDlg::getMirror(SMESH::AxisStruct& theMirror, SMESH::SMESH_MeshEditor::MirrorType& theMirrorType) {
1186   theMirror.x =  SpinBox_X->GetValue();
1187   theMirror.y =  SpinBox_Y->GetValue();
1188   theMirror.z =  SpinBox_Z->GetValue();
1189   if (GetConstructorId() == 0) {
1190     theMirror.vx = theMirror.vy = theMirror.vz = 0;
1191   } else {
1192     theMirror.vx = SpinBox_DX->GetValue();
1193     theMirror.vy = SpinBox_DY->GetValue();
1194     theMirror.vz = SpinBox_DZ->GetValue();
1195   }
1196   if (GetConstructorId() == 0)
1197     theMirrorType = SMESH::SMESH_MeshEditor::POINT;
1198   if (GetConstructorId() == 1)
1199     theMirrorType = SMESH::SMESH_MeshEditor::AXIS;
1200   if (GetConstructorId() == 2)
1201     theMirrorType = SMESH::SMESH_MeshEditor::PLANE;
1202 }