Salome HOME
Copyright update 2021
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_AttributeTextHighlightColor.cxx
index a9323e0084600201eb871dd6317abb986ef58231..e10b63a6e05eb5f0d7105b6964045b5c1dc168aa 100644 (file)
@@ -1,43 +1,39 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2007-2021  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 
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// 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 
+// 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/
+// 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;
 }
 
@@ -50,7 +46,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);
 }
 
 //=======================================================================
@@ -58,33 +57,32 @@ 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 
 }
-           
+            
 //=======================================================================
 //function : TextHighlightColor
 //purpose  :
 //=======================================================================
-Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextHighlightColor::TextHighlightColor()
+std::vector<double> SALOMEDSImpl_AttributeTextHighlightColor::TextHighlightColor()
 {
    return myValue;
 }      
@@ -93,12 +91,12 @@ Handle(TColStd_HArray1OfReal) SALOMEDSImpl_AttributeTextHighlightColor::TextHigh
 //function : ChangeArray
 //purpose  : 
 //=======================================================================
-void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const Handle(TColStd_HArray1OfReal)& newArray)
+void SALOMEDSImpl_AttributeTextHighlightColor::ChangeArray(const std::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  
 }    
@@ -108,7 +106,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(); 
 }
@@ -118,10 +116,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;
 }
 
@@ -130,29 +127,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() 
+std::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]);
+  std::string ret(Val);
   delete Val;
   return ret;
 }
 
-void SALOMEDSImpl_AttributeTextHighlightColor::Load(const TCollection_AsciiString& value) 
+void SALOMEDSImpl_AttributeTextHighlightColor::Load(const std::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;
 }