Salome HOME
Merge branch 'V9_9_BR'
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ExtrusionAlongPathDlg.cxx
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_ExtrusionAlongPathDlg.cxx
25 // Author : Vadim SANDLER, Open CASCADE S.A.S.
26 // SMESH includes
27
28 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
29
30 #include "SMESHGUI.h"
31 #include "SMESHGUI_ExtrusionDlg.h" // for SMESHGUI_3TypesSelector
32 #include "SMESHGUI_FilterDlg.h"
33 #include "SMESHGUI_IdValidator.h"
34 #include "SMESHGUI_MeshEditPreview.h"
35 #include "SMESHGUI_MeshUtils.h"
36 #include "SMESHGUI_SpinBox.h"
37 #include "SMESHGUI_Utils.h"
38 #include "SMESHGUI_VTKUtils.h"
39
40 #include <SMESH_Actor.h>
41 #include <SMESH_TypeFilter.hxx>
42 #include <SMESH_NumberFilter.hxx>
43 #include <SMESH_LogicalFilter.hxx>
44
45 #include <SMDS_Mesh.hxx>
46
47 // SALOME GEOM includes
48 #include <GEOMBase.h>
49
50 // SALOME GUI includes
51 #include <SUIT_ResourceMgr.h>
52 #include <SUIT_OverrideCursor.h>
53 #include <SUIT_Desktop.h>
54 #include <SUIT_MessageBox.h>
55 #include <SUIT_Session.h>
56 #include <LightApp_Application.h>
57 #include <LightApp_SelectionMgr.h>
58 #include <SVTK_ViewWindow.h>
59
60 // OCCT includes
61 #include <BRep_Tool.hxx>
62 #include <TopoDS_Vertex.hxx>
63 #include <gp_Pnt.hxx>
64 #include <TColStd_MapOfInteger.hxx>
65
66 // Qt includes
67 #include <QButtonGroup>
68 #include <QGroupBox>
69 #include <QLabel>
70 #include <QLineEdit>
71 #include <QPushButton>
72 #include <QToolButton>
73 #include <QRadioButton>
74 #include <QCheckBox>
75 #include <QListWidget>
76 #include <QVBoxLayout>
77 #include <QHBoxLayout>
78 #include <QGridLayout>
79 #include <QKeyEvent>
80
81 // IDL includes
82 #include <SALOMEconfig.h>
83 #include CORBA_SERVER_HEADER(SMESH_Group)
84 #include CORBA_SERVER_HEADER(SMESH_MeshEditor)
85
86 #define SPACING 6
87 #define MARGIN  11
88
89 class SMESHGUI_ExtrusionAlongPathDlg::SetBusy
90 {
91 public:
92   SetBusy( SMESHGUI_ExtrusionAlongPathDlg* _dlg )
93   {
94     myDlg = _dlg; 
95     myDlg->myBusy = true;
96   }
97   
98   ~SetBusy()
99   { 
100     myDlg->myBusy = false;
101   }
102   
103 private:
104   SMESHGUI_ExtrusionAlongPathDlg* myDlg;
105 };
106
107 //=================================================================================
108 // function : SMESHGUI_ExtrusionAlongPathDlg()
109 // purpose  : constructor
110 //=================================================================================
111 SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theModule )
112   : SMESHGUI_PreviewDlg( theModule ),
113     mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
114 {
115   SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI );
116   QPixmap selectImage ( mgr->loadPixmap("SMESH", tr("ICON_SELECT")));
117   QPixmap addImage    ( mgr->loadPixmap("SMESH", tr("ICON_APPEND")));
118   QPixmap removeImage ( mgr->loadPixmap("SMESH", tr("ICON_REMOVE")));
119
120   setModal( false );
121   setAttribute( Qt::WA_DeleteOnClose, true );
122   setWindowTitle(tr("EXTRUSION_ALONG_PATH"));
123   setSizeGripEnabled(true);
124
125   QVBoxLayout* topLayout = new QVBoxLayout(this);
126   topLayout->setSpacing(SPACING);
127   topLayout->setMargin(MARGIN);
128
129   /***************************************************************/
130   // Arguments group box
131   GroupArguments = new QGroupBox(tr("SMESH_EXTRUSION"), this);
132   QGridLayout* GroupArgumentsLayout = new QGridLayout(GroupArguments);
133   GroupArgumentsLayout->setSpacing(SPACING); GroupArgumentsLayout->setMargin(MARGIN);
134
135   myIdValidator = new SMESHGUI_IdValidator(this);
136
137   // Controls for elements selection
138   SelectorWdg = new SMESHGUI_3TypesSelector( GroupArguments );
139   
140   // Controls for path selection
141   PathGrp = new QGroupBox(tr("SMESH_PATH"), GroupArguments);
142   QGridLayout* PathGrpLayout = new QGridLayout(PathGrp);
143   PathGrpLayout->setSpacing(SPACING); PathGrpLayout->setMargin(MARGIN);
144
145   // Controls for path mesh selection
146   QLabel* PathMeshLab = new QLabel(tr("SMESH_PATH_MESH"), PathGrp);
147
148   SelectPathMeshButton = new QPushButton(PathGrp);
149   SelectPathMeshButton->setIcon(selectImage);
150   SelectPathMeshButton->setCheckable(true);
151
152   PathMeshLineEdit = new QLineEdit(PathGrp);
153   PathMeshLineEdit->setReadOnly(true);
154
155   // Controls for path starting point selection
156   QLabel* StartPointLab = new QLabel(tr("SMESH_PATH_START"), PathGrp);
157
158   SelectStartPointButton = new QPushButton(PathGrp);
159   SelectStartPointButton->setIcon(selectImage);
160   SelectStartPointButton->setCheckable(true);
161
162   StartPointLineEdit = new QLineEdit(PathGrp);
163   StartPointLineEdit->setValidator(new QIntValidator(this));
164
165   // layouting
166   PathGrpLayout->addWidget(PathMeshLab,            0, 0);
167   PathGrpLayout->addWidget(SelectPathMeshButton,   0, 1);
168   PathGrpLayout->addWidget(PathMeshLineEdit,       0, 2);
169   PathGrpLayout->addWidget(StartPointLab,          1, 0);
170   PathGrpLayout->addWidget(SelectStartPointButton, 1, 1);
171   PathGrpLayout->addWidget(StartPointLineEdit,     1, 2);
172
173   BasePointGrp = new QGroupBox(tr("SMESH_BASE_POINT"), GroupArguments);
174   BasePointGrp->setCheckable(true);
175   BasePointGrp->setChecked(false);
176   QHBoxLayout* BasePointGrpLayout = new QHBoxLayout(BasePointGrp);
177   BasePointGrpLayout->setSpacing(SPACING); BasePointGrpLayout->setMargin(MARGIN);
178
179   SelectBasePointButton = new QPushButton(BasePointGrp);
180   SelectBasePointButton->setIcon(selectImage);
181   SelectBasePointButton->setCheckable(true);
182
183   SelectorWdg->GetButtonGroup()->addButton( SelectPathMeshButton );
184   SelectorWdg->GetButtonGroup()->addButton( SelectStartPointButton );
185   SelectorWdg->GetButtonGroup()->addButton( SelectBasePointButton );
186
187   QLabel* XLab  = new QLabel(tr("SMESH_X"), BasePointGrp);
188   XSpin = new SMESHGUI_SpinBox(BasePointGrp);
189   QLabel* YLab  = new QLabel(tr("SMESH_Y"), BasePointGrp);
190   YSpin = new SMESHGUI_SpinBox(BasePointGrp);
191   QLabel* ZLab  = new QLabel(tr("SMESH_Z"), BasePointGrp);
192   ZSpin = new SMESHGUI_SpinBox(BasePointGrp);
193
194   // layouting
195   BasePointGrpLayout->addWidget(SelectBasePointButton);
196   BasePointGrpLayout->addWidget(XLab);
197   BasePointGrpLayout->addWidget(XSpin);
198   BasePointGrpLayout->addWidget(YLab);
199   BasePointGrpLayout->addWidget(YSpin);
200   BasePointGrpLayout->addWidget(ZLab);
201   BasePointGrpLayout->addWidget(ZSpin);
202
203   // Angles
204   AnglesGrp = new QGroupBox(tr("SMESH_ANGLES"), GroupArguments);
205   AnglesGrp->setCheckable(true);
206   AnglesGrp->setChecked(false);
207   QGridLayout* AnglesGrpLayout = new QGridLayout(AnglesGrp);
208   AnglesGrpLayout->setSpacing(SPACING); AnglesGrpLayout->setMargin(MARGIN);
209
210   AnglesList = new QListWidget(AnglesGrp);
211   AnglesList->setSelectionMode(QListWidget::ExtendedSelection);
212
213   AddAngleButton = new QToolButton(AnglesGrp);
214   AddAngleButton->setIcon(addImage);
215
216   RemoveAngleButton = new QToolButton(AnglesGrp);
217   RemoveAngleButton->setIcon(removeImage);
218
219   AngleSpin = new SMESHGUI_SpinBox(AnglesGrp);
220
221   LinearAnglesCheck = new QCheckBox(tr("LINEAR_ANGLES"), AnglesGrp);
222
223   AnglesGrpLayout->addWidget(AnglesList,        0, 0, 4, 1);
224   AnglesGrpLayout->addWidget(AddAngleButton,    0, 1);
225   AnglesGrpLayout->addWidget(RemoveAngleButton, 2, 1);
226   AnglesGrpLayout->addWidget(AngleSpin,         0, 2);
227   AnglesGrpLayout->addWidget(LinearAnglesCheck, 4, 0, 1, 3);
228   AnglesGrpLayout->setRowMinimumHeight(1, 10);
229   AnglesGrpLayout->setRowStretch(3, 10);
230
231   // Scales
232   ScalesGrp = new QGroupBox(tr("SMESH_SCALES"), GroupArguments);
233   ScalesGrp->setCheckable(true);
234   ScalesGrp->setChecked(false);
235   QGridLayout* ScalesGrpLayout = new QGridLayout(ScalesGrp);
236   ScalesGrpLayout->setSpacing(SPACING); ScalesGrpLayout->setMargin(MARGIN);
237
238   ScalesList = new QListWidget(ScalesGrp);
239   ScalesList->setSelectionMode(QListWidget::ExtendedSelection);
240
241   AddScaleButton = new QToolButton(ScalesGrp);
242   AddScaleButton->setIcon(addImage);
243
244   RemoveScaleButton = new QToolButton(ScalesGrp);
245   RemoveScaleButton->setIcon(removeImage);
246
247   ScaleSpin = new SMESHGUI_SpinBox(ScalesGrp);
248
249   LinearScalesCheck = new QCheckBox(tr("LINEAR_SCALES"), ScalesGrp);
250
251   ScalesGrpLayout->addWidget(ScalesList,        0, 0, 4, 1);
252   ScalesGrpLayout->addWidget(AddScaleButton,    0, 1);
253   ScalesGrpLayout->addWidget(RemoveScaleButton, 2, 1);
254   ScalesGrpLayout->addWidget(ScaleSpin,         0, 2);
255   ScalesGrpLayout->addWidget(LinearScalesCheck, 4, 0, 1, 3);
256   ScalesGrpLayout->setRowMinimumHeight(1, 10);
257   ScalesGrpLayout->setRowStretch(3, 10);
258
259   // CheckBox for groups generation
260   MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments);
261   MakeGroupsCheck->setChecked(true);
262
263   //Preview check box
264   myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments);
265
266   // layouting
267   GroupArgumentsLayout->addWidget(SelectorWdg,          0, 0, 3, 2);
268   GroupArgumentsLayout->addWidget(PathGrp,              0, 2, 1, 2);
269   GroupArgumentsLayout->addWidget(BasePointGrp,         1, 2, 1, 2);
270   GroupArgumentsLayout->addWidget(AnglesGrp,            2, 2);
271   GroupArgumentsLayout->addWidget(ScalesGrp,            2, 3);
272   GroupArgumentsLayout->addWidget(myPreviewCheckBox,    3, 0);
273   GroupArgumentsLayout->addWidget(MakeGroupsCheck,      3, 1);
274   SelectorWdg->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
275   SelectorWdg->setMinimumWidth(320);
276
277   /***************************************************************/
278   // common buttons group box
279   GroupButtons = new QGroupBox(this);
280   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
281   GroupButtonsLayout->setSpacing(SPACING); GroupButtonsLayout->setMargin(MARGIN);
282
283   OkButton = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
284   OkButton->setAutoDefault(true);
285   OkButton->setDefault(true);
286
287   ApplyButton = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons); 
288   ApplyButton->setAutoDefault(true);
289
290   CloseButton = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
291   CloseButton->setAutoDefault(true);
292
293   HelpButton = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
294   HelpButton->setAutoDefault(true);
295
296   // layouting
297   GroupButtonsLayout->addWidget(OkButton);
298   GroupButtonsLayout->addSpacing(10);
299   GroupButtonsLayout->addWidget(ApplyButton);
300   GroupButtonsLayout->addSpacing(10);
301   GroupButtonsLayout->addStretch();
302   GroupButtonsLayout->addWidget(CloseButton);
303   GroupButtonsLayout->addWidget(HelpButton);
304
305   /***************************************************************/
306   // layouting
307   topLayout->addWidget(GroupArguments);
308   topLayout->addWidget(GroupButtons);
309
310   /***************************************************************/
311   // Initialisations
312   XSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
313   YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
314   ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
315   AngleSpin->RangeStepAndValidator(-180.0, 180.0, 5.0, "angle_precision");
316   ScaleSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 1.0, "length_precision");
317
318   mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
319
320   mySMESHGUI->SetActiveDialogBox(this);
321
322   myPathMeshFilter = new SMESH_TypeFilter(SMESH::IDSOURCE_EDGE);
323
324   myHelpFileName = "extrusion_along_path.html";
325
326   Init();
327
328   /***************************************************************/
329   // signals-slots connections
330   connect(OkButton,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
331   connect(CloseButton,  SIGNAL(clicked()), this, SLOT(reject()));
332   connect(ApplyButton,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
333   connect(HelpButton,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
334
335   connect(AddAngleButton,    SIGNAL(clicked()), this, SLOT(OnAngleAdded()));
336   connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved()));
337   connect(AddScaleButton,    SIGNAL(clicked()), this, SLOT(OnAngleAdded()));
338   connect(RemoveScaleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved()));
339
340   connect(SelectPathMeshButton,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
341   connect(SelectStartPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
342   connect(SelectBasePointButton,  SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
343   connect(BasePointGrp,       SIGNAL(toggled(bool)), this, SLOT(SetEditCurrentArgument()));
344
345   connect(mySMESHGUI,  SIGNAL(SignalCloseAllDialogs()),        SLOT(reject()));
346   connect(mySMESHGUI,  SIGNAL(SignalActivatedViewManager()),   SLOT(onOpenView()));
347   connect(mySMESHGUI,  SIGNAL(SignalCloseView()),              SLOT(onCloseView()));
348   connect(mySMESHGUI,  SIGNAL(SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
349   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),   SLOT(SelectionIntoArgument()));
350   connect(SelectorWdg,    SIGNAL(selectionChanged()), this,    SLOT(toDisplaySimulation()));
351   connect(SelectorWdg,    SIGNAL(selectionChanged()), this,    SLOT(CheckIsEnable()));
352
353   connect(StartPointLineEdit, SIGNAL(textChanged(const QString&)),
354           SLOT(onTextChange(const QString&)));
355
356   connect(XSpin,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
357   connect(YSpin,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
358   connect(ZSpin,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
359   connect(AddAngleButton,    SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
360   connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
361   connect(AddScaleButton,    SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
362   connect(RemoveScaleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
363   connect(LinearScalesCheck, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation()));
364   connect(LinearAnglesCheck, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation()));
365   connect(ScalesGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation()));
366   connect(AnglesGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation()));
367
368
369   //To Connect preview check box
370   connectPreviewControl();
371
372   AnglesList        ->installEventFilter(this);
373   ScalesList        ->installEventFilter(this);
374   StartPointLineEdit->installEventFilter(this);
375   XSpin->editor()   ->installEventFilter(this);
376   YSpin->editor()   ->installEventFilter(this);
377   ZSpin->editor()   ->installEventFilter(this);
378
379   CheckIsEnable();
380
381   resize( minimumSizeHint() );
382 }
383
384 //=================================================================================
385 // function : ~SMESHGUI_ExtrusionAlongPathDlg()
386 // purpose  : destructor
387 //=================================================================================
388 SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
389 {
390   // no need to delete child widgets, Qt does it all for us
391 }
392
393 //=================================================================================
394 // function : Init()
395 // purpose  : initialization
396 //=================================================================================
397 void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls)
398 {
399   myBusy = false;
400   myEditCurrentArgument = 0;
401
402   myPath = SMESH::SMESH_IDSource::_nil();
403
404   SelectorWdg->Clear();
405   PathMeshLineEdit->clear();
406   StartPointLineEdit->clear();
407
408   if (ResetControls) {
409     XSpin->SetValue(0.0);
410     YSpin->SetValue(0.0);
411     ZSpin->SetValue(0.0);
412
413     AngleSpin->SetValue(45);
414     ScaleSpin->SetValue(2);
415     myPreviewCheckBox->setChecked(false);
416     onDisplaySimulation(false);
417   }
418   SetEditCurrentArgument(0);
419 }
420
421 //=================================================================================
422 // function : CheckIsEnable()
423 // purpose  : Check whether the Ok and Apply buttons should be enabled or not
424 //=================================================================================
425
426 void SMESHGUI_ExtrusionAlongPathDlg::CheckIsEnable()
427 {  
428   bool anIsEnable = SelectorWdg->IsAnythingSelected() && isValuesValid();
429
430   OkButton->setEnabled(anIsEnable);
431   ApplyButton->setEnabled(anIsEnable);
432 }
433
434 //=================================================================================
435 // function : ClickOnApply()
436 // purpose  : Called when user presses <Apply> button
437 //=================================================================================
438 bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
439 {
440   if (SMESHGUI::isStudyLocked())
441     return false;
442
443   if ( !SelectorWdg->IsAnythingSelected() || myPath->_is_nil() )
444     return false;
445
446   if (!isValid())
447     return false;
448
449   if (StartPointLineEdit->text().trimmed().isEmpty()) {
450     return false;
451   }
452   
453   bool bOk;
454   long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
455   if (!bOk) {
456     return false;
457   }
458
459   QStringList aParameters;
460   
461   //get angles
462   SMESH::double_array_var anAngles = getAngles(); 
463   for (int i = 0; i < myAnglesList.count(); i++)
464     aParameters << AnglesList->item(i)->text();
465
466   // get base point
467   SMESH::PointStruct aBasePoint;
468   if (BasePointGrp->isChecked()) {
469     aBasePoint.x = XSpin->GetValue();
470     aBasePoint.y = YSpin->GetValue();
471     aBasePoint.z = ZSpin->GetValue();
472   }
473   aParameters << XSpin->text();
474   aParameters << YSpin->text();
475   aParameters << ZSpin->text();
476
477   //get scales
478   SMESH::double_array_var aScales = getScales();
479   for (int i = 0; i < myScalesList.count(); i++)
480     aParameters << ScalesList->item(i)->text();
481
482   bool meshHadNewTypeBefore = true;
483   int  maxSelType = 0;
484   const bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
485
486   try {
487     SUIT_OverrideCursor wc;
488
489     SMESH::SMESH_Mesh_var mesh = SelectorWdg->GetMesh();
490
491     mesh->SetParameters( aParameters.join(":").toUtf8().constData() );
492
493     SMESH::ListOfIDSources_var nodes = new SMESH::ListOfIDSources();
494     SMESH::ListOfIDSources_var edges = new SMESH::ListOfIDSources();
495     SMESH::ListOfIDSources_var faces = new SMESH::ListOfIDSources();
496     maxSelType = SelectorWdg->GetSelected( nodes, edges, faces );
497
498     // is it necessary to switch on the next Display Mode?
499     SMESH::ElementType newType = (SMESH::ElementType)( maxSelType + 1 );
500     SMESH::array_of_ElementType_var oldTypes = mesh->GetTypes();
501     meshHadNewTypeBefore = false;
502     for ( size_t i = 0; i < oldTypes->length() && !meshHadNewTypeBefore; ++i )
503       meshHadNewTypeBefore = ( oldTypes[i] >= newType );
504
505     SMESH::SMESH_MeshEditor_var aMeshEditor = mesh->GetMeshEditor();
506     SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
507
508     SMESH::ListOfGroups_var groups =
509       aMeshEditor->ExtrusionAlongPathObjects( nodes, edges, faces, myPath,
510                                               GEOM::GEOM_Object::_nil(),
511                                               aNodeStart, AnglesGrp->isChecked(),
512                                               anAngles, LinearAnglesCheck->isChecked(),
513                                               BasePointGrp->isChecked(), aBasePoint, makeGroups,
514                                               aScales, LinearScalesCheck->isChecked(), retVal );
515
516     wc.suspend();
517     switch (retVal) {
518     case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS:
519       SUIT_MessageBox::warning(this,
520                                tr("SMESH_ERROR"),
521                                tr("NO_ELEMENTS_SELECTED"));
522       return false; break;
523     case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE:
524       SUIT_MessageBox::warning(this,
525                                tr("SMESH_ERROR"),
526                                tr("SELECTED_PATH_IS_NOT_EDGE"));
527       return false; break;
528     case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE:
529       SUIT_MessageBox::warning(this,
530                                tr("SMESH_ERROR"),
531                                tr("BAD_SHAPE_TYPE"));
532       return false; break;
533     case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE:
534       SUIT_MessageBox::warning(this,
535                                tr("SMESH_ERROR"),
536                                tr("EXTR_BAD_STARTING_NODE"));
537       return false; break;
538     case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER:
539       SUIT_MessageBox::warning(this,
540                                tr("SMESH_ERROR"),
541                                tr("WRONG_ANGLES_NUMBER"));
542       return false; break;
543     case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT:
544       SUIT_MessageBox::warning(this,
545                                tr("SMESH_ERROR"),
546                                tr("CANT_GET_TANGENT"));
547       return false; break;
548     case SMESH::SMESH_MeshEditor::EXTR_OK:
549       break;
550     }
551   } catch (...) {
552     return false;
553   }
554
555   SMESH_Actor* actor = SelectorWdg->GetActor();
556   if ( actor && !meshHadNewTypeBefore )
557   {
558     unsigned int aMode = actor->GetEntityMode();
559     switch ( maxSelType ) {
560     case SMESH::NODE: // extrude node -> edges
561       actor->SetRepresentation(SMESH_Actor::eEdge);
562       actor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break;
563     case SMESH::EDGE: // edge -> faces
564       actor->SetRepresentation(SMESH_Actor::eSurface);
565       actor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break;
566     case SMESH::FACE: // faces -> volumes
567       actor->SetRepresentation(SMESH_Actor::eSurface);
568       actor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break;
569     }
570   }
571   if ( actor )
572     SMESH::Update( actor->getIO(), actor->GetVisibility() );
573   if ( makeGroups )
574     mySMESHGUI->updateObjBrowser(true); // new groups may appear
575   Init(false);
576   mySelectionMgr->clearSelected();
577   SelectorWdg->Clear();
578
579   SMESHGUI::Modified();
580   return true;
581 }
582
583 //=================================================================================
584 // function : ClickOnOk()
585 // purpose  : Called when user presses <OK> button
586 //=================================================================================
587 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
588 {
589   if (ClickOnApply())
590     reject();
591 }
592
593 //=================================================================================
594 // function : ClickOnHelp()
595 // purpose  :
596 //=================================================================================
597 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnHelp()
598 {
599   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
600   if (app) 
601     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
602   else {
603     QString platform;
604 #ifdef WIN32
605     platform = "winapplication";
606 #else
607     platform = "application";
608 #endif
609     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
610                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
611                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
612                                                                  platform)).
613                              arg(myHelpFileName));
614   }
615 }
616
617 //=================================================================================
618 // function : reject()
619 // purpose  : Called when dialog box is closed
620 //=================================================================================
621 void SMESHGUI_ExtrusionAlongPathDlg::reject()
622 {
623   disconnect(mySelectionMgr, 0, this, 0);
624   mySelectionMgr->clearFilters();
625   //mySelectionMgr->clearSelected();
626   if (SMESH::GetCurrentVtkView()) {
627     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
628     SMESH::SetPointRepresentation(false);
629     SMESH::SetPickable();
630   }
631   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
632     aViewWindow->SetSelectionMode(ActorSelection);
633   mySMESHGUI->ResetState();
634
635   QDialog::reject();
636 }
637
638 //=================================================================================
639 // function : onOpenView()
640 // purpose  :
641 //=================================================================================
642 void SMESHGUI_ExtrusionAlongPathDlg::onOpenView()
643 {
644   if ( mySelector ) {
645     SMESH::SetPointRepresentation(false);
646   }
647   else {
648     mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
649     ActivateThisDialog();
650   }
651 }
652
653 //=================================================================================
654 // function : onCloseView()
655 // purpose  :
656 //=================================================================================
657 void SMESHGUI_ExtrusionAlongPathDlg::onCloseView()
658 {
659   DeactivateActiveDialog();
660   mySelector = 0;
661 }
662
663 //=======================================================================
664 // function : onTextChange()
665 // purpose  :
666 //=======================================================================
667 void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText)
668 {
669   QLineEdit* send = (QLineEdit*)sender();
670
671   // return if busy
672   if (myBusy) return;
673
674   // set busy flag
675   SetBusy sb (this);
676
677   if (send == StartPointLineEdit &&
678       myEditCurrentArgument == StartPointLineEdit)
679   {
680     if (!myPath->_is_nil()) {
681       SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
682       SMDS_Mesh* aMesh = aPathActor ? aPathActor->GetObject()->GetMesh() : 0;
683       if (aMesh) {
684         SALOME_ListIO aList;
685         aList.Append(aPathActor->getIO());
686         mySelectionMgr->setSelectedObjects(aList, false);
687
688         bool bOk;
689         long ind = theNewText.toLong(&bOk);
690         if (bOk) {
691           const SMDS_MeshNode* n = aMesh->FindNode(ind);
692           if (n) {
693             SVTK_TVtkIDsMap newIndices;
694             newIndices.Add(n->GetID());
695             mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false );
696             if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
697               aViewWindow->highlight( aPathActor->getIO(), true, true );
698           }
699         }
700       }
701     }
702   }
703   CheckIsEnable();
704   onDisplaySimulation(true);
705 }
706
707 //=================================================================================
708 // function : SelectionIntoArgument()
709 // purpose  : Called when selection as changed or other case
710 //=================================================================================
711 void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
712 {
713   if (myBusy) return;
714
715   // return if dialog box is inactive
716   if (!GroupButtons->isEnabled())
717     return;
718
719   // selected objects count
720   const SALOME_ListIO& aList = mySelector->StoredIObjects();
721   int nbSel = aList.Extent();
722   if (nbSel != 1)
723     return;
724
725   // set busy flag
726   SetBusy sb (this);
727
728   const bool isPathDef = ( SelectPathMeshButton->isChecked() ||
729                            SelectStartPointButton->isChecked() );
730
731   if (myEditCurrentArgument == PathMeshLineEdit && isPathDef)
732   {
733     // we are now selecting path mesh
734     // reset
735     PathMeshLineEdit->clear();
736     myPath = SMESH::SMESH_IDSource::_nil();
737     StartPointLineEdit->clear();
738
739     // try to get mesh from selection
740     Handle(SALOME_InteractiveObject) IO = aList.First();
741     myPath = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
742     if( myPath->_is_nil() )
743       return;
744
745     QString aString;
746     SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
747     PathMeshLineEdit->setText(aString);
748   }
749   else if (myEditCurrentArgument == StartPointLineEdit && isPathDef )
750   {
751     // we are now selecting start point of path
752     // reset
753     StartPointLineEdit->clear();
754
755     // return if path mesh or path shape is not yet selected
756     if( myPath->_is_nil() )
757       return;
758
759     // try to get shape from selection
760     Handle(SALOME_InteractiveObject) IO = aList.First();
761
762     SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
763     if ( !aPathActor )
764       return;
765
766     QString aString;
767     int aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aPathActor->getIO(), aString);
768     if (aNbUnits == 1)
769       StartPointLineEdit->setText(aString.trimmed());
770   }
771   else if ( myEditCurrentArgument == XSpin &&
772             SelectBasePointButton->isChecked() )
773   {
774     // we are now selecting base point
775     // reset is not performed here!
776
777     // return if is not enabled
778     if (!BasePointGrp->isChecked())
779       return;
780
781     // try to get shape from selection
782     Handle(SALOME_InteractiveObject) IO = aList.First();
783
784     // check if geom vertex is selected
785     GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO);
786     TopoDS_Vertex aVertex;
787     if (!aGeomObj->_is_nil()) {
788       if (aGeomObj->IsShape() && GEOMBase::GetShape(aGeomObj, aVertex) && !aVertex.IsNull()) {
789         gp_Pnt aPnt = BRep_Tool::Pnt(aVertex);
790         XSpin->SetValue(aPnt.X());
791         YSpin->SetValue(aPnt.Y());
792         ZSpin->SetValue(aPnt.Z());
793       }
794       return;
795     }
796
797     // check if smesh node is selected
798     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(IO);
799     if (aMesh->_is_nil())
800       return;
801
802     QString aString;
803     int aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
804     // return if more than one node is selected
805     if (aNbUnits != 1)
806       return;
807
808     SMESH_Actor* aMeshActor = SMESH::FindActorByObject(aMesh);
809     if (!aMeshActor)
810       return;
811
812     SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
813     if (!mesh)
814       return;
815
816     const SMDS_MeshNode* n = mesh->FindNode(aString.toLong());
817     if (!n)
818       return;
819
820     XSpin->SetValue(n->X());
821     YSpin->SetValue(n->Y());
822     ZSpin->SetValue(n->Z());
823   }
824   else
825   {
826     return;
827   }
828
829   onDisplaySimulation(true);
830   CheckIsEnable();
831 }
832
833 //=================================================================================
834 // function : SetEditCurrentArgument()
835 // purpose  :
836 //=================================================================================
837 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
838 {
839   QPushButton* send = (QPushButton*)sender();
840   if ( sender() == BasePointGrp )
841     send = SelectBasePointButton;
842   if (send != SelectPathMeshButton   &&
843       send != SelectStartPointButton &&
844       send != SelectBasePointButton)
845     return;
846   SetEditCurrentArgument(send);
847 }
848
849 //=================================================================================
850 // function : SetEditCurrentArgument()
851 // purpose  :
852 //=================================================================================
853 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QPushButton* button)
854 {
855   disconnect(mySelectionMgr, 0, this, 0);
856   //  mySelectionMgr->clearSelected();
857   mySelectionMgr->clearFilters();
858   SMESH::SetPickable();
859
860   myEditCurrentArgument = 0;
861   if (button == SelectPathMeshButton)
862   {
863     myEditCurrentArgument = PathMeshLineEdit;
864     SMESH::SetPointRepresentation(false);
865     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
866       aViewWindow->SetSelectionMode(ActorSelection);
867     mySelectionMgr->installFilter(myPathMeshFilter);
868   }
869   else if (button == SelectStartPointButton)
870   {
871     myEditCurrentArgument = StartPointLineEdit;
872     if (!myPath->_is_nil()) {
873       SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
874       if (aPathActor) {
875         aPathActor->SetPointRepresentation( true );
876         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
877           aViewWindow->SetSelectionMode(NodeSelection);
878         SMESH::SetPickable(aPathActor);
879       }
880     }
881   }
882   else if (button == SelectBasePointButton)
883   {
884     myEditCurrentArgument = XSpin;
885     SMESH::SetPointRepresentation(true);
886     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
887       aViewWindow->SetSelectionMode(NodeSelection);
888
889     SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter(SMESH::IDSOURCE);
890     SMESH_NumberFilter* aVertexFilter      = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE,
891                                                                      -1, TopAbs_VERTEX);
892     QList<SUIT_SelectionFilter*> aListOfFilters;
893     if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
894     if (aVertexFilter)        aListOfFilters.append(aVertexFilter);
895
896     mySelectionMgr->installFilter(new SMESH_LogicalFilter
897                                   (aListOfFilters, SMESH_LogicalFilter::LO_OR, true));
898   }
899
900   if (myEditCurrentArgument && !myEditCurrentArgument->hasFocus())
901     myEditCurrentArgument->setFocus();
902
903   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
904   SelectionIntoArgument();
905 }
906
907 //=================================================================================
908 // function : DeactivateActiveDialog()
909 // purpose  : Deactivates this dialog
910 //=================================================================================
911 void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
912 {
913   if (GroupButtons->isEnabled())
914   {
915     GroupArguments->setEnabled(false);
916     GroupButtons->setEnabled(false);
917     SelectorWdg->setEnabled(false);
918     mySMESHGUI->ResetState();
919     mySMESHGUI->SetActiveDialogBox(0);
920   }
921 }
922
923 //=================================================================================
924 // function : ActivateThisDialog()
925 // purpose  : Activates this dialog
926 //=================================================================================
927 void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
928 {
929   // Emit a signal to deactivate the active dialog
930   mySMESHGUI->EmitSignalDeactivateDialog();
931   GroupArguments->setEnabled(true);
932   GroupButtons->setEnabled(true);
933   SelectorWdg->setEnabled(true);
934
935   mySMESHGUI->SetActiveDialogBox(this);
936   SelectionIntoArgument();
937 }
938
939 //=================================================================================
940 // function : enterEvent()
941 // purpose  :
942 //=================================================================================
943 void SMESHGUI_ExtrusionAlongPathDlg::enterEvent (QEvent*)
944 {
945   if ( !GroupButtons->isEnabled() ) {
946     SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
947     if ( aViewWindow && !mySelector) {
948       mySelector = aViewWindow->GetSelector();
949     }
950     ActivateThisDialog();
951   }
952 }
953
954 //=======================================================================
955 // function : OnAngleAdded()
956 // purpose  : Called when user adds angle to the list
957 //=======================================================================
958 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
959 {
960   if ( sender() == AddAngleButton )
961   {
962     QString msg;
963     if( !AngleSpin->isValid( msg, true ) ) {
964       QString str( tr( "SMESH_INCORRECT_INPUT" ) );
965       if ( !msg.isEmpty() )
966         str += "\n" + msg;
967       SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
968       return;
969     }
970     AnglesList->addItem(AngleSpin->text());
971     myAnglesList.append(AngleSpin->GetValue());
972   }
973   
974   if ( sender() == AddScaleButton )
975   {
976     QString msg;
977     if( !ScaleSpin->isValid( msg, true ) ) {
978       QString str( tr( "SMESH_INCORRECT_INPUT" ) );
979       if ( !msg.isEmpty() )
980         str += "\n" + msg;
981       SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
982       return;
983     }
984     ScalesList->addItem(ScaleSpin->text());
985     myScalesList.append(ScaleSpin->GetValue());
986   }
987   
988   updateLinearAngles();
989 }
990
991 //=======================================================================
992 // function : OnAngleRemoved()
993 // purpose  : Called when user removes angle(s) from the list
994 //=======================================================================
995 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
996 {
997   QListWidget* widget;
998   QList<double>* list;
999   if ( sender() == RemoveScaleButton )
1000   {
1001     widget = ScalesList;
1002     list   = & myScalesList;
1003   }
1004   else
1005   {
1006     widget = AnglesList;
1007     list   = & myAnglesList;
1008   }
1009
1010   QList<QListWidgetItem*> aList = widget->selectedItems();
1011   QListWidgetItem* anItem;
1012   foreach(anItem, aList) {
1013     list->removeAt( widget->row( anItem ));
1014     delete anItem;
1015   }
1016
1017   updateLinearAngles();
1018 }
1019
1020 //=================================================================================
1021 // function : eventFilter()
1022 // purpose  : event filter ???
1023 //=================================================================================
1024 bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter (QObject* object, QEvent* event)
1025 {
1026   if (event->type() == QEvent::KeyPress) {
1027     QKeyEvent* ke = (QKeyEvent*)event;
1028     if (object == AnglesList) {
1029       if (ke->key() == Qt::Key_Delete)
1030         RemoveAngleButton->click();
1031     }
1032     if (object == ScalesList) {
1033       if (ke->key() == Qt::Key_Delete)
1034         RemoveScaleButton->click();
1035     }
1036   }
1037   else if (event->type() == QEvent::FocusIn) {
1038     if (object == StartPointLineEdit) {
1039       if (myEditCurrentArgument != StartPointLineEdit)
1040         SetEditCurrentArgument(SelectStartPointButton);
1041     }
1042     else if (object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor()) {
1043       if (myEditCurrentArgument != XSpin)
1044         SetEditCurrentArgument(SelectBasePointButton);
1045     }
1046   }
1047   return QDialog::eventFilter(object, event);
1048 }
1049
1050 //=================================================================================
1051 // function : keyPressEvent()
1052 // purpose  :
1053 //=================================================================================
1054 void SMESHGUI_ExtrusionAlongPathDlg::keyPressEvent( QKeyEvent* e )
1055 {
1056   QDialog::keyPressEvent( e );
1057   if ( e->isAccepted() )
1058     return;
1059
1060   if ( e->key() == Qt::Key_F1 ) {
1061     e->accept();
1062     ClickOnHelp();
1063   }
1064 }
1065
1066 //=================================================================================
1067 // function : isValid
1068 // purpose  :
1069 //=================================================================================
1070 bool SMESHGUI_ExtrusionAlongPathDlg::isValid()
1071 {
1072   QString msg;
1073   bool ok = true;
1074   ok = XSpin->isValid( msg, true ) && ok;
1075   ok = YSpin->isValid( msg, true ) && ok;
1076   ok = ZSpin->isValid( msg, true ) && ok;
1077
1078   if( !ok ) {
1079     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1080     if ( !msg.isEmpty() )
1081       str += "\n" + msg;
1082     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1083     return false;
1084   }
1085   return true;
1086 }
1087
1088 //=================================================================================
1089 // function : updateLinearAngles
1090 // purpose  :
1091 //=================================================================================
1092 void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles()
1093 {
1094   bool enableLinear = true;
1095   for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) {
1096     if( QListWidgetItem* anItem = AnglesList->item( row ) ) {
1097       enableLinear = false;
1098       anItem->text().toDouble(&enableLinear);
1099       if( !enableLinear )
1100         break;
1101     }
1102   }
1103   if( !enableLinear )
1104     LinearAnglesCheck->setChecked( false );
1105   LinearAnglesCheck->setEnabled( enableLinear );
1106
1107   enableLinear = true;
1108   for( int row = 0, nbRows = ScalesList->count(); row < nbRows; row++ ) {
1109     if( QListWidgetItem* anItem = ScalesList->item( row ) ) {
1110       enableLinear = false;
1111       anItem->text().toDouble(&enableLinear);
1112       if( !enableLinear )
1113         break;
1114     }
1115   }
1116   if( !enableLinear )
1117     LinearScalesCheck->setChecked( false );
1118   LinearScalesCheck->setEnabled( enableLinear );
1119 }
1120
1121 //=================================================================================
1122 // function : isValuesValid()
1123 // purpose  : Return true in case if values entered into dialog are valid
1124 //=================================================================================
1125
1126 bool SMESHGUI_ExtrusionAlongPathDlg::isValuesValid()
1127
1128   if ( myPath->_is_nil() )
1129     return false;
1130   
1131   bool bOk;
1132   long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
1133   if ( !bOk || aNodeStart < 1 )
1134     return false;
1135
1136   SMESH::SMESH_Mesh_var mesh = myPath->GetMesh();
1137   if ( mesh->_is_nil() )
1138     return false;
1139
1140   SMESH::ElementType type = mesh->GetElementType( aNodeStart, false );
1141   if ( type != SMESH::NODE )
1142     return false;
1143
1144   if ( mesh->HasShapeToMesh() )
1145   {
1146     SMESH::NodePosition_var pos = mesh->GetNodePosition( aNodeStart );
1147     if ( pos->shapeType != GEOM::VERTEX )
1148       return false;
1149   }
1150   else
1151   {
1152     SMESH::smIdType_array_var elems = mesh->GetNodeInverseElements( aNodeStart, SMESH::ALL );
1153     if ( elems->length() != 1 ||
1154          mesh->GetElementType( elems[0], true ) != SMESH::EDGE )
1155       return false;
1156   }
1157   return true;
1158 }
1159
1160 //=================================================================================
1161 // function : onDisplaySimulation
1162 // purpose  : Show/Hide preview
1163 //=================================================================================
1164
1165 void SMESHGUI_ExtrusionAlongPathDlg::onDisplaySimulation( bool toDisplayPreview )
1166 {
1167   if ( myPreviewCheckBox->isChecked() && toDisplayPreview ) {
1168     if ( SelectorWdg->IsAnythingSelected() && isValid() && isValuesValid())
1169     {
1170       // get angles and scales
1171       SMESH::double_array_var anAngles = getAngles();
1172       SMESH::double_array_var aScales  = getScales();
1173
1174       // get base point
1175       SMESH::PointStruct aBasePoint;
1176       if (BasePointGrp->isChecked()) {
1177         aBasePoint.x = XSpin->GetValue();
1178         aBasePoint.y = YSpin->GetValue();
1179         aBasePoint.z = ZSpin->GetValue();
1180       }
1181       bool bOk;
1182       long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
1183       if (bOk) {
1184
1185         try {
1186           SUIT_OverrideCursor wc;
1187
1188           SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
1189           SMESH::SMESH_Mesh_var             mesh = SelectorWdg->GetMesh();
1190           SMESH::SMESH_MeshEditor_var meshEditor = mesh->GetMeshEditPreviewer();
1191
1192           SMESH::ListOfIDSources_var nodes = new SMESH::ListOfIDSources();
1193           SMESH::ListOfIDSources_var edges = new SMESH::ListOfIDSources();
1194           SMESH::ListOfIDSources_var faces = new SMESH::ListOfIDSources();
1195           SelectorWdg->GetSelected( nodes, edges, faces );
1196           const bool makeGroups = false;
1197
1198           SMESH::ListOfGroups_var groups =
1199             meshEditor->ExtrusionAlongPathObjects( nodes, edges, faces, myPath,
1200                                                    GEOM::GEOM_Object::_nil(),
1201                                                    aNodeStart, AnglesGrp->isChecked(),
1202                                                    anAngles, LinearAnglesCheck->isChecked(),
1203                                                    BasePointGrp->isChecked(), aBasePoint,
1204                                                    makeGroups,
1205                                                    aScales, LinearScalesCheck->isChecked(),
1206                                                    retVal);
1207
1208           if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK )
1209           {
1210             SMESH::MeshPreviewStruct_var aMeshPreviewStruct = meshEditor->GetPreviewData();
1211             mySimulation->SetData( aMeshPreviewStruct.in() );
1212           }
1213           else {
1214             hidePreview();
1215           }
1216
1217         } catch (...) {
1218           hidePreview();
1219         }
1220       } else {
1221         hidePreview();
1222       }
1223
1224     } else {
1225       hidePreview();
1226     }
1227   } else {
1228     hidePreview();
1229   }
1230 }
1231
1232 //=======================================================================
1233 //function : getAngles
1234 //purpose  : return CORBA array of angles
1235 //=======================================================================
1236
1237 SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getAngles()
1238 {
1239   SMESH::double_array_var anAngles = new SMESH::double_array;
1240   if ( AnglesGrp->isChecked() )
1241   {
1242     anAngles->length( myAnglesList.count() );
1243     for (int i = 0; i < myAnglesList.count(); i++)
1244       anAngles[ i ] = myAnglesList[ i ] * M_PI / 180.;
1245   }
1246   return anAngles;
1247 }
1248
1249 //=======================================================================
1250 //function : getScales
1251 //purpose  : return CORBA array of scale factors
1252 //=======================================================================
1253
1254 SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getScales()
1255 {
1256   SMESH::double_array_var anScales = new SMESH::double_array;
1257   if ( ScalesGrp->isChecked() )
1258   {
1259     anScales->length( myScalesList.count() );
1260     for (int i = 0; i < myScalesList.count(); i++)
1261       anScales[ i ] = myScalesList[ i ];
1262   }
1263   return anScales;
1264 }