- // Hide sketcher result
- CompositeFeaturePtr aSketchFeature =
- std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
- std::list<ResultPtr> aResults = aSketchFeature->results();
- std::list<ResultPtr>::const_iterator aIt;
- for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
- (*aIt)->setDisplayed(false);
- }
- aSketchFeature->setDisplayed(false);
- static Events_Loop* aLoop = Events_Loop::loop();
- aLoop->flush(aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
-
- // Add Selected body were created the sketcher to list of selected objects
- std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::OBJECTS_ID();
- AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute);
- if (aSelList.get()) {
- DataPtr aData = aSketchFeature->data();
- AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
- (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
- ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr();
- if (aRes.get()) {
- SessionPtr aMgr = ModelAPI_Session::get();
- ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute);
- std::string aValidatorID, anError;
- aSelList->append(aRes, GeomShapePtr());
- if (aFactory->validate(anAttribute, aValidatorID, anError))
- updateObject(aCompFeature);
- else
- aSelList->clear();
- }
+ if (aCompFeature->numberOfSubs() == 0) {
+ // call activateWidget() of the parent to connect to the viewer seleciton
+ activateSelectionControl();
+ }
+ else {
+ // check if the created sketch is valid. If it is invalid, it will be deleted with warning else
+ /// the attribute selection list will be filled by result of this sketch.
+ setVisibleSelectionControl(false);
+
+ // Update value in attribute selection list
+ 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)
+ aWidget->restoreValue();
+ }
+
+ // Hide sketcher result
+ CompositeFeaturePtr aSketchFeature =
+ std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aCompFeature->subFeature(0));
+ std::list<ResultPtr> aResults = aSketchFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ (*aIt)->setDisplayed(false);
+ }
+ aSketchFeature->setDisplayed(false);
+ static Events_Loop* aLoop = Events_Loop::loop();
+ aLoop->flush(aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
+ // Add Selected body were created the sketcher to list of selected objects
+ std::string anObjectsAttribute = FeaturesPlugin_CompositeBoolean::OBJECTS_ID();
+ AttributeSelectionListPtr aSelList = aCompFeature->data()->selectionList(anObjectsAttribute);
+ if (aSelList.get()) {
+ DataPtr aData = aSketchFeature->data();
+ AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+ (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+ ResultPtr aRes = aSelAttr.get() ? aSelAttr->context() : ResultPtr();
+ if (aRes.get()) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+ AttributePtr anAttribute = myFeature->attribute(anObjectsAttribute);
+ std::string aValidatorID, anError;
+ aSelList->append(aRes, GeomShapePtr());
+ if (aFactory->validate(anAttribute, aValidatorID, anError))
+ updateObject(aCompFeature);
+ else
+ aSelList->clear();