1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: materialattribute3d.cxx,v $
9 * last change: $Author: aw $ $Date: 2008-05-27 14:11:19 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/attribute/materialattribute3d.hxx>
40 #include <basegfx/color/bcolor.hxx>
42 //////////////////////////////////////////////////////////////////////////////
44 namespace drawinglayer
48 class ImpMaterialAttribute3D
51 // materialAttribute3D definitions
52 basegfx::BColor maColor
; // object color
53 basegfx::BColor maSpecular
; // material specular color
54 basegfx::BColor maEmission
; // material emissive color
55 sal_uInt16 mnSpecularIntensity
; // material specular intensity [0..128]
58 sal_uInt32 mnRefCount
;
60 ImpMaterialAttribute3D(const basegfx::BColor
& rColor
, const basegfx::BColor
& rSpecular
, const basegfx::BColor
& rEmission
, sal_uInt16 nSpecularIntensity
)
62 maSpecular(rSpecular
),
63 maEmission(rEmission
),
64 mnSpecularIntensity(nSpecularIntensity
),
69 ImpMaterialAttribute3D(const basegfx::BColor
& rColor
)
71 maSpecular(1.0, 1.0, 1.0),
73 mnSpecularIntensity(15),
78 ImpMaterialAttribute3D()
79 : mnSpecularIntensity(0),
84 bool operator==(const ImpMaterialAttribute3D
& rCandidate
) const
86 return (maColor
== rCandidate
.maColor
87 && maSpecular
== rCandidate
.maSpecular
88 && maEmission
== rCandidate
.maEmission
89 && mnSpecularIntensity
== rCandidate
.mnSpecularIntensity
);
92 const basegfx::BColor
& getColor() const { return maColor
; }
93 const basegfx::BColor
& getSpecular() const { return maSpecular
; }
94 const basegfx::BColor
& getEmission() const { return maEmission
; }
95 sal_uInt16
getSpecularIntensity() const { return mnSpecularIntensity
; }
97 } // end of anonymous namespace
98 } // end of namespace drawinglayer
100 //////////////////////////////////////////////////////////////////////////////
102 namespace drawinglayer
106 MaterialAttribute3D::MaterialAttribute3D(const basegfx::BColor
& rColor
, const basegfx::BColor
& rSpecular
, const basegfx::BColor
& rEmission
, sal_uInt16 nSpecularIntensity
)
107 : mpMaterialAttribute3D(new ImpMaterialAttribute3D(rColor
, rSpecular
, rEmission
, nSpecularIntensity
))
111 MaterialAttribute3D::MaterialAttribute3D(const basegfx::BColor
& rColor
)
112 : mpMaterialAttribute3D(new ImpMaterialAttribute3D(rColor
))
116 MaterialAttribute3D::MaterialAttribute3D()
117 : mpMaterialAttribute3D(new ImpMaterialAttribute3D())
121 MaterialAttribute3D::MaterialAttribute3D(const MaterialAttribute3D
& rCandidate
)
122 : mpMaterialAttribute3D(rCandidate
.mpMaterialAttribute3D
)
124 mpMaterialAttribute3D
->mnRefCount
++;
127 MaterialAttribute3D::~MaterialAttribute3D()
129 if(mpMaterialAttribute3D
->mnRefCount
)
131 mpMaterialAttribute3D
->mnRefCount
--;
135 delete mpMaterialAttribute3D
;
139 MaterialAttribute3D
& MaterialAttribute3D::operator=(const MaterialAttribute3D
& rCandidate
)
141 if(rCandidate
.mpMaterialAttribute3D
!= mpMaterialAttribute3D
)
143 if(mpMaterialAttribute3D
->mnRefCount
)
145 mpMaterialAttribute3D
->mnRefCount
--;
149 delete mpMaterialAttribute3D
;
152 mpMaterialAttribute3D
= rCandidate
.mpMaterialAttribute3D
;
153 mpMaterialAttribute3D
->mnRefCount
++;
159 bool MaterialAttribute3D::operator==(const MaterialAttribute3D
& rCandidate
) const
161 if(rCandidate
.mpMaterialAttribute3D
== mpMaterialAttribute3D
)
166 return (*rCandidate
.mpMaterialAttribute3D
== *mpMaterialAttribute3D
);
169 const basegfx::BColor
& MaterialAttribute3D::getColor() const
171 return mpMaterialAttribute3D
->getColor();
174 const basegfx::BColor
& MaterialAttribute3D::getSpecular() const
176 return mpMaterialAttribute3D
->getSpecular();
179 const basegfx::BColor
& MaterialAttribute3D::getEmission() const
181 return mpMaterialAttribute3D
->getEmission();
184 sal_uInt16
MaterialAttribute3D::getSpecularIntensity() const
186 return mpMaterialAttribute3D
->getSpecularIntensity();
188 } // end of namespace attribute
189 } // end of namespace drawinglayer
191 //////////////////////////////////////////////////////////////////////////////