Salome HOME
53428e3714d4d2f552fbbbccdbf34870dc5bb803
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTextHighlightColor.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDSImpl_AttributeTextHighlightColor.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25 #include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
26 #include <Standard_GUID.hxx>
27
28 using namespace std;
29
30 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute )
31 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute )
32
33 //=======================================================================
34 //function : GetID
35 //purpose  : 
36 //=======================================================================
37
38 const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::GetID () 
39 {
40   static Standard_GUID SALOMEDSImpl_AttributeTextHighlightColorID ("12837190-8F52-11d6-A8A3-0001021E8C7F");
41   return SALOMEDSImpl_AttributeTextHighlightColorID;
42 }
43
44
45
46 //=======================================================================
47 //function : constructor
48 //purpose  : 
49 //=======================================================================
50 SALOMEDSImpl_AttributeTextHighlightColor::SALOMEDSImpl_AttributeTextHighlightColor()
51 :SALOMEDSImpl_GenericAttribute("AttributeTextHighlightColor")
52
53   myValue = new TColStd_HArray1OfReal(1, 3, RealFirst());
54 }
55
56 //=======================================================================
57 //function : ID
58 //purpose  : 
59 //=======================================================================
60
61 const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::ID () const { return GetID(); }
62
63
64 //=======================================================================
65 //function : SetTextHighlightColor
66 //purpose  :
67 //=======================================================================
68 void SALOMEDSImpl_AttributeTextHighlightColor::SetTextHighlightColor(const Standard_Real R, 
69                                                                      const Standard_Real G, 
70                                                                      const Standard_Real B)
71 {
72    CheckLocked();
73    if(myValue.IsNull()) return;  
74    Backup(); 
75
76    myValue->SetValue(1, R);
77    myValue->SetValue(2, G);
78    myValue->SetValue(3, B);
79    
80    SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
81 }
82             
83 //=======================================================================
84 //function : TextHighlightColor
85 //purpose  :
86 //=======================================================================
87 Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextHighlightColor::TextHighlightColor()
88 {
89    return myValue;
90 }      
91
92 //=======================================================================
93 //function : ChangeArray
94 //purpose  : 
95 //=======================================================================
96 void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray)
97 {
98   Backup();
99
100   for(int i = 1; i <= 3; i++)
101     myValue->SetValue(i, newArray->Value(i));
102
103   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved  
104 }    
105
106 //=======================================================================
107 //function : NewEmpty
108 //purpose  : 
109 //=======================================================================
110
111 Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextHighlightColor::NewEmpty () const
112 {  
113   return new SALOMEDSImpl_AttributeTextHighlightColor(); 
114 }
115
116 //=======================================================================
117 //function : Restore
118 //purpose  : 
119 //=======================================================================
120
121 void SALOMEDSImpl_AttributeTextHighlightColor::Restore(const Handle(TDF_Attribute)& with) 
122 {
123   Handle(TColStd_HArray1OfReal) s = Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (with)->TextHighlightColor ();
124   ChangeArray(s);
125   return;
126 }
127
128 //=======================================================================
129 //function : Paste
130 //purpose  : 
131 //=======================================================================
132
133 void SALOMEDSImpl_AttributeTextHighlightColor::Paste (const Handle(TDF_Attribute)& into,
134                                                   const Handle(TDF_RelocationTable)& ) const
135 {
136   Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (into)->ChangeArray (myValue);
137 }
138
139 TCollection_AsciiString SALOMEDSImpl_AttributeTextHighlightColor::Save() 
140 {
141   char *Val = new char[75];
142   sprintf(Val, "%f %f %f", (float)myValue->Value(1), 
143                            (float)myValue->Value(2), 
144                            (float)myValue->Value(3));
145   TCollection_AsciiString ret(Val);
146   delete Val;
147   return ret;
148 }
149
150 void SALOMEDSImpl_AttributeTextHighlightColor::Load(const TCollection_AsciiString& value) 
151 {
152   float r, g, b;
153   sscanf(value.ToCString(), "%f %f %f", &r, &g, &b);
154   myValue->SetValue(1, r);
155   myValue->SetValue(2, g);
156   myValue->SetValue(3, b);
157 }
158