0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / BinMDataStd / BinMDataStd_VariableDriver.cxx
1 // Created on: 2001-08-24
2 // Created by: Alexnder GRIGORIEV
3 // Copyright (c) 2001-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16
17 #include <BinMDataStd_VariableDriver.hxx>
18 #include <BinObjMgt_Persistent.hxx>
19 #include <Message_Messenger.hxx>
20 #include <Standard_Type.hxx>
21 #include <TCollection_AsciiString.hxx>
22 #include <TDataStd_Variable.hxx>
23 #include <TDF_Attribute.hxx>
24
25 IMPLEMENT_STANDARD_RTTIEXT(BinMDataStd_VariableDriver,BinMDF_ADriver)
26
27 //=======================================================================
28 //function : BinMDataStd_VariableDriver
29 //purpose  : Constructor
30 //=======================================================================
31 BinMDataStd_VariableDriver::BinMDataStd_VariableDriver
32                         (const Handle(Message_Messenger)& theMsgDriver)
33       : BinMDF_ADriver (theMsgDriver, NULL)
34 {}
35
36 //=======================================================================
37 //function : NewEmpty
38 //purpose  : 
39 //=======================================================================
40 Handle(TDF_Attribute) BinMDataStd_VariableDriver::NewEmpty() const
41 {
42   return (new TDataStd_Variable());
43 }
44
45 //=======================================================================
46 //function : Paste
47 //purpose  : 
48 //=======================================================================
49 Standard_Boolean BinMDataStd_VariableDriver::Paste
50                                 (const BinObjMgt_Persistent&  theSource,
51                                  const Handle(TDF_Attribute)& theTarget,
52                                  BinObjMgt_RRelocationTable&  ) const
53 {
54   Handle(TDataStd_Variable) aV = Handle(TDataStd_Variable)::DownCast(theTarget);
55
56   Standard_Boolean isConstant;
57   if (! (theSource >> isConstant))
58     return Standard_False;
59   aV->Constant (isConstant);
60
61   TCollection_AsciiString anStr;
62   if (! (theSource >> anStr))
63     return Standard_False;
64   aV->Unit(anStr);
65   
66   return Standard_True;
67 }
68
69 //=======================================================================
70 //function : Paste
71 //purpose  : 
72 //=======================================================================
73 void BinMDataStd_VariableDriver::Paste (const Handle(TDF_Attribute)& theSource,
74                                         BinObjMgt_Persistent&        theTarget,
75                                         BinObjMgt_SRelocationTable&  ) const
76 {
77   Handle(TDataStd_Variable) aV = Handle(TDataStd_Variable)::DownCast(theSource);
78   theTarget << aV->IsConstant() << aV->Unit();
79 }