ResultPtr aContext = anAttrSelection->context();
if(!aContext.get()) {
FeaturePtr aContFeat = anAttrSelection->contextFeature();
- if (!aContFeat.get()) {
+ if (!aContFeat.get() || !aContFeat->results().size()) {
theError = "Error: Empty selection context.";
return false;
}
}
}
std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
- if(!aShape.get()) {
+ if(!aShape.get() && aContext.get()) {
GeomShapePtr aContextShape = aContext->shape();
aShape = aContextShape;
}
}
ResultPtr aContext = anAttrSelection->context();
if(!aContext.get()) {
- theError = "Error: Empty selection context.";
- return false;
+ FeaturePtr aContFeat = anAttrSelection->contextFeature();
+ if (!aContFeat.get() || !aContFeat->results().size() ||
+ aContFeat->firstResult()->groupName() != ModelAPI_ResultBody::group()) {
+ theError = "Error: Empty selection context.";
+ return false;
+ }
+ if (aContFeat->results().size() == 1)
+ aContext = aContFeat->firstResult();
+ else {
+ theError = "Error: Too many shapes selected.";
+ return false;
+ }
}
ResultBodyPtr aContextOwner = ModelAPI_Tools::bodyOwner(aContext);
if (anOwner->shapeType() != GeomAPI_Shape::SOLID &&
anOwner->shapeType() != GeomAPI_Shape::COMPSOLID) {
- theError = "Error: Not all selected shapes are sub-shapes of solids";
+ theError = "Error: Not all selected shapes are sub-shapes of solids.";
return false;
}
return false;
}
ResultPtr aContext = anAttrSelection->context();
- if (!aContext.get()) {
- theError = "Error: Empty selection context.";
- return false;
+ if(!aContext.get()) {
+ FeaturePtr aContFeat = anAttrSelection->contextFeature();
+ if (!aContFeat.get() || !aContFeat->results().size() ||
+ aContFeat->firstResult()->groupName() != ModelAPI_ResultBody::group()) {
+ theError = "Error: Empty selection context.";
+ return false;
+ }
}
ResultConstructionPtr aResultConstruction =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
return false;
}
ResultPtr aContext = anAttrSelection->context();
- if (!aContext.get()) {
- theError = "Error: empty selection context.";
- return false;
+ if(!aContext.get()) {
+ FeaturePtr aContFeat = anAttrSelection->contextFeature();
+ if (!aContFeat.get() || !aContFeat->results().size() ||
+ aContFeat->firstResult()->groupName() != ModelAPI_ResultBody::group()) {
+ theError = "Error: Empty selection context.";
+ return false;
+ }
}
- FeaturePtr aFeature = ModelAPI_Feature::feature(aContext);
+ FeaturePtr aFeature = anAttrSelection->contextFeature().get() ?
+ anAttrSelection->contextFeature() : ModelAPI_Feature::feature(aContext);
if (!aFeature.get()) {
theError = "Error: empty feature.";
return false;
return false;
}
std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
- GeomShapePtr aContextShape = aContext->shape();
if (!aShape.get()) {
+ GeomShapePtr aContextShape = aContext->shape();
aShape = aContextShape;
}
if (!aShape.get()) {
theError = "Error: empty shape.";
return false;
}
- if (!aShape->isEqual(aContextShape)) {
+ if (aContext.get() && !aShape->isEqual(aContext->shape())) {
theError = "Error: Local selection not allowed.";
return false;
}
return false;
}
ResultPtr aContext = anAttrSelection->context();
- if (!aContext.get()) {
- theError = "Error: Empty selection context.";
- return false;
+ if(!aContext.get()) {
+ FeaturePtr aContFeat = anAttrSelection->contextFeature();
+ if (!aContFeat.get() || !aContFeat->results().size() ||
+ aContFeat->firstResult()->groupName() != ModelAPI_ResultBody::group()) {
+ theError = "Error: Empty selection context.";
+ return false;
+ }
}
ResultConstructionPtr aResultConstruction =
std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aContext);
return false;
}
std::shared_ptr<GeomAPI_Shape> aShape = anAttrSelection->value();
- GeomShapePtr aContextShape = aContext->shape();
if (!aShape.get()) {
+ GeomShapePtr aContextShape = aContext->shape();
aShape = aContextShape;
}
if (!aShape.get()) {
theError = "Error: Empty shape.";
return false;
}
- if (!aShape->isEqual(aContextShape)) {
+ if (aContext.get() && !aShape->isEqual(aContext->shape())) {
theError = "Error: Local selection not allowed.";
return false;
}