Salome HOME
52943: "Apply and Close" button does not active on symmetry dialog box
[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
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     myElementsId = "";
711     myObjects.clear();
712     myObjectsNames.clear();
713     myMeshes.clear();
714
715     for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
716       Handle(SALOME_InteractiveObject) IO = it.Value();
717       SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO );
718       if ( aMesh->_is_nil() )
719         return;
720       
721       myActor = SMESH::FindActorByObject( aMesh );
722       if ( !myActor )
723         myActor = SMESH::FindActorByEntry( IO->getEntry() );
724       if ( !myActor && !CheckBoxMesh->isChecked() )
725         return;
726       
727       if ( !SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO )->_is_nil() ) {
728         if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() ) {
729           _PTR(SObject) obj = aStudy->FindObjectID( qPrintable( QString( IO->getEntry() ) ) );
730           _PTR(GenericAttribute) anAttr;
731           if ( obj && obj->FindAttribute( anAttr, "AttributeName" ) ) {
732             _PTR(AttributeName) aNameAttr( anAttr );
733             myObjects << SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
734             myObjectsNames << aNameAttr->Value().c_str();
735             myMeshes << aMesh;
736           }
737         }
738       }
739     }
740
741     // MakeGroups is available if there are groups and "Copy"
742     int aNbGroups = 0;
743     for ( int i = 0; i < myMeshes.count(); i++ )
744       aNbGroups += myMeshes[i]->NbGroups();
745     if ( aNbGroups == 0 ) {
746       MakeGroupsCheck->setChecked(false);
747       MakeGroupsCheck->setEnabled(false);
748     }
749     else if ( ActionGroup->checkedId() != MOVE_ELEMS_BUTTON ) {
750       MakeGroupsCheck->setEnabled(true);
751     }
752     if (CheckBoxMesh->isChecked()) {
753       SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
754
755       if ( myMeshes.isEmpty() )
756         return;
757     }
758     else {
759       aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aList.First(), aString);
760       myElementsId = aString;
761       if (aNbUnits < 1)
762         return;
763     }
764
765     myNbOkElements = true;
766
767   } else {
768     Handle(SALOME_InteractiveObject) IO = aList.First();
769     if ((SMESH::GetMeshByIO(IO))->_is_nil())
770       return;
771
772     SMESH_Actor* anActor = SMESH::FindActorByObject(SMESH::GetMeshByIO(IO));
773     if (!anActor)
774       anActor = SMESH::FindActorByEntry(IO->getEntry());
775     if (!anActor && !CheckBoxMesh->isChecked())
776       return;
777
778     aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
779     if (aNbUnits != 1)
780       return;
781
782     SMDS_Mesh* aMesh =  anActor->GetObject()->GetMesh();
783     if (!aMesh)
784       return;
785
786     const SMDS_MeshNode * n = aMesh->FindNode(aString.toInt());
787     if (!n)
788       return;
789
790     double x = n->X();
791     double y = n->Y();
792     double z = n->Z();
793
794     if (myEditCurrentArgument == (QWidget*)SpinBox_X) {
795       SpinBox_X->SetValue(x);
796       SpinBox_Y->SetValue(y);
797       SpinBox_Z->SetValue(z);
798     } else if (myEditCurrentArgument == (QWidget*)SpinBox_DX) {
799       SpinBox_DX->SetValue(x - SpinBox_X->GetValue());
800       SpinBox_DY->SetValue(y - SpinBox_Y->GetValue());
801       SpinBox_DZ->SetValue(z - SpinBox_Z->GetValue());
802     }
803   }
804
805   myBusy = true;
806   if (myEditCurrentArgument == (QWidget*)LineEditElements) {
807     LineEditElements->setText(aString);
808     LineEditElements->repaint();
809     LineEditElements->setEnabled(false); // to update lineedit IPAL 19809
810     LineEditElements->setEnabled(true);
811     setNewMeshName();
812   }
813   myBusy = false;
814
815   // OK
816   if (myNbOkElements && IsAxisOk()) {
817     buttonOk->setEnabled(true);
818     buttonApply->setEnabled(true);
819   }
820   onDisplaySimulation(true);
821 }
822
823 //=================================================================================
824 // function : SetEditCurrentArgument()
825 // purpose  :
826 //=================================================================================
827 void SMESHGUI_RotationDlg::SetEditCurrentArgument()
828 {
829   QPushButton* send = (QPushButton*)sender();
830
831   disconnect(mySelectionMgr, 0, this, 0);
832   mySelectionMgr->clearSelected();
833   mySelectionMgr->clearFilters();
834
835   switch (myConstructorId) {
836   case 0: /* default constructor */
837     {
838       SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
839       if (send == SelectElementsButton) {
840         myEditCurrentArgument = (QWidget*)LineEditElements;
841         SMESH::SetPointRepresentation(false);
842         if (CheckBoxMesh->isChecked()) {
843           if ( aViewWindow )
844             aViewWindow->SetSelectionMode(ActorSelection);
845           mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
846         } else {
847           if ( aViewWindow )
848             aViewWindow->SetSelectionMode( CellSelection );
849         }
850       } else if (send == SelectPointButton) {
851         myEditCurrentArgument = (QWidget*)SpinBox_X;
852         SMESH::SetPointRepresentation(true);
853         if ( aViewWindow )
854           aViewWindow->SetSelectionMode( NodeSelection );
855       } else if (send == SelectVectorButton) {
856         myEditCurrentArgument = (QWidget*)SpinBox_DX;
857         SMESH::SetPointRepresentation(true);
858         if ( aViewWindow )
859           aViewWindow->SetSelectionMode( NodeSelection );
860       }
861       break;
862     }
863
864   }
865
866   myEditCurrentArgument->setFocus();
867   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
868   SelectionIntoArgument();
869 }
870
871 //=================================================================================
872 // function : DeactivateActiveDialog()
873 // purpose  :
874 //=================================================================================
875 void SMESHGUI_RotationDlg::DeactivateActiveDialog()
876 {
877   if (GroupConstructors->isEnabled()) {
878     GroupConstructors->setEnabled(false);
879     GroupArguments->setEnabled(false);
880     GroupButtons->setEnabled(false);
881     mySMESHGUI->ResetState();
882     mySMESHGUI->SetActiveDialogBox(0);
883   }
884 }
885
886 //=================================================================================
887 // function : ActivateThisDialog()
888 // purpose  :
889 //=================================================================================
890 void SMESHGUI_RotationDlg::ActivateThisDialog()
891 {
892   /* Emit a signal to deactivate the active dialog */
893   mySMESHGUI->EmitSignalDeactivateDialog();
894   GroupConstructors->setEnabled(true);
895   GroupArguments->setEnabled(true);
896   GroupButtons->setEnabled(true);
897
898   mySMESHGUI->SetActiveDialogBox((QDialog*)this);
899
900   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
901     aViewWindow->SetSelectionMode( CellSelection );
902   SelectionIntoArgument();
903 }
904
905 //=================================================================================
906 // function : enterEvent()
907 // purpose  :
908 //=================================================================================
909 void SMESHGUI_RotationDlg::enterEvent (QEvent*)
910 {
911   if (!GroupConstructors->isEnabled()) {
912     SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
913     if ( aViewWindow && !mySelector) {
914       mySelector = aViewWindow->GetSelector();
915     }
916     ActivateThisDialog();
917   }
918 }
919
920 //=================================================================================
921 // function : onSelectMesh()
922 // purpose  :
923 //=================================================================================
924 void SMESHGUI_RotationDlg::onSelectMesh (bool toSelectMesh)
925 {
926   if (toSelectMesh)
927     TextLabelElements->setText(tr("SMESH_NAME"));
928   else
929     TextLabelElements->setText(tr("SMESH_ID_ELEMENTS"));
930   myFilterBtn->setEnabled(!toSelectMesh);
931
932   if (myEditCurrentArgument != LineEditElements) {
933     LineEditElements->clear();
934     return;
935   }
936
937   mySelectionMgr->clearFilters();
938   SMESH::SetPointRepresentation(false);
939
940   if (toSelectMesh) {
941     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
942       aViewWindow->SetSelectionMode(ActorSelection);
943     mySelectionMgr->installFilter(myMeshOrSubMeshOrGroupFilter);
944     LineEditElements->setReadOnly(true);
945     LineEditElements->setValidator(0);
946   } else {
947     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
948       aViewWindow->SetSelectionMode( CellSelection );
949     LineEditElements->setReadOnly(false);
950     LineEditElements->setValidator(myIdValidator);
951     hidePreview();
952   }
953
954   SelectionIntoArgument();
955 }
956
957 //=================================================================================
958 // function : IsAxisOk()
959 // purpose  :
960 //=================================================================================
961 bool SMESHGUI_RotationDlg::IsAxisOk()
962 {
963   return (SpinBox_DX->GetValue() != 0 ||
964           SpinBox_DY->GetValue() != 0 ||
965           SpinBox_DZ->GetValue() != 0);
966 }
967
968 //=================================================================================
969 // function : onVectorChanged()
970 // purpose  :
971 //=================================================================================
972 void SMESHGUI_RotationDlg::onVectorChanged()
973 {
974   if (IsAxisOk()) {
975     buttonOk->setEnabled(true);
976     buttonApply->setEnabled(true);
977   } else {
978     buttonOk->setEnabled(false);
979     buttonApply->setEnabled(false);
980   }
981 }
982
983
984 //=======================================================================
985 //function : onActionClicked
986 //purpose  : slot called when an action type changed
987 //=======================================================================
988
989 void SMESHGUI_RotationDlg::onActionClicked(int button)
990 {
991   int aNbGroups = 0;
992   for ( int i = 0; i < myMeshes.count(); i++ )
993     aNbGroups += myMeshes[i]->NbGroups();
994
995   switch ( button ) {
996   case MOVE_ELEMS_BUTTON:
997     MakeGroupsCheck->setEnabled(false);
998     LineEditNewMesh->setEnabled(false);
999     break;
1000   case COPY_ELEMS_BUTTON:
1001     LineEditNewMesh->setEnabled(false);
1002     MakeGroupsCheck->setText( tr("SMESH_MAKE_GROUPS"));
1003     MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 );
1004     break;
1005   case MAKE_MESH_BUTTON:
1006     LineEditNewMesh->setEnabled(true);
1007     MakeGroupsCheck->setText( tr("SMESH_COPY_GROUPS"));
1008     MakeGroupsCheck->setEnabled( myMeshes.isEmpty() || aNbGroups > 0 );
1009     break;
1010   }
1011   setNewMeshName();
1012   toDisplaySimulation();
1013 }
1014
1015 //=======================================================================
1016 //function : setNewMeshName
1017 //purpose  : update contents of LineEditNewMesh
1018 //=======================================================================
1019
1020 void SMESHGUI_RotationDlg::setNewMeshName()
1021 {
1022   LineEditNewMesh->setText("");
1023   if ( LineEditNewMesh->isEnabled() && !myMeshes.isEmpty() ) {
1024     QString name;
1025     if ( CheckBoxMesh->isChecked() ) {
1026       name = myMeshes.count() > 1 ? "*" : LineEditElements->text();
1027     }
1028     else {
1029       _PTR(SObject) meshSO = SMESH::FindSObject( myMeshes[0] );
1030       name = meshSO->GetName().c_str();
1031     }
1032     if ( !name.isEmpty() )
1033       LineEditNewMesh->setText( SMESH::UniqueMeshName( name, "rotated"));
1034   }
1035 }
1036
1037 //=================================================================================
1038 // function : keyPressEvent()
1039 // purpose  :
1040 //=================================================================================
1041 void SMESHGUI_RotationDlg::keyPressEvent( QKeyEvent* e )
1042 {
1043   QDialog::keyPressEvent( e );
1044   if ( e->isAccepted() )
1045     return;
1046
1047   if ( e->key() == Qt::Key_F1 ) {
1048     e->accept();
1049     ClickOnHelp();
1050   }
1051 }
1052
1053 //=================================================================================
1054 // function : setFilters()
1055 // purpose  : SLOT. Called when "Filter" button pressed.
1056 //=================================================================================
1057 void SMESHGUI_RotationDlg::setFilters()
1058 {
1059   if ( myMeshes.isEmpty() ) {
1060     SUIT_MessageBox::critical(this,
1061                               tr("SMESH_ERROR"),
1062                               tr("NO_MESH_SELECTED"));
1063    return;
1064   }
1065   if ( !myFilterDlg )
1066     myFilterDlg = new SMESHGUI_FilterDlg( mySMESHGUI, SMESH::ALL );
1067
1068   QList<int> types;
1069   if ( myMeshes[0]->NbEdges()     ) types << SMESH::EDGE;
1070   if ( myMeshes[0]->NbFaces()     ) types << SMESH::FACE;
1071   if ( myMeshes[0]->NbVolumes()   ) types << SMESH::VOLUME;
1072   if ( myMeshes[0]->NbBalls()     ) types << SMESH::BALL;
1073   if ( myMeshes[0]->Nb0DElements()) types << SMESH::ELEM0D;
1074   if ( types.count() > 1 )          types << SMESH::ALL;
1075
1076   myFilterDlg->Init( types );
1077   myFilterDlg->SetSelection();
1078   myFilterDlg->SetMesh( myMeshes[0] );
1079   myFilterDlg->SetSourceWg( LineEditElements );
1080
1081   myFilterDlg->show();
1082 }
1083
1084 //=================================================================================
1085 // function : isValid
1086 // purpose  :
1087 //=================================================================================
1088 bool SMESHGUI_RotationDlg::isValid()
1089 {
1090   bool ok = true;
1091   QString msg;
1092
1093   ok = SpinBox_X->isValid( msg, true ) && ok;
1094   ok = SpinBox_Y->isValid( msg, true ) && ok;
1095   ok = SpinBox_Z->isValid( msg, true ) && ok;
1096   ok = SpinBox_DX->isValid( msg, true ) && ok;
1097   ok = SpinBox_DY->isValid( msg, true ) && ok;
1098   ok = SpinBox_DZ->isValid( msg, true ) && ok;
1099   ok = SpinBox_Angle->isValid( msg, true ) && ok;
1100
1101   if( !ok ) {
1102     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1103     if ( !msg.isEmpty() )
1104       str += "\n" + msg;
1105     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1106     return false;
1107   }
1108   return true;
1109 }
1110
1111
1112 //=================================================================================
1113 // function : onDisplaySimulation
1114 // purpose  : Show/Hide preview
1115 //=================================================================================
1116 void SMESHGUI_RotationDlg::onDisplaySimulation( bool toDisplayPreview ) {
1117   if (myPreviewCheckBox->isChecked() && toDisplayPreview) {
1118     if(myNbOkElements && isValid() && IsAxisOk()) {
1119       QStringList aListElementsId = myElementsId.split(" ", QString::SkipEmptyParts);
1120       SMESH::long_array_var anElementsId = new SMESH::long_array;
1121       
1122       anElementsId->length(aListElementsId.count());
1123       for (int i = 0; i < aListElementsId.count(); i++)
1124         anElementsId[i] = aListElementsId[i].toInt();
1125       
1126       SMESH::AxisStruct anAxis;
1127       
1128       anAxis.x =  SpinBox_X->GetValue();
1129       anAxis.y =  SpinBox_Y->GetValue();
1130       anAxis.z =  SpinBox_Z->GetValue();;
1131       anAxis.vx = SpinBox_DX->GetValue();
1132       anAxis.vy = SpinBox_DY->GetValue();
1133       anAxis.vz = SpinBox_DZ->GetValue();
1134       double anAngle = (SpinBox_Angle->GetValue())*M_PI/180.;
1135       
1136       try {
1137         SUIT_OverrideCursor aWaitCursor;
1138         bool copy = ( ActionGroup->checkedId() == COPY_ELEMS_BUTTON  ||
1139                       ActionGroup->checkedId() == MAKE_MESH_BUTTON );
1140         QList<SMESH::MeshPreviewStruct_var> aMeshPreviewStruct;
1141         if(CheckBoxMesh->isChecked())
1142           for ( int i = 0; i < myObjects.count(); i++ ) {
1143             SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[i]->GetMeshEditPreviewer();
1144             aMeshEditor->RotateObject(myObjects[i], anAxis, anAngle, copy);
1145             aMeshPreviewStruct << aMeshEditor->GetPreviewData();
1146           }
1147         else {
1148           SMESH::SMESH_MeshEditor_var aMeshEditor = myMeshes[0]->GetMeshEditPreviewer();
1149           aMeshEditor->Rotate(anElementsId, anAxis, anAngle, copy);
1150           aMeshPreviewStruct << aMeshEditor->GetPreviewData();
1151         }
1152         setSimulationPreview( aMeshPreviewStruct );
1153       } catch (...) {
1154         hidePreview();
1155       }
1156     }
1157     else {
1158       hidePreview();
1159     }
1160   } else {
1161     hidePreview();
1162   }
1163 }