8c7fab9b |
1 | // Copyright (c) 2017-2018 OPEN CASCADE SAS |
024d6f77 |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #include <Standard_GUID.hxx> |
15 | #include <TDF_Label.hxx> |
16 | #include <XCAFDoc_NoteComment.hxx> |
17 | |
18 | IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_NoteComment, XCAFDoc_Note) |
19 | |
8c7fab9b |
20 | // ======================================================================= |
21 | // function : GetID |
22 | // purpose : |
23 | // ======================================================================= |
24 | const Standard_GUID& |
024d6f77 |
25 | XCAFDoc_NoteComment::GetID() |
26 | { |
27 | static Standard_GUID s_ID("FDEA4C52-0F54-484c-B590-579E18F7B5D4"); |
28 | return s_ID; |
29 | } |
30 | |
8c7fab9b |
31 | // ======================================================================= |
32 | // function : Get |
33 | // purpose : |
34 | // ======================================================================= |
35 | Handle(XCAFDoc_NoteComment) |
024d6f77 |
36 | XCAFDoc_NoteComment::Get(const TDF_Label& theLabel) |
37 | { |
38 | Handle(XCAFDoc_NoteComment) aThis; |
39 | theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aThis); |
40 | return aThis; |
41 | } |
42 | |
8c7fab9b |
43 | // ======================================================================= |
44 | // function : Set |
45 | // purpose : |
46 | // ======================================================================= |
47 | Handle(XCAFDoc_NoteComment) |
024d6f77 |
48 | XCAFDoc_NoteComment::Set(const TDF_Label& theLabel, |
49 | const TCollection_ExtendedString& theUserName, |
50 | const TCollection_ExtendedString& theTimeStamp, |
51 | const TCollection_ExtendedString& theComment) |
52 | { |
53 | Handle(XCAFDoc_NoteComment) aNoteComment; |
54 | if (!theLabel.IsNull() && !theLabel.FindAttribute(XCAFDoc_NoteComment::GetID(), aNoteComment)) |
55 | { |
56 | aNoteComment = new XCAFDoc_NoteComment(); |
57 | aNoteComment->XCAFDoc_Note::Set(theUserName, theTimeStamp); |
58 | aNoteComment->Set(theComment); |
59 | theLabel.AddAttribute(aNoteComment); |
60 | } |
61 | return aNoteComment; |
62 | } |
63 | |
8c7fab9b |
64 | // ======================================================================= |
65 | // function : XCAFDoc_NoteComment |
66 | // purpose : |
67 | // ======================================================================= |
024d6f77 |
68 | XCAFDoc_NoteComment::XCAFDoc_NoteComment() |
69 | { |
70 | } |
71 | |
8c7fab9b |
72 | // ======================================================================= |
73 | // function : Set |
74 | // purpose : |
75 | // ======================================================================= |
76 | void |
024d6f77 |
77 | XCAFDoc_NoteComment::Set(const TCollection_ExtendedString& theComment) |
78 | { |
79 | Backup(); |
80 | |
81 | myComment = theComment; |
82 | } |
83 | |
8c7fab9b |
84 | // ======================================================================= |
85 | // function : ID |
86 | // purpose : |
87 | // ======================================================================= |
88 | const Standard_GUID& |
024d6f77 |
89 | XCAFDoc_NoteComment::ID() const |
90 | { |
91 | return GetID(); |
92 | } |
93 | |
8c7fab9b |
94 | // ======================================================================= |
95 | // function : NewEmpty |
96 | // purpose : |
97 | // ======================================================================= |
98 | Handle(TDF_Attribute) |
024d6f77 |
99 | XCAFDoc_NoteComment::NewEmpty() const |
100 | { |
101 | return new XCAFDoc_NoteComment(); |
102 | } |
103 | |
8c7fab9b |
104 | // ======================================================================= |
105 | // function : Restore |
106 | // purpose : |
107 | // ======================================================================= |
108 | void |
024d6f77 |
109 | XCAFDoc_NoteComment::Restore(const Handle(TDF_Attribute)& theAttr) |
110 | { |
111 | XCAFDoc_Note::Restore(theAttr); |
112 | |
113 | Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttr); |
114 | if (!aMine.IsNull()) |
115 | myComment = aMine->myComment; |
116 | } |
117 | |
8c7fab9b |
118 | // ======================================================================= |
119 | // function : Paste |
120 | // purpose : |
121 | // ======================================================================= |
122 | void |
024d6f77 |
123 | XCAFDoc_NoteComment::Paste(const Handle(TDF_Attribute)& theAttrInto, |
124 | const Handle(TDF_RelocationTable)& theRT) const |
125 | { |
126 | XCAFDoc_Note::Paste(theAttrInto, theRT); |
127 | |
128 | Handle(XCAFDoc_NoteComment) aMine = Handle(XCAFDoc_NoteComment)::DownCast(theAttrInto); |
129 | if (!aMine.IsNull()) |
130 | aMine->Set(myComment); |
131 | } |
132 | |
8c7fab9b |
133 | // ======================================================================= |
134 | // function : Dump |
135 | // purpose : |
136 | // ======================================================================= |
137 | Standard_OStream& |
024d6f77 |
138 | XCAFDoc_NoteComment::Dump(Standard_OStream& theOS) const |
139 | { |
140 | XCAFDoc_Note::Dump(theOS); |
141 | theOS << "\n" |
142 | << "Comment : " << (!myComment.IsEmpty() ? myComment : "<empty>") |
143 | ; |
144 | return theOS; |
145 | } |