e9d273752d6df8e4c16c7619c422d1d3abf62266
[occt.git] / src / MPrsStd / MPrsStd_AISPresentationRetrievalDriver.cxx
1 // Created on: 1999-07-08
2 // Created by: Sergey RUIN
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <MPrsStd_AISPresentationRetrievalDriver.ixx>
24
25 #include <PPrsStd_AISPresentation.hxx>
26 #include <TPrsStd_AISPresentation.hxx>
27 #include <AIS_Drawer.hxx>
28 #include <TCollection_ExtendedString.hxx>
29 #include <PCollection_HExtendedString.hxx>
30 #include <Quantity_NameOfColor.hxx>
31 #include <Graphic3d_NameOfMaterial.hxx>
32 #include <CDM_MessageDriver.hxx>
33
34 //=======================================================================
35 //function : MPrsStd_AISPresentationRetrievalDriver
36 //purpose  : 
37 //=======================================================================
38
39 MPrsStd_AISPresentationRetrievalDriver::MPrsStd_AISPresentationRetrievalDriver(const Handle(CDM_MessageDriver)& theMsgDriver):MDF_ARDriver(theMsgDriver)
40 {}
41
42 Standard_Integer MPrsStd_AISPresentationRetrievalDriver::VersionNumber() const
43 { return 0; }
44
45 Handle(Standard_Type) MPrsStd_AISPresentationRetrievalDriver::SourceType() const
46 { return STANDARD_TYPE(PPrsStd_AISPresentation); }
47
48 Handle(TDF_Attribute) MPrsStd_AISPresentationRetrievalDriver::NewEmpty() const
49 { return new TPrsStd_AISPresentation; }
50
51 void MPrsStd_AISPresentationRetrievalDriver::Paste(const Handle(PDF_Attribute)& Source,const Handle(TDF_Attribute)& Target,const Handle(MDF_RRelocationTable)& RelocTable) const
52 {
53   Handle(PPrsStd_AISPresentation) S = Handle(PPrsStd_AISPresentation)::DownCast (Source);
54   Handle(TPrsStd_AISPresentation) T = Handle(TPrsStd_AISPresentation)::DownCast (Target);
55
56   T->SetDisplayed( S->IsDisplayed() );  
57
58   TCollection_ExtendedString extstr = (S->GetDriverGUID())->Convert();   
59   Standard_GUID guid( extstr.ToExtString() );  
60  
61   T->SetDriverGUID( guid ); 
62
63   if( S->Color() != -1 ) T->SetColor( (Quantity_NameOfColor)(S->Color()) );
64   else T->UnsetColor();
65
66   if( S->Material() != -1 ) T->SetMaterial( (Graphic3d_NameOfMaterial)(S->Material()) );
67   else T->UnsetMaterial(); 
68
69   if( S->Transparency() != -1. ) T->SetTransparency( S->Transparency() );
70   else T->UnsetTransparency(); 
71
72   if( S->Width() != -1. ) T->SetWidth( S->Width() );
73   else T->UnsetWidth(); 
74
75 #ifdef DEB
76   cout << "AISPresentationRetrievalDriver "  << "retrieved DriverGUID ==> ";
77   guid.ShallowDump(cout);
78   cout << endl;
79 #endif
80 }
81