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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : RepairGUI_ShapeProcessDlg.cxx
25 // Author : Lucien PIGNOLONI
31 #include "RepairGUI_ShapeProcessDlg.h"
33 #include "GEOMImpl_Types.hxx"
35 #include "QAD_Desktop.h"
36 #include "SALOME_ListIteratorOfListIO.hxx"
37 #include "SALOME_ListIO.hxx"
39 #include <TCollection_AsciiString.hxx>
42 #include <qmessagebox.h>
45 //=================================================================================
46 // class : RepairGUI_ShapeProcessDlg()
47 // purpose : Constructs a RepairGUI_ShapeProcessDlg which is a child of 'parent', with the
48 // name 'name' and widget flags set to 'f'.
49 // The dialog will by default be modeless, unless you set 'modal' to
50 // TRUE to construct a modal dialog.
51 //=================================================================================
52 RepairGUI_ShapeProcessDlg::RepairGUI_ShapeProcessDlg(QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl)
53 :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
59 //=================================================================================
60 // function : ~RepairGUI_ShapeProcessDlg()
61 // purpose : Destroys the object and frees any allocated resources
62 //=================================================================================
63 RepairGUI_ShapeProcessDlg::~RepairGUI_ShapeProcessDlg()
68 //=================================================================================
71 //=================================================================================
72 void RepairGUI_ShapeProcessDlg::init()
74 myGeomGUI->SetState( 0 );
79 setCaption(tr("GEOM_SHAPEPROCESS_TITLE"));
81 GroupConstructors->hide();
83 // select widget on the top
84 mySelectWdgt = new DlgRef_1Sel_QTD( this, "SelectedObjects" );
85 mySelectWdgt->GroupBox1->setTitle( tr("GEOM_SHAPE") );
86 mySelectWdgt->TextLabel1->setText( tr("GEOM_SELECTED_OBJECTS") );
87 mySelectWdgt->PushButton1->setPixmap( QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT")) );
88 mySelectWdgt->LineEdit1->setReadOnly( true );
90 Layout1->addWidget( mySelectWdgt, 0, 0 );
92 // layout the two group boxes in the middle, add a list of operations
93 QFrame* aMidFrame = new QFrame( this );
94 QGridLayout* aMidLay = new QGridLayout( aMidFrame, 1, 3, 0, 5 );
95 QGroupBox* anOperGr = new QGroupBox( tr("GEOM_OPERATIONS"), aMidFrame );
96 QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr, 0, 0 );
98 myOpList = new QListView( anOperGr );
99 myOpList->setSorting( -1 );
100 myOpList->addColumn( "Operations" );
101 myOpList->header()->hide();
102 aOperLay->addWidget( myOpList );
103 QStringList::ConstIterator it = myOpLst.end();
104 do // iterating from end to begin so to keep the order of items in the listview.
105 new QCheckListItem ( myOpList, *(--it), QCheckListItem::CheckBox );
106 while ( it != myOpLst.begin() );
108 QGroupBox* aParamsGr = new QGroupBox( tr("GEOM_PARAMETERS"), aMidFrame );
109 aMidLay->addWidget( anOperGr, 0, 0 );
110 aMidLay->addMultiCellWidget( aParamsGr, 0, 0, 1, 3 );
111 aMidLay->setColStretch( 0, 1 );
112 aMidLay->setColStretch( 1, 2 );
114 Layout1->addWidget( aMidFrame, 2, 0 );
115 Layout1->setRowStretch( 0, 0 );
116 Layout1->setRowStretch( 1, 1 );
118 // add a widget stack to the parameters group box
119 myStack = new QWidgetStack( aParamsGr );
120 QVBoxLayout* aVParamsLay = new QVBoxLayout( aParamsGr );
121 aVParamsLay->addWidget( myStack );
123 // continueties values..
124 QStringList aContinueties = QStringList::split( ",", "C0,G1,C1,G2,C2,C3,CN" );
127 QFrame* aFrame = new QFrame( myStack );
128 QGridLayout* aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
130 myFixShapeTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
131 myFixShapeMaxTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
133 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
134 aLay->addWidget( myFixShapeTol3D, 0, 1 );
135 aLay->addWidget( new QLabel( tr("GEOM_MAX_3D_TOLERANCE"), aFrame ), 1, 0 );
136 aLay->addWidget( myFixShapeMaxTol3D, 1, 1 );
137 aLay->setRowStretch( 9, 2 );
139 myStack->addWidget( aFrame, myOpLst.findIndex( "FixShape" ) );
142 aFrame = new QFrame( myStack );
143 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
145 myFixFaceSizeTol = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
147 aLay->addWidget( new QLabel( tr("GEOM_TOLERANCE"), aFrame ), 0, 0 );
148 aLay->addWidget( myFixFaceSizeTol, 0, 1 );
149 aLay->setRowStretch( 9, 2 );
151 myStack->addWidget( aFrame, myOpLst.findIndex( "FixFaceSize" ) );
154 aFrame = new QFrame( myStack );
155 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
157 myDropSmallEdgesTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
159 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
160 aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 );
161 aLay->setRowStretch( 9, 2 );
163 myStack->addWidget( aFrame, myOpLst.findIndex( "DropSmallEdges" ) );
166 aFrame = new QFrame( myStack );
167 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
169 mySplitAngleAngle = new QAD_SpinBoxDbl( aFrame, 0, 360, 1 );
170 mySplitAngleMaxTol = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
172 aLay->addWidget( new QLabel( tr("GEOM_ANGLE_1"), aFrame ), 0, 0 );
173 aLay->addWidget( mySplitAngleAngle, 0, 1 );
174 aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame ), 1, 0 );
175 aLay->addWidget( mySplitAngleMaxTol, 1, 1 );
176 aLay->setRowStretch( 9, 2 );
178 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitAngle" ) );
181 aFrame = new QFrame( myStack );
182 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
184 mySplitClosedFacesNum = new QSpinBox( aFrame );
186 aLay->addWidget( new QLabel( tr("GEOM_NUM_SPLIT_POINTS"), aFrame ), 0, 0 );
187 aLay->addWidget( mySplitClosedFacesNum, 0, 1 );
188 aLay->setRowStretch( 9, 2 );
190 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitClosedFaces" ) );
193 aFrame = new QFrame( myStack );
194 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
196 mySplitContTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
197 mySplitContSurfCont = new QComboBox( aFrame );
198 mySplitContSurfCont->insertStringList( aContinueties );
199 mySplitContCurvCont = new QComboBox( aFrame );
200 mySplitContCurvCont->insertStringList( aContinueties );
202 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
203 aLay->addWidget( mySplitContTol3D, 0, 1 );
204 aLay->addWidget( new QLabel( tr("GEOM_SURFACE_CONTINUTY"), aFrame ), 1, 0 );
205 aLay->addWidget( mySplitContSurfCont, 1, 1 );
206 aLay->addWidget( new QLabel( tr("GEOM_CURVE_CONTINUTY"), aFrame ), 2, 0 );
207 aLay->addWidget( mySplitContCurvCont, 2, 1 );
208 aLay->setRowStretch( 9, 2 );
210 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitContinuity" ) );
212 // BSplineRestriction
213 aFrame = new QFrame( myStack );
214 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
216 myBSplineSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame );
217 myBSpline3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame );
218 myBSpline2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame );
219 myBSplineTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
220 myBSplineTol2D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
221 myBSplineDegree = new QSpinBox( aFrame );
222 myBSplineSegments = new QSpinBox( aFrame );
223 myBSpline2DCont = new QComboBox( aFrame );
224 myBSpline2DCont->insertStringList( aContinueties );
225 myBSpline3DCont = new QComboBox( aFrame );
226 myBSpline3DCont->insertStringList( 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"), aFrame), 3, 0 );
236 aLay->addWidget( myBSplineTol3D, 3, 1 );
237 aLay->addWidget( new QLabel( tr("GEOM_2D_TOLERANCE"), aFrame), 4, 0 );
238 aLay->addWidget( myBSplineTol2D, 4, 1 );
239 aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_DEGREE"), aFrame), 5, 0 );
240 aLay->addWidget( myBSplineDegree, 5, 1 );
241 aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_NUM_SEGMENTS"), aFrame), 6, 0 );
242 aLay->addWidget( myBSplineSegments, 6, 1 );
243 aLay->addWidget( new QLabel( tr("GEOM_3D_CONTINUTY"), aFrame), 7, 0 );
244 aLay->addWidget( myBSpline3DCont, 7, 1 );
245 aLay->addWidget( new QLabel( tr("GEOM_2D_CONTINUTY"), aFrame), 8, 0 );
246 aLay->addWidget( myBSpline2DCont, 8, 1 );
247 aLay->setRowStretch( 9, 2 );
249 myStack->addWidget( aFrame, myOpLst.findIndex( "BSplineRestriction" ) );
252 aFrame = new QFrame( myStack );
253 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
255 myToBezierSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame );
256 myToBezier3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame );
257 myToBezier2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame );
258 myToBezierMaxTol = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
260 aLay->addWidget( myToBezierSurfModeChk, 0, 0 );
261 aLay->addWidget( myToBezier3DCurveChk, 1, 0 );
262 aLay->addWidget( myToBezier2DCurveChk, 2, 0 );
263 aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame), 3, 0 );
264 aLay->addWidget( myToBezierMaxTol, 3, 1 );
265 aLay->setRowStretch( 9, 2 );
267 myStack->addWidget( aFrame, myOpLst.findIndex( "ToBezier" ) );
270 aFrame = new QFrame( myStack );
271 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
273 mySameParameterTol3D = new QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
275 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
276 aLay->addWidget( mySameParameterTol3D, 0, 1 );
277 aLay->setRowStretch( 9, 2 );
279 myStack->addWidget( aFrame, myOpLst.findIndex( "SameParameter" ) );
281 // signals and slots connections
282 connect( myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(deactivate()) );
283 connect( myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onCancel()) );
285 connect( buttonCancel, SIGNAL(clicked()), this, SLOT(onCancel()) );
286 connect( buttonOk, SIGNAL(clicked()), this, SLOT(onOk()) );
287 connect( buttonApply, SIGNAL(clicked()), this, SLOT(onApply()) );
289 connect( mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged()) );
290 connect( myOpList, SIGNAL(selectionChanged()), this, SLOT(operationChanged()) );
292 connect( mySelectWdgt->PushButton1, SIGNAL(clicked()), this, SLOT(selectClicked()) );
293 connect( mySelectWdgt->LineEdit1, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()) );
295 connect( myToBezierSurfModeChk, SIGNAL(toggled(bool)), SLOT(advOptionToggled(bool)) );
298 loadDefaults(); // init dialog fields with values from resource file
299 myOpList->setSelected( myOpList->findItem( "FixShape", 0 ), true );
302 initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) );
305 //=================================================================================
306 // function : operationChanged()
308 //=================================================================================
309 void RepairGUI_ShapeProcessDlg::operationChanged()
311 QListViewItem* anItem = myOpList->selectedItem();
314 int id = myOpLst.findIndex( anItem->text(0) );
316 myStack->raiseWidget( id );
320 //=================================================================================
322 // purpose : Same than click on apply but close this dialog.
323 //=================================================================================
324 void RepairGUI_ShapeProcessDlg::onOk()
332 //=================================================================================
333 // function : onApply()
335 //=================================================================================
336 bool RepairGUI_ShapeProcessDlg::onApply()
350 //=================================================================================
351 // function : onCancel()
353 //=================================================================================
354 void RepairGUI_ShapeProcessDlg::onCancel()
356 GEOMBase_Skeleton::ClickOnCancel();
360 //=================================================================================
361 // function : selectionChanged()
362 // purpose : Called when selection as changed or other case
363 // : used only by SelectButtonC1A1 (LineEditC1A1)
364 //=================================================================================
365 void RepairGUI_ShapeProcessDlg::selectionChanged()
369 Standard_Boolean aRes = Standard_False;
371 myObjects->length( mySelection->IObjectCount() );
372 for ( SALOME_ListIteratorOfListIO anIt( mySelection->StoredIObjects() ); anIt.More(); anIt.Next() )
374 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes );
375 if ( !CORBA::is_nil( aSelectedObject ) && aRes )
376 myObjects[i++] = aSelectedObject;
378 myObjects->length( i );
380 mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) );
382 mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) );
386 //=================================================================================
387 // function : selectClicked()
389 //=================================================================================
390 void RepairGUI_ShapeProcessDlg::selectClicked()
392 myEditCurrentArgument = mySelectWdgt->LineEdit1;
393 mySelectWdgt->LineEdit1->setFocus();
398 //=================================================================================
399 // function : lineEditReturnPressed()
401 //=================================================================================
402 void RepairGUI_ShapeProcessDlg::lineEditReturnPressed()
404 GEOMBase_Skeleton::LineEditReturnPressed();
408 //=================================================================================
409 // function : deactivate()
411 //=================================================================================
412 void RepairGUI_ShapeProcessDlg::deactivate()
414 myGeomGUI->SetState( -1 );
415 GEOMBase_Skeleton::DeactivateActiveDialog();
419 //=================================================================================
420 // function : activate()
422 //=================================================================================
423 void RepairGUI_ShapeProcessDlg::activate()
425 GEOMBase_Skeleton::ActivateThisDialog();
426 connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged()));
429 myGeomGUI->SetState( 0 );
434 //=================================================================================
435 // function : enterEvent()
436 // purpose : Mouse enter onto the dialog to activate it
437 //=================================================================================
438 void RepairGUI_ShapeProcessDlg::enterEvent(QEvent* e)
440 if ( !GroupConstructors->isEnabled() )
445 //=================================================================================
446 // function : closeEvent()
447 // purpose : same than click on cancel button
448 //=================================================================================
449 void RepairGUI_ShapeProcessDlg::closeEvent(QCloseEvent* e)
451 myGeomGUI->SetState( -1 );
452 GEOMBase_Skeleton::closeEvent( e );
456 //=================================================================================
457 // function : reset()
458 // purpose : Completely reset the state of method including local context
459 //=================================================================================
460 void RepairGUI_ShapeProcessDlg::reset()
462 myObjects = new GEOM::ListOfGO();
463 myObjects->length( 0 );
464 mySelectWdgt->LineEdit1->setText("");
468 //=================================================================================
469 // function : get_convert
470 // purpose : conversion of angle values to radians (non-angle values are not converted)
471 //=================================================================================
472 const char* get_convert( const char* theParam, const char* theValue )
474 if ( !strcmp( theParam, "SplitAngle.Angle" ) )
476 double doubleValue = atof( theValue ) * PI / 180;
477 TCollection_AsciiString str( doubleValue );
478 return CORBA::string_dup( str.ToCString() );
480 return CORBA::string_dup( theValue );
483 //=================================================================================
484 // function : set_convert
485 // purpose : conversion of angle values to degrees (non-angle values are not converted)
486 //=================================================================================
487 const char* set_convert( const char* theParam, const char* theValue )
489 if ( !strcmp( theParam, "SplitAngle.Angle" ) )
491 double doubleValue = atof( theValue ) * 180 / PI;
492 TCollection_AsciiString str( doubleValue );
493 return CORBA::string_dup( str.ToCString() );
495 return CORBA::string_dup( theValue );
498 //=================================================================================
499 // function : loadDefaults()
500 // purpose : initialize "values"-fields with default values retrieved from IHealingOperations
501 //=================================================================================
502 void RepairGUI_ShapeProcessDlg::loadDefaults()
504 const int aStudyId = QAD_Application::getDesktop()->getActiveStudy()->getStudyId();
505 GEOM::GEOM_IHealingOperations_var anOp = myGeomGUI->GetGeomGen()->GetIHealingOperations( aStudyId );
506 GEOM::string_array_var anOperators, aParams, aValues;
507 anOp->GetShapeProcessParameters( anOperators, aParams, aValues );
509 // check the default items-operators
511 for ( i = 0; i < anOperators->length(); i++ )
513 //MESSAGE("-->"<<(const char*)anOperators[i]);
514 QListViewItem* anItem = myOpList->findItem( (const char*)anOperators[i], 0 );
515 if ( anItem /*&& anItem->inherits( "QCheckListItem" )*/ )
516 ((QCheckListItem*) anItem)->setOn( true );
519 // Retrieve default parameters for ALL operators
520 for ( QListViewItemIterator it(myOpList); it.current(); ++it ) {
521 CORBA::String_var anOperator = CORBA::string_dup( it.current()->text( 0 ).latin1() );
522 anOp->GetOperatorParameters( anOperator.in(), aParams, aValues );
524 // set default values of parameters
525 if ( aParams->length() != aValues->length() )
527 for ( i = 0; i < aParams->length(); i++ ) {
528 QWidget* aCtrl = getControl( (const char*)aParams[i] );
529 const char* aValue = set_convert( (const char*)aParams[i], aValues[i] );
530 setValue( aCtrl, aValue );
535 //=================================================================================
536 // function : setValue()
537 // purpose : set value in the proper way
538 //=================================================================================
539 void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const char* theValue )
541 if ( theControl == NULL || theValue == NULL )
544 if ( theControl->isA( "QAD_SpinBoxDbl" ) )
545 ((QAD_SpinBoxDbl*)theControl)->setValue( QString( theValue ).toDouble() );
546 else if ( theControl->isA( "QSpinBox" ) )
547 ((QSpinBox*)theControl)->setValue( QString( theValue ).toInt() );
548 else if ( theControl->isA( "QComboBox" ) )
549 ((QComboBox*)theControl)->setCurrentText( QString( theValue ) );
550 else if ( theControl->isA( "QCheckBox" ) )
551 ((QCheckBox*)theControl)->setChecked( QString( theValue ).toInt() != 0 );
554 //=================================================================================
555 // function : getValue()
556 // purpose : get value in the proper way
557 //=================================================================================
558 const char* RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const
560 if ( theControl == NULL )
563 if ( theControl->isA( "QAD_SpinBoxDbl" ) )
564 return ((QAD_SpinBoxDbl*)theControl)->text().latin1();
565 else if ( theControl->isA( "QSpinBox" ) )
566 return ((QSpinBox*)theControl)->text().latin1();
567 else if ( theControl->isA( "QComboBox" ) )
568 return ((QComboBox*)theControl)->currentText().latin1();
569 else if ( theControl->isA( "QCheckBox" ) )
570 return ((QCheckBox*)theControl)->isChecked() ? "1" : "0";
575 //=================================================================================
576 // function : createOperation
578 //=================================================================================
579 GEOM::GEOM_IOperations_ptr RepairGUI_ShapeProcessDlg::createOperation()
581 return getGeomEngine()->GetIHealingOperations( getStudyId() );
584 //=================================================================================
585 // function : isValid
587 //=================================================================================
588 bool RepairGUI_ShapeProcessDlg::isValid( QString& msg )
591 GEOM::string_array_var anOperators = getActiveOperators();
592 if ( !myObjects->length() )
594 msg += tr( "ERROR_NO_OBJECTS" );
597 if ( !anOperators->length() )
601 msg += tr( "ERROR_NO_OPERATORS" );
607 //=================================================================================
608 // function : execute
610 //=================================================================================
611 bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects )
613 GEOM::string_array_var anOperators = getActiveOperators();
614 GEOM::string_array_var aParams = getParameters( anOperators );
615 GEOM::string_array_var aValues = getValues( aParams );
619 MESSAGE("Objects : ");
620 for ( z = 0; z < myObjects->length(); z++ )
621 MESSAGE(myObjects[z]->GetName() << " ");
622 MESSAGE("\nOperators : ");
623 for ( z = 0; z < anOperators->length(); z++ )
624 MESSAGE(anOperators[z] << " ");
625 MESSAGE("\nParameters : ");
626 for ( z = 0; z < aParams->length(); z++ )
627 MESSAGE(aParams[z] << " ");
628 MESSAGE("\nValues : ");
629 for ( z = 0; z < aValues->length(); z ++ )
630 MESSAGE(aValues[z] << " ");
634 QStringList anErrorObjNames;
635 for ( int i = 0; i < myObjects->length(); i++ )
637 GEOM::GEOM_Object_var obj = myObjects[i];
638 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->ProcessShape(
639 obj, anOperators, aParams, aValues );
640 if ( anObj->_is_nil() )
641 anErrorObjNames << GEOMBase::GetName( obj );
643 objects.push_back( anObj._retn() );
646 if ( !anErrorObjNames.empty() )
647 MESSAGE("ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ));
649 return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing.
652 //=================================================================================
653 // function : getActiveOperators
655 //=================================================================================
656 GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators()
658 GEOM::string_array_var anOperators = new GEOM::string_array();
659 QStringList aCheckedList;
660 QStringList::Iterator it;
661 for ( it = myOpLst.begin(); it != myOpLst.end(); ++it )
662 if ( ((QCheckListItem*)myOpList->findItem( *it, 0 ))->isOn() )
664 anOperators->length( aCheckedList.size() );
666 for ( it = aCheckedList.begin(); it != aCheckedList.end(); ++it )
667 anOperators[i++] = CORBA::string_dup( (*it).latin1() );
669 return anOperators._retn();
672 //=================================================================================
673 // function : getcontrol
675 //=================================================================================
676 QWidget* RepairGUI_ShapeProcessDlg::getControl( const char* theParam )
678 string aParam = theParam;
679 if ( aParam == "SplitAngle.Angle" ) return mySplitAngleAngle;
680 else if ( aParam == "SplitAngle.MaxTolerance" ) return mySplitAngleMaxTol;
681 else if ( aParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum;
682 else if ( aParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol;
683 else if ( aParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D;
684 else if ( aParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk;
685 else if ( aParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk;
686 else if ( aParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk;
687 else if ( aParam == "BSplineRestriction.Tolerance3d" ) return myBSplineTol3D;
688 else if ( aParam == "BSplineRestriction.Tolerance2d" ) return myBSplineTol2D;
689 else if ( aParam == "BSplineRestriction.RequiredDegree" ) return myBSplineDegree;
690 else if ( aParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments;
691 else if ( aParam == "BSplineRestriction.Continuity3d" ) return myBSpline3DCont;
692 else if ( aParam == "BSplineRestriction.Continuity2d" ) return myBSpline2DCont;
693 else if ( aParam == "SplitContinuity.Tolerance3d" ) return mySplitContTol3D;
694 else if ( aParam == "SplitContinuity.SurfaceContinuity" ) return mySplitContSurfCont;
695 else if ( aParam == "SplitContinuity.CurveContinuity" ) return mySplitContCurvCont;
696 else if ( aParam == "ToBezier.SurfaceMode" ) return myToBezierSurfModeChk;
697 else if ( aParam == "ToBezier.Curve3dMode" ) return myToBezier3DCurveChk;
698 else if ( aParam == "ToBezier.Curve2dMode" ) return myToBezier2DCurveChk;
699 else if ( aParam == "ToBezier.MaxTolerance" ) return myToBezierMaxTol;
700 else if ( aParam == "SameParameter.Tolerance3d" ) return mySameParameterTol3D;
701 else if ( aParam == "FixShape.Tolerance3d" ) return myFixShapeTol3D;
702 else if ( aParam == "FixShape.MaxTolerance3d" ) return myFixShapeMaxTol3D;
706 //=================================================================================
707 // function : getParameters
709 //=================================================================================
710 void RepairGUI_ShapeProcessDlg::initParamsValues()
712 myOpLst << "FixShape";
713 myValMap["FixShape"] << "FixShape.Tolerance3d";
714 myValMap["FixShape"] << "FixShape.MaxTolerance3d";
716 myOpLst << "FixFaceSize";
717 myValMap["FixFaceSize"] << "FixFaceSize.Tolerance";
719 myOpLst << "DropSmallEdges";
720 myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d";
722 myOpLst << "SplitAngle";
723 myValMap["SplitAngle"] << "SplitAngle.Angle";
724 myValMap["SplitAngle"] << "SplitAngle.MaxTolerance";
726 myOpLst << "SplitClosedFaces";
727 myValMap["SplitClosedFaces"] << "SplitClosedFaces.NbSplitPoints";
729 myOpLst << "SplitContinuity";
730 myValMap["SplitContinuity"] << "SplitContinuity.Tolerance3d";
731 myValMap["SplitContinuity"] << "SplitContinuity.SurfaceContinuity";
732 myValMap["SplitContinuity"] << "SplitContinuity.CurveContinuity";
734 myOpLst << "BSplineRestriction";
735 myValMap["BSplineRestriction"] << "BSplineRestriction.SurfaceMode";
736 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve3dMode";
737 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve2dMode";
738 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance3d";
739 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance2d";
740 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredDegree";
741 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredNbSegments";
742 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity3d";
743 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity2d";
745 myOpLst << "ToBezier";
746 myValMap["ToBezier"] << "ToBezier.SurfaceMode";
747 myValMap["ToBezier"] << "ToBezier.Curve3dMode";
748 myValMap["ToBezier"] << "ToBezier.Curve2dMode";
749 myValMap["ToBezier"] << "ToBezier.MaxTolerance";
751 myOpLst << "SameParameter";
752 myValMap["SameParameter"] << "SameParameter.Tolerance3d";
755 //=================================================================================
756 // function : getParameters
758 //=================================================================================
759 GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string_array& theOperators )
761 GEOM::string_array_var aParams = new GEOM::string_array();
764 // calculate the length of parameters
765 for ( i = 0, j = 0; i < theOperators.length(); i++ )
766 j+= myValMap[QString((const char*)theOperators[i])].size();
768 // set the new length of paremeters
769 aParams->length( j );
771 // fill the parameters
772 for ( i = 0, j = 0; i < theOperators.length(); i++ )
774 QStringList aValLst = myValMap[QString( (const char*)theOperators[i] )];
775 for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it )
776 aParams[j++] = CORBA::string_dup( (*it).latin1() );
779 return aParams._retn();
783 //=================================================================================
784 // function : getValues
786 //=================================================================================
787 GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_array& theParams )
789 GEOM::string_array_var aValues = new GEOM::string_array();
790 aValues->length( theParams.length() );
792 for ( int i = 0; i < theParams.length(); i++ )
794 QWidget* aCtrl = getControl( (const char*)theParams[i] );
796 aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) );
799 return aValues._retn();
802 //=================================================================================
803 // function : initSelection
804 // purpose : set selection of ALL shape types except vertexes
805 //=================================================================================
806 void RepairGUI_ShapeProcessDlg::initSelection()
808 TColStd_MapOfInteger aTypes;
809 aTypes.Add( GEOM_COMPOUND );
810 aTypes.Add( GEOM_SOLID );
811 aTypes.Add( GEOM_SHELL );
812 aTypes.Add( GEOM_FACE );
813 aTypes.Add( GEOM_WIRE );
814 aTypes.Add( GEOM_EDGE );
815 globalSelection( aTypes );
818 //=================================================================================
819 // function : advOptionToggled
820 // purpose : this slot is used to warn the user about possible consequences
821 // of enabling some advanced options
822 //=================================================================================
823 void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on )
825 QButton* btn = (QButton*)sender();
826 if ( on && btn->isToggleButton() &&
827 QMessageBox::warning( QAD_Application::getDesktop(), tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )