Salome HOME
Merge with OCC_development_01
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_ExtrusionAlongPathDlg.cxx
1 //  SMESH SMESHGUI : GUI for SMESH component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESHGUI_ExtrusionAlongPathDlg.cxx
25 //  Author : Vadim SANDLER
26 //  Module : SMESH
27 //  $Header: 
28
29 #include "SMESHGUI_ExtrusionAlongPathDlg.h"
30 #include "SMESHGUI.h"
31 #include "SMESHGUI_SpinBox.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMESHGUI_VTKUtils.h"
34 #include "SMESHGUI_MeshUtils.h"
35 #include "SMESHGUI_IdValidator.h"
36 #include "SMESH_Actor.h"
37 #include "SMESH_NumberFilter.hxx"
38 #include "SMDS_Mesh.hxx"
39 #include "GEOM_ShapeTypeFilter.hxx"
40 #include "GEOMBase.h"
41
42 #include "QAD_Application.h"
43 #include "QAD_WaitCursor.h"
44 #include "QAD_Desktop.h"
45 #include "QAD_MessageBox.h"
46 #include "utilities.h"
47
48 #include <BRep_Tool.hxx>
49 #include <TopoDS_Shape.hxx>
50 #include <TopoDS.hxx>
51 #include <TopoDS_Vertex.hxx>
52 #include <gp_Pnt.hxx>
53
54 // QT Includes
55 #include <qapplication.h>
56 #include <qbuttongroup.h>
57 #include <qgroupbox.h>
58 #include <qlabel.h>
59 #include <qlineedit.h>
60 #include <qpushbutton.h>
61 #include <qtoolbutton.h>
62 #include <qradiobutton.h>
63 #include <qcheckbox.h>
64 #include <qlistbox.h>
65 #include <qlayout.h>
66 #include <qvalidator.h>
67 #include <qptrlist.h>
68
69 // IDL Headers
70 #include "SALOMEconfig.h"
71 #include CORBA_SERVER_HEADER(SMESH_Group)
72
73 using namespace std;
74
75 //=================================================================================
76 // function : SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg()
77 // purpose  : constructor
78 //=================================================================================
79 SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( QWidget* parent, SALOME_Selection* Sel, bool modal )
80      : QDialog( parent, "SMESHGUI_ExtrusionAlongPathDlg", modal, 
81                 WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose )
82 {
83   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg");
84   myType = -1;
85   QPixmap edgeImage  ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_DLG_EDGE" ) ) );
86   QPixmap faceImage  ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_DLG_TRIANGLE" ) ) );
87   QPixmap selectImage( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) );
88   QPixmap addImage   ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_APPEND" ) ) );
89   QPixmap removeImage( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_REMOVE" ) ) );
90
91   setCaption( tr( "EXTRUSION_ALONG_PATH" ) );
92   setSizeGripEnabled( TRUE );
93
94   QGridLayout* topLayout = new QGridLayout( this ); 
95   topLayout->setSpacing( 6 ); topLayout->setMargin( 11 );
96
97   /***************************************************************/
98   // Elements type group box (1d / 2d elements)
99   ElementsTypeGrp = new QButtonGroup( tr( "SMESH_EXTRUSION" ), this );
100   ElementsTypeGrp->setColumnLayout( 0, Qt::Vertical );
101   ElementsTypeGrp->layout()->setSpacing( 0 );  ElementsTypeGrp->layout()->setMargin( 0 );
102   QGridLayout* ElementsTypeGrpLayout = new QGridLayout( ElementsTypeGrp->layout() );
103   ElementsTypeGrpLayout->setAlignment( Qt::AlignTop );
104   ElementsTypeGrpLayout->setSpacing( 6 ); ElementsTypeGrpLayout->setMargin( 11 );
105
106   Elements1dRB = new QRadioButton( ElementsTypeGrp );
107   Elements1dRB->setPixmap( edgeImage );
108   Elements2dRB = new QRadioButton( ElementsTypeGrp );
109   Elements2dRB->setPixmap( faceImage );
110   Elements1dRB->setChecked( true );
111
112   // layouting
113   ElementsTypeGrpLayout->addWidget( Elements1dRB, 0, 0 );
114   ElementsTypeGrpLayout->addWidget( Elements2dRB, 0, 2 );
115   
116   /***************************************************************/
117   // Arguments group box
118   ArgumentsGrp = new QGroupBox( tr( "EXTRUSION_1D" ), this );
119   ArgumentsGrp->setColumnLayout( 0, Qt::Vertical );
120   ArgumentsGrp->layout()->setSpacing( 0 ); ArgumentsGrp->layout()->setMargin( 0 );
121   QGridLayout* ArgumentsGrpLayout = new QGridLayout( ArgumentsGrp->layout() );
122   ArgumentsGrpLayout->setAlignment( Qt::AlignTop );
123   ArgumentsGrpLayout->setSpacing( 6 ); ArgumentsGrpLayout->setMargin( 11 );
124
125   // Controls for elements selection
126   ElementsLab = new QLabel( tr( "SMESH_ID_ELEMENTS" ), ArgumentsGrp );
127
128   SelectElementsButton = new QToolButton( ArgumentsGrp );
129   SelectElementsButton->setPixmap( selectImage );
130
131   ElementsLineEdit = new QLineEdit( ArgumentsGrp );
132   ElementsLineEdit->setValidator( new SMESHGUI_IdValidator( this ) );
133
134   // Controls for the whole mesh selection
135   MeshCheck = new QCheckBox( tr( "SMESH_SELECT_WHOLE_MESH" ), ArgumentsGrp );
136
137   // Controls for path selection
138   PathGrp = new QGroupBox( tr( "SMESH_PATH" ), ArgumentsGrp );
139   PathGrp->setColumnLayout( 0, Qt::Vertical );
140   PathGrp->layout()->setSpacing( 0 ); PathGrp->layout()->setMargin( 0 );
141   QGridLayout* PathGrpLayout = new QGridLayout( PathGrp->layout() );
142   PathGrpLayout->setAlignment( Qt::AlignTop );
143   PathGrpLayout->setSpacing( 6 ); PathGrpLayout->setMargin( 11 );
144   
145   // Controls for path mesh selection
146   PathMeshLab = new QLabel( tr( "SMESH_PATH_MESH" ), PathGrp );
147
148   SelectPathMeshButton = new QToolButton( PathGrp );
149   SelectPathMeshButton->setPixmap( selectImage );
150
151   PathMeshLineEdit = new QLineEdit( PathGrp );
152   PathMeshLineEdit->setReadOnly( true );
153
154   // Controls for path shape selection
155   PathShapeLab = new QLabel( tr( "SMESH_PATH_SHAPE" ), PathGrp );
156
157   SelectPathShapeButton = new QToolButton( PathGrp );
158   SelectPathShapeButton->setPixmap( selectImage );
159
160   PathShapeLineEdit = new QLineEdit( PathGrp );
161   PathShapeLineEdit->setReadOnly( true );
162
163   // Controls for path starting point selection
164   StartPointLab = new QLabel( tr( "SMESH_PATH_START" ), PathGrp );
165
166   SelectStartPointButton = new QToolButton( PathGrp );
167   SelectStartPointButton->setPixmap( selectImage );
168
169   StartPointLineEdit = new QLineEdit( PathGrp );
170   StartPointLineEdit->setValidator( new QIntValidator( this ) );
171
172   // layouting
173   PathGrpLayout->addWidget( PathMeshLab,            0, 0 );
174   PathGrpLayout->addWidget( SelectPathMeshButton,   0, 1 );
175   PathGrpLayout->addWidget( PathMeshLineEdit,       0, 2 );
176   PathGrpLayout->addWidget( PathShapeLab,           1, 0 );
177   PathGrpLayout->addWidget( SelectPathShapeButton,  1, 1 );
178   PathGrpLayout->addWidget( PathShapeLineEdit,      1, 2 );
179   PathGrpLayout->addWidget( StartPointLab,          2, 0 );
180   PathGrpLayout->addWidget( SelectStartPointButton, 2, 1 );
181   PathGrpLayout->addWidget( StartPointLineEdit,     2, 2 );
182
183   // Controls for angles defining
184   AnglesCheck = new QCheckBox( tr( "SMESH_USE_ANGLES" ), ArgumentsGrp );
185   
186   AnglesGrp = new QGroupBox( tr( "SMESH_ANGLES" ), ArgumentsGrp );
187   AnglesGrp->setColumnLayout( 0, Qt::Vertical );
188   AnglesGrp->layout()->setSpacing( 0 ); AnglesGrp->layout()->setMargin( 0 );
189   QGridLayout* AnglesGrpLayout = new QGridLayout( AnglesGrp->layout() );
190   AnglesGrpLayout->setAlignment( Qt::AlignTop );
191   AnglesGrpLayout->setSpacing( 6 ); AnglesGrpLayout->setMargin( 11 );
192   
193   AnglesList = new QListBox( AnglesGrp );
194   AnglesList->setSelectionMode( QListBox::Extended );
195
196   AddAngleButton = new QToolButton( AnglesGrp ); 
197   AddAngleButton->setPixmap( addImage );
198
199   RemoveAngleButton = new QToolButton( AnglesGrp ); 
200   RemoveAngleButton->setPixmap( removeImage );
201
202   AngleSpin = new SMESHGUI_SpinBox( AnglesGrp );
203
204   // layouting
205   QVBoxLayout* bLayout = new QVBoxLayout(); 
206   bLayout->addWidget( AddAngleButton );
207   bLayout->addSpacing( 6 );
208   bLayout->addWidget( RemoveAngleButton );
209   bLayout->addStretch();
210   AnglesGrpLayout->addMultiCellWidget( AnglesList, 0, 1, 0, 0 );
211   AnglesGrpLayout->addMultiCellLayout( bLayout,    0, 1, 1, 1 );
212   AnglesGrpLayout->addWidget(          AngleSpin,  0,    2    );
213   AnglesGrpLayout->setRowStretch( 1, 10 );
214   
215   // Controls for base point defining
216   BasePointCheck = new QCheckBox( tr( "SMESH_USE_BASE_POINT" ), ArgumentsGrp );
217
218   BasePointGrp = new QGroupBox( tr( "SMESH_BASE_POINT" ), ArgumentsGrp );
219   BasePointGrp->setColumnLayout( 0, Qt::Vertical );
220   BasePointGrp->layout()->setSpacing( 0 ); BasePointGrp->layout()->setMargin( 0 );
221   QGridLayout* BasePointGrpLayout = new QGridLayout( BasePointGrp->layout() );
222   BasePointGrpLayout->setAlignment( Qt::AlignTop );
223   BasePointGrpLayout->setSpacing( 6 ); BasePointGrpLayout->setMargin( 11 );
224   
225   SelectBasePointButton = new QToolButton( BasePointGrp );
226   SelectBasePointButton->setPixmap( selectImage );
227
228   XLab  = new QLabel( tr( "SMESH_X" ), BasePointGrp );
229   XSpin = new SMESHGUI_SpinBox( BasePointGrp );
230   YLab  = new QLabel( tr( "SMESH_Y" ), BasePointGrp );
231   YSpin = new SMESHGUI_SpinBox( BasePointGrp );
232   ZLab  = new QLabel( tr( "SMESH_Z" ), BasePointGrp );
233   ZSpin = new SMESHGUI_SpinBox( BasePointGrp );
234
235   // layouting
236   BasePointGrpLayout->addWidget( SelectBasePointButton, 0, 0 );
237   BasePointGrpLayout->addWidget( XLab,                  0, 1 );
238   BasePointGrpLayout->addWidget( XSpin,                 0, 2 );
239   BasePointGrpLayout->addWidget( YLab,                  0, 3 );
240   BasePointGrpLayout->addWidget( YSpin,                 0, 4 );
241   BasePointGrpLayout->addWidget( ZLab,                  0, 5 );
242   BasePointGrpLayout->addWidget( ZSpin,                 0, 6 );
243
244   // layouting
245   ArgumentsGrpLayout->addWidget(          ElementsLab,            0,    0    );
246   ArgumentsGrpLayout->addWidget(          SelectElementsButton,   0,    1    );
247   ArgumentsGrpLayout->addWidget(          ElementsLineEdit,       0,    2    );
248   ArgumentsGrpLayout->addMultiCellWidget( MeshCheck,              1, 1, 0, 2 );
249   ArgumentsGrpLayout->addMultiCellWidget( PathGrp,                2, 2, 0, 2 );
250   ArgumentsGrpLayout->addWidget(          AnglesCheck,            3,    0    );
251   ArgumentsGrpLayout->addMultiCellWidget( AnglesGrp,              3, 4, 1, 2 );
252   ArgumentsGrpLayout->addWidget(          BasePointCheck,         5,    0    );
253   ArgumentsGrpLayout->addMultiCellWidget( BasePointGrp,           5, 6, 1, 2 );
254   ArgumentsGrpLayout->setRowStretch( 4, 10 );
255
256   /***************************************************************/
257   // common buttons group box
258   ButtonsGrp = new QGroupBox( this );
259   ButtonsGrp->setColumnLayout( 0, Qt::Vertical );
260   ButtonsGrp->layout()->setSpacing( 0 ); ButtonsGrp->layout()->setMargin( 0 );
261   QGridLayout* ButtonsGrpLayout = new QGridLayout( ButtonsGrp->layout() );
262   ButtonsGrpLayout->setAlignment( Qt::AlignTop );
263   ButtonsGrpLayout->setSpacing( 6 ); ButtonsGrpLayout->setMargin( 11 );
264
265   OkButton = new QPushButton( tr( "SMESH_BUT_OK" ), ButtonsGrp );
266   OkButton->setAutoDefault( true );
267   OkButton->setDefault( true );
268
269   ApplyButton = new QPushButton( tr( "SMESH_BUT_APPLY" ), ButtonsGrp );
270   ApplyButton->setAutoDefault( true );
271
272   CloseButton = new QPushButton( tr( "SMESH_BUT_CLOSE" ), ButtonsGrp );
273   CloseButton->setAutoDefault( true );
274
275   // layouting
276   ButtonsGrpLayout->addWidget( OkButton,    0, 0 );
277   ButtonsGrpLayout->addWidget( ApplyButton, 0, 1 );
278   ButtonsGrpLayout->addWidget( CloseButton, 0, 3 );
279   ButtonsGrpLayout->addColSpacing( 2, 10 );
280   ButtonsGrpLayout->setColStretch( 2, 10 );
281
282   /***************************************************************/
283   // layouting
284   topLayout->addWidget( ElementsTypeGrp, 0, 0 );
285   topLayout->addWidget( ArgumentsGrp,    1, 0 );
286   topLayout->addWidget( ButtonsGrp,      2, 0 );
287
288   /***************************************************************/
289   // Initialisations
290   XSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
291   YSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
292   ZSpin->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 );
293   AngleSpin->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 );
294  
295   mySelection = Sel;  
296   mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
297   mySMESHGUI->SetActiveDialogBox( this ) ;
298   
299   // Costruction of the logical filter for the elements: mesh/sub-mesh/group
300   SMESH_ListOfFilter aListOfFilters;
301   Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
302   if ( !aMeshOrSubMeshFilter.IsNull() )
303     aListOfFilters.Append( aMeshOrSubMeshFilter );
304   Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
305   if ( !aSmeshGroupFilter.IsNull() )
306     aListOfFilters.Append( aSmeshGroupFilter );
307   
308   myElementsFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
309   
310   myPathMeshFilter = new SMESH_TypeFilter( MESH );
311   
312   Init();
313
314   /***************************************************************/
315   // signals-slots connections
316   connect( OkButton,     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
317   connect( CloseButton,  SIGNAL( clicked() ), this, SLOT( reject() ) ) ;
318   connect( ApplyButton,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
319
320   connect( AddAngleButton,    SIGNAL( clicked() ), this, SLOT( OnAngleAdded() ) );
321   connect( RemoveAngleButton, SIGNAL( clicked() ), this, SLOT( OnAngleRemoved() ) );
322
323   connect( ElementsTypeGrp, SIGNAL( clicked( int ) ), SLOT( TypeChanged( int ) ) );
324   
325   connect( SelectElementsButton,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
326   connect( SelectPathMeshButton,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
327   connect( SelectPathShapeButton,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
328   connect( SelectStartPointButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
329   connect( SelectBasePointButton,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
330
331   connect( mySMESHGUI,  SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
332   connect( mySelection, SIGNAL( currentSelectionChanged() ),      this, SLOT( SelectionIntoArgument() ) );
333   connect( mySMESHGUI,  SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( reject() ) ) ;
334
335   connect( ElementsLineEdit, SIGNAL( textChanged( const QString& ) ),
336            SLOT( onTextChange( const QString& ) ) );
337   connect( StartPointLineEdit, SIGNAL( textChanged( const QString& ) ),
338            SLOT( onTextChange( const QString& ) ) );
339
340   connect( MeshCheck,      SIGNAL( toggled( bool ) ), SLOT( onSelectMesh() ) );
341   connect( AnglesCheck,    SIGNAL( toggled( bool ) ), SLOT( onAnglesCheck() ) );
342   connect( BasePointCheck, SIGNAL( toggled( bool ) ), SLOT( onBasePointCheck() ) );
343
344   AnglesList->installEventFilter( this );
345   ElementsLineEdit->installEventFilter( this );
346   StartPointLineEdit->installEventFilter( this );
347   XSpin->editor()->installEventFilter( this );
348   YSpin->editor()->installEventFilter( this );
349   ZSpin->editor()->installEventFilter( this );
350
351   /***************************************************************/
352   // set position and show dialog box
353   int x, y ;
354   mySMESHGUI->DefineDlgPosition( this, x, y ) ;
355   this->move( x, y ) ;
356   this->show() ; // displays Dialog
357 }
358
359 //=================================================================================
360 // function : SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
361 // purpose  : destructor
362 //=================================================================================
363 SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
364 {
365   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg");
366   // no need to delete child widgets, Qt does it all for us
367 }
368
369 //=================================================================================
370 // function : SMESHGUI_ExtrusionAlongPathDlg::eventFilter
371 // purpose  : event filter
372 //=================================================================================
373 bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter( QObject* object, QEvent* event )
374 {
375   if ( event->type() == QEvent::KeyPress ) {
376     QKeyEvent* ke = ( QKeyEvent* )event;
377     if ( object == AnglesList ) {
378       if ( ke->key() == Key_Delete )
379         OnAngleRemoved();
380     }
381   }
382   else if ( event->type() == QEvent::FocusIn ) {
383     if ( object == ElementsLineEdit ) {
384       if ( myEditCurrentArgument != ElementsLineEdit )
385         SetEditCurrentArgument( SelectElementsButton );
386     }
387     else if ( object == StartPointLineEdit ) {
388       if ( myEditCurrentArgument != StartPointLineEdit )
389         SetEditCurrentArgument( SelectStartPointButton );
390     }
391     else if ( object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor() ) {
392       if ( myEditCurrentArgument != XSpin )
393         SetEditCurrentArgument( SelectBasePointButton );
394     }
395   }
396   return QDialog::eventFilter( object, event );
397 }
398
399 //=================================================================================
400 // function : SMESHGUI_ExtrusionAlongPathDlg::Init()
401 // purpose  : initialization
402 //=================================================================================
403 void SMESHGUI_ExtrusionAlongPathDlg::Init( bool ResetControls )
404 {
405   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::Init");
406   myBusy = false;
407   myEditCurrentArgument = 0;
408  
409   myMesh      = SMESH::SMESH_Mesh::_nil();
410   myIDSource  = SMESH::SMESH_IDSource::_nil();
411   myMeshActor = 0;
412   myPathMesh  = SMESH::SMESH_Mesh::_nil();
413   myPathShape = GEOM::GEOM_Object::_nil();
414   
415   ElementsLineEdit->clear();
416   PathMeshLineEdit->clear();
417   PathShapeLineEdit->clear();
418   StartPointLineEdit->clear();
419
420   if( ResetControls ) {
421     XSpin->SetValue( 0.0 );
422     YSpin->SetValue( 0.0 );
423     ZSpin->SetValue( 0.0 );
424     
425     AngleSpin->SetValue( 45 );
426     MeshCheck->setChecked( false );
427     TypeChanged( 0 );
428     onSelectMesh();
429     onAnglesCheck();
430     onBasePointCheck();
431   }
432   SetEditCurrentArgument( 0 );
433 }
434
435 //=================================================================================
436 // function : SMESHGUI_ExtrusionAlongPathDlg::TypeChanged()
437 // purpose  : Called when user changes type of elements ( 1d / 2d )
438 //=================================================================================
439 void SMESHGUI_ExtrusionAlongPathDlg::TypeChanged( int type )
440 {
441   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::TypeChanged");
442   if ( myType != type ) {
443     disconnect( mySelection, 0, this, 0 );
444     
445     if ( type == 0 )
446       ArgumentsGrp->setTitle( tr( "EXTRUSION_1D" ) );
447     else if ( type == 1 )
448       ArgumentsGrp->setTitle( tr( "EXTRUSION_2D" ) );
449     
450     // clear elements ID list
451     if ( !MeshCheck->isChecked() ) {
452       ElementsLineEdit->clear();
453     }
454     // set selection mode if necessary
455     if( myEditCurrentArgument == ElementsLineEdit ) {
456       mySelection->ClearIObjects();
457       mySelection->ClearFilters();
458       SMESH::SetPickable();
459   
460       SMESH::SetPointRepresentation( false );
461       if ( MeshCheck->isChecked() ) {
462         QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
463         mySelection->AddFilter( myElementsFilter );
464       }
465       else  {
466         if ( type == 0 )
467           QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
468         if ( type == 1 )
469           QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
470       }
471     }
472     connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
473   }
474   myType = type;
475
476
477
478 //=================================================================================
479 // function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
480 // purpose  : Called when user presses <Apply> button
481 //=================================================================================
482 bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
483 {
484   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply");
485   if ( mySMESHGUI->ActiveStudyLocked() ) {
486     return false;
487   }
488   
489   if( myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() || !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil() ) {
490     return false;
491   }
492
493   SMESH::long_array_var anElementsId = new SMESH::long_array;
494
495   if ( MeshCheck->isChecked() ) {
496     // If "Select whole mesh, submesh or group" check box is on ->
497     // get all elements of the required type from the object selected
498
499     // if MESH object is selected
500     if ( !CORBA::is_nil( SMESH::SMESH_Mesh::_narrow( myIDSource ) ) ) {
501       // get mesh
502       SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( myIDSource );
503       // get IDs from mesh...
504       if ( Elements1dRB->isChecked() )
505         // 1d elements
506         anElementsId = aMesh->GetElementsByType( SMESH::EDGE );
507       else if ( Elements2dRB->isChecked() ) {
508         anElementsId = aMesh->GetElementsByType( SMESH::FACE );
509       }
510     }
511     // SUBMESH is selected
512     if ( !CORBA::is_nil( SMESH::SMESH_subMesh::_narrow( myIDSource ) ) ) {
513       // get submesh
514       SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( myIDSource );
515       // get IDs from submesh
516       if ( Elements1dRB->isChecked() )
517         // 1d elements
518         anElementsId = aSubMesh->GetElementsByType( SMESH::EDGE );
519       else if ( Elements2dRB->isChecked() )
520         // 2d elements
521         anElementsId = aSubMesh->GetElementsByType( SMESH::FACE );
522     }  
523     // GROUP is selected
524     if ( !CORBA::is_nil( SMESH::SMESH_GroupBase::_narrow( myIDSource ) ) ) {
525       // get smesh group
526       SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( myIDSource );
527       // get IDs from group
528       // 1d elements or 2d elements
529       if ( Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE ||
530            Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE )
531         anElementsId = aGroup->GetListOfID();
532     }
533   }
534   else {
535     // If "Select whole mesh, submesh or group" check box is off ->
536     // use only elements of given type selected by user
537
538     SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh();
539     if ( aMesh ) {
540       QStringList aListElementsId = QStringList::split( " ", ElementsLineEdit->text(), false );
541       anElementsId = new SMESH::long_array;
542       anElementsId->length( aListElementsId.count() );
543       bool bOk;
544       int j = 0;
545       for ( int i = 0; i < aListElementsId.count(); i++ ) {
546         long ind = aListElementsId[ i ].toLong( &bOk );
547         if  ( bOk ) {
548           const SMDS_MeshElement* e = aMesh->FindElement( ind );
549           if ( e ) {
550             bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || 
551                              Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
552             if ( typeMatch )
553               anElementsId[ j++ ] = ind;
554           }
555         }
556       }
557       anElementsId->length( j );
558     }
559   }
560       
561   if ( anElementsId->length() <= 0 ) {
562     return false;
563   }
564
565   if ( StartPointLineEdit->text().stripWhiteSpace().isEmpty() ) {
566     return false;
567   }
568   
569   bool bOk;
570   long aNodeStart = StartPointLineEdit->text().toLong( &bOk );
571   if ( !bOk ) {
572     return false;
573   }
574   
575   // get angles
576   SMESH::double_array_var anAngles = new SMESH::double_array;
577   if ( AnglesCheck->isChecked() ) {
578     anAngles->length( AnglesList->count() );
579     int j = 0;
580     bool bOk;
581     for ( int i = 0; i < AnglesList->count(); i++ ) {
582       long angle = AnglesList->text( i ).toLong( &bOk );
583       if  ( bOk )
584         anAngles[ j++ ] = angle;
585     }
586     anAngles->length( j );
587   }
588
589   // get base point
590   SMESH::PointStruct aBasePoint;
591   if ( BasePointCheck->isChecked() ) {
592     aBasePoint.x = XSpin->GetValue();
593     aBasePoint.y = YSpin->GetValue();
594     aBasePoint.z = ZSpin->GetValue();
595   }
596   
597   try {
598     QAD_WaitCursor wc;
599     SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
600     aMeshEditor->ExtrusionAlongPath( anElementsId.inout(), myPathMesh, myPathShape, aNodeStart, 
601                                      AnglesCheck->isChecked(), anAngles.inout(), 
602                                      BasePointCheck->isChecked(), aBasePoint );
603   }
604   catch( ... ) {
605     return false;
606   }
607     
608   mySelection->ClearIObjects();
609   SMESH::UpdateView();
610   Init( false );
611   TypeChanged( GetConstructorId() );
612   return true;
613 }
614
615 //=================================================================================
616 // function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
617 // purpose  : Called when user presses <OK> button
618 //=================================================================================
619 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
620 {
621   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk");
622   if ( !ClickOnApply() )
623     return;
624   reject();
625 }
626
627 //=======================================================================
628 // function : SMESHGUI_ExtrusionAlongPathDlg::onTextChange
629 // purpose  : 
630 //=======================================================================
631
632 void SMESHGUI_ExtrusionAlongPathDlg::onTextChange(const QString& theNewText)
633 {
634   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onTextChange");
635   QLineEdit* send = (QLineEdit*)sender();
636   if ( send != StartPointLineEdit && send != ElementsLineEdit )
637     send = ElementsLineEdit;
638
639   // return if busy
640   if ( myBusy ) 
641     return;
642
643   // set busy flag
644   SetBusy sb( this );
645   
646   if ( send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit ) {
647     // hilight entered elements
648     SMDS_Mesh* aMesh = 0;
649     if ( myMeshActor )
650       aMesh = myMeshActor->GetObject()->GetMesh();
651     if ( aMesh ) {
652       mySelection->ClearIObjects();
653       mySelection->AddIObject( myMeshActor->getIO() );
654       
655       QStringList aListId = QStringList::split( " ", theNewText, false );
656       bool bOk;
657       for ( int i = 0; i < aListId.count(); i++ ) {
658         long ind = aListId[ i ].toLong( &bOk );
659         if ( bOk ) {
660           const SMDS_MeshElement* e = aMesh->FindElement( ind );
661           if ( e ) {
662             // check also type of element
663             bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || 
664                              Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
665             if ( typeMatch ) {
666               if ( !mySelection->IsIndexSelected( myMeshActor->getIO(), e->GetID() ) )
667                 mySelection->AddOrRemoveIndex( myMeshActor->getIO(), e->GetID(), true );
668             }
669           }
670         }
671       }
672     }
673   }
674   else if ( send == StartPointLineEdit && myEditCurrentArgument == StartPointLineEdit ) {
675     if ( !myPathMesh->_is_nil() ) {
676       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
677       SMDS_Mesh* aMesh = 0;
678       if ( aPathActor )
679         aMesh = aPathActor->GetObject()->GetMesh();
680       if ( aMesh ) {
681         mySelection->ClearIObjects();
682         mySelection->AddIObject( aPathActor->getIO() );
683       
684         bool bOk;
685         long ind = theNewText.toLong( &bOk );
686         if ( bOk ) {
687           const SMDS_MeshNode* n = aMesh->FindNode( ind );
688           if ( n ) {
689             if ( !mySelection->IsIndexSelected( aPathActor->getIO(), n->GetID() ) ) {
690               mySelection->AddOrRemoveIndex( aPathActor->getIO(), n->GetID(), true );
691             }
692           }
693         }
694       }
695     }
696   }
697 }
698
699 //=================================================================================
700 // function : SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
701 // purpose  : Called when selection as changed or other case
702 //=================================================================================
703 void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
704 {
705   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument");
706   // return if busy
707   if ( myBusy ) 
708     return;
709   
710   // return if dialog box is inactive
711   if ( !ButtonsGrp->isEnabled() )
712     return;
713
714   // selected objects count
715   int nbSel = mySelection->IObjectCount();
716
717   // set busy flag
718   SetBusy sb( this );
719
720   if ( myEditCurrentArgument == ElementsLineEdit ) {
721     // we are now selecting mesh elements (or whole mesh/submesh/group)
722     // reset
723     ElementsLineEdit->clear();
724     myMesh      = SMESH::SMESH_Mesh::_nil();
725     myIDSource  = SMESH::SMESH_IDSource::_nil();
726     myMeshActor = 0;
727     
728     // only one object is acceptable
729     if( nbSel != 1 )
730       return;
731
732     // try to get mesh from selection
733     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
734     myMesh = SMESH::GetMeshByIO( IO );
735     if( myMesh->_is_nil() )
736       return;
737     // find actor
738     myMeshActor = SMESH::FindActorByObject( myMesh );
739     if ( !myMeshActor )
740       return;
741
742     if ( MeshCheck->isChecked() ) {
743       // If "Select whole mesh, submesh or group" check box is on ->
744       // get ID source and put it's name to the edit box
745       QString aString;
746       SMESH::GetNameOfSelectedIObjects( mySelection, aString );
747
748       myIDSource = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
749       ElementsLineEdit->setText( aString );
750     }
751     else {
752       // If "Select whole mesh, submesh or group" check box is off ->
753       // try to get selected elements IDs
754       QString aString;
755       int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString );
756       ElementsLineEdit->setText( aString );
757     }
758   }
759   else if ( myEditCurrentArgument == PathMeshLineEdit ) {
760     // we are now selecting path mesh
761     // reset
762     PathMeshLineEdit->clear();
763     myPathMesh = SMESH::SMESH_Mesh::_nil();
764     PathShapeLineEdit->clear();
765     myPathShape = GEOM::GEOM_Object::_nil();
766     StartPointLineEdit->clear();
767
768     // only one object is acceptable
769     if( nbSel != 1 )
770       return;
771
772     // try to get mesh from selection
773     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
774     myPathMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( IO );
775     if( myPathMesh->_is_nil() )
776       return;
777
778     QString aString;
779     SMESH::GetNameOfSelectedIObjects( mySelection, aString );
780     PathMeshLineEdit->setText( aString );
781   }
782   else if ( myEditCurrentArgument == PathShapeLineEdit ) {
783     // we are now selecting path mesh
784     // reset
785     PathShapeLineEdit->clear();
786     myPathShape = GEOM::GEOM_Object::_nil();
787     StartPointLineEdit->clear();
788
789     // return if path mesh is not yet selected
790     if ( myPathMesh->_is_nil() )
791       return;
792
793     // only one object is acceptable
794     if( nbSel != 1 )
795       return;
796
797     // try to get shape from selection
798     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
799     myPathShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO );
800     if ( myPathShape->_is_nil() )
801       return;
802
803     QString aString;
804     SMESH::GetNameOfSelectedIObjects( mySelection, aString );
805     PathShapeLineEdit->setText( aString );
806   }
807   else if ( myEditCurrentArgument == StartPointLineEdit ) {
808     // we are now selecting start point of path
809     // reset
810     StartPointLineEdit->clear();
811
812     // return if path mesh or path shape is not yet selected
813     if ( myPathMesh->_is_nil() || myPathShape->_is_nil() )
814       return;
815
816     // only one object is acceptable
817     if( nbSel != 1 )
818       return;
819
820     // try to get shape from selection
821     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
822     
823     QString aString;
824     int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString );
825     if ( aNbUnits == 1 )
826       StartPointLineEdit->setText( aString.stripWhiteSpace() );
827   }
828   else if ( myEditCurrentArgument == XSpin ) {
829     // we are now selecting base point
830     // reset is not performed here!
831
832     // return if is not enabled
833     if ( !BasePointGrp->isEnabled() ) 
834       return;
835
836     // only one object is acceptable
837     if( nbSel != 1 )
838       return;
839     
840     // try to get shape from selection
841     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
842     
843     // check if geom vertex is selected
844     GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO );
845     TopoDS_Vertex aVertex;
846     if( !aGeomObj->_is_nil() ) {
847       if(  aGeomObj->IsShape() && GEOMBase::GetShape( aGeomObj, aVertex ) && !aVertex.IsNull() ) {
848         gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
849         XSpin->SetValue( aPnt.X() );
850         YSpin->SetValue( aPnt.Y() );
851         ZSpin->SetValue( aPnt.Z() );
852       }
853       return;
854     }
855
856     // check if smesh node is selected
857     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO );
858     if( aMesh->_is_nil() )
859       return;
860
861     QString aString;
862     int aNbUnits = SMESH::GetNameOfSelectedNodes( mySelection, aString );
863     // return if more than one node is selected
864     if( aNbUnits != 1 )
865       return;
866       
867     SMESH_Actor* aMeshActor = SMESH::FindActorByObject( aMesh );
868     if ( !aMeshActor )
869       return;
870
871     SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
872     if (!mesh)
873       return;
874
875     const SMDS_MeshNode* n = mesh->FindNode( aString.toLong() );
876     if ( !n )
877       return;
878
879     XSpin->SetValue( n->X() );
880     YSpin->SetValue( n->Y() );
881     ZSpin->SetValue( n->Z() );
882   }
883 }
884
885 //=================================================================================
886 // function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
887 // purpose  :
888 //=================================================================================
889 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
890 {
891   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument");
892   QToolButton* send = (QToolButton*)sender();
893   if ( send != SelectElementsButton   && 
894        send != SelectPathMeshButton   && 
895        send != SelectPathShapeButton  && 
896        send != SelectStartPointButton && 
897        send != SelectBasePointButton )
898     return;
899   SetEditCurrentArgument( send );
900 }
901
902 //=================================================================================
903 // function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
904 // purpose  :
905 //=================================================================================
906 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument( QToolButton* button )
907 {
908   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument(button)");
909   disconnect( mySelection, 0, this, 0 );
910   mySelection->ClearIObjects();
911   mySelection->ClearFilters();
912   SMESH::SetPickable();
913   
914   if( button == SelectElementsButton ) {
915     myEditCurrentArgument = ElementsLineEdit;
916     SMESH::SetPointRepresentation( false );
917     if ( MeshCheck->isChecked() ) {
918       QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
919       mySelection->AddFilter( myElementsFilter );
920     }
921     else  {
922       if ( Elements1dRB->isChecked() )
923         QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
924       else if ( Elements2dRB->isChecked() )
925         QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
926     }
927   }
928   else if ( button == SelectPathMeshButton ) {
929     myEditCurrentArgument = PathMeshLineEdit;
930     SMESH::SetPointRepresentation( false );
931     QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
932     mySelection->AddFilter( myPathMeshFilter );
933   }
934   else if ( button == SelectPathShapeButton ) {
935     myEditCurrentArgument = PathShapeLineEdit;
936     SMESH::SetPointRepresentation( false );
937     QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
938
939     if ( !myPathMesh->_is_nil() ) {
940       TColStd_MapOfInteger aTypes;
941       aTypes.Add( TopAbs_EDGE );
942       aTypes.Add( TopAbs_WIRE );
943       GEOM::GEOM_Object_var aMainShape = myPathMesh->GetShapeToMesh();
944       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
945
946       if ( !aMainShape->_is_nil() && aPathActor )
947         mySelection->AddFilter( new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, aTypes, aMainShape ) );
948         //SMESH::SetPickable( aPathActor );
949     }
950   }
951   else if ( button == SelectStartPointButton ) {
952     myEditCurrentArgument = StartPointLineEdit;
953     if ( !myPathMesh->_is_nil() ) {
954       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
955       if ( aPathActor ) {
956         SMESH::SetPointRepresentation( true );
957         QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
958         SMESH::SetPickable( aPathActor );
959       }
960     }
961   }
962   else if ( button == SelectBasePointButton ) {
963     myEditCurrentArgument = XSpin;
964     SMESH::SetPointRepresentation( true );
965     QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
966
967     SMESH_ListOfFilter aListOfFilters;
968     Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
969     if ( !aMeshOrSubMeshFilter.IsNull() )
970       aListOfFilters.Append( aMeshOrSubMeshFilter );
971     Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
972     if ( !aSmeshGroupFilter.IsNull() )
973       aListOfFilters.Append( aSmeshGroupFilter );
974     //Handle(GEOM_ShapeTypeFilter) aVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX );
975     Handle(SMESH_NumberFilter) aVertexFilter = new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_VERTEX, GEOM::GEOM_Object::_nil() );
976     if ( !aVertexFilter.IsNull() )
977       aListOfFilters.Append( aVertexFilter );
978   
979     mySelection->AddFilter( new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ) );
980   }
981
982   if ( myEditCurrentArgument && !myEditCurrentArgument->hasFocus() )
983     myEditCurrentArgument->setFocus();
984
985   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
986   SelectionIntoArgument();
987 }
988
989 //=================================================================================
990 // function : SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
991 // purpose  : Deactivates this dialog
992 //=================================================================================
993 void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
994 {
995   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog");
996   if ( ElementsTypeGrp->isEnabled() ) {
997     ElementsTypeGrp->setEnabled( false );
998     ArgumentsGrp->setEnabled( false );
999     ButtonsGrp->setEnabled( false );
1000     mySMESHGUI->ResetState();    
1001     mySMESHGUI->SetActiveDialogBox( 0 );
1002   }
1003 }
1004
1005 //=================================================================================
1006 // function : SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1007 // purpose  : Activates this dialog
1008 //=================================================================================
1009 void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1010 {
1011   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog");
1012   // Emit a signal to deactivate the active dialog
1013   mySMESHGUI->EmitSignalDeactivateDialog();   
1014   ElementsTypeGrp->setEnabled( true );
1015   ArgumentsGrp->setEnabled( true );
1016   ButtonsGrp->setEnabled( true );
1017   
1018   mySMESHGUI->SetActiveDialogBox( this );
1019
1020   TypeChanged( GetConstructorId() );
1021   SelectionIntoArgument();
1022 }
1023
1024 //=================================================================================
1025 // function : SMESHGUI_ExtrusionAlongPathDlg::enterEvent()
1026 // purpose  : Mouse enter event
1027 //=================================================================================
1028 void SMESHGUI_ExtrusionAlongPathDlg::enterEvent(QEvent* e)
1029 {
1030   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::enterEvent");
1031   if ( ElementsTypeGrp->isEnabled() )
1032     return;  
1033   ActivateThisDialog();
1034 }
1035
1036 //=================================================================================
1037 // function : SMESHGUI_ExtrusionAlongPathDlg::reject()
1038 // purpose  : Called when dialog box is closed
1039 //=================================================================================
1040 void SMESHGUI_ExtrusionAlongPathDlg::reject()
1041 {
1042   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::reject");
1043   disconnect( mySelection, 0, this, 0 );
1044   mySelection->ClearFilters();
1045   mySelection->ClearIObjects();
1046   SMESH::SetPickable();
1047   SMESH::SetPointRepresentation( false );
1048   QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
1049   mySMESHGUI->ResetState() ;
1050   QDialog::reject();
1051 }
1052
1053 //=================================================================================
1054 // function : SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1055 // purpose  : 
1056 //=================================================================================
1057 int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1058
1059   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId");
1060   if ( ElementsTypeGrp != NULL && ElementsTypeGrp->selected() != NULL )
1061     return ElementsTypeGrp->id( ElementsTypeGrp->selected() );
1062   return -1;
1063 }
1064
1065 //=======================================================================
1066 // function : SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh
1067 // purpose  :
1068 //=======================================================================
1069 void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh()
1070 {
1071   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh");
1072   bool toSelectMesh = MeshCheck->isChecked();
1073   
1074   ElementsLineEdit->setReadOnly( toSelectMesh );
1075   ElementsLab->setText( toSelectMesh ? tr( "SMESH_NAME" ) : tr( "SMESH_ID_ELEMENTS" ) );
1076   ElementsLineEdit->clear();
1077   
1078   SetEditCurrentArgument( SelectElementsButton );
1079 }
1080
1081 //=======================================================================
1082 // function : SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck
1083 // purpose  : called when "Use Angles" check box is switched
1084 //=======================================================================
1085 void SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck()
1086 {
1087   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck");
1088   AnglesGrp->setEnabled( AnglesCheck->isChecked() );
1089 }
1090
1091 //=======================================================================
1092 // function : SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck
1093 // purpose  : called when "Use Base Point" check box is switched
1094 //=======================================================================
1095 void SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck()
1096 {
1097   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck");
1098   BasePointGrp->setEnabled( BasePointCheck->isChecked() );
1099 }
1100
1101 //=======================================================================
1102 // function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded
1103 // purpose  : Called when user adds angle to the list
1104 //=======================================================================
1105 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
1106 {
1107   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded");
1108   AnglesList->insertItem( QString::number( AngleSpin->GetValue() ) );
1109 }
1110
1111 //=======================================================================
1112 // function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved
1113 // purpose  : Called when user removes angle(s) from the list
1114 //=======================================================================
1115 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
1116 {
1117   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved");
1118   QList<QListBoxItem> aList;
1119   aList.setAutoDelete( false );
1120   for ( int i = 0; i < AnglesList->count(); i++ )
1121     if ( AnglesList->isSelected( i ) )
1122       aList.append( AnglesList->item( i ) );
1123
1124   for ( int i = 0; i < aList.count(); i++ )
1125     delete aList.at( i );
1126 }
1127