Salome HOME
Copyright update 2020
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ExtrusionAlongPathDlg.cxx
1 // Copyright (C) 2007-2020  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, 1, 2);
268   GroupArgumentsLayout->addWidget(PathGrp,              1, 0, 1, 2);
269   GroupArgumentsLayout->addWidget(BasePointGrp,         2, 0, 1, 2);
270   GroupArgumentsLayout->addWidget(AnglesGrp,            3, 0);
271   GroupArgumentsLayout->addWidget(ScalesGrp,            3, 1);
272   GroupArgumentsLayout->addWidget(myPreviewCheckBox,    4, 0);
273   GroupArgumentsLayout->addWidget(MakeGroupsCheck,      5, 0);
274
275   /***************************************************************/
276   // common buttons group box
277   GroupButtons = new QGroupBox(this);
278   QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
279   GroupButtonsLayout->setSpacing(SPACING); GroupButtonsLayout->setMargin(MARGIN);
280
281   OkButton = new QPushButton(tr("SMESH_BUT_APPLY_AND_CLOSE"), GroupButtons);
282   OkButton->setAutoDefault(true);
283   OkButton->setDefault(true);
284
285   ApplyButton = new QPushButton(tr("SMESH_BUT_APPLY"), GroupButtons); 
286   ApplyButton->setAutoDefault(true);
287
288   CloseButton = new QPushButton(tr("SMESH_BUT_CLOSE"), GroupButtons);
289   CloseButton->setAutoDefault(true);
290
291   HelpButton = new QPushButton(tr("SMESH_BUT_HELP"), GroupButtons);
292   HelpButton->setAutoDefault(true);
293
294   // layouting
295   GroupButtonsLayout->addWidget(OkButton);
296   GroupButtonsLayout->addSpacing(10);
297   GroupButtonsLayout->addWidget(ApplyButton);
298   GroupButtonsLayout->addSpacing(10);
299   GroupButtonsLayout->addStretch();
300   GroupButtonsLayout->addWidget(CloseButton);
301   GroupButtonsLayout->addWidget(HelpButton);
302
303   /***************************************************************/
304   // layouting
305   topLayout->addWidget(GroupArguments);
306   topLayout->addWidget(GroupButtons);
307
308   /***************************************************************/
309   // Initialisations
310   XSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
311   YSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
312   ZSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
313   AngleSpin->RangeStepAndValidator(-180.0, 180.0, 5.0, "angle_precision");
314   ScaleSpin->RangeStepAndValidator(COORD_MIN, COORD_MAX, 1.0, "length_precision");
315
316   mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
317
318   mySMESHGUI->SetActiveDialogBox(this);
319
320   myPathMeshFilter = new SMESH_TypeFilter(SMESH::IDSOURCE_EDGE);
321
322   myHelpFileName = "extrusion_along_path.html";
323
324   Init();
325
326   /***************************************************************/
327   // signals-slots connections
328   connect(OkButton,     SIGNAL(clicked()), this, SLOT(ClickOnOk()));
329   connect(CloseButton,  SIGNAL(clicked()), this, SLOT(reject()));
330   connect(ApplyButton,  SIGNAL(clicked()), this, SLOT(ClickOnApply()));
331   connect(HelpButton,   SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
332
333   connect(AddAngleButton,    SIGNAL(clicked()), this, SLOT(OnAngleAdded()));
334   connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved()));
335   connect(AddScaleButton,    SIGNAL(clicked()), this, SLOT(OnAngleAdded()));
336   connect(RemoveScaleButton, SIGNAL(clicked()), this, SLOT(OnAngleRemoved()));
337
338   connect(SelectPathMeshButton,   SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
339   connect(SelectStartPointButton, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
340   connect(SelectBasePointButton,  SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
341   connect(BasePointGrp,       SIGNAL(toggled(bool)), this, SLOT(SetEditCurrentArgument()));
342
343   connect(mySMESHGUI,  SIGNAL(SignalCloseAllDialogs()),        SLOT(reject()));
344   connect(mySMESHGUI,  SIGNAL(SignalActivatedViewManager()),   SLOT(onOpenView()));
345   connect(mySMESHGUI,  SIGNAL(SignalCloseView()),              SLOT(onCloseView()));
346   connect(mySMESHGUI,  SIGNAL(SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
347   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()),   SLOT(SelectionIntoArgument()));
348   connect(SelectorWdg,    SIGNAL(selectionChanged()), this,    SLOT(toDisplaySimulation()));
349   connect(SelectorWdg,    SIGNAL(selectionChanged()), this,    SLOT(CheckIsEnable()));
350
351   connect(StartPointLineEdit, SIGNAL(textChanged(const QString&)),
352           SLOT(onTextChange(const QString&)));
353
354   connect(XSpin,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
355   connect(YSpin,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
356   connect(ZSpin,  SIGNAL(valueChanged(double)), this, SLOT(toDisplaySimulation()));
357   connect(AddAngleButton,    SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
358   connect(RemoveAngleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
359   connect(AddScaleButton,    SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
360   connect(RemoveScaleButton, SIGNAL(clicked()), this, SLOT(toDisplaySimulation()));
361   connect(LinearScalesCheck, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation()));
362   connect(LinearAnglesCheck, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation()));
363   connect(ScalesGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation()));
364   connect(AnglesGrp, SIGNAL(toggled(bool)), this, SLOT(toDisplaySimulation()));
365
366
367   //To Connect preview check box
368   connectPreviewControl();
369
370   AnglesList        ->installEventFilter(this);
371   ScalesList        ->installEventFilter(this);
372   StartPointLineEdit->installEventFilter(this);
373   XSpin->editor()   ->installEventFilter(this);
374   YSpin->editor()   ->installEventFilter(this);
375   ZSpin->editor()   ->installEventFilter(this);
376
377   CheckIsEnable();
378
379   resize( minimumSizeHint() );
380 }
381
382 //=================================================================================
383 // function : ~SMESHGUI_ExtrusionAlongPathDlg()
384 // purpose  : destructor
385 //=================================================================================
386 SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
387 {
388   // no need to delete child widgets, Qt does it all for us
389 }
390
391 //=================================================================================
392 // function : Init()
393 // purpose  : initialization
394 //=================================================================================
395 void SMESHGUI_ExtrusionAlongPathDlg::Init (bool ResetControls)
396 {
397   myBusy = false;
398   myEditCurrentArgument = 0;
399
400   myPath = SMESH::SMESH_IDSource::_nil();
401
402   SelectorWdg->Clear();
403   PathMeshLineEdit->clear();
404   StartPointLineEdit->clear();
405
406   if (ResetControls) {
407     XSpin->SetValue(0.0);
408     YSpin->SetValue(0.0);
409     ZSpin->SetValue(0.0);
410
411     AngleSpin->SetValue(45);
412     ScaleSpin->SetValue(2);
413     myPreviewCheckBox->setChecked(false);
414     onDisplaySimulation(false);
415   }
416   SetEditCurrentArgument(0);
417 }
418
419 //=================================================================================
420 // function : CheckIsEnable()
421 // purpose  : Check whether the Ok and Apply buttons should be enabled or not
422 //=================================================================================
423
424 void SMESHGUI_ExtrusionAlongPathDlg::CheckIsEnable()
425 {  
426   bool anIsEnable = SelectorWdg->IsAnythingSelected() && isValuesValid();
427
428   OkButton->setEnabled(anIsEnable);
429   ApplyButton->setEnabled(anIsEnable);
430 }
431
432 //=================================================================================
433 // function : ClickOnApply()
434 // purpose  : Called when user presses <Apply> button
435 //=================================================================================
436 bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
437 {
438   if (SMESHGUI::isStudyLocked())
439     return false;
440
441   if ( !SelectorWdg->IsAnythingSelected() || myPath->_is_nil() )
442     return false;
443
444   if (!isValid())
445     return false;
446
447   if (StartPointLineEdit->text().trimmed().isEmpty()) {
448     return false;
449   }
450   
451   bool bOk;
452   long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
453   if (!bOk) {
454     return false;
455   }
456
457   QStringList aParameters;
458   
459   //get angles
460   SMESH::double_array_var anAngles = getAngles(); 
461   for (int i = 0; i < myAnglesList.count(); i++)
462     aParameters << AnglesList->item(i)->text();
463
464   // get base point
465   SMESH::PointStruct aBasePoint;
466   if (BasePointGrp->isChecked()) {
467     aBasePoint.x = XSpin->GetValue();
468     aBasePoint.y = YSpin->GetValue();
469     aBasePoint.z = ZSpin->GetValue();
470   }
471   aParameters << XSpin->text();
472   aParameters << YSpin->text();
473   aParameters << ZSpin->text();
474
475   //get scales
476   SMESH::double_array_var aScales = getScales();
477   for (int i = 0; i < myScalesList.count(); i++)
478     aParameters << ScalesList->item(i)->text();
479
480   bool meshHadNewTypeBefore = true;
481   int  maxSelType = 0;
482   const bool makeGroups = ( MakeGroupsCheck->isEnabled() && MakeGroupsCheck->isChecked() );
483
484   try {
485     SUIT_OverrideCursor wc;
486
487     SMESH::SMESH_Mesh_var mesh = SelectorWdg->GetMesh();
488
489     mesh->SetParameters( aParameters.join(":").toUtf8().constData() );
490
491     SMESH::ListOfIDSources_var nodes = new SMESH::ListOfIDSources();
492     SMESH::ListOfIDSources_var edges = new SMESH::ListOfIDSources();
493     SMESH::ListOfIDSources_var faces = new SMESH::ListOfIDSources();
494     maxSelType = SelectorWdg->GetSelected( nodes, edges, faces );
495
496     // is it necessary to switch on the next Display Mode?
497     SMESH::ElementType newType = (SMESH::ElementType)( maxSelType + 1 );
498     SMESH::array_of_ElementType_var oldTypes = mesh->GetTypes();
499     meshHadNewTypeBefore = false;
500     for ( size_t i = 0; i < oldTypes->length() && !meshHadNewTypeBefore; ++i )
501       meshHadNewTypeBefore = ( oldTypes[i] >= newType );
502
503     SMESH::SMESH_MeshEditor_var aMeshEditor = mesh->GetMeshEditor();
504     SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
505
506     SMESH::ListOfGroups_var groups =
507       aMeshEditor->ExtrusionAlongPathObjects( nodes, edges, faces, myPath,
508                                               GEOM::GEOM_Object::_nil(),
509                                               aNodeStart, AnglesGrp->isChecked(),
510                                               anAngles, LinearAnglesCheck->isChecked(),
511                                               BasePointGrp->isChecked(), aBasePoint, makeGroups,
512                                               aScales, LinearScalesCheck->isChecked(), retVal );
513
514     wc.suspend();
515     switch (retVal) {
516     case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS:
517       SUIT_MessageBox::warning(this,
518                                tr("SMESH_ERROR"),
519                                tr("NO_ELEMENTS_SELECTED"));
520       return false; break;
521     case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE:
522       SUIT_MessageBox::warning(this,
523                                tr("SMESH_ERROR"),
524                                tr("SELECTED_PATH_IS_NOT_EDGE"));
525       return false; break;
526     case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE:
527       SUIT_MessageBox::warning(this,
528                                tr("SMESH_ERROR"),
529                                tr("BAD_SHAPE_TYPE"));
530       return false; break;
531     case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE:
532       SUIT_MessageBox::warning(this,
533                                tr("SMESH_ERROR"),
534                                tr("EXTR_BAD_STARTING_NODE"));
535       return false; break;
536     case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER:
537       SUIT_MessageBox::warning(this,
538                                tr("SMESH_ERROR"),
539                                tr("WRONG_ANGLES_NUMBER"));
540       return false; break;
541     case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT:
542       SUIT_MessageBox::warning(this,
543                                tr("SMESH_ERROR"),
544                                tr("CANT_GET_TANGENT"));
545       return false; break;
546     case SMESH::SMESH_MeshEditor::EXTR_OK:
547       break;
548     }
549   } catch (...) {
550     return false;
551   }
552
553   SMESH_Actor* actor = SelectorWdg->GetActor();
554   if ( actor && !meshHadNewTypeBefore )
555   {
556     unsigned int aMode = actor->GetEntityMode();
557     switch ( maxSelType ) {
558     case SMESH::NODE: // extrude node -> edges
559       actor->SetRepresentation(SMESH_Actor::eEdge);
560       actor->SetEntityMode( aMode |= SMESH_Actor::eEdges ); break;
561     case SMESH::EDGE: // edge -> faces
562       actor->SetRepresentation(SMESH_Actor::eSurface);
563       actor->SetEntityMode( aMode |= SMESH_Actor::eFaces ); break;
564     case SMESH::FACE: // faces -> volumes
565       actor->SetRepresentation(SMESH_Actor::eSurface);
566       actor->SetEntityMode( aMode |= SMESH_Actor::eVolumes ); break;
567     }
568   }
569   if ( actor )
570     SMESH::Update( actor->getIO(), actor->GetVisibility() );
571   if ( makeGroups )
572     mySMESHGUI->updateObjBrowser(true); // new groups may appear
573   Init(false);
574   mySelectionMgr->clearSelected();
575   SelectorWdg->Clear();
576
577   SMESHGUI::Modified();
578   return true;
579 }
580
581 //=================================================================================
582 // function : ClickOnOk()
583 // purpose  : Called when user presses <OK> button
584 //=================================================================================
585 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
586 {
587   if (ClickOnApply())
588     reject();
589 }
590
591 //=================================================================================
592 // function : ClickOnHelp()
593 // purpose  :
594 //=================================================================================
595 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnHelp()
596 {
597   LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
598   if (app) 
599     app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
600   else {
601     QString platform;
602 #ifdef WIN32
603     platform = "winapplication";
604 #else
605     platform = "application";
606 #endif
607     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
608                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
609                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
610                                                                  platform)).
611                              arg(myHelpFileName));
612   }
613 }
614
615 //=================================================================================
616 // function : reject()
617 // purpose  : Called when dialog box is closed
618 //=================================================================================
619 void SMESHGUI_ExtrusionAlongPathDlg::reject()
620 {
621   disconnect(mySelectionMgr, 0, this, 0);
622   mySelectionMgr->clearFilters();
623   //mySelectionMgr->clearSelected();
624   if (SMESH::GetCurrentVtkView()) {
625     SMESH::RemoveFilters(); // PAL6938 -- clean all mesh entity filters
626     SMESH::SetPointRepresentation(false);
627     SMESH::SetPickable();
628   }
629   if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
630     aViewWindow->SetSelectionMode(ActorSelection);
631   mySMESHGUI->ResetState();
632
633   QDialog::reject();
634 }
635
636 //=================================================================================
637 // function : onOpenView()
638 // purpose  :
639 //=================================================================================
640 void SMESHGUI_ExtrusionAlongPathDlg::onOpenView()
641 {
642   if ( mySelector ) {
643     SMESH::SetPointRepresentation(false);
644   }
645   else {
646     mySelector = SMESH::GetViewWindow( mySMESHGUI )->GetSelector();
647     ActivateThisDialog();
648   }
649 }
650
651 //=================================================================================
652 // function : onCloseView()
653 // purpose  :
654 //=================================================================================
655 void SMESHGUI_ExtrusionAlongPathDlg::onCloseView()
656 {
657   DeactivateActiveDialog();
658   mySelector = 0;
659 }
660
661 //=======================================================================
662 // function : onTextChange()
663 // purpose  :
664 //=======================================================================
665 void SMESHGUI_ExtrusionAlongPathDlg::onTextChange (const QString& theNewText)
666 {
667   QLineEdit* send = (QLineEdit*)sender();
668
669   // return if busy
670   if (myBusy) return;
671
672   // set busy flag
673   SetBusy sb (this);
674
675   if (send == StartPointLineEdit &&
676       myEditCurrentArgument == StartPointLineEdit)
677   {
678     if (!myPath->_is_nil()) {
679       SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
680       SMDS_Mesh* aMesh = aPathActor ? aPathActor->GetObject()->GetMesh() : 0;
681       if (aMesh) {
682         SALOME_ListIO aList;
683         aList.Append(aPathActor->getIO());
684         mySelectionMgr->setSelectedObjects(aList, false);
685
686         bool bOk;
687         long ind = theNewText.toLong(&bOk);
688         if (bOk) {
689           const SMDS_MeshNode* n = aMesh->FindNode(ind);
690           if (n) {
691             TColStd_MapOfInteger newIndices;
692             newIndices.Add(n->GetID());
693             mySelector->AddOrRemoveIndex( aPathActor->getIO(), newIndices, false );
694             if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
695               aViewWindow->highlight( aPathActor->getIO(), true, true );
696           }
697         }
698       }
699     }
700   }
701   CheckIsEnable();
702   onDisplaySimulation(true);
703 }
704
705 //=================================================================================
706 // function : SelectionIntoArgument()
707 // purpose  : Called when selection as changed or other case
708 //=================================================================================
709 void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
710 {
711   if (myBusy) return;
712
713   // return if dialog box is inactive
714   if (!GroupButtons->isEnabled())
715     return;
716
717   // selected objects count
718   const SALOME_ListIO& aList = mySelector->StoredIObjects();
719   int nbSel = aList.Extent();
720   if (nbSel != 1)
721     return;
722
723   // set busy flag
724   SetBusy sb (this);
725
726   const bool isPathDef = ( SelectPathMeshButton->isChecked() ||
727                            SelectStartPointButton->isChecked() );
728
729   if (myEditCurrentArgument == PathMeshLineEdit && isPathDef)
730   {
731     // we are now selecting path mesh
732     // reset
733     PathMeshLineEdit->clear();
734     myPath = SMESH::SMESH_IDSource::_nil();
735     StartPointLineEdit->clear();
736
737     // try to get mesh from selection
738     Handle(SALOME_InteractiveObject) IO = aList.First();
739     myPath = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>(IO);
740     if( myPath->_is_nil() )
741       return;
742
743     QString aString;
744     SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aString);
745     PathMeshLineEdit->setText(aString);
746   }
747   else if (myEditCurrentArgument == StartPointLineEdit && isPathDef )
748   {
749     // we are now selecting start point of path
750     // reset
751     StartPointLineEdit->clear();
752
753     // return if path mesh or path shape is not yet selected
754     if( myPath->_is_nil() )
755       return;
756
757     // try to get shape from selection
758     Handle(SALOME_InteractiveObject) IO = aList.First();
759
760     SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
761     if ( !aPathActor )
762       return;
763
764     QString aString;
765     int aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, aPathActor->getIO(), aString);
766     if (aNbUnits == 1)
767       StartPointLineEdit->setText(aString.trimmed());
768   }
769   else if ( myEditCurrentArgument == XSpin &&
770             SelectBasePointButton->isChecked() )
771   {
772     // we are now selecting base point
773     // reset is not performed here!
774
775     // return if is not enabled
776     if (!BasePointGrp->isChecked())
777       return;
778
779     // try to get shape from selection
780     Handle(SALOME_InteractiveObject) IO = aList.First();
781
782     // check if geom vertex is selected
783     GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>(IO);
784     TopoDS_Vertex aVertex;
785     if (!aGeomObj->_is_nil()) {
786       if (aGeomObj->IsShape() && GEOMBase::GetShape(aGeomObj, aVertex) && !aVertex.IsNull()) {
787         gp_Pnt aPnt = BRep_Tool::Pnt(aVertex);
788         XSpin->SetValue(aPnt.X());
789         YSpin->SetValue(aPnt.Y());
790         ZSpin->SetValue(aPnt.Z());
791       }
792       return;
793     }
794
795     // check if smesh node is selected
796     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(IO);
797     if (aMesh->_is_nil())
798       return;
799
800     QString aString;
801     int aNbUnits = SMESH::GetNameOfSelectedNodes(mySelector, IO, aString);
802     // return if more than one node is selected
803     if (aNbUnits != 1)
804       return;
805
806     SMESH_Actor* aMeshActor = SMESH::FindActorByObject(aMesh);
807     if (!aMeshActor)
808       return;
809
810     SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
811     if (!mesh)
812       return;
813
814     const SMDS_MeshNode* n = mesh->FindNode(aString.toLong());
815     if (!n)
816       return;
817
818     XSpin->SetValue(n->X());
819     YSpin->SetValue(n->Y());
820     ZSpin->SetValue(n->Z());
821   }
822   else
823   {
824     return;
825   }
826
827   onDisplaySimulation(true);
828   CheckIsEnable();
829 }
830
831 //=================================================================================
832 // function : SetEditCurrentArgument()
833 // purpose  :
834 //=================================================================================
835 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
836 {
837   QPushButton* send = (QPushButton*)sender();
838   if ( sender() == BasePointGrp )
839     send = SelectBasePointButton;
840   if (send != SelectPathMeshButton   &&
841       send != SelectStartPointButton &&
842       send != SelectBasePointButton)
843     return;
844   SetEditCurrentArgument(send);
845 }
846
847 //=================================================================================
848 // function : SetEditCurrentArgument()
849 // purpose  :
850 //=================================================================================
851 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument (QPushButton* button)
852 {
853   disconnect(mySelectionMgr, 0, this, 0);
854   //  mySelectionMgr->clearSelected();
855   mySelectionMgr->clearFilters();
856   SMESH::SetPickable();
857
858   myEditCurrentArgument = 0;
859   if (button == SelectPathMeshButton)
860   {
861     myEditCurrentArgument = PathMeshLineEdit;
862     SMESH::SetPointRepresentation(false);
863     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
864       aViewWindow->SetSelectionMode(ActorSelection);
865     mySelectionMgr->installFilter(myPathMeshFilter);
866   }
867   else if (button == SelectStartPointButton)
868   {
869     myEditCurrentArgument = StartPointLineEdit;
870     if (!myPath->_is_nil()) {
871       SMESH_Actor* aPathActor = SMESH::FindActorByObject(myPath);
872       if (aPathActor) {
873         aPathActor->SetPointRepresentation( true );
874         if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
875           aViewWindow->SetSelectionMode(NodeSelection);
876         SMESH::SetPickable(aPathActor);
877       }
878     }
879   }
880   else if (button == SelectBasePointButton)
881   {
882     myEditCurrentArgument = XSpin;
883     SMESH::SetPointRepresentation(true);
884     if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
885       aViewWindow->SetSelectionMode(NodeSelection);
886
887     SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter(SMESH::IDSOURCE);
888     SMESH_NumberFilter* aVertexFilter      = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE,
889                                                                      -1, TopAbs_VERTEX);
890     QList<SUIT_SelectionFilter*> aListOfFilters;
891     if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
892     if (aVertexFilter)        aListOfFilters.append(aVertexFilter);
893
894     mySelectionMgr->installFilter(new SMESH_LogicalFilter
895                                   (aListOfFilters, SMESH_LogicalFilter::LO_OR, true));
896   }
897
898   if (myEditCurrentArgument && !myEditCurrentArgument->hasFocus())
899     myEditCurrentArgument->setFocus();
900
901   connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
902   SelectionIntoArgument();
903 }
904
905 //=================================================================================
906 // function : DeactivateActiveDialog()
907 // purpose  : Deactivates this dialog
908 //=================================================================================
909 void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
910 {
911   if (GroupButtons->isEnabled())
912   {
913     GroupArguments->setEnabled(false);
914     GroupButtons->setEnabled(false);
915     SelectorWdg->setEnabled(false);
916     mySMESHGUI->ResetState();
917     mySMESHGUI->SetActiveDialogBox(0);
918   }
919 }
920
921 //=================================================================================
922 // function : ActivateThisDialog()
923 // purpose  : Activates this dialog
924 //=================================================================================
925 void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
926 {
927   // Emit a signal to deactivate the active dialog
928   mySMESHGUI->EmitSignalDeactivateDialog();
929   GroupArguments->setEnabled(true);
930   GroupButtons->setEnabled(true);
931   SelectorWdg->setEnabled(true);
932
933   mySMESHGUI->SetActiveDialogBox(this);
934   SelectionIntoArgument();
935 }
936
937 //=================================================================================
938 // function : enterEvent()
939 // purpose  :
940 //=================================================================================
941 void SMESHGUI_ExtrusionAlongPathDlg::enterEvent (QEvent*)
942 {
943   if ( !GroupButtons->isEnabled() ) {
944     SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI );
945     if ( aViewWindow && !mySelector) {
946       mySelector = aViewWindow->GetSelector();
947     }
948     ActivateThisDialog();
949   }
950 }
951
952 //=======================================================================
953 // function : OnAngleAdded()
954 // purpose  : Called when user adds angle to the list
955 //=======================================================================
956 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
957 {
958   if ( sender() == AddAngleButton )
959   {
960     QString msg;
961     if( !AngleSpin->isValid( msg, true ) ) {
962       QString str( tr( "SMESH_INCORRECT_INPUT" ) );
963       if ( !msg.isEmpty() )
964         str += "\n" + msg;
965       SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
966       return;
967     }
968     AnglesList->addItem(AngleSpin->text());
969     myAnglesList.append(AngleSpin->GetValue());
970   }
971   
972   if ( sender() == AddScaleButton )
973   {
974     QString msg;
975     if( !ScaleSpin->isValid( msg, true ) ) {
976       QString str( tr( "SMESH_INCORRECT_INPUT" ) );
977       if ( !msg.isEmpty() )
978         str += "\n" + msg;
979       SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
980       return;
981     }
982     ScalesList->addItem(ScaleSpin->text());
983     myScalesList.append(ScaleSpin->GetValue());
984   }
985   
986   updateLinearAngles();
987 }
988
989 //=======================================================================
990 // function : OnAngleRemoved()
991 // purpose  : Called when user removes angle(s) from the list
992 //=======================================================================
993 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
994 {
995   QListWidget* widget;
996   QList<double>* list;
997   if ( sender() == RemoveScaleButton )
998   {
999     widget = ScalesList;
1000     list   = & myScalesList;
1001   }
1002   else
1003   {
1004     widget = AnglesList;
1005     list   = & myAnglesList;
1006   }
1007
1008   QList<QListWidgetItem*> aList = widget->selectedItems();
1009   QListWidgetItem* anItem;
1010   foreach(anItem, aList) {
1011     list->removeAt( widget->row( anItem ));
1012     delete anItem;
1013   }
1014
1015   updateLinearAngles();
1016 }
1017
1018 //=================================================================================
1019 // function : eventFilter()
1020 // purpose  : event filter ???
1021 //=================================================================================
1022 bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter (QObject* object, QEvent* event)
1023 {
1024   if (event->type() == QEvent::KeyPress) {
1025     QKeyEvent* ke = (QKeyEvent*)event;
1026     if (object == AnglesList) {
1027       if (ke->key() == Qt::Key_Delete)
1028         RemoveAngleButton->click();
1029     }
1030     if (object == ScalesList) {
1031       if (ke->key() == Qt::Key_Delete)
1032         RemoveScaleButton->click();
1033     }
1034   }
1035   else if (event->type() == QEvent::FocusIn) {
1036     if (object == StartPointLineEdit) {
1037       if (myEditCurrentArgument != StartPointLineEdit)
1038         SetEditCurrentArgument(SelectStartPointButton);
1039     }
1040     else if (object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor()) {
1041       if (myEditCurrentArgument != XSpin)
1042         SetEditCurrentArgument(SelectBasePointButton);
1043     }
1044   }
1045   return QDialog::eventFilter(object, event);
1046 }
1047
1048 //=================================================================================
1049 // function : keyPressEvent()
1050 // purpose  :
1051 //=================================================================================
1052 void SMESHGUI_ExtrusionAlongPathDlg::keyPressEvent( QKeyEvent* e )
1053 {
1054   QDialog::keyPressEvent( e );
1055   if ( e->isAccepted() )
1056     return;
1057
1058   if ( e->key() == Qt::Key_F1 ) {
1059     e->accept();
1060     ClickOnHelp();
1061   }
1062 }
1063
1064 //=================================================================================
1065 // function : isValid
1066 // purpose  :
1067 //=================================================================================
1068 bool SMESHGUI_ExtrusionAlongPathDlg::isValid()
1069 {
1070   QString msg;
1071   bool ok = true;
1072   ok = XSpin->isValid( msg, true ) && ok;
1073   ok = YSpin->isValid( msg, true ) && ok;
1074   ok = ZSpin->isValid( msg, true ) && ok;
1075
1076   if( !ok ) {
1077     QString str( tr( "SMESH_INCORRECT_INPUT" ) );
1078     if ( !msg.isEmpty() )
1079       str += "\n" + msg;
1080     SUIT_MessageBox::critical( this, tr( "SMESH_ERROR" ), str );
1081     return false;
1082   }
1083   return true;
1084 }
1085
1086 //=================================================================================
1087 // function : updateLinearAngles
1088 // purpose  :
1089 //=================================================================================
1090 void SMESHGUI_ExtrusionAlongPathDlg::updateLinearAngles()
1091 {
1092   bool enableLinear = true;
1093   for( int row = 0, nbRows = AnglesList->count(); row < nbRows; row++ ) {
1094     if( QListWidgetItem* anItem = AnglesList->item( row ) ) {
1095       enableLinear = false;
1096       anItem->text().toDouble(&enableLinear);
1097       if( !enableLinear )
1098         break;
1099     }
1100   }
1101   if( !enableLinear )
1102     LinearAnglesCheck->setChecked( false );
1103   LinearAnglesCheck->setEnabled( enableLinear );
1104
1105   enableLinear = true;
1106   for( int row = 0, nbRows = ScalesList->count(); row < nbRows; row++ ) {
1107     if( QListWidgetItem* anItem = ScalesList->item( row ) ) {
1108       enableLinear = false;
1109       anItem->text().toDouble(&enableLinear);
1110       if( !enableLinear )
1111         break;
1112     }
1113   }
1114   if( !enableLinear )
1115     LinearScalesCheck->setChecked( false );
1116   LinearScalesCheck->setEnabled( enableLinear );
1117 }
1118
1119 //=================================================================================
1120 // function : isValuesValid()
1121 // purpose  : Return true in case if values entered into dialog are valid
1122 //=================================================================================
1123
1124 bool SMESHGUI_ExtrusionAlongPathDlg::isValuesValid()
1125
1126   if ( myPath->_is_nil() )
1127     return false;
1128   
1129   bool bOk;
1130   long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
1131   if ( !bOk || aNodeStart < 1 )
1132     return false;
1133
1134   SMESH::SMESH_Mesh_var mesh = myPath->GetMesh();
1135   if ( mesh->_is_nil() )
1136     return false;
1137
1138   SMESH::ElementType type = mesh->GetElementType( aNodeStart, false );
1139   if ( type != SMESH::NODE )
1140     return false;
1141
1142   if ( mesh->HasShapeToMesh() )
1143   {
1144     SMESH::NodePosition_var pos = mesh->GetNodePosition( aNodeStart );
1145     if ( pos->shapeType != GEOM::VERTEX )
1146       return false;
1147   }
1148   else
1149   {
1150     SMESH::long_array_var elems = mesh->GetNodeInverseElements( aNodeStart, SMESH::ALL );
1151     if ( elems->length() != 1 ||
1152          mesh->GetElementType( elems[0], true ) != SMESH::EDGE )
1153       return false;
1154   }
1155   return true;
1156 }
1157
1158 //=================================================================================
1159 // function : onDisplaySimulation
1160 // purpose  : Show/Hide preview
1161 //=================================================================================
1162
1163 void SMESHGUI_ExtrusionAlongPathDlg::onDisplaySimulation( bool toDisplayPreview )
1164 {
1165   if ( myPreviewCheckBox->isChecked() && toDisplayPreview ) {
1166     if ( SelectorWdg->IsAnythingSelected() && isValid() && isValuesValid())
1167     {
1168       // get angles and scales
1169       SMESH::double_array_var anAngles = getAngles();
1170       SMESH::double_array_var aScales  = getScales();
1171
1172       // get base point
1173       SMESH::PointStruct aBasePoint;
1174       if (BasePointGrp->isChecked()) {
1175         aBasePoint.x = XSpin->GetValue();
1176         aBasePoint.y = YSpin->GetValue();
1177         aBasePoint.z = ZSpin->GetValue();
1178       }
1179       bool bOk;
1180       long aNodeStart = StartPointLineEdit->text().toLong(&bOk);
1181       if (bOk) {
1182
1183         try {
1184           SUIT_OverrideCursor wc;
1185
1186           SMESH::SMESH_MeshEditor::Extrusion_Error retVal;
1187           SMESH::SMESH_Mesh_var             mesh = SelectorWdg->GetMesh();
1188           SMESH::SMESH_MeshEditor_var meshEditor = mesh->GetMeshEditPreviewer();
1189
1190           SMESH::ListOfIDSources_var nodes = new SMESH::ListOfIDSources();
1191           SMESH::ListOfIDSources_var edges = new SMESH::ListOfIDSources();
1192           SMESH::ListOfIDSources_var faces = new SMESH::ListOfIDSources();
1193           SelectorWdg->GetSelected( nodes, edges, faces );
1194           const bool makeGroups = false;
1195
1196           SMESH::ListOfGroups_var groups =
1197             meshEditor->ExtrusionAlongPathObjects( nodes, edges, faces, myPath,
1198                                                    GEOM::GEOM_Object::_nil(),
1199                                                    aNodeStart, AnglesGrp->isChecked(),
1200                                                    anAngles, LinearAnglesCheck->isChecked(),
1201                                                    BasePointGrp->isChecked(), aBasePoint,
1202                                                    makeGroups,
1203                                                    aScales, LinearScalesCheck->isChecked(),
1204                                                    retVal);
1205
1206           if( retVal == SMESH::SMESH_MeshEditor::EXTR_OK )
1207           {
1208             SMESH::MeshPreviewStruct_var aMeshPreviewStruct = meshEditor->GetPreviewData();
1209             mySimulation->SetData( aMeshPreviewStruct.in() );
1210           }
1211           else {
1212             hidePreview();
1213           }
1214
1215         } catch (...) {
1216           hidePreview();
1217         }
1218       } else {
1219         hidePreview();
1220       }
1221
1222     } else {
1223       hidePreview();
1224     }
1225   } else {
1226     hidePreview();
1227   }
1228 }
1229
1230 //=======================================================================
1231 //function : getAngles
1232 //purpose  : return CORBA array of angles
1233 //=======================================================================
1234
1235 SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getAngles()
1236 {
1237   SMESH::double_array_var anAngles = new SMESH::double_array;
1238   if ( AnglesGrp->isChecked() )
1239   {
1240     anAngles->length( myAnglesList.count() );
1241     for (int i = 0; i < myAnglesList.count(); i++)
1242       anAngles[ i ] = myAnglesList[ i ] * M_PI / 180.;
1243   }
1244   return anAngles;
1245 }
1246
1247 //=======================================================================
1248 //function : getScales
1249 //purpose  : return CORBA array of scale factors
1250 //=======================================================================
1251
1252 SMESH::double_array_var SMESHGUI_ExtrusionAlongPathDlg::getScales()
1253 {
1254   SMESH::double_array_var anScales = new SMESH::double_array;
1255   if ( ScalesGrp->isChecked() )
1256   {
1257     anScales->length( myScalesList.count() );
1258     for (int i = 0; i < myScalesList.count(); i++)
1259       anScales[ i ] = myScalesList[ i ];
1260   }
1261   return anScales;
1262 }