mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
Notes attached to an assembly item sub-shape overwrite other assembly item notes
This commit is contained in:
parent
865f597eda
commit
9c2488148b
@ -125,7 +125,35 @@ XCAFDoc_NotesTool::FindAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) co
|
|||||||
for (TDF_ChildIDIterator anIter(GetAnnotatedItemsLabel(), XCAFDoc_AssemblyItemRef::GetID()); anIter.More(); anIter.Next())
|
for (TDF_ChildIDIterator anIter(GetAnnotatedItemsLabel(), XCAFDoc_AssemblyItemRef::GetID()); anIter.More(); anIter.Next())
|
||||||
{
|
{
|
||||||
Handle(XCAFDoc_AssemblyItemRef) anItemRef = Handle(XCAFDoc_AssemblyItemRef)::DownCast(anIter.Value());
|
Handle(XCAFDoc_AssemblyItemRef) anItemRef = Handle(XCAFDoc_AssemblyItemRef)::DownCast(anIter.Value());
|
||||||
if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId))
|
if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId) && !anItemRef->HasExtraRef())
|
||||||
|
return anItemRef->Label();
|
||||||
|
}
|
||||||
|
return TDF_Label();
|
||||||
|
}
|
||||||
|
|
||||||
|
TDF_Label
|
||||||
|
XCAFDoc_NotesTool::FindAnnotatedItemGUID(const XCAFDoc_AssemblyItemId& theItemId,
|
||||||
|
const Standard_GUID& theGUID) const
|
||||||
|
{
|
||||||
|
for (TDF_ChildIDIterator anIter(GetAnnotatedItemsLabel(), XCAFDoc_AssemblyItemRef::GetID()); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
Handle(XCAFDoc_AssemblyItemRef) anItemRef = Handle(XCAFDoc_AssemblyItemRef)::DownCast(anIter.Value());
|
||||||
|
if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId) &&
|
||||||
|
anItemRef->HasExtraRef() && anItemRef->GetGUID() == theGUID)
|
||||||
|
return anItemRef->Label();
|
||||||
|
}
|
||||||
|
return TDF_Label();
|
||||||
|
}
|
||||||
|
|
||||||
|
TDF_Label
|
||||||
|
XCAFDoc_NotesTool::FindAnnotatedItemSubshape(const XCAFDoc_AssemblyItemId& theItemId,
|
||||||
|
Standard_Integer theSubshapeIndex) const
|
||||||
|
{
|
||||||
|
for (TDF_ChildIDIterator anIter(GetAnnotatedItemsLabel(), XCAFDoc_AssemblyItemRef::GetID()); anIter.More(); anIter.Next())
|
||||||
|
{
|
||||||
|
Handle(XCAFDoc_AssemblyItemRef) anItemRef = Handle(XCAFDoc_AssemblyItemRef)::DownCast(anIter.Value());
|
||||||
|
if (!anItemRef.IsNull() && anItemRef->GetItem().IsEqual(theItemId) &&
|
||||||
|
anItemRef->HasExtraRef() && anItemRef->GetSubshapeIndex() == theSubshapeIndex)
|
||||||
return anItemRef->Label();
|
return anItemRef->Label();
|
||||||
}
|
}
|
||||||
return TDF_Label();
|
return TDF_Label();
|
||||||
@ -242,9 +270,48 @@ XCAFDoc_NotesTool::AddNoteToAttr(const TDF_Label& theNoteLabel,
|
|||||||
const XCAFDoc_AssemblyItemId& theItemId,
|
const XCAFDoc_AssemblyItemId& theItemId,
|
||||||
const Standard_GUID& theGUID)
|
const Standard_GUID& theGUID)
|
||||||
{
|
{
|
||||||
Handle(XCAFDoc_AssemblyItemRef) anItemRef = AddNote(theNoteLabel, theItemId);
|
Handle(XCAFDoc_AssemblyItemRef) anItemRef;
|
||||||
if (!anItemRef.IsNull())
|
|
||||||
|
if (!XCAFDoc_Note::IsMine(theNoteLabel))
|
||||||
|
return anItemRef;
|
||||||
|
|
||||||
|
Handle(XCAFDoc_GraphNode) aChild;
|
||||||
|
TDF_Label anAnnotatedItem = FindAnnotatedItemGUID(theItemId, theGUID);
|
||||||
|
if (anAnnotatedItem.IsNull())
|
||||||
|
{
|
||||||
|
TDF_TagSource aTag;
|
||||||
|
anAnnotatedItem = aTag.NewChild(GetAnnotatedItemsLabel());
|
||||||
|
if (anAnnotatedItem.IsNull())
|
||||||
|
return anItemRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
|
||||||
|
{
|
||||||
|
aChild = XCAFDoc_GraphNode::Set(anAnnotatedItem, XCAFDoc::NoteRefGUID());
|
||||||
|
if (aChild.IsNull())
|
||||||
|
return anItemRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!anAnnotatedItem.FindAttribute(XCAFDoc_AssemblyItemRef::GetID(), anItemRef))
|
||||||
|
{
|
||||||
|
anItemRef = XCAFDoc_AssemblyItemRef::Set(anAnnotatedItem, theItemId);
|
||||||
|
if (anItemRef.IsNull())
|
||||||
|
return anItemRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(XCAFDoc_GraphNode) aFather;
|
||||||
|
if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather))
|
||||||
|
{
|
||||||
|
aFather = XCAFDoc_GraphNode::Set(theNoteLabel, XCAFDoc::NoteRefGUID());
|
||||||
|
if (aFather.IsNull())
|
||||||
|
return anItemRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
aChild->SetFather(aFather);
|
||||||
|
aFather->SetChild(aChild);
|
||||||
|
|
||||||
anItemRef->SetGUID(theGUID);
|
anItemRef->SetGUID(theGUID);
|
||||||
|
|
||||||
return anItemRef;
|
return anItemRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,9 +320,48 @@ XCAFDoc_NotesTool::AddNoteToSubshape(const TDF_Label& theNoteLabel,
|
|||||||
const XCAFDoc_AssemblyItemId& theItemId,
|
const XCAFDoc_AssemblyItemId& theItemId,
|
||||||
Standard_Integer theSubshapeIndex)
|
Standard_Integer theSubshapeIndex)
|
||||||
{
|
{
|
||||||
Handle(XCAFDoc_AssemblyItemRef) anItemRef = AddNote(theNoteLabel, theItemId);
|
Handle(XCAFDoc_AssemblyItemRef) anItemRef;
|
||||||
if (!anItemRef.IsNull())
|
|
||||||
|
if (!XCAFDoc_Note::IsMine(theNoteLabel))
|
||||||
|
return anItemRef;
|
||||||
|
|
||||||
|
Handle(XCAFDoc_GraphNode) aChild;
|
||||||
|
TDF_Label anAnnotatedItem = FindAnnotatedItemSubshape(theItemId, theSubshapeIndex);
|
||||||
|
if (anAnnotatedItem.IsNull())
|
||||||
|
{
|
||||||
|
TDF_TagSource aTag;
|
||||||
|
anAnnotatedItem = aTag.NewChild(GetAnnotatedItemsLabel());
|
||||||
|
if (anAnnotatedItem.IsNull())
|
||||||
|
return anItemRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!anAnnotatedItem.FindAttribute(XCAFDoc::NoteRefGUID(), aChild))
|
||||||
|
{
|
||||||
|
aChild = XCAFDoc_GraphNode::Set(anAnnotatedItem, XCAFDoc::NoteRefGUID());
|
||||||
|
if (aChild.IsNull())
|
||||||
|
return anItemRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!anAnnotatedItem.FindAttribute(XCAFDoc_AssemblyItemRef::GetID(), anItemRef))
|
||||||
|
{
|
||||||
|
anItemRef = XCAFDoc_AssemblyItemRef::Set(anAnnotatedItem, theItemId);
|
||||||
|
if (anItemRef.IsNull())
|
||||||
|
return anItemRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle(XCAFDoc_GraphNode) aFather;
|
||||||
|
if (!theNoteLabel.FindAttribute(XCAFDoc::NoteRefGUID(), aFather))
|
||||||
|
{
|
||||||
|
aFather = XCAFDoc_GraphNode::Set(theNoteLabel, XCAFDoc::NoteRefGUID());
|
||||||
|
if (aFather.IsNull())
|
||||||
|
return anItemRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
aChild->SetFather(aFather);
|
||||||
|
aFather->SetChild(aChild);
|
||||||
|
|
||||||
anItemRef->SetSubshapeIndex(theSubshapeIndex);
|
anItemRef->SetSubshapeIndex(theSubshapeIndex);
|
||||||
|
|
||||||
return anItemRef;
|
return anItemRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,10 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT Standard_Boolean IsAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) const;
|
Standard_EXPORT Standard_Boolean IsAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) const;
|
||||||
Standard_EXPORT TDF_Label FindAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) const;
|
Standard_EXPORT TDF_Label FindAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) const;
|
||||||
|
Standard_EXPORT TDF_Label FindAnnotatedItemGUID(const XCAFDoc_AssemblyItemId& theItemId,
|
||||||
|
const Standard_GUID& theGUID) const;
|
||||||
|
Standard_EXPORT TDF_Label FindAnnotatedItemSubshape(const XCAFDoc_AssemblyItemId& theItemId,
|
||||||
|
Standard_Integer theSubshapeIndex) const;
|
||||||
|
|
||||||
Standard_EXPORT Handle(XCAFDoc_Note) CreateComment(const TCollection_ExtendedString& theUserName,
|
Standard_EXPORT Handle(XCAFDoc_Note) CreateComment(const TCollection_ExtendedString& theUserName,
|
||||||
const TCollection_ExtendedString& theTimeStamp,
|
const TCollection_ExtendedString& theTimeStamp,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user