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