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