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.
18 #include <Standard_GUID.hxx>
19 #include <Standard_Type.hxx>
20 #include <TDataStd.hxx>
21 #include <TDataStd_Real.hxx>
22 #include <TDF_Attribute.hxx>
23 #include <TDF_Label.hxx>
24 #include <TDF_Reference.hxx>
25 #include <TDF_RelocationTable.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Real,TDF_Attribute)
29 //=======================================================================
32 //=======================================================================
33 const Standard_GUID& TDataStd_Real::GetID()
35 static Standard_GUID TDataStd_RealID("2a96b60f-ec8b-11d0-bee7-080009dc3333");
36 return TDataStd_RealID;
40 //=======================================================================
43 //=======================================================================
45 Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L,
46 const Standard_Real V)
48 Handle(TDataStd_Real) A;
49 if (!L.FindAttribute(TDataStd_Real::GetID(), A)) {
50 A = new TDataStd_Real ();
58 //=======================================================================
60 //purpose : User defined attribute
61 //=======================================================================
63 Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L, const Standard_GUID& theGuid,
64 const Standard_Real V)
66 Handle(TDataStd_Real) A;
67 if (!L.FindAttribute(theGuid, A)) {
68 A = new TDataStd_Real ();
76 //=======================================================================
77 //function : TDataStd_Real
78 //purpose : Empty constructor
79 //=======================================================================
81 TDataStd_Real::TDataStd_Real ()
82 : myValue (RealFirst()),
83 myDimension (TDataStd_SCALAR),
89 //=======================================================================
90 //function : IsCaptured
92 //=======================================================================
94 Standard_Boolean TDataStd_Real::IsCaptured() const
96 Handle(TDF_Reference) reference;
99 if (Label().FindAttribute(TDF_Reference::GetID(),reference)) {
100 const TDF_Label& aLabel = reference->Get();
101 return aLabel.IsAttribute (myID);
104 return Standard_False;
108 //=======================================================================
111 //=======================================================================
113 void TDataStd_Real::Set(const Standard_Real v)
115 // OCC2932 correction
116 if( myValue == v) return;
122 //=======================================================================
125 //=======================================================================
127 Standard_Real TDataStd_Real::Get() const { return myValue; }
130 //=======================================================================
131 //function : SetDimension
133 //=======================================================================
135 void TDataStd_Real::SetDimension (const TDataStd_RealEnum DIM)
137 // OCC2932 correction
138 if(myDimension == DIM) return;
145 //=======================================================================
146 //function : GetDimension
148 //=======================================================================
150 TDataStd_RealEnum TDataStd_Real::GetDimension () const
156 //=======================================================================
159 //=======================================================================
161 const Standard_GUID& TDataStd_Real::ID() const { return myID; }
163 //=======================================================================
166 //=======================================================================
168 void TDataStd_Real::SetID( const Standard_GUID& theGuid)
170 if(myID == theGuid) return;
176 //=======================================================================
178 //purpose : sets default ID
179 //=======================================================================
180 void TDataStd_Real::SetID()
185 //=======================================================================
186 //function : NewEmpty
188 //=======================================================================
190 Handle(TDF_Attribute) TDataStd_Real::NewEmpty () const
192 Handle(TDataStd_Real) Att = new TDataStd_Real();
197 //=======================================================================
200 //=======================================================================
202 void TDataStd_Real::Restore(const Handle(TDF_Attribute)& With)
204 Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (With);
206 myDimension = R->GetDimension();
212 //=======================================================================
215 //=======================================================================
217 void TDataStd_Real::Paste (const Handle(TDF_Attribute)& Into,
218 const Handle(TDF_RelocationTable)& /*RT*/) const
220 Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (Into);
222 R->SetDimension(myDimension);
226 //=======================================================================
229 //=======================================================================
231 Standard_OStream& TDataStd_Real::Dump (Standard_OStream& anOS) const
234 TDataStd::Print(GetDimension(),anOS);
236 Standard_Character sguid[Standard_GUID_SIZE_ALLOC];
237 myID.ToCString(sguid);