Salome HOME
sources v1.2
[modules/geom.git] / src / GEOMGUI / GeometryGUI_FillingDlg.cxx
1 using namespace std;
2 //  File      : GeometryGUI_FillingDlg.cxx
3 //  Created   :
4 //  Author    : Lucien PIGNOLONI
5 //  Project   : SALOME
6 //  Module    : GeometryGUI
7 //  Copyright : OPEN CASCADE
8 //  $Header$
9
10
11 #include "GeometryGUI_FillingDlg.h"
12
13 #include "GeometryGUI.h"
14 #include "GEOM_ShapeTypeFilter.hxx"
15
16 #include <qbuttongroup.h>
17 #include <qgroupbox.h>
18 #include <qlabel.h>
19 #include <qlineedit.h>
20 #include <qpushbutton.h>
21 #include <qradiobutton.h>
22 #include <qspinbox.h>
23 #include <qlayout.h>
24 #include <qvariant.h>
25 #include <qtooltip.h>
26 #include <qwhatsthis.h>
27 #include <qvalidator.h>
28 #include <qimage.h>
29 #include <qpixmap.h>
30
31
32
33 //=================================================================================
34 // class    : GeometryGUI_FillingDlg()
35 // purpose  : Constructs a GeometryGUI_FillingDlg which is a child of 'parent', with the 
36 //            name 'name' and widget flags set to 'f'.
37 //            The dialog will by default be modeless, unless you set 'modal' to
38 //            TRUE to construct a modal dialog.
39 //=================================================================================
40 GeometryGUI_FillingDlg::GeometryGUI_FillingDlg( QWidget* parent,
41                                                 const char* name,
42                                                 SALOME_Selection* Sel,
43                                                 bool modal,
44                                                 WFlags fl )
45     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
46 {
47
48     QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_DLG_FILLING")));
49     QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "GeometryGUI",tr("ICON_SELECT")));
50
51     if ( !name )
52         setName( "GeometryGUI_FillingDlg" );
53     resize( 303, 275 ); 
54     setCaption( tr( "GEOM_FILLING_TITLE"  ) );
55     setSizeGripEnabled( TRUE );
56     GeometryGUI_FillingDlgLayout = new QGridLayout( this ); 
57     GeometryGUI_FillingDlgLayout->setSpacing( 6 );
58     GeometryGUI_FillingDlgLayout->setMargin( 11 );
59     
60
61     GroupConstructors = new QButtonGroup( this, "GroupConstructors" );
62     GroupConstructors->setTitle( tr( "GEOM_FILLING"  ) );
63     GroupConstructors->setExclusive( TRUE );
64     GroupConstructors->setColumnLayout(0, Qt::Vertical );
65     GroupConstructors->layout()->setSpacing( 0 );
66     GroupConstructors->layout()->setMargin( 0 );
67     GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() );
68     GroupConstructorsLayout->setAlignment( Qt::AlignTop );
69     GroupConstructorsLayout->setSpacing( 6 );
70     GroupConstructorsLayout->setMargin( 11 );
71
72     Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" );
73     Constructor1->setText( tr( ""  ) );
74     Constructor1->setPixmap( image0 );
75     Constructor1->setChecked( TRUE );
76     Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) );
77     Constructor1->setMinimumSize( QSize( 50, 0 ) );
78
79     GroupConstructorsLayout->addWidget( Constructor1, 0, 0 );
80     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
81     GroupConstructorsLayout->addItem( spacer, 0, 1 );
82
83     GeometryGUI_FillingDlgLayout->addWidget( GroupConstructors, 0, 0 );
84
85     GroupButtons = new QGroupBox( this, "GroupButtons" );
86     GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
87     GroupButtons->setTitle( tr( ""  ) );
88     GroupButtons->setColumnLayout(0, Qt::Vertical );
89     GroupButtons->layout()->setSpacing( 0 );
90     GroupButtons->layout()->setMargin( 0 );
91     GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
92     GroupButtonsLayout->setAlignment( Qt::AlignTop );
93     GroupButtonsLayout->setSpacing( 6 );
94     GroupButtonsLayout->setMargin( 11 );
95     buttonCancel = new QPushButton( GroupButtons, "buttonCancel" );
96     buttonCancel->setText( tr( "GEOM_BUT_CLOSE"  ) );
97     buttonCancel->setAutoDefault( TRUE );
98     GroupButtonsLayout->addWidget( buttonCancel, 0, 3 );
99     buttonApply = new QPushButton( GroupButtons, "buttonApply" );
100     buttonApply->setText( tr( "GEOM_BUT_APPLY"  ) );
101     buttonApply->setAutoDefault( TRUE );
102     GroupButtonsLayout->addWidget( buttonApply, 0, 1 );
103     QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
104     GroupButtonsLayout->addItem( spacer_9, 0, 2 );
105     buttonOk = new QPushButton( GroupButtons, "buttonOk" );
106     buttonOk->setText( tr( "GEOM_BUT_OK"  ) );
107     buttonOk->setAutoDefault( TRUE );
108     buttonOk->setDefault( TRUE );
109     GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
110
111     GeometryGUI_FillingDlgLayout->addWidget( GroupButtons, 2, 0 );
112
113 //      GroupC1 = new QGroupBox( this, "GroupC1" );
114 //      GroupC1->setTitle( tr( "GEOM_FILLING_ARG"  ) );
115 //      GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupC1->sizePolicy().hasHeightForWidth() ) );
116 //      GroupC1->setColumnLayout(0, Qt::Vertical );
117 //      GroupC1->layout()->setSpacing( 0 );
118 //      GroupC1->layout()->setMargin( 0 );
119 //      GroupC1Layout = new QGridLayout( GroupC1->layout() );
120 //      GroupC1Layout->setAlignment( Qt::AlignTop );
121 //      GroupC1Layout->setSpacing( 6 );
122 //      GroupC1Layout->setMargin( 11 );
123
124 //      LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
125 //      LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
126
127 //      GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 3, 5 );
128
129 //      TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
130 //      TextLabelC1A2->setText( tr( "GEOM_FILLING_MIN_DEG"  ) );
131 //      TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
132 //      TextLabelC1A2->setFrameShape( QLabel::NoFrame );
133 //      TextLabelC1A2->setFrameShadow( QLabel::Plain );
134
135 //      GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
136
137 //      LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" );
138 //      LineEditC1A2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2->sizePolicy().hasHeightForWidth() ) );
139 //      LineEditC1A2->setMinimumSize( QSize( 40, 0 ) );
140
141 //      GroupC1Layout->addMultiCellWidget( LineEditC1A2, 1, 1, 1, 2 );
142
143 //      TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
144 //      TextLabelC1A3->setText( tr( "GEOM_FILLING_MAX_DEG"  ) );
145 //      TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
146 //      TextLabelC1A3->setFrameShape( QLabel::NoFrame );
147 //      TextLabelC1A3->setFrameShadow( QLabel::Plain );
148
149 //      GroupC1Layout->addWidget( TextLabelC1A3, 1, 4 );
150
151 //      TextLabelC1A5 = new QLabel( GroupC1, "TextLabelC1A5" );
152 //      TextLabelC1A5->setText( tr( "GEOM_FILLING_TOL_2D"  ) );
153 //      TextLabelC1A5->setMinimumSize( QSize( 50, 0 ) );
154 //      TextLabelC1A5->setFrameShape( QLabel::NoFrame );
155 //      TextLabelC1A5->setFrameShadow( QLabel::Plain );
156
157 //      GroupC1Layout->addWidget( TextLabelC1A5, 2, 4 );
158
159 //      LineEditC1A3 = new QLineEdit( GroupC1, "LineEditC1A3" );
160 //      LineEditC1A3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A3->sizePolicy().hasHeightForWidth() ) );
161 //      LineEditC1A3->setMinimumSize( QSize( 40, 0 ) );
162
163 //      GroupC1Layout->addWidget( LineEditC1A3, 1, 5 );
164
165 //      LineEditC1A5 = new QLineEdit( GroupC1, "LineEditC1A5" );
166 //      LineEditC1A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A5->sizePolicy().hasHeightForWidth() ) );
167 //      LineEditC1A5->setMinimumSize( QSize( 40, 0 ) );
168
169 //      GroupC1Layout->addWidget( LineEditC1A5, 2, 5 );
170
171 //      TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
172 //      TextLabelC1A1->setText( tr( "GEOM_FILLING_COMPOUND"  ) );
173 //      TextLabelC1A1->setMinimumSize( QSize( 90, 0 ) );
174 //      TextLabelC1A1->setFrameShape( QLabel::NoFrame );
175 //      TextLabelC1A1->setFrameShadow( QLabel::Plain );
176
177 //      GroupC1Layout->addMultiCellWidget( TextLabelC1A1, 0, 0, 0, 1 );
178
179 //      SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
180 //      SelectButtonC1A1->setText( tr( ""  ) );
181 //      SelectButtonC1A1->setPixmap( image1 );
182
183 //      GroupC1Layout->addWidget( SelectButtonC1A1, 0, 2 );
184
185 //      TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
186 //      TextLabelC1A4->setText( tr( "GEOM_FILLING_TOL_3D"  ) );
187 //      TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
188 //      TextLabelC1A4->setFrameShape( QLabel::NoFrame );
189 //      TextLabelC1A4->setFrameShadow( QLabel::Plain );
190
191 //      GroupC1Layout->addWidget( TextLabelC1A4, 2, 0 );
192
193 //      TextLabelC1A6 = new QLabel( GroupC1, "TextLabelC1A6" );
194 //      TextLabelC1A6->setText( tr( "GEOM_FILLING_NB_ITER"  ) );
195 //      TextLabelC1A6->setMinimumSize( QSize( 50, 0 ) );
196 //      TextLabelC1A6->setFrameShape( QLabel::NoFrame );
197 //      TextLabelC1A6->setFrameShadow( QLabel::Plain );
198
199 //      GroupC1Layout->addWidget( TextLabelC1A6, 3, 0 );
200
201 //      LineEditC1A4 = new QLineEdit( GroupC1, "LineEditC1A4" );
202 //      LineEditC1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A4->sizePolicy().hasHeightForWidth() ) );
203 //      LineEditC1A4->setMinimumSize( QSize( 40, 0 ) );
204
205 //      GroupC1Layout->addMultiCellWidget( LineEditC1A4, 2, 2, 1, 2 );
206
207 //      LineEditC1A6 = new QLineEdit( GroupC1, "LineEditC1A6" );
208 //      LineEditC1A6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A6->sizePolicy().hasHeightForWidth() ) );
209 //      LineEditC1A6->setMinimumSize( QSize( 40, 0 ) );
210
211 //      GroupC1Layout->addMultiCellWidget( LineEditC1A6, 3, 3, 1, 2 );
212 //      QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
213 //      GroupC1Layout->addItem( spacer_3, 1, 3 );
214 //      QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
215 //      GroupC1Layout->addItem( spacer_4, 2, 3 );
216 //      QSpacerItem* spacer_5 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
217 //      GroupC1Layout->addMultiCell( spacer_5, 3, 3, 3, 5 );
218
219 //      GeometryGUI_FillingDlgLayout->addWidget( GroupC1, 1, 0 );
220
221     GroupC1 = new QGroupBox( this, "GroupC1" );
222     GroupC1->setMinimumSize( QSize( 0, 0 ) );
223     GroupC1->setFrameShape( QGroupBox::Box );
224     GroupC1->setFrameShadow( QGroupBox::Sunken );
225     GroupC1->setTitle( tr( "GEOM_FILLING_ARG"  ) );
226     GroupC1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, GroupC1->sizePolicy().hasHeightForWidth() ) );
227     GroupC1->setColumnLayout(0, Qt::Vertical );
228     GroupC1->layout()->setSpacing( 0 );
229     GroupC1->layout()->setMargin( 0 );
230     GroupC1Layout = new QGridLayout( GroupC1->layout() );
231     GroupC1Layout->setAlignment( Qt::AlignTop );
232     GroupC1Layout->setSpacing( 6 );
233     GroupC1Layout->setMargin( 11 );
234
235     LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" );
236     LineEditC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1->sizePolicy().hasHeightForWidth() ) );
237
238     GroupC1Layout->addMultiCellWidget( LineEditC1A1, 0, 0, 3, 6 );
239
240     TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" );
241     TextLabelC1A2->setText( tr( "GEOM_FILLING_MIN_DEG"  ) );
242     TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) );
243     TextLabelC1A2->setFrameShape( QLabel::NoFrame );
244     TextLabelC1A2->setFrameShadow( QLabel::Plain );
245
246     GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 );
247
248     TextLabelC1A5 = new QLabel( GroupC1, "TextLabelC1A5" );
249     TextLabelC1A5->setText( tr( "GEOM_FILLING_TOL_2D"  ) );
250     TextLabelC1A5->setMinimumSize( QSize( 50, 0 ) );
251     TextLabelC1A5->setFrameShape( QLabel::NoFrame );
252     TextLabelC1A5->setFrameShadow( QLabel::Plain );
253
254     GroupC1Layout->addWidget( TextLabelC1A5, 2, 5 );
255
256     LineEditC1A5 = new QLineEdit( GroupC1, "LineEditC1A5" );
257     LineEditC1A5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A5->sizePolicy().hasHeightForWidth() ) );
258     LineEditC1A5->setMinimumSize( QSize( 40, 0 ) );
259
260     GroupC1Layout->addWidget( LineEditC1A5, 2, 6 );
261
262     TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" );
263     TextLabelC1A1->setText( tr( "GEOM_FILLING_COMPOUND"  ) );
264     TextLabelC1A1->setMinimumSize( QSize( 90, 0 ) );
265     TextLabelC1A1->setFrameShape( QLabel::NoFrame );
266     TextLabelC1A1->setFrameShadow( QLabel::Plain );
267
268     GroupC1Layout->addMultiCellWidget( TextLabelC1A1, 0, 0, 0, 1 );
269
270     SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" );
271     SelectButtonC1A1->setText( tr( ""  ) );
272     SelectButtonC1A1->setPixmap( image1 );
273     SelectButtonC1A1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, SelectButtonC1A1->sizePolicy().hasHeightForWidth() ) );
274
275     GroupC1Layout->addWidget( SelectButtonC1A1, 0, 2 );
276
277     TextLabelC1A4 = new QLabel( GroupC1, "TextLabelC1A4" );
278     TextLabelC1A4->setText( tr( "GEOM_FILLING_TOL_3D" ) );
279     TextLabelC1A4->setMinimumSize( QSize( 50, 0 ) );
280     TextLabelC1A4->setFrameShape( QLabel::NoFrame );
281     TextLabelC1A4->setFrameShadow( QLabel::Plain );
282
283     GroupC1Layout->addWidget( TextLabelC1A4, 2, 0 );
284
285     TextLabelC1A6 = new QLabel( GroupC1, "TextLabelC1A6" );
286     TextLabelC1A6->setText( tr( "GEOM_FILLING_NB_ITER"  ) );
287     TextLabelC1A6->setMinimumSize( QSize( 50, 0 ) );
288     TextLabelC1A6->setFrameShape( QLabel::NoFrame );
289     TextLabelC1A6->setFrameShadow( QLabel::Plain );
290
291     GroupC1Layout->addWidget( TextLabelC1A6, 3, 0 );
292     QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
293     GroupC1Layout->addItem( spacer_3, 1, 3 );
294     QSpacerItem* spacer_4 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
295     GroupC1Layout->addMultiCell( spacer_4, 2, 2, 3, 4 );
296     QSpacerItem* spacer_5 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
297     GroupC1Layout->addMultiCell( spacer_5, 3, 3, 3, 6 );
298
299     SpinBox_C1A2 = new QSpinBox( GroupC1, "SpinBox_C1A2" );
300     SpinBox_C1A2->setMinValue( 1 );
301     SpinBox_C1A2->setMaxValue( 15 );
302     SpinBox_C1A2->setWrapping( TRUE );
303
304     GroupC1Layout->addMultiCellWidget( SpinBox_C1A2, 1, 1, 1, 2 );
305
306     LineEditC1A4 = new QLineEdit( GroupC1, "LineEditC1A4" );
307     LineEditC1A4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A4->sizePolicy().hasHeightForWidth() ) );
308     LineEditC1A4->setMinimumSize( QSize( 40, 0 ) );
309
310     GroupC1Layout->addMultiCellWidget( LineEditC1A4, 2, 2, 1, 2 );
311
312     TextLabelC1A3 = new QLabel( GroupC1, "TextLabelC1A3" );
313     TextLabelC1A3->setText( tr( "GEOM_FILLING_MAX_DEG" ) );
314     TextLabelC1A3->setMinimumSize( QSize( 50, 0 ) );
315     TextLabelC1A3->setFrameShape( QLabel::NoFrame );
316     TextLabelC1A3->setFrameShadow( QLabel::Plain );
317
318     GroupC1Layout->addMultiCellWidget( TextLabelC1A3, 1, 1, 4, 5 );
319
320     SpinBox_C1A3 = new QSpinBox( GroupC1, "SpinBox_C1A3" );
321     SpinBox_C1A3->setMinValue( 1 );
322     SpinBox_C1A3->setMaxValue( 15 );
323     SpinBox_C1A3->setWrapping( TRUE );
324
325     GroupC1Layout->addWidget( SpinBox_C1A3, 1, 6 );
326
327     SpinBox_C1A6 = new QSpinBox( GroupC1, "SpinBox_C1A6" );
328     SpinBox_C1A6->setMinValue( 1 );
329     SpinBox_C1A6->setMaxValue( 30 );
330     SpinBox_C1A6->setWrapping( TRUE );
331
332     GroupC1Layout->addMultiCellWidget( SpinBox_C1A6, 3, 3, 1, 2 );
333
334     GeometryGUI_FillingDlgLayout->addWidget( GroupC1, 1, 0 );
335
336     /* Initialisations */
337     Init(Sel) ;
338 }
339
340
341 //=================================================================================
342 // function : ~GeometryGUI_FillingDlg()
343 // purpose  : Destroys the object and frees any allocated resources
344 //=================================================================================
345 GeometryGUI_FillingDlg::~GeometryGUI_FillingDlg()
346 {
347     // no need to delete child widgets, Qt does it all for us
348 }
349
350
351
352 //=================================================================================
353 // function : Init()
354 // purpose  :
355 //=================================================================================
356 void GeometryGUI_FillingDlg::Init( SALOME_Selection* Sel )
357 {
358
359   LineEditC1A4->setMaxLength( 10 ); /* myTol3D  */
360   LineEditC1A5->setMaxLength( 10 ); /* myTol2D  */
361   QDoubleValidator *Vc = new QDoubleValidator( 0.00001, +10000.0, 3, LineEditC1A4 ) ;
362   QDoubleValidator *Vd = new QDoubleValidator( 0.00001, +10000.0, 3, LineEditC1A5 ) ;
363   LineEditC1A4->setValidator( Vc) ;
364   LineEditC1A5->setValidator( Vd) ;
365
366   GroupC1->show();
367   myConstructorId = 0 ;
368   Constructor1->setChecked( TRUE );
369   myEditCurrentArgument = LineEditC1A1 ;        
370   mySelection = Sel;
371   myGeomGUI = GeometryGUI::GetGeometryGUI() ;
372
373   SpinBox_C1A2->setValue(2) ;       /* myMinDeg */
374   SpinBox_C1A3->setValue(5) ;       /* myMaxDeg */
375   LineEditC1A4->setText("0.0001") ; /* myTol3D  */
376   LineEditC1A5->setText("0.0001") ; /* myTol2D  */
377   SpinBox_C1A6->setValue(5) ;       /* myNbIter */
378
379   this->myMinDeg = 2 ;
380   this->myMaxDeg = 5 ;
381   this->myTol3D = 0.0001 ;
382   this->myTol2D = 0.0001 ;
383   this->myNbIter =  5 ;
384
385   myOkSectionShape = false ;
386   mySectionShape.Nullify() ;
387   myGeomGUI->SetActiveDialogBox( (QDialog*)this ) ;
388
389   // TODO previous selection into argument ?
390
391   /* Filter definitions */
392   Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Geometry");
393   myGeom = GEOM::GEOM_Gen::_narrow(comp);
394   myCompoundFilter = new GEOM_ShapeTypeFilter( TopAbs_COMPOUND, myGeom );
395   /* first filter used */
396   mySelection->AddFilter(myCompoundFilter) ;
397
398   /* signals and slots connections */
399   connect( buttonOk, SIGNAL( clicked() ),     this, SLOT( ClickOnOk() ) );
400   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ;
401   connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) );
402   connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) );  
403   connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ;
404
405   connect( LineEditC1A1, SIGNAL (returnPressed() ), this, SLOT( LineEditReturnPressed() ) ) ;
406
407   connect( myGeomGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ;  
408   connect( mySelection, SIGNAL( currentSelectionChanged() ),     this, SLOT( SelectionIntoArgument() ) );
409   /* to close dialog if study change */
410   connect( myGeomGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ;
411  
412   /* Move widget on the botton right corner of main widget */
413   int x, y ;
414   myGeomGUI->DefineDlgPosition( this, x, y ) ;
415   this->move( x, y ) ;
416   /* Displays Dialog */
417   this->show() ;
418
419   return ;
420 }
421
422
423
424 //=================================================================================
425 // function : ConstructorsClicked()
426 // purpose  : Radio button management
427 //=================================================================================
428 void GeometryGUI_FillingDlg::ConstructorsClicked(int constructorId)
429 {
430   return ;
431 }
432
433 //=================================================================================
434 // function : ClickOnOk()
435 // purpose  :
436 //=================================================================================
437 void GeometryGUI_FillingDlg::ClickOnOk()
438 {
439   this->ClickOnApply() ;
440   this->ClickOnCancel() ;
441
442   return ;
443 }
444
445 //=================================================================================
446 // function : ClickOnApply()
447 // purpose  :
448 //=================================================================================
449 void GeometryGUI_FillingDlg::ClickOnApply()
450 {
451   switch(myConstructorId)
452     { 
453     case 0 :
454       { 
455         this->myMinDeg = SpinBox_C1A2->value() ;
456         this->myMaxDeg = SpinBox_C1A3->value() ;
457         this->myTol3D  = LineEditC1A4->text().toDouble(); 
458         this->myTol2D  = LineEditC1A5->text().toDouble(); 
459         this->myNbIter = SpinBox_C1A6->value() ;
460         if(myOkSectionShape) {    
461           myGeomGUI->MakeFillingAndDisplay( myGeomShape, myMinDeg, myMaxDeg, myTol3D, myTol2D, myNbIter) ;
462         }
463         break ;
464       }
465     }
466   return ;
467 }
468
469
470 //=================================================================================
471 // function : ClickOnCancel()
472 // purpose  :
473 //=================================================================================
474 void GeometryGUI_FillingDlg::ClickOnCancel()
475 {
476   mySelection->ClearFilters() ;
477   disconnect( mySelection, 0, this, 0 );
478   myGeomGUI->ResetState() ;
479   reject() ;
480   return ;
481 }
482
483
484 //=================================================================================
485 // function : SelectionIntoArgument()
486 // purpose  : Called when selection as changed or other case
487 //=================================================================================
488 void GeometryGUI_FillingDlg::SelectionIntoArgument()
489 {
490   myEditCurrentArgument->setText("") ;
491   QString aString = ""; /* name of selection */
492   
493   int nbSel = myGeomGUI->GetNameOfSelectedIObjects(mySelection, aString) ;
494   if ( nbSel != 1 ) {
495     if ( myEditCurrentArgument == LineEditC1A1 ) {
496       myOkSectionShape = false ;
497     }
498     return ;
499   }
500   
501   // nbSel == 1
502   TopoDS_Shape S; 
503   Standard_Boolean testResult ;
504   Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ;
505   if( !myGeomGUI->GetTopoFromSelection(mySelection, S) )
506     return ;
507   
508   if ( myEditCurrentArgument == LineEditC1A1 && S.ShapeType() == TopAbs_COMPOUND  ) {
509     myEditCurrentArgument->setText(aString) ;
510     myGeomShape = myGeomGUI->ConvertIOinGEOMShape(IO, testResult) ;
511     if( !testResult )
512       return ;
513     myOkSectionShape = true ;
514   }
515   /* no simulation */
516   return ;
517 }
518
519
520 //=================================================================================
521 // function : SetEditCurrentArgument()
522 // purpose  :
523 //=================================================================================
524 void GeometryGUI_FillingDlg::SetEditCurrentArgument()
525 {
526   QPushButton* send = (QPushButton*)sender();
527   mySelection->ClearFilters() ;
528   switch (myConstructorId)
529     {
530     case 0: /* default constructor */
531       { 
532         if(send == SelectButtonC1A1) {
533           LineEditC1A1->setFocus() ;
534           myEditCurrentArgument = LineEditC1A1;
535           mySelection->AddFilter(myCompoundFilter) ;
536         }
537         SelectionIntoArgument() ;
538         break;
539       }
540     }
541   return ;
542 }
543
544
545
546 //=================================================================================
547 // function : LineEditReturnPressed()
548 // purpose  :
549 //=================================================================================
550 void GeometryGUI_FillingDlg::LineEditReturnPressed()
551 {  
552   QLineEdit* send = (QLineEdit*)sender();  
553   if( send == LineEditC1A1 )
554     myEditCurrentArgument = LineEditC1A1 ;
555   else 
556     return ;
557
558   /* User name of object input management                          */
559   /* If successfull the selection is changed and signal emitted... */
560   /* so SelectionIntoArgument() is automatically called.           */
561   const QString objectUserName = myEditCurrentArgument->text() ;
562   QWidget* thisWidget = (QWidget*)this ;
563   if( myGeomGUI->SelectionByNameInDialogs( thisWidget, objectUserName, mySelection ) ) {
564       myEditCurrentArgument->setText( objectUserName ) ;
565   }
566   return ;
567 }
568
569
570 //=================================================================================
571 // function : DeactivateActiveDialog()
572 // purpose  :
573 //=================================================================================
574 void GeometryGUI_FillingDlg::DeactivateActiveDialog()
575 {
576   if ( GroupConstructors->isEnabled() ) {
577     GroupConstructors->setEnabled(false) ;
578     GroupC1->setEnabled(false) ;
579     GroupButtons->setEnabled(false) ;
580     disconnect( mySelection, 0, this, 0 );
581     mySelection->ClearFilters() ;
582   }
583   return ;
584 }
585
586
587 //=================================================================================
588 // function : ActivateThisDialog()
589 // purpose  :
590 //=================================================================================
591 void GeometryGUI_FillingDlg::ActivateThisDialog()
592 {
593   /* Emit a signal to deactivate the active dialog */
594   myGeomGUI->EmitSignalDeactivateDialog() ;   
595   GroupConstructors->setEnabled(true) ;
596   GroupC1->setEnabled(true) ;
597   GroupButtons->setEnabled(true) ;
598   connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
599   return ;
600 }
601
602
603 //=================================================================================
604 // function : enterEvent()
605 // purpose  :
606 //=================================================================================
607 void GeometryGUI_FillingDlg::enterEvent(QEvent* e)
608 {
609   if ( GroupConstructors->isEnabled() )
610     return ;  
611   ActivateThisDialog() ;
612   return ;
613 }
614
615
616 //=================================================================================
617 // function : closeEvent()
618 // purpose  :
619 //=================================================================================
620 void GeometryGUI_FillingDlg::closeEvent( QCloseEvent* e )
621 {
622   /* same than click on cancel button */
623   this->ClickOnCancel() ;
624   return ;
625 }