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