- else {
- // this is a workarount to display the feature results in the operation selection mode
- // if this is absent, sketch point/line local selection is available on extrusion cut result
- static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
- ModelAPI_EventCreator::get()->sendUpdated(feature(), anUpdateEvent);
- updateObject(feature());
- }
+ }
+ restoreValue();
+}
+
+bool PartSet_WidgetSketchCreator::validateSelectionList() const
+{
+ AttributeSelectionListPtr anAttrList = myFeature->data()->selectionList(myAttributeListID);
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ std::string aValidatorID;
+ Events_InfoMessage anError;
+ bool isValidPComposite = aFactory->validate(anAttrList, aValidatorID, anError);
+ if (!isValidPComposite) {
+ XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
+ // TODO(spo): translate
+ QMessageBox::question(aWorkshop->desktop(), tr("Apply current feature"),
+ tr("Sketch is invalid and will be deleted.\nError: %1")
+ .arg(anError.messageString().c_str()),
+ QMessageBox::Ok);
+ }
+ return isValidPComposite;
+}
+
+void PartSet_WidgetSketchCreator::setSketchObjectToList(
+ const CompositeFeaturePtr& theCompositeFeature,
+ const AttributePtr& theAttribute)
+{
+ if (!theCompositeFeature.get() || theCompositeFeature->numberOfSubs() != 1)
+ return;
+
+ AttributeSelectionListPtr aBaseObjectsSelectionList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(theAttribute);
+ if(!aBaseObjectsSelectionList.get() || aBaseObjectsSelectionList->isInitialized()) {
+ return;
+ }
+
+ FeaturePtr aSketchFeature = theCompositeFeature->subFeature(0);
+ if(!aSketchFeature.get() || aSketchFeature->results().empty()) {
+ return;
+ }
+
+ ResultPtr aSketchRes = aSketchFeature->results().front();
+ ResultConstructionPtr aConstruction =
+ std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aSketchRes);
+ if(!aConstruction.get()) {
+ return;
+ }
+
+ if(aBaseObjectsSelectionList->size() == 0) {
+ aBaseObjectsSelectionList->append(aSketchRes, GeomShapePtr());
+ }
+}
+
+void PartSet_WidgetSketchCreator::setEnabledModelWidget(ModuleBase_ModelWidget* theModelWidget,
+ const bool theEnabled)
+{
+ QList<QWidget*> aMyControls = theModelWidget->getControls();
+ foreach(QWidget* eachControl, aMyControls) {
+ eachControl->setEnabled(theEnabled);