Salome HOME
Fix compilation error (conflict of OK name between OCCT Plate_Plate.hxx and GEOM...
[modules/geom.git] / src / OperationGUI / OperationGUI_PartitionDlg.cxx
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : OperationGUI_PartitionDlg.cxx
25 // Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
26
27 #include "OperationGUI_PartitionDlg.h"
28
29 #include <DlgRef.h>
30 #include <GeometryGUI.h>
31 #include <GEOMBase.h>
32
33 #include <GEOMImpl_Types.hxx>
34
35 #include <SUIT_Desktop.h>
36 #include <SUIT_Session.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SUIT_MessageBox.h>
39 #include <SalomeApp_Application.h>
40 #include <LightApp_SelectionMgr.h>
41
42 #include <TopoDS_Iterator.hxx>
43 #include <TopoDS_Shape.hxx>
44
45 // VSR 22/08/2012: issue 0021787: remove "Preview" button from BOP and Partition operations
46 // Comment next line to enable preview in Partition dialog box
47 #define NO_PREVIEW
48
49 #define DEFAULT_FUZZY_VALUE   1e-5
50
51
52 //=================================================================================
53 // class    : OperationGUI_PartitionDlg()
54 // purpose  : Constructs a OperationGUI_PartitionDlg which is a child of 'parent', with the
55 //            name 'name' and widget flags set to 'f'.
56 //            The dialog will by default be modeless, unless you set 'modal' to
57 //            TRUE to construct a modal dialog.
58 //=================================================================================
59 OperationGUI_PartitionDlg::OperationGUI_PartitionDlg( GeometryGUI* theGeometryGUI, QWidget* parent )
60   : GEOMBase_Skeleton( theGeometryGUI, parent, false )
61 {
62   SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr();
63   QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PARTITION" ) ) );
64   QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_PARTITION_PLANE" ) ) );
65   QPixmap image2( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
66
67   setWindowTitle( tr( "GEOM_PARTITION_TITLE" ) );
68
69   /***************************************************************/
70   mainFrame()->GroupConstructors->setTitle( tr( "GEOM_PARTITION" ) );
71   mainFrame()->RadioButton1->setIcon( image0 );
72   mainFrame()->RadioButton2->setIcon( image1 );
73   mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
74   mainFrame()->RadioButton2->close();
75   mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
76   mainFrame()->RadioButton3->close();
77
78   // Full partition (contains half-space partition)
79   GroupPoints = new DlgRef_2Sel1List2Check( centralWidget() );
80   GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) );
81   GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
82   GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) );
83   GroupPoints->TextLabel3->setText( tr( "GEOM_RECONSTRUCTION_LIMIT" ) );
84   GroupPoints->PushButton1->setIcon( image2 );
85   GroupPoints->PushButton2->setIcon( image2 );
86   GroupPoints->LineEdit1->setReadOnly( true );
87   GroupPoints->LineEdit2->setReadOnly( true );
88   GroupPoints->LineEdit1->setEnabled( true );
89   GroupPoints->LineEdit2->setEnabled( false );
90   GroupPoints->CheckButton1->setText( tr( "GEOM_KEEP_NONLIMIT_SHAPES" ) );
91   GroupPoints->CheckButton2->setText( tr( "GEOM_NO_SELF_INTERSECTION" ) );
92
93   mySelfInte = new QCheckBox(GroupPoints->GroupBox1);
94   mySelfInte->setText(tr("GEOM_CHECK_SELF_INTERSECTIONS"));
95   GroupPoints->gridLayout1->addWidget(mySelfInte, 5, 0, 1, 3);
96
97   // Add all "fuzzy parameter" related widgets
98   myFuzzyChk = new QCheckBox(GroupPoints->GroupBox1);
99   myFuzzyChk->setText(tr("GEOM_USE_FUZZY_PARAMETER"));
100   GroupPoints->gridLayout1->addWidget(myFuzzyChk, 6, 0, 1, 3);
101
102   myFuzzyLbl = new QLabel(GroupPoints->GroupBox1);
103   myFuzzyLbl->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
104   myFuzzyLbl->setText(tr("GEOM_FUZZY_PARAMETER"));
105   GroupPoints->gridLayout1->addWidget(myFuzzyLbl, 7, 0, 1, 2);
106
107   myFuzzyEdt = new SalomeApp_DoubleSpinBox(GroupPoints->GroupBox1);
108   initSpinBox( myFuzzyEdt, 1.e-7, 10.0, DEFAULT_FUZZY_VALUE, "length_tol_precision" );
109   myFuzzyEdt->setValue(DEFAULT_FUZZY_VALUE);
110   GroupPoints->gridLayout1->addWidget(myFuzzyEdt, 7, 2);
111
112   QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
113   layout->setMargin( 0 ); layout->setSpacing( 6 );
114   layout->addWidget( GroupPoints );
115
116   /***************************************************************/
117
118   setHelpFileName( "partition_page.html" );
119
120 #ifdef NO_PREVIEW
121   mainFrame()->CheckBoxPreview->setChecked( false );
122   mainFrame()->CheckBoxPreview->hide();
123 #endif
124   Init();
125 }
126
127
128 //=================================================================================
129 // function : ~OperationGUI_PartitionDlg()
130 // purpose  : Destroys the object and frees any allocated resources
131 //=================================================================================
132 OperationGUI_PartitionDlg::~OperationGUI_PartitionDlg()
133 {
134   // no need to delete child widgets, Qt does it all for us
135 }
136
137 void OperationGUI_PartitionDlg::SetListMaterials( GEOM::ListOfLong ListMaterials )
138 {
139   myListMaterials = ListMaterials;
140 }
141
142 GEOM::ListOfLong OperationGUI_PartitionDlg::GetListMaterials()
143 {
144   return myListMaterials;
145 }
146
147 //=================================================================================
148 // function : Init()
149 // purpose  :
150 //=================================================================================
151 void OperationGUI_PartitionDlg::Init()
152 {
153   /* type for sub-shape selection */
154   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SOLID" ) );
155   GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::SOLID);
156   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_SHELL" ) );
157   GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::SHELL);
158   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_FACE" ) );
159   GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::FACE);
160   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_WIRE" ) );
161   GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::WIRE);
162   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_EDGE" ) );
163   GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::EDGE);
164   GroupPoints->ComboBox1->addItem( tr( "GEOM_RECONSTRUCTION_LIMIT_VERTEX" ) );
165   GroupPoints->ComboBox1->setItemData(GroupPoints->ComboBox1->count()-1, GEOM::VERTEX);
166   GroupPoints->CheckButton1->setChecked( false );
167   mySelfInte->setChecked(false);
168
169   // Do not use Fuzzy parameter by default
170   myFuzzyChk->setChecked(false);
171   myFuzzyLbl->setEnabled(false);
172   myFuzzyEdt->setEnabled(false);
173
174   mainFrame()->GroupBoxPublish->show();
175
176   /* signals and slots connections */
177   connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
178   connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
179
180   connect( this, SIGNAL( constructorsClicked( int ) ), this, SLOT( ConstructorsClicked( int ) ) );
181
182   connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
183   connect( GroupPoints->PushButton2, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
184
185   connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
186   connect( GroupPoints->LineEdit2, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
187
188   connect( GroupPoints->ComboBox1, SIGNAL( activated( int ) ), this, SLOT( ComboTextChanged() ) );
189
190   connect( myGeomGUI->getApp()->selectionMgr(),
191            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
192
193   connect( GroupPoints->CheckButton1, SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
194   connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
195   connect( GroupPoints->CheckButton2, SIGNAL(toggled(bool)), mySelfInte, SLOT(setEnabled(bool)) );
196   connect( mySelfInte,                SIGNAL(toggled(bool)), this, SLOT(processPreview()) );
197
198   connect( myFuzzyChk, SIGNAL(stateChanged(int)), this, SLOT(UseFuzzyChanged(int)));
199
200   mySelfInte->setEnabled(GroupPoints->CheckButton2->isChecked());
201   initName( tr( "GEOM_PARTITION" ) );
202
203   ConstructorsClicked( 0 );
204   GroupPoints->PushButton1->click();
205 }
206
207
208 //=================================================================================
209 // function : ConstructorsClicked()
210 // purpose  : Radio button management
211 //=================================================================================
212 void OperationGUI_PartitionDlg::ConstructorsClicked( int constructorId )
213 {
214   disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
215   globalSelection();
216
217   switch ( constructorId ) {
218   case 0: /*Full partition */
219     GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION" ) );
220     GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
221     GroupPoints->TextLabel2->setText( tr( "GEOM_TOOL_OBJECTS" ) );
222     GroupPoints->TextLabel3->show();
223     GroupPoints->ComboBox1->show();
224     GroupPoints->ComboBox1->setCurrentIndex( 0 );
225     GroupPoints->CheckButton1->show();
226     GroupPoints->CheckButton2->show();
227     mySelfInte->show();
228     GroupPoints->PushButton1->setDown( true );
229     GroupPoints->PushButton2->setDown( false );
230     GroupPoints->LineEdit1->setEnabled(true);
231     GroupPoints->LineEdit2->setEnabled(false);
232     break;
233   case 1: /*Half-space partition */
234     GroupPoints->GroupBox1->setTitle( tr( "GEOM_PARTITION_HALFSPACE" ) );
235     GroupPoints->TextLabel3->hide();
236     GroupPoints->ComboBox1->hide();
237     GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECT" ) );
238     GroupPoints->TextLabel2->setText( tr( "GEOM_PLANE" ) );
239     GroupPoints->CheckButton1->hide();
240     GroupPoints->CheckButton2->hide();
241     mySelfInte->hide();
242     GroupPoints->PushButton1->setDown( true );
243     GroupPoints->LineEdit1->setEnabled(true);
244     break;
245   }
246
247   myEditCurrentArgument = GroupPoints->LineEdit1;
248   GroupPoints->LineEdit1->clear();
249   GroupPoints->LineEdit2->clear();
250
251   qApp->processEvents();
252   updateGeometry();
253   resize( minimumSizeHint() );
254
255   myEditCurrentArgument->setFocus();
256   connect( myGeomGUI->getApp()->selectionMgr(),
257            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
258   SelectionIntoArgument();
259 }
260
261
262 //=================================================================================
263 // function : ClickOnOk()
264 // purpose  :
265 //=================================================================================
266 void OperationGUI_PartitionDlg::ClickOnOk()
267 {
268   setIsApplyAndClose( true );
269   if ( ClickOnApply() )
270     ClickOnCancel();
271 }
272
273
274 //=================================================================================
275 // function : ClickOnApply()
276 // purpose  :
277 //=================================================================================
278 bool OperationGUI_PartitionDlg::ClickOnApply()
279 {
280   if ( !onAccept() )
281     return false;
282
283   initName();
284   //  0020854: EDF 1398 GEOM: Ergonomy of Partition GUI window
285   //  ConstructorsClicked( getConstructorId() );
286   return true;
287 }
288
289
290 //=================================================================================
291 // function : UseFuzzyChanged()
292 // purpose  : This slot is called whenever the status of CheckButton3 has changed
293 //=================================================================================
294 void OperationGUI_PartitionDlg::UseFuzzyChanged(int state)
295 {
296   QCheckBox* send = (QCheckBox*)sender();
297
298   if (send == myFuzzyChk) {
299     bool isChecked = (state != Qt::Unchecked);
300     myFuzzyLbl->setEnabled(isChecked);
301     myFuzzyEdt->setEnabled(isChecked);
302   }
303 }
304
305
306 //=================================================================================
307 // function : SelectionIntoArgument()
308 // purpose  : Called when selection as changed or other case
309 //=================================================================================
310 void OperationGUI_PartitionDlg::SelectionIntoArgument()
311 {
312   myEditCurrentArgument->setText( "" );
313   QString aString = "";
314
315   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
316   SALOME_ListIO aSelList;
317   aSelMgr->selectedObjects(aSelList);
318
319   int nbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aString, true);
320
321   if ( getConstructorId() == 1 ) {
322     // for half-selection, only one shape can be selected as an object
323     // and only one plane as a tool
324     if ( nbSel != 1 ) {
325       if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
326         myListShapes.length( 0 );
327         // myListMaterials.length( 0 ); // obsolete
328         return;
329       }
330       else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
331         myListTools.length( 0 );
332         return;
333       }
334     }
335   }
336   else {
337     if ( nbSel < 1 ) {
338       if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
339         myListShapes.length( 0 );
340         //myListMaterials.length( 0 ); // obsolete
341         return;
342       }
343       else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
344         myListTools.length( 0 );
345         return;
346       }
347     }
348   }
349
350   if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
351     GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListShapes, true);
352     //myListMaterials.length( 0 ); // obsolete
353
354     GEOM::shape_type type = GEOM::SHAPE;
355     for (int i = 0; i < (int)myListShapes.length(); i++)
356       type = qMin( type, myListShapes[i]->GetMaxShapeType() );
357     int idx = qMax( 0, GroupPoints->ComboBox1->findData( type ) );
358     GroupPoints->ComboBox1->setCurrentIndex( idx );
359
360     if ( !myListShapes.length() )
361       return;
362   }
363   else if ( myEditCurrentArgument == GroupPoints->LineEdit2 ) {
364     GEOMBase::ConvertListOfIOInListOfGO(aSelList, myListTools, true);
365     if ( !myListTools.length() )
366       return;
367     else if ( myListTools.length() == 1 && getConstructorId() == 1 ) {
368       GEOM::GEOM_IMeasureOperations_var mOp = getGeomEngine()->GetIMeasureOperations();
369       GEOM::ListOfLong_var   intList;
370       GEOM::ListOfDouble_var dblList;
371       GEOM::GEOM_IKindOfShape::shape_kind kind = mOp->KindOfShape( myListTools[0].in(), intList.out(), dblList.out() );
372       mOp->UnRegister();
373       if ( kind < GEOM::GEOM_IKindOfShape::DISK_CIRCLE || kind > GEOM::GEOM_IKindOfShape::PLANAR ) {
374         myListTools.length( 0 );
375         return;
376       }
377     }
378   }
379
380   myEditCurrentArgument->setText( aString );
381   processPreview();
382 }
383
384
385 //=================================================================================
386 // function : SetEditCurrentArgument()
387 // purpose  :
388 //=================================================================================
389 void OperationGUI_PartitionDlg::SetEditCurrentArgument()
390 {
391   QPushButton* send = (QPushButton*)sender();
392
393   if ( send == GroupPoints->PushButton1 ) {
394     myEditCurrentArgument = GroupPoints->LineEdit1;
395     GroupPoints->PushButton2->setDown(false);
396     GroupPoints->LineEdit1->setEnabled(true);
397     GroupPoints->LineEdit2->setEnabled(false);
398   }
399   else if ( send == GroupPoints->PushButton2 ) {
400     myGeomGUI->getApp()->selectionMgr()->clearSelected(); //clear prewious selection
401     myEditCurrentArgument = GroupPoints->LineEdit2;
402     GroupPoints->PushButton1->setDown(false);
403     GroupPoints->LineEdit1->setEnabled(false);
404     GroupPoints->LineEdit2->setEnabled(true);
405     if ( getConstructorId() == 1 )
406       globalSelection( GEOM_PLANE  );
407   }
408
409   globalSelection( GEOM_ALLSHAPES );
410
411   myEditCurrentArgument->setFocus();
412   SelectionIntoArgument();
413   send->setDown(true);
414   processPreview();
415 }
416
417
418 //=================================================================================
419 // function : LineEditReturnPressed()
420 // purpose  :
421 //=================================================================================
422 void OperationGUI_PartitionDlg::LineEditReturnPressed()
423 {
424   QLineEdit* send = (QLineEdit*)sender();
425
426   if ( send == GroupPoints->LineEdit1 ||
427        send == GroupPoints->LineEdit2 ) {
428       myEditCurrentArgument = send;
429       GEOMBase_Skeleton::LineEditReturnPressed();
430   }
431 }
432
433
434 //=================================================================================
435 // function : ActivateThisDialog()
436 // purpose  :
437 //=================================================================================
438 void OperationGUI_PartitionDlg::ActivateThisDialog()
439 {
440   GEOMBase_Skeleton::ActivateThisDialog();
441   connect( myGeomGUI->getApp()->selectionMgr(),
442            SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
443
444   ConstructorsClicked( getConstructorId() );
445   processPreview();
446 }
447
448
449 //=================================================================================
450 // function : enterEvent()
451 // purpose  :
452 //=================================================================================
453 void OperationGUI_PartitionDlg::enterEvent( QEvent* )
454 {
455   if ( !mainFrame()->GroupConstructors->isEnabled() )
456     this->ActivateThisDialog();
457 }
458
459
460 //=================================================================================
461 // function : createOperation
462 // purpose  :
463 //=================================================================================
464 GEOM::GEOM_IOperations_ptr OperationGUI_PartitionDlg::createOperation()
465 {
466   return getGeomEngine()->GetIBooleanOperations();
467 }
468
469
470 //=================================================================================
471 // function : isValid
472 // purpose  :
473 //=================================================================================
474 bool OperationGUI_PartitionDlg::isValid (QString& )
475 {
476   return (getConstructorId() == 0 ?
477           myListShapes.length() :
478           myListShapes.length() && myListTools.length());
479 }
480
481
482 //=================================================================================
483 // function : execute
484 // purpose  :
485 //=================================================================================
486 bool OperationGUI_PartitionDlg::execute (ObjectList& objects)
487 {
488   bool res = false;
489   GEOM::GEOM_Object_var anObj;
490
491   GEOM::GEOM_IBooleanOperations_var anOper = GEOM::GEOM_IBooleanOperations::_narrow(getOperation());
492
493   bool useFuzzyParam = myFuzzyChk->isChecked();
494   double aFuzzyParam = (useFuzzyParam ? myFuzzyEdt->value() : -1.0);
495
496   switch ( getConstructorId() ) {
497   case 0:
498     {
499       bool isDetectSelfInte    = mySelfInte->isChecked();
500       int aLimit               = GetLimit();
501       int aKeepNonlimitShapes  = GroupPoints->CheckButton1->isChecked();
502       bool aNoSelfIntersection = GroupPoints->CheckButton2->isChecked();
503
504       anObj = aNoSelfIntersection ?
505         anOper->MakePartitionNonSelfIntersectedShapeWithFuzzy(myListShapes, myListTools,
506                                                               myListKeepInside, myListRemoveInside,
507                                                               aLimit, false, myListMaterials, aKeepNonlimitShapes,
508                                                               isDetectSelfInte, aFuzzyParam) :
509         anOper->MakePartitionWithFuzzy(myListShapes, myListTools,
510                                        myListKeepInside, myListRemoveInside,
511                                        aLimit, false, myListMaterials, aKeepNonlimitShapes, aFuzzyParam);
512       res = true;
513     }
514     break;
515   case 1:
516     {
517       anObj = anOper->MakeHalfPartitionWithFuzzy(myListShapes[0].in(), myListTools[0].in(), aFuzzyParam);
518       res = true;
519     }
520     break;
521   }
522
523   if ( !anObj->_is_nil() ) {
524     TopoDS_Shape aShape;
525     GEOMBase::GetShape( anObj, aShape, TopAbs_SHAPE );
526     TopoDS_Iterator It( aShape, Standard_True, Standard_True );
527     int nbSubshapes = 0;
528     for (; It.More(); It.Next())
529       nbSubshapes++;
530
531     if ( nbSubshapes )
532       objects.push_back( anObj._retn() );
533     else
534       SUIT_MessageBox::warning( this,
535                                 QObject::tr( "GEOM_ERROR" ),
536                                 QObject::tr( "GEOM_WRN_PARTITION_RESULT_EMPTY" ) );
537   }
538
539   return res;
540 }
541
542 //=================================================================================
543 // function : restoreSubShapes
544 // purpose  :
545 //=================================================================================
546 void OperationGUI_PartitionDlg::restoreSubShapes( SALOMEDS::SObject_ptr theSObject )
547 {
548   if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
549     // empty list of arguments means that all arguments should be restored
550     getGeomEngine()->RestoreSubShapesSO( theSObject, GEOM::ListOfGO(),
551                                          /*theFindMethod=*/GEOM::FSM_GetInPlaceByHistory,
552                                          /*theInheritFirstArg=*/myListShapes.length() == 1 && myListTools.length() == 0,
553                                          mainFrame()->CheckBoxAddPrefix->isChecked() ); // ? false
554   }
555 }
556
557 //=======================================================================
558 //function : ComboTextChanged
559 //purpose  :
560 //=======================================================================
561 void OperationGUI_PartitionDlg::ComboTextChanged()
562 {
563   processPreview();
564 }
565
566 //=================================================================================
567 // function : GetLimit()
568 // purpose  :
569 //=================================================================================
570 int OperationGUI_PartitionDlg::GetLimit() const
571 {
572   int aLimit = GroupPoints->ComboBox1->currentIndex();
573
574   switch ( aLimit ) {
575   case 0:  aLimit = GEOM::SOLID ; break;
576   case 1:  aLimit = GEOM::SHELL ; break;
577   case 2:  aLimit = GEOM::FACE  ; break;
578   case 3:  aLimit = GEOM::WIRE  ; break;
579   case 4:  aLimit = GEOM::EDGE  ; break;
580   case 5:  aLimit = GEOM::VERTEX; break;
581   default: aLimit = GEOM::SHAPE ;
582   }
583
584   return aLimit;
585 }
586
587 //=================================================================================
588 // function : getSourceObjects
589 // purpose  : virtual method to get source objects
590 //=================================================================================
591 QList<GEOM::GeomObjPtr> OperationGUI_PartitionDlg::getSourceObjects()
592 {
593   QList<GEOM::GeomObjPtr> res;
594   for (int i = 0; i < (int)myListShapes.length(); i++) {
595     GEOM::GeomObjPtr aGeomObjPtr(myListShapes[i]);
596     res << aGeomObjPtr;
597   }
598   for (int i = 0; i < (int)myListTools.length(); i++) {
599     GEOM::GeomObjPtr aGeomObjPtr(myListTools[i]);
600     res << aGeomObjPtr;
601   }
602   for (int i = 0; i < (int)myListRemoveInside.length(); i++) {
603     GEOM::GeomObjPtr aGeomObjPtr(myListRemoveInside[i]);
604     res << aGeomObjPtr;
605   }
606   for (int i = 0; i < (int)myListKeepInside.length(); i++) {
607     GEOM::GeomObjPtr aGeomObjPtr(myListKeepInside[i]);
608     res << aGeomObjPtr;
609   }
610   return res;
611 }