1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-11 10:44:53 +03:00

XCAF: remove subshape/attr note/all notes

This commit is contained in:
snn 2017-05-11 11:31:57 +03:00 committed by apl
parent 1bebdb9c92
commit 2c465c8c0c
2 changed files with 142 additions and 0 deletions

View File

@ -444,6 +444,72 @@ XCAFDoc_NotesTool::RemoveNote(const TDF_Label& theNoteLabel,
return Standard_True; return Standard_True;
} }
Standard_Boolean
XCAFDoc_NotesTool::RemoveSubshapeNote(const TDF_Label& theNoteLabel,
const XCAFDoc_AssemblyItemId& theItemId,
Standard_Integer theSubshapeIndex,
Standard_Boolean theDelIfOrphan)
{
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(theNoteLabel);
if (aNote.IsNull())
return Standard_False;
Handle(XCAFDoc_GraphNode) aFather;
if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather))
return Standard_False;
TDF_Label anAnnotatedItem = FindAnnotatedItemSubshape(theItemId, theSubshapeIndex);
if (anAnnotatedItem.IsNull())
return Standard_False;
Handle(XCAFDoc_GraphNode) aChild;
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
return Standard_False;
aChild->UnSetFather(aFather);
if (aChild->NbFathers() == 0)
anAnnotatedItem.ForgetAllAttributes();
if (theDelIfOrphan && aNote->IsOrphan())
DeleteNote(theNoteLabel);
return Standard_True;
}
Standard_Boolean
XCAFDoc_NotesTool::RemoveAttrNote(const TDF_Label& theNoteLabel,
const XCAFDoc_AssemblyItemId& theItemId,
const Standard_GUID& theGUID,
Standard_Boolean theDelIfOrphan)
{
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(theNoteLabel);
if (aNote.IsNull())
return Standard_False;
Handle(XCAFDoc_GraphNode) aFather;
if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather))
return Standard_False;
TDF_Label anAnnotatedItem = FindAnnotatedItemAttr(theItemId, theGUID);
if (anAnnotatedItem.IsNull())
return Standard_False;
Handle(XCAFDoc_GraphNode) aChild;
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
return Standard_False;
aChild->UnSetFather(aFather);
if (aChild->NbFathers() == 0)
anAnnotatedItem.ForgetAllAttributes();
if (theDelIfOrphan && aNote->IsOrphan())
DeleteNote(theNoteLabel);
return Standard_True;
}
Standard_Boolean Standard_Boolean
XCAFDoc_NotesTool::RemoveAllNotes(const XCAFDoc_AssemblyItemId& theItemId, XCAFDoc_NotesTool::RemoveAllNotes(const XCAFDoc_AssemblyItemId& theItemId,
Standard_Boolean theDelIfOrphan) Standard_Boolean theDelIfOrphan)
@ -474,6 +540,68 @@ XCAFDoc_NotesTool::RemoveAllNotes(const XCAFDoc_AssemblyItemId& theItemId,
return Standard_True; return Standard_True;
} }
Standard_Boolean
XCAFDoc_NotesTool::RemoveAllSubshapeNotes(const XCAFDoc_AssemblyItemId& theItemId,
Standard_Integer theSubshapeIndex,
Standard_Boolean theDelIfOrphan)
{
TDF_Label anAnnotatedItem = FindAnnotatedItemSubshape(theItemId, theSubshapeIndex);
if (anAnnotatedItem.IsNull())
return Standard_False;
Handle(XCAFDoc_GraphNode) aChild;
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
return Standard_False;
Standard_Integer nbFathers = aChild->NbFathers();
for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
{
Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(aFather->Label());
if (!aNote.IsNull())
{
aFather->UnSetChild(aChild);
if (theDelIfOrphan && aNote->IsOrphan())
DeleteNote(aFather->Label());
}
}
anAnnotatedItem.ForgetAllAttributes();
return Standard_True;
}
Standard_Boolean
XCAFDoc_NotesTool::RemoveAllAttrNotes(const XCAFDoc_AssemblyItemId& theItemId,
const Standard_GUID& theGUID,
Standard_Boolean theDelIfOrphan)
{
TDF_Label anAnnotatedItem = FindAnnotatedItemAttr(theItemId, theGUID);
if (anAnnotatedItem.IsNull())
return Standard_False;
Handle(XCAFDoc_GraphNode) aChild;
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
return Standard_False;
Standard_Integer nbFathers = aChild->NbFathers();
for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather)
{
Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather);
Handle(XCAFDoc_Note) aNote = XCAFDoc_Note::Get(aFather->Label());
if (!aNote.IsNull())
{
aFather->UnSetChild(aChild);
if (theDelIfOrphan && aNote->IsOrphan())
DeleteNote(aFather->Label());
}
}
anAnnotatedItem.ForgetAllAttributes();
return Standard_True;
}
Standard_Boolean Standard_Boolean
XCAFDoc_NotesTool::DeleteNote(const TDF_Label& theNoteLabel) XCAFDoc_NotesTool::DeleteNote(const TDF_Label& theNoteLabel)
{ {

View File

@ -99,8 +99,22 @@ public:
Standard_EXPORT Standard_Boolean RemoveNote(const TDF_Label& theNoteLabel, Standard_EXPORT Standard_Boolean RemoveNote(const TDF_Label& theNoteLabel,
const XCAFDoc_AssemblyItemId& theItemId, const XCAFDoc_AssemblyItemId& theItemId,
Standard_Boolean theDelIfOrphan = Standard_False); Standard_Boolean theDelIfOrphan = Standard_False);
Standard_EXPORT Standard_Boolean RemoveSubshapeNote(const TDF_Label& theNoteLabel,
const XCAFDoc_AssemblyItemId& theItemId,
Standard_Integer theSubshapeIndex,
Standard_Boolean theDelIfOrphan = Standard_False);
Standard_EXPORT Standard_Boolean RemoveAttrNote(const TDF_Label& theNoteLabel,
const XCAFDoc_AssemblyItemId& theItemId,
const Standard_GUID& theGUID,
Standard_Boolean theDelIfOrphan = Standard_False);
Standard_EXPORT Standard_Boolean RemoveAllNotes(const XCAFDoc_AssemblyItemId& theItemId, Standard_EXPORT Standard_Boolean RemoveAllNotes(const XCAFDoc_AssemblyItemId& theItemId,
Standard_Boolean theDelIfOrphan = Standard_False); Standard_Boolean theDelIfOrphan = Standard_False);
Standard_EXPORT Standard_Boolean RemoveAllSubshapeNotes(const XCAFDoc_AssemblyItemId& theItemId,
Standard_Integer theSubshapeIndex,
Standard_Boolean theDelIfOrphan = Standard_False);
Standard_EXPORT Standard_Boolean RemoveAllAttrNotes(const XCAFDoc_AssemblyItemId& theItemId,
const Standard_GUID& theGUID,
Standard_Boolean theDelIfOrphan = Standard_False);
Standard_EXPORT Standard_Boolean DeleteNote(const TDF_Label& theNoteLabel); Standard_EXPORT Standard_Boolean DeleteNote(const TDF_Label& theNoteLabel);
Standard_EXPORT Standard_Integer DeleteNotes(TDF_LabelSequence& theNoteLabels); Standard_EXPORT Standard_Integer DeleteNotes(TDF_LabelSequence& theNoteLabels);