Salome HOME
989518fe02b671162ec32071a150deb6d87dbf72
[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 base point defining
184   BasePointCheck = new QCheckBox( tr( "SMESH_USE_BASE_POINT" ), ArgumentsGrp );
185
186   BasePointGrp = new QGroupBox( tr( "SMESH_BASE_POINT" ), ArgumentsGrp );
187   BasePointGrp->setColumnLayout( 0, Qt::Vertical );
188   BasePointGrp->layout()->setSpacing( 0 ); BasePointGrp->layout()->setMargin( 0 );
189   QGridLayout* BasePointGrpLayout = new QGridLayout( BasePointGrp->layout() );
190   BasePointGrpLayout->setAlignment( Qt::AlignTop );
191   BasePointGrpLayout->setSpacing( 6 ); BasePointGrpLayout->setMargin( 11 );
192   
193   SelectBasePointButton = new QToolButton( BasePointGrp );
194   SelectBasePointButton->setPixmap( selectImage );
195
196   XLab  = new QLabel( tr( "SMESH_X" ), BasePointGrp );
197   XSpin = new SMESHGUI_SpinBox( BasePointGrp );
198   YLab  = new QLabel( tr( "SMESH_Y" ), BasePointGrp );
199   YSpin = new SMESHGUI_SpinBox( BasePointGrp );
200   ZLab  = new QLabel( tr( "SMESH_Z" ), BasePointGrp );
201   ZSpin = new SMESHGUI_SpinBox( BasePointGrp );
202
203   // layouting
204   BasePointGrpLayout->addWidget( SelectBasePointButton, 0, 0 );
205   BasePointGrpLayout->addWidget( XLab,                  0, 1 );
206   BasePointGrpLayout->addWidget( XSpin,                 0, 2 );
207   BasePointGrpLayout->addWidget( YLab,                  0, 3 );
208   BasePointGrpLayout->addWidget( YSpin,                 0, 4 );
209   BasePointGrpLayout->addWidget( ZLab,                  0, 5 );
210   BasePointGrpLayout->addWidget( ZSpin,                 0, 6 );
211
212   // Controls for angles defining
213   AnglesCheck = new QCheckBox( tr( "SMESH_USE_ANGLES" ), ArgumentsGrp );
214   
215   AnglesGrp = new QGroupBox( tr( "SMESH_ANGLES" ), ArgumentsGrp );
216   AnglesGrp->setColumnLayout( 0, Qt::Vertical );
217   AnglesGrp->layout()->setSpacing( 0 ); AnglesGrp->layout()->setMargin( 0 );
218   QGridLayout* AnglesGrpLayout = new QGridLayout( AnglesGrp->layout() );
219   AnglesGrpLayout->setAlignment( Qt::AlignTop );
220   AnglesGrpLayout->setSpacing( 6 ); AnglesGrpLayout->setMargin( 11 );
221   
222   AnglesList = new QListBox( AnglesGrp );
223   AnglesList->setSelectionMode( QListBox::Extended );
224
225   AddAngleButton = new QToolButton( AnglesGrp ); 
226   AddAngleButton->setPixmap( addImage );
227
228   RemoveAngleButton = new QToolButton( AnglesGrp ); 
229   RemoveAngleButton->setPixmap( removeImage );
230
231   AngleSpin = new SMESHGUI_SpinBox( AnglesGrp );
232
233   // layouting
234   QVBoxLayout* bLayout = new QVBoxLayout(); 
235   bLayout->addWidget( AddAngleButton );
236   bLayout->addSpacing( 6 );
237   bLayout->addWidget( RemoveAngleButton );
238   bLayout->addStretch();
239   AnglesGrpLayout->addMultiCellWidget( AnglesList, 0, 1, 0, 0 );
240   AnglesGrpLayout->addMultiCellLayout( bLayout,    0, 1, 1, 1 );
241   AnglesGrpLayout->addWidget(          AngleSpin,  0,    2    );
242   AnglesGrpLayout->setRowStretch( 1, 10 );
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(          BasePointCheck,         3,    0    );
251   ArgumentsGrpLayout->addMultiCellWidget( BasePointGrp,           3, 4, 1, 2 );
252   ArgumentsGrpLayout->addWidget(          AnglesCheck,            5,    0    );
253   ArgumentsGrpLayout->addMultiCellWidget( AnglesGrp,              5, 6, 1, 2 );
254   ArgumentsGrpLayout->setRowStretch( 6, 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       double angle = AnglesList->text( i ).toDouble( &bOk );
583       if  ( bOk )
584         anAngles[ j++ ] = angle*PI/180;
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     SMESH::SMESH_MeshEditor::Extrusion_Error retVal = 
601       aMeshEditor->ExtrusionAlongPath( anElementsId.inout(), myPathMesh, myPathShape, aNodeStart, 
602                                        AnglesCheck->isChecked(), anAngles.inout(), 
603                                        BasePointCheck->isChecked(), aBasePoint );
604
605     wc.stop();
606     switch ( retVal ) {
607     case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS:
608       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
609                              tr( "SMESH_ERROR" ),
610                              tr( "NO_ELEMENTS_SELECTED" ),
611                              tr( "SMESH_BUT_OK" ) );
612       return false; break;
613     case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE:
614       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
615                              tr( "SMESH_ERROR" ),
616                              tr( "SELECTED_PATH_IS_NOT_EDGE" ),
617                              tr( "SMESH_BUT_OK" ) );
618       return false; break;
619     case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE:
620       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
621                              tr( "SMESH_ERROR" ),
622                              tr( "BAD_SHAPE_TYPE" ),
623                              tr( "SMESH_BUT_OK" ) );
624       return false; break;
625     case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE:
626       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
627                              tr( "SMESH_ERROR" ),
628                              tr( "EXTR_BAD_STARTING_NODE" ),
629                              tr( "SMESH_BUT_OK" ) );
630       return false; break;
631     case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER:
632       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
633                              tr( "SMESH_ERROR" ),
634                              tr( "WRONG_ANGLES_NUMBER" ),
635                              tr( "SMESH_BUT_OK" ) );
636       return false; break;
637     case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT:
638       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
639                              tr( "SMESH_ERROR" ),
640                              tr( "CANT_GET_TANGENT" ),
641                              tr( "SMESH_BUT_OK" ) );
642       return false; break;
643     case SMESH::SMESH_MeshEditor::EXTR_OK:
644       break;
645     }
646   }
647   catch( ... ) {
648     return false;
649   }
650     
651   mySelection->ClearIObjects();
652   SMESH::UpdateView();
653   Init( false );
654   TypeChanged( GetConstructorId() );
655   return true;
656 }
657
658 //=================================================================================
659 // function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
660 // purpose  : Called when user presses <OK> button
661 //=================================================================================
662 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
663 {
664   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk");
665   if ( !ClickOnApply() )
666     return;
667   reject();
668 }
669
670 //=======================================================================
671 // function : SMESHGUI_ExtrusionAlongPathDlg::onTextChange
672 // purpose  : 
673 //=======================================================================
674
675 void SMESHGUI_ExtrusionAlongPathDlg::onTextChange(const QString& theNewText)
676 {
677   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onTextChange");
678   QLineEdit* send = (QLineEdit*)sender();
679   if ( send != StartPointLineEdit && send != ElementsLineEdit )
680     send = ElementsLineEdit;
681
682   // return if busy
683   if ( myBusy ) 
684     return;
685
686   // set busy flag
687   SetBusy sb( this );
688   
689   if ( send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit ) {
690     // hilight entered elements
691     SMDS_Mesh* aMesh = 0;
692     if ( myMeshActor )
693       aMesh = myMeshActor->GetObject()->GetMesh();
694     if ( aMesh ) {
695       mySelection->ClearIObjects();
696       mySelection->AddIObject( myMeshActor->getIO() );
697       
698       QStringList aListId = QStringList::split( " ", theNewText, false );
699       bool bOk;
700       for ( int i = 0; i < aListId.count(); i++ ) {
701         long ind = aListId[ i ].toLong( &bOk );
702         if ( bOk ) {
703           const SMDS_MeshElement* e = aMesh->FindElement( ind );
704           if ( e ) {
705             // check also type of element
706             bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || 
707                              Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
708             if ( typeMatch ) {
709               if ( !mySelection->IsIndexSelected( myMeshActor->getIO(), e->GetID() ) )
710                 mySelection->AddOrRemoveIndex( myMeshActor->getIO(), e->GetID(), true );
711             }
712           }
713         }
714       }
715     }
716   }
717   else if ( send == StartPointLineEdit && myEditCurrentArgument == StartPointLineEdit ) {
718     if ( !myPathMesh->_is_nil() ) {
719       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
720       SMDS_Mesh* aMesh = 0;
721       if ( aPathActor )
722         aMesh = aPathActor->GetObject()->GetMesh();
723       if ( aMesh ) {
724         mySelection->ClearIObjects();
725         mySelection->AddIObject( aPathActor->getIO() );
726       
727         bool bOk;
728         long ind = theNewText.toLong( &bOk );
729         if ( bOk ) {
730           const SMDS_MeshNode* n = aMesh->FindNode( ind );
731           if ( n ) {
732             if ( !mySelection->IsIndexSelected( aPathActor->getIO(), n->GetID() ) ) {
733               mySelection->AddOrRemoveIndex( aPathActor->getIO(), n->GetID(), true );
734             }
735           }
736         }
737       }
738     }
739   }
740 }
741
742 //=================================================================================
743 // function : SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
744 // purpose  : Called when selection as changed or other case
745 //=================================================================================
746 void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
747 {
748   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument");
749   // return if busy
750   if ( myBusy ) 
751     return;
752   
753   // return if dialog box is inactive
754   if ( !ButtonsGrp->isEnabled() )
755     return;
756
757   // selected objects count
758   int nbSel = mySelection->IObjectCount();
759
760   // set busy flag
761   SetBusy sb( this );
762
763   if ( myEditCurrentArgument == ElementsLineEdit ) {
764     // we are now selecting mesh elements (or whole mesh/submesh/group)
765     // reset
766     ElementsLineEdit->clear();
767     myMesh      = SMESH::SMESH_Mesh::_nil();
768     myIDSource  = SMESH::SMESH_IDSource::_nil();
769     myMeshActor = 0;
770     
771     // only one object is acceptable
772     if( nbSel != 1 )
773       return;
774
775     // try to get mesh from selection
776     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
777     myMesh = SMESH::GetMeshByIO( IO );
778     if( myMesh->_is_nil() )
779       return;
780     // find actor
781     myMeshActor = SMESH::FindActorByObject( myMesh );
782     if ( !myMeshActor )
783       return;
784
785     if ( MeshCheck->isChecked() ) {
786       // If "Select whole mesh, submesh or group" check box is on ->
787       // get ID source and put it's name to the edit box
788       QString aString;
789       SMESH::GetNameOfSelectedIObjects( mySelection, aString );
790
791       myIDSource = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
792       ElementsLineEdit->setText( aString );
793     }
794     else {
795       // If "Select whole mesh, submesh or group" check box is off ->
796       // try to get selected elements IDs
797       QString aString;
798       int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString );
799       ElementsLineEdit->setText( aString );
800     }
801   }
802   else if ( myEditCurrentArgument == PathMeshLineEdit ) {
803     // we are now selecting path mesh
804     // reset
805     PathMeshLineEdit->clear();
806     myPathMesh = SMESH::SMESH_Mesh::_nil();
807     PathShapeLineEdit->clear();
808     myPathShape = GEOM::GEOM_Object::_nil();
809     StartPointLineEdit->clear();
810
811     // only one object is acceptable
812     if( nbSel != 1 )
813       return;
814
815     // try to get mesh from selection
816     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
817     myPathMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( IO );
818     if( myPathMesh->_is_nil() )
819       return;
820
821     QString aString;
822     SMESH::GetNameOfSelectedIObjects( mySelection, aString );
823     PathMeshLineEdit->setText( aString );
824   }
825   else if ( myEditCurrentArgument == PathShapeLineEdit ) {
826     // we are now selecting path mesh
827     // reset
828     PathShapeLineEdit->clear();
829     myPathShape = GEOM::GEOM_Object::_nil();
830     StartPointLineEdit->clear();
831
832     // return if path mesh is not yet selected
833     if ( myPathMesh->_is_nil() )
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     myPathShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO );
843     if ( myPathShape->_is_nil() )
844       return;
845
846     QString aString;
847     SMESH::GetNameOfSelectedIObjects( mySelection, aString );
848     PathShapeLineEdit->setText( aString );
849   }
850   else if ( myEditCurrentArgument == StartPointLineEdit ) {
851     // we are now selecting start point of path
852     // reset
853     StartPointLineEdit->clear();
854
855     // return if path mesh or path shape is not yet selected
856     if ( myPathMesh->_is_nil() || myPathShape->_is_nil() )
857       return;
858
859     // only one object is acceptable
860     if( nbSel != 1 )
861       return;
862
863     // try to get shape from selection
864     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
865     
866     QString aString;
867     int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString );
868     if ( aNbUnits == 1 )
869       StartPointLineEdit->setText( aString.stripWhiteSpace() );
870   }
871   else if ( myEditCurrentArgument == XSpin ) {
872     // we are now selecting base point
873     // reset is not performed here!
874
875     // return if is not enabled
876     if ( !BasePointGrp->isEnabled() ) 
877       return;
878
879     // only one object is acceptable
880     if( nbSel != 1 )
881       return;
882     
883     // try to get shape from selection
884     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
885     
886     // check if geom vertex is selected
887     GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO );
888     TopoDS_Vertex aVertex;
889     if( !aGeomObj->_is_nil() ) {
890       if(  aGeomObj->IsShape() && GEOMBase::GetShape( aGeomObj, aVertex ) && !aVertex.IsNull() ) {
891         gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
892         XSpin->SetValue( aPnt.X() );
893         YSpin->SetValue( aPnt.Y() );
894         ZSpin->SetValue( aPnt.Z() );
895       }
896       return;
897     }
898
899     // check if smesh node is selected
900     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO );
901     if( aMesh->_is_nil() )
902       return;
903
904     QString aString;
905     int aNbUnits = SMESH::GetNameOfSelectedNodes( mySelection, aString );
906     // return if more than one node is selected
907     if( aNbUnits != 1 )
908       return;
909       
910     SMESH_Actor* aMeshActor = SMESH::FindActorByObject( aMesh );
911     if ( !aMeshActor )
912       return;
913
914     SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
915     if (!mesh)
916       return;
917
918     const SMDS_MeshNode* n = mesh->FindNode( aString.toLong() );
919     if ( !n )
920       return;
921
922     XSpin->SetValue( n->X() );
923     YSpin->SetValue( n->Y() );
924     ZSpin->SetValue( n->Z() );
925   }
926 }
927
928 //=================================================================================
929 // function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
930 // purpose  :
931 //=================================================================================
932 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
933 {
934   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument");
935   QToolButton* send = (QToolButton*)sender();
936   if ( send != SelectElementsButton   && 
937        send != SelectPathMeshButton   && 
938        send != SelectPathShapeButton  && 
939        send != SelectStartPointButton && 
940        send != SelectBasePointButton )
941     return;
942   SetEditCurrentArgument( send );
943 }
944
945 //=================================================================================
946 // function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
947 // purpose  :
948 //=================================================================================
949 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument( QToolButton* button )
950 {
951   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument(button)");
952   disconnect( mySelection, 0, this, 0 );
953   mySelection->ClearIObjects();
954   mySelection->ClearFilters();
955   SMESH::SetPickable();
956   
957   if( button == SelectElementsButton ) {
958     myEditCurrentArgument = ElementsLineEdit;
959     SMESH::SetPointRepresentation( false );
960     if ( MeshCheck->isChecked() ) {
961       QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
962       mySelection->AddFilter( myElementsFilter );
963     }
964     else  {
965       if ( Elements1dRB->isChecked() )
966         QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
967       else if ( Elements2dRB->isChecked() )
968         QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
969     }
970   }
971   else if ( button == SelectPathMeshButton ) {
972     myEditCurrentArgument = PathMeshLineEdit;
973     SMESH::SetPointRepresentation( false );
974     QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
975     mySelection->AddFilter( myPathMeshFilter );
976   }
977   else if ( button == SelectPathShapeButton ) {
978     myEditCurrentArgument = PathShapeLineEdit;
979     SMESH::SetPointRepresentation( false );
980     QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
981
982     if ( !myPathMesh->_is_nil() ) {
983       GEOM::GEOM_Object_var aMainShape = myPathMesh->GetShapeToMesh();
984       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
985
986       if ( !aMainShape->_is_nil() && aPathActor )
987         mySelection->AddFilter( new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_EDGE, aMainShape ) );
988         //SMESH::SetPickable( aPathActor );
989     }
990   }
991   else if ( button == SelectStartPointButton ) {
992     myEditCurrentArgument = StartPointLineEdit;
993     if ( !myPathMesh->_is_nil() ) {
994       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
995       if ( aPathActor ) {
996         SMESH::SetPointRepresentation( true );
997         QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
998         SMESH::SetPickable( aPathActor );
999       }
1000     }
1001   }
1002   else if ( button == SelectBasePointButton ) {
1003     myEditCurrentArgument = XSpin;
1004     SMESH::SetPointRepresentation( true );
1005     QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
1006
1007     SMESH_ListOfFilter aListOfFilters;
1008     Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
1009     if ( !aMeshOrSubMeshFilter.IsNull() )
1010       aListOfFilters.Append( aMeshOrSubMeshFilter );
1011     Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
1012     if ( !aSmeshGroupFilter.IsNull() )
1013       aListOfFilters.Append( aSmeshGroupFilter );
1014     //Handle(GEOM_ShapeTypeFilter) aVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX );
1015     Handle(SMESH_NumberFilter) aVertexFilter = new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_VERTEX, GEOM::GEOM_Object::_nil() );
1016     if ( !aVertexFilter.IsNull() )
1017       aListOfFilters.Append( aVertexFilter );
1018   
1019     mySelection->AddFilter( new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ) );
1020   }
1021
1022   if ( myEditCurrentArgument && !myEditCurrentArgument->hasFocus() )
1023     myEditCurrentArgument->setFocus();
1024
1025   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1026   SelectionIntoArgument();
1027 }
1028
1029 //=================================================================================
1030 // function : SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
1031 // purpose  : Deactivates this dialog
1032 //=================================================================================
1033 void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
1034 {
1035   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog");
1036   if ( ElementsTypeGrp->isEnabled() ) {
1037     ElementsTypeGrp->setEnabled( false );
1038     ArgumentsGrp->setEnabled( false );
1039     ButtonsGrp->setEnabled( false );
1040     mySMESHGUI->ResetState();    
1041     mySMESHGUI->SetActiveDialogBox( 0 );
1042   }
1043 }
1044
1045 //=================================================================================
1046 // function : SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1047 // purpose  : Activates this dialog
1048 //=================================================================================
1049 void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1050 {
1051   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog");
1052   // Emit a signal to deactivate the active dialog
1053   mySMESHGUI->EmitSignalDeactivateDialog();   
1054   ElementsTypeGrp->setEnabled( true );
1055   ArgumentsGrp->setEnabled( true );
1056   ButtonsGrp->setEnabled( true );
1057   
1058   mySMESHGUI->SetActiveDialogBox( this );
1059
1060   TypeChanged( GetConstructorId() );
1061   SelectionIntoArgument();
1062 }
1063
1064 //=================================================================================
1065 // function : SMESHGUI_ExtrusionAlongPathDlg::enterEvent()
1066 // purpose  : Mouse enter event
1067 //=================================================================================
1068 void SMESHGUI_ExtrusionAlongPathDlg::enterEvent(QEvent* e)
1069 {
1070   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::enterEvent");
1071   if ( ElementsTypeGrp->isEnabled() )
1072     return;  
1073   ActivateThisDialog();
1074 }
1075
1076 //=================================================================================
1077 // function : SMESHGUI_ExtrusionAlongPathDlg::reject()
1078 // purpose  : Called when dialog box is closed
1079 //=================================================================================
1080 void SMESHGUI_ExtrusionAlongPathDlg::reject()
1081 {
1082   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::reject");
1083   disconnect( mySelection, 0, this, 0 );
1084   mySelection->ClearFilters();
1085   mySelection->ClearIObjects();
1086   SMESH::SetPickable();
1087   SMESH::SetPointRepresentation( false );
1088   QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
1089   mySMESHGUI->ResetState() ;
1090   QDialog::reject();
1091 }
1092
1093 //=================================================================================
1094 // function : SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1095 // purpose  : 
1096 //=================================================================================
1097 int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1098
1099   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId");
1100   if ( ElementsTypeGrp != NULL && ElementsTypeGrp->selected() != NULL )
1101     return ElementsTypeGrp->id( ElementsTypeGrp->selected() );
1102   return -1;
1103 }
1104
1105 //=======================================================================
1106 // function : SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh
1107 // purpose  :
1108 //=======================================================================
1109 void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh()
1110 {
1111   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh");
1112   bool toSelectMesh = MeshCheck->isChecked();
1113   
1114   ElementsLineEdit->setReadOnly( toSelectMesh );
1115   ElementsLab->setText( toSelectMesh ? tr( "SMESH_NAME" ) : tr( "SMESH_ID_ELEMENTS" ) );
1116   ElementsLineEdit->clear();
1117   
1118   SetEditCurrentArgument( SelectElementsButton );
1119 }
1120
1121 //=======================================================================
1122 // function : SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck
1123 // purpose  : called when "Use Angles" check box is switched
1124 //=======================================================================
1125 void SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck()
1126 {
1127   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck");
1128   AnglesGrp->setEnabled( AnglesCheck->isChecked() );
1129 }
1130
1131 //=======================================================================
1132 // function : SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck
1133 // purpose  : called when "Use Base Point" check box is switched
1134 //=======================================================================
1135 void SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck()
1136 {
1137   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck");
1138   BasePointGrp->setEnabled( BasePointCheck->isChecked() );
1139 }
1140
1141 //=======================================================================
1142 // function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded
1143 // purpose  : Called when user adds angle to the list
1144 //=======================================================================
1145 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
1146 {
1147   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded");
1148   AnglesList->insertItem( QString::number( AngleSpin->GetValue() ) );
1149 }
1150
1151 //=======================================================================
1152 // function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved
1153 // purpose  : Called when user removes angle(s) from the list
1154 //=======================================================================
1155 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
1156 {
1157   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved");
1158   QList<QListBoxItem> aList;
1159   aList.setAutoDelete( false );
1160   for ( int i = 0; i < AnglesList->count(); i++ )
1161     if ( AnglesList->isSelected( i ) )
1162       aList.append( AnglesList->item( i ) );
1163
1164   for ( int i = 0; i < aList.count(); i++ )
1165     delete aList.at( i );
1166 }
1167