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