Salome HOME
Roll back invalid integration.
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTextColor.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_AttributeTextColor.cxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24
25 #include "SALOMEDSImpl_AttributeTextColor.hxx"
26 #include <Standard_GUID.hxx>
27
28 using namespace std;
29
30 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextColor, SALOMEDSImpl_GenericAttribute )
31 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTextColor, SALOMEDSImpl_GenericAttribute )
32
33 //=======================================================================
34 //function : GetID
35 //purpose  : 
36 //=======================================================================
37
38 const Standard_GUID& SALOMEDSImpl_AttributeTextColor::GetID () 
39 {
40   static Standard_GUID SALOMEDSImpl_AttributeTextColorID ("12837189-8F52-11d6-A8A3-0001021E8C7F");
41   return SALOMEDSImpl_AttributeTextColorID;
42 }
43
44
45 //=======================================================================
46 //function : constructor
47 //purpose  : 
48 //=======================================================================
49 SALOMEDSImpl_AttributeTextColor::SALOMEDSImpl_AttributeTextColor()
50 :SALOMEDSImpl_GenericAttribute("AttributeTextColor")
51 {
52   myValue = new TColStd_HArray1OfReal(1, 3, RealFirst());
53 }
54
55 //=======================================================================
56 //function : SetTextColor
57 //purpose  :
58 //=======================================================================   
59 void SALOMEDSImpl_AttributeTextColor::SetTextColor(const Standard_Real R, const Standard_Real G, const Standard_Real B)
60 {
61    CheckLocked();
62    if(myValue.IsNull()) return;  
63    Backup(); 
64
65    myValue->SetValue(1, R);
66    myValue->SetValue(2, G);
67    myValue->SetValue(3, B);
68    
69    SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
70 }
71
72 //=======================================================================
73 //function : TextColor
74 //purpose  :
75 //=======================================================================
76 Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextColor::TextColor()
77 {
78   return myValue; 
79 }
80
81 //=======================================================================
82 //function : ChangeArray
83 //purpose  : 
84 //=======================================================================
85 void SALOMEDSImpl_AttributeTextColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray)
86 {
87   Backup();
88
89   for(int i = 1; i <= 3; i++)
90     myValue->SetValue(i, newArray->Value(i));
91     
92   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved     
93 }    
94
95 //=======================================================================
96 //function : ID
97 //purpose  : 
98 //=======================================================================
99
100 const Standard_GUID& SALOMEDSImpl_AttributeTextColor::ID () const { return GetID(); }
101
102
103 //=======================================================================
104 //function : NewEmpty
105 //purpose  : 
106 //=======================================================================
107
108 Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextColor::NewEmpty () const
109 {  
110   return new SALOMEDSImpl_AttributeTextColor(); 
111 }
112
113 //=======================================================================
114 //function : Restore
115 //purpose  : 
116 //=======================================================================
117
118 void SALOMEDSImpl_AttributeTextColor::Restore(const Handle(TDF_Attribute)& with) 
119 {
120   Handle(TColStd_HArray1OfReal) s = Handle(SALOMEDSImpl_AttributeTextColor)::DownCast (with)->TextColor ();
121   ChangeArray(s);
122   return;
123 }
124
125 //=======================================================================
126 //function : Paste
127 //purpose  : 
128 //=======================================================================
129
130 void SALOMEDSImpl_AttributeTextColor::Paste (const Handle(TDF_Attribute)& into,
131                                              const Handle(TDF_RelocationTable)& RT) const
132 {
133   Handle(SALOMEDSImpl_AttributeTextColor)::DownCast (into)->ChangeArray (myValue);
134 }
135
136
137
138 TCollection_AsciiString SALOMEDSImpl_AttributeTextColor::Save() 
139 {
140   char *Val = new char[75];
141   sprintf(Val, "%f %f %f", (float)myValue->Value(1), 
142                            (float)myValue->Value(2), 
143                            (float)myValue->Value(3));
144   TCollection_AsciiString ret(Val);
145   delete Val;
146   return ret;
147 }
148
149 void SALOMEDSImpl_AttributeTextColor::Load(const TCollection_AsciiString& value) 
150 {
151   float r, g, b;
152   sscanf(value.ToCString(), "%f %f %f", &r, &g, &b);
153   myValue->SetValue(1, r);
154   myValue->SetValue(2, g);
155   myValue->SetValue(3, b);
156 }