return aHasObject;
}
-void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
+bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
const GeomShapePtr& theShape, ModuleBase_IWorkshop* theWorkshop,
const bool theTemporarily, const bool theCheckIfAttributeHasObject)
{
if (!theAttribute.get())
- return;
+ return false;
+ bool isDone = true;
std::string aType = theAttribute->attributeType();
if (aType == ModelAPI_AttributeReference::typeId()) {
AttributeReferencePtr aRef = std::dynamic_pointer_cast<ModelAPI_AttributeReference>(theAttribute);
}
else if (aType == ModelAPI_AttributeRefList::typeId()) {
AttributeRefListPtr aRefListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(theAttribute);
- if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject))
- aRefListAttr->append(theObject);
+ if (!theCheckIfAttributeHasObject || !aRefListAttr->isInList(theObject)) {
+ if (theObject.get())
+ aRefListAttr->append(theObject);
+ else
+ isDone = false;
+ }
}
else if (aType == ModelAPI_AttributeRefAttrList::typeId()) {
AttributeRefAttrListPtr aRefAttrListAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
aRefAttrListAttr->append(anAttribute);
}
else {
- if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject))
- aRefAttrListAttr->append(theObject);
+ if (!theCheckIfAttributeHasObject || !aRefAttrListAttr->isInList(theObject)) {
+ if (theObject.get())
+ aRefAttrListAttr->append(theObject);
+ else
+ isDone = false;
+ }
}
}
+ return isDone;
}
GeomShapePtr getShape(const AttributePtr& theAttribute, ModuleBase_IWorkshop* theWorkshop)
/// \param theTemporarily if it is true, do not store and name the added in the data framework
/// \param theCheckIfAttributeHasObject if it is true, the check isInList is called
/// It is useful for attribute selection
-MODULEBASE_EXPORT void setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
+/// \return true if the attribute is filled with the given parameters
+MODULEBASE_EXPORT bool setObject(const AttributePtr& theAttribute, const ObjectPtr& theObject,
const std::shared_ptr<GeomAPI_Shape>& theShape,
ModuleBase_IWorkshop* theWorkshop,
const bool theTemporarily,
getGeomSelection(thePrs, anObject, aShape);
// the last flag is to be depending on hasObject is called before. To be corrected later
- ModuleBase_Tools::setObject(attribute(), anObject, aShape, myWorkshop, myIsInValidate, true);
- return true;
+ return ModuleBase_Tools::setObject(attribute(), anObject, aShape, myWorkshop, myIsInValidate, true);
}
//********************************************************************
std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
// 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()) {
+ if (aSPFeature.get() == NULL)
+ theObject = NULL;
+ if (myExternalObjectMgr->useExternal()) {
GeomShapePtr aShape = theShape;
if (!aShape.get()) {
ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
// 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()) {
+ if (aSPFeature.get() == NULL)
+ theObject = NULL;
+ if (myExternalObjectMgr->useExternal()) {
GeomShapePtr aShape = theShape;
if (!aShape.get()) {
ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);