1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 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 // File : RepairGUI_ShapeProcessDlg.cxx
23 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26 #include "RepairGUI_ShapeProcessDlg.h"
29 #include <GeometryGUI.h>
31 #include <GEOMImpl_Types.hxx>
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>
41 #include <TCollection_AsciiString.hxx>
42 #include <TColStd_MapOfInteger.hxx>
44 #include <QListWidget>
45 #include <QStackedLayout>
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,
56 : GEOMBase_Skeleton( theGeometryGUI, parent, modal )
58 setHelpFileName( "shape_processing_operation_page.html" );
62 //=================================================================================
63 // function : ~RepairGUI_ShapeProcessDlg()
64 // purpose : Destroys the object and frees any allocated resources
65 //=================================================================================
66 RepairGUI_ShapeProcessDlg::~RepairGUI_ShapeProcessDlg()
70 //=================================================================================
73 //=================================================================================
74 void RepairGUI_ShapeProcessDlg::init()
76 //myGeomGUI->SetState( 0 );
81 setWindowTitle( tr( "GEOM_SHAPEPROCESS_TITLE" ) );
83 mainFrame()->GroupConstructors->hide();
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 );
92 // layout the two group boxes in the middle, add a list of operations
93 QGroupBox* anOperGr = new QGroupBox( tr( "GEOM_OPERATIONS" ), centralWidget() );
95 // operations list widget
96 myOpList = new QListWidget( anOperGr );
97 myOpList->setSortingEnabled( false );
98 myOpList->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
100 QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr );
101 aOperLay->setMargin( 9 );
102 aOperLay->addWidget( myOpList );
104 QGroupBox* aParamsGr = new QGroupBox( tr( "GEOM_PARAMETERS" ), centralWidget() );
106 // add a widget stack to the parameters group box
107 QStackedLayout* aStack = new QStackedLayout( aParamsGr );
109 // continueties values..
110 QStringList aContinueties = QString( "C0,G1,C1,G2,C2,C3,CN" ).split( "," );
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 );
120 if ( myOpLst[i] == "FixShape" ) {
122 w = new QWidget( aParamsGr );
123 QGridLayout* aLay = new QGridLayout( w );
124 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
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 );
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 );
137 else if ( myOpLst[i] == "FixFaceSize" ) {
139 w = new QWidget( aParamsGr );
140 QGridLayout* aLay = new QGridLayout( w );
141 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
143 myFixFaceSizeTol = new QDoubleSpinBox( w );
144 initSpinBox( myFixFaceSizeTol, 0, 100, 1e-7, 10 );
146 aLay->addWidget( new QLabel( tr( "GEOM_TOLERANCE" ), w ), 0, 0 );
147 aLay->addWidget( myFixFaceSizeTol, 0, 1 );
148 aLay->setRowStretch( aLay->rowCount(), 5 );
150 else if ( myOpLst[i] == "DropSmallEdges" ) {
152 w = new QWidget( aParamsGr );
153 QGridLayout* aLay = new QGridLayout( w );
154 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
156 myDropSmallEdgesTol3D = new QDoubleSpinBox( w );
157 initSpinBox( myDropSmallEdgesTol3D, 0, 100, 1e-7, 10 );
159 aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
160 aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 );
161 aLay->setRowStretch( aLay->rowCount(), 5 );
163 else if ( myOpLst[i] == "SplitAngle" ) {
165 w = new QWidget( aParamsGr );
166 QGridLayout* aLay = new QGridLayout( w );
167 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
169 mySplitAngleAngle = new QDoubleSpinBox( w );
170 initSpinBox( mySplitAngleAngle, 0, 360, 1 );
171 mySplitAngleMaxTol = new QDoubleSpinBox( w );
172 initSpinBox( mySplitAngleMaxTol, 0, 100, 1e-7, 10 );
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 );
180 else if ( myOpLst[i] == "SplitClosedFaces" ) {
182 w = new QWidget( aParamsGr );
183 QGridLayout* aLay = new QGridLayout( w );
184 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
186 mySplitClosedFacesNum = new QSpinBox( w );
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 );
192 else if ( myOpLst[i] == "SplitContinuity" ) {
194 w = new QWidget( aParamsGr );
195 QGridLayout* aLay = new QGridLayout( w );
196 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
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 );
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 );
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 );
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 );
223 myBSplineTol3D = new QDoubleSpinBox( w );
224 initSpinBox( myBSplineTol3D, 0, 100, 1e-7, 10 );
226 myBSplineTol2D = new QDoubleSpinBox( w );
227 initSpinBox( myBSplineTol2D, 0, 100, 1e-7, 10 );
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 );
236 myBSplineSurfModeChk->setChecked( true );
237 myBSpline3DCurveChk->setChecked( true );
238 myBSpline2DCurveChk->setChecked( true );
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 );
257 else if ( myOpLst[i] == "ToBezier" ) {
259 w = new QWidget( aParamsGr );
260 QGridLayout* aLay = new QGridLayout( w );
261 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
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 );
267 myToBezierMaxTol = new QDoubleSpinBox( w );
268 initSpinBox( myToBezierMaxTol, 0, 100, 1e-7, 10 );
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 );
277 else if ( myOpLst[i] == "SameParameter" ) {
279 w = new QWidget( aParamsGr );
280 QGridLayout* aLay = new QGridLayout( w );
281 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
283 mySameParameterTol3D = new QDoubleSpinBox( w );
284 initSpinBox( mySameParameterTol3D, 0, 100, 1e-7, 10 );
286 aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
287 aLay->addWidget( mySameParameterTol3D, 0, 1 );
288 aLay->setRowStretch( aLay->rowCount(), 5 );
291 w = new QWidget( aParamsGr ); // dumb widget
293 aStack->insertWidget( i, w );
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 );
302 // signals and slots connections
303 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() ) );
304 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) );
306 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
307 SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) );
309 connect( mySelectWdgt->PushButton1, SIGNAL( clicked() ), this, SLOT( selectClicked() ) );
310 connect( mySelectWdgt->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( lineEditReturnPressed() ) );
312 connect( myToBezierSurfModeChk, SIGNAL( toggled( bool ) ), this, SLOT( advOptionToggled( bool ) ) );
314 connect( myOpList, SIGNAL( currentRowChanged( int ) ), aStack, SLOT( setCurrentIndex( int ) ) );
317 loadDefaults(); // init dialog fields with values from resource file
318 //myOpList->setCurrentRow( myOpList->findItem( 0 );
321 initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) );
324 //=================================================================================
326 // purpose : Same than click on apply but close this dialog.
327 //=================================================================================
328 void RepairGUI_ShapeProcessDlg::onOk()
334 //=================================================================================
335 // function : onApply()
337 //=================================================================================
338 bool RepairGUI_ShapeProcessDlg::onApply()
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()
361 Standard_Boolean aRes = Standard_False;
363 myObjects->length( IObjectCount() );
364 for ( SALOME_ListIteratorOfListIO anIt( selectedIO() ); anIt.More(); anIt.Next() ) {
365 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes );
366 if ( !CORBA::is_nil( aSelectedObject ) && aRes )
367 myObjects[i++] = aSelectedObject;
369 myObjects->length( i );
371 mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) );
373 mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) );
377 //=================================================================================
378 // function : selectClicked()
380 //=================================================================================
381 void RepairGUI_ShapeProcessDlg::selectClicked()
383 myEditCurrentArgument = mySelectWdgt->LineEdit1;
384 mySelectWdgt->LineEdit1->setFocus();
389 //=================================================================================
390 // function : lineEditReturnPressed()
392 //=================================================================================
393 void RepairGUI_ShapeProcessDlg::lineEditReturnPressed()
395 GEOMBase_Skeleton::LineEditReturnPressed();
399 //=================================================================================
400 // function : activate()
402 //=================================================================================
403 void RepairGUI_ShapeProcessDlg::activate()
405 GEOMBase_Skeleton::ActivateThisDialog();
406 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication( ) ))->selectionMgr(),
407 SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) );
410 //myGeomGUI->SetState( 0 );
415 //=================================================================================
416 // function : enterEvent()
417 // purpose : Mouse enter onto the dialog to activate it
418 //=================================================================================
419 void RepairGUI_ShapeProcessDlg::enterEvent( QEvent* )
421 if ( !mainFrame()->GroupBoxName->isEnabled() )
426 //=================================================================================
427 // function : reset()
428 // purpose : Completely reset the state of method including local context
429 //=================================================================================
430 void RepairGUI_ShapeProcessDlg::reset()
432 myObjects = new GEOM::ListOfGO();
433 myObjects->length( 0 );
434 mySelectWdgt->LineEdit1->setText( "" );
438 //=================================================================================
439 // function : get_convert
440 // purpose : conversion of angle values to radians (non-angle values are not converted)
441 //=================================================================================
442 const char* get_convert( const char* theParam, const QString& theValue )
444 if ( !strcmp( theParam, "SplitAngle.Angle" ) ) {
445 double doubleValue = theValue.toDouble() * PI / 180;
446 return CORBA::string_dup( QString::number( doubleValue ).toLatin1().constData() );
448 return CORBA::string_dup( theValue.toLatin1().constData() );
451 //=================================================================================
452 // function : set_convert
453 // purpose : conversion of angle values to degrees (non-angle values are not converted)
454 //=================================================================================
455 const char* set_convert( const char* theParam, const char* theValue )
457 if ( !strcmp( theParam, "SplitAngle.Angle" ) ) {
458 double doubleValue = atof( theValue ) * 180 / PI;
459 TCollection_AsciiString str( doubleValue );
460 return CORBA::string_dup( str.ToCString() );
462 return CORBA::string_dup( theValue );
465 //=================================================================================
466 // function : loadDefaults()
467 // purpose : initialize "values"-fields with default values retrieved from IHealingOperations
468 //=================================================================================
469 void RepairGUI_ShapeProcessDlg::loadDefaults()
471 GEOM::GEOM_IHealingOperations_var anOp = myGeomGUI->GetGeomGen()->GetIHealingOperations( getStudyId() );
472 GEOM::string_array_var anOperators, aParams, aValues;
473 anOp->GetShapeProcessParameters( anOperators, aParams, aValues );
475 // check the default items-operators
476 for ( int i = 0; i < anOperators->length(); i++ ) {
477 //MESSAGE("-->"<<(const char*)anOperators[i]);
478 QList<QListWidgetItem*> items = myOpList->findItems ( (const char*)anOperators[i], Qt::MatchFixedString );
480 ( items[0] )->setCheckState( Qt::Checked );
483 // Retrieve default parameters for ALL operators
484 for ( int i = 0; i < myOpList->count(); i++ ) {
485 CORBA::String_var anOperator = CORBA::string_dup( myOpList->item( i )->text().toLatin1().constData() );
486 anOp->GetOperatorParameters( anOperator.in(), aParams, aValues );
488 // set default values of parameters
489 if ( aParams->length() != aValues->length() )
492 for ( int j = 0; j < aParams->length(); j++ ) {
493 QWidget* aCtrl = getControl( (const char*)aParams[j] );
494 const char* aValue = set_convert( (const char*)aParams[j], aValues[j] );
495 setValue( aCtrl, aValue );
500 //=================================================================================
501 // function : setValue()
502 // purpose : set value in the proper way
503 //=================================================================================
504 void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const QString& theValue )
506 if ( theControl && !theValue.isNull() ) {
507 if ( qobject_cast<QDoubleSpinBox*>( theControl ) )
508 qobject_cast<QDoubleSpinBox*>( theControl )->setValue( theValue.toDouble() );
509 else if ( qobject_cast<QSpinBox*>( theControl ) )
510 qobject_cast<QSpinBox*>( theControl )->setValue( theValue.toInt() );
511 else if ( qobject_cast<QComboBox*>( theControl ) )
512 qobject_cast<QComboBox*>( theControl )->setEditText( theValue );
513 else if ( qobject_cast<QCheckBox*>( theControl ) )
514 qobject_cast<QCheckBox*>( theControl )->setChecked( theValue.toInt() != 0 );
518 //=================================================================================
519 // function : getValue()
520 // purpose : get value in the proper way
521 //=================================================================================
522 QString RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const
525 if ( qobject_cast<QDoubleSpinBox*>( theControl ) )
526 return QString::number( qobject_cast<QDoubleSpinBox*>( theControl )->value() );
527 else if ( qobject_cast<QSpinBox*>( theControl ) )
528 return QString::number( qobject_cast<QSpinBox*>( theControl )->value() );
529 else if ( qobject_cast<QComboBox*>( theControl ) )
530 return qobject_cast<QComboBox*>( theControl )->currentText();
531 else if ( qobject_cast<QCheckBox*>( theControl ) )
532 return qobject_cast<QCheckBox*>( theControl )->isChecked() ? "1" : "0";
537 //=================================================================================
538 // function : createOperation
540 //=================================================================================
541 GEOM::GEOM_IOperations_ptr RepairGUI_ShapeProcessDlg::createOperation()
543 return getGeomEngine()->GetIHealingOperations( getStudyId() );
546 //=================================================================================
547 // function : isValid
549 //=================================================================================
550 bool RepairGUI_ShapeProcessDlg::isValid( QString& msg )
553 GEOM::string_array_var anOperators = getActiveOperators();
554 if ( !myObjects->length() ) {
555 msg += tr( "ERROR_NO_OBJECTS" );
558 if ( !anOperators->length() ) {
561 msg += tr( "ERROR_NO_OPERATORS" );
567 //=================================================================================
568 // function : execute
570 //=================================================================================
571 bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects )
573 GEOM::string_array_var anOperators = getActiveOperators();
574 GEOM::string_array_var aParams = getParameters( anOperators );
575 GEOM::string_array_var aValues = getValues( aParams );
579 MESSAGE("Objects : ");
580 for ( z = 0; z < myObjects->length(); z++ )
581 MESSAGE(myObjects[z]->GetName() << " ");
582 MESSAGE("\nOperators : ");
583 for ( z = 0; z < anOperators->length(); z++ )
584 MESSAGE(anOperators[z] << " ");
585 MESSAGE("\nParameters : ");
586 for ( z = 0; z < aParams->length(); z++ )
587 MESSAGE(aParams[z] << " ");
588 MESSAGE("\nValues : ");
589 for ( z = 0; z < aValues->length(); z ++ )
590 MESSAGE(aValues[z] << " ");
594 QStringList anErrorObjNames;
595 for ( int i = 0; i < myObjects->length(); i++ ) {
596 GEOM::GEOM_Object_var obj = myObjects[i];
597 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->
598 ProcessShape( obj, anOperators, aParams, aValues );
599 if ( anObj->_is_nil() )
600 anErrorObjNames << GEOMBase::GetName( obj );
602 objects.push_back( anObj._retn() );
605 if ( !anErrorObjNames.empty() )
606 MESSAGE( "ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ).toLatin1().data() );
608 return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing.
611 //=================================================================================
612 // function : getActiveOperators
614 //=================================================================================
615 GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators()
617 GEOM::string_array_var anOperators = new GEOM::string_array();
618 QStringList aCheckedList;
620 for ( int i = 0; i < myOpList->count(); i++ ) {
621 if ( myOpList->item( i )->checkState() == Qt::Checked )
622 aCheckedList << myOpList->item( i )->text();
625 anOperators->length( aCheckedList.count() );
627 for ( int i = 0; i < aCheckedList.count(); i++ )
628 anOperators[i] = CORBA::string_dup( aCheckedList[i].toLatin1().constData() );
630 return anOperators._retn();
633 //=================================================================================
634 // function : getcontrol
636 //=================================================================================
637 QWidget* RepairGUI_ShapeProcessDlg::getControl( const QString& theParam )
639 if ( theParam == "SplitAngle.Angle" ) return mySplitAngleAngle;
640 else if ( theParam == "SplitAngle.MaxTolerance" ) return mySplitAngleMaxTol;
641 else if ( theParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum;
642 else if ( theParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol;
643 else if ( theParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D;
644 else if ( theParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk;
645 else if ( theParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk;
646 else if ( theParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk;
647 else if ( theParam == "BSplineRestriction.Tolerance3d" ) return myBSplineTol3D;
648 else if ( theParam == "BSplineRestriction.Tolerance2d" ) return myBSplineTol2D;
649 else if ( theParam == "BSplineRestriction.RequiredDegree" ) return myBSplineDegree;
650 else if ( theParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments;
651 else if ( theParam == "BSplineRestriction.Continuity3d" ) return myBSpline3DCont;
652 else if ( theParam == "BSplineRestriction.Continuity2d" ) return myBSpline2DCont;
653 else if ( theParam == "SplitContinuity.Tolerance3d" ) return mySplitContTol3D;
654 else if ( theParam == "SplitContinuity.SurfaceContinuity" ) return mySplitContSurfCont;
655 else if ( theParam == "SplitContinuity.CurveContinuity" ) return mySplitContCurvCont;
656 else if ( theParam == "ToBezier.SurfaceMode" ) return myToBezierSurfModeChk;
657 else if ( theParam == "ToBezier.Curve3dMode" ) return myToBezier3DCurveChk;
658 else if ( theParam == "ToBezier.Curve2dMode" ) return myToBezier2DCurveChk;
659 else if ( theParam == "ToBezier.MaxTolerance" ) return myToBezierMaxTol;
660 else if ( theParam == "SameParameter.Tolerance3d" ) return mySameParameterTol3D;
661 else if ( theParam == "FixShape.Tolerance3d" ) return myFixShapeTol3D;
662 else if ( theParam == "FixShape.MaxTolerance3d" ) return myFixShapeMaxTol3D;
666 //=================================================================================
667 // function : getParameters
669 //=================================================================================
670 void RepairGUI_ShapeProcessDlg::initParamsValues()
672 if ( myOpLst.count() )
673 return; // already filled
675 myOpLst << "FixShape";
676 myValMap["FixShape"] << "FixShape.Tolerance3d";
677 myValMap["FixShape"] << "FixShape.MaxTolerance3d";
679 myOpLst << "FixFaceSize";
680 myValMap["FixFaceSize"] << "FixFaceSize.Tolerance";
682 myOpLst << "DropSmallEdges";
683 myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d";
685 myOpLst << "SplitAngle";
686 myValMap["SplitAngle"] << "SplitAngle.Angle";
687 myValMap["SplitAngle"] << "SplitAngle.MaxTolerance";
689 myOpLst << "SplitClosedFaces";
690 myValMap["SplitClosedFaces"] << "SplitClosedFaces.NbSplitPoints";
692 myOpLst << "SplitContinuity";
693 myValMap["SplitContinuity"] << "SplitContinuity.Tolerance3d";
694 myValMap["SplitContinuity"] << "SplitContinuity.SurfaceContinuity";
695 myValMap["SplitContinuity"] << "SplitContinuity.CurveContinuity";
697 myOpLst << "BSplineRestriction";
698 myValMap["BSplineRestriction"] << "BSplineRestriction.SurfaceMode";
699 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve3dMode";
700 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve2dMode";
701 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance3d";
702 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance2d";
703 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredDegree";
704 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredNbSegments";
705 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity3d";
706 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity2d";
708 myOpLst << "ToBezier";
709 myValMap["ToBezier"] << "ToBezier.SurfaceMode";
710 myValMap["ToBezier"] << "ToBezier.Curve3dMode";
711 myValMap["ToBezier"] << "ToBezier.Curve2dMode";
712 myValMap["ToBezier"] << "ToBezier.MaxTolerance";
714 myOpLst << "SameParameter";
715 myValMap["SameParameter"] << "SameParameter.Tolerance3d";
718 //=================================================================================
719 // function : getParameters
721 //=================================================================================
722 GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string_array& theOperators )
724 GEOM::string_array_var aParams = new GEOM::string_array();
727 // calculate the length of parameters
728 for ( i = 0, j = 0; i < theOperators.length(); i++ )
729 j += myValMap[ QString( theOperators[i] ) ].size();
731 // set the new length of paremeters
732 aParams->length( j );
734 // fill the parameters
735 for ( i = 0, j = 0; i < theOperators.length(); i++ ) {
736 QStringList aValLst = myValMap[ QString( theOperators[i] ) ];
737 for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it )
738 aParams[j++] = CORBA::string_dup( (*it).toLatin1().constData() );
741 return aParams._retn();
745 //=================================================================================
746 // function : getValues
748 //=================================================================================
749 GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_array& theParams )
751 GEOM::string_array_var aValues = new GEOM::string_array();
752 aValues->length( theParams.length() );
754 for ( int i = 0; i < theParams.length(); i++ ) {
755 QWidget* aCtrl = getControl( (const char*)theParams[i] );
757 aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) );
760 return aValues._retn();
763 //=================================================================================
764 // function : initSelection
765 // purpose : set selection of ALL shape types except vertexes
766 //=================================================================================
767 void RepairGUI_ShapeProcessDlg::initSelection()
769 TColStd_MapOfInteger aTypes;
770 aTypes.Add( GEOM_COMPOUND );
771 aTypes.Add( GEOM_SOLID );
772 aTypes.Add( GEOM_SHELL );
773 aTypes.Add( GEOM_FACE );
774 aTypes.Add( GEOM_WIRE );
775 aTypes.Add( GEOM_EDGE );
776 globalSelection( aTypes );
779 //=================================================================================
780 // function : advOptionToggled
781 // purpose : this slot is used to warn the user about possible consequences
782 // of enabling some advanced options
783 //=================================================================================
784 void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on )
786 QAbstractButton* btn = (QAbstractButton*)sender();
787 if ( on && btn->isCheckable() &&
788 SUIT_MessageBox::warning( this,
789 tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ),
790 SUIT_MessageBox::Yes | SUIT_MessageBox::No ) == SUIT_MessageBox::No )