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>
32 #include <QtxDoubleSpinBox.h>
34 #include <SalomeApp_Application.h>
35 #include <LightApp_SelectionMgr.h>
36 #include <SUIT_Session.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_MessageBox.h>
39 #include <SALOME_ListIteratorOfListIO.hxx>
40 #include <SALOME_ListIO.hxx>
42 #include <TCollection_AsciiString.hxx>
43 #include <TColStd_MapOfInteger.hxx>
45 #include <QListWidget>
46 #include <QStackedLayout>
48 //=================================================================================
49 // class : RepairGUI_ShapeProcessDlg()
50 // purpose : Constructs a RepairGUI_ShapeProcessDlg which is a child of 'parent', with the
51 // name 'name' and widget flags set to 'f'.
52 // The dialog will by default be modeless, unless you set 'modal' to
53 // TRUE to construct a modal dialog.
54 //=================================================================================
55 RepairGUI_ShapeProcessDlg::RepairGUI_ShapeProcessDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
57 : GEOMBase_Skeleton( theGeometryGUI, parent, modal )
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 setWindowTitle( tr( "GEOM_SHAPEPROCESS_TITLE" ) );
84 mainFrame()->GroupConstructors->hide();
86 // select widget on the top
87 mySelectWdgt = new DlgRef_1Sel( centralWidget() );
88 mySelectWdgt->GroupBox1->setTitle( tr( "GEOM_SHAPE" ) );
89 mySelectWdgt->TextLabel1->setText( tr( "GEOM_SELECTED_OBJECTS" ) );
90 mySelectWdgt->PushButton1->setIcon( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
91 mySelectWdgt->LineEdit1->setReadOnly( true );
93 // layout the two group boxes in the middle, add a list of operations
94 QGroupBox* anOperGr = new QGroupBox( tr( "GEOM_OPERATIONS" ), centralWidget() );
96 // operations list widget
97 myOpList = new QListWidget( anOperGr );
98 myOpList->setSortingEnabled( false );
99 myOpList->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
101 QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr );
102 aOperLay->setMargin( 9 );
103 aOperLay->addWidget( myOpList );
105 QGroupBox* aParamsGr = new QGroupBox( tr( "GEOM_PARAMETERS" ), centralWidget() );
107 // add a widget stack to the parameters group box
108 QStackedLayout* aStack = new QStackedLayout( aParamsGr );
110 // continueties values..
111 QStringList aContinueties = QString( "C0,G1,C1,G2,C2,C3,CN" ).split( "," );
113 // fill in the widgets
114 for ( int i = 0; i < myOpLst.count(); i++ ) {
115 QListWidgetItem* item = new QListWidgetItem( myOpLst[i] );
116 item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable );
117 item->setCheckState( Qt::Unchecked );
118 myOpList->addItem( item );
121 if ( myOpLst[i] == "FixShape" ) {
123 w = new QWidget( aParamsGr );
124 QGridLayout* aLay = new QGridLayout( w );
125 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
127 myFixShapeTol3D = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
128 myFixShapeMaxTol3D = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
130 aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
131 aLay->addWidget( myFixShapeTol3D, 0, 1 );
132 aLay->addWidget( new QLabel( tr( "GEOM_MAX_3D_TOLERANCE" ), w ), 1, 0 );
133 aLay->addWidget( myFixShapeMaxTol3D, 1, 1 );
134 aLay->setRowStretch( aLay->rowCount(), 5 );
136 else if ( myOpLst[i] == "FixFaceSize" ) {
138 w = new QWidget( aParamsGr );
139 QGridLayout* aLay = new QGridLayout( w );
140 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
142 myFixFaceSizeTol = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
144 aLay->addWidget( new QLabel( tr( "GEOM_TOLERANCE" ), w ), 0, 0 );
145 aLay->addWidget( myFixFaceSizeTol, 0, 1 );
146 aLay->setRowStretch( aLay->rowCount(), 5 );
148 else if ( myOpLst[i] == "DropSmallEdges" ) {
150 w = new QWidget( aParamsGr );
151 QGridLayout* aLay = new QGridLayout( w );
152 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
154 myDropSmallEdgesTol3D = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
156 aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
157 aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 );
158 aLay->setRowStretch( aLay->rowCount(), 5 );
160 else if ( myOpLst[i] == "SplitAngle" ) {
162 w = new QWidget( aParamsGr );
163 QGridLayout* aLay = new QGridLayout( w );
164 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
166 mySplitAngleAngle = new QtxDoubleSpinBox( 0, 360, 1, 10, 10, w );
167 mySplitAngleMaxTol = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
169 aLay->addWidget( new QLabel( tr( "GEOM_ANGLE_1" ), w ), 0, 0 );
170 aLay->addWidget( mySplitAngleAngle, 0, 1 );
171 aLay->addWidget( new QLabel( tr( "GEOM_MAX_TOLERANCE" ), w ), 1, 0 );
172 aLay->addWidget( mySplitAngleMaxTol, 1, 1 );
173 aLay->setRowStretch( aLay->rowCount(), 5 );
175 else if ( myOpLst[i] == "SplitClosedFaces" ) {
177 w = new QWidget( aParamsGr );
178 QGridLayout* aLay = new QGridLayout( w );
179 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
181 mySplitClosedFacesNum = new QSpinBox( w );
183 aLay->addWidget( new QLabel( tr( "GEOM_NUM_SPLIT_POINTS" ), w ), 0, 0 );
184 aLay->addWidget( mySplitClosedFacesNum, 0, 1 );
185 aLay->setRowStretch( aLay->rowCount(), 5 );
187 else if ( myOpLst[i] == "SplitContinuity" ) {
189 w = new QWidget( aParamsGr );
190 QGridLayout* aLay = new QGridLayout( w );
191 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
193 mySplitContTol3D = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
194 mySplitContSurfCont = new QComboBox( w );
195 mySplitContSurfCont->addItems( aContinueties );
196 mySplitContCurvCont = new QComboBox( w );
197 mySplitContCurvCont->addItems( aContinueties );
199 aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
200 aLay->addWidget( mySplitContTol3D, 0, 1 );
201 aLay->addWidget( new QLabel( tr( "GEOM_SURFACE_CONTINUTY" ), w ), 1, 0 );
202 aLay->addWidget( mySplitContSurfCont, 1, 1 );
203 aLay->addWidget( new QLabel( tr( "GEOM_CURVE_CONTINUTY" ), w ), 2, 0 );
204 aLay->addWidget( mySplitContCurvCont, 2, 1 );
205 aLay->setRowStretch( aLay->rowCount(), 5 );
207 else if ( myOpLst[i] == "BSplineRestriction" ) {
208 // BSplineRestriction
209 w = new QWidget( aParamsGr );
210 QGridLayout* aLay = new QGridLayout( w );
211 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
213 myBSplineSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), w );
214 myBSpline3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), w );
215 myBSpline2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), w );
217 myBSplineTol3D = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
219 myBSplineTol2D = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
221 myBSplineDegree = new QSpinBox( w );
222 myBSplineSegments = new QSpinBox( w );
223 myBSpline2DCont = new QComboBox( w );
224 myBSpline2DCont->addItems( aContinueties );
225 myBSpline3DCont = new QComboBox( w );
226 myBSpline3DCont->addItems( aContinueties );
228 myBSplineSurfModeChk->setChecked( true );
229 myBSpline3DCurveChk->setChecked( true );
230 myBSpline2DCurveChk->setChecked( true );
232 aLay->addWidget( myBSplineSurfModeChk, 0, 0 );
233 aLay->addWidget( myBSpline3DCurveChk, 1, 0 );
234 aLay->addWidget( myBSpline2DCurveChk, 2, 0 );
235 aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 3, 0 );
236 aLay->addWidget( myBSplineTol3D, 3, 1 );
237 aLay->addWidget( new QLabel( tr( "GEOM_2D_TOLERANCE" ), w ), 4, 0 );
238 aLay->addWidget( myBSplineTol2D, 4, 1 );
239 aLay->addWidget( new QLabel( tr( "GEOM_REQUIRED_DEGREE" ), w ), 5, 0 );
240 aLay->addWidget( myBSplineDegree, 5, 1 );
241 aLay->addWidget( new QLabel( tr( "GEOM_REQUIRED_NUM_SEGMENTS" ), w ), 6, 0 );
242 aLay->addWidget( myBSplineSegments, 6, 1 );
243 aLay->addWidget( new QLabel( tr( "GEOM_3D_CONTINUTY" ), w ), 7, 0 );
244 aLay->addWidget( myBSpline3DCont, 7, 1 );
245 aLay->addWidget( new QLabel( tr( "GEOM_2D_CONTINUTY" ), w ), 8, 0 );
246 aLay->addWidget( myBSpline2DCont, 8, 1 );
247 aLay->setRowStretch( aLay->rowCount(), 5 );
249 else if ( myOpLst[i] == "ToBezier" ) {
251 w = new QWidget( aParamsGr );
252 QGridLayout* aLay = new QGridLayout( w );
253 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
255 myToBezierSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), w );
256 myToBezier3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), w );
257 myToBezier2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), w );
259 myToBezierMaxTol = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
261 aLay->addWidget( myToBezierSurfModeChk, 0, 0 );
262 aLay->addWidget( myToBezier3DCurveChk, 1, 0 );
263 aLay->addWidget( myToBezier2DCurveChk, 2, 0 );
264 aLay->addWidget( new QLabel( tr( "GEOM_MAX_TOLERANCE" ), w ), 3, 0 );
265 aLay->addWidget( myToBezierMaxTol, 3, 1 );
266 aLay->setRowStretch( aLay->rowCount(), 5 );
268 else if ( myOpLst[i] == "SameParameter" ) {
270 w = new QWidget( aParamsGr );
271 QGridLayout* aLay = new QGridLayout( w );
272 aLay->setMargin( 9 ); aLay->setSpacing( 6 );
274 mySameParameterTol3D = new QtxDoubleSpinBox( 0., 100., 1e-7, 10, 10, w );
276 aLay->addWidget( new QLabel( tr( "GEOM_3D_TOLERANCE" ), w ), 0, 0 );
277 aLay->addWidget( mySameParameterTol3D, 0, 1 );
278 aLay->setRowStretch( aLay->rowCount(), 5 );
281 w = new QWidget( aParamsGr ); // dumb widget
283 aStack->insertWidget( i, w );
286 QGridLayout* layout = new QGridLayout( centralWidget() );
287 layout->setMargin( 0 ); layout->setSpacing( 6 );
288 layout->addWidget( mySelectWdgt, 0, 0, 1, 2 );
289 layout->addWidget( anOperGr, 1, 0 );
290 layout->addWidget( aParamsGr, 1, 1 );
292 // signals and slots connections
293 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( onOk() ) );
294 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( onApply() ) );
296 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
297 SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) );
299 connect( mySelectWdgt->PushButton1, SIGNAL( clicked() ), this, SLOT( selectClicked() ) );
300 connect( mySelectWdgt->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( lineEditReturnPressed() ) );
302 connect( myToBezierSurfModeChk, SIGNAL( toggled( bool ) ), this, SLOT( advOptionToggled( bool ) ) );
304 connect( myOpList, SIGNAL( currentRowChanged( int ) ), aStack, SLOT( setCurrentIndex( int ) ) );
307 loadDefaults(); // init dialog fields with values from resource file
308 //myOpList->setCurrentRow( myOpList->findItem( 0 );
311 initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) );
314 //=================================================================================
316 // purpose : Same than click on apply but close this dialog.
317 //=================================================================================
318 void RepairGUI_ShapeProcessDlg::onOk()
324 //=================================================================================
325 // function : onApply()
327 //=================================================================================
328 bool RepairGUI_ShapeProcessDlg::onApply()
342 //=================================================================================
343 // function : selectionChanged()
344 // purpose : Called when selection as changed or other case
345 // : used only by SelectButtonC1A1 (LineEditC1A1)
346 //=================================================================================
347 void RepairGUI_ShapeProcessDlg::selectionChanged()
351 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
352 SALOME_ListIO aSelList;
353 aSelMgr->selectedObjects(aSelList);
355 Standard_Boolean aRes = Standard_False;
357 myObjects->length(aSelList.Extent());
358 for (SALOME_ListIteratorOfListIO anIt (aSelList); anIt.More(); anIt.Next()) {
359 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes );
360 if ( !CORBA::is_nil( aSelectedObject ) && aRes )
361 myObjects[i++] = aSelectedObject;
363 myObjects->length( i );
365 mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) );
367 mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) );
371 //=================================================================================
372 // function : selectClicked()
374 //=================================================================================
375 void RepairGUI_ShapeProcessDlg::selectClicked()
377 myEditCurrentArgument = mySelectWdgt->LineEdit1;
378 mySelectWdgt->LineEdit1->setFocus();
383 //=================================================================================
384 // function : lineEditReturnPressed()
386 //=================================================================================
387 void RepairGUI_ShapeProcessDlg::lineEditReturnPressed()
389 GEOMBase_Skeleton::LineEditReturnPressed();
393 //=================================================================================
394 // function : activate()
396 //=================================================================================
397 void RepairGUI_ShapeProcessDlg::activate()
399 GEOMBase_Skeleton::ActivateThisDialog();
400 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication( ) ))->selectionMgr(),
401 SIGNAL( currentSelectionChanged() ), this, SLOT( selectionChanged() ) );
404 //myGeomGUI->SetState( 0 );
409 //=================================================================================
410 // function : enterEvent()
411 // purpose : Mouse enter onto the dialog to activate it
412 //=================================================================================
413 void RepairGUI_ShapeProcessDlg::enterEvent( QEvent* )
415 if ( !mainFrame()->GroupBoxName->isEnabled() )
420 //=================================================================================
421 // function : reset()
422 // purpose : Completely reset the state of method including local context
423 //=================================================================================
424 void RepairGUI_ShapeProcessDlg::reset()
426 myObjects = new GEOM::ListOfGO();
427 myObjects->length( 0 );
428 mySelectWdgt->LineEdit1->setText( "" );
432 //=================================================================================
433 // function : get_convert
434 // purpose : conversion of angle values to radians (non-angle values are not converted)
435 //=================================================================================
436 const char* get_convert( const char* theParam, const QString& theValue )
438 if ( !strcmp( theParam, "SplitAngle.Angle" ) ) {
439 double doubleValue = theValue.toDouble() * PI / 180;
440 return CORBA::string_dup( QString::number( doubleValue ).toLatin1().constData() );
442 return CORBA::string_dup( theValue.toLatin1().constData() );
445 //=================================================================================
446 // function : set_convert
447 // purpose : conversion of angle values to degrees (non-angle values are not converted)
448 //=================================================================================
449 const char* set_convert( const char* theParam, const char* theValue )
451 if ( !strcmp( theParam, "SplitAngle.Angle" ) ) {
452 double doubleValue = atof( theValue ) * 180 / PI;
453 TCollection_AsciiString str( doubleValue );
454 return CORBA::string_dup( str.ToCString() );
456 return CORBA::string_dup( theValue );
459 //=================================================================================
460 // function : loadDefaults()
461 // purpose : initialize "values"-fields with default values retrieved from IHealingOperations
462 //=================================================================================
463 void RepairGUI_ShapeProcessDlg::loadDefaults()
465 GEOM::GEOM_IHealingOperations_var anOp = myGeomGUI->GetGeomGen()->GetIHealingOperations( getStudyId() );
466 GEOM::string_array_var anOperators, aParams, aValues;
467 anOp->GetShapeProcessParameters( anOperators, aParams, aValues );
469 // check the default items-operators
470 for ( int i = 0; i < anOperators->length(); i++ ) {
471 //MESSAGE("-->"<<(const char*)anOperators[i]);
472 QList<QListWidgetItem*> items = myOpList->findItems ( (const char*)anOperators[i], Qt::MatchFixedString );
474 ( items[0] )->setCheckState( Qt::Checked );
477 // Retrieve default parameters for ALL operators
478 for ( int i = 0; i < myOpList->count(); i++ ) {
479 CORBA::String_var anOperator = CORBA::string_dup( myOpList->item( i )->text().toLatin1().constData() );
480 anOp->GetOperatorParameters( anOperator.in(), aParams, aValues );
482 // set default values of parameters
483 if ( aParams->length() != aValues->length() )
486 for ( int j = 0; j < aParams->length(); j++ ) {
487 QWidget* aCtrl = getControl( (const char*)aParams[j] );
488 const char* aValue = set_convert( (const char*)aParams[j], aValues[j] );
489 setValue( aCtrl, aValue );
494 //=================================================================================
495 // function : setValue()
496 // purpose : set value in the proper way
497 //=================================================================================
498 void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const QString& theValue )
500 if ( theControl && !theValue.isNull() ) {
501 if ( qobject_cast<QtxDoubleSpinBox*>( theControl ) )
502 qobject_cast<QtxDoubleSpinBox*>( theControl )->setValue( theValue.toDouble() );
503 else if ( qobject_cast<QSpinBox*>( theControl ) )
504 qobject_cast<QSpinBox*>( theControl )->setValue( theValue.toInt() );
505 else if ( qobject_cast<QComboBox*>( theControl ) )
506 qobject_cast<QComboBox*>( theControl )->setEditText( theValue );
507 else if ( qobject_cast<QCheckBox*>( theControl ) )
508 qobject_cast<QCheckBox*>( theControl )->setChecked( theValue.toInt() != 0 );
512 //=================================================================================
513 // function : getValue()
514 // purpose : get value in the proper way
515 //=================================================================================
516 QString RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const
519 if ( qobject_cast<QtxDoubleSpinBox*>( theControl ) )
520 return QString::number( qobject_cast<QtxDoubleSpinBox*>( theControl )->value() );
521 else if ( qobject_cast<QSpinBox*>( theControl ) )
522 return QString::number( qobject_cast<QSpinBox*>( theControl )->value() );
523 else if ( qobject_cast<QComboBox*>( theControl ) )
524 return qobject_cast<QComboBox*>( theControl )->currentText();
525 else if ( qobject_cast<QCheckBox*>( theControl ) )
526 return qobject_cast<QCheckBox*>( theControl )->isChecked() ? "1" : "0";
531 //=================================================================================
532 // function : createOperation
534 //=================================================================================
535 GEOM::GEOM_IOperations_ptr RepairGUI_ShapeProcessDlg::createOperation()
537 return getGeomEngine()->GetIHealingOperations( getStudyId() );
540 //=================================================================================
541 // function : isValid
543 //=================================================================================
544 bool RepairGUI_ShapeProcessDlg::isValid( QString& msg )
547 GEOM::string_array_var anOperators = getActiveOperators();
548 if ( !myObjects->length() ) {
549 msg += tr( "ERROR_NO_OBJECTS" );
552 if ( !anOperators->length() ) {
555 msg += tr( "ERROR_NO_OPERATORS" );
561 //=================================================================================
562 // function : execute
564 //=================================================================================
565 bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects )
567 GEOM::string_array_var anOperators = getActiveOperators();
568 GEOM::string_array_var aParams = getParameters( anOperators );
569 GEOM::string_array_var aValues = getValues( aParams );
573 MESSAGE("Objects : ");
574 for ( z = 0; z < myObjects->length(); z++ )
575 MESSAGE(myObjects[z]->GetName() << " ");
576 MESSAGE("\nOperators : ");
577 for ( z = 0; z < anOperators->length(); z++ )
578 MESSAGE(anOperators[z] << " ");
579 MESSAGE("\nParameters : ");
580 for ( z = 0; z < aParams->length(); z++ )
581 MESSAGE(aParams[z] << " ");
582 MESSAGE("\nValues : ");
583 for ( z = 0; z < aValues->length(); z ++ )
584 MESSAGE(aValues[z] << " ");
588 QStringList anErrorObjNames;
589 for ( int i = 0; i < myObjects->length(); i++ ) {
590 GEOM::GEOM_Object_var obj = myObjects[i];
591 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->
592 ProcessShape( obj, anOperators, aParams, aValues );
593 if ( anObj->_is_nil() )
594 anErrorObjNames << GEOMBase::GetName( obj );
596 objects.push_back( anObj._retn() );
599 if ( !anErrorObjNames.empty() )
600 MESSAGE( "ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ).toLatin1().data() );
602 return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing.
605 //=================================================================================
606 // function : getActiveOperators
608 //=================================================================================
609 GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators()
611 GEOM::string_array_var anOperators = new GEOM::string_array();
612 QStringList aCheckedList;
614 for ( int i = 0; i < myOpList->count(); i++ ) {
615 if ( myOpList->item( i )->checkState() == Qt::Checked )
616 aCheckedList << myOpList->item( i )->text();
619 anOperators->length( aCheckedList.count() );
621 for ( int i = 0; i < aCheckedList.count(); i++ )
622 anOperators[i] = CORBA::string_dup( aCheckedList[i].toLatin1().constData() );
624 return anOperators._retn();
627 //=================================================================================
628 // function : getcontrol
630 //=================================================================================
631 QWidget* RepairGUI_ShapeProcessDlg::getControl( const QString& theParam )
633 if ( theParam == "SplitAngle.Angle" ) return mySplitAngleAngle;
634 else if ( theParam == "SplitAngle.MaxTolerance" ) return mySplitAngleMaxTol;
635 else if ( theParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum;
636 else if ( theParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol;
637 else if ( theParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D;
638 else if ( theParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk;
639 else if ( theParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk;
640 else if ( theParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk;
641 else if ( theParam == "BSplineRestriction.Tolerance3d" ) return myBSplineTol3D;
642 else if ( theParam == "BSplineRestriction.Tolerance2d" ) return myBSplineTol2D;
643 else if ( theParam == "BSplineRestriction.RequiredDegree" ) return myBSplineDegree;
644 else if ( theParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments;
645 else if ( theParam == "BSplineRestriction.Continuity3d" ) return myBSpline3DCont;
646 else if ( theParam == "BSplineRestriction.Continuity2d" ) return myBSpline2DCont;
647 else if ( theParam == "SplitContinuity.Tolerance3d" ) return mySplitContTol3D;
648 else if ( theParam == "SplitContinuity.SurfaceContinuity" ) return mySplitContSurfCont;
649 else if ( theParam == "SplitContinuity.CurveContinuity" ) return mySplitContCurvCont;
650 else if ( theParam == "ToBezier.SurfaceMode" ) return myToBezierSurfModeChk;
651 else if ( theParam == "ToBezier.Curve3dMode" ) return myToBezier3DCurveChk;
652 else if ( theParam == "ToBezier.Curve2dMode" ) return myToBezier2DCurveChk;
653 else if ( theParam == "ToBezier.MaxTolerance" ) return myToBezierMaxTol;
654 else if ( theParam == "SameParameter.Tolerance3d" ) return mySameParameterTol3D;
655 else if ( theParam == "FixShape.Tolerance3d" ) return myFixShapeTol3D;
656 else if ( theParam == "FixShape.MaxTolerance3d" ) return myFixShapeMaxTol3D;
660 //=================================================================================
661 // function : getParameters
663 //=================================================================================
664 void RepairGUI_ShapeProcessDlg::initParamsValues()
666 if ( myOpLst.count() )
667 return; // already filled
669 myOpLst << "FixShape";
670 myValMap["FixShape"] << "FixShape.Tolerance3d";
671 myValMap["FixShape"] << "FixShape.MaxTolerance3d";
673 myOpLst << "FixFaceSize";
674 myValMap["FixFaceSize"] << "FixFaceSize.Tolerance";
676 myOpLst << "DropSmallEdges";
677 myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d";
679 myOpLst << "SplitAngle";
680 myValMap["SplitAngle"] << "SplitAngle.Angle";
681 myValMap["SplitAngle"] << "SplitAngle.MaxTolerance";
683 myOpLst << "SplitClosedFaces";
684 myValMap["SplitClosedFaces"] << "SplitClosedFaces.NbSplitPoints";
686 myOpLst << "SplitContinuity";
687 myValMap["SplitContinuity"] << "SplitContinuity.Tolerance3d";
688 myValMap["SplitContinuity"] << "SplitContinuity.SurfaceContinuity";
689 myValMap["SplitContinuity"] << "SplitContinuity.CurveContinuity";
691 myOpLst << "BSplineRestriction";
692 myValMap["BSplineRestriction"] << "BSplineRestriction.SurfaceMode";
693 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve3dMode";
694 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve2dMode";
695 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance3d";
696 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance2d";
697 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredDegree";
698 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredNbSegments";
699 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity3d";
700 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity2d";
702 myOpLst << "ToBezier";
703 myValMap["ToBezier"] << "ToBezier.SurfaceMode";
704 myValMap["ToBezier"] << "ToBezier.Curve3dMode";
705 myValMap["ToBezier"] << "ToBezier.Curve2dMode";
706 myValMap["ToBezier"] << "ToBezier.MaxTolerance";
708 myOpLst << "SameParameter";
709 myValMap["SameParameter"] << "SameParameter.Tolerance3d";
712 //=================================================================================
713 // function : getParameters
715 //=================================================================================
716 GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string_array& theOperators )
718 GEOM::string_array_var aParams = new GEOM::string_array();
721 // calculate the length of parameters
722 for ( i = 0, j = 0; i < theOperators.length(); i++ )
723 j += myValMap[ QString( theOperators[i] ) ].size();
725 // set the new length of paremeters
726 aParams->length( j );
728 // fill the parameters
729 for ( i = 0, j = 0; i < theOperators.length(); i++ ) {
730 QStringList aValLst = myValMap[ QString( theOperators[i] ) ];
731 for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it )
732 aParams[j++] = CORBA::string_dup( (*it).toLatin1().constData() );
735 return aParams._retn();
739 //=================================================================================
740 // function : getValues
742 //=================================================================================
743 GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_array& theParams )
745 GEOM::string_array_var aValues = new GEOM::string_array();
746 aValues->length( theParams.length() );
748 for ( int i = 0; i < theParams.length(); i++ ) {
749 QWidget* aCtrl = getControl( (const char*)theParams[i] );
751 aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) );
754 return aValues._retn();
757 //=================================================================================
758 // function : initSelection
759 // purpose : set selection of ALL shape types except vertexes
760 //=================================================================================
761 void RepairGUI_ShapeProcessDlg::initSelection()
763 TColStd_MapOfInteger aTypes;
764 aTypes.Add( GEOM_COMPOUND );
765 aTypes.Add( GEOM_SOLID );
766 aTypes.Add( GEOM_SHELL );
767 aTypes.Add( GEOM_FACE );
768 aTypes.Add( GEOM_WIRE );
769 aTypes.Add( GEOM_EDGE );
770 globalSelection( aTypes );
773 //=================================================================================
774 // function : advOptionToggled
775 // purpose : this slot is used to warn the user about possible consequences
776 // of enabling some advanced options
777 //=================================================================================
778 void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on )
780 QAbstractButton* btn = (QAbstractButton*)sender();
781 if ( on && btn->isCheckable() &&
782 SUIT_MessageBox::warning( this,
783 tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ),
784 SUIT_MessageBox::Yes | SUIT_MessageBox::No ) == SUIT_MessageBox::No )