1 // Created on: 1997-03-06
2 // Created by: Denis PASCAL
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TDataStd_Real.hxx>
19 #include <Standard_Dump.hxx>
20 #include <Standard_GUID.hxx>
21 #include <Standard_Type.hxx>
22 #include <TDataStd.hxx>
23 #include <TDF_Attribute.hxx>
24 #include <TDF_Label.hxx>
25 #include <TDF_Reference.hxx>
26 #include <TDF_RelocationTable.hxx>
28 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Real,TDF_Attribute)
30 //=======================================================================
33 //=======================================================================
34 const Standard_GUID& TDataStd_Real::GetID()
36 static Standard_GUID TDataStd_RealID("2a96b60f-ec8b-11d0-bee7-080009dc3333");
37 return TDataStd_RealID;
40 //=======================================================================
42 //purpose : Implements Set functionality
43 //=======================================================================
44 static Handle(TDataStd_Real) SetAttr(const TDF_Label& label,
45 const Standard_Real V,
46 const Standard_GUID& theGuid)
48 Handle(TDataStd_Real) A;
49 if (!label.FindAttribute(theGuid, A)) {
50 A = new TDataStd_Real ();
52 label.AddAttribute(A);
58 //=======================================================================
61 //=======================================================================
63 Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L,
64 const Standard_Real V)
66 return SetAttr(L, V, GetID());
69 //=======================================================================
71 //purpose : User defined attribute
72 //=======================================================================
74 Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L,
75 const Standard_GUID& theGuid,
76 const Standard_Real V)
78 return SetAttr(L, V, theGuid);
81 //=======================================================================
82 //function : TDataStd_Real
83 //purpose : Empty constructor
84 //=======================================================================
86 TDataStd_Real::TDataStd_Real ()
87 : myValue (RealFirst()),
88 myDimension (TDataStd_SCALAR),
94 //=======================================================================
95 //function : IsCaptured
97 //=======================================================================
99 Standard_Boolean TDataStd_Real::IsCaptured() const
101 Handle(TDF_Reference) reference;
104 if (Label().FindAttribute(TDF_Reference::GetID(),reference)) {
105 const TDF_Label& aLabel = reference->Get();
106 return aLabel.IsAttribute (myID);
109 return Standard_False;
113 //=======================================================================
116 //=======================================================================
118 void TDataStd_Real::Set(const Standard_Real v)
120 // OCC2932 correction
121 if( myValue == v) return;
127 //=======================================================================
130 //=======================================================================
132 Standard_Real TDataStd_Real::Get() const { return myValue; }
135 //=======================================================================
136 //function : SetDimension
138 //=======================================================================
140 void TDataStd_Real::SetDimension (const TDataStd_RealEnum DIM)
142 // OCC2932 correction
143 if(myDimension == DIM) return;
150 //=======================================================================
151 //function : GetDimension
153 //=======================================================================
155 TDataStd_RealEnum TDataStd_Real::GetDimension () const
161 //=======================================================================
164 //=======================================================================
166 const Standard_GUID& TDataStd_Real::ID() const { return myID; }
168 //=======================================================================
171 //=======================================================================
173 void TDataStd_Real::SetID( const Standard_GUID& theGuid)
175 if(myID == theGuid) return;
181 //=======================================================================
183 //purpose : sets default ID
184 //=======================================================================
185 void TDataStd_Real::SetID()
190 //=======================================================================
191 //function : NewEmpty
193 //=======================================================================
195 Handle(TDF_Attribute) TDataStd_Real::NewEmpty () const
197 return new TDataStd_Real();
200 //=======================================================================
203 //=======================================================================
205 void TDataStd_Real::Restore(const Handle(TDF_Attribute)& With)
207 Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (With);
209 Standard_DISABLE_DEPRECATION_WARNINGS
210 myDimension = R->GetDimension();
211 Standard_ENABLE_DEPRECATION_WARNINGS
217 //=======================================================================
220 //=======================================================================
222 void TDataStd_Real::Paste (const Handle(TDF_Attribute)& Into,
223 const Handle(TDF_RelocationTable)& /*RT*/) const
225 Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (Into);
227 Standard_DISABLE_DEPRECATION_WARNINGS
228 R->SetDimension(myDimension);
229 Standard_ENABLE_DEPRECATION_WARNINGS
233 //=======================================================================
236 //=======================================================================
238 Standard_OStream& TDataStd_Real::Dump (Standard_OStream& anOS) const
241 Standard_DISABLE_DEPRECATION_WARNINGS
242 TDataStd::Print(GetDimension(), anOS);
243 Standard_ENABLE_DEPRECATION_WARNINGS
245 Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
246 myID.ToCString(sguid);
251 //=======================================================================
252 //function : DumpJson
254 //=======================================================================
255 void TDataStd_Real::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
257 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
259 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
261 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myValue)
262 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDimension)
263 OCCT_DUMP_FIELD_VALUE_GUID (theOStream, myID)