std::shared_ptr<GeomAPI_Shape> Model_AttributeSelection::value()
{
if (myTmpContext.get() || myTmpSubShape.get()) {
- return myTmpSubShape;
+ return myTmpSubShape.get() ? myTmpSubShape : myTmpContext->shape();
}
std::shared_ptr<GeomAPI_Shape> aResult;
std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
aShape->setImpl<TopoDS_Shape>(new TopoDS_Shape(aComp));
selectConstruction(aContext, aShape);
+ } else {
+ // For correct naming selection, put the shape into the naming structure.
+ // It seems sub-shapes are not needed: only this shape is (and can be ) selected.
+ TNaming_Builder aBuilder(aSelLab);
+ aBuilder.Generated(aContext->shape()->impl<TopoDS_Shape>());
+ std::shared_ptr<Model_Document> aMyDoc =
+ std::dynamic_pointer_cast<Model_Document>(owner()->document());
+ std::string aName = aContext->data()->name();
+ aMyDoc->addNamingName(aSelLab, aName);
+ TDataStd_Name::Set(aSelLab, aName.c_str());
}
return setInvalidIfFalse(aSelLab, aContext->shape() && !aContext->shape()->isNull());
}
if (aSelLab.IsAttribute(kPART_REF_ID)) { // it is reference to the part object
std::shared_ptr<GeomAPI_Shape> aNoSelection;
- return setInvalidIfFalse(aSelLab, selectPart(aContext, aNoSelection, true));
+ bool aResult = selectPart(aContext, aNoSelection, true);
+ if (aResult) {
+ owner()->data()->sendAttributeUpdated(this);
+ }
+ return setInvalidIfFalse(aSelLab, aResult);
}
if (aContext->groupName() == ModelAPI_ResultBody::group()) {
return setInvalidIfFalse(aSelLab, false);
}
- if (aShapeType == TopAbs_FACE) { // compound is for the whole sketch selection
+ if (aShapeType == TopAbs_FACE || aShapeType == TopAbs_WIRE) { // compound is for the whole sketch selection
// If this is a wire with plane defined thin it is a sketch-like object
if (!aConstructionContext->facesNum()) // no faces, update can not work correctly
return setInvalidIfFalse(aSelLab, false);
}
}
if (aNewSelected) { // store this new selection
+ if (aShapeType == TopAbs_WIRE) { // just get a wire from face to have wire
+ TopExp_Explorer aWireExp(aNewSelected->impl<TopoDS_Shape>(), TopAbs_WIRE);
+ if (aWireExp.More()) {
+ aNewSelected.reset(new GeomAPI_Shape);
+ aNewSelected->setImpl<TopoDS_Shape>(new TopoDS_Shape(aWireExp.Current()));
+ }
+ }
selectConstruction(aContext, aNewSelected);
owner()->data()->sendAttributeUpdated(this);
return setInvalidIfFalse(aSelLab, true);
if (!theAdditionalName.empty())
aName<<theAdditionalName<<"/";
if (theShape.ShapeType() == TopAbs_FACE) aName<<"Face";
+ else if (theShape.ShapeType() == TopAbs_WIRE) aName<<"Wire";
else if (theShape.ShapeType() == TopAbs_EDGE) aName<<"Edge";
else if (theShape.ShapeType() == TopAbs_VERTEX) aName<<"Vertex";