b311480e |
1 | // Created on: 2000-08-15 |
2 | // Created by: data exchange team |
973c2be1 |
3 | // Copyright (c) 2000-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
bc73b006 |
16 | #include <XCAFDoc_Location.hxx> |
42cf5bc1 |
17 | |
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 <TopLoc_Location.hxx> |
7fd59977 |
24 | |
92efcf78 |
25 | IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Location,TDF_Attribute) |
26 | |
7fd59977 |
27 | //======================================================================= |
28 | //function : Constructor |
29 | //purpose : |
30 | //======================================================================= |
7fd59977 |
31 | XCAFDoc_Location::XCAFDoc_Location() |
32 | { |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : GetID |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | const Standard_GUID& XCAFDoc_Location::GetID() |
41 | { |
42 | static Standard_GUID LocationID ("efd212ef-6dfd-11d4-b9c8-0060b0ee281b"); |
43 | return LocationID; |
44 | } |
45 | |
46 | //======================================================================= |
47 | //function : Set |
48 | //purpose : |
49 | //======================================================================= |
50 | |
51 | Handle(XCAFDoc_Location) XCAFDoc_Location::Set(const TDF_Label& L,const TopLoc_Location& Loc) |
52 | { |
53 | Handle(XCAFDoc_Location) A; |
54 | if (!L.FindAttribute (XCAFDoc_Location::GetID(), A)) { |
55 | A = new XCAFDoc_Location (); |
56 | L.AddAttribute(A); |
57 | } |
58 | A->Set (Loc); |
59 | return A; |
60 | } |
61 | |
62 | //======================================================================= |
63 | //function : Set |
64 | //purpose : |
65 | //======================================================================= |
66 | |
67 | void XCAFDoc_Location::Set(const TopLoc_Location& Loc) |
68 | { |
69 | Backup(); |
70 | myLocation = Loc; |
71 | } |
72 | |
73 | //======================================================================= |
74 | //function : Get |
75 | //purpose : |
76 | //======================================================================= |
77 | |
d97f89db |
78 | const TopLoc_Location& XCAFDoc_Location::Get() const |
7fd59977 |
79 | { |
80 | return myLocation; |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : ID |
85 | //purpose : |
86 | //======================================================================= |
87 | |
88 | const Standard_GUID& XCAFDoc_Location::ID() const |
89 | { |
90 | return GetID(); |
91 | } |
92 | |
93 | //======================================================================= |
94 | //function : Restore |
95 | //purpose : |
96 | //======================================================================= |
97 | |
98 | void XCAFDoc_Location::Restore(const Handle(TDF_Attribute)& With) |
99 | { |
100 | myLocation = Handle(XCAFDoc_Location)::DownCast(With)->Get(); |
101 | } |
102 | |
103 | //======================================================================= |
104 | //function : NewEmpty |
105 | //purpose : |
106 | //======================================================================= |
107 | |
108 | Handle(TDF_Attribute) XCAFDoc_Location::NewEmpty() const |
109 | { |
110 | return new XCAFDoc_Location(); |
111 | } |
112 | |
113 | //======================================================================= |
114 | //function : Paste |
115 | //purpose : |
116 | //======================================================================= |
117 | |
118 | void XCAFDoc_Location::Paste(const Handle(TDF_Attribute)& Into,const Handle(TDF_RelocationTable)& /* RT */) const |
119 | { |
120 | Handle(XCAFDoc_Location)::DownCast(Into)->Set(myLocation); |
121 | |
122 | } |
123 | |
bc73b006 |
124 | //======================================================================= |
125 | //function : DumpJson |
126 | //purpose : |
127 | //======================================================================= |
128 | void XCAFDoc_Location::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const |
129 | { |
130 | OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream) |
131 | |
132 | OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute) |
133 | |
134 | OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myLocation) |
135 | } |