aSelLab.ForgetAllAttributes(true);
TDataStd_UAttribute::Set(aSelLab, kPART_REF_ID);
selectPart(std::dynamic_pointer_cast<ModelAPI_Result>(theContext), theSubShape);
+ } else { // check the feature context: parent-Part of this feature should not be used
+ FeaturePtr aFeatureContext = std::dynamic_pointer_cast<ModelAPI_Feature>(theContext);
+ if (aFeatureContext.get()) {
+ if (owner()->document() != aFeatureContext->document()) {
+ aSelLab.ForgetAllAttributes(true);
+ myRef.setValue(ObjectPtr());
+ if (aToUnblock)
+ owner()->data()->blockSendAttributeUpdated(false);
+ return false;
+ }
+ }
}
owner()->data()->sendAttributeUpdated(this);
if (aConstr->isInfinite())
return aResult; // empty result
}
- // whole feature
- FeaturePtr aFeature = contextFeature();
- if (aFeature.get()) {
- std::list<GeomShapePtr> allShapes;
- std::list<ResultPtr>::const_iterator aRes = aFeature->results().cbegin();
- for (; aRes != aFeature->results().cend(); aRes++) {
- if (aRes->get() && !(*aRes)->isDisabled()) {
- GeomShapePtr aShape = (*aRes)->shape();
- if (aShape.get() && !aShape->isNull()) {
- allShapes.push_back(aShape);
+ if (!aConstr.get()) { // for construction context, return empty result as usual even
+ // the whole feature is selected
+ FeaturePtr aFeature = contextFeature();
+ if (aFeature.get()) {
+ std::list<GeomShapePtr> allShapes;
+ std::list<ResultPtr>::const_iterator aRes = aFeature->results().cbegin();
+ for (; aRes != aFeature->results().cend(); aRes++) {
+ if (aRes->get() && !(*aRes)->isDisabled()) {
+ GeomShapePtr aShape = (*aRes)->shape();
+ if (aShape.get() && !aShape->isNull()) {
+ allShapes.push_back(aShape);
+ }
}
}
+ return GeomAlgoAPI_CompoundBuilder::compound(allShapes);
}
- return GeomAlgoAPI_CompoundBuilder::compound(allShapes);
}
Handle(TNaming_NamedShape) aSelection;
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(myRef.value());
// for parts there could be same-data result, so take the last enabled
- if (aResult.get() && aResult->groupName() == ModelAPI_ResultPart::group()) {
- int aSize = aResult->document()->size(ModelAPI_ResultPart::group());
- for(int a = aSize - 1; a >= 0; a--) {
- ObjectPtr aPart = aResult->document()->object(ModelAPI_ResultPart::group(), a);
- if (aPart.get() && aPart->data() == aResult->data()) {
- ResultPtr aPartResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPart);
- FeaturePtr anOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
- // check that this result is not this-feature result (it is forbidden t oselect itself)
- if (anOwnerFeature.get() && anOwnerFeature->firstResult() != aPartResult) {
- return aPartResult;
+ if (aResult.get()) {
+ if(aResult->groupName() == ModelAPI_ResultPart::group()) {
+ int aSize = aResult->document()->size(ModelAPI_ResultPart::group());
+ for(int a = aSize - 1; a >= 0; a--) {
+ ObjectPtr aPart = aResult->document()->object(ModelAPI_ResultPart::group(), a);
+ if(aPart.get() && aPart->data() == aResult->data()) {
+ ResultPtr aPartResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPart);
+ FeaturePtr anOwnerFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
+ // check that this result is not this-feature result (it is forbidden t oselect itself)
+ if(anOwnerFeature.get() && anOwnerFeature->firstResult() != aPartResult) {
+ return aPartResult;
+ }
}
}
}
+ } else { // if feature - construction is selected, it has only one result, return this result
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(myRef.value());
+ if (aFeature.get() && aFeature->results().size() == 1 &&
+ aFeature->firstResult()->groupName() == ModelAPI_ResultConstruction::group())
+ return aFeature->firstResult();
}
return aResult;
}
bool Model_AttributeSelection::update()
{
+ FeaturePtr aContextFeature = contextFeature();
+ if (aContextFeature.get()) {
+ return true;
+ }
TDF_Label aSelLab = selectionLabel();
ResultPtr aContext = context();
if (!aContext.get())
std::shared_ptr<GeomAPI_Shape> aSubSh = internalValue(aCenterType);
ResultPtr aCont = context();
- if (!aCont.get()) {
+ if (!aCont.get() ||
+ (aCont->groupName() == ModelAPI_ResultConstruction::group() && contextFeature().get())) {
// selection of a full feature
FeaturePtr aFeatureCont = contextFeature();
if (aFeatureCont.get()) {