1 // Created on: 2004-05-17
2 // Created by: Sergey ZARITCHNY
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 #include <BinMDataXtd_PresentationDriver.hxx>
18 #include <TDataXtd_Presentation.hxx>
19 #include <BinObjMgt_Persistent.hxx>
20 #include <Message_Messenger.hxx>
22 IMPLEMENT_STANDARD_RTTIEXT(BinMDataXtd_PresentationDriver,BinMDF_ADriver)
24 //=======================================================================
25 //function : BinMDataStd_AISPresentationDriver
26 //purpose : Constructor
27 //=======================================================================
28 BinMDataXtd_PresentationDriver::BinMDataXtd_PresentationDriver
29 (const Handle(Message_Messenger)& theMsgDriver)
30 : BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(TDataXtd_Presentation)->Name())
34 //=======================================================================
37 //=======================================================================
39 Handle(TDF_Attribute) BinMDataXtd_PresentationDriver::NewEmpty() const
41 return new TDataXtd_Presentation();
44 //=======================================================================
46 //purpose : persistent -> transient (retrieve)
47 //=======================================================================
49 Standard_Boolean BinMDataXtd_PresentationDriver::Paste
50 (const BinObjMgt_Persistent& theSource,
51 const Handle(TDF_Attribute)& theTarget,
52 BinObjMgt_RRelocationTable& /*theRT*/) const
54 Standard_Boolean ok = Standard_False;
55 Handle(TDataXtd_Presentation) anAttribute = Handle(TDataXtd_Presentation)::DownCast(theTarget);
58 Standard_Integer aValue;
59 ok = theSource >> aValue;
61 anAttribute->SetDisplayed (aValue != 0);
65 ok = theSource >> aGUID;
67 anAttribute->SetDriverGUID(aGUID);
70 ok = theSource >> aValue;
73 anAttribute->SetColor((Quantity_NameOfColor)aValue);
75 anAttribute->UnsetColor();
78 ok = theSource >> aValue;
81 anAttribute->SetMaterialIndex(aValue);
83 anAttribute->UnsetMaterial();
86 Standard_Real aRValue;
87 ok = theSource >> aRValue;
90 anAttribute->SetTransparency(aRValue);
92 anAttribute->UnsetTransparency();
95 ok = theSource >> aRValue;
98 anAttribute->SetWidth(aRValue);
100 anAttribute->UnsetWidth();
103 ok = theSource >> aValue;
104 if ( !ok ) return ok;
106 anAttribute->SetMode(aValue);
108 anAttribute->UnsetMode();
113 //=======================================================================
115 //purpose : transient -> persistent (store)
116 //=======================================================================
118 void BinMDataXtd_PresentationDriver::Paste(const Handle(TDF_Attribute)& theSource,
119 BinObjMgt_Persistent& theTarget,
120 BinObjMgt_SRelocationTable& /*theSRT*/) const
122 Handle(TDataXtd_Presentation) anAttribute = Handle(TDataXtd_Presentation)::DownCast(theSource);
125 theTarget.PutBoolean(anAttribute->IsDisplayed());
128 theTarget.PutGUID(anAttribute->GetDriverGUID());
131 if (anAttribute->HasOwnColor())
132 theTarget.PutInteger(anAttribute->Color());
134 theTarget.PutInteger(-1);
137 if (anAttribute->HasOwnMaterial())
138 theTarget.PutInteger(anAttribute->MaterialIndex());
140 theTarget.PutInteger(-1);
143 if (anAttribute->HasOwnTransparency())
144 theTarget.PutReal(anAttribute->Transparency());
146 theTarget.PutReal(-1.);
149 if (anAttribute->HasOwnWidth())
150 theTarget.PutReal(anAttribute->Width());
152 theTarget.PutReal(-1.);
155 if (anAttribute->HasOwnMode())
156 theTarget.PutInteger(anAttribute->Mode());
158 theTarget.PutInteger(-1);