+ QIntList aShapeTypes;
+ foreach(QString aType, myShapeTypes) {
+ aShapeTypes.append(ModuleBase_Tools::shapeType(aType));
+ }
+ return aShapeTypes;
+}
+
+void PartSet_WidgetSketchCreator::setEditingMode(bool isEditing)
+{
+ ModuleBase_ModelWidget::setEditingMode(isEditing);
+ if (isEditing) {
+ setVisibleSelectionControl(false);
+
+ ModuleBase_ModelWidget* anAttributeListWidget = 0;
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
+ XGUI_PropertyPanel* aPanel = aWorkshop->propertyPanel();
+ const QList<ModuleBase_ModelWidget*>& aWidgets = aPanel->modelWidgets();
+ foreach(ModuleBase_ModelWidget* aWidget, aWidgets) {
+ if (aWidget->attributeID() == myAttributeListID) {
+ anAttributeListWidget = aWidget;
+ break;
+ }
+ }
+ if (anAttributeListWidget)
+ setEnabledModelWidget(anAttributeListWidget, !hasSubObjects());
+ }
+}
+
+bool PartSet_WidgetSketchCreator::isSelectionMode() const
+{
+ AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
+ bool aHasValueInList = anAttrList.get() && anAttrList->size() > 0;
+
+ return !aHasValueInList;
+}
+
+bool PartSet_WidgetSketchCreator::hasSubObjects() const
+{
+ bool aHasSubObjects = false;
+
+ bool aCanSetFocus = true;
+ CompositeFeaturePtr aComposite = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aComposite.get())
+ aHasSubObjects = aComposite->numberOfSubs() > 0;
+ return aHasSubObjects;
+}
+
+bool PartSet_WidgetSketchCreator::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
+ const bool theToValidate)
+{
+ bool aDone = false;
+ if (!startSketchOperation(theValues)) {
+ myIsCustomAttribute = true;
+ QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = theValues.begin(), aLast = theValues.end();
+ bool aProcessed = false;
+ for (; anIt != aLast; anIt++) {
+ ModuleBase_ViewerPrsPtr aValue = *anIt;
+ if (!theToValidate || isValidInFilters(aValue))
+ aProcessed = setSelectionCustom(aValue) || aProcessed;
+ }
+ myIsCustomAttribute = false;
+ aDone = aProcessed;
+ if (aProcessed) {
+ emit valuesChanged();
+ updateObject(myFeature);
+ setVisibleSelectionControl(false);
+ // manually deactivation because the widget was not activated as has no focus acceptin controls
+ deactivate();
+ emit focusOutWidget(this);
+ }
+ }
+ return aDone;
+}
+
+//********************************************************************
+void PartSet_WidgetSketchCreator::onSelectionChanged()
+{
+ QList<ModuleBase_ViewerPrsPtr> aSelected = getFilteredSelected();
+ bool isDone = setSelection(aSelected, true/*false*/);
+}
+
+//********************************************************************
+void PartSet_WidgetSketchCreator::updateOnSelectionChanged(const bool theDone)
+{
+}
+
+bool PartSet_WidgetSketchCreator::startSketchOperation(const QList<ModuleBase_ViewerPrsPtr>& theValues)
+{
+ bool aSketchStarted = false;
+
+ if (theValues.size() != 1)
+ return aSketchStarted;
+
+ ModuleBase_ViewerPrsPtr aValue = theValues.front();
+ if (!aValue.get() || !PartSet_WidgetSketchLabel::canFillSketch(aValue))
+ return aSketchStarted;
+
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aValue->object());
+ /// sketch should not started by object(face) selected as global. If Local face is selected,
+ /// sketch is started
+ if (aResult.get() && aValue->shape().get() && aResult->shape()->isEqual(aValue->shape())) {
+ ResultConstructionPtr aConstruction = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aResult);
+ if (!aConstruction.get() || !aConstruction->isInfinite())
+ return aSketchStarted;
+ }
+ aSketchStarted = true;
+
+ // manually deactivation because the widget was not activated as has no focus acceptin controls
+ deactivate();
+ bool aHidePreview = myPreviewPlanes->isPreviewDisplayed();
+ myPreviewPlanes->erasePreviewPlanes(myWorkshop);
+
+ // Launch Sketch operation