1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <XCAFDoc_DimTol.hxx>
16 #include <Standard_Dump.hxx>
17 #include <Standard_GUID.hxx>
18 #include <Standard_Type.hxx>
19 #include <TCollection_HAsciiString.hxx>
20 #include <TDF_Attribute.hxx>
21 #include <TDF_Label.hxx>
22 #include <TDF_RelocationTable.hxx>
24 IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_DimTol,TDF_Attribute)
26 //=======================================================================
27 //function : XCAFDoc_DimTol
29 //=======================================================================
30 XCAFDoc_DimTol::XCAFDoc_DimTol()
35 //=======================================================================
38 //=======================================================================
40 const Standard_GUID& XCAFDoc_DimTol::GetID()
42 static Standard_GUID DGTID ("58ed092d-44de-11d8-8776-001083004c77");
43 //static Standard_GUID ID("efd212e9-6dfd-11d4-b9c8-0060b0ee281b");
49 //=======================================================================
52 //=======================================================================
54 Handle(XCAFDoc_DimTol) XCAFDoc_DimTol::Set(const TDF_Label& label,
55 const Standard_Integer kind,
56 const Handle(TColStd_HArray1OfReal)& aVal,
57 const Handle(TCollection_HAsciiString)& aName,
58 const Handle(TCollection_HAsciiString)& aDescription)
60 Handle(XCAFDoc_DimTol) A;
61 if (!label.FindAttribute(XCAFDoc_DimTol::GetID(), A)) {
62 A = new XCAFDoc_DimTol();
63 label.AddAttribute(A);
65 A->Set(kind,aVal,aName,aDescription);
70 //=======================================================================
73 //=======================================================================
75 void XCAFDoc_DimTol::Set(const Standard_Integer kind,
76 const Handle(TColStd_HArray1OfReal)& aVal,
77 const Handle(TCollection_HAsciiString)& aName,
78 const Handle(TCollection_HAsciiString)& aDescription)
84 myDescription = aDescription;
88 //=======================================================================
91 //=======================================================================
93 Standard_Integer XCAFDoc_DimTol::GetKind() const
99 //=======================================================================
102 //=======================================================================
104 Handle(TColStd_HArray1OfReal) XCAFDoc_DimTol::GetVal() const
110 //=======================================================================
113 //=======================================================================
115 Handle(TCollection_HAsciiString) XCAFDoc_DimTol::GetName() const
121 //=======================================================================
122 //function : GetDescription
124 //=======================================================================
126 Handle(TCollection_HAsciiString) XCAFDoc_DimTol::GetDescription() const
128 return myDescription;
132 //=======================================================================
135 //=======================================================================
137 const Standard_GUID& XCAFDoc_DimTol::ID() const
143 //=======================================================================
146 //=======================================================================
148 void XCAFDoc_DimTol::Restore(const Handle(TDF_Attribute)& With)
150 myKind = Handle(XCAFDoc_DimTol)::DownCast(With)->GetKind();
151 myVal = Handle(XCAFDoc_DimTol)::DownCast(With)->GetVal();
152 myName = Handle(XCAFDoc_DimTol)::DownCast(With)->GetName();
153 myDescription = Handle(XCAFDoc_DimTol)::DownCast(With)->GetDescription();
157 //=======================================================================
158 //function : NewEmpty
160 //=======================================================================
162 Handle(TDF_Attribute) XCAFDoc_DimTol::NewEmpty() const
164 return new XCAFDoc_DimTol();
168 //=======================================================================
171 //=======================================================================
173 void XCAFDoc_DimTol::Paste(const Handle(TDF_Attribute)& Into,
174 const Handle(TDF_RelocationTable)& /*RT*/) const
176 Handle(XCAFDoc_DimTol)::DownCast(Into)->Set(myKind,myVal,myName,myDescription);
179 //=======================================================================
180 //function : DumpJson
182 //=======================================================================
183 void XCAFDoc_DimTol::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
185 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
187 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
189 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myKind)
191 for (TColStd_Array1OfReal::Iterator aValIt (myVal->Array1()); aValIt.More(); aValIt.Next())
193 const Standard_Real& aValue = aValIt.Value();
194 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, aValue)
197 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myName.get())
198 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myDescription.get())