Salome HOME
PAL13000: Crash with 'import CALCULATOR_TEST_STUDY_WITHOUTIHM'
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_StudyHandle.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDSImpl_StudyHandle.cxx
21 //  Author : Sergey LITONIN
22 //  Module : SALOME
23
24 #include "SALOMEDSImpl_StudyHandle.hxx"
25 #include <TDF_Attribute.hxx>
26 #include <Standard_GUID.hxx>
27
28 /*
29   Class       : SALOMEDSImpl_StudyHandle
30   Description : This class is intended for storing information about
31                 graphic representation of objects in dirrent views
32 */
33
34 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_StudyHandle, TDF_Attribute )
35 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyHandle, TDF_Attribute )
36
37 //=======================================================================
38 //function : GetID
39 //purpose  : Get GUID of this attribute
40 //=======================================================================
41 const Standard_GUID& SALOMEDSImpl_StudyHandle::GetID()
42 {
43   static Standard_GUID SALOMEDSImpl_StudyHandleID( "050C9555-4BA8-49bf-8F1C-086F0469A40B" );
44   return SALOMEDSImpl_StudyHandleID;
45 }
46
47 //=======================================================================
48 //function : SALOMEDSImpl_StudyHandle
49 //purpose  : Empty Constructor
50 //=======================================================================
51 SALOMEDSImpl_StudyHandle::SALOMEDSImpl_StudyHandle()
52 {
53   myHandle.Nullify();
54 }
55
56 //=======================================================================
57 //function : Set
58 //purpose  : 
59 //=======================================================================
60 Handle(SALOMEDSImpl_StudyHandle) SALOMEDSImpl_StudyHandle::Set(const TDF_Label& theLabel, 
61                                                                const Handle(SALOMEDSImpl_Study)& theStudy)
62 {
63   Handle(SALOMEDSImpl_StudyHandle) A;
64   if (!theLabel.FindAttribute(GetID(), A)) {
65     A = new  SALOMEDSImpl_StudyHandle(); 
66     theLabel.AddAttribute(A);
67   }
68
69   A->SetHandle(theStudy);
70   return A;  
71 }
72
73
74 //=======================================================================
75 //function : ID
76 //purpose  : Get GUID of this attribute
77 //=======================================================================
78 const Standard_GUID& SALOMEDSImpl_StudyHandle::ID () const
79 {
80   return GetID();
81 }
82
83
84 //=======================================================================
85 //function : NewEmpty
86 //purpose  : Create new empty attribute
87 //=======================================================================
88 Handle(TDF_Attribute) SALOMEDSImpl_StudyHandle::NewEmpty () const
89 {
90   return new SALOMEDSImpl_StudyHandle ();
91 }
92
93
94 //=======================================================================
95 //function : Restore
96 //purpose  : Restore value of attribute with value of theWith one
97 //=======================================================================
98 void SALOMEDSImpl_StudyHandle::Restore( const Handle(TDF_Attribute)& theWith )
99 {
100   Handle(SALOMEDSImpl_StudyHandle) anAttr = Handle(SALOMEDSImpl_StudyHandle)::DownCast( theWith );
101   if ( !anAttr.IsNull() ) SetHandle( anAttr->GetHandle() );
102 }
103
104 //=======================================================================
105 //function : Paste
106 //purpose  : Paste value of current attribute to the value of entry one
107 //=======================================================================
108 void SALOMEDSImpl_StudyHandle::Paste( const Handle(TDF_Attribute)& theInto,
109                                        const Handle(TDF_RelocationTable)& ) const
110 {
111   Handle(SALOMEDSImpl_StudyHandle) anAttr =  Handle(SALOMEDSImpl_StudyHandle)::DownCast( theInto );
112   if ( !anAttr.IsNull() ) anAttr->SetHandle( myHandle );
113 }
114