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 <BinMPrsStd_AISPresentationDriver.ixx>
17 #include <TPrsStd_AISPresentation.hxx>
18 #include <Graphic3d_NameOfMaterial.hxx>
19 #include <Quantity_NameOfColor.hxx>
20 #include <CDM_MessageDriver.hxx>
21 //=======================================================================
22 //function : BinMDataStd_AISPresentationDriver
23 //purpose : Constructor
24 //=======================================================================
26 BinMPrsStd_AISPresentationDriver::BinMPrsStd_AISPresentationDriver
27 (const Handle(CDM_MessageDriver)& theMsgDriver)
28 : BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(TPrsStd_AISPresentation)->Name())
32 //=======================================================================
35 //=======================================================================
37 Handle(TDF_Attribute) BinMPrsStd_AISPresentationDriver::NewEmpty() const
39 return new TPrsStd_AISPresentation();
42 //=======================================================================
44 //purpose : persistent -> transient (retrieve)
45 //=======================================================================
47 Standard_Boolean BinMPrsStd_AISPresentationDriver::Paste
48 (const BinObjMgt_Persistent& theSource,
49 const Handle(TDF_Attribute)& theTarget,
50 BinObjMgt_RRelocationTable& ) const
52 Handle(TPrsStd_AISPresentation) anAtt = Handle(TPrsStd_AISPresentation)::DownCast(theTarget);
53 Standard_Integer aValue;
55 Standard_Boolean ok = theSource >> aValue;
57 anAtt->SetDisplayed((Standard_Boolean)aValue);
61 ok = theSource >> aGUID;
63 anAtt->SetDriverGUID(aGUID);
66 ok = theSource >> aValue;
68 if(aValue != -1) anAtt->SetColor( (Quantity_NameOfColor)(aValue) );
69 else anAtt->UnsetColor();
72 ok = theSource >> aValue;
74 if(aValue != -1) anAtt->SetMaterial( (Graphic3d_NameOfMaterial)(aValue) );
75 else anAtt->UnsetMaterial();
78 Standard_Real aRValue;
79 ok = theSource >> aRValue;
81 if(aRValue != -1.) anAtt->SetTransparency(aRValue);
82 else anAtt->UnsetTransparency();
85 ok = theSource >> aRValue;
87 if(aRValue != -1.) anAtt->SetWidth( aRValue );
88 else anAtt->UnsetWidth();
91 ok = theSource >> aValue;
93 if(aValue != -1) anAtt->SetMode(aValue);
94 else anAtt->UnsetMode();
99 //=======================================================================
101 //purpose : transient -> persistent (store)
102 //=======================================================================
104 void BinMPrsStd_AISPresentationDriver::Paste (const Handle(TDF_Attribute)& theSource,
105 BinObjMgt_Persistent& theTarget,
106 BinObjMgt_SRelocationTable& ) const
108 Handle(TPrsStd_AISPresentation) anAtt = Handle(TPrsStd_AISPresentation)::DownCast(theSource);
110 theTarget.PutBoolean(anAtt->IsDisplayed());//Bool
112 theTarget.PutGUID(anAtt->GetDriverGUID());//GUID
114 if(anAtt->HasOwnColor())
115 theTarget.PutInteger((Standard_Integer)anAtt->Color());//Color
116 else theTarget.PutInteger(-1);
118 if(anAtt->HasOwnMaterial())
119 theTarget.PutInteger((Standard_Integer)anAtt->Material());
120 else theTarget.PutInteger(-1);
122 if(anAtt->HasOwnTransparency())
123 theTarget.PutReal(anAtt->Transparency()); //Real
124 else theTarget.PutReal(-1.);
126 if(anAtt->HasOwnWidth())
127 theTarget.PutReal(anAtt->Width());// Real
128 else theTarget.PutReal(-1.);
130 if(anAtt->HasOwnMode())
131 theTarget.PutInteger(anAtt->Mode()); //Int
132 else theTarget.PutInteger(-1);