Salome HOME
Issue 0020472: An error in SALOMEDSImpl_Tool::Exists
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTextHighlightColor.cxx
index fd9615b7ac8066ea6b7118015deaaff119e511a5..8624d52f66e4ae8b2dc89aa3b546490037486dbd 100644 (file)
@@ -1,24 +1,40 @@
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 //  File   : SALOMEDSImpl_AttributeTextHighlightColor.cxx
 //  Author : Sergey RUIN
 //  Module : SALOME
-
-
+//
 #include "SALOMEDSImpl_AttributeTextHighlightColor.hxx"
-#include <Standard_GUID.hxx>
 
 using namespace std;
 
-IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute )
-IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeTextHighlightColor, SALOMEDSImpl_GenericAttribute )
-
 //=======================================================================
 //function : GetID
 //purpose  : 
 //=======================================================================
 
-const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::GetID () 
+const std::string& SALOMEDSImpl_AttributeTextHighlightColor::GetID () 
 {
-  static Standard_GUID SALOMEDSImpl_AttributeTextHighlightColorID ("12837190-8F52-11d6-A8A3-0001021E8C7F");
+  static std::string SALOMEDSImpl_AttributeTextHighlightColorID ("12837190-8F52-11d6-A8A3-0001021E8C7F");
   return SALOMEDSImpl_AttributeTextHighlightColorID;
 }
 
@@ -31,7 +47,10 @@ const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::GetID ()
 SALOMEDSImpl_AttributeTextHighlightColor::SALOMEDSImpl_AttributeTextHighlightColor()
 :SALOMEDSImpl_GenericAttribute("AttributeTextHighlightColor")
 { 
-  myValue = new TColStd_HArray1OfReal(1, 3, RealFirst());
+  myValue.clear();
+  myValue.push_back(0.0);
+  myValue.push_back(0.0);
+  myValue.push_back(0.0);
 }
 
 //=======================================================================
@@ -39,24 +58,23 @@ SALOMEDSImpl_AttributeTextHighlightColor::SALOMEDSImpl_AttributeTextHighlightCol
 //purpose  : 
 //=======================================================================
 
-const Standard_GUID& SALOMEDSImpl_AttributeTextHighlightColor::ID () const { return GetID(); }
+const std::string& SALOMEDSImpl_AttributeTextHighlightColor::ID () const { return GetID(); }
 
 
 //=======================================================================
 //function : SetTextHighlightColor
 //purpose  :
 //=======================================================================
-void SALOMEDSImpl_AttributeTextHighlightColor::SetTextHighlightColor(const Standard_Real R, 
-                                                                    const Standard_Real G, 
-                                                                    const Standard_Real B)
+void SALOMEDSImpl_AttributeTextHighlightColor::SetTextHighlightColor(const double& R, 
+                                                                    const double& G, 
+                                                                    const double& B)
 {
    CheckLocked();
-   if(myValue.IsNull()) return;  
    Backup(); 
 
-   myValue->SetValue(1, R);
-   myValue->SetValue(2, G);
-   myValue->SetValue(3, B);
+   myValue[0] = R;
+   myValue[1] = G;
+   myValue[2] = B;
    
    SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved 
 }
@@ -65,7 +83,7 @@ void SALOMEDSImpl_AttributeTextHighlightColor::SetTextHighlightColor(const Stand
 //function : TextHighlightColor
 //purpose  :
 //=======================================================================
-Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextHighlightColor::TextHighlightColor()
+vector<double> SALOMEDSImpl_AttributeTextHighlightColor::TextHighlightColor()
 {
    return myValue;
 }      
@@ -74,12 +92,12 @@ Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextHighlightColor::TextHigh
 //function : ChangeArray
 //purpose  : 
 //=======================================================================
-void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray)
+void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const vector<double>& newArray)
 {
   Backup();
 
-  for(int i = 1; i <= 3; i++)
-    myValue->SetValue(i, newArray->Value(i));
+  for(int i = 0; i < 3; i++)
+    myValue[i] = newArray[i];
 
   SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved  
 }    
@@ -89,7 +107,7 @@ void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const Handle(TColStd_
 //purpose  : 
 //=======================================================================
 
-Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextHighlightColor::NewEmpty () const
+DF_Attribute* SALOMEDSImpl_AttributeTextHighlightColor::NewEmpty () const
 {  
   return new SALOMEDSImpl_AttributeTextHighlightColor(); 
 }
@@ -99,10 +117,9 @@ Handle(TDF_Attribute) SALOMEDSImpl_AttributeTextHighlightColor::NewEmpty () cons
 //purpose  : 
 //=======================================================================
 
-void SALOMEDSImpl_AttributeTextHighlightColor::Restore(const Handle(TDF_Attribute)& with) 
+void SALOMEDSImpl_AttributeTextHighlightColor::Restore(DF_Attribute* with) 
 {
-  Handle(TColStd_HArray1OfReal) s = Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (with)->TextHighlightColor ();
-  ChangeArray(s);
+  ChangeArray(dynamic_cast<SALOMEDSImpl_AttributeTextHighlightColor*>(with)->TextHighlightColor());;
   return;
 }
 
@@ -111,29 +128,28 @@ void SALOMEDSImpl_AttributeTextHighlightColor::Restore(const Handle(TDF_Attribut
 //purpose  : 
 //=======================================================================
 
-void SALOMEDSImpl_AttributeTextHighlightColor::Paste (const Handle(TDF_Attribute)& into,
-                                                  const Handle(TDF_RelocationTable)& ) const
+void SALOMEDSImpl_AttributeTextHighlightColor::Paste (DF_Attribute* into)
 {
-  Handle(SALOMEDSImpl_AttributeTextHighlightColor)::DownCast (into)->ChangeArray (myValue);
+  dynamic_cast<SALOMEDSImpl_AttributeTextHighlightColor*>(into)->ChangeArray (myValue);
 }
 
-TCollection_AsciiString SALOMEDSImpl_AttributeTextHighlightColor::Save() 
+string SALOMEDSImpl_AttributeTextHighlightColor::Save() 
 {
   char *Val = new char[75];
-  sprintf(Val, "%f %f %f", (float)myValue->Value(1)
-                           (float)myValue->Value(2)
-                          (float)myValue->Value(3));
-  TCollection_AsciiString ret(Val);
+  sprintf(Val, "%f %f %f", (float)myValue[0]
+                           (float)myValue[1]
+                          (float)myValue[2]);
+  string ret(Val);
   delete Val;
   return ret;
 }
 
-void SALOMEDSImpl_AttributeTextHighlightColor::Load(const TCollection_AsciiString& value) 
+void SALOMEDSImpl_AttributeTextHighlightColor::Load(const string& value) 
 {
   float r, g, b;
-  sscanf(value.ToCString(), "%f %f %f", &r, &g, &b);
-  myValue->SetValue(1, r);
-  myValue->SetValue(2, g);
-  myValue->SetValue(3, b);
+  sscanf(value.c_str(), "%f %f %f", &r, &g, &b);
+  myValue[0] = r;
+  myValue[1] = g;
+  myValue[2] = b;
 }