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