1 // Created on: 2004-11-24
2 // Created by: Edward AGAPOV
3 // Copyright (c) 2004-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 // The original implementation Copyright: (C) RINA S.p.A
18 #include <BinTObjDrivers_ModelDriver.hxx>
20 #include <BinObjMgt_Persistent.hxx>
21 #include <CDM_MessageDriver.hxx>
22 #include <Standard_GUID.hxx>
23 #include <TDF_Attribute.hxx>
25 #include <TObj_TModel.hxx>
26 #include <TObj_Model.hxx>
27 #include <TObj_Assistant.hxx>
32 IMPLEMENT_STANDARD_RTTIEXT(BinTObjDrivers_ModelDriver,BinMDF_ADriver)
34 //=======================================================================
35 //function : BinTObjDrivers_ModelDriver
36 //purpose : constructor
37 //=======================================================================
39 BinTObjDrivers_ModelDriver::BinTObjDrivers_ModelDriver
40 (const Handle(CDM_MessageDriver)& theMessageDriver)
41 : BinMDF_ADriver( theMessageDriver, NULL)
45 //=======================================================================
47 //purpose : Creates a new attribute
48 //=======================================================================
50 Handle(TDF_Attribute) BinTObjDrivers_ModelDriver::NewEmpty() const
52 return new TObj_TModel;
55 //=======================================================================
57 //purpose : Translate the contents of <theSource> and put it
59 // Set CurrentModel of TObj_Assistant into theTarget TObj_TModel
60 // if its GUID and GUID stored in theSource are same
61 //=======================================================================
63 Standard_Boolean BinTObjDrivers_ModelDriver::Paste
64 (const BinObjMgt_Persistent& theSource,
65 const Handle(TDF_Attribute)& theTarget,
66 BinObjMgt_RRelocationTable&) const
69 if (! (theSource >> aGUID)) return Standard_False;
71 Handle(TObj_Model) aCurrentModel = TObj_Assistant::GetCurrentModel();
72 if (aCurrentModel.IsNull()) return Standard_False;
74 if (aGUID != aCurrentModel->GetGUID())
76 WriteMessage("TObj_TModel retrieval: wrong model GUID");
77 return Standard_False;
80 Handle(TObj_TModel) aTModel = Handle(TObj_TModel)::DownCast( theTarget );
81 aCurrentModel->SetLabel ( aTModel->Label() );
82 aTModel->Set( aCurrentModel );
86 //=======================================================================
88 //purpose : Translate the contents of <theSource> and put it
90 // a Model is stored as its GUID
91 //=======================================================================
93 void BinTObjDrivers_ModelDriver::Paste
94 (const Handle(TDF_Attribute)& theSource,
95 BinObjMgt_Persistent& theTarget,
96 BinObjMgt_SRelocationTable&) const
98 Handle(TObj_TModel) aTModel =
99 Handle(TObj_TModel)::DownCast( theSource );
100 Handle(TObj_Model) aModel = aTModel->Model();
101 if (!aModel.IsNull())
104 Standard_GUID aGUID = aModel->GetGUID();