1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "PartSet_WidgetSketchCreator.h"
21 #include "PartSet_Module.h"
22 #include "PartSet_WidgetSketchLabel.h"
23 #include "PartSet_PreviewPlanes.h"
25 #include <Config_Keywords.h>
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>
36 #include <GeomAPI_Face.h>
38 #include <Events_InfoMessage.h>
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>
48 #include <SketchPlugin_SketchEntity.h>
49 #include <FeaturesPlugin_CompositeBoolean.h>
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 #include <ModuleBase_ChoiceCtrl.h>
57 #include <ModuleBase_IWorkshop.h>
58 #include <ModuleBase_ISelectionActivate.h>
60 #include <Config_WidgetAPI.h>
62 #include <Events_Loop.h>
66 #include <QDoubleValidator>
67 //#include <QFormLayout>
68 #include <QVBoxLayout>
69 #include <QMessageBox>
70 #include <QMainWindow>
72 #define DEBUG_UNDO_INVALID_SKETCH
76 QStringList getIconsList(const QStringList& theNames)
79 foreach(QString aName, theNames) {
80 QString aUName = aName.toUpper();
81 if ((aUName == "VERTICES") || (aUName == "VERTEX"))
82 aIcons << ":pictures/vertex32.png";
83 else if ((aUName == "EDGES") || (aUName == "EDGE"))
84 aIcons << ":pictures/edge32.png";
85 else if ((aUName == "FACES") || (aUName == "FACE"))
86 aIcons << ":pictures/face32.png";
93 PartSet_WidgetSketchCreator::PartSet_WidgetSketchCreator(QWidget* theParent,
94 PartSet_Module* theModule,
95 const Config_WidgetAPI* theData)
96 : ModuleBase_WidgetSelector(theParent, theModule->workshop(), theData),
97 myModule(theModule), myIsCustomAttribute(false)
99 myAttributeListID = theData->getProperty("attribute_list_id");
101 //QFormLayout* aLayout = new QFormLayout(this);
102 QVBoxLayout* aLayout = new QVBoxLayout(this);
103 ModuleBase_Tools::zeroMargins(aLayout);
105 ModuleBase_Tools::adjustMargins(aLayout);
107 QString aLabelText = translate(theData->widgetLabel());
108 QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
110 // Size of the View control
111 mySizeOfViewWidget = new QWidget(this);
112 QHBoxLayout* aSizeLayout = new QHBoxLayout(mySizeOfViewWidget);
113 aSizeLayout->addWidget(new QLabel(tr("Size of the view"), mySizeOfViewWidget));
114 mySizeOfView = new QLineEdit(mySizeOfViewWidget);
116 QDoubleValidator* aValidator = new QDoubleValidator(0, DBL_MAX, 12, mySizeOfView);
117 aValidator->setLocale(ModuleBase_Tools::doubleLocale());
118 aValidator->setNotation(QDoubleValidator::StandardNotation);
119 mySizeOfView->setValidator(aValidator);
120 aSizeLayout->addWidget(mySizeOfView);
122 myLabel = new QLabel(aLabelText, this);
123 myLabel->setWordWrap(true);
125 aLayout->addWidget(mySizeOfViewWidget);
126 aLayout->addWidget(myLabel);
128 std::string aTypes = theData->getProperty("shape_types");
129 myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts);
130 myIsUseChoice = theData->getBooleanAttribute("use_choice", false);
132 QStringList aIconsList;
133 std::string aIcons = theData->getProperty("type_icons");
134 if (aIcons.size() > 0)
135 aIconsList = QString(aIcons.c_str()).split(' ', QString::SkipEmptyParts);
137 if (aIconsList.size() != myShapeTypes.size())
138 aIconsList = getIconsList(myShapeTypes);
140 myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList);
141 myTypeCtrl->setLabel(tr("Type"));
142 if (!myShapeTypes.empty()) {
143 std::string aDefType = theData->getProperty("default_type");
144 if (aDefType.size() > 0) {
146 int aId = QString(aDefType.c_str()).toInt(&aOk);
148 myTypeCtrl->setValue(aId);
149 myDefMode = myShapeTypes.at(aId).toStdString();
152 if (myDefMode.size() == 0) {
153 myTypeCtrl->setValue(0);
154 myDefMode = myShapeTypes.first().toStdString();
157 aLayout->addWidget(myTypeCtrl);
158 // There is no sense to parameterize list of types while we can not parameterize selection mode
159 // if the xml definition contains one type, the controls to select a type should not be shown
160 if (myShapeTypes.size() <= 1 || !myIsUseChoice) {
161 myTypeCtrl->setVisible(false);
163 connect(myTypeCtrl, SIGNAL(valueChanged(int)), this, SLOT(onSelectionTypeChanged()));
165 aLayout->addStretch(1);
166 myPreviewPlanes = new PartSet_PreviewPlanes();
169 PartSet_WidgetSketchCreator::~PartSet_WidgetSketchCreator()
171 // we need to deactivate here in order to hide preview planes if the selection mode is
176 QList<QWidget*> PartSet_WidgetSketchCreator::getControls() const
178 QList<QWidget*> aControls;
179 aControls.append(myLabel);
183 bool PartSet_WidgetSketchCreator::restoreValueCustom()
188 bool PartSet_WidgetSketchCreator::storeValueCustom()
193 AttributePtr PartSet_WidgetSketchCreator::attribute() const
195 AttributePtr anAttribute;
196 if (myIsCustomAttribute)
197 anAttribute = myFeature->attribute(myAttributeListID);
199 anAttribute = ModuleBase_WidgetSelector::attribute();
204 //********************************************************************
205 void PartSet_WidgetSketchCreator::openExtrusionTransaction()
207 SessionPtr aMgr = ModelAPI_Session::get();
208 bool aIsOp = aMgr->isOperation();
210 const static std::string aNestedOpID("Parameters modification");
211 aMgr->startOperation(aNestedOpID, true);
215 //********************************************************************
216 bool PartSet_WidgetSketchCreator::isValidSelection(const ModuleBase_ViewerPrsPtr& theValue)
219 if (myIsCustomAttribute) {
220 // check only suiting of the value to custom attribute (myAttributeListID)
221 // do not cash of validation to avoid using states, stored for XML attribute
222 // there is an alternative is to call clearValidatedCash() in setSelection()
223 aValid = isValidSelectionForAttribute(theValue, attribute());
225 else { /// if the validated attribute is already custom
226 if (getValidState(theValue, aValid)) {
229 aValid = isValidSelectionCustom(theValue);
231 // check selection to create new sketh (XML current attribute)
232 aValid = isValidSelectionForAttribute(theValue, attribute());
234 // check selection to fill list attribute (myAttributeListID)
235 bool isCustomAttribute = myIsCustomAttribute;
236 myIsCustomAttribute = true;
237 aValid = isValidSelectionForAttribute(theValue, attribute());
238 myIsCustomAttribute = isCustomAttribute;
241 storeValidState(theValue, aValid);
245 //********************************************************************
246 bool PartSet_WidgetSketchCreator::isValidSelectionCustom(const ModuleBase_ViewerPrsPtr& theValue)
248 return PartSet_WidgetSketchLabel::canFillSketch(theValue);
251 void PartSet_WidgetSketchCreator::activateSelectionControl()
253 // reset previously set size of view needed on restart extrusion after Sketch
254 if (myModule->sketchMgr()->previewSketchPlane()->isUseSizeOfView())
255 myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(0, false);
257 // we need to call activate here as the widget has no focus accepted controls
258 // if these controls are added here, activate will happens automatically after focusIn()
259 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
260 XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
261 aPanel->activateWidget(this, false);
264 void PartSet_WidgetSketchCreator::setVisibleSelectionControl(const bool theSelectionControl)
266 // hide current widget, activate the next widget
267 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
268 XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
269 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
270 foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
271 if (theSelectionControl) { // hide other controls
273 aWidget->setVisible(false);
275 else { // hide current control
277 aWidget->setVisible(false);
279 aWidget->setVisible(true);
280 if (aWidget->attributeID() == myAttributeListID)
281 setEnabledModelWidget(aWidget, !hasSubObjects());
286 if (theSelectionControl) {
287 bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop);
288 bool aSketchIsVisualized = myPreviewPlanes->hasVisualizedSketch(myWorkshop);
289 if (!aBodyIsVisualized && !aSketchIsVisualized) {
290 // We have to select a plane before any operation
291 myPreviewPlanes->showPreviewPlanes(myWorkshop);
292 mySizeOfViewWidget->setVisible(true);
295 mySizeOfViewWidget->setVisible(false);
299 bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
300 myPreviewPlanes->erasePreviewPlanes(myWorkshop);
302 aWorkshop->viewer()->update();
306 QIntList PartSet_WidgetSketchCreator::shapeTypes() const
308 QIntList aShapeTypes;
309 if (myShapeTypes.length() > 1 && myIsUseChoice) {
310 aShapeTypes.append(ModuleBase_Tools::shapeType(myTypeCtrl->textValue()));
313 foreach(QString aType, myShapeTypes) {
314 aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
320 void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
322 ModuleBase_ModelWidget::setEditingMode(isEditing);
324 setVisibleSelectionControl(false);
326 ModuleBase_ModelWidget* anAttributeListWidget = 0;
327 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
328 XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
329 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
330 foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
331 if (aWidget->attributeID() == myAttributeListID) {
332 anAttributeListWidget = aWidget;
336 if (anAttributeListWidget)
337 setEnabledModelWidget(anAttributeListWidget, !hasSubObjects());
341 bool PartSet_WidgetSketchCreator::isSelectionMode() const
343 AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
344 bool aHasValueInList = anAttrList.get() && anAttrList->size() > 0;
346 return !aHasValueInList;
349 bool PartSet_WidgetSketchCreator::hasSubObjects() const
351 bool aHasSubObjects = false;
353 bool aCanSetFocus = true;
354 CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
355 if (aComposite.get())
356 aHasSubObjects = aComposite->numberOfSubs() > 0;
357 return aHasSubObjects;
360 bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
361 const bool theToValidate)
364 if (!startSketchOperation(theValues)) {
365 myIsCustomAttribute = true;
366 QList<ModuleBase_ViewerPrsPtr>::const_iterator
367 anIt = theValues.begin(), aLast = theValues.end();
368 bool aProcessed = false;
369 for (; anIt != aLast; anIt++) {
370 ModuleBase_ViewerPrsPtr aValue = *anIt;
371 if (!theToValidate || isValidInFilters(aValue))
372 aProcessed = setSelectionCustom(aValue) || aProcessed;
374 myIsCustomAttribute = false;
377 emit valuesChanged();
378 updateObject(myFeature);
379 setVisibleSelectionControl(false);
380 // manually deactivation because the widget was
381 // not activated as has no focus acceptin controls
383 emit focusOutWidget(this);
389 //********************************************************************
390 bool PartSet_WidgetSketchCreator::processSelection()
392 QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
393 bool isDone = setSelection(aSelected, true/*false*/);
398 //********************************************************************
399 void PartSet_WidgetSketchCreator::updateOnSelectionChanged(const bool theDone)
403 bool PartSet_WidgetSketchCreator::startSketchOperation(
404 const QList<ModuleBase_ViewerPrsPtr>& theValues)
406 bool aSketchStarted = false;
408 if (theValues.size() != 1)
409 return aSketchStarted;
411 ModuleBase_ViewerPrsPtr aValue = theValues.front();
412 if (!aValue.get() || !PartSet_WidgetSketchLabel::canFillSketch(aValue))
413 return aSketchStarted;
415 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
416 /// sketch should not started by object(face) selected as global. If Local face is selected,
417 /// sketch is started
418 if (aResult.get() && aValue->shape().get() && aResult->shape()->isEqual(aValue->shape())) {
419 ResultConstructionPtr aConstruction =
420 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
421 if (!aConstruction.get() || !aConstruction->isInfinite())
422 return aSketchStarted;
424 aSketchStarted = true;
425 // Set View size if a plane is selected
426 if (myPreviewPlanes->isPreviewDisplayed() &&
427 myPreviewPlanes->isPreviewShape(aValue->shape())) {
428 // set default plane size
429 bool isSetSizeOfView = false;
430 double aSizeOfView = 0;
431 QString aSizeOfViewStr = mySizeOfView->text();
432 if (!aSizeOfViewStr.isEmpty()) {
433 aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
434 if (isSetSizeOfView && aSizeOfView <= 0) {
435 isSetSizeOfView = false;
439 myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
441 // manually deactivation because the widget was not activated as has no focus acceptin controls
443 bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
444 myPreviewPlanes->erasePreviewPlanes(myWorkshop);
446 // start edit operation for the sketch
447 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
448 (myModule->createOperation("Sketch"));
449 QList<ModuleBase_ViewerPrsPtr> aValues;
450 aValues.push_back(aValue);
451 aFOperation->setPreselection(aValues);
453 myWorkshop->processLaunchOperation(aFOperation);
455 return aSketchStarted;
458 bool PartSet_WidgetSketchCreator::focusTo()
460 // this method is called only in creation mode. In Edition mode this widget is hidden
461 if (isSelectionMode() && !hasSubObjects()) {
462 setVisibleSelectionControl(true);
463 activateSelectionControl();
464 openExtrusionTransaction();
468 connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)),
469 SLOT(onResumed(ModuleBase_Operation*)));
474 void PartSet_WidgetSketchCreator::deactivate()
476 ModuleBase_WidgetSelector::deactivate();
478 bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
479 myPreviewPlanes->erasePreviewPlanes(myWorkshop);
481 XGUI_Tools::workshop(myWorkshop)->viewer()->update();
485 void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
487 SessionPtr aMgr = ModelAPI_Session::get();
488 bool aIsOp = aMgr->isOperation();
490 // in current implementation, all transactions are closed when resume happens
491 // so, this is a wrong case, which is not checked.
492 // To provide it, make correction in later rows about abort/undo transactions
495 // Set visible only selection control
496 setVisibleSelectionControl(true);
498 // Validate the created sketch. If it is valid, it is set into the composite feature selection
499 // list, otherwise it is removed
500 CompositeFeaturePtr aCompFeature =
501 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
502 AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
503 if (aCompFeature->numberOfSubs() > 0) {
504 // set the sub feature to attribute selection list and check whether sketch is valid
505 SessionPtr aMgr = ModelAPI_Session::get();
506 const static std::string aNestedOpID("Set Sketch result into Selection list");
507 aMgr->startOperation(aNestedOpID, false); // false to not attach to Extrusion operation
508 setSketchObjectToList(aCompFeature, anAttrList);
509 aMgr->finishOperation();
511 if (!validateSelectionList()) {
512 #ifdef DEBUG_UNDO_INVALID_SKETCH
513 aMgr->undo(); // Extrusion modification parameters: setSketchObjectToList()
514 aMgr->undo(); /// Sketch creation
516 aMgr->startOperation("Delete invalid Sketch feature", false);
518 // delete invalid sketch
519 CompositeFeaturePtr aSketchFeature =
520 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
521 QObjectPtrList anObjects;
522 anObjects.append(aSketchFeature);
524 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
525 aWorkshop->deleteFeatures(anObjects);
527 aMgr->finishOperation();
531 openExtrusionTransaction();
533 if (aCompFeature->numberOfSubs() == 0) {
534 // call activateWidget() of the parent to connect to the viewer seleciton
535 activateSelectionControl();
538 // check if the created sketch is valid. If it is invalid, it will be deleted with warning else
539 /// the attribute selection list will be filled by result of this sketch.
540 setVisibleSelectionControl(false);
542 // Update value in attribute selection list
543 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
544 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
545 const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
546 ModuleBase_ModelWidget* aListWidget = 0;
547 foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
548 if (aWidget->attributeID() == myAttributeListID) {
549 aListWidget = aWidget;
554 aListWidget->restoreValue();
555 aPropertyPanel->activateNextWidget(aListWidget);
558 // Hide sketcher result
559 CompositeFeaturePtr aSketchFeature =
560 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
561 std::list<ResultPtr> aResults = aSketchFeature->results();
562 std::list<ResultPtr>::const_iterator aIt;
563 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
564 (*aIt)->setDisplayed(false);
566 aSketchFeature->setDisplayed(false);
567 static Events_Loop* aLoop = Events_Loop::loop();
568 aLoop->flush(aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
570 // Add Selected body were created the sketcher to list of selected objects
571 std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::OBJECTS_ID();
572 AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute);
573 if (aSelList.get()) {
574 DataPtr aData = aSketchFeature->data();
575 AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
576 (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
577 ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr();
579 SessionPtr aMgr = ModelAPI_Session::get();
580 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
581 AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute);
582 std::string aValidatorID;
583 Events_InfoMessage anError;
584 aSelList->append(aRes, GeomShapePtr());
585 if (aFactory->validate(anAttribute, aValidatorID, anError))
586 updateObject(aCompFeature);
595 bool PartSet_WidgetSketchCreator::validateSelectionList() const
597 AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
599 SessionPtr aMgr = ModelAPI_Session::get();
600 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
601 std::string aValidatorID;
602 Events_InfoMessage anError;
603 bool isValidPComposite = aFactory->validate(anAttrList, aValidatorID, anError);
604 if (!isValidPComposite) {
605 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
606 // TODO(spo): translate
607 QMessageBox::question(aWorkshop->desktop(), tr("Apply current feature"),
608 tr("Sketch is invalid and will be deleted.\nError: %1")
609 .arg(anError.messageString().c_str()),
612 return isValidPComposite;
615 void PartSet_WidgetSketchCreator::setSketchObjectToList(
616 const CompositeFeaturePtr& theCompositeFeature,
617 const AttributePtr& theAttribute)
619 if (!theCompositeFeature.get() || theCompositeFeature->numberOfSubs() != 1)
622 AttributeSelectionListPtr aBaseObjectsSelectionList =
623 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
624 if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
628 FeaturePtr aSketchFeature = theCompositeFeature->subFeature(0);
629 if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
633 ResultPtr aSketchRes = aSketchFeature->results().front();
634 ResultConstructionPtr aConstruction =
635 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
636 if(!aConstruction.get()) {
640 if(aBaseObjectsSelectionList->size() == 0) {
641 aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
645 void PartSet_WidgetSketchCreator::setEnabledModelWidget(ModuleBase_ModelWidget* theModelWidget,
646 const bool theEnabled)
648 QList<QWidget*> aMyControls = theModelWidget->getControls();
649 foreach(QWidget* eachControl, aMyControls) {
650 eachControl->setEnabled(theEnabled);
654 void PartSet_WidgetSketchCreator::onSelectionTypeChanged()
656 // Clear current selection in order to avoid updating of object browser with obsolete indexes
657 // which can appear because of results deletetion after changing a type of selection
658 QString aSelectionType = myTypeCtrl->textValue();
659 QList<ModuleBase_ViewerPrsPtr> aEmptyList;
660 myWorkshop->setSelected(aEmptyList);
662 updateSelectionModesAndFilters(true);
663 myWorkshop->selectionActivate()->updateSelectionModes();
668 if (aSelectionType != "Faces") {
669 setVisibleSelectionControl(false);
670 myWorkshop->propertyPanel()->activateNextWidget();
673 /// store the selected type
674 AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
675 anAttrList->setSelectionType(aSelectionType.toStdString());
678 // update object is necessary to flush update signal. It leads to objects references map update
679 // and the operation presentation will not contain deleted items visualized as parameters of
681 updateObject(myFeature);
682 myWorkshop->propertyPanel()->activeWidget()->restoreValue();
683 myWorkshop->setSelected(getAttributeSelection());
684 // may be the feature's result is not displayed, but attributes should be
685 // hope that something is redisplayed by object updated
686 myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments, true);