1 // Copyright (C) 2014-2021 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 QStringList aTypes = myTypeCtrl->textValue().split("|", QString::SkipEmptyParts);
311 foreach(QString aType, aTypes) {
312 aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
316 foreach(QString aType, myShapeTypes) {
317 QStringList aSubTypes = aType.split("|", QString::SkipEmptyParts);
318 foreach(QString asubType, aSubTypes) {
319 aShapeTypes.append(ModuleBase_Tools::shapeType(asubType));
326 void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
328 ModuleBase_ModelWidget::setEditingMode(isEditing);
330 setVisibleSelectionControl(false);
332 ModuleBase_ModelWidget* anAttributeListWidget = 0;
333 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
334 XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
335 const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
336 foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
337 if (aWidget->attributeID() == myAttributeListID) {
338 anAttributeListWidget = aWidget;
342 if (anAttributeListWidget)
343 setEnabledModelWidget(anAttributeListWidget, !hasSubObjects());
347 bool PartSet_WidgetSketchCreator::isSelectionMode() const
349 AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
350 bool aHasValueInList = anAttrList.get() && anAttrList->size() > 0;
352 return !aHasValueInList;
355 bool PartSet_WidgetSketchCreator::hasSubObjects() const
357 bool aHasSubObjects = false;
358 CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
359 if (aComposite.get())
360 aHasSubObjects = aComposite->numberOfSubs() > 0;
361 return aHasSubObjects;
364 bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
365 const bool theToValidate)
368 if (!startSketchOperation(theValues)) {
369 myIsCustomAttribute = true;
370 QList<ModuleBase_ViewerPrsPtr>::const_iterator
371 anIt = theValues.begin(), aLast = theValues.end();
372 bool aProcessed = false;
373 for (; anIt != aLast; anIt++) {
374 ModuleBase_ViewerPrsPtr aValue = *anIt;
375 if (!theToValidate || isValidInFilters(aValue))
376 aProcessed = setSelectionCustom(aValue) || aProcessed;
378 myIsCustomAttribute = false;
381 emit valuesChanged();
382 updateObject(myFeature);
383 setVisibleSelectionControl(false);
384 // manually deactivation because the widget was
385 // not activated as has no focus acceptin controls
387 emit focusOutWidget(this);
393 //********************************************************************
394 bool PartSet_WidgetSketchCreator::processSelection()
396 QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
397 bool isDone = setSelection(aSelected, true/*false*/);
402 //********************************************************************
403 void PartSet_WidgetSketchCreator::updateOnSelectionChanged(const bool theDone)
407 bool PartSet_WidgetSketchCreator::startSketchOperation(
408 const QList<ModuleBase_ViewerPrsPtr>& theValues)
410 bool aSketchStarted = false;
412 if (theValues.size() != 1)
413 return aSketchStarted;
415 ModuleBase_ViewerPrsPtr aValue = theValues.front();
416 if (!aValue.get() || !PartSet_WidgetSketchLabel::canFillSketch(aValue))
417 return aSketchStarted;
419 ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
420 /// sketch should not started by object(face) selected as global. If Local face is selected,
421 /// sketch is started
422 if (aResult.get() && aValue->shape().get() && aResult->shape()->isEqual(aValue->shape())) {
423 ResultConstructionPtr aConstruction =
424 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
425 if (!aConstruction.get() || !aConstruction->isInfinite())
426 return aSketchStarted;
428 aSketchStarted = true;
429 // Set View size if a plane is selected
430 if (myPreviewPlanes->isPreviewDisplayed() &&
431 myPreviewPlanes->isPreviewShape(aValue->shape())) {
432 // set default plane size
433 bool isSetSizeOfView = false;
434 double aSizeOfView = 0;
435 QString aSizeOfViewStr = mySizeOfView->text();
436 if (!aSizeOfViewStr.isEmpty()) {
437 aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
438 if (isSetSizeOfView && aSizeOfView <= 0) {
439 isSetSizeOfView = false;
443 myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
445 // manually deactivation because the widget was not activated as has no focus acceptin controls
447 myPreviewPlanes->erasePreviewPlanes(myWorkshop);
449 // start edit operation for the sketch
450 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
451 (myModule->createOperation("Sketch"));
452 QList<ModuleBase_ViewerPrsPtr> aValues;
453 aValues.push_back(aValue);
454 aFOperation->setPreselection(aValues);
456 myWorkshop->processLaunchOperation(aFOperation);
458 return aSketchStarted;
461 bool PartSet_WidgetSketchCreator::focusTo()
463 // this method is called only in creation mode. In Edition mode this widget is hidden
464 if (isSelectionMode() && !hasSubObjects()) {
465 setVisibleSelectionControl(true);
466 activateSelectionControl();
467 openExtrusionTransaction();
471 connect(myModule, SIGNAL(resumed(ModuleBase_Operation*)),
472 SLOT(onResumed(ModuleBase_Operation*)));
477 void PartSet_WidgetSketchCreator::deactivate()
479 ModuleBase_WidgetSelector::deactivate();
481 bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
482 myPreviewPlanes->erasePreviewPlanes(myWorkshop);
484 XGUI_Tools::workshop(myWorkshop)->viewer()->update();
488 void PartSet_WidgetSketchCreator::onResumed(ModuleBase_Operation* theOp)
490 SessionPtr aMgr = ModelAPI_Session::get();
491 bool aIsOp = aMgr->isOperation();
493 // in current implementation, all transactions are closed when resume happens
494 // so, this is a wrong case, which is not checked.
495 // To provide it, make correction in later rows about abort/undo transactions
498 // Set visible only selection control
499 setVisibleSelectionControl(true);
501 // Validate the created sketch. If it is valid, it is set into the composite feature selection
502 // list, otherwise it is removed
503 CompositeFeaturePtr aCompFeature =
504 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
505 AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
506 if (aCompFeature->numberOfSubs() > 0) {
507 // set the sub feature to attribute selection list and check whether sketch is valid
508 const static std::string aNestedOpID("Set Sketch result into Selection list");
509 aMgr->startOperation(aNestedOpID, false); // false to not attach to Extrusion operation
510 setSketchObjectToList(aCompFeature, anAttrList);
511 aMgr->finishOperation();
513 if (!validateSelectionList()) {
514 #ifdef DEBUG_UNDO_INVALID_SKETCH
515 aMgr->undo(); // Extrusion modification parameters: setSketchObjectToList()
516 aMgr->undo(); /// Sketch creation
518 aMgr->startOperation("Delete invalid Sketch feature", false);
520 // delete invalid sketch
521 CompositeFeaturePtr aSketchFeature =
522 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
523 QObjectPtrList anObjects;
524 anObjects.append(aSketchFeature);
526 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
527 aWorkshop->deleteFeatures(anObjects);
529 aMgr->finishOperation();
533 openExtrusionTransaction();
535 if (aCompFeature->numberOfSubs() == 0) {
536 // call activateWidget() of the parent to connect to the viewer seleciton
537 activateSelectionControl();
540 // check if the created sketch is valid. If it is invalid, it will be deleted with warning else
541 /// the attribute selection list will be filled by result of this sketch.
542 setVisibleSelectionControl(false);
544 // Update value in attribute selection list
545 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
546 XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
547 const QList<ModuleBase_ModelWidget*>& aWidgets = aPropertyPanel->modelWidgets();
548 ModuleBase_ModelWidget* aListWidget = 0;
549 foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
550 if (aWidget->attributeID() == myAttributeListID) {
551 aListWidget = aWidget;
556 aListWidget->restoreValue();
557 aPropertyPanel->activateNextWidget(aListWidget);
560 // Hide sketcher result
561 CompositeFeaturePtr aSketchFeature =
562 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
563 std::list<ResultPtr> aResults = aSketchFeature->results();
564 std::list<ResultPtr>::const_iterator aIt;
565 for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
566 (*aIt)->setDisplayed(false);
568 aSketchFeature->setDisplayed(false);
569 static Events_Loop* aLoop = Events_Loop::loop();
570 aLoop->flush(aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
572 // Add Selected body were created the sketcher to list of selected objects
573 std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::OBJECTS_ID();
574 AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute);
575 if (aSelList.get()) {
576 DataPtr aData = aSketchFeature->data();
577 AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
578 (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
579 ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr();
581 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
582 AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute);
583 std::string aValidatorID;
584 Events_InfoMessage anError;
585 aSelList->append(aRes, GeomShapePtr());
586 if (aFactory->validate(anAttribute, aValidatorID, anError))
587 updateObject(aCompFeature);
596 bool PartSet_WidgetSketchCreator::validateSelectionList() const
598 AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
600 SessionPtr aMgr = ModelAPI_Session::get();
601 ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
602 std::string aValidatorID;
603 Events_InfoMessage anError;
604 bool isValidPComposite = aFactory->validate(anAttrList, aValidatorID, anError);
605 if (!isValidPComposite) {
606 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
607 // TODO(spo): translate
608 QMessageBox::question(aWorkshop->desktop(), tr("Apply current feature"),
609 tr("Sketch is invalid and will be deleted.\nError: %1")
610 .arg(anError.messageString().c_str()),
613 return isValidPComposite;
616 void PartSet_WidgetSketchCreator::setSketchObjectToList(
617 const CompositeFeaturePtr& theCompositeFeature,
618 const AttributePtr& theAttribute)
620 if (!theCompositeFeature.get() || theCompositeFeature->numberOfSubs() != 1)
623 AttributeSelectionListPtr aBaseObjectsSelectionList =
624 std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
625 if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
629 FeaturePtr aSketchFeature = theCompositeFeature->subFeature(0);
630 if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
634 ResultPtr aSketchRes = aSketchFeature->results().front();
635 ResultConstructionPtr aConstruction =
636 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
637 if(!aConstruction.get()) {
641 if(aBaseObjectsSelectionList->size() == 0) {
642 aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
646 void PartSet_WidgetSketchCreator::setEnabledModelWidget(ModuleBase_ModelWidget* theModelWidget,
647 const bool theEnabled)
649 QList<QWidget*> aMyControls = theModelWidget->getControls();
650 foreach(QWidget* eachControl, aMyControls) {
651 eachControl->setEnabled(theEnabled);
655 void PartSet_WidgetSketchCreator::onSelectionTypeChanged()
657 // Clear current selection in order to avoid updating of object browser with obsolete indexes
658 // which can appear because of results deletetion after changing a type of selection
659 QString aSelectionType = myTypeCtrl->textValue();
660 QList<ModuleBase_ViewerPrsPtr> aEmptyList;
661 myWorkshop->setSelected(aEmptyList);
663 updateSelectionModesAndFilters(true);
664 myWorkshop->selectionActivate()->updateSelectionModes();
669 if (aSelectionType != "Faces") {
670 setVisibleSelectionControl(false);
671 myWorkshop->propertyPanel()->activateNextWidget();
674 /// store the selected type
675 AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
676 anAttrList->setSelectionType(aSelectionType.toStdString());
679 // update object is necessary to flush update signal. It leads to objects references map update
680 // and the operation presentation will not contain deleted items visualized as parameters of
682 updateObject(myFeature);
683 myWorkshop->propertyPanel()->activeWidget()->restoreValue();
684 myWorkshop->setSelected(getAttributeSelection());
685 // may be the feature's result is not displayed, but attributes should be
686 // hope that something is redisplayed by object updated
687 myWorkshop->module()->customizeFeature(myFeature, ModuleBase_IModule::CustomizeArguments, true);