]> SALOME platform Git repositories - modules/geom.git/blob - src/RepairGUI/RepairGUI_ShapeProcessDlg.cxx
Salome HOME
Remove some methods of GEOMBase_Helper (IObjectCount(), firstIObject(), lastIObject...
[modules/geom.git] / src / RepairGUI / RepairGUI_ShapeProcessDlg.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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // File   : RepairGUI_ShapeProcessDlg.cxx
23 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
24 //
25
26 #include "RepairGUI_ShapeProcessDlg.h"
27
28 #include <DlgRef.h>
29 #include <GeometryGUI.h>
30 #include <GEOMBase.h>
31 #include <GEOMImpl_Types.hxx>
32
33 #include <SalomeApp_Application.h>
34 #include <LightApp_SelectionMgr.h>
35 #include <SUIT_Session.h>
36 #include <SUIT_ResourceMgr.h>
37 #include <SUIT_MessageBox.h>
38 #include <SALOME_ListIteratorOfListIO.hxx>
39 #include <SALOME_ListIO.hxx>
40
41 #include <TCollection_AsciiString.hxx>
42 #include <TColStd_MapOfInteger.hxx>
43
44 #include <QListWidget>
45 #include <QStackedLayout>
46
47 //=================================================================================
48 // class    : RepairGUI_ShapeProcessDlg()
49 // purpose  : Constructs a RepairGUI_ShapeProcessDlg  which is a child of 'parent', with the
50 //            name 'name' and widget flags set to 'f'.
51 //            The dialog will by default be modeless, unless you set 'modal' to
52 //            TRUE to construct a modal dialog.
53 //=================================================================================
54 RepairGUI_ShapeProcessDlg::RepairGUI_ShapeProcessDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
55                                                       bool modal )
56   : GEOMBase_Skeleton( theGeometryGUI, parent, modal )
57 {
58   setHelpFileName( "shape_processing_operation_page.html" );
59   init();
60 }
61
62 //=================================================================================
63 // function : ~RepairGUI_ShapeProcessDlg()
64 // purpose  : Destroys the object and frees any allocated resources
65 //=================================================================================
66 RepairGUI_ShapeProcessDlg::~RepairGUI_ShapeProcessDlg()
67 {
68 }
69
70 //=================================================================================
71 // function : Init()
72 // purpose  :
73 //=================================================================================
74 void RepairGUI_ShapeProcessDlg::init()
75 {
76   //myGeomGUI->SetState( 0 );
77
78   initParamsValues();
79   initSelection();
80         
81   setWindowTitle( tr( "GEOM_SHAPEPROCESS_TITLE" ) );
82
83   mainFrame()->GroupConstructors->hide();
84   
85   // select widget on the top 
86   mySelectWdgt = new DlgRef_1Sel( centralWidget() );
87   mySelectWdgt->GroupBox1->setTitle( tr( "GEOM_SHAPE" ) );
88   mySelectWdgt->TextLabel1->setText( tr( "GEOM_SELECTED_OBJECTS" ) );
89   mySelectWdgt->PushButton1->setIcon( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
90   mySelectWdgt->LineEdit1->setReadOnly( true );
91
92   // layout the two group boxes in the middle, add a list of operations
93   QGroupBox* anOperGr = new QGroupBox( tr( "GEOM_OPERATIONS" ), centralWidget() );
94
95   // operations list widget
96   myOpList = new QListWidget( anOperGr );
97   myOpList->setSortingEnabled( false );
98   myOpList->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
99
100   QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr );
101   aOperLay->setMargin( 9 );
102   aOperLay->addWidget( myOpList );
103
104   QGroupBox* aParamsGr = new QGroupBox( tr( "GEOM_PARAMETERS" ), centralWidget() );
105
106   // add a widget stack to the parameters group box
107   QStackedLayout* aStack = new QStackedLayout( aParamsGr );
108
109   // continueties values..
110   QStringList aContinueties = QString( "C0,G1,C1,G2,C2,C3,CN" ).split( "," );
111
112   // fill in the widgets
113   for ( int i = 0; i < myOpLst.count(); i++ ) {
114     QListWidgetItem* item = new QListWidgetItem( myOpLst[i] );
115     item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
116     item->setCheckState( Qt::Unchecked );
117     myOpList->addItem( item );
118
119     QWidget* w;
120     if ( myOpLst[i] == "FixShape" ) {
121       // FixShape
122       w = new QWidget( aParamsGr );
123       QGridLayout* aLay = new QGridLayout( w );
124       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
125       
126       myFixShapeTol3D = new QDoubleSpinBox( w );
127       initSpinBox( myFixShapeTol3D, 0, 100, 1e-7, 10 );
128       myFixShapeMaxTol3D = new QDoubleSpinBox( w );
129       initSpinBox( myFixShapeMaxTol3D, 0, 100, 1e-7, 10 );
130       
131       aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
132       aLay->addWidget( myFixShapeTol3D, 0, 1 );
133       aLay->addWidget( new QLabel( tr( "GEOM_MAX_3D_TOLERANCE" ), w ), 1, 0 );
134       aLay->addWidget( myFixShapeMaxTol3D, 1, 1 );
135       aLay->setRowStretch( aLay->rowCount(), 5 );
136     }
137     else if ( myOpLst[i] == "FixFaceSize" ) {
138       // FixFaceSize  
139       w = new QWidget( aParamsGr );
140       QGridLayout* aLay = new QGridLayout( w );
141       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
142       
143       myFixFaceSizeTol = new QDoubleSpinBox( w );
144       initSpinBox( myFixFaceSizeTol, 0, 100, 1e-7, 10 );
145       
146       aLay->addWidget( new QLabel( tr( "GEOM_TOLERANCE" ), w ), 0, 0 );
147       aLay->addWidget( myFixFaceSizeTol, 0, 1 );
148       aLay->setRowStretch( aLay->rowCount(), 5 );
149     }
150     else if ( myOpLst[i] == "DropSmallEdges" ) {
151       // DropSmallEdges
152       w = new QWidget( aParamsGr );
153       QGridLayout* aLay = new QGridLayout( w );
154       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
155       
156       myDropSmallEdgesTol3D = new QDoubleSpinBox( w );
157       initSpinBox( myDropSmallEdgesTol3D, 0, 100, 1e-7, 10 );
158   
159       aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
160       aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 );
161       aLay->setRowStretch( aLay->rowCount(), 5 );
162     }
163     else if ( myOpLst[i] == "SplitAngle" ) {
164       // SplitAngle
165       w = new QWidget( aParamsGr );
166       QGridLayout* aLay = new QGridLayout( w );
167       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
168       
169       mySplitAngleAngle = new QDoubleSpinBox( w );
170       initSpinBox( mySplitAngleAngle, 0, 360, 1 );
171       mySplitAngleMaxTol = new QDoubleSpinBox( w );
172       initSpinBox( mySplitAngleMaxTol, 0, 100, 1e-7, 10 );
173       
174       aLay->addWidget( new QLabel( tr( "GEOM_ANGLE_1" ), w ), 0, 0 );
175       aLay->addWidget( mySplitAngleAngle, 0, 1 );
176       aLay->addWidget( new QLabel( tr( "GEOM_MAX_TOLERANCE" ), w ), 1, 0 );
177       aLay->addWidget( mySplitAngleMaxTol, 1, 1 );
178       aLay->setRowStretch( aLay->rowCount(), 5 );
179     }
180     else if ( myOpLst[i] == "SplitClosedFaces" ) {
181       // SplitClosedFaces
182       w = new QWidget( aParamsGr );
183       QGridLayout* aLay = new QGridLayout( w );
184       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
185       
186       mySplitClosedFacesNum = new QSpinBox( w );
187   
188       aLay->addWidget( new QLabel( tr( "GEOM_NUM_SPLIT_POINTS" ), w ), 0, 0 );
189       aLay->addWidget( mySplitClosedFacesNum, 0, 1 );
190       aLay->setRowStretch( aLay->rowCount(), 5 );
191     }      
192     else if ( myOpLst[i] == "SplitContinuity" ) {
193       // SplitContinuity
194       w = new QWidget( aParamsGr );
195       QGridLayout* aLay = new QGridLayout( w );
196       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
197
198       mySplitContTol3D = new QDoubleSpinBox( w );
199       initSpinBox( mySplitContTol3D, 0, 100, 1e-7, 10 );
200       mySplitContSurfCont = new QComboBox( w );
201       mySplitContSurfCont->addItems( aContinueties );
202       mySplitContCurvCont = new QComboBox( w );
203       mySplitContCurvCont->addItems( aContinueties );
204       
205       aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
206       aLay->addWidget( mySplitContTol3D, 0, 1 );
207       aLay->addWidget( new QLabel( tr( "GEOM_SURFACE_CONTINUTY" ), w ), 1, 0 );
208       aLay->addWidget( mySplitContSurfCont, 1, 1 );
209       aLay->addWidget( new QLabel( tr( "GEOM_CURVE_CONTINUTY" ), w ), 2, 0 );
210       aLay->addWidget( mySplitContCurvCont, 2, 1 );
211       aLay->setRowStretch( aLay->rowCount(), 5 );
212     }
213     else if ( myOpLst[i] == "BSplineRestriction" ) {
214       // BSplineRestriction
215       w = new QWidget( aParamsGr );
216       QGridLayout* aLay = new QGridLayout( w );
217       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
218
219       myBSplineSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), w );
220       myBSpline3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), w );
221       myBSpline2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), w );
222
223       myBSplineTol3D = new QDoubleSpinBox( w );
224       initSpinBox( myBSplineTol3D, 0, 100, 1e-7, 10 );
225       
226       myBSplineTol2D = new QDoubleSpinBox( w );
227       initSpinBox( myBSplineTol2D, 0, 100, 1e-7, 10 );
228
229       myBSplineDegree = new QSpinBox( w );
230       myBSplineSegments = new QSpinBox( w );
231       myBSpline2DCont = new QComboBox( w );
232       myBSpline2DCont->addItems( aContinueties );
233       myBSpline3DCont = new QComboBox( w );
234       myBSpline3DCont->addItems( aContinueties );
235       
236       myBSplineSurfModeChk->setChecked( true );
237       myBSpline3DCurveChk->setChecked( true );
238       myBSpline2DCurveChk->setChecked( true );
239
240       aLay->addWidget( myBSplineSurfModeChk, 0, 0 );
241       aLay->addWidget( myBSpline3DCurveChk,  1, 0 );
242       aLay->addWidget( myBSpline2DCurveChk,  2, 0 );
243       aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 3, 0 );
244       aLay->addWidget( myBSplineTol3D, 3, 1 );
245       aLay->addWidget( new QLabel( tr( "GEOM_2D_TOLERANCE" ), w ), 4, 0 );
246       aLay->addWidget( myBSplineTol2D, 4, 1 );
247       aLay->addWidget( new QLabel( tr( "GEOM_REQUIRED_DEGREE" ), w ), 5, 0 );
248       aLay->addWidget( myBSplineDegree, 5, 1 );
249       aLay->addWidget( new QLabel( tr( "GEOM_REQUIRED_NUM_SEGMENTS" ), w ), 6, 0 );
250       aLay->addWidget( myBSplineSegments, 6, 1 );
251       aLay->addWidget( new QLabel( tr( "GEOM_3D_CONTINUTY" ), w ), 7, 0 );
252       aLay->addWidget( myBSpline3DCont, 7, 1 );
253       aLay->addWidget( new QLabel( tr( "GEOM_2D_CONTINUTY" ), w ), 8, 0 );
254       aLay->addWidget( myBSpline2DCont, 8, 1 );
255       aLay->setRowStretch( aLay->rowCount(), 5 );
256     }
257     else if ( myOpLst[i] == "ToBezier" ) {
258       // ToBezier
259       w = new QWidget( aParamsGr );
260       QGridLayout* aLay = new QGridLayout( w );
261       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
262
263       myToBezierSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), w );
264       myToBezier3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), w );
265       myToBezier2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), w );
266   
267       myToBezierMaxTol = new QDoubleSpinBox( w );
268       initSpinBox( myToBezierMaxTol, 0, 100, 1e-7, 10 );
269
270       aLay->addWidget( myToBezierSurfModeChk, 0, 0 );
271       aLay->addWidget( myToBezier3DCurveChk, 1, 0 );
272       aLay->addWidget( myToBezier2DCurveChk, 2, 0 );
273       aLay->addWidget( new QLabel( tr( "GEOM_MAX_TOLERANCE" ), w ), 3, 0 );
274       aLay->addWidget( myToBezierMaxTol, 3, 1 );
275       aLay->setRowStretch( aLay->rowCount(), 5 );
276     }
277     else if ( myOpLst[i] == "SameParameter" ) {
278       // SameParameter
279       w = new QWidget( aParamsGr );
280       QGridLayout* aLay = new QGridLayout( w );
281       aLay->setMargin( 9 ); aLay->setSpacing( 6 );
282
283       mySameParameterTol3D = new QDoubleSpinBox( w );
284       initSpinBox( mySameParameterTol3D, 0, 100, 1e-7, 10 );
285       
286       aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
287       aLay->addWidget( mySameParameterTol3D, 0, 1 );
288       aLay->setRowStretch( aLay->rowCount(), 5 );
289     }
290     else {
291       w = new QWidget( aParamsGr ); // dumb widget
292     }
293     aStack->insertWidget( i, w );
294   }
295
296   QGridLayout* layout = new QGridLayout( centralWidget() );
297   layout->setMargin( 0 ); layout->setSpacing( 6 );
298   layout->addWidget( mySelectWdgt, 0, 0, 1, 2 );
299   layout->addWidget( anOperGr,     1, 0 );
300   layout->addWidget( aParamsGr,    1, 1 );
301
302   // signals and slots connections
303   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( onOk() ) );
304   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) );
305
306   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
307            SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) );
308
309   connect( mySelectWdgt->PushButton1, SIGNAL( clicked() ),       this, SLOT( selectClicked() ) );
310   connect( mySelectWdgt->LineEdit1,   SIGNAL( returnPressed() ), this, SLOT( lineEditReturnPressed() ) );
311
312   connect( myToBezierSurfModeChk,     SIGNAL( toggled( bool ) ), this, SLOT( advOptionToggled( bool ) ) );
313
314   connect( myOpList, SIGNAL( currentRowChanged( int ) ), aStack, SLOT( setCurrentIndex( int ) ) );
315
316   adjustSize();
317   loadDefaults(); // init dialog fields with values from resource file
318   //myOpList->setCurrentRow( myOpList->findItem( 0 );
319   reset();
320
321   initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) );
322 }
323
324 //=================================================================================
325 // function : onOk()
326 // purpose  : Same than click on apply but close this dialog.
327 //=================================================================================
328 void RepairGUI_ShapeProcessDlg::onOk()
329 {
330   if ( onApply() )
331     ClickOnCancel();
332 }
333
334 //=================================================================================
335 // function : onApply()
336 // purpose  :
337 //=================================================================================
338 bool RepairGUI_ShapeProcessDlg::onApply()
339 {
340   if ( !onAccept() )
341     return false;
342
343   initName();
344
345   reset();
346   initSelection();
347   
348   return true;
349 }
350
351
352 //=================================================================================
353 // function : selectionChanged()
354 // purpose  : Called when selection as changed or other case
355 //          : used only by SelectButtonC1A1 (LineEditC1A1)
356 //=================================================================================
357 void RepairGUI_ShapeProcessDlg::selectionChanged()
358 {
359   reset();
360         
361   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
362   SALOME_ListIO aSelList;
363   aSelMgr->selectedObjects(aSelList);
364
365   Standard_Boolean aRes = Standard_False;
366   int i = 0;
367   myObjects->length(aSelList.Extent());
368   for (SALOME_ListIteratorOfListIO anIt (aSelList); anIt.More(); anIt.Next()) {
369     GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes );
370     if ( !CORBA::is_nil( aSelectedObject ) && aRes )
371         myObjects[i++] = aSelectedObject;
372   }
373   myObjects->length( i );
374   if ( i == 1 )
375     mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) );
376   else if ( i > 0 )
377     mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) );
378 }
379
380
381 //=================================================================================
382 // function : selectClicked()
383 // purpose  :
384 //=================================================================================
385 void RepairGUI_ShapeProcessDlg::selectClicked()
386 {
387   myEditCurrentArgument = mySelectWdgt->LineEdit1;
388   mySelectWdgt->LineEdit1->setFocus();
389   selectionChanged();
390 }
391
392
393 //=================================================================================
394 // function : lineEditReturnPressed()
395 // purpose  :
396 //=================================================================================
397 void RepairGUI_ShapeProcessDlg::lineEditReturnPressed()
398 {
399   GEOMBase_Skeleton::LineEditReturnPressed();
400 }
401
402
403 //=================================================================================
404 // function : activate()
405 // purpose  :
406 //=================================================================================
407 void RepairGUI_ShapeProcessDlg::activate()
408 {
409   GEOMBase_Skeleton::ActivateThisDialog();
410   connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication( ) ))->selectionMgr(),
411            SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) );
412         
413   reset();
414   //myGeomGUI->SetState( 0 );
415   initSelection();
416 }
417
418
419 //=================================================================================
420 // function : enterEvent()
421 // purpose  : Mouse enter onto the dialog to activate it
422 //=================================================================================
423 void RepairGUI_ShapeProcessDlg::enterEvent( QEvent* )
424 {
425   if ( !mainFrame()->GroupBoxName->isEnabled() )
426     activate();
427 }
428
429
430 //=================================================================================
431 // function : reset()
432 // purpose  : Completely reset the state of method including local context
433 //=================================================================================
434 void RepairGUI_ShapeProcessDlg::reset()
435 {
436   myObjects = new GEOM::ListOfGO();
437   myObjects->length( 0 );       
438   mySelectWdgt->LineEdit1->setText( "" );
439 }
440
441
442 //=================================================================================
443 // function : get_convert
444 // purpose  : conversion of angle values to radians (non-angle values are not converted)
445 //=================================================================================
446 const char* get_convert( const char* theParam, const QString& theValue )
447 {
448   if ( !strcmp( theParam, "SplitAngle.Angle" ) ) {
449     double doubleValue = theValue.toDouble() * PI / 180;
450     return CORBA::string_dup( QString::number( doubleValue ).toLatin1().constData() );
451   }
452   return CORBA::string_dup( theValue.toLatin1().constData() );
453 }
454
455 //=================================================================================
456 // function : set_convert
457 // purpose  : conversion of angle values to degrees (non-angle values are not converted)
458 //=================================================================================
459 const char* set_convert( const char* theParam, const char* theValue )
460 {
461   if ( !strcmp( theParam, "SplitAngle.Angle" ) ) {
462     double doubleValue = atof( theValue ) * 180 / PI;
463     TCollection_AsciiString str( doubleValue );
464     return CORBA::string_dup( str.ToCString() );
465   }
466   return CORBA::string_dup( theValue );
467 }
468
469 //=================================================================================
470 // function : loadDefaults()
471 // purpose  : initialize "values"-fields with default values retrieved from IHealingOperations
472 //=================================================================================
473 void RepairGUI_ShapeProcessDlg::loadDefaults()
474 {
475   GEOM::GEOM_IHealingOperations_var anOp = myGeomGUI->GetGeomGen()->GetIHealingOperations( getStudyId() );
476   GEOM::string_array_var anOperators, aParams, aValues;
477   anOp->GetShapeProcessParameters( anOperators, aParams, aValues );
478
479   // check the default items-operators
480   for ( int i = 0; i < anOperators->length(); i++ ) {
481     //MESSAGE("-->"<<(const char*)anOperators[i]);
482     QList<QListWidgetItem*> items = myOpList->findItems ( (const char*)anOperators[i], Qt::MatchFixedString );
483     if ( items.count() ) 
484       ( items[0] )->setCheckState( Qt::Checked );
485   }
486
487   // Retrieve default parameters for ALL operators
488   for ( int i = 0; i < myOpList->count(); i++ ) {
489     CORBA::String_var anOperator = CORBA::string_dup( myOpList->item( i )->text().toLatin1().constData() );
490     anOp->GetOperatorParameters( anOperator.in(), aParams, aValues );
491
492     // set default values of parameters
493     if ( aParams->length() != aValues->length() )
494       continue;
495
496     for ( int j = 0; j < aParams->length(); j++ ) {
497       QWidget* aCtrl = getControl( (const char*)aParams[j] );
498       const char* aValue = set_convert( (const char*)aParams[j], aValues[j] );
499       setValue( aCtrl, aValue );
500     }
501   }
502 }
503
504 //=================================================================================
505 // function : setValue()
506 // purpose  : set value in the proper way
507 //=================================================================================
508 void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const QString& theValue )
509 {
510   if ( theControl && !theValue.isNull() ) {
511     if ( qobject_cast<QDoubleSpinBox*>( theControl ) )
512       qobject_cast<QDoubleSpinBox*>( theControl )->setValue( theValue.toDouble() );
513     else if ( qobject_cast<QSpinBox*>( theControl ) )
514       qobject_cast<QSpinBox*>( theControl )->setValue( theValue.toInt() );
515     else if ( qobject_cast<QComboBox*>( theControl ) )
516       qobject_cast<QComboBox*>( theControl )->setEditText( theValue );
517     else if ( qobject_cast<QCheckBox*>( theControl ) )
518       qobject_cast<QCheckBox*>( theControl )->setChecked( theValue.toInt() != 0 );
519   }
520 }
521
522 //=================================================================================
523 // function : getValue()
524 // purpose  : get value in the proper way
525 //=================================================================================
526 QString RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const
527 {
528   if ( theControl ) {
529     if ( qobject_cast<QDoubleSpinBox*>( theControl ) )
530       return QString::number( qobject_cast<QDoubleSpinBox*>( theControl )->value() );
531     else if ( qobject_cast<QSpinBox*>( theControl ) )
532       return QString::number( qobject_cast<QSpinBox*>( theControl )->value() );
533     else if ( qobject_cast<QComboBox*>( theControl ) )
534       return qobject_cast<QComboBox*>( theControl )->currentText();
535     else if ( qobject_cast<QCheckBox*>( theControl ) )
536       return qobject_cast<QCheckBox*>( theControl )->isChecked() ? "1" : "0";
537   }   
538   return 0;
539 }
540
541 //=================================================================================
542 // function : createOperation
543 // purpose  :
544 //=================================================================================
545 GEOM::GEOM_IOperations_ptr RepairGUI_ShapeProcessDlg::createOperation()
546 {
547   return getGeomEngine()->GetIHealingOperations( getStudyId() );
548 }
549
550 //=================================================================================
551 // function : isValid
552 // purpose  :
553 //=================================================================================
554 bool RepairGUI_ShapeProcessDlg::isValid( QString& msg )
555 {
556   bool error = false;
557   GEOM::string_array_var anOperators = getActiveOperators();
558   if ( !myObjects->length() ) {
559     msg += tr( "ERROR_NO_OBJECTS" );
560     error = true;
561   }
562   if ( !anOperators->length() ) {
563     if ( error ) 
564       msg += "\n";
565     msg += tr( "ERROR_NO_OPERATORS" );
566     error = true;
567   }
568   return !error;
569 }
570
571 //=================================================================================
572 // function : execute
573 // purpose  :
574 //=================================================================================
575 bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects )
576 {
577   GEOM::string_array_var anOperators = getActiveOperators();
578   GEOM::string_array_var aParams = getParameters( anOperators );
579   GEOM::string_array_var aValues = getValues( aParams );
580
581   /*//-- check --
582   int z;
583         MESSAGE("Objects : ");
584         for ( z = 0; z < myObjects->length(); z++ )
585                 MESSAGE(myObjects[z]->GetName() << " ");
586         MESSAGE("\nOperators : ");
587         for ( z = 0; z < anOperators->length(); z++ )
588                 MESSAGE(anOperators[z] << " ");
589         MESSAGE("\nParameters : ");
590         for ( z = 0; z < aParams->length(); z++ )
591                 MESSAGE(aParams[z] << " ");
592         MESSAGE("\nValues : ");
593         for ( z = 0; z < aValues->length(); z ++ )
594                 MESSAGE(aValues[z] << " ");
595         MESSAGE("\n");
596   */// -----------
597
598   QStringList anErrorObjNames;
599   for ( int i = 0; i < myObjects->length(); i++ ) {
600     GEOM::GEOM_Object_var obj = myObjects[i];
601     GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->
602       ProcessShape( obj, anOperators, aParams, aValues );
603     if ( anObj->_is_nil() )
604       anErrorObjNames << GEOMBase::GetName( obj );
605     else
606       objects.push_back( anObj._retn() );
607   }
608
609   if ( !anErrorObjNames.empty() )
610     MESSAGE( "ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ).toLatin1().data() );
611     
612   return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing.
613 }
614
615 //=================================================================================
616 // function : getActiveOperators
617 // purpose  :
618 //=================================================================================
619 GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators()
620 {
621   GEOM::string_array_var anOperators = new GEOM::string_array();
622   QStringList aCheckedList;
623
624   for ( int i = 0; i < myOpList->count(); i++ ) {
625     if ( myOpList->item( i )->checkState() == Qt::Checked )
626       aCheckedList << myOpList->item( i )->text();
627   }
628
629   anOperators->length( aCheckedList.count() );
630
631   for ( int i = 0; i < aCheckedList.count(); i++ )
632     anOperators[i] = CORBA::string_dup( aCheckedList[i].toLatin1().constData() );
633                  
634   return anOperators._retn();
635 }
636
637 //=================================================================================
638 // function : getcontrol
639 // purpose  :
640 //=================================================================================
641 QWidget* RepairGUI_ShapeProcessDlg::getControl( const QString& theParam )
642 {
643   if ( theParam == "SplitAngle.Angle" )                           return mySplitAngleAngle;
644   else if ( theParam == "SplitAngle.MaxTolerance" )               return mySplitAngleMaxTol;
645   else if ( theParam == "SplitClosedFaces.NbSplitPoints" )        return mySplitClosedFacesNum;
646   else if ( theParam == "FixFaceSize.Tolerance" )                 return myFixFaceSizeTol;
647   else if ( theParam == "DropSmallEdges.Tolerance3d" )            return myDropSmallEdgesTol3D;
648   else if ( theParam == "BSplineRestriction.SurfaceMode" )        return myBSplineSurfModeChk;
649   else if ( theParam == "BSplineRestriction.Curve3dMode" )        return myBSpline3DCurveChk;
650   else if ( theParam == "BSplineRestriction.Curve2dMode" )        return myBSpline2DCurveChk;
651   else if ( theParam == "BSplineRestriction.Tolerance3d" )        return myBSplineTol3D;
652   else if ( theParam == "BSplineRestriction.Tolerance2d" )        return myBSplineTol2D;
653   else if ( theParam == "BSplineRestriction.RequiredDegree" )     return myBSplineDegree;
654   else if ( theParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments;
655   else if ( theParam == "BSplineRestriction.Continuity3d" )       return myBSpline3DCont;
656   else if ( theParam == "BSplineRestriction.Continuity2d" )       return myBSpline2DCont;
657   else if ( theParam == "SplitContinuity.Tolerance3d" )           return mySplitContTol3D;
658   else if ( theParam == "SplitContinuity.SurfaceContinuity" )     return mySplitContSurfCont;
659   else if ( theParam == "SplitContinuity.CurveContinuity" )       return mySplitContCurvCont;
660   else if ( theParam == "ToBezier.SurfaceMode" )                  return myToBezierSurfModeChk;
661   else if ( theParam == "ToBezier.Curve3dMode" )                  return myToBezier3DCurveChk;
662   else if ( theParam == "ToBezier.Curve2dMode" )                  return myToBezier2DCurveChk;
663   else if ( theParam == "ToBezier.MaxTolerance" )                 return myToBezierMaxTol;
664   else if ( theParam == "SameParameter.Tolerance3d" )             return mySameParameterTol3D;
665   else if ( theParam == "FixShape.Tolerance3d" )                  return myFixShapeTol3D;
666   else if ( theParam == "FixShape.MaxTolerance3d" )               return myFixShapeMaxTol3D;
667   return 0;
668 }
669
670 //=================================================================================
671 // function : getParameters
672 // purpose  :
673 //=================================================================================
674 void RepairGUI_ShapeProcessDlg::initParamsValues()
675 {
676   if ( myOpLst.count() )
677     return;  // already filled
678
679   myOpLst << "FixShape";
680   myValMap["FixShape"] << "FixShape.Tolerance3d";
681   myValMap["FixShape"] << "FixShape.MaxTolerance3d";
682
683   myOpLst << "FixFaceSize";
684   myValMap["FixFaceSize"] << "FixFaceSize.Tolerance";
685
686   myOpLst << "DropSmallEdges";
687   myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d";
688
689   myOpLst << "SplitAngle";
690   myValMap["SplitAngle"] << "SplitAngle.Angle";
691   myValMap["SplitAngle"] << "SplitAngle.MaxTolerance";
692
693   myOpLst << "SplitClosedFaces";
694   myValMap["SplitClosedFaces"] << "SplitClosedFaces.NbSplitPoints";
695
696   myOpLst << "SplitContinuity";
697   myValMap["SplitContinuity"] << "SplitContinuity.Tolerance3d";
698   myValMap["SplitContinuity"] << "SplitContinuity.SurfaceContinuity";
699   myValMap["SplitContinuity"] << "SplitContinuity.CurveContinuity";
700
701   myOpLst << "BSplineRestriction";
702   myValMap["BSplineRestriction"] << "BSplineRestriction.SurfaceMode";
703   myValMap["BSplineRestriction"] << "BSplineRestriction.Curve3dMode";
704   myValMap["BSplineRestriction"] << "BSplineRestriction.Curve2dMode";
705   myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance3d";
706   myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance2d";
707   myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredDegree";
708   myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredNbSegments";
709   myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity3d";
710   myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity2d";
711
712   myOpLst << "ToBezier";
713   myValMap["ToBezier"] << "ToBezier.SurfaceMode";
714   myValMap["ToBezier"] << "ToBezier.Curve3dMode";
715   myValMap["ToBezier"] << "ToBezier.Curve2dMode";
716   myValMap["ToBezier"] << "ToBezier.MaxTolerance";
717
718   myOpLst << "SameParameter";
719   myValMap["SameParameter"] << "SameParameter.Tolerance3d";
720 }
721
722 //=================================================================================
723 // function : getParameters
724 // purpose  :
725 //=================================================================================
726 GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string_array& theOperators )
727 {
728   GEOM::string_array_var aParams = new GEOM::string_array();
729   int i = 0, j = 0;
730
731   // calculate the length of parameters
732   for ( i = 0, j = 0; i < theOperators.length(); i++ )
733     j += myValMap[ QString( theOperators[i] ) ].size();
734   
735   // set the new length of paremeters
736   aParams->length( j );
737
738   // fill the parameters
739   for ( i = 0, j = 0; i < theOperators.length(); i++ ) {
740     QStringList aValLst = myValMap[ QString( theOperators[i] ) ];
741     for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it )
742       aParams[j++] = CORBA::string_dup( (*it).toLatin1().constData() );
743   }
744
745   return aParams._retn();
746 }
747
748
749 //=================================================================================
750 // function : getValues
751 // purpose  :
752 //=================================================================================
753 GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_array& theParams )
754 {
755   GEOM::string_array_var aValues = new GEOM::string_array();
756   aValues->length( theParams.length() );
757     
758   for ( int i = 0; i < theParams.length(); i++ ) {
759     QWidget* aCtrl = getControl( (const char*)theParams[i] );
760     if ( aCtrl )
761       aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) );
762   }
763     
764   return aValues._retn();
765 }
766
767 //=================================================================================
768 // function : initSelection
769 // purpose  : set selection of ALL shape types except vertexes
770 //=================================================================================
771 void RepairGUI_ShapeProcessDlg::initSelection()
772 {
773   TColStd_MapOfInteger aTypes;
774   aTypes.Add( GEOM_COMPOUND );
775   aTypes.Add( GEOM_SOLID );
776   aTypes.Add( GEOM_SHELL );
777   aTypes.Add( GEOM_FACE );
778   aTypes.Add( GEOM_WIRE );
779   aTypes.Add( GEOM_EDGE );
780   globalSelection( aTypes );
781 }
782
783 //=================================================================================
784 // function : advOptionToggled
785 // purpose  : this slot is used to warn the user about possible consequences
786 //            of enabling some advanced options
787 //=================================================================================
788 void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on )
789 {
790   QAbstractButton* btn = (QAbstractButton*)sender();
791   if ( on && btn->isCheckable() &&
792        SUIT_MessageBox::warning( this,
793                                  tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ),
794                                  SUIT_MessageBox::Yes | SUIT_MessageBox::No ) == SUIT_MessageBox::No )
795     btn->toggle();
796 }