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