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