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