From: dbv Date: Wed, 17 May 2017 15:43:59 +0000 (+0300) Subject: 0028748: XCAFDoc_GraphNode does not restore child on Undo X-Git-Tag: V7_2_0_beta~134 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=9e6cdbcad52eb3b65600960cb2dc9bff587fd2e1;p=occt.git 0028748: XCAFDoc_GraphNode does not restore child on Undo Fixed calling Backup method. Now it called where data really changed. --- diff --git a/src/XCAFDoc/XCAFDoc_GraphNode.cxx b/src/XCAFDoc/XCAFDoc_GraphNode.cxx index 9385cbb0a3..9aa7af0e55 100644 --- a/src/XCAFDoc/XCAFDoc_GraphNode.cxx +++ b/src/XCAFDoc/XCAFDoc_GraphNode.cxx @@ -140,7 +140,6 @@ Standard_Integer XCAFDoc_GraphNode::SetChild(const Handle(XCAFDoc_GraphNode)& Ch void XCAFDoc_GraphNode::UnSetFather(const Handle(XCAFDoc_GraphNode)& F) { - Backup(); Standard_Integer Findex = FatherIndex(F); if (Findex != 0) F->UnSetChildlink(this); @@ -167,6 +166,7 @@ void XCAFDoc_GraphNode::UnSetFather(const Standard_Integer Findex) void XCAFDoc_GraphNode::UnSetFatherlink(const Handle(XCAFDoc_GraphNode)& F) { + Backup(); myFathers.Remove( FatherIndex(F) ); } @@ -177,7 +177,6 @@ void XCAFDoc_GraphNode::UnSetFatherlink(const Handle(XCAFDoc_GraphNode)& F) void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch) { - Backup(); Standard_Integer Chindex = ChildIndex(Ch); if (Chindex != 0) Ch->UnSetFatherlink(this); @@ -204,6 +203,7 @@ void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch) void XCAFDoc_GraphNode::UnSetChildlink(const Handle(XCAFDoc_GraphNode)& Ch) { + Backup(); myChildren.Remove( ChildIndex(Ch) ); } diff --git a/src/XDEDRAW/XDEDRAW_Layers.cxx b/src/XDEDRAW/XDEDRAW_Layers.cxx index 858c072044..14afe28804 100644 --- a/src/XDEDRAW/XDEDRAW_Layers.cxx +++ b/src/XDEDRAW/XDEDRAW_Layers.cxx @@ -24,7 +24,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -394,6 +396,67 @@ static Standard_Integer isVisible (Draw_Interpretor& di, Standard_Integer argc, return 0; } +static Standard_Integer getLayerRefs(Draw_Interpretor& theDI, + Standard_Integer theArgc, + const char** theArgv) +{ + if (theArgc != 3) + { + theDI << "Use: " << theArgv[0] << "DocName Label\n"; + return 1; + } + + Handle(TDocStd_Document) aDoc; + DDocStd::GetDocument(theArgv[1], aDoc); + if (aDoc.IsNull()) + { + theDI << "Error: \"" << theArgv[1] << "\" is not a document.\n"; + return 1; + } + + TDF_Label aLabel; + TDF_Tool::Label(aDoc->GetData(), theArgv[2], aLabel); + if (aLabel.IsNull()) + { + theDI << "Error: Document \"" << theArgv[1] << "\" does not have a label \"" << theArgv[2] << "\".\n"; + return 1; + } + + Handle(XCAFDoc_GraphNode) aGraphNode; + aLabel.FindAttribute(XCAFDoc::LayerRefGUID(), aGraphNode); + if (aGraphNode.IsNull()) + { + theDI << "Error: Label \"" << theArgv[2] << "\" does not have a layer ref.\n"; + return 1; + } + + if (aGraphNode->NbChildren() > 0) + { + theDI << "Label \"" << theArgv[2] << "\" childs:\n"; + for (int anIndex = 1; anIndex <= aGraphNode->NbChildren(); ++anIndex) + { + Handle(XCAFDoc_GraphNode) aChild = aGraphNode->GetChild(anIndex); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aChild->Label(), anEntry); + theDI << anEntry << "\n"; + } + } + + if (aGraphNode->NbFathers() > 0) + { + theDI << "Label \"" << theArgv[2] << "\" fathers:\n"; + for (int anIndex = 1; anIndex <= aGraphNode->NbFathers(); ++anIndex) + { + Handle(XCAFDoc_GraphNode) aFather = aGraphNode->GetFather(anIndex); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aFather->Label(), anEntry); + theDI << anEntry << "\n"; + } + } + + return 0; +} + //======================================================================= //function : InitCommands //purpose : @@ -455,4 +518,7 @@ void XDEDRAW_Layers::InitCommands(Draw_Interpretor& di) di.Add ("XIsVisible","DocName {layerLable|StringLayer} \t: Return 1 if layer is visible, 0 if not", __FILE__, isVisible, g); + + di.Add("XGetLayerRefs", "DocName Label \t: Prints layers labels which are referenced in passed label or prints labels which reference passed layer label.", + __FILE__, getLayerRefs, g); } diff --git a/tests/bugs/xde/bug28748 b/tests/bugs/xde/bug28748 new file mode 100644 index 0000000000..2aa5d9cd57 --- /dev/null +++ b/tests/bugs/xde/bug28748 @@ -0,0 +1,23 @@ +puts "==========" +puts "OCC28748" +puts "==========" +puts "" +########################################################### +# XCAFDoc_GraphNode does not restore child on Undo +########################################################### + +pload DCAF + +ReadStep d [locate_data_file bug21802_as1-oc-214.stp] +UndoLimit d 1 +OpenCommand d +XUnSetLayer d 0:1:1:3 256 +CommitCommand d +Undo d + +set info [XGetLayerRefs d 0:1:3:1] +if { [regexp "0:1:1:3" $info] != 1 } { + puts "Error: child not restored on Undo" +} else { + puts "OK: child restored on Undo" +}