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