Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchCreator.cpp
1 // Copyright (C) 2014-2017  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<mailto: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   // we need to call activate here as the widget has no focus accepted controls
198   // if these controls are added here, activate will happens automatically after focusIn()
199   XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
200   XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
201   aPanel->activateWidget(this, false);
202 }
203
204 void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl)
205 {
206   // hide current widget, activate the next widget
207   XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
208   XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
209   const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
210   foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
211     if (theSelectionControl) { // hide other controls
212       if (aWidget != this)
213         aWidget->setVisible(false);
214     }
215     else { // hide current control
216       if (aWidget == this)
217         aWidget->setVisible(false);
218       else {
219         aWidget->setVisible(true);
220         if (aWidget->attributeID() == myAttributeListID)
221           setEnabledModelWidget(aWidget, !hasSubObjects());
222       }
223     }
224   }
225
226   if (theSelectionControl) {
227     bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop);
228     bool aSketchIsVisualized = myPreviewPlanes->hasVisualizedSketch(myWorkshop);
229     if (!aBodyIsVisualized && !aSketchIsVisualized) {
230       // We have to select a plane before any operation
231       myPreviewPlanes->showPreviewPlanes(myWorkshop);
232       mySizeOfViewWidget->setVisible(true);
233     }
234     else {
235       mySizeOfViewWidget->setVisible(false);
236     }
237
238   } else {
239     bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
240     myPreviewPlanes->erasePreviewPlanes(myWorkshop);
241     if (aHidePreview)
242       aWorkshop->viewer()->update();
243   }
244 }
245
246 QIntList PartSet_WidgetSketchCreator::shapeTypes() const
247 {
248   QIntList aShapeTypes;
249   foreach(QString aType, myShapeTypes) {
250     aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
251   }
252   return aShapeTypes;
253 }
254
255 void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
256 {
257   ModuleBase_ModelWidget::setEditingMode(isEditing);
258   if (isEditing) {
259     setVisibleSelectionControl(false);
260
261     ModuleBase_ModelWidget* anAttributeListWidget = 0;
262     XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
263     XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
264     const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
265     foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
266       if (aWidget->attributeID() == myAttributeListID) {
267         anAttributeListWidget = aWidget;
268         break;
269       }
270     }
271     if (anAttributeListWidget)
272       setEnabledModelWidget(anAttributeListWidget, !hasSubObjects());
273   }
274 }
275
276 bool PartSet_WidgetSketchCreator::isSelectionMode() const
277 {
278   AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
279   bool aHasValueInList = anAttrList.get() && anAttrList->size() > 0;
280
281   return !aHasValueInList;
282 }
283
284 bool PartSet_WidgetSketchCreator::hasSubObjects() const
285 {
286   bool aHasSubObjects = false;
287
288   bool aCanSetFocus = true;
289   CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
290   if (aComposite.get())
291     aHasSubObjects = aComposite->numberOfSubs() > 0;
292   return aHasSubObjects;
293 }
294
295 bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
296                                                const bool theToValidate)
297 {
298   bool aDone = false;
299   if (!startSketchOperation(theValues)) {
300     myIsCustomAttribute = true;
301     QList<ModuleBase_ViewerPrsPtr>::const_iterator
302       anIt = theValues.begin(), aLast = theValues.end();
303     bool aProcessed = false;
304     for (; anIt != aLast; anIt++) {
305       ModuleBase_ViewerPrsPtr aValue = *anIt;
306       if (!theToValidate || isValidInFilters(aValue))
307         aProcessed = setSelectionCustom(aValue) || aProcessed;
308     }
309     myIsCustomAttribute = false;
310     aDone = aProcessed;
311     if (aProcessed) {
312       emit valuesChanged();
313       updateObject(myFeature);
314       setVisibleSelectionControl(false);
315       // manually deactivation because the widget was
316       // not activated as has no focus acceptin controls
317       deactivate();
318       emit focusOutWidget(this);
319     }
320   }
321   return aDone;
322 }
323
324 //********************************************************************
325 void PartSet_WidgetSketchCreator::onSelectionChanged()
326 {
327   QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
328   bool isDone = setSelection(aSelected, true/*false*/);
329 }
330
331 //********************************************************************
332 void PartSet_WidgetSketchCreator::updateOnSelectionChanged(const bool theDone)
333 {
334 }
335
336 bool PartSet_WidgetSketchCreator::startSketchOperation(
337                               const QList<ModuleBase_ViewerPrsPtr>& theValues)
338 {
339   bool aSketchStarted = false;
340
341   if (theValues.size() != 1)
342     return aSketchStarted;
343
344   ModuleBase_ViewerPrsPtr aValue = theValues.front();
345   if (!aValue.get() || !PartSet_WidgetSketchLabel::canFillSketch(aValue))
346     return aSketchStarted;
347
348   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
349   /// sketch should not started by object(face) selected as global. If Local face is selected,
350   /// sketch is started
351   if (aResult.get() && aValue->shape().get() && aResult->shape()->isEqual(aValue->shape())) {
352     ResultConstructionPtr aConstruction =
353       std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
354     if (!aConstruction.get() || !aConstruction->isInfinite())
355       return aSketchStarted;
356   }
357   aSketchStarted = true;
358   // Set View size if a plane is selected
359   if (myPreviewPlanes->isPreviewDisplayed() &&
360       myPreviewPlanes->isPreviewShape(aValue->shape())) {
361     QString aSizeOfViewStr = mySizeOfView->text();
362     if (!aSizeOfViewStr.isEmpty()) {
363       bool isOk;
364       double aSizeOfView = aSizeOfViewStr.toDouble(&isOk);
365       if (isOk && aSizeOfView > 0) {
366         Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
367         if (!aView3d.IsNull()) {
368           Bnd_Box aBndBox;
369           double aHalfSize = aSizeOfView/2.0;
370           aBndBox.Update(-aHalfSize, -aHalfSize, -aHalfSize, aHalfSize, aHalfSize, aHalfSize);
371           aView3d->FitAll(aBndBox, 0.01, false);
372         }
373       }
374     }
375   }
376   // manually deactivation because the widget was not activated as has no focus acceptin controls
377   deactivate();
378   bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
379   myPreviewPlanes->erasePreviewPlanes(myWorkshop);
380
381   // Launch Sketch operation
382   CompositeFeaturePtr aCompFeature =
383     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
384
385   // start edit operation for the sketch
386   ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
387                                                             (myModule->createOperation("Sketch"));
388   QList<ModuleBase_ViewerPrsPtr> aValues;
389   aValues.push_back(aValue);
390   aFOperation->setPreselection(aValues);
391
392   myWorkshop->processLaunchOperation(aFOperation);
393
394   return aSketchStarted;
395 }
396
397 bool PartSet_WidgetSketchCreator::focusTo()
398 {
399   // this method is called only in creation mode. In Edition mode this widget is hidden
400   if (isSelectionMode() && !hasSubObjects()) {
401     setVisibleSelectionControl(true);
402     activateSelectionControl();
403     openExtrusionTransaction();
404     return true;
405   }
406   else
407     connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)),
408             SLOT(onResumed(ModuleBase_Operation*)));
409
410   return true;
411 }
412
413 void PartSet_WidgetSketchCreator::deactivate()
414 {
415   ModuleBase_WidgetSelector::deactivate();
416
417   bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
418   myPreviewPlanes->erasePreviewPlanes(myWorkshop);
419   if (aHidePreview)
420     XGUI_Tools::workshop(myWorkshop)->viewer()->update();
421
422 }
423
424 void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
425 {
426   SessionPtr aMgr = ModelAPI_Session::get();
427   bool aIsOp = aMgr->isOperation();
428   if (aIsOp) {
429     // in current implementation, all transactions are closed when resume happens
430     // so, this is a wrong case, which is not checked.
431     // To provide it, make correction in later rows about abort/undo transactions
432     return;
433   }
434   // Set visible only selection control
435   setVisibleSelectionControl(true);
436
437   // Validate the created sketch. If it is valid, it is set into the composite feature selection
438   // list, otherwise it is removed
439   CompositeFeaturePtr aCompFeature =
440     std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
441   AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
442   if (aCompFeature->numberOfSubs() > 0) {
443     // set the sub feature to attribute selection list and check whether sketch is valid
444     SessionPtr aMgr = ModelAPI_Session::get();
445     const static std::string aNestedOpID("Set Sketch result into Selection list");
446     aMgr->startOperation(aNestedOpID, false); // false to not attach to Extrusion operation
447     setSketchObjectToList(aCompFeature, anAttrList);
448     aMgr->finishOperation();
449
450     if (!validateSelectionList()) {
451 #ifdef DEBUG_UNDO_INVALID_SKETCH
452       aMgr->undo(); // Extrusion modification parameters: setSketchObjectToList()
453       aMgr->undo(); /// Sketch creation
454 #else
455       aMgr->startOperation("Delete invalid Sketch feature", false);
456
457       // delete invalid sketch
458       CompositeFeaturePtr aSketchFeature =
459               std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
460       QObjectPtrList anObjects;
461       anObjects.append(aSketchFeature);
462
463       XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
464       aWorkshop->deleteFeatures(anObjects);
465
466       aMgr->finishOperation();
467 #endif
468     }
469   }
470   openExtrusionTransaction();
471
472   if (aCompFeature->numberOfSubs() == 0) {
473     // call activateWidget() of the parent to connect to the viewer seleciton
474     activateSelectionControl();
475   }
476   else {
477     // check if the created sketch is valid. If it is invalid, it will be deleted with warning else
478     /// the attribute selection list will be filled by result of this sketch.
479     setVisibleSelectionControl(false);
480
481     // Update value in attribute selection list
482     XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
483     XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
484     const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
485     ModuleBase_ModelWidget* aListWidget = 0;
486     foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
487       if (aWidget->attributeID() == myAttributeListID) {
488         aListWidget = aWidget;
489         break;
490       }
491     }
492     if (aListWidget) {
493       aListWidget->restoreValue();
494       aPropertyPanel->activateNextWidget(aListWidget);
495     }
496
497     // Hide sketcher result
498     CompositeFeaturePtr aSketchFeature =
499       std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
500     std::list<ResultPtr> aResults = aSketchFeature->results();
501     std::list<ResultPtr>::const_iterator aIt;
502     for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
503       (*aIt)->setDisplayed(false);
504     }
505     aSketchFeature->setDisplayed(false);
506     static Events_Loop* aLoop = Events_Loop::loop();
507     aLoop->flush(aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
508
509     // Add Selected body were created the sketcher to list of selected objects
510     std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::OBJECTS_ID();
511     AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute);
512     if (aSelList.get()) {
513       DataPtr aData = aSketchFeature->data();
514       AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
515                                     (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
516       ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr();
517       if (aRes.get()) {
518         SessionPtr aMgr = ModelAPI_Session::get();
519         ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
520         AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute);
521         std::string aValidatorID;
522         Events_InfoMessage anError;
523         aSelList->append(aRes, GeomShapePtr());
524         if (aFactory->validate(anAttribute, aValidatorID, anError))
525           updateObject(aCompFeature);
526         else
527           aSelList->clear();
528       }
529     }
530   }
531   restoreValue();
532 }
533
534 bool PartSet_WidgetSketchCreator::validateSelectionList() const
535 {
536   AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
537
538   SessionPtr aMgr = ModelAPI_Session::get();
539   ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
540   std::string aValidatorID;
541   Events_InfoMessage anError;
542   bool isValidPComposite = aFactory->validate(anAttrList, aValidatorID, anError);
543   if (!isValidPComposite) {
544     XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
545     // TODO(spo): translate
546     QMessageBox::question(aWorkshop->desktop(), tr("Apply current feature"),
547                   tr("Sketch is invalid and will be deleted.\nError: %1")
548                   .arg(anError.messageString().c_str()),
549                   QMessageBox::Ok);
550   }
551   return isValidPComposite;
552 }
553
554 void PartSet_WidgetSketchCreator::setSketchObjectToList(
555                             const CompositeFeaturePtr& theCompositeFeature,
556                             const AttributePtr& theAttribute)
557 {
558   if (!theCompositeFeature.get() || theCompositeFeature->numberOfSubs() != 1)
559     return;
560
561   AttributeSelectionListPtr aBaseObjectsSelectionList =
562                      std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
563   if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
564     return;
565   }
566
567   FeaturePtr aSketchFeature = theCompositeFeature->subFeature(0);
568   if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
569     return;
570   }
571
572   ResultPtr aSketchRes = aSketchFeature->results().front();
573   ResultConstructionPtr aConstruction =
574     std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
575   if(!aConstruction.get()) {
576     return;
577   }
578
579   if(aBaseObjectsSelectionList->size() == 0) {
580     aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
581   }
582 }
583
584 void PartSet_WidgetSketchCreator::setEnabledModelWidget(ModuleBase_ModelWidget* theModelWidget,
585                                                         const bool theEnabled)
586 {
587   QList<QWidget*> aMyControls = theModelWidget->getControls();
588   foreach(QWidget*  eachControl, aMyControls) {
589     eachControl->setEnabled(theEnabled);
590   }
591 }