Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <drawinglayer/attribute/materialattribute3d.hxx>
21 : #include <basegfx/color/bcolor.hxx>
22 : #include <rtl/instance.hxx>
23 :
24 :
25 :
26 : namespace drawinglayer
27 : {
28 : namespace attribute
29 : {
30 0 : class ImpMaterialAttribute3D
31 : {
32 : public:
33 : // materialAttribute3D definitions
34 : basegfx::BColor maColor; // object color
35 : basegfx::BColor maSpecular; // material specular color
36 : basegfx::BColor maEmission; // material emissive color
37 : sal_uInt16 mnSpecularIntensity; // material specular intensity [0..128]
38 :
39 0 : ImpMaterialAttribute3D(const basegfx::BColor& rColor, const basegfx::BColor& rSpecular, const basegfx::BColor& rEmission, sal_uInt16 nSpecularIntensity)
40 : : maColor(rColor),
41 : maSpecular(rSpecular),
42 : maEmission(rEmission),
43 0 : mnSpecularIntensity(nSpecularIntensity)
44 : {
45 0 : }
46 :
47 0 : ImpMaterialAttribute3D(const basegfx::BColor& rColor)
48 : : maColor(rColor),
49 : maSpecular(1.0, 1.0, 1.0),
50 : maEmission(),
51 0 : mnSpecularIntensity(15)
52 : {
53 0 : }
54 :
55 0 : ImpMaterialAttribute3D()
56 : : maColor(basegfx::BColor()),
57 : maSpecular(basegfx::BColor()),
58 : maEmission(basegfx::BColor()),
59 0 : mnSpecularIntensity(0)
60 : {
61 0 : }
62 :
63 : // data read access
64 0 : const basegfx::BColor& getColor() const { return maColor; }
65 0 : const basegfx::BColor& getSpecular() const { return maSpecular; }
66 0 : const basegfx::BColor& getEmission() const { return maEmission; }
67 0 : sal_uInt16 getSpecularIntensity() const { return mnSpecularIntensity; }
68 :
69 0 : bool operator==(const ImpMaterialAttribute3D& rCandidate) const
70 : {
71 0 : return (getColor() == rCandidate.getColor()
72 0 : && getSpecular() == rCandidate.getSpecular()
73 0 : && getEmission() == rCandidate.getEmission()
74 0 : && getSpecularIntensity() == rCandidate.getSpecularIntensity());
75 : }
76 : };
77 :
78 : namespace
79 : {
80 : struct theGlobalDefault :
81 : public rtl::Static< MaterialAttribute3D::ImplType, theGlobalDefault > {};
82 : }
83 :
84 0 : MaterialAttribute3D::MaterialAttribute3D(
85 : const basegfx::BColor& rColor,
86 : const basegfx::BColor& rSpecular,
87 : const basegfx::BColor& rEmission,
88 : sal_uInt16 nSpecularIntensity)
89 : : mpMaterialAttribute3D(ImpMaterialAttribute3D(
90 0 : rColor, rSpecular, rEmission, nSpecularIntensity))
91 : {
92 0 : }
93 :
94 0 : MaterialAttribute3D::MaterialAttribute3D(
95 : const basegfx::BColor& rColor)
96 0 : : mpMaterialAttribute3D(ImpMaterialAttribute3D(rColor))
97 : {
98 0 : }
99 :
100 0 : MaterialAttribute3D::MaterialAttribute3D()
101 0 : : mpMaterialAttribute3D(theGlobalDefault::get())
102 : {
103 0 : }
104 :
105 0 : MaterialAttribute3D::MaterialAttribute3D(const MaterialAttribute3D& rCandidate)
106 0 : : mpMaterialAttribute3D(rCandidate.mpMaterialAttribute3D)
107 : {
108 0 : }
109 :
110 0 : MaterialAttribute3D::~MaterialAttribute3D()
111 : {
112 0 : }
113 :
114 0 : MaterialAttribute3D& MaterialAttribute3D::operator=(const MaterialAttribute3D& rCandidate)
115 : {
116 0 : mpMaterialAttribute3D = rCandidate.mpMaterialAttribute3D;
117 0 : return *this;
118 : }
119 :
120 0 : bool MaterialAttribute3D::operator==(const MaterialAttribute3D& rCandidate) const
121 : {
122 0 : return rCandidate.mpMaterialAttribute3D == mpMaterialAttribute3D;
123 : }
124 :
125 0 : const basegfx::BColor& MaterialAttribute3D::getColor() const
126 : {
127 0 : return mpMaterialAttribute3D->getColor();
128 : }
129 :
130 0 : const basegfx::BColor& MaterialAttribute3D::getSpecular() const
131 : {
132 0 : return mpMaterialAttribute3D->getSpecular();
133 : }
134 :
135 0 : const basegfx::BColor& MaterialAttribute3D::getEmission() const
136 : {
137 0 : return mpMaterialAttribute3D->getEmission();
138 : }
139 :
140 0 : sal_uInt16 MaterialAttribute3D::getSpecularIntensity() const
141 : {
142 0 : return mpMaterialAttribute3D->getSpecularIntensity();
143 : }
144 : } // end of namespace attribute
145 : } // end of namespace drawinglayer
146 :
147 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|