Salome HOME
PAL9022. before algo->Compute(), clean only elements directly bound to the shape...
[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( COORD_MIN, COORD_MAX, 10.0, 3 );
291   YSpin->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
292   ZSpin->RangeStepAndValidator( COORD_MIN, COORD_MAX, 10.0, 3 );
293   AngleSpin->RangeStepAndValidator( COORD_MIN, COORD_MAX, 5.0, 3 );
294   //?? AngleSpin->RangeStepAndValidator( -360., +360., 5.0, 3 );
295
296   mySelection = Sel;  
297   mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
298   mySMESHGUI->SetActiveDialogBox( this ) ;
299   
300   // Costruction of the logical filter for the elements: mesh/sub-mesh/group
301   SMESH_ListOfFilter aListOfFilters;
302   Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
303   if ( !aMeshOrSubMeshFilter.IsNull() )
304     aListOfFilters.Append( aMeshOrSubMeshFilter );
305   Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
306   if ( !aSmeshGroupFilter.IsNull() )
307     aListOfFilters.Append( aSmeshGroupFilter );
308   
309   myElementsFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR );
310   
311   myPathMeshFilter = new SMESH_TypeFilter( MESH );
312   
313   Init();
314
315   /***************************************************************/
316   // signals-slots connections
317   connect( OkButton,     SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
318   connect( CloseButton,  SIGNAL( clicked() ), this, SLOT( reject() ) ) ;
319   connect( ApplyButton,  SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
320
321   connect( AddAngleButton,    SIGNAL( clicked() ), this, SLOT( OnAngleAdded() ) );
322   connect( RemoveAngleButton, SIGNAL( clicked() ), this, SLOT( OnAngleRemoved() ) );
323
324   connect( ElementsTypeGrp, SIGNAL( clicked( int ) ), SLOT( TypeChanged( int ) ) );
325   
326   connect( SelectElementsButton,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
327   connect( SelectPathMeshButton,   SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
328   connect( SelectPathShapeButton,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
329   connect( SelectStartPointButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
330   connect( SelectBasePointButton,  SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
331
332   connect( mySMESHGUI,  SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;
333   connect( mySelection, SIGNAL( currentSelectionChanged() ),      this, SLOT( SelectionIntoArgument() ) );
334   connect( mySMESHGUI,  SIGNAL( SignalCloseAllDialogs() ),        this, SLOT( reject() ) ) ;
335
336   connect( ElementsLineEdit, SIGNAL( textChanged( const QString& ) ),
337            SLOT( onTextChange( const QString& ) ) );
338   connect( StartPointLineEdit, SIGNAL( textChanged( const QString& ) ),
339            SLOT( onTextChange( const QString& ) ) );
340
341   connect( MeshCheck,      SIGNAL( toggled( bool ) ), SLOT( onSelectMesh() ) );
342   connect( AnglesCheck,    SIGNAL( toggled( bool ) ), SLOT( onAnglesCheck() ) );
343   connect( BasePointCheck, SIGNAL( toggled( bool ) ), SLOT( onBasePointCheck() ) );
344
345   AnglesList->installEventFilter( this );
346   ElementsLineEdit->installEventFilter( this );
347   StartPointLineEdit->installEventFilter( this );
348   XSpin->editor()->installEventFilter( this );
349   YSpin->editor()->installEventFilter( this );
350   ZSpin->editor()->installEventFilter( this );
351
352   /***************************************************************/
353   // set position and show dialog box
354   int x, y ;
355   mySMESHGUI->DefineDlgPosition( this, x, y ) ;
356   this->move( x, y ) ;
357   this->show() ; // displays Dialog
358 }
359
360 //=================================================================================
361 // function : SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
362 // purpose  : destructor
363 //=================================================================================
364 SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg()
365 {
366   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::~SMESHGUI_ExtrusionAlongPathDlg");
367   // no need to delete child widgets, Qt does it all for us
368 }
369
370 //=================================================================================
371 // function : SMESHGUI_ExtrusionAlongPathDlg::eventFilter
372 // purpose  : event filter
373 //=================================================================================
374 bool SMESHGUI_ExtrusionAlongPathDlg::eventFilter( QObject* object, QEvent* event )
375 {
376   if ( event->type() == QEvent::KeyPress ) {
377     QKeyEvent* ke = ( QKeyEvent* )event;
378     if ( object == AnglesList ) {
379       if ( ke->key() == Key_Delete )
380         OnAngleRemoved();
381     }
382   }
383   else if ( event->type() == QEvent::FocusIn ) {
384     if ( object == ElementsLineEdit ) {
385       if ( myEditCurrentArgument != ElementsLineEdit )
386         SetEditCurrentArgument( SelectElementsButton );
387     }
388     else if ( object == StartPointLineEdit ) {
389       if ( myEditCurrentArgument != StartPointLineEdit )
390         SetEditCurrentArgument( SelectStartPointButton );
391     }
392     else if ( object == XSpin->editor() || object == YSpin->editor() || object == ZSpin->editor() ) {
393       if ( myEditCurrentArgument != XSpin )
394         SetEditCurrentArgument( SelectBasePointButton );
395     }
396   }
397   return QDialog::eventFilter( object, event );
398 }
399
400 //=================================================================================
401 // function : SMESHGUI_ExtrusionAlongPathDlg::Init()
402 // purpose  : initialization
403 //=================================================================================
404 void SMESHGUI_ExtrusionAlongPathDlg::Init( bool ResetControls )
405 {
406   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::Init");
407   myBusy = false;
408   myEditCurrentArgument = 0;
409  
410   myMesh      = SMESH::SMESH_Mesh::_nil();
411   myIDSource  = SMESH::SMESH_IDSource::_nil();
412   myMeshActor = 0;
413   myPathMesh  = SMESH::SMESH_Mesh::_nil();
414   myPathShape = GEOM::GEOM_Object::_nil();
415   
416   ElementsLineEdit->clear();
417   PathMeshLineEdit->clear();
418   PathShapeLineEdit->clear();
419   StartPointLineEdit->clear();
420
421   if( ResetControls ) {
422     XSpin->SetValue( 0.0 );
423     YSpin->SetValue( 0.0 );
424     ZSpin->SetValue( 0.0 );
425     
426     AngleSpin->SetValue( 45 );
427     MeshCheck->setChecked( false );
428     TypeChanged( 0 );
429     onSelectMesh();
430     onAnglesCheck();
431     onBasePointCheck();
432   }
433   SetEditCurrentArgument( 0 );
434 }
435
436 //=================================================================================
437 // function : SMESHGUI_ExtrusionAlongPathDlg::TypeChanged()
438 // purpose  : Called when user changes type of elements ( 1d / 2d )
439 //=================================================================================
440 void SMESHGUI_ExtrusionAlongPathDlg::TypeChanged( int type )
441 {
442   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::TypeChanged");
443   if ( myType != type ) {
444     disconnect( mySelection, 0, this, 0 );
445     
446     if ( type == 0 )
447       ArgumentsGrp->setTitle( tr( "EXTRUSION_1D" ) );
448     else if ( type == 1 )
449       ArgumentsGrp->setTitle( tr( "EXTRUSION_2D" ) );
450     
451     // clear elements ID list
452     if ( !MeshCheck->isChecked() ) {
453       ElementsLineEdit->clear();
454     }
455     // set selection mode if necessary
456     if( myEditCurrentArgument == ElementsLineEdit ) {
457       mySelection->ClearIObjects();
458       mySelection->ClearFilters();
459       SMESH::SetPickable();
460   
461       SMESH::SetPointRepresentation( false );
462       if ( MeshCheck->isChecked() ) {
463         QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
464         mySelection->AddFilter( myElementsFilter );
465       }
466       else  {
467         if ( type == 0 )
468           QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
469         if ( type == 1 )
470           QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
471       }
472     }
473     connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
474   }
475   myType = type;
476
477
478
479 //=================================================================================
480 // function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
481 // purpose  : Called when user presses <Apply> button
482 //=================================================================================
483 bool SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply()
484 {
485   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnApply");
486   if ( mySMESHGUI->ActiveStudyLocked() ) {
487     return false;
488   }
489   
490   if( myMesh->_is_nil() || MeshCheck->isChecked() && myIDSource->_is_nil() || !myMeshActor || myPathMesh->_is_nil() || myPathShape->_is_nil() ) {
491     return false;
492   }
493
494   SMESH::long_array_var anElementsId = new SMESH::long_array;
495
496   if ( MeshCheck->isChecked() ) {
497     // If "Select whole mesh, submesh or group" check box is on ->
498     // get all elements of the required type from the object selected
499
500     // if MESH object is selected
501     if ( !CORBA::is_nil( SMESH::SMESH_Mesh::_narrow( myIDSource ) ) ) {
502       // get mesh
503       SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( myIDSource );
504       // get IDs from mesh...
505       if ( Elements1dRB->isChecked() )
506         // 1d elements
507         anElementsId = aMesh->GetElementsByType( SMESH::EDGE );
508       else if ( Elements2dRB->isChecked() ) {
509         anElementsId = aMesh->GetElementsByType( SMESH::FACE );
510       }
511     }
512     // SUBMESH is selected
513     if ( !CORBA::is_nil( SMESH::SMESH_subMesh::_narrow( myIDSource ) ) ) {
514       // get submesh
515       SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( myIDSource );
516       // get IDs from submesh
517       if ( Elements1dRB->isChecked() )
518         // 1d elements
519         anElementsId = aSubMesh->GetElementsByType( SMESH::EDGE );
520       else if ( Elements2dRB->isChecked() )
521         // 2d elements
522         anElementsId = aSubMesh->GetElementsByType( SMESH::FACE );
523     }  
524     // GROUP is selected
525     if ( !CORBA::is_nil( SMESH::SMESH_GroupBase::_narrow( myIDSource ) ) ) {
526       // get smesh group
527       SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( myIDSource );
528       // get IDs from group
529       // 1d elements or 2d elements
530       if ( Elements1dRB->isChecked() && aGroup->GetType() == SMESH::EDGE ||
531            Elements2dRB->isChecked() && aGroup->GetType() == SMESH::FACE )
532         anElementsId = aGroup->GetListOfID();
533     }
534   }
535   else {
536     // If "Select whole mesh, submesh or group" check box is off ->
537     // use only elements of given type selected by user
538
539     SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh();
540     if ( aMesh ) {
541       QStringList aListElementsId = QStringList::split( " ", ElementsLineEdit->text(), false );
542       anElementsId = new SMESH::long_array;
543       anElementsId->length( aListElementsId.count() );
544       bool bOk;
545       int j = 0;
546       for ( int i = 0; i < aListElementsId.count(); i++ ) {
547         long ind = aListElementsId[ i ].toLong( &bOk );
548         if  ( bOk ) {
549           const SMDS_MeshElement* e = aMesh->FindElement( ind );
550           if ( e ) {
551             bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || 
552                              Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
553             if ( typeMatch )
554               anElementsId[ j++ ] = ind;
555           }
556         }
557       }
558       anElementsId->length( j );
559     }
560   }
561       
562   if ( anElementsId->length() <= 0 ) {
563     return false;
564   }
565
566   if ( StartPointLineEdit->text().stripWhiteSpace().isEmpty() ) {
567     return false;
568   }
569   
570   bool bOk;
571   long aNodeStart = StartPointLineEdit->text().toLong( &bOk );
572   if ( !bOk ) {
573     return false;
574   }
575   
576   // get angles
577   SMESH::double_array_var anAngles = new SMESH::double_array;
578   if ( AnglesCheck->isChecked() ) {
579     anAngles->length( AnglesList->count() );
580     int j = 0;
581     bool bOk;
582     for ( int i = 0; i < AnglesList->count(); i++ ) {
583       double angle = AnglesList->text( i ).toDouble( &bOk );
584       if  ( bOk )
585         anAngles[ j++ ] = angle*PI/180;
586     }
587     anAngles->length( j );
588   }
589
590   // get base point
591   SMESH::PointStruct aBasePoint;
592   if ( BasePointCheck->isChecked() ) {
593     aBasePoint.x = XSpin->GetValue();
594     aBasePoint.y = YSpin->GetValue();
595     aBasePoint.z = ZSpin->GetValue();
596   }
597   
598   try {
599     QAD_WaitCursor wc;
600     SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
601     SMESH::SMESH_MeshEditor::Extrusion_Error retVal = 
602       aMeshEditor->ExtrusionAlongPath( anElementsId.inout(), myPathMesh, myPathShape, aNodeStart, 
603                                        AnglesCheck->isChecked(), anAngles.inout(), 
604                                        BasePointCheck->isChecked(), aBasePoint );
605
606     wc.stop();
607     switch ( retVal ) {
608     case SMESH::SMESH_MeshEditor::EXTR_NO_ELEMENTS:
609       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
610                              tr( "SMESH_ERROR" ),
611                              tr( "NO_ELEMENTS_SELECTED" ),
612                              tr( "SMESH_BUT_OK" ) );
613       return false; break;
614     case SMESH::SMESH_MeshEditor::EXTR_PATH_NOT_EDGE:
615       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
616                              tr( "SMESH_ERROR" ),
617                              tr( "SELECTED_PATH_IS_NOT_EDGE" ),
618                              tr( "SMESH_BUT_OK" ) );
619       return false; break;
620     case SMESH::SMESH_MeshEditor::EXTR_BAD_PATH_SHAPE:
621       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
622                              tr( "SMESH_ERROR" ),
623                              tr( "BAD_SHAPE_TYPE" ),
624                              tr( "SMESH_BUT_OK" ) );
625       return false; break;
626     case SMESH::SMESH_MeshEditor::EXTR_BAD_STARTING_NODE:
627       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
628                              tr( "SMESH_ERROR" ),
629                              tr( "EXTR_BAD_STARTING_NODE" ),
630                              tr( "SMESH_BUT_OK" ) );
631       return false; break;
632     case SMESH::SMESH_MeshEditor::EXTR_BAD_ANGLES_NUMBER:
633       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
634                              tr( "SMESH_ERROR" ),
635                              tr( "WRONG_ANGLES_NUMBER" ),
636                              tr( "SMESH_BUT_OK" ) );
637       return false; break;
638     case SMESH::SMESH_MeshEditor::EXTR_CANT_GET_TANGENT:
639       QAD_MessageBox::warn1( QAD_Application::getDesktop(),
640                              tr( "SMESH_ERROR" ),
641                              tr( "CANT_GET_TANGENT" ),
642                              tr( "SMESH_BUT_OK" ) );
643       return false; break;
644     case SMESH::SMESH_MeshEditor::EXTR_OK:
645       break;
646     }
647   }
648   catch( ... ) {
649     return false;
650   }
651     
652   mySelection->ClearIObjects();
653   SMESH::UpdateView();
654   Init( false );
655   TypeChanged( GetConstructorId() );
656   return true;
657 }
658
659 //=================================================================================
660 // function : SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
661 // purpose  : Called when user presses <OK> button
662 //=================================================================================
663 void SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk()
664 {
665   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ClickOnOk");
666   if ( !ClickOnApply() )
667     return;
668   reject();
669 }
670
671 //=======================================================================
672 // function : SMESHGUI_ExtrusionAlongPathDlg::onTextChange
673 // purpose  : 
674 //=======================================================================
675
676 void SMESHGUI_ExtrusionAlongPathDlg::onTextChange(const QString& theNewText)
677 {
678   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onTextChange");
679   QLineEdit* send = (QLineEdit*)sender();
680   if ( send != StartPointLineEdit && send != ElementsLineEdit )
681     send = ElementsLineEdit;
682
683   // return if busy
684   if ( myBusy ) 
685     return;
686
687   // set busy flag
688   SetBusy sb( this );
689   
690   if ( send == ElementsLineEdit && myEditCurrentArgument == ElementsLineEdit ) {
691     // hilight entered elements
692     SMDS_Mesh* aMesh = 0;
693     if ( myMeshActor )
694       aMesh = myMeshActor->GetObject()->GetMesh();
695     if ( aMesh ) {
696       mySelection->ClearIObjects();
697       mySelection->AddIObject( myMeshActor->getIO() );
698       
699       QStringList aListId = QStringList::split( " ", theNewText, false );
700       bool bOk;
701       for ( int i = 0; i < aListId.count(); i++ ) {
702         long ind = aListId[ i ].toLong( &bOk );
703         if ( bOk ) {
704           const SMDS_MeshElement* e = aMesh->FindElement( ind );
705           if ( e ) {
706             // check also type of element
707             bool typeMatch = Elements1dRB->isChecked() && e->GetType() == SMDSAbs_Edge || 
708                              Elements2dRB->isChecked() && e->GetType() == SMDSAbs_Face;
709             if ( typeMatch ) {
710               if ( !mySelection->IsIndexSelected( myMeshActor->getIO(), e->GetID() ) )
711                 mySelection->AddOrRemoveIndex( myMeshActor->getIO(), e->GetID(), true );
712             }
713           }
714         }
715       }
716     }
717   }
718   else if ( send == StartPointLineEdit && myEditCurrentArgument == StartPointLineEdit ) {
719     if ( !myPathMesh->_is_nil() ) {
720       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
721       SMDS_Mesh* aMesh = 0;
722       if ( aPathActor )
723         aMesh = aPathActor->GetObject()->GetMesh();
724       if ( aMesh ) {
725         mySelection->ClearIObjects();
726         mySelection->AddIObject( aPathActor->getIO() );
727       
728         bool bOk;
729         long ind = theNewText.toLong( &bOk );
730         if ( bOk ) {
731           const SMDS_MeshNode* n = aMesh->FindNode( ind );
732           if ( n ) {
733             if ( !mySelection->IsIndexSelected( aPathActor->getIO(), n->GetID() ) ) {
734               mySelection->AddOrRemoveIndex( aPathActor->getIO(), n->GetID(), true );
735             }
736           }
737         }
738       }
739     }
740   }
741 }
742
743 //=================================================================================
744 // function : SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
745 // purpose  : Called when selection as changed or other case
746 //=================================================================================
747 void SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument()
748 {
749   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SelectionIntoArgument");
750   // return if busy
751   if ( myBusy ) 
752     return;
753   
754   // return if dialog box is inactive
755   if ( !ButtonsGrp->isEnabled() )
756     return;
757
758   // selected objects count
759   int nbSel = mySelection->IObjectCount();
760
761   // set busy flag
762   SetBusy sb( this );
763
764   if ( myEditCurrentArgument == ElementsLineEdit ) {
765     // we are now selecting mesh elements (or whole mesh/submesh/group)
766     // reset
767     ElementsLineEdit->clear();
768     myMesh      = SMESH::SMESH_Mesh::_nil();
769     myIDSource  = SMESH::SMESH_IDSource::_nil();
770     myMeshActor = 0;
771     
772     // only one object is acceptable
773     if( nbSel != 1 )
774       return;
775
776     // try to get mesh from selection
777     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
778     myMesh = SMESH::GetMeshByIO( IO );
779     if( myMesh->_is_nil() )
780       return;
781     // find actor
782     myMeshActor = SMESH::FindActorByObject( myMesh );
783     if ( !myMeshActor )
784       return;
785
786     if ( MeshCheck->isChecked() ) {
787       // If "Select whole mesh, submesh or group" check box is on ->
788       // get ID source and put it's name to the edit box
789       QString aString;
790       SMESH::GetNameOfSelectedIObjects( mySelection, aString );
791
792       myIDSource = SMESH::IObjectToInterface<SMESH::SMESH_IDSource>( IO );
793       ElementsLineEdit->setText( aString );
794     }
795     else {
796       // If "Select whole mesh, submesh or group" check box is off ->
797       // try to get selected elements IDs
798       QString aString;
799       int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString );
800       ElementsLineEdit->setText( aString );
801     }
802   }
803   else if ( myEditCurrentArgument == PathMeshLineEdit ) {
804     // we are now selecting path mesh
805     // reset
806     PathMeshLineEdit->clear();
807     myPathMesh = SMESH::SMESH_Mesh::_nil();
808     PathShapeLineEdit->clear();
809     myPathShape = GEOM::GEOM_Object::_nil();
810     StartPointLineEdit->clear();
811
812     // only one object is acceptable
813     if( nbSel != 1 )
814       return;
815
816     // try to get mesh from selection
817     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
818     myPathMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>( IO );
819     if( myPathMesh->_is_nil() )
820       return;
821
822     QString aString;
823     SMESH::GetNameOfSelectedIObjects( mySelection, aString );
824     PathMeshLineEdit->setText( aString );
825   }
826   else if ( myEditCurrentArgument == PathShapeLineEdit ) {
827     // we are now selecting path mesh
828     // reset
829     PathShapeLineEdit->clear();
830     myPathShape = GEOM::GEOM_Object::_nil();
831     StartPointLineEdit->clear();
832
833     // return if path mesh is not yet selected
834     if ( myPathMesh->_is_nil() )
835       return;
836
837     // only one object is acceptable
838     if( nbSel != 1 )
839       return;
840
841     // try to get shape from selection
842     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
843     myPathShape = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO );
844     if ( myPathShape->_is_nil() )
845       return;
846
847     QString aString;
848     SMESH::GetNameOfSelectedIObjects( mySelection, aString );
849     PathShapeLineEdit->setText( aString );
850   }
851   else if ( myEditCurrentArgument == StartPointLineEdit ) {
852     // we are now selecting start point of path
853     // reset
854     StartPointLineEdit->clear();
855
856     // return if path mesh or path shape is not yet selected
857     if ( myPathMesh->_is_nil() || myPathShape->_is_nil() )
858       return;
859
860     // only one object is acceptable
861     if( nbSel != 1 )
862       return;
863
864     // try to get shape from selection
865     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
866     
867     QString aString;
868     int aNbUnits = SMESH::GetNameOfSelectedElements( mySelection, aString );
869     if ( aNbUnits == 1 )
870       StartPointLineEdit->setText( aString.stripWhiteSpace() );
871   }
872   else if ( myEditCurrentArgument == XSpin ) {
873     // we are now selecting base point
874     // reset is not performed here!
875
876     // return if is not enabled
877     if ( !BasePointGrp->isEnabled() ) 
878       return;
879
880     // only one object is acceptable
881     if( nbSel != 1 )
882       return;
883     
884     // try to get shape from selection
885     Handle( SALOME_InteractiveObject ) IO = mySelection->firstIObject();
886     
887     // check if geom vertex is selected
888     GEOM::GEOM_Object_var aGeomObj = SMESH::IObjectToInterface<GEOM::GEOM_Object>( IO );
889     TopoDS_Vertex aVertex;
890     if( !aGeomObj->_is_nil() ) {
891       if(  aGeomObj->IsShape() && GEOMBase::GetShape( aGeomObj, aVertex ) && !aVertex.IsNull() ) {
892         gp_Pnt aPnt = BRep_Tool::Pnt( aVertex );
893         XSpin->SetValue( aPnt.X() );
894         YSpin->SetValue( aPnt.Y() );
895         ZSpin->SetValue( aPnt.Z() );
896       }
897       return;
898     }
899
900     // check if smesh node is selected
901     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( IO );
902     if( aMesh->_is_nil() )
903       return;
904
905     QString aString;
906     int aNbUnits = SMESH::GetNameOfSelectedNodes( mySelection, aString );
907     // return if more than one node is selected
908     if( aNbUnits != 1 )
909       return;
910       
911     SMESH_Actor* aMeshActor = SMESH::FindActorByObject( aMesh );
912     if ( !aMeshActor )
913       return;
914
915     SMDS_Mesh* mesh = aMeshActor->GetObject()->GetMesh();
916     if (!mesh)
917       return;
918
919     const SMDS_MeshNode* n = mesh->FindNode( aString.toLong() );
920     if ( !n )
921       return;
922
923     XSpin->SetValue( n->X() );
924     YSpin->SetValue( n->Y() );
925     ZSpin->SetValue( n->Z() );
926   }
927 }
928
929 //=================================================================================
930 // function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
931 // purpose  :
932 //=================================================================================
933 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
934 {
935   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument");
936   QToolButton* send = (QToolButton*)sender();
937   if ( send != SelectElementsButton   && 
938        send != SelectPathMeshButton   && 
939        send != SelectPathShapeButton  && 
940        send != SelectStartPointButton && 
941        send != SelectBasePointButton )
942     return;
943   SetEditCurrentArgument( send );
944 }
945
946 //=================================================================================
947 // function : SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument()
948 // purpose  :
949 //=================================================================================
950 void SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument( QToolButton* button )
951 {
952   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::SetEditCurrentArgument(button)");
953   disconnect( mySelection, 0, this, 0 );
954   mySelection->ClearIObjects();
955   mySelection->ClearFilters();
956   SMESH::SetPickable();
957   
958   if( button == SelectElementsButton ) {
959     myEditCurrentArgument = ElementsLineEdit;
960     SMESH::SetPointRepresentation( false );
961     if ( MeshCheck->isChecked() ) {
962       QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
963       mySelection->AddFilter( myElementsFilter );
964     }
965     else  {
966       if ( Elements1dRB->isChecked() )
967         QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true );
968       else if ( Elements2dRB->isChecked() )
969         QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true );
970     }
971   }
972   else if ( button == SelectPathMeshButton ) {
973     myEditCurrentArgument = PathMeshLineEdit;
974     SMESH::SetPointRepresentation( false );
975     QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
976     mySelection->AddFilter( myPathMeshFilter );
977   }
978   else if ( button == SelectPathShapeButton ) {
979     myEditCurrentArgument = PathShapeLineEdit;
980     SMESH::SetPointRepresentation( false );
981     QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
982
983     if ( !myPathMesh->_is_nil() ) {
984       GEOM::GEOM_Object_var aMainShape = myPathMesh->GetShapeToMesh();
985       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
986
987       if ( !aMainShape->_is_nil() && aPathActor )
988         mySelection->AddFilter( new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_EDGE, aMainShape ) );
989         //SMESH::SetPickable( aPathActor );
990     }
991   }
992   else if ( button == SelectStartPointButton ) {
993     myEditCurrentArgument = StartPointLineEdit;
994     if ( !myPathMesh->_is_nil() ) {
995       SMESH_Actor* aPathActor = SMESH::FindActorByObject( myPathMesh );
996       if ( aPathActor ) {
997         SMESH::SetPointRepresentation( true );
998         QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
999         SMESH::SetPickable( aPathActor );
1000       }
1001     }
1002   }
1003   else if ( button == SelectBasePointButton ) {
1004     myEditCurrentArgument = XSpin;
1005     SMESH::SetPointRepresentation( true );
1006     QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true );
1007
1008     SMESH_ListOfFilter aListOfFilters;
1009     Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH );
1010     if ( !aMeshOrSubMeshFilter.IsNull() )
1011       aListOfFilters.Append( aMeshOrSubMeshFilter );
1012     Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP );
1013     if ( !aSmeshGroupFilter.IsNull() )
1014       aListOfFilters.Append( aSmeshGroupFilter );
1015     //Handle(GEOM_ShapeTypeFilter) aVertexFilter = new GEOM_ShapeTypeFilter( TopAbs_VERTEX );
1016     Handle(SMESH_NumberFilter) aVertexFilter = new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, -1, TopAbs_VERTEX, GEOM::GEOM_Object::_nil() );
1017     if ( !aVertexFilter.IsNull() )
1018       aListOfFilters.Append( aVertexFilter );
1019   
1020     mySelection->AddFilter( new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ) );
1021   }
1022
1023   if ( myEditCurrentArgument && !myEditCurrentArgument->hasFocus() )
1024     myEditCurrentArgument->setFocus();
1025
1026   connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
1027   SelectionIntoArgument();
1028 }
1029
1030 //=================================================================================
1031 // function : SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
1032 // purpose  : Deactivates this dialog
1033 //=================================================================================
1034 void SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog()
1035 {
1036   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::DeactivateActiveDialog");
1037   if ( ElementsTypeGrp->isEnabled() ) {
1038     ElementsTypeGrp->setEnabled( false );
1039     ArgumentsGrp->setEnabled( false );
1040     ButtonsGrp->setEnabled( false );
1041     mySMESHGUI->ResetState();    
1042     mySMESHGUI->SetActiveDialogBox( 0 );
1043   }
1044 }
1045
1046 //=================================================================================
1047 // function : SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1048 // purpose  : Activates this dialog
1049 //=================================================================================
1050 void SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog()
1051 {
1052   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::ActivateThisDialog");
1053   // Emit a signal to deactivate the active dialog
1054   mySMESHGUI->EmitSignalDeactivateDialog();   
1055   ElementsTypeGrp->setEnabled( true );
1056   ArgumentsGrp->setEnabled( true );
1057   ButtonsGrp->setEnabled( true );
1058   
1059   mySMESHGUI->SetActiveDialogBox( this );
1060
1061   TypeChanged( GetConstructorId() );
1062   SelectionIntoArgument();
1063 }
1064
1065 //=================================================================================
1066 // function : SMESHGUI_ExtrusionAlongPathDlg::enterEvent()
1067 // purpose  : Mouse enter event
1068 //=================================================================================
1069 void SMESHGUI_ExtrusionAlongPathDlg::enterEvent(QEvent* e)
1070 {
1071   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::enterEvent");
1072   if ( ElementsTypeGrp->isEnabled() )
1073     return;  
1074   ActivateThisDialog();
1075 }
1076
1077 //=================================================================================
1078 // function : SMESHGUI_ExtrusionAlongPathDlg::reject()
1079 // purpose  : Called when dialog box is closed
1080 //=================================================================================
1081 void SMESHGUI_ExtrusionAlongPathDlg::reject()
1082 {
1083   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::reject");
1084   disconnect( mySelection, 0, this, 0 );
1085   mySelection->ClearFilters();
1086   mySelection->ClearIObjects();
1087   SMESH::SetPickable();
1088   SMESH::SetPointRepresentation( false );
1089   QAD_Application::getDesktop()->SetSelectionMode( ActorSelection );
1090   mySMESHGUI->ResetState() ;
1091   QDialog::reject();
1092 }
1093
1094 //=================================================================================
1095 // function : SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1096 // purpose  : 
1097 //=================================================================================
1098 int SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId()
1099
1100   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::GetConstructorId");
1101   if ( ElementsTypeGrp != NULL && ElementsTypeGrp->selected() != NULL )
1102     return ElementsTypeGrp->id( ElementsTypeGrp->selected() );
1103   return -1;
1104 }
1105
1106 //=======================================================================
1107 // function : SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh
1108 // purpose  :
1109 //=======================================================================
1110 void SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh()
1111 {
1112   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onSelectMesh");
1113   bool toSelectMesh = MeshCheck->isChecked();
1114   
1115   ElementsLineEdit->setReadOnly( toSelectMesh );
1116   ElementsLab->setText( toSelectMesh ? tr( "SMESH_NAME" ) : tr( "SMESH_ID_ELEMENTS" ) );
1117   ElementsLineEdit->clear();
1118   
1119   SetEditCurrentArgument( SelectElementsButton );
1120 }
1121
1122 //=======================================================================
1123 // function : SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck
1124 // purpose  : called when "Use Angles" check box is switched
1125 //=======================================================================
1126 void SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck()
1127 {
1128   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onAnglesCheck");
1129   AnglesGrp->setEnabled( AnglesCheck->isChecked() );
1130 }
1131
1132 //=======================================================================
1133 // function : SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck
1134 // purpose  : called when "Use Base Point" check box is switched
1135 //=======================================================================
1136 void SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck()
1137 {
1138   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::onBasePointCheck");
1139   BasePointGrp->setEnabled( BasePointCheck->isChecked() );
1140 }
1141
1142 //=======================================================================
1143 // function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded
1144 // purpose  : Called when user adds angle to the list
1145 //=======================================================================
1146 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded()
1147 {
1148   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleAdded");
1149   AnglesList->insertItem( QString::number( AngleSpin->GetValue() ) );
1150 }
1151
1152 //=======================================================================
1153 // function : SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved
1154 // purpose  : Called when user removes angle(s) from the list
1155 //=======================================================================
1156 void SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved()
1157 {
1158   MESSAGE("SMESHGUI_ExtrusionAlongPathDlg::OnAngleRemoved");
1159   QList<QListBoxItem> aList;
1160   aList.setAutoDelete( false );
1161   for ( int i = 0; i < AnglesList->count(); i++ )
1162     if ( AnglesList->isSelected( i ) )
1163       aList.append( AnglesList->item( i ) );
1164
1165   for ( int i = 0; i < aList.count(); i++ )
1166     delete aList.at( i );
1167 }
1168