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
29 #include "RepairGUI_ShapeProcessDlg.h"
31 #include "GEOMImpl_Types.hxx"
33 #include "SalomeApp_Application.h"
34 #include "LightApp_SelectionMgr.h"
35 #include "SUIT_Session.h"
36 #include "SALOME_ListIteratorOfListIO.hxx"
37 #include "SALOME_ListIO.hxx"
39 #include <TCollection_AsciiString.hxx>
40 #include <TColStd_MapOfInteger.hxx>
44 #include <qmessagebox.h>
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(QWidget* parent, const char* name, bool modal, WFlags fl)
56 :GEOMBase_Skeleton(parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
62 //=================================================================================
63 // function : ~RepairGUI_ShapeProcessDlg()
64 // purpose : Destroys the object and frees any allocated resources
65 //=================================================================================
66 RepairGUI_ShapeProcessDlg::~RepairGUI_ShapeProcessDlg()
71 //=================================================================================
74 //=================================================================================
75 void RepairGUI_ShapeProcessDlg::init()
77 //myGeomGUI->SetState( 0 );
82 setCaption(tr("GEOM_SHAPEPROCESS_TITLE"));
84 GroupConstructors->hide();
86 // select widget on the top
87 mySelectWdgt = new DlgRef_1Sel_QTD( this, "SelectedObjects" );
88 mySelectWdgt->GroupBox1->setTitle( tr("GEOM_SHAPE") );
89 mySelectWdgt->TextLabel1->setText( tr("GEOM_SELECTED_OBJECTS") );
90 mySelectWdgt->PushButton1->setPixmap( SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")) );
91 mySelectWdgt->LineEdit1->setReadOnly( true );
93 Layout1->addWidget( mySelectWdgt, 0, 0 );
95 // layout the two group boxes in the middle, add a list of operations
96 QFrame* aMidFrame = new QFrame( this );
97 QGridLayout* aMidLay = new QGridLayout( aMidFrame, 1, 3, 0, 5 );
98 QGroupBox* anOperGr = new QGroupBox( tr("GEOM_OPERATIONS"), aMidFrame );
99 QVBoxLayout* aOperLay = new QVBoxLayout( anOperGr, 0, 0 );
101 myOpList = new QListView( anOperGr );
102 myOpList->setSorting( -1 );
103 myOpList->addColumn( "Operations" );
104 myOpList->header()->hide();
105 aOperLay->addWidget( myOpList );
106 QStringList::ConstIterator it = myOpLst.end();
107 do // iterating from end to begin so to keep the order of items in the listview.
108 new QCheckListItem ( myOpList, *(--it), QCheckListItem::CheckBox );
109 while ( it != myOpLst.begin() );
111 QGroupBox* aParamsGr = new QGroupBox( tr("GEOM_PARAMETERS"), aMidFrame );
112 aMidLay->addWidget( anOperGr, 0, 0 );
113 aMidLay->addMultiCellWidget( aParamsGr, 0, 0, 1, 3 );
114 aMidLay->setColStretch( 0, 1 );
115 aMidLay->setColStretch( 1, 2 );
117 Layout1->addWidget( aMidFrame, 2, 0 );
118 Layout1->setRowStretch( 0, 0 );
119 Layout1->setRowStretch( 1, 1 );
121 // add a widget stack to the parameters group box
122 myStack = new QWidgetStack( aParamsGr );
123 QVBoxLayout* aVParamsLay = new QVBoxLayout( aParamsGr );
124 aVParamsLay->addWidget( myStack );
126 // continueties values..
127 QStringList aContinueties = QStringList::split( ",", "C0,G1,C1,G2,C2,C3,CN" );
130 QFrame* aFrame = new QFrame( myStack );
131 QGridLayout* aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
133 myFixShapeTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
134 myFixShapeTol3D->setPrecision( 10 );
135 myFixShapeMaxTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
136 myFixShapeMaxTol3D->setPrecision( 10 );
138 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
139 aLay->addWidget( myFixShapeTol3D, 0, 1 );
140 aLay->addWidget( new QLabel( tr("GEOM_MAX_3D_TOLERANCE"), aFrame ), 1, 0 );
141 aLay->addWidget( myFixShapeMaxTol3D, 1, 1 );
142 aLay->setRowStretch( 9, 2 );
144 myStack->addWidget( aFrame, myOpLst.findIndex( "FixShape" ) );
147 aFrame = new QFrame( myStack );
148 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
150 myFixFaceSizeTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
151 myFixFaceSizeTol->setPrecision( 10 );
153 aLay->addWidget( new QLabel( tr("GEOM_TOLERANCE"), aFrame ), 0, 0 );
154 aLay->addWidget( myFixFaceSizeTol, 0, 1 );
155 aLay->setRowStretch( 9, 2 );
157 myStack->addWidget( aFrame, myOpLst.findIndex( "FixFaceSize" ) );
160 aFrame = new QFrame( myStack );
161 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
163 myDropSmallEdgesTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
164 myDropSmallEdgesTol3D->setPrecision( 10 );
166 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
167 aLay->addWidget( myDropSmallEdgesTol3D, 0, 1 );
168 aLay->setRowStretch( 9, 2 );
170 myStack->addWidget( aFrame, myOpLst.findIndex( "DropSmallEdges" ) );
173 aFrame = new QFrame( myStack );
174 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
176 mySplitAngleAngle = new QtxDblSpinBox( 0, 360, 1, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 360, 1 );
177 mySplitAngleMaxTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
178 mySplitAngleMaxTol->setPrecision( 10 );
180 aLay->addWidget( new QLabel( tr("GEOM_ANGLE_1"), aFrame ), 0, 0 );
181 aLay->addWidget( mySplitAngleAngle, 0, 1 );
182 aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame ), 1, 0 );
183 aLay->addWidget( mySplitAngleMaxTol, 1, 1 );
184 aLay->setRowStretch( 9, 2 );
186 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitAngle" ) );
189 aFrame = new QFrame( myStack );
190 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
192 mySplitClosedFacesNum = new QSpinBox( aFrame );
194 aLay->addWidget( new QLabel( tr("GEOM_NUM_SPLIT_POINTS"), aFrame ), 0, 0 );
195 aLay->addWidget( mySplitClosedFacesNum, 0, 1 );
196 aLay->setRowStretch( 9, 2 );
198 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitClosedFaces" ) );
201 aFrame = new QFrame( myStack );
202 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
204 mySplitContTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
205 mySplitContTol3D->setPrecision( 10 );
206 mySplitContSurfCont = new QComboBox( aFrame );
207 mySplitContSurfCont->insertStringList( aContinueties );
208 mySplitContCurvCont = new QComboBox( aFrame );
209 mySplitContCurvCont->insertStringList( aContinueties );
211 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
212 aLay->addWidget( mySplitContTol3D, 0, 1 );
213 aLay->addWidget( new QLabel( tr("GEOM_SURFACE_CONTINUTY"), aFrame ), 1, 0 );
214 aLay->addWidget( mySplitContSurfCont, 1, 1 );
215 aLay->addWidget( new QLabel( tr("GEOM_CURVE_CONTINUTY"), aFrame ), 2, 0 );
216 aLay->addWidget( mySplitContCurvCont, 2, 1 );
217 aLay->setRowStretch( 9, 2 );
219 myStack->addWidget( aFrame, myOpLst.findIndex( "SplitContinuity" ) );
221 // BSplineRestriction
222 aFrame = new QFrame( myStack );
223 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
225 myBSplineSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame );
226 myBSpline3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame );
227 myBSpline2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame );
229 myBSplineTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
230 myBSplineTol3D->setPrecision( 10 );
232 myBSplineTol2D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
233 myBSplineTol2D->setPrecision( 10 );
235 myBSplineDegree = new QSpinBox( aFrame );
236 myBSplineSegments = new QSpinBox( aFrame );
237 myBSpline2DCont = new QComboBox( aFrame );
238 myBSpline2DCont->insertStringList( aContinueties );
239 myBSpline3DCont = new QComboBox( aFrame );
240 myBSpline3DCont->insertStringList( aContinueties );
242 myBSplineSurfModeChk->setChecked( true );
243 myBSpline3DCurveChk->setChecked( true );
244 myBSpline2DCurveChk->setChecked( true );
246 aLay->addWidget( myBSplineSurfModeChk, 0, 0 );
247 aLay->addWidget( myBSpline3DCurveChk, 1, 0 );
248 aLay->addWidget( myBSpline2DCurveChk, 2, 0 );
249 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame), 3, 0 );
250 aLay->addWidget( myBSplineTol3D, 3, 1 );
251 aLay->addWidget( new QLabel( tr("GEOM_2D_TOLERANCE"), aFrame), 4, 0 );
252 aLay->addWidget( myBSplineTol2D, 4, 1 );
253 aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_DEGREE"), aFrame), 5, 0 );
254 aLay->addWidget( myBSplineDegree, 5, 1 );
255 aLay->addWidget( new QLabel( tr("GEOM_REQUIRED_NUM_SEGMENTS"), aFrame), 6, 0 );
256 aLay->addWidget( myBSplineSegments, 6, 1 );
257 aLay->addWidget( new QLabel( tr("GEOM_3D_CONTINUTY"), aFrame), 7, 0 );
258 aLay->addWidget( myBSpline3DCont, 7, 1 );
259 aLay->addWidget( new QLabel( tr("GEOM_2D_CONTINUTY"), aFrame), 8, 0 );
260 aLay->addWidget( myBSpline2DCont, 8, 1 );
261 aLay->setRowStretch( 9, 2 );
263 myStack->addWidget( aFrame, myOpLst.findIndex( "BSplineRestriction" ) );
266 aFrame = new QFrame( myStack );
267 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
269 myToBezierSurfModeChk = new QCheckBox( tr("GEOM_SURFACE_MODE"), aFrame );
270 myToBezier3DCurveChk = new QCheckBox( tr("GEOM_3D_CURVE_MODE"), aFrame );
271 myToBezier2DCurveChk = new QCheckBox( tr("GEOM_2D_CURVE_MODE"), aFrame );
273 myToBezierMaxTol = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
274 myToBezierMaxTol->setPrecision( 10 );
276 aLay->addWidget( myToBezierSurfModeChk, 0, 0 );
277 aLay->addWidget( myToBezier3DCurveChk, 1, 0 );
278 aLay->addWidget( myToBezier2DCurveChk, 2, 0 );
279 aLay->addWidget( new QLabel( tr("GEOM_MAX_TOLERANCE"), aFrame), 3, 0 );
280 aLay->addWidget( myToBezierMaxTol, 3, 1 );
281 aLay->setRowStretch( 9, 2 );
283 myStack->addWidget( aFrame, myOpLst.findIndex( "ToBezier" ) );
286 aFrame = new QFrame( myStack );
287 aLay = new QGridLayout( aFrame, 10, 2, 0, 5 );
289 mySameParameterTol3D = new QtxDblSpinBox( 0, 100, 1e-7, aFrame );//QAD_SpinBoxDbl( aFrame, 0, 100, 1e-7, 10, 1e-10 );
290 mySameParameterTol3D->setPrecision( 10 );
292 aLay->addWidget( new QLabel( tr("GEOM_3D_TOLERANCE"), aFrame ), 0, 0 );
293 aLay->addWidget( mySameParameterTol3D, 0, 1 );
294 aLay->setRowStretch( 9, 2 );
296 myStack->addWidget( aFrame, myOpLst.findIndex( "SameParameter" ) );
298 // signals and slots connections
299 connect( myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(deactivate()) );
300 connect( myGeomGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onCancel()) );
302 connect( buttonCancel, SIGNAL(clicked()), this, SLOT(onCancel()) );
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()) );
308 connect( myOpList, SIGNAL(selectionChanged()), this, SLOT(operationChanged()) );
310 connect( mySelectWdgt->PushButton1, SIGNAL(clicked()), this, SLOT(selectClicked()) );
311 connect( mySelectWdgt->LineEdit1, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()) );
313 connect( myToBezierSurfModeChk, SIGNAL(toggled(bool)), SLOT(advOptionToggled(bool)) );
316 loadDefaults(); // init dialog fields with values from resource file
317 myOpList->setSelected( myOpList->findItem( "FixShape", 0 ), true );
320 initName( tr( "PROCESS_SHAPE_NEW_OBJ_NAME" ) );
323 //=================================================================================
324 // function : operationChanged()
326 //=================================================================================
327 void RepairGUI_ShapeProcessDlg::operationChanged()
329 QListViewItem* anItem = myOpList->selectedItem();
332 int id = myOpLst.findIndex( anItem->text(0) );
334 myStack->raiseWidget( id );
338 //=================================================================================
340 // purpose : Same than click on apply but close this dialog.
341 //=================================================================================
342 void RepairGUI_ShapeProcessDlg::onOk()
350 //=================================================================================
351 // function : onApply()
353 //=================================================================================
354 bool RepairGUI_ShapeProcessDlg::onApply()
368 //=================================================================================
369 // function : onCancel()
371 //=================================================================================
372 void RepairGUI_ShapeProcessDlg::onCancel()
374 GEOMBase_Skeleton::ClickOnCancel();
378 //=================================================================================
379 // function : selectionChanged()
380 // purpose : Called when selection as changed or other case
381 // : used only by SelectButtonC1A1 (LineEditC1A1)
382 //=================================================================================
383 void RepairGUI_ShapeProcessDlg::selectionChanged()
387 Standard_Boolean aRes = Standard_False;
389 myObjects->length( IObjectCount() );
390 for ( SALOME_ListIteratorOfListIO anIt( selectedIO() ); anIt.More(); anIt.Next() )
392 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( anIt.Value(), aRes );
393 if ( !CORBA::is_nil( aSelectedObject ) && aRes )
394 myObjects[i++] = aSelectedObject;
396 myObjects->length( i );
398 mySelectWdgt->LineEdit1->setText( GEOMBase::GetName( myObjects[0] ) );
400 mySelectWdgt->LineEdit1->setText( QString::number( i ) + "_" + tr( "GEOM_OBJECTS" ) );
404 //=================================================================================
405 // function : selectClicked()
407 //=================================================================================
408 void RepairGUI_ShapeProcessDlg::selectClicked()
410 myEditCurrentArgument = mySelectWdgt->LineEdit1;
411 mySelectWdgt->LineEdit1->setFocus();
416 //=================================================================================
417 // function : lineEditReturnPressed()
419 //=================================================================================
420 void RepairGUI_ShapeProcessDlg::lineEditReturnPressed()
422 GEOMBase_Skeleton::LineEditReturnPressed();
426 //=================================================================================
427 // function : deactivate()
429 //=================================================================================
430 void RepairGUI_ShapeProcessDlg::deactivate()
432 //myGeomGUI->SetState( -1 );
433 GEOMBase_Skeleton::DeactivateActiveDialog();
437 //=================================================================================
438 // function : activate()
440 //=================================================================================
441 void RepairGUI_ShapeProcessDlg::activate()
443 GEOMBase_Skeleton::ActivateThisDialog();
444 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
445 SIGNAL(currentSelectionChanged()), this, SLOT(selectionChanged()));
448 //myGeomGUI->SetState( 0 );
453 //=================================================================================
454 // function : enterEvent()
455 // purpose : Mouse enter onto the dialog to activate it
456 //=================================================================================
457 void RepairGUI_ShapeProcessDlg::enterEvent(QEvent* e)
459 if ( !GroupConstructors->isEnabled() )
464 //=================================================================================
465 // function : closeEvent()
466 // purpose : same than click on cancel button
467 //=================================================================================
468 void RepairGUI_ShapeProcessDlg::closeEvent(QCloseEvent* e)
470 //myGeomGUI->SetState( -1 );
471 GEOMBase_Skeleton::closeEvent( e );
475 //=================================================================================
476 // function : reset()
477 // purpose : Completely reset the state of method including local context
478 //=================================================================================
479 void RepairGUI_ShapeProcessDlg::reset()
481 myObjects = new GEOM::ListOfGO();
482 myObjects->length( 0 );
483 mySelectWdgt->LineEdit1->setText("");
487 //=================================================================================
488 // function : get_convert
489 // purpose : conversion of angle values to radians (non-angle values are not converted)
490 //=================================================================================
491 const char* get_convert( const char* theParam, const char* theValue )
493 if ( !strcmp( theParam, "SplitAngle.Angle" ) )
495 double doubleValue = atof( theValue ) * PI / 180;
496 TCollection_AsciiString str( doubleValue );
497 return CORBA::string_dup( str.ToCString() );
499 return CORBA::string_dup( theValue );
502 //=================================================================================
503 // function : set_convert
504 // purpose : conversion of angle values to degrees (non-angle values are not converted)
505 //=================================================================================
506 const char* set_convert( const char* theParam, const char* theValue )
508 if ( !strcmp( theParam, "SplitAngle.Angle" ) )
510 double doubleValue = atof( theValue ) * 180 / PI;
511 TCollection_AsciiString str( doubleValue );
512 return CORBA::string_dup( str.ToCString() );
514 return CORBA::string_dup( theValue );
517 //=================================================================================
518 // function : loadDefaults()
519 // purpose : initialize "values"-fields with default values retrieved from IHealingOperations
520 //=================================================================================
521 void RepairGUI_ShapeProcessDlg::loadDefaults()
523 GEOM::GEOM_IHealingOperations_var anOp = myGeomGUI->GetGeomGen()->GetIHealingOperations( getStudyId() );
524 GEOM::string_array_var anOperators, aParams, aValues;
525 anOp->GetShapeProcessParameters( anOperators, aParams, aValues );
527 // check the default items-operators
529 for ( i = 0; i < anOperators->length(); i++ )
531 //MESSAGE("-->"<<(const char*)anOperators[i]);
532 QListViewItem* anItem = myOpList->findItem( (const char*)anOperators[i], 0 );
533 if ( anItem /*&& anItem->inherits( "QCheckListItem" )*/ )
534 ((QCheckListItem*) anItem)->setOn( true );
537 // Retrieve default parameters for ALL operators
538 for ( QListViewItemIterator it(myOpList); it.current(); ++it ) {
539 CORBA::String_var anOperator = CORBA::string_dup( it.current()->text( 0 ).latin1() );
540 anOp->GetOperatorParameters( anOperator.in(), aParams, aValues );
542 // set default values of parameters
543 if ( aParams->length() != aValues->length() )
545 for ( i = 0; i < aParams->length(); i++ ) {
546 QWidget* aCtrl = getControl( (const char*)aParams[i] );
547 const char* aValue = set_convert( (const char*)aParams[i], aValues[i] );
548 setValue( aCtrl, aValue );
553 //=================================================================================
554 // function : setValue()
555 // purpose : set value in the proper way
556 //=================================================================================
557 void RepairGUI_ShapeProcessDlg::setValue( QWidget* theControl, const char* theValue )
559 if ( theControl == NULL || theValue == NULL )
562 if ( theControl->isA( "QtxDblSpinBox" ) )
563 ((QtxDblSpinBox*)theControl)->setValue( QString( theValue ).toDouble() );
564 else if ( theControl->isA( "QSpinBox" ) )
565 ((QSpinBox*)theControl)->setValue( QString( theValue ).toInt() );
566 else if ( theControl->isA( "QComboBox" ) )
567 ((QComboBox*)theControl)->setCurrentText( QString( theValue ) );
568 else if ( theControl->isA( "QCheckBox" ) )
569 ((QCheckBox*)theControl)->setChecked( QString( theValue ).toInt() != 0 );
572 //=================================================================================
573 // function : getValue()
574 // purpose : get value in the proper way
575 //=================================================================================
576 const char* RepairGUI_ShapeProcessDlg::getValue( QWidget* theControl ) const
578 if ( theControl == NULL )
581 if ( theControl->isA( "QtxDblSpinBox" ) )
582 return ((QtxDblSpinBox*)theControl)->text().latin1();
583 else if ( theControl->isA( "QSpinBox" ) )
584 return ((QSpinBox*)theControl)->text().latin1();
585 else if ( theControl->isA( "QComboBox" ) )
586 return ((QComboBox*)theControl)->currentText().latin1();
587 else if ( theControl->isA( "QCheckBox" ) )
588 return ((QCheckBox*)theControl)->isChecked() ? "1" : "0";
593 //=================================================================================
594 // function : createOperation
596 //=================================================================================
597 GEOM::GEOM_IOperations_ptr RepairGUI_ShapeProcessDlg::createOperation()
599 return getGeomEngine()->GetIHealingOperations( getStudyId() );
602 //=================================================================================
603 // function : isValid
605 //=================================================================================
606 bool RepairGUI_ShapeProcessDlg::isValid( QString& msg )
609 GEOM::string_array_var anOperators = getActiveOperators();
610 if ( !myObjects->length() )
612 msg += tr( "ERROR_NO_OBJECTS" );
615 if ( !anOperators->length() )
619 msg += tr( "ERROR_NO_OPERATORS" );
625 //=================================================================================
626 // function : execute
628 //=================================================================================
629 bool RepairGUI_ShapeProcessDlg::execute( ObjectList& objects )
631 GEOM::string_array_var anOperators = getActiveOperators();
632 GEOM::string_array_var aParams = getParameters( anOperators );
633 GEOM::string_array_var aValues = getValues( aParams );
637 MESSAGE("Objects : ");
638 for ( z = 0; z < myObjects->length(); z++ )
639 MESSAGE(myObjects[z]->GetName() << " ");
640 MESSAGE("\nOperators : ");
641 for ( z = 0; z < anOperators->length(); z++ )
642 MESSAGE(anOperators[z] << " ");
643 MESSAGE("\nParameters : ");
644 for ( z = 0; z < aParams->length(); z++ )
645 MESSAGE(aParams[z] << " ");
646 MESSAGE("\nValues : ");
647 for ( z = 0; z < aValues->length(); z ++ )
648 MESSAGE(aValues[z] << " ");
652 QStringList anErrorObjNames;
653 for ( int i = 0; i < myObjects->length(); i++ )
655 GEOM::GEOM_Object_var obj = myObjects[i];
656 GEOM::GEOM_Object_var anObj = GEOM::GEOM_IHealingOperations::_narrow( getOperation() )->ProcessShape(
657 obj, anOperators, aParams, aValues );
658 if ( anObj->_is_nil() )
659 anErrorObjNames << GEOMBase::GetName( obj );
661 objects.push_back( anObj._retn() );
664 if ( !anErrorObjNames.empty() )
665 MESSAGE("ERRORS occured while processing the following objects: " << anErrorObjNames.join( " " ));
667 return anErrorObjNames.size() < myObjects->length(); // true if at least one object was OK, false if ALL objects were nil after Healing.
670 //=================================================================================
671 // function : getActiveOperators
673 //=================================================================================
674 GEOM::string_array* RepairGUI_ShapeProcessDlg::getActiveOperators()
676 GEOM::string_array_var anOperators = new GEOM::string_array();
677 QStringList aCheckedList;
678 QStringList::Iterator it;
679 for ( it = myOpLst.begin(); it != myOpLst.end(); ++it )
680 if ( ((QCheckListItem*)myOpList->findItem( *it, 0 ))->isOn() )
682 anOperators->length( aCheckedList.size() );
684 for ( it = aCheckedList.begin(); it != aCheckedList.end(); ++it )
685 anOperators[i++] = CORBA::string_dup( (*it).latin1() );
687 return anOperators._retn();
690 //=================================================================================
691 // function : getcontrol
693 //=================================================================================
694 QWidget* RepairGUI_ShapeProcessDlg::getControl( const char* theParam )
696 string aParam = theParam;
697 if ( aParam == "SplitAngle.Angle" ) return mySplitAngleAngle;
698 else if ( aParam == "SplitAngle.MaxTolerance" ) return mySplitAngleMaxTol;
699 else if ( aParam == "SplitClosedFaces.NbSplitPoints" ) return mySplitClosedFacesNum;
700 else if ( aParam == "FixFaceSize.Tolerance" ) return myFixFaceSizeTol;
701 else if ( aParam == "DropSmallEdges.Tolerance3d" ) return myDropSmallEdgesTol3D;
702 else if ( aParam == "BSplineRestriction.SurfaceMode" ) return myBSplineSurfModeChk;
703 else if ( aParam == "BSplineRestriction.Curve3dMode" ) return myBSpline3DCurveChk;
704 else if ( aParam == "BSplineRestriction.Curve2dMode" ) return myBSpline2DCurveChk;
705 else if ( aParam == "BSplineRestriction.Tolerance3d" ) return myBSplineTol3D;
706 else if ( aParam == "BSplineRestriction.Tolerance2d" ) return myBSplineTol2D;
707 else if ( aParam == "BSplineRestriction.RequiredDegree" ) return myBSplineDegree;
708 else if ( aParam == "BSplineRestriction.RequiredNbSegments" ) return myBSplineSegments;
709 else if ( aParam == "BSplineRestriction.Continuity3d" ) return myBSpline3DCont;
710 else if ( aParam == "BSplineRestriction.Continuity2d" ) return myBSpline2DCont;
711 else if ( aParam == "SplitContinuity.Tolerance3d" ) return mySplitContTol3D;
712 else if ( aParam == "SplitContinuity.SurfaceContinuity" ) return mySplitContSurfCont;
713 else if ( aParam == "SplitContinuity.CurveContinuity" ) return mySplitContCurvCont;
714 else if ( aParam == "ToBezier.SurfaceMode" ) return myToBezierSurfModeChk;
715 else if ( aParam == "ToBezier.Curve3dMode" ) return myToBezier3DCurveChk;
716 else if ( aParam == "ToBezier.Curve2dMode" ) return myToBezier2DCurveChk;
717 else if ( aParam == "ToBezier.MaxTolerance" ) return myToBezierMaxTol;
718 else if ( aParam == "SameParameter.Tolerance3d" ) return mySameParameterTol3D;
719 else if ( aParam == "FixShape.Tolerance3d" ) return myFixShapeTol3D;
720 else if ( aParam == "FixShape.MaxTolerance3d" ) return myFixShapeMaxTol3D;
724 //=================================================================================
725 // function : getParameters
727 //=================================================================================
728 void RepairGUI_ShapeProcessDlg::initParamsValues()
730 myOpLst << "FixShape";
731 myValMap["FixShape"] << "FixShape.Tolerance3d";
732 myValMap["FixShape"] << "FixShape.MaxTolerance3d";
734 myOpLst << "FixFaceSize";
735 myValMap["FixFaceSize"] << "FixFaceSize.Tolerance";
737 myOpLst << "DropSmallEdges";
738 myValMap["DropSmallEdges"] << "DropSmallEdges.Tolerance3d";
740 myOpLst << "SplitAngle";
741 myValMap["SplitAngle"] << "SplitAngle.Angle";
742 myValMap["SplitAngle"] << "SplitAngle.MaxTolerance";
744 myOpLst << "SplitClosedFaces";
745 myValMap["SplitClosedFaces"] << "SplitClosedFaces.NbSplitPoints";
747 myOpLst << "SplitContinuity";
748 myValMap["SplitContinuity"] << "SplitContinuity.Tolerance3d";
749 myValMap["SplitContinuity"] << "SplitContinuity.SurfaceContinuity";
750 myValMap["SplitContinuity"] << "SplitContinuity.CurveContinuity";
752 myOpLst << "BSplineRestriction";
753 myValMap["BSplineRestriction"] << "BSplineRestriction.SurfaceMode";
754 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve3dMode";
755 myValMap["BSplineRestriction"] << "BSplineRestriction.Curve2dMode";
756 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance3d";
757 myValMap["BSplineRestriction"] << "BSplineRestriction.Tolerance2d";
758 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredDegree";
759 myValMap["BSplineRestriction"] << "BSplineRestriction.RequiredNbSegments";
760 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity3d";
761 myValMap["BSplineRestriction"] << "BSplineRestriction.Continuity2d";
763 myOpLst << "ToBezier";
764 myValMap["ToBezier"] << "ToBezier.SurfaceMode";
765 myValMap["ToBezier"] << "ToBezier.Curve3dMode";
766 myValMap["ToBezier"] << "ToBezier.Curve2dMode";
767 myValMap["ToBezier"] << "ToBezier.MaxTolerance";
769 myOpLst << "SameParameter";
770 myValMap["SameParameter"] << "SameParameter.Tolerance3d";
773 //=================================================================================
774 // function : getParameters
776 //=================================================================================
777 GEOM::string_array* RepairGUI_ShapeProcessDlg::getParameters( const GEOM::string_array& theOperators )
779 GEOM::string_array_var aParams = new GEOM::string_array();
782 // calculate the length of parameters
783 for ( i = 0, j = 0; i < theOperators.length(); i++ )
784 j+= myValMap[QString((const char*)theOperators[i])].size();
786 // set the new length of paremeters
787 aParams->length( j );
789 // fill the parameters
790 for ( i = 0, j = 0; i < theOperators.length(); i++ )
792 QStringList aValLst = myValMap[QString( (const char*)theOperators[i] )];
793 for ( QStringList::Iterator it = aValLst.begin(); it != aValLst.end(); ++it )
794 aParams[j++] = CORBA::string_dup( (*it).latin1() );
797 return aParams._retn();
801 //=================================================================================
802 // function : getValues
804 //=================================================================================
805 GEOM::string_array* RepairGUI_ShapeProcessDlg::getValues( const GEOM::string_array& theParams )
807 GEOM::string_array_var aValues = new GEOM::string_array();
808 aValues->length( theParams.length() );
810 for ( int i = 0; i < theParams.length(); i++ )
812 QWidget* aCtrl = getControl( (const char*)theParams[i] );
814 aValues[i] = get_convert( (const char*)theParams[i], getValue( aCtrl ) );
817 return aValues._retn();
820 //=================================================================================
821 // function : initSelection
822 // purpose : set selection of ALL shape types except vertexes
823 //=================================================================================
824 void RepairGUI_ShapeProcessDlg::initSelection()
826 TColStd_MapOfInteger aTypes;
827 aTypes.Add( GEOM_COMPOUND );
828 aTypes.Add( GEOM_SOLID );
829 aTypes.Add( GEOM_SHELL );
830 aTypes.Add( GEOM_FACE );
831 aTypes.Add( GEOM_WIRE );
832 aTypes.Add( GEOM_EDGE );
833 globalSelection( aTypes );
836 //=================================================================================
837 // function : advOptionToggled
838 // purpose : this slot is used to warn the user about possible consequences
839 // of enabling some advanced options
840 //=================================================================================
841 void RepairGUI_ShapeProcessDlg::advOptionToggled( bool on )
843 QButton* btn = (QButton*)sender();
844 if ( on && btn->isToggleButton() &&
845 QMessageBox::warning( SUIT_Session::session()->activeApplication()->desktop(), tr( "GEOM_WRN_WARNING" ), tr( "TIME_CONSUMING" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )