Salome HOME
c2469e697a878803a276ebf8cbbdea96876e6519
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_StudyHandle.cxx
1 // Copyright (C) 2007-2024  CEA, EDF, 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_StudyHandle.cxx
24 //  Author : Sergey LITONIN
25 //  Module : SALOME
26 //
27 #include "SALOMEDSImpl_StudyHandle.hxx"
28
29 /*
30   Class       : SALOMEDSImpl_StudyHandle
31   Description : This class is intended for storing information about
32                 graphic representation of objects in dirrent views
33 */
34
35
36 //=======================================================================
37 //function : GetID
38 //purpose  : Get GUID of this attribute
39 //=======================================================================
40 const std::string& SALOMEDSImpl_StudyHandle::GetID()
41 {
42   static std::string SALOMEDSImpl_StudyHandleID( "050C9555-4BA8-49bf-8F1C-086F0469A40B" );
43   return SALOMEDSImpl_StudyHandleID;
44 }
45
46 //=======================================================================
47 //function : SALOMEDSImpl_StudyHandle
48 //purpose  : Empty Constructor
49 //=======================================================================
50 SALOMEDSImpl_StudyHandle::SALOMEDSImpl_StudyHandle()
51 {
52   myHandle = NULL;
53 }
54
55 //=======================================================================
56 //function : Set
57 //purpose  : 
58 //=======================================================================
59 SALOMEDSImpl_StudyHandle* SALOMEDSImpl_StudyHandle::Set(const DF_Label& theLabel, 
60                                                         SALOMEDSImpl_Study* theStudy)
61 {
62   SALOMEDSImpl_StudyHandle* A = NULL;
63   if (!(A=(SALOMEDSImpl_StudyHandle*)theLabel.FindAttribute(GetID()))) {
64     A = new SALOMEDSImpl_StudyHandle; 
65     theLabel.AddAttribute(A);
66   }
67
68   A->Set(theStudy);
69   return A;  
70 }
71
72
73 //=======================================================================
74 //function : ID
75 //purpose  : Get GUID of this attribute
76 //=======================================================================
77 const std::string& SALOMEDSImpl_StudyHandle::ID () const
78 {
79   return GetID();
80 }
81
82
83 //=======================================================================
84 //function : NewEmpty
85 //purpose  : Create new empty attribute
86 //=======================================================================
87 DF_Attribute* SALOMEDSImpl_StudyHandle::NewEmpty () const
88 {
89   return new SALOMEDSImpl_StudyHandle ();
90 }
91
92
93 //=======================================================================
94 //function : Restore
95 //purpose  : Restore value of attribute with value of theWith one
96 //=======================================================================
97 void SALOMEDSImpl_StudyHandle::Restore( DF_Attribute* theWith )
98 {
99   SALOMEDSImpl_StudyHandle* anAttr = dynamic_cast<SALOMEDSImpl_StudyHandle*>( theWith );
100   if ( anAttr ) Set ( anAttr->Get() );
101 }
102
103 //=======================================================================
104 //function : Paste
105 //purpose  : Paste value of current attribute to the value of entry one
106 //=======================================================================
107 void SALOMEDSImpl_StudyHandle::Paste( DF_Attribute* theInto)
108 {
109   SALOMEDSImpl_StudyHandle* anAttr =  dynamic_cast<SALOMEDSImpl_StudyHandle*>( theInto );
110   if ( anAttr ) anAttr->Set ( myHandle );
111 }
112