Salome HOME
Update copyrights
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchCreator.cpp
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "PartSet_WidgetSketchCreator.h"
21 #include "PartSet_Module.h"
22 #include "PartSet_WidgetSketchLabel.h"
23 #include "PartSet_PreviewPlanes.h"
24
25 #include <Config_Keywords.h>
26
27 #include <XGUI_ModuleConnector.h>
28 #include <XGUI_Workshop.h>
29 #include <XGUI_Displayer.h>
30 #include <XGUI_SelectionMgr.h>
31 #include <XGUI_OperationMgr.h>
32 #include <XGUI_PropertyPanel.h>
33 #include <XGUI_Tools.h>
34 #include <XGUI_ViewerProxy.h>
35
36 #include <GeomAPI_Face.h>
37
38 #include <Events_InfoMessage.h>
39
40 #include <ModelAPI_Session.h>
41 #include <ModelAPI_ResultBody.h>
42 #include <ModelAPI_AttributeSelection.h>
43 #include <ModelAPI_AttributeSelectionList.h>
44 #include <ModelAPI_Validator.h>
45 #include <ModelAPI_Events.h>
46 #include <ModelAPI_ResultConstruction.h>
47
48 #include <SketchPlugin_SketchEntity.h>
49 #include <FeaturesPlugin_CompositeBoolean.h>
50
51 #include <ModuleBase_Tools.h>
52 #include <ModuleBase_Operation.h>
53 #include <ModuleBase_IPropertyPanel.h>
54 #include <ModuleBase_OperationFeature.h>
55 #include <ModuleBase_ViewerPrs.h>
56
57 #include <Config_WidgetAPI.h>
58
59 #include <Events_Loop.h>
60
61 #include <QLabel>
62 #include <QLineEdit>
63 #include <QDoubleValidator>
64 //#include <QFormLayout>
65 #include <QVBoxLayout>
66 #include <QMessageBox>
67 #include <QMainWindow>
68
69 #define DEBUG_UNDO_INVALID_SKETCH
70
71 PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent,
72                                                          PartSet_Module* theModule,
73                                                          const Config_WidgetAPI* theData)
74 : ModuleBase_WidgetSelector(theParent, theModule->workshop(), theData),
75   myModule(theModule), myIsCustomAttribute(false)
76 {
77   myAttributeListID = theData->getProperty("attribute_list_id");
78
79   //QFormLayout* aLayout = new QFormLayout(this);
80   QVBoxLayout* aLayout = new QVBoxLayout(this);
81   ModuleBase_Tools::zeroMargins(aLayout);
82
83   ModuleBase_Tools::adjustMargins(aLayout);
84
85   QString aLabelText = QString::fromStdString(theData->widgetLabel());
86   QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
87
88   // Size of the View control
89   mySizeOfViewWidget = new QWidget(this);
90   QHBoxLayout* aSizeLayout = new QHBoxLayout(mySizeOfViewWidget);
91   aSizeLayout->addWidget(new QLabel("Size of the view", mySizeOfViewWidget));
92   mySizeOfView = new QLineEdit(mySizeOfViewWidget);
93
94   QDoubleValidator* aValidator = new QDoubleValidator(0, DBL_MAX, 12, mySizeOfView);
95   aValidator->setLocale(ModuleBase_Tools::doubleLocale());
96   aValidator->setNotation(QDoubleValidator::StandardNotation);
97   mySizeOfView->setValidator(aValidator);
98   aSizeLayout->addWidget(mySizeOfView);
99
100   myLabel = new QLabel(aLabelText, this);
101   myLabel->setWordWrap(true);
102
103   aLayout->addWidget(mySizeOfViewWidget);
104   aLayout->addWidget(myLabel);
105   aLayout->addStretch(1);
106
107   std::string aTypes = theData->getProperty("shape_types");
108   myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts);
109
110   myPreviewPlanes = new PartSet_PreviewPlanes();
111 }
112
113 PartSet_WidgetSketchCreator::~PartSet_WidgetSketchCreator()
114 {
115   // we need to deactivate here in order to hide preview planes if the selection mode is
116   // active
117   deactivate();
118 }
119
120 QList<QWidget*> PartSet_WidgetSketchCreator::getControls() const
121 {
122   QList<QWidget*> aControls;
123   aControls.append(myLabel);
124   return aControls;
125 }
126
127 bool PartSet_WidgetSketchCreator::restoreValueCustom()
128 {
129   return true;
130 }
131
132 bool PartSet_WidgetSketchCreator::storeValueCustom()
133 {
134   return true;
135 }
136
137 AttributePtr PartSet_WidgetSketchCreator::attribute() const
138 {
139   AttributePtr anAttribute;
140   if (myIsCustomAttribute)
141     anAttribute = myFeature->attribute(myAttributeListID);
142   else
143     anAttribute = ModuleBase_WidgetSelector::attribute();
144
145   return anAttribute;
146 }
147
148 //********************************************************************
149 void PartSet_WidgetSketchCreator::openExtrusionTransaction()
150 {
151   SessionPtr aMgr = ModelAPI_Session::get();
152   bool aIsOp = aMgr->isOperation();
153   if (!aIsOp) {
154     const static std::string aNestedOpID("Parameters modification");
155     aMgr->startOperation(aNestedOpID, true);
156   }
157 }
158
159 //********************************************************************
160 bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrsPtr& theValue)
161 {
162   bool aValid = false;
163   if (myIsCustomAttribute) {
164     // check only suiting of the value to custom attribute (myAttributeListID)
165     // do not cash of validation to avoid using states, stored for XML attribute
166     // there is an alternative is to call clearValidatedCash() in setSelection()
167     aValid = isValidSelectionForAttribute(theValue, attribute());
168   }
169   else { /// if the validated attribute is already custom
170     if (getValidState(theValue, aValid)) {
171       return aValid;
172     }
173     aValid = isValidSelectionCustom(theValue);
174     if (!aValid)
175       // check selection to create new sketh (XML current attribute)
176       aValid = isValidSelectionForAttribute(theValue, attribute());
177     if (!aValid) {
178       // check selection to fill list attribute (myAttributeListID)
179       bool isCustomAttribute = myIsCustomAttribute;
180       myIsCustomAttribute = true;
181       aValid = isValidSelectionForAttribute(theValue, attribute());
182       myIsCustomAttribute = isCustomAttribute;
183     }
184   }
185   storeValidState(theValue, aValid);
186   return aValid;
187 }
188
189 //********************************************************************
190 bool PartSet_WidgetSketchCreator::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& theValue)
191 {
192   return PartSet_WidgetSketchLabel::canFillSketch(theValue);
193 }
194
195 void PartSet_WidgetSketchCreator::activateSelectionControl()
196 {
197   // reset previously set size of view needed on restart extrusion after Sketch
198   if (myModule->sketchMgr()->previewSketchPlane()->isUseSizeOfView())
199     myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(0, false);
200
201   // we need to call activate here as the widget has no focus accepted controls
202   // if these controls are added here, activate will happens automatically after focusIn()
203   XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
204   XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
205   aPanel->activateWidget(this, false);
206 }
207
208 void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl)
209 {
210   // hide current widget, activate the next widget
211   XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
212   XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
213   const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
214   foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
215     if (theSelectionControl) { // hide other controls
216       if (aWidget != this)
217         aWidget->setVisible(false);
218     }
219     else { // hide current control
220       if (aWidget == this)
221         aWidget->setVisible(false);
222       else {
223         aWidget->setVisible(true);
224         if (aWidget->attributeID() == myAttributeListID)
225           setEnabledModelWidget(aWidget, !hasSubObjects());
226       }
227     }
228   }
229
230   if (theSelectionControl) {
231     bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop);
232     bool aSketchIsVisualized = myPreviewPlanes->hasVisualizedSketch(myWorkshop);
233     if (!aBodyIsVisualized && !aSketchIsVisualized) {
234       // We have to select a plane before any operation
235       myPreviewPlanes->showPreviewPlanes(myWorkshop);
236       mySizeOfViewWidget->setVisible(true);
237     }
238     else {
239       mySizeOfViewWidget->setVisible(false);
240     }
241
242   } else {
243     bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
244     myPreviewPlanes->erasePreviewPlanes(myWorkshop);
245     if (aHidePreview)
246       aWorkshop->viewer()->update();
247   }
248 }
249
250 QIntList PartSet_WidgetSketchCreator::shapeTypes() const
251 {
252   QIntList aShapeTypes;
253   foreach(QString aType, myShapeTypes) {
254     aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
255   }
256   return aShapeTypes;
257 }
258
259 void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
260 {
261   ModuleBase_ModelWidget::setEditingMode(isEditing);
262   if (isEditing) {
263     setVisibleSelectionControl(false);
264
265     ModuleBase_ModelWidget* anAttributeListWidget = 0;
266     XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
267     XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
268     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
269     foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
270       if (aWidget->attributeID() == myAttributeListID) {
271         anAttributeListWidget = aWidget;
272         break;
273       }
274     }
275     if (anAttributeListWidget)
276       setEnabledModelWidget(anAttributeListWidget, !hasSubObjects());
277   }
278 }
279
280 bool PartSet_WidgetSketchCreator::isSelectionMode() const
281 {
282   AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
283   bool aHasValueInList = anAttrList.get() && anAttrList->size() > 0;
284
285   return !aHasValueInList;
286 }
287
288 bool PartSet_WidgetSketchCreator::hasSubObjects() const
289 {
290   bool aHasSubObjects = false;
291
292   bool aCanSetFocus = true;
293   CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
294   if (aComposite.get())
295     aHasSubObjects = aComposite->numberOfSubs() > 0;
296   return aHasSubObjects;
297 }
298
299 bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
300                                                const bool theToValidate)
301 {
302   bool aDone = false;
303   if (!startSketchOperation(theValues)) {
304     myIsCustomAttribute = true;
305     QList<ModuleBase_ViewerPrsPtr>::const_iterator
306       anIt = theValues.begin(), aLast = theValues.end();
307     bool aProcessed = false;
308     for (; anIt != aLast; anIt++) {
309       ModuleBase_ViewerPrsPtr aValue = *anIt;
310       if (!theToValidate || isValidInFilters(aValue))
311         aProcessed = setSelectionCustom(aValue) || aProcessed;
312     }
313     myIsCustomAttribute = false;
314     aDone = aProcessed;
315     if (aProcessed) {
316       emit valuesChanged();
317       updateObject(myFeature);
318       setVisibleSelectionControl(false);
319       // manually deactivation because the widget was
320       // not activated as has no focus acceptin controls
321       deactivate();
322       emit focusOutWidget(this);
323     }
324   }
325   return aDone;
326 }
327
328 //********************************************************************
329 bool PartSet_WidgetSketchCreator::processSelection()
330 {
331   QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
332   bool isDone = setSelection(aSelected, true/*false*/);
333
334   return isDone;
335 }
336
337 //********************************************************************
338 void PartSet_WidgetSketchCreator::updateOnSelectionChanged(const bool theDone)
339 {
340 }
341
342 bool PartSet_WidgetSketchCreator::startSketchOperation(
343                               const QList<ModuleBase_ViewerPrsPtr>& theValues)
344 {
345   bool aSketchStarted = false;
346
347   if (theValues.size() != 1)
348     return aSketchStarted;
349
350   ModuleBase_ViewerPrsPtr aValue = theValues.front();
351   if (!aValue.get() || !PartSet_WidgetSketchLabel::canFillSketch(aValue))
352     return aSketchStarted;
353
354   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
355   /// sketch should not started by object(face) selected as global. If Local face is selected,
356   /// sketch is started
357   if (aResult.get() && aValue->shape().get() && aResult->shape()->isEqual(aValue->shape())) {
358     ResultConstructionPtr aConstruction =
359       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
360     if (!aConstruction.get() || !aConstruction->isInfinite())
361       return aSketchStarted;
362   }
363   aSketchStarted = true;
364   // Set View size if a plane is selected
365   if (myPreviewPlanes->isPreviewDisplayed() &&
366       myPreviewPlanes->isPreviewShape(aValue->shape())) {
367     // set default plane size
368     bool isSetSizeOfView = false;
369     double aSizeOfView = 0;
370     QString aSizeOfViewStr = mySizeOfView->text();
371     if (!aSizeOfViewStr.isEmpty()) {
372       aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
373       if (isSetSizeOfView && aSizeOfView <= 0) {
374         isSetSizeOfView = false;
375       }
376     }
377     if (isSetSizeOfView)
378       myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
379   }
380   // manually deactivation because the widget was not activated as has no focus acceptin controls
381   deactivate();
382   bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
383   myPreviewPlanes->erasePreviewPlanes(myWorkshop);
384
385   // Launch Sketch operation
386   CompositeFeaturePtr aCompFeature =
387     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
388
389   // start edit operation for the sketch
390   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
391                                                             (myModule->createOperation("Sketch"));
392   QList<ModuleBase_ViewerPrsPtr> aValues;
393   aValues.push_back(aValue);
394   aFOperation->setPreselection(aValues);
395
396   myWorkshop->processLaunchOperation(aFOperation);
397
398   return aSketchStarted;
399 }
400
401 bool PartSet_WidgetSketchCreator::focusTo()
402 {
403   // this method is called only in creation mode. In Edition mode this widget is hidden
404   if (isSelectionMode() && !hasSubObjects()) {
405     setVisibleSelectionControl(true);
406     activateSelectionControl();
407     openExtrusionTransaction();
408     return true;
409   }
410   else
411     connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)),
412             SLOT(onResumed(ModuleBase_Operation*)));
413
414   return true;
415 }
416
417 void PartSet_WidgetSketchCreator::deactivate()
418 {
419   ModuleBase_WidgetSelector::deactivate();
420
421   bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
422   myPreviewPlanes->erasePreviewPlanes(myWorkshop);
423   if (aHidePreview)
424     XGUI_Tools::workshop(myWorkshop)->viewer()->update();
425
426 }
427
428 void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
429 {
430   SessionPtr aMgr = ModelAPI_Session::get();
431   bool aIsOp = aMgr->isOperation();
432   if (aIsOp) {
433     // in current implementation, all transactions are closed when resume happens
434     // so, this is a wrong case, which is not checked.
435     // To provide it, make correction in later rows about abort/undo transactions
436     return;
437   }
438   // Set visible only selection control
439   setVisibleSelectionControl(true);
440
441   // Validate the created sketch. If it is valid, it is set into the composite feature selection
442   // list, otherwise it is removed
443   CompositeFeaturePtr aCompFeature =
444     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
445   AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
446   if (aCompFeature->numberOfSubs() > 0) {
447     // set the sub feature to attribute selection list and check whether sketch is valid
448     SessionPtr aMgr = ModelAPI_Session::get();
449     const static std::string aNestedOpID("Set Sketch result into Selection list");
450     aMgr->startOperation(aNestedOpID, false); // false to not attach to Extrusion operation
451     setSketchObjectToList(aCompFeature, anAttrList);
452     aMgr->finishOperation();
453
454     if (!validateSelectionList()) {
455 #ifdef DEBUG_UNDO_INVALID_SKETCH
456       aMgr->undo(); // Extrusion modification parameters: setSketchObjectToList()
457       aMgr->undo(); /// Sketch creation
458 #else
459       aMgr->startOperation("Delete invalid Sketch feature", false);
460
461       // delete invalid sketch
462       CompositeFeaturePtr aSketchFeature =
463               std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
464       QObjectPtrList anObjects;
465       anObjects.append(aSketchFeature);
466
467       XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
468       aWorkshop->deleteFeatures(anObjects);
469
470       aMgr->finishOperation();
471 #endif
472     }
473   }
474   openExtrusionTransaction();
475
476   if (aCompFeature->numberOfSubs() == 0) {
477     // call activateWidget() of the parent to connect to the viewer seleciton
478     activateSelectionControl();
479   }
480   else {
481     // check if the created sketch is valid. If it is invalid, it will be deleted with warning else
482     /// the attribute selection list will be filled by result of this sketch.
483     setVisibleSelectionControl(false);
484
485     // Update value in attribute selection list
486     XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
487     XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
488     const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
489     ModuleBase_ModelWidget* aListWidget = 0;
490     foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
491       if (aWidget->attributeID() == myAttributeListID) {
492         aListWidget = aWidget;
493         break;
494       }
495     }
496     if (aListWidget) {
497       aListWidget->restoreValue();
498       aPropertyPanel->activateNextWidget(aListWidget);
499     }
500
501     // Hide sketcher result
502     CompositeFeaturePtr aSketchFeature =
503       std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
504     std::list<ResultPtr> aResults = aSketchFeature->results();
505     std::list<ResultPtr>::const_iterator aIt;
506     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
507       (*aIt)->setDisplayed(false);
508     }
509     aSketchFeature->setDisplayed(false);
510     static Events_Loop* aLoop = Events_Loop::loop();
511     aLoop->flush(aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
512
513     // Add Selected body were created the sketcher to list of selected objects
514     std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::OBJECTS_ID();
515     AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute);
516     if (aSelList.get()) {
517       DataPtr aData = aSketchFeature->data();
518       AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
519                                     (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
520       ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr();
521       if (aRes.get()) {
522         SessionPtr aMgr = ModelAPI_Session::get();
523         ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
524         AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute);
525         std::string aValidatorID;
526         Events_InfoMessage anError;
527         aSelList->append(aRes, GeomShapePtr());
528         if (aFactory->validate(anAttribute, aValidatorID, anError))
529           updateObject(aCompFeature);
530         else
531           aSelList->clear();
532       }
533     }
534   }
535   restoreValue();
536 }
537
538 bool PartSet_WidgetSketchCreator::validateSelectionList() const
539 {
540   AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
541
542   SessionPtr aMgr = ModelAPI_Session::get();
543   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
544   std::string aValidatorID;
545   Events_InfoMessage anError;
546   bool isValidPComposite = aFactory->validate(anAttrList, aValidatorID, anError);
547   if (!isValidPComposite) {
548     XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
549     // TODO(spo): translate
550     QMessageBox::question(aWorkshop->desktop(), tr("Apply current feature"),
551                   tr("Sketch is invalid and will be deleted.\nError: %1")
552                   .arg(anError.messageString().c_str()),
553                   QMessageBox::Ok);
554   }
555   return isValidPComposite;
556 }
557
558 void PartSet_WidgetSketchCreator::setSketchObjectToList(
559                             const CompositeFeaturePtr& theCompositeFeature,
560                             const AttributePtr& theAttribute)
561 {
562   if (!theCompositeFeature.get() || theCompositeFeature->numberOfSubs() != 1)
563     return;
564
565   AttributeSelectionListPtr aBaseObjectsSelectionList =
566                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
567   if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
568     return;
569   }
570
571   FeaturePtr aSketchFeature = theCompositeFeature->subFeature(0);
572   if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
573     return;
574   }
575
576   ResultPtr aSketchRes = aSketchFeature->results().front();
577   ResultConstructionPtr aConstruction =
578     std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
579   if(!aConstruction.get()) {
580     return;
581   }
582
583   if(aBaseObjectsSelectionList->size() == 0) {
584     aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
585   }
586 }
587
588 void PartSet_WidgetSketchCreator::setEnabledModelWidget(ModuleBase_ModelWidget* theModelWidget,
589                                                         const bool theEnabled)
590 {
591   QList<QWidget*> aMyControls = theModelWidget->getControls();
592   foreach(QWidget*  eachControl, aMyControls) {
593     eachControl->setEnabled(theEnabled);
594   }
595 }