1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : RepairGUI_ShapeProcessDlg.cxx
24 // Author : Lucien PIGNOLONI
28 #include "RepairGUI_ShapeProcessDlg.h"
30 #include "GEOMImpl_Types.hxx"
32 #include "SalomeApp_Application.h"
33 #include "LightApp_SelectionMgr.h"
34 #include "SUIT_Session.h"
35 #include "SALOME_ListIteratorOfListIO.hxx"
36 #include "SALOME_ListIO.hxx"
38 #include <TCollection_AsciiString.hxx>
39 #include <TColStd_MapOfInteger.hxx>
43 #include <qmessagebox.h>
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 const char* name, bool modal, WFlags fl)
56 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
57 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
59 setHelpFileName("shape_processing_operation_page.html");
63 //=================================================================================
64 // function : ~RepairGUI_ShapeProcessDlg()
65 // purpose : Destroys the object and frees any allocated resources
66 //=================================================================================
67 RepairGUI_ShapeProcessDlg::~RepairGUI_ShapeProcessDlg()
71 //=================================================================================
74 //=================================================================================
75 void RepairGUI_ShapeProcessDlg::init()
77 //myGeomGUI->SetState( 0 );
82 setCaption(tr("GEOM_SHAPEPROCESS_TITLE"));
84 GroupConstructors->hide();
86 // select widget on the top
87 mySelectWdgt = new DlgRef_1Sel_QTD( this, "SelectedObjects" );
88 mySelectWdgt->GroupBox1->setTitle( tr("GEOM_SHAPE") );
89 mySelectWdgt->TextLabel1->setText( tr("GEOM_SELECTED_OBJECTS") );
90 mySelectWdgt->PushButton1->setPixmap( SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")) );
91 mySelectWdgt->LineEdit1->setReadOnly( true );
93 Layout1->addWidget( mySelectWdgt, 0, 0 );
95 // layout the two group boxes in the middle, add a list of operations
96 QFrame* aMidFrame = new QFrame( this );
97 QGridLayout* aMidLay = new QGridLayout( aMidFrame, 1, 3, 0, 5 );
98 QGroupBox* anOperGr = new QGroupBox( tr("GEOM_OPERATIONS"), aMidFrame );
99 QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr, 0, 0 );
101 myOpList = new QListView( anOperGr );
102 myOpList->setSorting( -1 );
103 myOpList->addColumn( "Operations" );
104 myOpList->header()->hide();
105 aOperLay->addWidget( myOpList );
106 QStringList::ConstIterator it = myOpLst.end();
107 do // iterating from end to begin so to keep the order of items in the listview.
108 new QCheckListItem ( myOpList, *(--it), QCheckListItem::CheckBox );
109 while ( it != myOpLst.begin() );
111 QGroupBox* aParamsGr = new QGroupBox( tr("GEOM_PARAMETERS"), aMidFrame );
112 aMidLay->addWidget( anOperGr, 0, 0 );
113 aMidLay->addMultiCellWidget( aParamsGr, 0, 0, 1, 3 );
114 aMidLay->setColStretch( 0, 1 );
115 aMidLay->setColStretch( 1, 2 );
117 Layout1->addWidget( aMidFrame, 2, 0 );
118 Layout1->setRowStretch( 0, 0 );
119 Layout1->setRowStretch( 1, 1 );
121 // add a widget stack to the parameters group box
122 myStack = new QWidgetStack( aParamsGr );
123 QVBoxLayout* aVParamsLay = new QVBoxLayout( aParamsGr );
124 aVParamsLay->addWidget( myStack );
126 // continueties values..
127 QStringList aContinueties = QStringList::split( ",", "C0,G1,C1,G2,C2,C3,CN" );
130 QFrame* aFrame = new QFrame( myStack );
131 QGridLayout* aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
133 myFixShapeTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
134 myFixShapeTol3D->setPrecision( 10 );
135 myFixShapeMaxTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
136 myFixShapeMaxTol3D->setPrecision( 10 );
138 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
139 aLay->addWidget( myFixShapeTol3D, 0, 1 );
140 aLay->addWidget( new QLabel( tr("GEOM_MAX_3D_TOLERANCE"), aFrame ), 1, 0 );
141 aLay->addWidget( myFixShapeMaxTol3D, 1, 1 );
142 aLay->setRowStretch( 9, 2 );
144 myStack->addWidget( aFrame, myOpLst.findIndex( "FixShape" ) );
147 aFrame = new QFrame( myStack );
148 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
150 myFixFaceSizeTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
151 myFixFaceSizeTol->setPrecision( 10 );
153 aLay->addWidget( new QLabel( tr("GEOM_TOLERANCE"), aFrame ), 0, 0 );
154 aLay->addWidget( myFixFaceSizeTol, 0, 1 );
155 aLay->setRowStretch( 9, 2 );
157 myStack->addWidget( aFrame, myOpLst.findIndex( "FixFaceSize" ) );
160 aFrame = new QFrame( myStack );
161 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
163 myDropSmallEdgesTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
164 myDropSmallEdgesTol3D->setPrecision( 10 );
166 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
167 aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 );
168 aLay->setRowStretch( 9, 2 );
170 myStack->addWidget( aFrame, myOpLst.findIndex( "DropSmallEdges" ) );
173 aFrame = new QFrame( myStack );
174 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
176 mySplitAngleAngle = new QtxDblSpinBox( 0, 360, 1, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 360, 1 );
177 mySplitAngleMaxTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
178 mySplitAngleMaxTol->setPrecision( 10 );
180 aLay->addWidget( new QLabel( tr("GEOM_ANGLE_1"), aFrame ), 0, 0 );
181 aLay->addWidget( mySplitAngleAngle, 0, 1 );
182 aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame ), 1, 0 );
183 aLay->addWidget( mySplitAngleMaxTol, 1, 1 );
184 aLay->setRowStretch( 9, 2 );
186 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitAngle" ) );
189 aFrame = new QFrame( myStack );
190 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
192 mySplitClosedFacesNum = new QSpinBox( aFrame );
194 aLay->addWidget( new QLabel( tr("GEOM_NUM_SPLIT_POINTS"), aFrame ), 0, 0 );
195 aLay->addWidget( mySplitClosedFacesNum, 0, 1 );
196 aLay->setRowStretch( 9, 2 );
198 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitClosedFaces" ) );
201 aFrame = new QFrame( myStack );
202 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
204 mySplitContTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
205 mySplitContTol3D->setPrecision( 10 );
206 mySplitContSurfCont = new QComboBox( aFrame );
207 mySplitContSurfCont->insertStringList( aContinueties );
208 mySplitContCurvCont = new QComboBox( aFrame );
209 mySplitContCurvCont->insertStringList( aContinueties );
211 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
212 aLay->addWidget( mySplitContTol3D, 0, 1 );
213 aLay->addWidget( new QLabel( tr("GEOM_SURFACE_CONTINUTY"), aFrame ), 1, 0 );
214 aLay->addWidget( mySplitContSurfCont, 1, 1 );
215 aLay->addWidget( new QLabel( tr("GEOM_CURVE_CONTINUTY"), aFrame ), 2, 0 );
216 aLay->addWidget( mySplitContCurvCont, 2, 1 );
217 aLay->setRowStretch( 9, 2 );
219 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitContinuity" ) );
221 // BSplineRestriction
222 aFrame = new QFrame( myStack );
223 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
225 myBSplineSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame );
226 myBSpline3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame );
227 myBSpline2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame );
229 myBSplineTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
230 myBSplineTol3D->setPrecision( 10 );
232 myBSplineTol2D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
233 myBSplineTol2D->setPrecision( 10 );
235 myBSplineDegree = new QSpinBox( aFrame );
236 myBSplineSegments = new QSpinBox( aFrame );
237 myBSpline2DCont = new QComboBox( aFrame );
238 myBSpline2DCont->insertStringList( aContinueties );
239 myBSpline3DCont = new QComboBox( aFrame );
240 myBSpline3DCont->insertStringList( aContinueties );
242 myBSplineSurfModeChk->setChecked( true );
243 myBSpline3DCurveChk->setChecked( true );
244 myBSpline2DCurveChk->setChecked( true );
246 aLay->addWidget( myBSplineSurfModeChk, 0, 0 );
247 aLay->addWidget( myBSpline3DCurveChk, 1, 0 );
248 aLay->addWidget( myBSpline2DCurveChk, 2, 0 );
249 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame), 3, 0 );
250 aLay->addWidget( myBSplineTol3D, 3, 1 );
251 aLay->addWidget( new QLabel( tr("GEOM_2D_TOLERANCE"), aFrame), 4, 0 );
252 aLay->addWidget( myBSplineTol2D, 4, 1 );
253 aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_DEGREE"), aFrame), 5, 0 );
254 aLay->addWidget( myBSplineDegree, 5, 1 );
255 aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_NUM_SEGMENTS"), aFrame), 6, 0 );
256 aLay->addWidget( myBSplineSegments, 6, 1 );
257 aLay->addWidget( new QLabel( tr("GEOM_3D_CONTINUTY"), aFrame), 7, 0 );
258 aLay->addWidget( myBSpline3DCont, 7, 1 );
259 aLay->addWidget( new QLabel( tr("GEOM_2D_CONTINUTY"), aFrame), 8, 0 );
260 aLay->addWidget( myBSpline2DCont, 8, 1 );
261 aLay->setRowStretch( 9, 2 );
263 myStack->addWidget( aFrame, myOpLst.findIndex( "BSplineRestriction" ) );
266 aFrame = new QFrame( myStack );
267 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
269 myToBezierSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame );
270 myToBezier3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame );
271 myToBezier2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame );
273 myToBezierMaxTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
274 myToBezierMaxTol->setPrecision( 10 );
276 aLay->addWidget( myToBezierSurfModeChk, 0, 0 );
277 aLay->addWidget( myToBezier3DCurveChk, 1, 0 );
278 aLay->addWidget( myToBezier2DCurveChk, 2, 0 );
279 aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame), 3, 0 );
280 aLay->addWidget( myToBezierMaxTol, 3, 1 );
281 aLay->setRowStretch( 9, 2 );
283 myStack->addWidget( aFrame, myOpLst.findIndex( "ToBezier" ) );
286 aFrame = new QFrame( myStack );
287 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
289 mySameParameterTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
290 mySameParameterTol3D->setPrecision( 10 );
292 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
293 aLay->addWidget( mySameParameterTol3D, 0, 1 );
294 aLay->setRowStretch( 9, 2 );
296 myStack->addWidget( aFrame, myOpLst.findIndex( "SameParameter" ) );
298 // signals and slots connections
299 connect( buttonOk, SIGNAL(clicked()), this, SLOT(onOk()) );
300 connect( buttonApply, SIGNAL(clicked()), this, SLOT(onApply()) );
302 connect( ((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
303 SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged()) );
304 connect( myOpList, SIGNAL(selectionChanged()), this, SLOT(operationChanged()) );
306 connect( mySelectWdgt->PushButton1, SIGNAL(clicked()), this, SLOT(selectClicked()) );
307 connect( mySelectWdgt->LineEdit1, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()) );
309 connect( myToBezierSurfModeChk, SIGNAL(toggled(bool)), SLOT(advOptionToggled(bool)) );
312 loadDefaults(); // init dialog fields with values from resource file
313 myOpList->setSelected( myOpList->findItem( "FixShape", 0 ), true );
316 initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) );
319 //=================================================================================
320 // function : operationChanged()
322 //=================================================================================
323 void RepairGUI_ShapeProcessDlg::operationChanged()
325 QListViewItem* anItem = myOpList->selectedItem();
328 int id = myOpLst.findIndex( anItem->text(0) );
330 myStack->raiseWidget( id );
334 //=================================================================================
336 // purpose : Same than click on apply but close this dialog.
337 //=================================================================================
338 void RepairGUI_ShapeProcessDlg::onOk()
344 //=================================================================================
345 // function : onApply()
347 //=================================================================================
348 bool RepairGUI_ShapeProcessDlg::onApply()
362 //=================================================================================
363 // function : selectionChanged()
364 // purpose : Called when selection as changed or other case
365 // : used only by SelectButtonC1A1 (LineEditC1A1)
366 //=================================================================================
367 void RepairGUI_ShapeProcessDlg::selectionChanged()
371 Standard_Boolean aRes = Standard_False;
373 myObjects->length( IObjectCount() );
374 for ( SALOME_ListIteratorOfListIO anIt( selectedIO() ); anIt.More(); anIt.Next() )
376 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes );
377 if ( !CORBA::is_nil( aSelectedObject ) && aRes )
378 myObjects[i++] = aSelectedObject;
380 myObjects->length( i );
382 mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) );
384 mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) );
388 //=================================================================================
389 // function : selectClicked()
391 //=================================================================================
392 void RepairGUI_ShapeProcessDlg::selectClicked()
394 myEditCurrentArgument = mySelectWdgt->LineEdit1;
395 mySelectWdgt->LineEdit1->setFocus();
400 //=================================================================================
401 // function : lineEditReturnPressed()
403 //=================================================================================
404 void RepairGUI_ShapeProcessDlg::lineEditReturnPressed()
406 GEOMBase_Skeleton::LineEditReturnPressed();
410 //=================================================================================
411 // function : activate()
413 //=================================================================================
414 void RepairGUI_ShapeProcessDlg::activate()
416 GEOMBase_Skeleton::ActivateThisDialog();
417 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
418 SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged()));
421 //myGeomGUI->SetState( 0 );
426 //=================================================================================
427 // function : enterEvent()
428 // purpose : Mouse enter onto the dialog to activate it
429 //=================================================================================
430 void RepairGUI_ShapeProcessDlg::enterEvent(QEvent* e)
432 if ( !GroupConstructors->isEnabled() )
437 //=================================================================================
438 // function : closeEvent()
439 // purpose : same than click on cancel button
440 //=================================================================================
441 void RepairGUI_ShapeProcessDlg::closeEvent(QCloseEvent* e)
443 //myGeomGUI->SetState( -1 );
444 GEOMBase_Skeleton::closeEvent( e );
448 //=================================================================================
449 // function : reset()
450 // purpose : Completely reset the state of method including local context
451 //=================================================================================
452 void RepairGUI_ShapeProcessDlg::reset()
454 myObjects = new GEOM::ListOfGO();
455 myObjects->length( 0 );
456 mySelectWdgt->LineEdit1->setText("");
460 //=================================================================================
461 // function : get_convert
462 // purpose : conversion of angle values to radians (non-angle values are not converted)
463 //=================================================================================
464 const char* get_convert( const char* theParam, const char* theValue )
466 if ( !strcmp( theParam, "SplitAngle.Angle" ) )
468 double doubleValue = atof( theValue ) * PI / 180;
469 TCollection_AsciiString str( doubleValue );
470 return CORBA::string_dup( str.ToCString() );
472 return CORBA::string_dup( theValue );
475 //=================================================================================
476 // function : set_convert
477 // purpose : conversion of angle values to degrees (non-angle values are not converted)
478 //=================================================================================
479 const char* set_convert( const char* theParam, const char* theValue )
481 if ( !strcmp( theParam, "SplitAngle.Angle" ) )
483 double doubleValue = atof( theValue ) * 180 / PI;
484 TCollection_AsciiString str( doubleValue );
485 return CORBA::string_dup( str.ToCString() );
487 return CORBA::string_dup( theValue );
490 //=================================================================================
491 // function : loadDefaults()
492 // purpose : initialize "values"-fields with default values retrieved from IHealingOperations
493 //=================================================================================
494 void RepairGUI_ShapeProcessDlg::loadDefaults()
496 GEOM::GEOM_IHealingOperations_var anOp = myGeomGUI->GetGeomGen()->GetIHealingOperations( getStudyId() );
497 GEOM::string_array_var anOperators, aParams, aValues;
498 anOp->GetShapeProcessParameters( anOperators, aParams, aValues );
500 // check the default items-operators
502 for ( i = 0; i < anOperators->length(); i++ )
504 //MESSAGE("-->"<<(const char*)anOperators[i]);
505 QListViewItem* anItem = myOpList->findItem( (const char*)anOperators[i], 0 );
506 if ( anItem /*&& anItem->inherits( "QCheckListItem" )*/ )
507 ((QCheckListItem*) anItem)->setOn( true );
510 // Retrieve default parameters for ALL operators
511 for ( QListViewItemIterator it(myOpList); it.current(); ++it ) {
512 CORBA::String_var anOperator = CORBA::string_dup( it.current()->text( 0 ).latin1() );
513 anOp->GetOperatorParameters( anOperator.in(), aParams, aValues );
515 // set default values of parameters
516 if ( aParams->length() != aValues->length() )
518 for ( i = 0; i < aParams->length(); i++ ) {
519 QWidget* aCtrl = getControl( (const char*)aParams[i] );
520 const char* aValue = set_convert( (const char*)aParams[i], aValues[i] );
521 setValue( aCtrl, aValue );
526 //=================================================================================
527 // function : setValue()
528 // purpose : set value in the proper way
529 //=================================================================================
530 void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const char* theValue )
532 if ( theControl == NULL || theValue == NULL )
535 if ( theControl->isA( "QtxDblSpinBox" ) )
536 ((QtxDblSpinBox*)theControl)->setValue( QString( theValue ).toDouble() );
537 else if ( theControl->isA( "QSpinBox" ) )
538 ((QSpinBox*)theControl)->setValue( QString( theValue ).toInt() );
539 else if ( theControl->isA( "QComboBox" ) )
540 ((QComboBox*)theControl)->setCurrentText( QString( theValue ) );
541 else if ( theControl->isA( "QCheckBox" ) )
542 ((QCheckBox*)theControl)->setChecked( QString( theValue ).toInt() != 0 );
545 //=================================================================================
546 // function : getValue()
547 // purpose : get value in the proper way
548 //=================================================================================
549 const char* RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const
551 if ( theControl == NULL )
554 if ( theControl->isA( "QtxDblSpinBox" ) )
555 return ((QtxDblSpinBox*)theControl)->text().latin1();
556 else if ( theControl->isA( "QSpinBox" ) )
557 return ((QSpinBox*)theControl)->text().latin1();
558 else if ( theControl->isA( "QComboBox" ) )
559 return ((QComboBox*)theControl)->currentText().latin1();
560 else if ( theControl->isA( "QCheckBox" ) )
561 return ((QCheckBox*)theControl)->isChecked() ? "1" : "0";
566 //=================================================================================
567 // function : createOperation
569 //=================================================================================
570 GEOM::GEOM_IOperations_ptr RepairGUI_ShapeProcessDlg::createOperation()
572 return getGeomEngine()->GetIHealingOperations( getStudyId() );
575 //=================================================================================
576 // function : isValid
578 //=================================================================================
579 bool RepairGUI_ShapeProcessDlg::isValid( QString& msg )
582 GEOM::string_array_var anOperators = getActiveOperators();
583 if ( !myObjects->length() )
585 msg += tr( "ERROR_NO_OBJECTS" );
588 if ( !anOperators->length() )
592 msg += tr( "ERROR_NO_OPERATORS" );
598 //=================================================================================
599 // function : execute
601 //=================================================================================
602 bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects )
604 GEOM::string_array_var anOperators = getActiveOperators();
605 GEOM::string_array_var aParams = getParameters( anOperators );
606 GEOM::string_array_var aValues = getValues( aParams );
610 MESSAGE("Objects : ");
611 for ( z = 0; z < myObjects->length(); z++ )
612 MESSAGE(myObjects[z]->GetName() << " ");
613 MESSAGE("\nOperators : ");
614 for ( z = 0; z < anOperators->length(); z++ )
615 MESSAGE(anOperators[z] << " ");
616 MESSAGE("\nParameters : ");
617 for ( z = 0; z < aParams->length(); z++ )
618 MESSAGE(aParams[z] << " ");
619 MESSAGE("\nValues : ");
620 for ( z = 0; z < aValues->length(); z ++ )
621 MESSAGE(aValues[z] << " ");
625 QStringList anErrorObjNames;
626 for ( int i = 0; i < myObjects->length(); i++ )
628 GEOM::GEOM_Object_var obj = myObjects[i];
629 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->ProcessShape(
630 obj, anOperators, aParams, aValues );
631 if ( anObj->_is_nil() )
632 anErrorObjNames << GEOMBase::GetName( obj );
634 objects.push_back( anObj._retn() );
637 if ( !anErrorObjNames.empty() )
638 MESSAGE("ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ));
640 return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing.
643 //=================================================================================
644 // function : getActiveOperators
646 //=================================================================================
647 GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators()
649 GEOM::string_array_var anOperators = new GEOM::string_array();
650 QStringList aCheckedList;
651 QStringList::Iterator it;
652 for ( it = myOpLst.begin(); it != myOpLst.end(); ++it )
653 if ( ((QCheckListItem*)myOpList->findItem( *it, 0 ))->isOn() )
655 anOperators->length( aCheckedList.size() );
657 for ( it = aCheckedList.begin(); it != aCheckedList.end(); ++it )
658 anOperators[i++] = CORBA::string_dup( (*it).latin1() );
660 return anOperators._retn();
663 //=================================================================================
664 // function : getcontrol
666 //=================================================================================
667 QWidget* RepairGUI_ShapeProcessDlg::getControl( const char* theParam )
669 string aParam = theParam;
670 if ( aParam == "SplitAngle.Angle" ) return mySplitAngleAngle;
671 else if ( aParam == "SplitAngle.MaxTolerance" ) return mySplitAngleMaxTol;
672 else if ( aParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum;
673 else if ( aParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol;
674 else if ( aParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D;
675 else if ( aParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk;
676 else if ( aParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk;
677 else if ( aParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk;
678 else if ( aParam == "BSplineRestriction.Tolerance3d" ) return myBSplineTol3D;
679 else if ( aParam == "BSplineRestriction.Tolerance2d" ) return myBSplineTol2D;
680 else if ( aParam == "BSplineRestriction.RequiredDegree" ) return myBSplineDegree;
681 else if ( aParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments;
682 else if ( aParam == "BSplineRestriction.Continuity3d" ) return myBSpline3DCont;
683 else if ( aParam == "BSplineRestriction.Continuity2d" ) return myBSpline2DCont;
684 else if ( aParam == "SplitContinuity.Tolerance3d" ) return mySplitContTol3D;
685 else if ( aParam == "SplitContinuity.SurfaceContinuity" ) return mySplitContSurfCont;
686 else if ( aParam == "SplitContinuity.CurveContinuity" ) return mySplitContCurvCont;
687 else if ( aParam == "ToBezier.SurfaceMode" ) return myToBezierSurfModeChk;
688 else if ( aParam == "ToBezier.Curve3dMode" ) return myToBezier3DCurveChk;
689 else if ( aParam == "ToBezier.Curve2dMode" ) return myToBezier2DCurveChk;
690 else if ( aParam == "ToBezier.MaxTolerance" ) return myToBezierMaxTol;
691 else if ( aParam == "SameParameter.Tolerance3d" ) return mySameParameterTol3D;
692 else if ( aParam == "FixShape.Tolerance3d" ) return myFixShapeTol3D;
693 else if ( aParam == "FixShape.MaxTolerance3d" ) return myFixShapeMaxTol3D;
697 //=================================================================================
698 // function : getParameters
700 //=================================================================================
701 void RepairGUI_ShapeProcessDlg::initParamsValues()
703 myOpLst << "FixShape";
704 myValMap["FixShape"] << "FixShape.Tolerance3d";
705 myValMap["FixShape"] << "FixShape.MaxTolerance3d";
707 myOpLst << "FixFaceSize";
708 myValMap["FixFaceSize"] << "FixFaceSize.Tolerance";
710 myOpLst << "DropSmallEdges";
711 myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d";
713 myOpLst << "SplitAngle";
714 myValMap["SplitAngle"] << "SplitAngle.Angle";
715 myValMap["SplitAngle"] << "SplitAngle.MaxTolerance";
717 myOpLst << "SplitClosedFaces";
718 myValMap["SplitClosedFaces"] << "SplitClosedFaces.NbSplitPoints";
720 myOpLst << "SplitContinuity";
721 myValMap["SplitContinuity"] << "SplitContinuity.Tolerance3d";
722 myValMap["SplitContinuity"] << "SplitContinuity.SurfaceContinuity";
723 myValMap["SplitContinuity"] << "SplitContinuity.CurveContinuity";
725 myOpLst << "BSplineRestriction";
726 myValMap["BSplineRestriction"] << "BSplineRestriction.SurfaceMode";
727 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve3dMode";
728 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve2dMode";
729 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance3d";
730 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance2d";
731 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredDegree";
732 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredNbSegments";
733 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity3d";
734 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity2d";
736 myOpLst << "ToBezier";
737 myValMap["ToBezier"] << "ToBezier.SurfaceMode";
738 myValMap["ToBezier"] << "ToBezier.Curve3dMode";
739 myValMap["ToBezier"] << "ToBezier.Curve2dMode";
740 myValMap["ToBezier"] << "ToBezier.MaxTolerance";
742 myOpLst << "SameParameter";
743 myValMap["SameParameter"] << "SameParameter.Tolerance3d";
746 //=================================================================================
747 // function : getParameters
749 //=================================================================================
750 GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string_array& theOperators )
752 GEOM::string_array_var aParams = new GEOM::string_array();
755 // calculate the length of parameters
756 for ( i = 0, j = 0; i < theOperators.length(); i++ )
757 j+= myValMap[QString((const char*)theOperators[i])].size();
759 // set the new length of paremeters
760 aParams->length( j );
762 // fill the parameters
763 for ( i = 0, j = 0; i < theOperators.length(); i++ )
765 QStringList aValLst = myValMap[QString( (const char*)theOperators[i] )];
766 for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it )
767 aParams[j++] = CORBA::string_dup( (*it).latin1() );
770 return aParams._retn();
774 //=================================================================================
775 // function : getValues
777 //=================================================================================
778 GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_array& theParams )
780 GEOM::string_array_var aValues = new GEOM::string_array();
781 aValues->length( theParams.length() );
783 for ( int i = 0; i < theParams.length(); i++ )
785 QWidget* aCtrl = getControl( (const char*)theParams[i] );
787 aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) );
790 return aValues._retn();
793 //=================================================================================
794 // function : initSelection
795 // purpose : set selection of ALL shape types except vertexes
796 //=================================================================================
797 void RepairGUI_ShapeProcessDlg::initSelection()
799 TColStd_MapOfInteger aTypes;
800 aTypes.Add( GEOM_COMPOUND );
801 aTypes.Add( GEOM_SOLID );
802 aTypes.Add( GEOM_SHELL );
803 aTypes.Add( GEOM_FACE );
804 aTypes.Add( GEOM_WIRE );
805 aTypes.Add( GEOM_EDGE );
806 globalSelection( aTypes );
809 //=================================================================================
810 // function : advOptionToggled
811 // purpose : this slot is used to warn the user about possible consequences
812 // of enabling some advanced options
813 //=================================================================================
814 void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on )
816 QButton* btn = (QButton*)sender();
817 if ( on && btn->isToggleButton() &&
818 QMessageBox::warning(myGeomGUI->getApp()->desktop(),
819 tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ),
820 QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )