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