1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <drawinglayer/attribute/materialattribute3d.hxx>
21 #include <basegfx/color/bcolor.hxx>
22 #include <rtl/instance.hxx>
25 namespace drawinglayer
29 class ImpMaterialAttribute3D
32 // materialAttribute3D definitions
33 basegfx::BColor maColor
; // object color
34 basegfx::BColor maSpecular
; // material specular color
35 basegfx::BColor maEmission
; // material emissive color
36 sal_uInt16 mnSpecularIntensity
; // material specular intensity [0..128]
38 ImpMaterialAttribute3D(const basegfx::BColor
& rColor
, const basegfx::BColor
& rSpecular
, const basegfx::BColor
& rEmission
, sal_uInt16 nSpecularIntensity
)
40 maSpecular(rSpecular
),
41 maEmission(rEmission
),
42 mnSpecularIntensity(nSpecularIntensity
)
46 explicit ImpMaterialAttribute3D(const basegfx::BColor
& rColor
)
48 maSpecular(1.0, 1.0, 1.0),
50 mnSpecularIntensity(15)
54 ImpMaterialAttribute3D()
55 : maColor(basegfx::BColor()),
56 maSpecular(basegfx::BColor()),
57 maEmission(basegfx::BColor()),
58 mnSpecularIntensity(0)
63 const basegfx::BColor
& getColor() const { return maColor
; }
64 const basegfx::BColor
& getSpecular() const { return maSpecular
; }
65 const basegfx::BColor
& getEmission() const { return maEmission
; }
66 sal_uInt16
getSpecularIntensity() const { return mnSpecularIntensity
; }
68 bool operator==(const ImpMaterialAttribute3D
& rCandidate
) const
70 return (getColor() == rCandidate
.getColor()
71 && getSpecular() == rCandidate
.getSpecular()
72 && getEmission() == rCandidate
.getEmission()
73 && getSpecularIntensity() == rCandidate
.getSpecularIntensity());
79 struct theGlobalDefault
:
80 public rtl::Static
< MaterialAttribute3D::ImplType
, theGlobalDefault
> {};
83 MaterialAttribute3D::MaterialAttribute3D(
84 const basegfx::BColor
& rColor
,
85 const basegfx::BColor
& rSpecular
,
86 const basegfx::BColor
& rEmission
,
87 sal_uInt16 nSpecularIntensity
)
88 : mpMaterialAttribute3D(ImpMaterialAttribute3D(
89 rColor
, rSpecular
, rEmission
, nSpecularIntensity
))
93 MaterialAttribute3D::MaterialAttribute3D(
94 const basegfx::BColor
& rColor
)
95 : mpMaterialAttribute3D(ImpMaterialAttribute3D(rColor
))
99 MaterialAttribute3D::MaterialAttribute3D()
100 : mpMaterialAttribute3D(theGlobalDefault::get())
104 MaterialAttribute3D::MaterialAttribute3D(const MaterialAttribute3D
&) = default;
106 MaterialAttribute3D::~MaterialAttribute3D() = default;
108 MaterialAttribute3D
& MaterialAttribute3D::operator=(const MaterialAttribute3D
&) = default;
110 bool MaterialAttribute3D::operator==(const MaterialAttribute3D
& rCandidate
) const
112 return rCandidate
.mpMaterialAttribute3D
== mpMaterialAttribute3D
;
115 const basegfx::BColor
& MaterialAttribute3D::getColor() const
117 return mpMaterialAttribute3D
->getColor();
120 const basegfx::BColor
& MaterialAttribute3D::getSpecular() const
122 return mpMaterialAttribute3D
->getSpecular();
125 const basegfx::BColor
& MaterialAttribute3D::getEmission() const
127 return mpMaterialAttribute3D
->getEmission();
130 sal_uInt16
MaterialAttribute3D::getSpecularIntensity() const
132 return mpMaterialAttribute3D
->getSpecularIntensity();
134 } // end of namespace attribute
135 } // end of namespace drawinglayer
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */