X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelection.cpp;h=b81952bd58d0d1b6188dc675235c27b9a59c054f;hb=e85bb4f7065e5750e48a7c77056c80c0fa18e559;hp=1be7f53ee6a44491185f482f3923fc695adca38d;hpb=9fadaebe6d57d0836c7997ee60eb4cfdb67e2ffb;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index 1be7f53ee..b81952bd5 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -180,6 +180,17 @@ bool Model_AttributeSelection::setValue(const ObjectPtr& theContext, aSelLab.ForgetAllAttributes(true); TDataStd_UAttribute::Set(aSelLab, kPART_REF_ID); selectPart(std::dynamic_pointer_cast(theContext), theSubShape); + } else { // check the feature context: parent-Part of this feature should not be used + FeaturePtr aFeatureContext = std::dynamic_pointer_cast(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); @@ -353,20 +364,22 @@ std::shared_ptr Model_AttributeSelection::internalValue(CenterTyp if (aConstr->isInfinite()) return aResult; // empty result } - // whole feature - FeaturePtr aFeature = contextFeature(); - if (aFeature.get()) { - std::list allShapes; - std::list::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 allShapes; + std::list::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; @@ -448,19 +461,26 @@ ResultPtr Model_AttributeSelection::context() ResultPtr aResult = std::dynamic_pointer_cast(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(aPart); - FeaturePtr anOwnerFeature = std::dynamic_pointer_cast(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(aPart); + FeaturePtr anOwnerFeature = std::dynamic_pointer_cast(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(myRef.value()); + if (aFeature.get() && aFeature->results().size() == 1 && + aFeature->firstResult()->groupName() == ModelAPI_ResultConstruction::group()) + return aFeature->firstResult(); } return aResult; } @@ -587,6 +607,10 @@ void Model_AttributeSelection::split( bool Model_AttributeSelection::update() { + FeaturePtr aContextFeature = contextFeature(); + if (aContextFeature.get()) { + return true; + } TDF_Label aSelLab = selectionLabel(); ResultPtr aContext = context(); if (!aContext.get()) @@ -824,7 +848,8 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa std::shared_ptr 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()) {