b311480e |
1 | // Created on: 1997-08-04 |
2 | // Created by: VAUTHIER Jean-Claude |
3 | // Copyright (c) 1997-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 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <Standard_GUID.hxx> |
19 | #include <Standard_Type.hxx> |
20 | #include <TDF_Attribute.hxx> |
21 | #include <TDF_Label.hxx> |
22 | #include <TDF_RelocationTable.hxx> |
23 | #include <TDF_TagSource.hxx> |
7fd59977 |
24 | |
92efcf78 |
25 | IMPLEMENT_STANDARD_RTTIEXT(TDF_TagSource,TDF_Attribute) |
26 | |
7fd59977 |
27 | //======================================================================= |
28 | //function : GetID |
29 | //purpose : |
30 | //======================================================================= |
7fd59977 |
31 | const Standard_GUID& TDF_TagSource::GetID () { |
32 | |
33 | static Standard_GUID TDF_TagSourceID("2a96b611-ec8b-11d0-bee7-080009dc3333"); |
34 | return TDF_TagSourceID; |
35 | } |
36 | |
37 | |
38 | |
39 | //======================================================================= |
40 | //function : Set |
41 | //purpose : |
42 | //======================================================================= |
43 | |
44 | Handle(TDF_TagSource) TDF_TagSource::Set (const TDF_Label& L) { |
45 | |
46 | Handle(TDF_TagSource) T; |
47 | if (!L.FindAttribute (TDF_TagSource::GetID (), T)) { |
48 | T = new TDF_TagSource (); |
49 | L.AddAttribute (T); |
50 | } |
51 | return T; |
52 | } |
53 | |
54 | //======================================================================= |
55 | //function : NewChild |
56 | //purpose : |
57 | //======================================================================= |
58 | |
59 | TDF_Label TDF_TagSource::NewChild (const TDF_Label& L) |
60 | { |
61 | Handle(TDF_TagSource) T; |
62 | if (!L.FindAttribute(GetID(),T)) { |
63 | T = new TDF_TagSource(); |
64 | L.AddAttribute(T); |
65 | } |
66 | return T->NewChild(); |
67 | } |
68 | |
69 | |
70 | |
71 | //======================================================================= |
72 | //function : TDF_TagSource |
73 | //purpose : |
74 | //======================================================================= |
75 | |
76 | TDF_TagSource::TDF_TagSource () : myTag(0) { } |
77 | |
78 | |
79 | |
80 | //======================================================================= |
81 | //function : NewTag |
82 | //purpose : |
83 | //======================================================================= |
84 | |
85 | Standard_Integer TDF_TagSource::NewTag () { |
86 | |
87 | Backup(); // FID 02/07/98 |
88 | return ++myTag; |
89 | } |
90 | |
91 | |
92 | //======================================================================= |
93 | //function : NewChild |
94 | //purpose : |
95 | //======================================================================= |
96 | |
97 | TDF_Label TDF_TagSource::NewChild () { |
98 | return Label().FindChild(NewTag(),Standard_True); |
99 | } |
100 | |
101 | |
102 | //======================================================================= |
103 | //function : Get |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | Standard_Integer TDF_TagSource::Get() const |
108 | { |
109 | return myTag; |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : Set |
114 | //purpose : |
115 | //======================================================================= |
116 | |
117 | void TDF_TagSource::Set (const Standard_Integer T) { |
118 | // OCC2932 correction |
119 | if(myTag == T) return; |
120 | |
121 | Backup (); // FID 02/07/98 |
122 | myTag = T; |
123 | } |
124 | |
125 | |
126 | //======================================================================= |
127 | //function : ID |
128 | //purpose : |
129 | //======================================================================= |
130 | |
131 | const Standard_GUID& TDF_TagSource::ID() const { return GetID (); } |
132 | |
133 | |
134 | |
135 | |
136 | //======================================================================= |
137 | //function : NewEmpty |
138 | //purpose : |
139 | //======================================================================= |
140 | |
141 | Handle(TDF_Attribute) TDF_TagSource::NewEmpty () const |
142 | { |
143 | return new TDF_TagSource (); |
144 | } |
145 | |
146 | |
147 | //======================================================================= |
148 | //function : Restore |
149 | //purpose : |
150 | //======================================================================= |
151 | |
152 | void TDF_TagSource::Restore(const Handle(TDF_Attribute)& With) |
153 | { |
154 | myTag = Handle(TDF_TagSource)::DownCast (With)->Get (); |
155 | } |
156 | |
157 | |
158 | |
159 | //======================================================================= |
160 | //function : Paste |
161 | //purpose : |
162 | //======================================================================= |
163 | |
35e08fe8 |
164 | void TDF_TagSource::Paste (const Handle(TDF_Attribute)& Into, |
165 | const Handle(TDF_RelocationTable)&) const |
7fd59977 |
166 | { |
167 | Handle(TDF_TagSource)::DownCast(Into)->Set (myTag); |
168 | } |