LibreOffice Module chart2 (master) 1
SceneProperties.cxx
Go to the documentation of this file.
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 <SceneProperties.hxx>
21#include <ChartType.hxx>
22#include <ChartTypeHelper.hxx>
23#include <com/sun/star/beans/PropertyAttribute.hpp>
24#include <com/sun/star/drawing/HomogenMatrix.hpp>
25#include <com/sun/star/drawing/ShadeMode.hpp>
26#include <com/sun/star/drawing/Direction3D.hpp>
27#include <com/sun/star/drawing/ProjectionMode.hpp>
28#include <com/sun/star/drawing/CameraGeometry.hpp>
29
30using namespace ::com::sun::star;
31
32using ::com::sun::star::beans::Property;
33
34namespace chart
35{
36
38 std::vector< Property > & rOutProperties )
39{
40 // transformation matrix
41 rOutProperties.emplace_back( "D3DTransformMatrix",
44 beans::PropertyAttribute::BOUND
45 | beans::PropertyAttribute::MAYBEVOID
46 | beans::PropertyAttribute::MAYBEDEFAULT );
47
48 // distance: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
49 rOutProperties.emplace_back( "D3DSceneDistance",
52 beans::PropertyAttribute::BOUND
53 | beans::PropertyAttribute::MAYBEVOID
54 | beans::PropertyAttribute::MAYBEDEFAULT );
55
56 // focalLength: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
57 rOutProperties.emplace_back( "D3DSceneFocalLength",
60 beans::PropertyAttribute::BOUND
61 | beans::PropertyAttribute::MAYBEVOID
62 | beans::PropertyAttribute::MAYBEDEFAULT );
63
64 // shadowSlant
65 rOutProperties.emplace_back( "D3DSceneShadowSlant",
68 beans::PropertyAttribute::BOUND
69 | beans::PropertyAttribute::MAYBEVOID
70 | beans::PropertyAttribute::MAYBEDEFAULT );
71
72 // shadeMode
73 rOutProperties.emplace_back( "D3DSceneShadeMode",
76 beans::PropertyAttribute::BOUND
77 | beans::PropertyAttribute::MAYBEVOID
78 | beans::PropertyAttribute::MAYBEDEFAULT );
79
80 // ambientColor
81 rOutProperties.emplace_back( "D3DSceneAmbientColor",
84 beans::PropertyAttribute::BOUND
85 | beans::PropertyAttribute::MAYBEVOID
86 | beans::PropertyAttribute::MAYBEDEFAULT );
87
88 // lightingMode
89 rOutProperties.emplace_back( "D3DSceneTwoSidedLighting",
92 beans::PropertyAttribute::BOUND
93 | beans::PropertyAttribute::MAYBEVOID
94 | beans::PropertyAttribute::MAYBEDEFAULT );
95
96 // camera geometry
97 rOutProperties.emplace_back( "D3DCameraGeometry",
100 beans::PropertyAttribute::BOUND
101 | beans::PropertyAttribute::MAYBEVOID
102 | beans::PropertyAttribute::MAYBEDEFAULT );
103
104 // perspective
105 rOutProperties.emplace_back( "D3DScenePerspective",
108 beans::PropertyAttribute::BOUND
109 | beans::PropertyAttribute::MAYBEVOID
110 | beans::PropertyAttribute::MAYBEDEFAULT );
111
112 // Light Sources
113 // light source 1
114 rOutProperties.emplace_back( "D3DSceneLightColor1",
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::MAYBEVOID
119 | beans::PropertyAttribute::MAYBEDEFAULT );
120 rOutProperties.emplace_back( "D3DSceneLightDirection1",
123 beans::PropertyAttribute::BOUND
124 | beans::PropertyAttribute::MAYBEVOID
125 | beans::PropertyAttribute::MAYBEDEFAULT );
126 rOutProperties.emplace_back( "D3DSceneLightOn1",
129 beans::PropertyAttribute::BOUND
130 | beans::PropertyAttribute::MAYBEVOID
131 | beans::PropertyAttribute::MAYBEDEFAULT );
132 // light source 2
133 rOutProperties.emplace_back( "D3DSceneLightColor2",
136 beans::PropertyAttribute::BOUND
137 | beans::PropertyAttribute::MAYBEVOID
138 | beans::PropertyAttribute::MAYBEDEFAULT );
139 rOutProperties.emplace_back( "D3DSceneLightDirection2",
142 beans::PropertyAttribute::BOUND
143 | beans::PropertyAttribute::MAYBEVOID
144 | beans::PropertyAttribute::MAYBEDEFAULT );
145 rOutProperties.emplace_back( "D3DSceneLightOn2",
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::MAYBEVOID
150 | beans::PropertyAttribute::MAYBEDEFAULT );
151 // light source 3
152 rOutProperties.emplace_back( "D3DSceneLightColor3",
155 beans::PropertyAttribute::BOUND
156 | beans::PropertyAttribute::MAYBEVOID
157 | beans::PropertyAttribute::MAYBEDEFAULT );
158 rOutProperties.emplace_back( "D3DSceneLightDirection3",
161 beans::PropertyAttribute::BOUND
162 | beans::PropertyAttribute::MAYBEVOID
163 | beans::PropertyAttribute::MAYBEDEFAULT );
164 rOutProperties.emplace_back( "D3DSceneLightOn3",
167 beans::PropertyAttribute::BOUND
168 | beans::PropertyAttribute::MAYBEVOID
169 | beans::PropertyAttribute::MAYBEDEFAULT );
170 // light source 4
171 rOutProperties.emplace_back( "D3DSceneLightColor4",
174 beans::PropertyAttribute::BOUND
175 | beans::PropertyAttribute::MAYBEVOID
176 | beans::PropertyAttribute::MAYBEDEFAULT );
177 rOutProperties.emplace_back( "D3DSceneLightDirection4",
180 beans::PropertyAttribute::BOUND
181 | beans::PropertyAttribute::MAYBEVOID
182 | beans::PropertyAttribute::MAYBEDEFAULT );
183 rOutProperties.emplace_back( "D3DSceneLightOn4",
186 beans::PropertyAttribute::BOUND
187 | beans::PropertyAttribute::MAYBEVOID
188 | beans::PropertyAttribute::MAYBEDEFAULT );
189 // light source 5
190 rOutProperties.emplace_back( "D3DSceneLightColor5",
193 beans::PropertyAttribute::BOUND
194 | beans::PropertyAttribute::MAYBEVOID
195 | beans::PropertyAttribute::MAYBEDEFAULT );
196 rOutProperties.emplace_back( "D3DSceneLightDirection5",
199 beans::PropertyAttribute::BOUND
200 | beans::PropertyAttribute::MAYBEVOID
201 | beans::PropertyAttribute::MAYBEDEFAULT );
202 rOutProperties.emplace_back( "D3DSceneLightOn5",
205 beans::PropertyAttribute::BOUND
206 | beans::PropertyAttribute::MAYBEVOID
207 | beans::PropertyAttribute::MAYBEDEFAULT );
208 // light source 6
209 rOutProperties.emplace_back( "D3DSceneLightColor6",
212 beans::PropertyAttribute::BOUND
213 | beans::PropertyAttribute::MAYBEVOID
214 | beans::PropertyAttribute::MAYBEDEFAULT );
215 rOutProperties.emplace_back( "D3DSceneLightDirection6",
218 beans::PropertyAttribute::BOUND
219 | beans::PropertyAttribute::MAYBEVOID
220 | beans::PropertyAttribute::MAYBEDEFAULT );
221 rOutProperties.emplace_back( "D3DSceneLightOn6",
224 beans::PropertyAttribute::BOUND
225 | beans::PropertyAttribute::MAYBEVOID
226 | beans::PropertyAttribute::MAYBEDEFAULT );
227 // light source 7
228 rOutProperties.emplace_back( "D3DSceneLightColor7",
231 beans::PropertyAttribute::BOUND
232 | beans::PropertyAttribute::MAYBEVOID
233 | beans::PropertyAttribute::MAYBEDEFAULT );
234 rOutProperties.emplace_back( "D3DSceneLightDirection7",
237 beans::PropertyAttribute::BOUND
238 | beans::PropertyAttribute::MAYBEVOID
239 | beans::PropertyAttribute::MAYBEDEFAULT );
240 rOutProperties.emplace_back( "D3DSceneLightOn7",
243 beans::PropertyAttribute::BOUND
244 | beans::PropertyAttribute::MAYBEVOID
245 | beans::PropertyAttribute::MAYBEDEFAULT );
246 // light source 8
247 rOutProperties.emplace_back( "D3DSceneLightColor8",
250 beans::PropertyAttribute::BOUND
251 | beans::PropertyAttribute::MAYBEVOID
252 | beans::PropertyAttribute::MAYBEDEFAULT );
253 rOutProperties.emplace_back( "D3DSceneLightDirection8",
256 beans::PropertyAttribute::BOUND
257 | beans::PropertyAttribute::MAYBEVOID
258 | beans::PropertyAttribute::MAYBEDEFAULT );
259 rOutProperties.emplace_back( "D3DSceneLightOn8",
262 beans::PropertyAttribute::BOUND
263 | beans::PropertyAttribute::MAYBEVOID
264 | beans::PropertyAttribute::MAYBEDEFAULT );
265}
266
269{
270 // Identity Matrix
271 drawing::HomogenMatrix aMtx;
272 aMtx.Line1.Column1 = aMtx.Line2.Column2 =
273 aMtx.Line3.Column3 = aMtx.Line4.Column4 = 1.0;
274 aMtx.Line1.Column2 = aMtx.Line1.Column3 = aMtx.Line1.Column4 =
275 aMtx.Line2.Column1 = aMtx.Line2.Column3 = aMtx.Line2.Column4 =
276 aMtx.Line3.Column1 = aMtx.Line3.Column2 = aMtx.Line3.Column4 =
277 aMtx.Line4.Column1 = aMtx.Line4.Column2 = aMtx.Line4.Column3 = 0.0;
278
282
283// PROP_SCENE_SHADOW_SLANT;
284 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_SHADE_MODE, drawing::ShadeMode_SMOOTH );
285
288
290
291 drawing::Position3D vrp( 0.0, 0.0, 1.0 );
292 drawing::Direction3D vpn( 0.0, 0.0, 1.0 );
293 drawing::Direction3D vup( 0.0, 1.0, 0.0 );
294 drawing::CameraGeometry aDefaultCameraGeometry( vrp, vpn, vup );
295
297 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_PERSPECTIVE, drawing::ProjectionMode_PERSPECTIVE );
298
299 // Light Sources
308
309 uno::Any aDefaultLightDirection( drawing::Direction3D( 0.0, 0.0, 1.0 ) );
318
319 uno::Any aDefaultLightColor;
320 aDefaultLightColor <<= ChartTypeHelper::getDefaultDirectLightColor(false,nullptr);
329}
330
331} // namespace chart
332
333/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SAL_DLLPRIVATE sal_Int32 getDefaultAmbientLightColor(bool bSimple, const rtl::Reference< ::chart::ChartType > &xChartType)
static SAL_DLLPRIVATE sal_Int32 getDefaultDirectLightColor(bool bSimple, const rtl::Reference< ::chart::ChartType > &xChartType)
static SAL_DLLPRIVATE css::drawing::Direction3D getDefaultSimpleLightDirection(const rtl::Reference< ::chart::ChartType > &xChartType)
void setPropertyValueDefault(tPropertyValueMap &rOutMap, tPropertyValueMapKey key, const Value &value)
Calls setPropertyValue() but asserts that the given property hasn't been set before.
OOO_DLLPUBLIC_CHARTTOOLS void AddDefaultsToMap(::chart::tPropertyValueMap &rOutMap)
OOO_DLLPUBLIC_CHARTTOOLS void AddPropertiesToVector(std::vector< css::beans::Property > &rOutProperties)
std::unordered_map< tPropertyValueMapKey, css::uno::Any > tPropertyValueMap