1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
18 // See http://www.salome-platform.org/
20 // File : SALOMEDSImpl_AttributeTextColor.cxx
21 // Author : Sergey RUIN
25 #include "SALOMEDSImpl_AttributeTextColor.hxx"
26 #include <Standard_GUID.hxx>
30 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextColor, SALOMEDSImpl_GenericAttribute )
31 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTextColor, SALOMEDSImpl_GenericAttribute )
33 //=======================================================================
36 //=======================================================================
38 const Standard_GUID& SALOMEDSImpl_AttributeTextColor::GetID ()
40 static Standard_GUID SALOMEDSImpl_AttributeTextColorID ("12837189-8F52-11d6-A8A3-0001021E8C7F");
41 return SALOMEDSImpl_AttributeTextColorID;
45 //=======================================================================
46 //function : constructor
48 //=======================================================================
49 SALOMEDSImpl_AttributeTextColor::SALOMEDSImpl_AttributeTextColor()
50 :SALOMEDSImpl_GenericAttribute("AttributeTextColor")
52 myValue = new TColStd_HArray1OfReal(1, 3, RealFirst());
55 //=======================================================================
56 //function : SetTextColor
58 //=======================================================================
59 void SALOMEDSImpl_AttributeTextColor::SetTextColor(const Standard_Real R, const Standard_Real G, const Standard_Real B)
62 if(myValue.IsNull()) return;
65 myValue->SetValue(1, R);
66 myValue->SetValue(2, G);
67 myValue->SetValue(3, B);
69 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
72 //=======================================================================
73 //function : TextColor
75 //=======================================================================
76 Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextColor::TextColor()
81 //=======================================================================
82 //function : ChangeArray
84 //=======================================================================
85 void SALOMEDSImpl_AttributeTextColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray)
89 for(int i = 1; i <= 3; i++)
90 myValue->SetValue(i, newArray->Value(i));
92 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
95 //=======================================================================
98 //=======================================================================
100 const Standard_GUID& SALOMEDSImpl_AttributeTextColor::ID () const { return GetID(); }
103 //=======================================================================
104 //function : NewEmpty
106 //=======================================================================
108 Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextColor::NewEmpty () const
110 return new SALOMEDSImpl_AttributeTextColor();
113 //=======================================================================
116 //=======================================================================
118 void SALOMEDSImpl_AttributeTextColor::Restore(const Handle(TDF_Attribute)& with)
120 Handle(TColStd_HArray1OfReal) s = Handle(SALOMEDSImpl_AttributeTextColor)::DownCast (with)->TextColor ();
125 //=======================================================================
128 //=======================================================================
130 void SALOMEDSImpl_AttributeTextColor::Paste (const Handle(TDF_Attribute)& into,
131 const Handle(TDF_RelocationTable)& RT) const
133 Handle(SALOMEDSImpl_AttributeTextColor)::DownCast (into)->ChangeArray (myValue);
138 TCollection_AsciiString SALOMEDSImpl_AttributeTextColor::Save()
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);
149 void SALOMEDSImpl_AttributeTextColor::Load(const TCollection_AsciiString& value)
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);