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