0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / TDataStd / TDataStd_Comment.cxx
CommitLineData
b311480e 1// Created on: 1998-01-15
2// Created by: Denis PASCAL
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
bc73b006 17#include <TDataStd_Comment.hxx>
7fd59977 18
bc73b006 19#include <Standard_Dump.hxx>
42cf5bc1 20#include <Standard_GUID.hxx>
21#include <Standard_Type.hxx>
7fd59977 22#include <TCollection_AsciiString.hxx>
42cf5bc1 23#include <TCollection_ExtendedString.hxx>
42cf5bc1 24#include <TDataStd_Integer.hxx>
25#include <TDataStd_Real.hxx>
26#include <TDF_Attribute.hxx>
7fd59977 27#include <TDF_ChildIDIterator.hxx>
28#include <TDF_ChildIterator.hxx>
29#include <TDF_Label.hxx>
42cf5bc1 30#include <TDF_RelocationTable.hxx>
7fd59977 31#include <TDF_Tool.hxx>
7fd59977 32
92efcf78 33IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Comment,TDF_Attribute)
34
7fd59977 35#define lid1 45
36#define lid2 36
37
38//=======================================================================
39//function : GetID
40//purpose :
41//=======================================================================
42
43const Standard_GUID& TDataStd_Comment::GetID ()
44{
45 static Standard_GUID TDataStd_CommentID ("2a96b616-ec8b-11d0-bee7-080009dc3333");
46 return TDataStd_CommentID;
47}
48
49
50
51//=======================================================================
52//function : Set
53//purpose :
54//=======================================================================
55
56Handle(TDataStd_Comment) TDataStd_Comment::Set (const TDF_Label& L,
57 const TCollection_ExtendedString& S)
58{
59 Handle(TDataStd_Comment) A;
60 if (!L.FindAttribute(TDataStd_Comment::GetID(),A)) {
61 A = new TDataStd_Comment ();
62 L.AddAttribute(A);
63 }
64 A->Set (S);
65 return A;
66}
67
68
69//=======================================================================
70//function : Set
71//purpose :
72//=======================================================================
73
74Handle(TDataStd_Comment) TDataStd_Comment::Set (const TDF_Label& L)
75{
76 Handle(TDataStd_Comment) A;
77 if (!L.FindAttribute(TDataStd_Comment::GetID(),A)) {
78 A = new TDataStd_Comment ();
79 L.AddAttribute(A);
80 }
81 return A;
82}
83
84
85//=======================================================================
86//function : TDataStd_Comment
87//purpose :
88//=======================================================================
89TDataStd_Comment::TDataStd_Comment () { }
90
91
92
93//=======================================================================
94//function : Set
95//purpose :
96//=======================================================================
97void TDataStd_Comment::Set (const TCollection_ExtendedString& S)
98{
99 // OCC2932 correction
100 if(myString == S) return;
101
102 Backup();
103
104 myString = S;
105}
106
107
108
109//=======================================================================
110//function : Get
111//purpose :
112//=======================================================================
113const TCollection_ExtendedString& TDataStd_Comment::Get () const
114{
115 return myString;
116}
117
118//=======================================================================
119//function : ID
120//purpose :
121//=======================================================================
122
123const Standard_GUID& TDataStd_Comment::ID () const { return GetID(); }
124
125
126//=======================================================================
127//function : NewEmpty
128//purpose :
129//=======================================================================
130
131Handle(TDF_Attribute) TDataStd_Comment::NewEmpty () const
132{
133 return new TDataStd_Comment();
134}
135
136//=======================================================================
137//function : Restore
138//purpose :
139//=======================================================================
140
141void TDataStd_Comment::Restore(const Handle(TDF_Attribute)& with)
142{
143 myString = Handle(TDataStd_Comment)::DownCast (with)->Get ();
144 return;
145}
146
147//=======================================================================
148//function : Paste
149//purpose :
150//=======================================================================
151
152void TDataStd_Comment::Paste (const Handle(TDF_Attribute)& into,
153 const Handle(TDF_RelocationTable)& /*RT*/) const
154{
155 Handle(TDataStd_Comment)::DownCast (into)->Set (myString);
156}
157
158//=======================================================================
159//function : Dump
160//purpose :
161//=======================================================================
162
163Standard_OStream& TDataStd_Comment::Dump (Standard_OStream& anOS) const
164{
165 TDF_Attribute::Dump(anOS);
166 anOS << "Comment=|"<<myString<<"|";
167 return anOS;
168}
169Standard_Boolean TDataStd_Comment::
170AfterRetrieval(const Standard_Boolean)
171{
172 return Standard_True;
173}
bc73b006 174
175//=======================================================================
176//function : DumpJson
177//purpose :
178//=======================================================================
179void TDataStd_Comment::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
180{
181 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
182
183 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
184
185 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myString)
186}