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