
Tue, 10/25/2011 - 19:42
Hi,
I have a little problem with my treeView. I try to delete a shape by my own context menu. It works well. I click on the item in the treeview, the contextmenu appear and I click on "Delete", so the shape disappear from the visualization and the name is clean from the treeView. But the row doesn't disappear. So I have an empty row in my treeView. I try to delete the shape with the following code:
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (this->mainXcafDocument->Main());
QModelIndex index = ui->treeView_entityBrowser->currentIndex();
TDF_Label label = deleteTreeItem(this->mainXcafDocument->Main().Root().FindChild(1), index);
aShapeTool->RemoveShape(label);
cadViewer->Context->RemoveAll(1);
cadViewer->redraw();
Furthermore I recognized that the number of my shapes in the this->mainXcafDocument->Main().Root() is not reduced after the RemoveShape-Command.
Any idea?
Regards,
Franz
Tue, 10/25/2011 - 22:51
Hi Franz,
"RemoveShape (const TDF_Label &L) const
Removes shape (whole label and all its sublabels)
Returns False (and does nothing) if shape is not free
or is not top-level shape "
What is the return value for the 'RemoveShape' method?
Pawel
Wed, 10/26/2011 - 12:34
The return value is "True".
But the output of this lines(Child(1:1) comprised the shapes):
cout << this->mainXcafDocument->Main().Root().FindChild(1).FindChild(1).NbChildren() << endl;
aShapeTool->RemoveShape(label);
cout << this->mainXcafDocument->Main().Root().FindChild(1).FindChild(1).NbChildren() << endl;
is still:
5
5
Wed, 10/26/2011 - 13:02
Hi Franz,
labels are never removed from the framework, only their attributes are forgotten. This is why '5' is produced.
So check if a label has any attributes that are not 'forgotten' or 'invalid' to know if this is used. I guess 'TDF_AttributeIterator' would also iterate only 'valid' attributes.
Pawel
Wed, 10/26/2011 - 20:06
Worked. Thank you!