From: mpv Date: Wed, 2 Mar 2016 08:44:45 +0000 (+0300) Subject: Fix for the issue #1346 : the copy of NamedShapes keeps the previous shapes now. X-Git-Tag: V_2.2.0~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=af80cfd8be99a0a23cb2f755e62be141107a0591;p=modules%2Fshaper.git Fix for the issue #1346 : the copy of NamedShapes keeps the previous shapes now. --- diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index a51cfae97..85f522a6e 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -85,6 +85,44 @@ void Model_AttributeSelectionList::removeLast() } } +#include +#include + +// copies named shapes: we need the implementation of this +static void CopyNS(const Handle(TNaming_NamedShape)& theFrom, + const Handle(TDF_Attribute)& theTo) +{ + TDF_Label aLab = theTo->Label(); + TNaming_Builder B(aLab); + + TNaming_Iterator It (theFrom); + for ( ;It.More() ; It.Next()) { + const TopoDS_Shape& OS = It.OldShape(); + const TopoDS_Shape& NS = It.NewShape(); + TNaming_Evolution Status = It.Evolution(); + + switch (Status) { + case TNaming_PRIMITIVE : + B.Generated(NS); + break; + case TNaming_GENERATED : + B.Generated(OS, NS); + break; + case TNaming_MODIFY : + B.Modify(OS, NS); + break; + case TNaming_DELETE : + B.Delete (OS); + break; + case TNaming_SELECTED : + B.Select(NS, OS); + break; + default: + break; + } + } +} + /// makes copy of all attributes on the given label and all sub-labels static void copyAttrs(TDF_Label theSource, TDF_Label theDestination) { TDF_AttributeIterator anAttrIter(theSource); @@ -95,8 +133,14 @@ static void copyAttrs(TDF_Label theSource, TDF_Label theDestination) { aTargetAttr = anAttrIter.Value()->NewEmpty(); theDestination.AddAttribute(aTargetAttr); } - Handle(TDF_RelocationTable) aRelocTable = new TDF_RelocationTable(); // no relocation, empty map - anAttrIter.Value()->Paste(aTargetAttr, aRelocTable); + // for named shape copy exact shapes (in NamedShape Paste method the CopyTool is used) + Handle(TNaming_NamedShape) aNS = Handle(TNaming_NamedShape)::DownCast(anAttrIter.Value()); + if (aNS.IsNull()) { + Handle(TDF_RelocationTable) aRelocTable = new TDF_RelocationTable(); // no relocation, empty map + anAttrIter.Value()->Paste(aTargetAttr, aRelocTable); + } else { + CopyNS(aNS, aTargetAttr); + } } // copy the sub-labels content TDF_ChildIterator aSubLabsIter(theSource);