From 07a45a94a93a5f1cc3d39f53328c12be074ff69b Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 1 Sep 2016 12:05:29 +0300 Subject: [PATCH] Fix for the problem of selection of the whole constructions of PartSet document from the Part feature. --- src/Model/Model_AttributeSelection.cpp | 3 ++- src/Model/Model_SelectionNaming.cpp | 26 +++++++++++++++++--------- src/Model/Model_SelectionNaming.h | 2 +- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Model/Model_AttributeSelection.cpp b/src/Model/Model_AttributeSelection.cpp index ac66944c5..2e2de8e87 100644 --- a/src/Model/Model_AttributeSelection.cpp +++ b/src/Model/Model_AttributeSelection.cpp @@ -877,7 +877,8 @@ std::string Model_AttributeSelection::namingName(const std::string& theDefaultNa ResultPtr aCont = context(); Model_SelectionNaming aSelNaming(selectionLabel()); - return aSelNaming.namingName(aCont, aSubSh, theDefaultName); + return aSelNaming.namingName( + aCont, aSubSh, theDefaultName, owner()->document() != aCont->document()); } // type ::= COMP | COMS | SOLD | SHEL | FACE | WIRE | EDGE | VERT diff --git a/src/Model/Model_SelectionNaming.cpp b/src/Model/Model_SelectionNaming.cpp index 5bf2d58c9..a3f9ace28 100644 --- a/src/Model/Model_SelectionNaming.cpp +++ b/src/Model/Model_SelectionNaming.cpp @@ -109,13 +109,28 @@ bool isTrivial (const TopTools_ListOfShape& theAncestors, TopTools_IndexedMapOfS } std::string Model_SelectionNaming::namingName(ResultPtr& theContext, - std::shared_ptr theSubSh, const std::string& theDefaultName) + std::shared_ptr theSubSh, const std::string& theDefaultName, + const bool theAnotherDoc) { std::string aName("Undefined name"); if(!theContext.get() || theContext->shape()->isNull()) return !theDefaultName.empty() ? theDefaultName : aName; + + // if it is in result of another part + std::shared_ptr aDoc = + std::dynamic_pointer_cast(theContext->document()); + if (theContext->groupName() == ModelAPI_ResultPart::group()) { + ResultPartPtr aPart = std::dynamic_pointer_cast(theContext); + int anIndex; + return aPart->data()->name() + "/" + aPart->nameInPart(theSubSh, anIndex); + } + if (!theSubSh.get() || theSubSh->isNull()) { // no subshape, so just the whole feature name - return theContext->data()->name(); + // but if it is in another Part, add this part name + std::string aPartName; + if (theAnotherDoc) + aPartName = theContext->document()->kind() + "/"; // PartSet + return aPartName + theContext->data()->name(); } TopoDS_Shape aSubShape = theSubSh->impl(); TopoDS_Shape aContext = theContext->shape()->impl(); @@ -125,13 +140,6 @@ std::string Model_SelectionNaming::namingName(ResultPtr& theContext, BRepTools::Write(aContext, "Context.brep"); } #endif - std::shared_ptr aDoc = - std::dynamic_pointer_cast(theContext->document()); - if (theContext->groupName() == ModelAPI_ResultPart::group()) { - ResultPartPtr aPart = std::dynamic_pointer_cast(theContext); - int anIndex; - return aPart->data()->name() + "/" + aPart->nameInPart(theSubSh, anIndex); - } // add the result name to the name of the shape (it was in BodyBuilder, but did not work on Result rename) bool isNeedContextName = theContext->shape().get() && !theContext->shape()->isEqual(theSubSh); diff --git a/src/Model/Model_SelectionNaming.h b/src/Model/Model_SelectionNaming.h index 82f1eca7a..ca513fe76 100644 --- a/src/Model/Model_SelectionNaming.h +++ b/src/Model/Model_SelectionNaming.h @@ -30,7 +30,7 @@ public: /// Produces the string-name for the selected shape std::string namingName(ResultPtr& theContext, std::shared_ptr theSubSh, - const std::string& theDefaultName); + const std::string& theDefaultName, const bool theAnotherDoc); /// Makes a selection by the string-name /// \param theType string of the type of the shape -- 2.39.2