X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_AttributeSelection.cpp;h=d35ea9cee6f24cfb6bf52730b097b95c56fcd824;hb=457b5e1d4368db3aead4592ad2b254bc47949f51;hp=ec6c691f8e8a2b0efcd83f8ec6084f6e3ebd2270;hpb=121c3643dc91171d185c470a90171d36de5b02e1;p=modules%2Fshaper.git diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index ec6c691f8..d35ea9cee 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -148,7 +148,8 @@ void Model_AttributeSelection::setValue(const ResultPtr& theContext, aBuilder.Generated(theContext->shape()->impl()); std::shared_ptr aMyDoc = std::dynamic_pointer_cast(owner()->document()); - std::string aName = theContext->data()->name(); + std::string aName = contextName(theContext); + // for selection in different document, add the document name aMyDoc->addNamingName(aSelLab, aName); TDataStd_Name::Set(aSelLab, aName.c_str()); } else { // for sketch the naming is needed in DS @@ -417,7 +418,7 @@ bool Model_AttributeSelection::update() aBuilder.Generated(aContext->shape()->impl()); std::shared_ptr aMyDoc = std::dynamic_pointer_cast(owner()->document()); - std::string aName = aContext->data()->name(); + std::string aName = contextName(aContext); aMyDoc->addNamingName(aSelLab, aName); TDataStd_Name::Set(aSelLab, aName.c_str()); } @@ -714,8 +715,9 @@ void Model_AttributeSelection::selectConstruction( // saving of context is enough: result construction contains exactly the needed shape TNaming_Builder aBuilder(selectionLabel()); aBuilder.Generated(aSubShape); - aMyDoc->addNamingName(selectionLabel(), theContext->data()->name()); - TDataStd_Name::Set(selectionLabel(), theContext->data()->name().c_str()); + std::string aName = contextName(theContext); + aMyDoc->addNamingName(selectionLabel(), aName); + TDataStd_Name::Set(selectionLabel(), aName.c_str()); return; } std::shared_ptr aData = std::dynamic_pointer_cast(owner()->data()); @@ -990,3 +992,20 @@ void Model_AttributeSelection::setId(int theID) setValue(aContext, aSelection); } +std::string Model_AttributeSelection::contextName(const ResultPtr& theContext) const +{ + std::string aResult; + if (owner()->document() != theContext->document()) { + if (theContext->document() == ModelAPI_Session::get()->moduleDocument()) { + aResult = theContext->document()->kind() + "/"; + } else { + ResultPtr aDocRes = ModelAPI_Tools::findPartResult( + ModelAPI_Session::get()->moduleDocument(), theContext->document()); + if (aDocRes.get()) { + aResult = aDocRes->data()->name() + "/"; + } + } + } + aResult += theContext->data()->name(); + return aResult; +}