From: snn Date: Wed, 29 May 2019 14:13:32 +0000 (+0300) Subject: 0031068: Data Exchange - A parent node shall be created for imported notes X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=41114c82f0baf30d5a5a147b783636ff84179632;p=occt-copy.git 0031068: Data Exchange - A parent node shall be created for imported notes --- diff --git a/src/XCAFDoc/XCAFDoc_NotesTool.cxx b/src/XCAFDoc/XCAFDoc_NotesTool.cxx index 0ca4e6b382..1cc1ef2926 100644 --- a/src/XCAFDoc/XCAFDoc_NotesTool.cxx +++ b/src/XCAFDoc/XCAFDoc_NotesTool.cxx @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,8 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NotesTool, TDF_Attribute) enum NotesTool_RootLabels { NotesTool_NotesRoot = 1, - NotesTool_AnnotatedItemsRoot + NotesTool_AnnotatedItemsRoot, + NotesTool_NoteGroupsRoot }; // ======================================================================= @@ -101,6 +103,15 @@ TDF_Label XCAFDoc_NotesTool::GetAnnotatedItemsLabel() const return Label().FindChild(NotesTool_AnnotatedItemsRoot); } +// ======================================================================= +// function : GetNoteGroupsLabel +// purpose : +// ======================================================================= +TDF_Label XCAFDoc_NotesTool::GetGroupsLabel() const +{ + return Label().FindChild(NotesTool_NoteGroupsRoot); +} + // ======================================================================= // function : NbNotes // purpose : @@ -133,6 +144,21 @@ XCAFDoc_NotesTool::NbAnnotatedItems() const return nbItems; } +// ======================================================================= +// function : NbNoteGroups +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::NbGroups() const +{ + Standard_Integer nbGroups = 0; + for (TDF_ChildIterator anIter(GetGroupsLabel()); anIter.More(); anIter.Next()) + { + ++nbGroups; + } + return nbGroups; +} + // ======================================================================= // function : GetNotes // purpose : @@ -205,6 +231,19 @@ XCAFDoc_NotesTool::GetAnnotatedItems(TDF_LabelSequence& theItemLabels) const } } +// ======================================================================= +// function : GetNoteGroups +// purpose : +// ======================================================================= +void +XCAFDoc_NotesTool::GetGroups(TDF_LabelSequence& theNoteGroupLabels) const +{ + for (TDF_ChildIterator anIter(GetGroupsLabel()); anIter.More(); anIter.Next()) + { + theNoteGroupLabels.Append(anIter.Value()); + } +} + // ======================================================================= // function : IsAnnotatedItem // purpose : @@ -248,6 +287,7 @@ XCAFDoc_NotesTool::FindAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) co if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId) && !anItemRef->HasExtraRef()) return anItemRef->Label(); } + return TDF_Label(); } @@ -276,6 +316,7 @@ XCAFDoc_NotesTool::FindAnnotatedItemAttr(const XCAFDoc_AssemblyItemId& theItemId anItemRef->HasExtraRef() && anItemRef->GetGUID() == theGUID) return anItemRef->Label(); } + return TDF_Label(); } @@ -305,6 +346,7 @@ XCAFDoc_NotesTool::FindAnnotatedItemSubshape(const XCAFDoc_AssemblyItemId& theIt anItemRef->HasExtraRef() && anItemRef->GetSubshapeIndex() == theSubshapeIndex) return anItemRef->Label(); } + return TDF_Label(); } @@ -407,6 +449,344 @@ XCAFDoc_NotesTool::CreateBinDataContainer(const TCollection_ExtendedString& theU return aNote; } +// ======================================================================= +// function : IsGroup +// purpose : +// ======================================================================= +Standard_Boolean +XCAFDoc_NotesTool::IsGroup(const TDF_Label& theLabel) const +{ + return !theLabel.IsNull() && !theLabel.Father().IsNull() + && theLabel.Father().IsEqual(GetGroupsLabel()); +} + +// ======================================================================= +// function : CreateGroup +// purpose : +// ======================================================================= +TDF_Label +XCAFDoc_NotesTool::CreateGroup(const TCollection_ExtendedString& theGroupName) +{ + TDF_TagSource aTag; + TDF_Label aGroupLabel = aTag.NewChild(GetGroupsLabel()); + if (!aGroupLabel.IsNull()) + { + if (TDataStd_Name::Set(aGroupLabel, theGroupName).IsNull()) + aGroupLabel.Nullify(); + } + return aGroupLabel; +} + +// ======================================================================= +// function : AddToGroup +// purpose : +// ======================================================================= +Standard_Boolean +XCAFDoc_NotesTool::GetGroupName(const TDF_Label& theGroupLabel, + TCollection_ExtendedString& theGroupName) +{ + if (!IsGroup(theGroupLabel)) + return Standard_False; + + Handle(TDataStd_Name) aName; + if (!theGroupLabel.FindAttribute(TDataStd_Name::GetID(), aName)) + return Standard_False; + + theGroupName = aName->Get(); + return Standard_True; +} + +// ======================================================================= +// function : NbGroupNotes +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::NbGroupNotes(const TDF_Label& theGroupLabel) const +{ + if (!IsGroup(theGroupLabel)) + return 0; + + Standard_Integer aNbNotes = 0; + + Handle(XCAFDoc_GraphNode) aFather; + if (theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull()) + { + aNbNotes = aFather->NbChildren(); + } + + return aNbNotes; +} + +// ======================================================================= +// function : AddToGroup +// purpose : +// ======================================================================= +Standard_Boolean +XCAFDoc_NotesTool::AddToGroup(const TDF_Label& theGroupLabel, + const Handle(XCAFDoc_Note)& theNote) +{ + return !theNote.IsNull() && AddToGroup(theGroupLabel, theNote->Label()); +} + +// ======================================================================= +// function : AddToGroup +// purpose : +// ======================================================================= +Standard_Boolean +XCAFDoc_NotesTool::AddToGroup(const TDF_Label& theGroupLabel, + const TDF_Label& theNoteLabel) +{ + if (!XCAFDoc_Note::IsMine(theNoteLabel)) + return Standard_False; + + Handle(XCAFDoc_GraphNode) aFather; + if (!theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather)) + { + aFather = XCAFDoc_GraphNode::Set(theGroupLabel, XCAFDoc::NoteRefGUID()); + if (aFather.IsNull()) + return Standard_False; + } + + Handle(XCAFDoc_GraphNode) aChild; + if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) + { + aChild = XCAFDoc_GraphNode::Set(theNoteLabel, XCAFDoc::NoteRefGUID()); + if (aChild.IsNull()) + return Standard_False; + } + + aFather->SetChild(aChild); + aChild->SetFather(aFather); + + return Standard_True; +} + +// ======================================================================= +// function : AddToGroup +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::AddToGroup(const TDF_Label& theGroupLabel, + const TDF_LabelSequence& theNoteLabels) +{ + Standard_Integer aNbAdded = 0; + for (TDF_LabelSequence::Iterator anIter(theNoteLabels); anIter.More(); anIter.Next()) + { + if (AddToGroup(theGroupLabel, anIter.Value())) + ++aNbAdded; + } + return aNbAdded; +} + +// ======================================================================= +// function : RemoveFromGroup +// purpose : +// ======================================================================= +Standard_Boolean +XCAFDoc_NotesTool::RemoveFromGroup(const TDF_Label& theGroupLabel, + const Handle(XCAFDoc_Note)& theNote) +{ + return !theNote.IsNull() && RemoveFromGroup(theGroupLabel, theNote->Label()); +} + +// ======================================================================= +// function : RemoveFromGroup +// purpose : +// ======================================================================= +Standard_Boolean +XCAFDoc_NotesTool::RemoveFromGroup(const TDF_Label& theGroupLabel, + const TDF_Label& theNoteLabel) +{ + if (!IsGroup(theGroupLabel)) + return Standard_False; + + Handle(XCAFDoc_GraphNode) aFather; + if (theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull()) + { + Standard_Integer nbChildren = aFather->NbChildren(); + for (Standard_Integer iChild = 1; iChild <= nbChildren; ++iChild) + { + Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(iChild); + if (!aChild.IsNull() && theNoteLabel.IsEqual(aChild->Label())) + { + aFather->UnSetChild(aChild); + return Standard_True; + } + } + } + + return Standard_False; +} + +// ======================================================================= +// function : RemoveFromGroup +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::RemoveFromGroup(const TDF_Label& theGroupLabel, + const TDF_LabelSequence& theNoteLabels) +{ + Standard_Integer aNbRemoved = 0; + for (TDF_LabelSequence::Iterator anIter(theNoteLabels); anIter.More(); anIter.Next()) + { + if (RemoveFromGroup(theGroupLabel, anIter.Value())) + ++aNbRemoved; + } + return aNbRemoved; +} + +// ======================================================================= +// function : ClearGroup +// purpose : +// ======================================================================= +Standard_Boolean +XCAFDoc_NotesTool::ClearGroup(const TDF_Label& theGroupLabel, + Standard_Boolean theDeleteNotes) +{ + if (!IsGroup(theGroupLabel)) + return Standard_False; + + Handle(XCAFDoc_GraphNode) aFather; + if (theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull()) + { + while (aFather->NbChildren() > 0) + { + Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(1); + if (!aChild.IsNull()) + aFather->UnSetChild(aChild); + if (theDeleteNotes) + DeleteNote(aChild->Label()); + } + } + + return Standard_True; +} + +// ======================================================================= +// function : GetGroupNotes +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::GetGroupNotes(const TDF_Label& theGroupLabel, + TDF_LabelSequence& theNoteLabels) const +{ + if (!IsGroup(theGroupLabel)) + return 0; + + Standard_Integer aNbNotes = 0; + + Handle(XCAFDoc_GraphNode) aFather; + if (theGroupLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather) && !aFather.IsNull()) + { + Standard_Integer nbChildren = aFather->NbChildren(); + for (Standard_Integer iChild = 1; iChild <= nbChildren; ++iChild) + { + Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(iChild); + theNoteLabels.Append(aChild->Label()); + } + } + + return aNbNotes; +} + +// ======================================================================= +// function : GetUngropedNotes +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::GetUngropedNotes(TDF_LabelSequence& theNoteLabels) const +{ + TDF_LabelSequence aNotes; + GetNotes(aNotes); + if (aNotes.IsEmpty()) + return 0; + + Standard_Integer nbNotes = 0; + for (TDF_LabelSequence::Iterator anIter(aNotes); anIter.More(); anIter.Next()) + { + TDF_LabelSequence aGroups; + if (GetNoteGroups(anIter.Value(), aGroups) == 0) + { + theNoteLabels.Append(anIter.Value()); + ++nbNotes; + } + } + return nbNotes; +} + +// ======================================================================= +// function : GetNoteGroups +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::GetNoteGroups(const Handle(XCAFDoc_Note)& theNote, + TDF_LabelSequence& theGroupLabels) const +{ + return !theNote.IsNull() ? GetNoteGroups(theNote->Label(), theGroupLabels) : 0; +} + +// ======================================================================= +// function : GetNoteGroups +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::GetNoteGroups(const TDF_Label& theNoteLabel, + TDF_LabelSequence& theGroupLabels) const +{ + if (!XCAFDoc_Note::IsMine(theNoteLabel)) + return 0; + + Standard_Integer nbGroups = 0; + Handle(XCAFDoc_GraphNode) aChild; + if (theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aChild) && !aChild.IsNull()) + { + Standard_Integer nbFathers = aChild->NbFathers(); + for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather) + { + Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather); + if (IsGroup(aFather->Label())) + { + theGroupLabels.Append(aFather->Label()); + ++nbGroups; + } + } + } + return nbGroups; +} + +// ======================================================================= +// function : DeleteGroup +// purpose : +// ======================================================================= +Standard_Boolean +XCAFDoc_NotesTool::DeleteGroup(const TDF_Label& theGroupLabel, + Standard_Boolean theDeleteNotes) +{ + if (ClearGroup(theGroupLabel, theDeleteNotes)) + { + theGroupLabel.ForgetAllAttributes(); + return Standard_True; + } + + return Standard_False; +} + +// ======================================================================= +// function : DeleteAllGroups +// purpose : +// ======================================================================= +Standard_Integer +XCAFDoc_NotesTool::DeleteAllGroups(Standard_Boolean theDeleteNotes) +{ + Standard_Integer nbGroups = 0; + for (TDF_ChildIterator anIter(GetGroupsLabel()); anIter.More(); anIter.Next()) + { + if (DeleteGroup(anIter.Value(), theDeleteNotes)) + ++nbGroups; + } + return nbGroups; +} + // ======================================================================= // function : GetNotes // purpose : @@ -423,14 +803,16 @@ XCAFDoc_NotesTool::GetNotes(const XCAFDoc_AssemblyItemId& theItemId, if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) return 0; + Standard_Integer nbNotes = 0; Standard_Integer nbFathers = aChild->NbFathers(); for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather) { Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather); theNoteLabels.Append(aFather->Label()); + ++nbNotes; } - return theNoteLabels.Length(); + return nbNotes; } // ======================================================================= @@ -472,14 +854,16 @@ XCAFDoc_NotesTool::GetAttrNotes(const XCAFDoc_AssemblyItemId& theItemId, if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) return 0; + Standard_Integer nbNotes = 0; Standard_Integer nbFathers = aChild->NbFathers(); for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather) { Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather); theNoteLabels.Append(aFather->Label()); + ++nbNotes; } - return theNoteLabels.Length(); + return nbNotes; } // ======================================================================= @@ -511,14 +895,16 @@ XCAFDoc_NotesTool::GetSubshapeNotes(const XCAFDoc_AssemblyItemId& theItemId, if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) return 0; + Standard_Integer nbNotes = 0; Standard_Integer nbFathers = aChild->NbFathers(); for (Standard_Integer iFather = 1; iFather <= nbFathers; ++iFather) { Handle(XCAFDoc_GraphNode) aFather = aChild->GetFather(iFather); theNoteLabels.Append(aFather->Label()); + ++nbNotes; } - return theNoteLabels.Length(); + return nbNotes; } // ======================================================================= @@ -534,7 +920,6 @@ XCAFDoc_NotesTool::AddNote(const TDF_Label& theNoteLabel, if (!XCAFDoc_Note::IsMine(theNoteLabel)) return anItemRef; - Handle(XCAFDoc_GraphNode) aChild; TDF_Label anAnnotatedItem = FindAnnotatedItem(theItemId); if (anAnnotatedItem.IsNull()) { @@ -544,6 +929,7 @@ XCAFDoc_NotesTool::AddNote(const TDF_Label& theNoteLabel, return anItemRef; } + Handle(XCAFDoc_GraphNode) aChild; if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild)) { aChild = XCAFDoc_GraphNode::Set(anAnnotatedItem, XCAFDoc::NoteRefGUID()); @@ -1039,10 +1425,10 @@ XCAFDoc_NotesTool::DeleteNote(const TDF_Label& theNoteLabel) Handle(XCAFDoc_GraphNode) aChild = aFather->GetChild(1); aFather->UnSetChild(aChild); if (aChild->NbFathers() == 0) - aChild->Label().ForgetAllAttributes(Standard_True); + aChild->Label().ForgetAllAttributes(); } } - theNoteLabel.ForgetAllAttributes(Standard_True); + theNoteLabel.ForgetAllAttributes(); return Standard_True; } return Standard_False; diff --git a/src/XCAFDoc/XCAFDoc_NotesTool.hxx b/src/XCAFDoc/XCAFDoc_NotesTool.hxx index 3a92795bca..36f7caec5b 100644 --- a/src/XCAFDoc/XCAFDoc_NotesTool.hxx +++ b/src/XCAFDoc/XCAFDoc_NotesTool.hxx @@ -17,6 +17,7 @@ #include #include #include +#include #include class OSD_File; @@ -48,17 +49,23 @@ class XCAFDoc_AssemblyItemRef; //! | 0:1:9 | //! ------------------------ //! |1 -//! | ------------------- --------------------------- -//! +___| Notes |-----| XCAFDoc_Note | -//! | 1| 0:1:9:1 |1 *| 0:1:9:1:* | -//! | ------------------- --------------------------- -//! | !* -//! | { XCAFDoc_GraphNode } -//! | *! -//! | ------------------- --------------------------- -//! +___| Annotated items |-----| XCAFDoc_AssemblyItemRef | -//! 1| 0:1:9:2 |1 *| 0:1:9:2:* | -//! ------------------- --------------------------- +//! | ------------------- --------------------------- +//! +___| Notes |------| XCAFDoc_Note | +//! | 1| 0:1:9:1 |1 *| 0:1:9:1:* | +//! | ------------------- --------------------------- +//! | [C] * [F] +//! | --- { XCAFDoc_GraphNode } ---| +//! | [F] * | +//! | ------------------- | +//! +___| Note groups | { XCAFDoc_GraphNode } +//! | 1| 0:1:9:3 | | +//! | ------------------- | +//! | | +//! | * [C] +//! | ------------------- --------------------------- +//! +___| Annotated items |------| XCAFDoc_AssemblyItemRef | +//! 1| 0:1:9:2 |1 *| 0:1:9:2:* | +//! ------------------- --------------------------- //! //! A typical annotation procedure is illustrated by the code example below: //! \code{.c++} @@ -94,12 +101,18 @@ public: //! Returns the label of the annotated items hive. Standard_EXPORT TDF_Label GetAnnotatedItemsLabel() const; + //! Returns the label of the note groups hive. + Standard_EXPORT TDF_Label GetGroupsLabel() const; + //! Returns the number of labels in the notes hive. Standard_EXPORT Standard_Integer NbNotes() const; //! Returns the number of labels in the annotated items hive. Standard_EXPORT Standard_Integer NbAnnotatedItems() const; + //! Returns the number of labels in the note groups hive. + Standard_EXPORT Standard_Integer NbGroups() const; + //! Returns all labels from the notes hive. //! The label sequence isn't cleared beforehand. //! \param [out] theNoteLabels - sequence of labels. @@ -116,6 +129,11 @@ public: //! \param [out] theNoteLabels - sequence of labels. Standard_EXPORT void GetAnnotatedItems(TDF_LabelSequence& theLabels) const; + //! Returns all labels from the note groups hive. + //! The label sequence isn't cleared beforehand. + //! \param [out] theGroupLabels - sequence of labels. + Standard_EXPORT void GetGroups(TDF_LabelSequence& theGroupLabels) const; + //! Checks if the given assembly item is annotated. //! \param [in] theItemId - assembly item ID. //! \return true if the item is annotated, otherwise - false. @@ -221,6 +239,120 @@ public: //! @} + //! @name Note groups functions + //! @{ + + //! Checks if the label is a note group. + //! \param [in] theLabel - label. + //! \return true if the label is a child of the note groups hive, otherwise - false. + Standard_EXPORT Standard_Boolean IsGroup(const TDF_Label& theLabel) const; + + //! Create a new note group. + //! \param [in] theGroupName - the user associated with the note. + //! \return new group label. + Standard_EXPORT TDF_Label CreateGroup(const TCollection_ExtendedString& theGroupName); + + //! Get group name. + //! \param [in] theGroupLabel - group label. + //! \param [out] theGroupName - group name. + //! \return true if the label is group, otherwise - false. + Standard_EXPORT Standard_Boolean GetGroupName(const TDF_Label& theGroupLabel, + TCollection_ExtendedString& theGroupName); + + //! Returns the number of notes in the group. + //! \param [in] theGroupLabel - group label. + Standard_EXPORT Standard_Integer NbGroupNotes(const TDF_Label& theGroupLabel) const; + + //! Adds note to group. + //! \param [in] theGroupLabel - group label. + //! \param [in] theNote - attribute identifying the note. + //! \return true if theNote was successfully added to the specified group, otherwise - false. + Standard_EXPORT Standard_Boolean AddToGroup(const TDF_Label& theGroupLabel, + const Handle(XCAFDoc_Note)& theNote); + + //! Adds note to group. + //! \param [in] theGroupLabel - group label. + //! \param [in] theNoteLabel - note label. + //! \return true if theNote was successfully added to the specified group, otherwise - false. + Standard_EXPORT Standard_Boolean AddToGroup(const TDF_Label& theGroupLabel, + const TDF_Label& theNoteLabel); + + //! Adds notes to group. + //! \param [in] theGroupLabel - group label. + //! \param [in] theNoteLabels - note label sequence. + //! \return the number of notes added to the group. + Standard_EXPORT Standard_Integer AddToGroup(const TDF_Label& theGroupLabel, + const TDF_LabelSequence& theNoteLabels); + + //! Removes note from the group. + //! \param [in] theGroupLabel - group label. + //! \param [in] theNote - attribute identifying the note. + //! \return true if the note was successfully from the group, otherwise - false. + Standard_EXPORT Standard_Boolean RemoveFromGroup(const TDF_Label& theGroupLabel, + const Handle(XCAFDoc_Note)& theNote); + + //! Removes note from the group. + //! \param [in] theGroupLabel - group label. + //! \param [in] theNoteLabel - note label. + //! \return true if the note was successfully from the group, otherwise - false. + Standard_EXPORT Standard_Boolean RemoveFromGroup(const TDF_Label& theGroupLabel, + const TDF_Label& theNoteLabel); + + //! Removes notes from the group. + //! \param [in] theGroupLabel - group label. + //! \param [in] theNoteLabels - note label sequence. + //! \return the number of removed notes. + Standard_EXPORT Standard_Integer RemoveFromGroup(const TDF_Label& theGroupLabel, + const TDF_LabelSequence& theNoteLabels); + + //! Removes all notes from the group. + //! \param [in] theGroupLabel - group label. + //! \return the number of removed notes. + Standard_EXPORT Standard_Boolean ClearGroup(const TDF_Label& theGroupLabel, + Standard_Boolean theDeleteNotes = Standard_False); + + //! Retrieves notes from group. + //! Out label sequence isn't cleared. + //! \param [in] theGroupLabel - group label. + //! \param [out] theNoteLabels - note label sequence. + //! \return the number of retrieved notes. + Standard_EXPORT Standard_Integer GetGroupNotes(const TDF_Label& theGroupLabel, + TDF_LabelSequence& theNoteLabels) const; + + //! Retrieves groups, to which the note belongs. + //! Out label sequence isn't cleared. + //! \param [in] theNote - attribute identifying the note. + //! \param [out] theGroupLabels - group label sequence. + //! \return the number of retrieved groups. + Standard_EXPORT Standard_Integer GetNoteGroups(const Handle(XCAFDoc_Note)& theNote, + TDF_LabelSequence& theGroupLabels) const; + + //! Retrieves groups, to which the note belongs. + //! Out label sequence isn't cleared. + //! \param [in] theNoteLabel - note label. + //! \param [out] theGroupLabels - group label sequence. + //! \return the number of retrieved groups. + Standard_EXPORT Standard_Integer GetNoteGroups(const TDF_Label& theNoteLabel, + TDF_LabelSequence& theGroupLabels) const; + + //! Retrieves notes, which don't belong to any group. + //! Out label sequence isn't cleared. + //! \param [out] theNoteLabels - note label sequence. + //! \return the number of retrieved notes. + Standard_EXPORT Standard_Integer GetUngropedNotes(TDF_LabelSequence& theNoteLabels) const; + + //! Delete group. + //! \param [in] theGroupLabel - group label. + //! \return true if the group was successfully deleted, otherwise - false. + Standard_EXPORT Standard_Boolean DeleteGroup(const TDF_Label& theGroupLabel, + Standard_Boolean theDeleteNotes = Standard_False); + + //! Delete all groups. + //! \return the number of deleted groups. + Standard_EXPORT Standard_Integer DeleteAllGroups(Standard_Boolean theDeleteNotes = Standard_False); + + //! @} + //! @name Get notes from annotated items functions //! @{ @@ -546,7 +678,6 @@ public: Standard_EXPORT void Paste(const Handle(TDF_Attribute)& theAttrInto, const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE; Standard_EXPORT Standard_OStream& Dump(Standard_OStream& theOS) const Standard_OVERRIDE; - }; DEFINE_STANDARD_HANDLE(XCAFDoc_NotesTool, TDF_Attribute)