blob: 0b2f9cddf9ff28a786968ba304c5c6d53696f7ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// File : XmlTObjDrivers_ModelDriver.cxx
// Created : Wed Nov 24 11:14:21 2004
// Author : Edward AGAPOV
// Copyright: Open CASCADE 2007
// The original implementation Copyright: (C) RINA S.p.A
#include "XmlTObjDrivers_ModelDriver.hxx"
#include <CDM_MessageDriver.hxx>
#include <XmlObjMgt_Persistent.hxx>
#include <XmlObjMgt_RRelocationTable.hxx>
#include <XmlObjMgt.hxx>
#include <Standard_GUID.hxx>
#include <TDF_Attribute.hxx>
#include <TObj_TModel.hxx>
#include <TObj_Model.hxx>
#include <TObj_Assistant.hxx>
IMPLEMENT_STANDARD_HANDLE(XmlTObjDrivers_ModelDriver,XmlMDF_ADriver)
IMPLEMENT_STANDARD_RTTIEXT(XmlTObjDrivers_ModelDriver,XmlMDF_ADriver);
//=======================================================================
//function : XmlTObjDrivers_ModelDriver
//purpose : constructor
//=======================================================================
XmlTObjDrivers_ModelDriver::XmlTObjDrivers_ModelDriver
(const Handle(CDM_MessageDriver)& theMessageDriver)
: XmlMDF_ADriver( theMessageDriver, NULL)
{
}
//=======================================================================
//function : NewEmpty
//purpose : Creates a new attribute
//=======================================================================
Handle(TDF_Attribute) XmlTObjDrivers_ModelDriver::NewEmpty() const
{
return new TObj_TModel;
}
//=======================================================================
//function : Paste
//purpose : Translate the contents of <aSource> and put it
// into <aTarget>, using the relocation table
// <aRelocTable> to keep the sharings.
// Set CurrentModel of TObj_Assistant into Target TObj_TModel
// if its GUID and GUID stored in Source are same
//=======================================================================
Standard_Boolean XmlTObjDrivers_ModelDriver::Paste
(const XmlObjMgt_Persistent& Source,
const Handle(TDF_Attribute)& Target,
XmlObjMgt_RRelocationTable& /*RelocTable*/) const
{
TCollection_ExtendedString aString;
if (XmlObjMgt::GetExtendedString (Source, aString))
{
Standard_GUID aGUID (aString.ToExtString());
Handle(TObj_Model) aCurrentModel = TObj_Assistant::GetCurrentModel();
if (aGUID == aCurrentModel->GetGUID())
{
Handle(TObj_TModel) aTModel = Handle(TObj_TModel)::DownCast( Target );
aCurrentModel->SetLabel ( aTModel->Label() );
aTModel->Set( aCurrentModel );
return Standard_True;
}
WriteMessage("TObj_TModel retrieval: wrong model GUID");
return Standard_False;
}
WriteMessage("error retrieving ExtendedString for type TObj_TModel");
return Standard_False;
}
//=======================================================================
//function : Paste
//purpose : Translate the contents of <aSource> and put it
// into <aTarget>, using the relocation table
// <aRelocTable> to keep the sharings.
// a Model is stored as its GUID
//=======================================================================
void XmlTObjDrivers_ModelDriver::Paste
(const Handle(TDF_Attribute)& Source,
XmlObjMgt_Persistent& Target,
XmlObjMgt_SRelocationTable& /*RelocTable*/) const
{
Handle(TObj_TModel) aTModel =
Handle(TObj_TModel)::DownCast( Source );
Handle(TObj_Model) aModel = aTModel->Model();
// Store model GUID.
Standard_PCharacter aPGuidString = new Standard_Character[256];
aModel->GetGUID().ToCString( aPGuidString );
XmlObjMgt::SetExtendedString (Target, *aPGuidString);
delete []aPGuidString;
}
|