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