Salome HOME
PR: merge from branch BR_UnitTests tag mergeto_trunk_17oct05
[modules/yacs.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTextHighlightColor.cxx
1 //  File   : SALOMEDSImpl_AttributeTextHighlightColor.cxx
2 //  Author : Sergey RUIN
3 //  Module : SALOME
4
5
6 #include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
7 #include <Standard_GUID.hxx>
8
9 using namespace std;
10
11 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute )
12 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute )
13
14 //=======================================================================
15 //function : GetID
16 //purpose  : 
17 //=======================================================================
18
19 const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::GetID () 
20 {
21   static Standard_GUID SALOMEDSImpl_AttributeTextHighlightColorID ("12837190-8F52-11d6-A8A3-0001021E8C7F");
22   return SALOMEDSImpl_AttributeTextHighlightColorID;
23 }
24
25
26
27 //=======================================================================
28 //function : constructor
29 //purpose  : 
30 //=======================================================================
31 SALOMEDSImpl_AttributeTextHighlightColor::SALOMEDSImpl_AttributeTextHighlightColor()
32 :SALOMEDSImpl_GenericAttribute("AttributeTextHighlightColor")
33
34   myValue = new TColStd_HArray1OfReal(1, 3, RealFirst());
35 }
36
37 //=======================================================================
38 //function : ID
39 //purpose  : 
40 //=======================================================================
41
42 const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::ID () const { return GetID(); }
43
44
45 //=======================================================================
46 //function : SetTextHighlightColor
47 //purpose  :
48 //=======================================================================
49 void SALOMEDSImpl_AttributeTextHighlightColor::SetTextHighlightColor(const Standard_Real R, 
50                                                                      const Standard_Real G, 
51                                                                      const Standard_Real B)
52 {
53    CheckLocked();
54    if(myValue.IsNull()) return;  
55    Backup(); 
56
57    myValue->SetValue(1, R);
58    myValue->SetValue(2, G);
59    myValue->SetValue(3, B);
60    
61    SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
62 }
63             
64 //=======================================================================
65 //function : TextHighlightColor
66 //purpose  :
67 //=======================================================================
68 Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextHighlightColor::TextHighlightColor()
69 {
70    return myValue;
71 }      
72
73 //=======================================================================
74 //function : ChangeArray
75 //purpose  : 
76 //=======================================================================
77 void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray)
78 {
79   Backup();
80
81   for(int i = 1; i <= 3; i++)
82     myValue->SetValue(i, newArray->Value(i));
83
84   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved  
85 }    
86
87 //=======================================================================
88 //function : NewEmpty
89 //purpose  : 
90 //=======================================================================
91
92 Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextHighlightColor::NewEmpty () const
93 {  
94   return new SALOMEDSImpl_AttributeTextHighlightColor(); 
95 }
96
97 //=======================================================================
98 //function : Restore
99 //purpose  : 
100 //=======================================================================
101
102 void SALOMEDSImpl_AttributeTextHighlightColor::Restore(const Handle(TDF_Attribute)& with) 
103 {
104   Handle(TColStd_HArray1OfReal) s = Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (with)->TextHighlightColor ();
105   ChangeArray(s);
106   return;
107 }
108
109 //=======================================================================
110 //function : Paste
111 //purpose  : 
112 //=======================================================================
113
114 void SALOMEDSImpl_AttributeTextHighlightColor::Paste (const Handle(TDF_Attribute)& into,
115                                                   const Handle(TDF_RelocationTable)& ) const
116 {
117   Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (into)->ChangeArray (myValue);
118 }
119
120 TCollection_AsciiString SALOMEDSImpl_AttributeTextHighlightColor::Save() 
121 {
122   char *Val = new char[75];
123   sprintf(Val, "%f %f %f", (float)myValue->Value(1), 
124                            (float)myValue->Value(2), 
125                            (float)myValue->Value(3));
126   TCollection_AsciiString ret(Val);
127   delete Val;
128   return ret;
129 }
130
131 void SALOMEDSImpl_AttributeTextHighlightColor::Load(const TCollection_AsciiString& value) 
132 {
133   float r, g, b;
134   sscanf(value.ToCString(), "%f %f %f", &r, &g, &b);
135   myValue->SetValue(1, r);
136   myValue->SetValue(2, g);
137   myValue->SetValue(3, b);
138 }
139