- if ((!aSPFeature) && (!myShape->isNull())) {
- // Processing of external (non-sketch) object
- ObjectPtr aObj = PartSet_Tools::createFixedObjectByEdge(myShape->impl<TopoDS_Shape>(),
- mySelectedObject, mySketch);
- if (aObj) {
- PartSet_WidgetShapeSelector* that = (PartSet_WidgetShapeSelector*) this;
- that->mySelectedObject = aObj;
- } else
- return false;
- } else {
- // Processing of sketch object
- DataPtr aData = myFeature->data();
- if (myShape) {
- AttributePtr aAttr = aData->attribute(attributeID());
- AttributeRefAttrPtr aRefAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(aAttr);
- if (aRefAttr) {
- TopoDS_Shape aShape = myShape->impl<TopoDS_Shape>();
- AttributePtr aPntAttr = PartSet_Tools::findAttributeBy2dPoint(mySelectedObject, aShape, mySketch);
- // this is an alternative, whether the attribute should be set or object in the attribute
- // the first check is the attribute because the object already exist
- // the object is set only if there is no selected attribute
- // test case is - preselection for distance operation, which contains two points selected on lines
- if (aPntAttr)
- aRefAttr->setAttr(aPntAttr);
- else if (mySelectedObject)
- aRefAttr->setObject(mySelectedObject);
- updateObject(myFeature);
- return true;
- }
+ // there is no a sketch feature is selected, but the shape exists, try to create an exernal object
+ // TODO: unite with the same functionality in PartSet_WidgetShapeSelector
+ if (aSPFeature.get() == NULL && myExternalObjectMgr->useExternal()) {
+ GeomShapePtr aShape = theShape;
+ if (!aShape.get()) {
+ ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+ if (aResult.get())
+ aShape = aResult->shape();