From ac5eea5d0e7b5fefd61ccd022492c95c48e10ab3 Mon Sep 17 00:00:00 2001 From: snn Date: Mon, 20 Feb 2017 13:35:39 +0300 Subject: [PATCH] XCAF: assembly item ref driver added, file name typo correction --- src/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx | 9 ----- src/XCAFDoc/XCAFDoc_AssemblyItemRef.hxx | 2 - src/XCAFDoc/XCAFDoc_Note.cxx | 2 +- src/XCAFDoc/XCAFDoc_NoteBinData.cxx | 54 ++++++++++++++++--------- src/XCAFDoc/XCAFDoc_NoteBinData.hxx | 2 +- src/XCAFDoc/XCAFDoc_NoteComment.cxx | 43 ++++++++++++-------- src/XCAFDoc/XCAFDoc_NoteComment.hxx | 2 +- src/XCAFDoc/XCAFDoc_NotesTool.cxx | 23 +++++------ 8 files changed, 73 insertions(+), 64 deletions(-) diff --git a/src/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx b/src/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx index 0bb89d6420..52709afb76 100644 --- a/src/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx +++ b/src/XCAFDoc/XCAFDoc_AssemblyItemRef.cxx @@ -27,15 +27,6 @@ XCAFDoc_AssemblyItemRef::GetID() return s_ID; } -Standard_Boolean -XCAFDoc_AssemblyItemRef::IsMine(const TDF_Label& theLabel) -{ - Handle(XCAFDoc_AssemblyItemRef) aThis; - return !theLabel.IsNull() && - theLabel.FindAttribute(XCAFDoc_AssemblyItemRef::GetID(), aThis) && - !aThis.IsNull(); -} - Handle(XCAFDoc_AssemblyItemRef) XCAFDoc_AssemblyItemRef::Get(const TDF_Label& theLabel) { diff --git a/src/XCAFDoc/XCAFDoc_AssemblyItemRef.hxx b/src/XCAFDoc/XCAFDoc_AssemblyItemRef.hxx index 9ef44c79be..c162a5ec48 100644 --- a/src/XCAFDoc/XCAFDoc_AssemblyItemRef.hxx +++ b/src/XCAFDoc/XCAFDoc_AssemblyItemRef.hxx @@ -36,8 +36,6 @@ public: Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel); - Standard_EXPORT static Handle(XCAFDoc_AssemblyItemRef) Get(const TDF_Label& theLabel); Standard_EXPORT static Handle(XCAFDoc_AssemblyItemRef) Set(const TDF_Label& theLabel, diff --git a/src/XCAFDoc/XCAFDoc_Note.cxx b/src/XCAFDoc/XCAFDoc_Note.cxx index 9a69acac5c..b127b49048 100644 --- a/src/XCAFDoc/XCAFDoc_Note.cxx +++ b/src/XCAFDoc/XCAFDoc_Note.cxx @@ -38,7 +38,7 @@ XCAFDoc_Note::Get(const TDF_Label& theLabel) Handle(XCAFDoc_Note) aNote; if (!theLabel.IsNull() && (theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aNote) || - theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNote))) + theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aNote))) return aNote; return aNote; } diff --git a/src/XCAFDoc/XCAFDoc_NoteBinData.cxx b/src/XCAFDoc/XCAFDoc_NoteBinData.cxx index c772c42603..e8c7fa12bd 100644 --- a/src/XCAFDoc/XCAFDoc_NoteBinData.cxx +++ b/src/XCAFDoc/XCAFDoc_NoteBinData.cxx @@ -20,16 +20,19 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteBinData, XCAFDoc_Note) -const Standard_GUID& XCAFDoc_NoteBinData::GetID() +const Standard_GUID& +XCAFDoc_NoteBinData::GetID() { static Standard_GUID s_ID("E9055501-F0FC-4864-BE4B-284FDA7DDEAC"); return s_ID; } -Standard_Boolean XCAFDoc_NoteBinData::IsMine(const TDF_Label& theLabel) +Handle(XCAFDoc_NoteBinData) +XCAFDoc_NoteBinData::Get(const TDF_Label& theLabel) { - Handle(XCAFDoc_NoteBinData) anAttr; - return (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), anAttr)); + Handle(XCAFDoc_NoteBinData) aThis; + theLabel.FindAttribute(XCAFDoc_NoteBinData::GetID(), aThis); + return aThis; } Handle(XCAFDoc_NoteBinData) @@ -76,9 +79,10 @@ XCAFDoc_NoteBinData::XCAFDoc_NoteBinData() { } -Standard_Boolean XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle, - const TCollection_AsciiString& theMIMEtype, - OSD_File& theFile) +Standard_Boolean +XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle, + const TCollection_AsciiString& theMIMEtype, + OSD_File& theFile) { if (!theFile.IsOpen() || !theFile.IsReadable()) return Standard_False; @@ -100,9 +104,10 @@ Standard_Boolean XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theT return Standard_True; } -void XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle, - const TCollection_AsciiString& theMIMEtype, - const Handle(TColStd_HArray1OfByte)& theData) +void +XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle, + const TCollection_AsciiString& theMIMEtype, + const Handle(TColStd_HArray1OfByte)& theData) { Backup(); @@ -111,37 +116,44 @@ void XCAFDoc_NoteBinData::Set(const TCollection_ExtendedString& theTitle, myMIMEtype = theMIMEtype; } -const TCollection_ExtendedString& XCAFDoc_NoteBinData::Title() const +const TCollection_ExtendedString& +XCAFDoc_NoteBinData::Title() const { return myTitle; } -const TCollection_AsciiString& XCAFDoc_NoteBinData::MIMEtype() const +const TCollection_AsciiString& +XCAFDoc_NoteBinData::MIMEtype() const { return myMIMEtype; } -Standard_Integer XCAFDoc_NoteBinData::Size() const +Standard_Integer +XCAFDoc_NoteBinData::Size() const { return (!myData.IsNull() ? myData->Length() : 0); } -const Handle(TColStd_HArray1OfByte)& XCAFDoc_NoteBinData::Data() const +const Handle(TColStd_HArray1OfByte)& +XCAFDoc_NoteBinData::Data() const { return myData; } -const Standard_GUID& XCAFDoc_NoteBinData::ID() const +const +Standard_GUID& XCAFDoc_NoteBinData::ID() const { return GetID(); } -Handle(TDF_Attribute) XCAFDoc_NoteBinData::NewEmpty() const +Handle(TDF_Attribute) +XCAFDoc_NoteBinData::NewEmpty() const { return new XCAFDoc_NoteBinData(); } -void XCAFDoc_NoteBinData::Restore(const Handle(TDF_Attribute)& theAttr) +void +XCAFDoc_NoteBinData::Restore(const Handle(TDF_Attribute)& theAttr) { XCAFDoc_Note::Restore(theAttr); @@ -154,8 +166,9 @@ void XCAFDoc_NoteBinData::Restore(const Handle(TDF_Attribute)& theAttr) } } -void XCAFDoc_NoteBinData::Paste(const Handle(TDF_Attribute)& theAttrInto, - const Handle(TDF_RelocationTable)& theRT) const +void +XCAFDoc_NoteBinData::Paste(const Handle(TDF_Attribute)& theAttrInto, + const Handle(TDF_RelocationTable)& theRT) const { XCAFDoc_Note::Paste(theAttrInto, theRT); @@ -164,7 +177,8 @@ void XCAFDoc_NoteBinData::Paste(const Handle(TDF_Attribute)& theAttrInto, aMine->Set(myTitle, myMIMEtype, myData); } -Standard_OStream& XCAFDoc_NoteBinData::Dump(Standard_OStream& theOS) const +Standard_OStream& +XCAFDoc_NoteBinData::Dump(Standard_OStream& theOS) const { XCAFDoc_Note::Dump(theOS); theOS << "\n" diff --git a/src/XCAFDoc/XCAFDoc_NoteBinData.hxx b/src/XCAFDoc/XCAFDoc_NoteBinData.hxx index 6b3f2dbcce..27160988f7 100644 --- a/src/XCAFDoc/XCAFDoc_NoteBinData.hxx +++ b/src/XCAFDoc/XCAFDoc_NoteBinData.hxx @@ -34,7 +34,7 @@ public: Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel); + Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Get(const TDF_Label& theLabel); Standard_EXPORT static Handle(XCAFDoc_NoteBinData) Set(const TDF_Label& theLabel, const TCollection_ExtendedString& theUserName, diff --git a/src/XCAFDoc/XCAFDoc_NoteComment.cxx b/src/XCAFDoc/XCAFDoc_NoteComment.cxx index 3e6f2d68f9..b88f721bb4 100644 --- a/src/XCAFDoc/XCAFDoc_NoteComment.cxx +++ b/src/XCAFDoc/XCAFDoc_NoteComment.cxx @@ -19,22 +19,26 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note) -const Standard_GUID& XCAFDoc_NoteComment::GetID() +const Standard_GUID& +XCAFDoc_NoteComment::GetID() { static Standard_GUID s_ID("FDEA4C52-0F54-484c-B590-579E18F7B5D4"); return s_ID; } -Standard_Boolean XCAFDoc_NoteComment::IsMine(const TDF_Label& theLabel) +Handle(XCAFDoc_NoteComment) +XCAFDoc_NoteComment::Get(const TDF_Label& theLabel) { - Handle(XCAFDoc_NoteComment) anAttr; - return (!theLabel.IsNull() && theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), anAttr)); + Handle(XCAFDoc_NoteComment) aThis; + theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aThis); + return aThis; } -Handle(XCAFDoc_NoteComment) XCAFDoc_NoteComment::Set(const TDF_Label& theLabel, - const TCollection_ExtendedString& theUserName, - const TCollection_ExtendedString& theTimeStamp, - const TCollection_ExtendedString& theComment) +Handle(XCAFDoc_NoteComment) +XCAFDoc_NoteComment::Set(const TDF_Label& theLabel, + const TCollection_ExtendedString& theUserName, + const TCollection_ExtendedString& theTimeStamp, + const TCollection_ExtendedString& theComment) { Handle(XCAFDoc_NoteComment) aNoteComment; if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aNoteComment)) @@ -51,29 +55,34 @@ XCAFDoc_NoteComment::XCAFDoc_NoteComment() { } -void XCAFDoc_NoteComment::Set(const TCollection_ExtendedString& theComment) +void +XCAFDoc_NoteComment::Set(const TCollection_ExtendedString& theComment) { Backup(); myComment = theComment; } -const TCollection_ExtendedString& XCAFDoc_NoteComment::Comment() const +const TCollection_ExtendedString& +XCAFDoc_NoteComment::Comment() const { return myComment; } -const Standard_GUID& XCAFDoc_NoteComment::ID() const +const Standard_GUID& +XCAFDoc_NoteComment::ID() const { return GetID(); } -Handle(TDF_Attribute) XCAFDoc_NoteComment::NewEmpty() const +Handle(TDF_Attribute) +XCAFDoc_NoteComment::NewEmpty() const { return new XCAFDoc_NoteComment(); } -void XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr) +void +XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr) { XCAFDoc_Note::Restore(theAttr); @@ -82,8 +91,9 @@ void XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr) myComment = aMine->myComment; } -void XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)& theAttrInto, - const Handle(TDF_RelocationTable)& theRT) const +void +XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)& theAttrInto, + const Handle(TDF_RelocationTable)& theRT) const { XCAFDoc_Note::Paste(theAttrInto, theRT); @@ -92,7 +102,8 @@ void XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)& theAttrInto, aMine->Set(myComment); } -Standard_OStream& XCAFDoc_NoteComment::Dump(Standard_OStream& theOS) const +Standard_OStream& +XCAFDoc_NoteComment::Dump(Standard_OStream& theOS) const { XCAFDoc_Note::Dump(theOS); theOS << "\n" diff --git a/src/XCAFDoc/XCAFDoc_NoteComment.hxx b/src/XCAFDoc/XCAFDoc_NoteComment.hxx index 04f6a15865..a8154a919a 100644 --- a/src/XCAFDoc/XCAFDoc_NoteComment.hxx +++ b/src/XCAFDoc/XCAFDoc_NoteComment.hxx @@ -29,7 +29,7 @@ public: Standard_EXPORT static const Standard_GUID& GetID(); - Standard_EXPORT static Standard_Boolean IsMine(const TDF_Label& theLabel); + Standard_EXPORT static Handle(XCAFDoc_NoteComment) Get(const TDF_Label& theLabel); Standard_EXPORT static Handle(XCAFDoc_NoteComment) Set(const TDF_Label& theLabel, const TCollection_ExtendedString& theUserName, diff --git a/src/XCAFDoc/XCAFDoc_NotesTool.cxx b/src/XCAFDoc/XCAFDoc_NotesTool.cxx index e70dbfaea0..bfdd95ea26 100644 --- a/src/XCAFDoc/XCAFDoc_NotesTool.cxx +++ b/src/XCAFDoc/XCAFDoc_NotesTool.cxx @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include @@ -76,7 +76,7 @@ XCAFDoc_NotesTool::NbNotes() const for (TDF_ChildIterator anIter(GetNotesLabel()); anIter.More(); anIter.Next()) { const TDF_Label aLabel = anIter.Value(); - if (XCAFDoc_Note::IsMine(aLabel)) + if (!XCAFDoc_Note::Get(aLabel).IsNull()) ++nbNotes; } return nbNotes; @@ -86,10 +86,8 @@ Standard_Integer XCAFDoc_NotesTool::NbAnnotatedItems() const { Standard_Integer nbItems = 0; - for (TDF_ChildIterator anIter(GetAnnotatedItemsLabel()); anIter.More(); anIter.Next()) + for (TDF_ChildIDIterator anIter(GetAnnotatedItemsLabel(), XCAFDoc_AssemblyItemRef::GetID()); anIter.More(); anIter.Next()) { - const TDF_Label aLabel = anIter.Value(); - if (XCAFDoc_AssemblyItemRef::IsMine(aLabel)) ++nbItems; } return nbItems; @@ -101,7 +99,7 @@ XCAFDoc_NotesTool::GetNotes(TDF_LabelSequence& theNoteLabels) const for (TDF_ChildIterator anIter(GetNotesLabel()); anIter.More(); anIter.Next()) { const TDF_Label aLabel = anIter.Value(); - if (XCAFDoc_Note::IsMine(aLabel)) + if (!XCAFDoc_Note::Get(aLabel).IsNull()) theNoteLabels.Append(aLabel); } } @@ -109,11 +107,9 @@ XCAFDoc_NotesTool::GetNotes(TDF_LabelSequence& theNoteLabels) const void XCAFDoc_NotesTool::GetAnnotatedItems(TDF_LabelSequence& theItemLabels) const { - for (TDF_ChildIterator anIter(GetAnnotatedItemsLabel()); anIter.More(); anIter.Next()) + for (TDF_ChildIDIterator anIter(GetAnnotatedItemsLabel(), XCAFDoc_AssemblyItemRef::GetID()); anIter.More(); anIter.Next()) { - const TDF_Label aLabel = anIter.Value(); - if (XCAFDoc_AssemblyItemRef::IsMine(aLabel)) - theItemLabels.Append(aLabel); + theItemLabels.Append(anIter.Value()->Label()); } } @@ -126,12 +122,11 @@ XCAFDoc_NotesTool::IsAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) cons TDF_Label XCAFDoc_NotesTool::FindAnnotatedItem(const XCAFDoc_AssemblyItemId& theItemId) const { - for (TDF_ChildIterator anIter(GetAnnotatedItemsLabel()); anIter.More(); anIter.Next()) + for (TDF_ChildIDIterator anIter(GetAnnotatedItemsLabel(), XCAFDoc_AssemblyItemRef::GetID()); anIter.More(); anIter.Next()) { - const TDF_Label aLabel = anIter.Value(); - Handle(XCAFDoc_AssemblyItemRef) anItemRef = XCAFDoc_AssemblyItemRef::Get(aLabel); + Handle(XCAFDoc_AssemblyItemRef) anItemRef = Handle(XCAFDoc_AssemblyItemRef)::DownCast(anIter.Value()); if (!anItemRef.IsNull() && anItemRef->Get().IsEqual(theItemId)) - return aLabel; + return anItemRef->Label(); } return TDF_Label(); }