bool Model_AttributeSelection::setValue(const ObjectPtr& theContext,
const std::shared_ptr<GeomAPI_Shape>& theSubShape, const bool theTemporarily)
{
- if (theTemporarily &&
- (!theContext.get() || theContext->groupName() != ModelAPI_Feature::group())) {
+ if (theTemporarily) {
// just keep the stored without DF update
- myTmpContext = std::dynamic_pointer_cast<ModelAPI_Result>(theContext);
+ myTmpContext = theContext;
myTmpSubShape = theSubShape;
owner()->data()->sendAttributeUpdated(this);
return true;
// it is just reference to construction.
return myTmpSubShape;
}
- return myTmpSubShape.get() ? myTmpSubShape : myTmpContext->shape();
+ FeaturePtr aFeature =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(myTmpContext);
+ if (aFeature.get()) {
+ // it is just reference to construction.
+ return myTmpSubShape;
+ }
+ return myTmpSubShape.get() ? myTmpSubShape :
+ std::dynamic_pointer_cast<ModelAPI_Result>(myTmpContext)->shape();
}
TDF_Label aSelLab = selectionLabel();
return ResultPtr();
if (myTmpContext.get() || myTmpSubShape.get()) {
- return myTmpContext;
+ return std::dynamic_pointer_cast<ModelAPI_Result>(myTmpContext);
}
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(myRef.value());
}
FeaturePtr Model_AttributeSelection::contextFeature() {
- if (myTmpContext.get() || myTmpSubShape.get()) {
- return FeaturePtr(); // feature can not be selected temporarily
+ if (myTmpContext.get()) {
+ return std::dynamic_pointer_cast<ModelAPI_Feature>(myTmpContext);
}
return std::dynamic_pointer_cast<ModelAPI_Feature>(myRef.value());
}
{
Model_AttributeReference myRef; ///< The reference functionality re-usage
/// temporarily storages to avoid keeping in the data structure if not needed
- ResultPtr myTmpContext;
+ ObjectPtr myTmpContext;
/// temporarily storages to avoid keeping in the data structure if not needed
std::shared_ptr<GeomAPI_Shape> myTmpSubShape;
/// temporarily storages to avoid keeping in the data structure if not needed
}
else
aValid = false;
- aSelectAttr->setValue(ObjectPtr(), GeomShapePtr(), true);
+ //aSelectAttr->setValue(ObjectPtr(), GeomShapePtr(), true);
}
else {
ResultPtr aResult = aFeature->firstResult();
if (!aValid) {
// Clear attribute if it still has selection
AttributePtr anAttr = attribute();
- anAttr->reset();
+ std::string aType = anAttr->attributeType();
+ if (aType == ModelAPI_AttributeSelection::typeId()) {
+ AttributeSelectionPtr aSelectAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(anAttr);
+ aSelectAttr->removeTemporaryValues();
+ }
}
return aValid;
}