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>
24 namespace drawinglayer::attribute
26 class ImpMaterialAttribute3D
29 // materialAttribute3D definitions
30 basegfx::BColor maColor
; // object color
31 basegfx::BColor maSpecular
; // material specular color
32 basegfx::BColor maEmission
; // material emissive color
33 sal_uInt16 mnSpecularIntensity
; // material specular intensity [0..128]
35 ImpMaterialAttribute3D(const basegfx::BColor
& rColor
, const basegfx::BColor
& rSpecular
, const basegfx::BColor
& rEmission
, sal_uInt16 nSpecularIntensity
)
37 maSpecular(rSpecular
),
38 maEmission(rEmission
),
39 mnSpecularIntensity(nSpecularIntensity
)
43 explicit ImpMaterialAttribute3D(const basegfx::BColor
& rColor
)
45 maSpecular(1.0, 1.0, 1.0),
46 mnSpecularIntensity(15)
50 ImpMaterialAttribute3D()
51 : mnSpecularIntensity(0)
56 const basegfx::BColor
& getColor() const { return maColor
; }
57 const basegfx::BColor
& getSpecular() const { return maSpecular
; }
58 const basegfx::BColor
& getEmission() const { return maEmission
; }
59 sal_uInt16
getSpecularIntensity() const { return mnSpecularIntensity
; }
61 bool operator==(const ImpMaterialAttribute3D
& rCandidate
) const
63 return (getColor() == rCandidate
.getColor()
64 && getSpecular() == rCandidate
.getSpecular()
65 && getEmission() == rCandidate
.getEmission()
66 && getSpecularIntensity() == rCandidate
.getSpecularIntensity());
72 MaterialAttribute3D::ImplType
& theGlobalDefault()
74 static MaterialAttribute3D::ImplType SINGLETON
;
79 MaterialAttribute3D::MaterialAttribute3D(
80 const basegfx::BColor
& rColor
,
81 const basegfx::BColor
& rSpecular
,
82 const basegfx::BColor
& rEmission
,
83 sal_uInt16 nSpecularIntensity
)
84 : mpMaterialAttribute3D(ImpMaterialAttribute3D(
85 rColor
, rSpecular
, rEmission
, nSpecularIntensity
))
89 MaterialAttribute3D::MaterialAttribute3D(
90 const basegfx::BColor
& rColor
)
91 : mpMaterialAttribute3D(ImpMaterialAttribute3D(rColor
))
95 MaterialAttribute3D::MaterialAttribute3D()
96 : mpMaterialAttribute3D(theGlobalDefault())
100 MaterialAttribute3D::MaterialAttribute3D(const MaterialAttribute3D
&) = default;
102 MaterialAttribute3D::~MaterialAttribute3D() = default;
104 MaterialAttribute3D
& MaterialAttribute3D::operator=(const MaterialAttribute3D
&) = default;
106 bool MaterialAttribute3D::operator==(const MaterialAttribute3D
& rCandidate
) const
108 return rCandidate
.mpMaterialAttribute3D
== mpMaterialAttribute3D
;
111 const basegfx::BColor
& MaterialAttribute3D::getColor() const
113 return mpMaterialAttribute3D
->getColor();
116 const basegfx::BColor
& MaterialAttribute3D::getSpecular() const
118 return mpMaterialAttribute3D
->getSpecular();
121 const basegfx::BColor
& MaterialAttribute3D::getEmission() const
123 return mpMaterialAttribute3D
->getEmission();
126 sal_uInt16
MaterialAttribute3D::getSpecularIntensity() const
128 return mpMaterialAttribute3D
->getSpecularIntensity();
131 } // end of namespace
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */