#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultGroup.h>
#include <ModelAPI_ResultPart.h>
#include <ModelAPI_CompositeFeature.h>
#include <ModelAPI_Tools.h>
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;
aSelLab.ForgetAllAttributes(true);
TDataStd_UAttribute::Set(aSelLab, kPART_REF_ID);
selectPart(std::dynamic_pointer_cast<ModelAPI_Result>(theContext), theSubShape);
+ } else if (theContext->groupName() == ModelAPI_ResultGroup::group()) {
+ aSelLab.ForgetAllAttributes(true);
+ TDataStd_UAttribute::Set(aSelLab, kSIMPLE_REF_ID);
} 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()) {
// 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();
std::shared_ptr<GeomAPI_Shape> aResult;
if (myRef.isInitialized()) {
TDF_Label aSelLab = selectionLabel();
- if (aSelLab.IsAttribute(kSIMPLE_REF_ID)) { // it is just reference to shape, not sub-shape
+ // it is just reference to shape, not sub-shape
+ if (aSelLab.IsAttribute(kSIMPLE_REF_ID) || aSelLab.IsAttribute(kPART_REF_ID)) {
ResultPtr aContext = context();
return aContext.get() != NULL;
}
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());
}
if(!this->isInitialized())
return !theDefaultName.empty() ? theDefaultName : aName;
+ // not argument has not parametric name (filters)
+ if (!this->isArgument() || (myParent && !myParent->isArgument())) {
+ GeomShapePtr aShape = value();
+ if (!aShape.get() && context().get())
+ aShape = context()->shape();
+ std::string aName;
+ if (aShape.get()) {
+ aName = aShape->shapeTypeStr();
+ if (myParent) {
+ aName += std::string("_") +
+ TCollection_AsciiString(selectionLabel().Father().Tag()).ToCString();
+ }
+ }
+ return aName;
+ }
+
CenterType aCenterType = NOT_CENTER;
std::shared_ptr<GeomAPI_Shape> aSubSh = internalValue(aCenterType);
ResultPtr aCont = context();
if (!aContData.get() || !aContData->isValid())
return;
TDF_Label aContLab = aContData->shapeLab(); // named shape where the selected context is located
+
+ // checking this may be just a reference to another context (same shape), so use that label
Handle(TNaming_NamedShape) aContNS;
+ Handle(TDF_Reference) aRefAttr;
+ while(!aContLab.FindAttribute(TNaming_NamedShape::GetID(), aContNS) &&
+ aContLab.FindAttribute(TDF_Reference::GetID(), aRefAttr))
+ aContLab = aRefAttr->Get();
+
if (!aContLab.FindAttribute(TNaming_NamedShape::GetID(), aContNS)) {
bool aFoundNewContext = true;
ResultPtr aNewContext = aContext;
continue;
FeaturePtr aRefFeat = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRef)->owner());
+
if (aRefFeat.get() && aRefFeat != owner() && aRefFeat->firstResult().get()) {
+ // check the reference is concealed: #2900
+ ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+ if (!aValidators->isConcealed(aRefFeat->getKind(), (*aRef)->id()))
+ continue;
FeaturePtr aThisFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(owner());
if (!aDoc->isLaterByDep(aRefFeat, aThisFeature)) { // found better feature
aFoundNewContext = true;
continue;
}
+ ResultPtr aNewContext = *aNewCont;
+ if (aValueShape.get()) { // #2892 if context is higher level result, search this sub in lower
+ ResultBodyPtr aBodyContext = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aNewContext);
+ if (aBodyContext.get() && aBodyContext->numberOfSubs() != 0) {
+ std::list<ResultPtr> aLower;
+ ModelAPI_Tools::allSubs(aBodyContext, aLower, true);
+ for(std::list<ResultPtr>::iterator aL = aLower.begin(); aL != aLower.end(); aL++) {
+ GeomShapePtr aLShape = (*aL)->shape();
+ if (aLShape.get() && !aLShape->isNull()) {
+ if (aLShape->isSubShape(aValueShape, false)) {
+ aNewContext = *aL;
+ break;
+ }
+ }
+ }
+ }
+ }
+
if (aFirst) {
- if (!myParent || !myParent->isInList(*aNewCont, aValueShape)) { // avoid duplicates
- setValue(*aNewCont, aValueShape);
+ if (!myParent || !myParent->isInList(aNewContext, aValueShape)) { // avoid duplicates
+ setValue(aNewContext, aValueShape);
aFirst = false;
}
} else if (myParent) {
- if (!myParent->isInList(*aNewCont, aValueShape)) // avoid addition of duplicates
- myParent->append(*aNewCont, aValueShape);
+ if (!myParent->isInList(aNewContext, aValueShape)) // avoid addition of duplicates
+ myParent->append(aNewContext, aValueShape);
}
}
if (aFirst) { // nothing was added, all results were deleted