mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-07-30 13:05:50 +03:00
0028748: XCAFDoc_GraphNode does not restore child on Undo
Fixed calling Backup method. Now it called where data really changed.
This commit is contained in:
parent
8c745be5e0
commit
9e6cdbcad5
@ -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) );
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,9 @@
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <XCAFDoc.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_GraphNode.hxx>
|
||||
#include <XCAFDoc_LayerTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XDEDRAW_Layers.hxx>
|
||||
@ -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);
|
||||
}
|
||||
|
23
tests/bugs/xde/bug28748
Normal file
23
tests/bugs/xde/bug28748
Normal file
@ -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"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user