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/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDSImpl_AttributeTextHighlightColor.cxx
21 // Author : Sergey RUIN
25 #include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
26 #include <Standard_GUID.hxx>
30 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute )
31 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute )
33 //=======================================================================
36 //=======================================================================
38 const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::GetID ()
40 static Standard_GUID SALOMEDSImpl_AttributeTextHighlightColorID ("12837190-8F52-11d6-A8A3-0001021E8C7F");
41 return SALOMEDSImpl_AttributeTextHighlightColorID;
46 //=======================================================================
47 //function : constructor
49 //=======================================================================
50 SALOMEDSImpl_AttributeTextHighlightColor::SALOMEDSImpl_AttributeTextHighlightColor()
51 :SALOMEDSImpl_GenericAttribute("AttributeTextHighlightColor")
53 myValue = new TColStd_HArray1OfReal(1, 3, RealFirst());
56 //=======================================================================
59 //=======================================================================
61 const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::ID () const { return GetID(); }
64 //=======================================================================
65 //function : SetTextHighlightColor
67 //=======================================================================
68 void SALOMEDSImpl_AttributeTextHighlightColor::SetTextHighlightColor(const Standard_Real R,
69 const Standard_Real G,
70 const Standard_Real B)
73 if(myValue.IsNull()) return;
76 myValue->SetValue(1, R);
77 myValue->SetValue(2, G);
78 myValue->SetValue(3, B);
80 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
83 //=======================================================================
84 //function : TextHighlightColor
86 //=======================================================================
87 Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextHighlightColor::TextHighlightColor()
92 //=======================================================================
93 //function : ChangeArray
95 //=======================================================================
96 void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray)
100 for(int i = 1; i <= 3; i++)
101 myValue->SetValue(i, newArray->Value(i));
103 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
106 //=======================================================================
107 //function : NewEmpty
109 //=======================================================================
111 Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextHighlightColor::NewEmpty () const
113 return new SALOMEDSImpl_AttributeTextHighlightColor();
116 //=======================================================================
119 //=======================================================================
121 void SALOMEDSImpl_AttributeTextHighlightColor::Restore(const Handle(TDF_Attribute)& with)
123 Handle(TColStd_HArray1OfReal) s = Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (with)->TextHighlightColor ();
128 //=======================================================================
131 //=======================================================================
133 void SALOMEDSImpl_AttributeTextHighlightColor::Paste (const Handle(TDF_Attribute)& into,
134 const Handle(TDF_RelocationTable)& ) const
136 Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (into)->ChangeArray (myValue);
139 TCollection_AsciiString SALOMEDSImpl_AttributeTextHighlightColor::Save()
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);
150 void SALOMEDSImpl_AttributeTextHighlightColor::Load(const TCollection_AsciiString& value)
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);