Salome HOME
CCAR: add a check to see if the CORBA object exists (non_existent())
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTextHighlightColor.cxx
1 //  Copyright (C) 2007-2008  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.
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 //  File   : SALOMEDSImpl_AttributeTextHighlightColor.cxx
23 //  Author : Sergey RUIN
24 //  Module : SALOME
25 //
26 #include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
27
28 using namespace std;
29
30 //=======================================================================
31 //function : GetID
32 //purpose  : 
33 //=======================================================================
34
35 const std::string& SALOMEDSImpl_AttributeTextHighlightColor::GetID () 
36 {
37   static std::string SALOMEDSImpl_AttributeTextHighlightColorID ("12837190-8F52-11d6-A8A3-0001021E8C7F");
38   return SALOMEDSImpl_AttributeTextHighlightColorID;
39 }
40
41
42
43 //=======================================================================
44 //function : constructor
45 //purpose  : 
46 //=======================================================================
47 SALOMEDSImpl_AttributeTextHighlightColor::SALOMEDSImpl_AttributeTextHighlightColor()
48 :SALOMEDSImpl_GenericAttribute("AttributeTextHighlightColor")
49
50   myValue.clear();
51   myValue.push_back(0.0);
52   myValue.push_back(0.0);
53   myValue.push_back(0.0);
54 }
55
56 //=======================================================================
57 //function : ID
58 //purpose  : 
59 //=======================================================================
60
61 const std::string& SALOMEDSImpl_AttributeTextHighlightColor::ID () const { return GetID(); }
62
63
64 //=======================================================================
65 //function : SetTextHighlightColor
66 //purpose  :
67 //=======================================================================
68 void SALOMEDSImpl_AttributeTextHighlightColor::SetTextHighlightColor(const double& R, 
69                                                                      const double& G, 
70                                                                      const double& B)
71 {
72    CheckLocked();
73    Backup(); 
74
75    myValue[0] = R;
76    myValue[1] = G;
77    myValue[2] = B;
78    
79    SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
80 }
81             
82 //=======================================================================
83 //function : TextHighlightColor
84 //purpose  :
85 //=======================================================================
86 vector<double> SALOMEDSImpl_AttributeTextHighlightColor::TextHighlightColor()
87 {
88    return myValue;
89 }      
90
91 //=======================================================================
92 //function : ChangeArray
93 //purpose  : 
94 //=======================================================================
95 void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const vector<double>& newArray)
96 {
97   Backup();
98
99   for(int i = 0; i < 3; i++)
100     myValue[i] = newArray[i];
101
102   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved  
103 }    
104
105 //=======================================================================
106 //function : NewEmpty
107 //purpose  : 
108 //=======================================================================
109
110 DF_Attribute* SALOMEDSImpl_AttributeTextHighlightColor::NewEmpty () const
111 {  
112   return new SALOMEDSImpl_AttributeTextHighlightColor(); 
113 }
114
115 //=======================================================================
116 //function : Restore
117 //purpose  : 
118 //=======================================================================
119
120 void SALOMEDSImpl_AttributeTextHighlightColor::Restore(DF_Attribute* with) 
121 {
122   ChangeArray(dynamic_cast<SALOMEDSImpl_AttributeTextHighlightColor*>(with)->TextHighlightColor());;
123   return;
124 }
125
126 //=======================================================================
127 //function : Paste
128 //purpose  : 
129 //=======================================================================
130
131 void SALOMEDSImpl_AttributeTextHighlightColor::Paste (DF_Attribute* into)
132 {
133   dynamic_cast<SALOMEDSImpl_AttributeTextHighlightColor*>(into)->ChangeArray (myValue);
134 }
135
136 string SALOMEDSImpl_AttributeTextHighlightColor::Save() 
137 {
138   char *Val = new char[75];
139   sprintf(Val, "%f %f %f", (float)myValue[0], 
140                            (float)myValue[1], 
141                            (float)myValue[2]);
142   string ret(Val);
143   delete Val;
144   return ret;
145 }
146
147 void SALOMEDSImpl_AttributeTextHighlightColor::Load(const string& value) 
148 {
149   float r, g, b;
150   sscanf(value.c_str(), "%f %f %f", &r, &g, &b);
151   myValue[0] = r;
152   myValue[1] = g;
153   myValue[2] = b;
154 }
155