1 // Copyright (c) 2017-2018 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <Standard_GUID.hxx>
15 #include <TDF_Label.hxx>
16 #include <XCAFDoc_NoteComment.hxx>
18 IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note)
20 // =======================================================================
23 // =======================================================================
25 XCAFDoc_NoteComment::GetID()
27 static Standard_GUID s_ID("FDEA4C52-0F54-484c-B590-579E18F7B5D4");
31 // =======================================================================
34 // =======================================================================
35 Handle(XCAFDoc_NoteComment)
36 XCAFDoc_NoteComment::Get(const TDF_Label& theLabel)
38 Handle(XCAFDoc_NoteComment) aThis;
39 theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aThis);
43 // =======================================================================
46 // =======================================================================
47 Handle(XCAFDoc_NoteComment)
48 XCAFDoc_NoteComment::Set(const TDF_Label& theLabel,
49 const TCollection_ExtendedString& theUserName,
50 const TCollection_ExtendedString& theTimeStamp,
51 const TCollection_ExtendedString& theComment)
53 Handle(XCAFDoc_NoteComment) aNoteComment;
54 if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aNoteComment))
56 aNoteComment = new XCAFDoc_NoteComment();
57 aNoteComment->XCAFDoc_Note::Set(theUserName, theTimeStamp);
58 aNoteComment->Set(theComment);
59 theLabel.AddAttribute(aNoteComment);
64 // =======================================================================
65 // function : XCAFDoc_NoteComment
67 // =======================================================================
68 XCAFDoc_NoteComment::XCAFDoc_NoteComment()
72 // =======================================================================
75 // =======================================================================
77 XCAFDoc_NoteComment::Set(const TCollection_ExtendedString& theComment)
81 myComment = theComment;
84 // =======================================================================
87 // =======================================================================
89 XCAFDoc_NoteComment::ID() const
94 // =======================================================================
95 // function : NewEmpty
97 // =======================================================================
99 XCAFDoc_NoteComment::NewEmpty() const
101 return new XCAFDoc_NoteComment();
104 // =======================================================================
105 // function : Restore
107 // =======================================================================
109 XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr)
111 XCAFDoc_Note::Restore(theAttr);
113 Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttr);
115 myComment = aMine->myComment;
118 // =======================================================================
121 // =======================================================================
123 XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)& theAttrInto,
124 const Handle(TDF_RelocationTable)& theRT) const
126 XCAFDoc_Note::Paste(theAttrInto, theRT);
128 Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttrInto);
130 aMine->Set(myComment);
133 // =======================================================================
136 // =======================================================================
138 XCAFDoc_NoteComment::Dump(Standard_OStream& theOS) const
140 XCAFDoc_Note::Dump(theOS);
142 << "Comment : " << (!myComment.IsEmpty() ? myComment : "<empty>")