bump product version to 4.1.6.2
[LibreOffice.git] / chart2 / source / tools / SceneProperties.cxx
blob8e86976501e8344d31538cdec755d3a802b5c1c6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
21 #include "SceneProperties.hxx"
22 #include "macros.hxx"
23 #include "ChartTypeHelper.hxx"
24 #include "ThreeDHelper.hxx"
25 #include <com/sun/star/beans/PropertyAttribute.hpp>
26 #include <com/sun/star/drawing/HomogenMatrix.hpp>
27 #include <com/sun/star/drawing/ShadeMode.hpp>
28 #include <com/sun/star/drawing/Direction3D.hpp>
29 #include <com/sun/star/drawing/ProjectionMode.hpp>
30 #include <com/sun/star/drawing/CameraGeometry.hpp>
32 // for F_PI
33 #include <tools/solar.h>
35 using namespace ::com::sun::star;
37 using ::com::sun::star::beans::Property;
39 namespace chart
42 void SceneProperties::AddPropertiesToVector(
43 ::std::vector< Property > & rOutProperties )
45 // transformation matrix
46 rOutProperties.push_back(
47 Property( "D3DTransformMatrix",
48 PROP_SCENE_TRANSF_MATRIX,
49 ::getCppuType( reinterpret_cast< const drawing::HomogenMatrix * >(0)),
50 beans::PropertyAttribute::BOUND
51 | beans::PropertyAttribute::MAYBEVOID
52 | beans::PropertyAttribute::MAYBEDEFAULT ));
54 // distance: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
55 rOutProperties.push_back(
56 Property( "D3DSceneDistance",
57 PROP_SCENE_DISTANCE,
58 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
59 beans::PropertyAttribute::BOUND
60 | beans::PropertyAttribute::MAYBEVOID
61 | beans::PropertyAttribute::MAYBEDEFAULT ));
63 // focalLength: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
64 rOutProperties.push_back(
65 Property( "D3DSceneFocalLength",
66 PROP_SCENE_FOCAL_LENGTH,
67 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
68 beans::PropertyAttribute::BOUND
69 | beans::PropertyAttribute::MAYBEVOID
70 | beans::PropertyAttribute::MAYBEDEFAULT ));
72 // shadowSlant
73 rOutProperties.push_back(
74 Property( "D3DSceneShadowSlant",
75 PROP_SCENE_SHADOW_SLANT,
76 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
77 beans::PropertyAttribute::BOUND
78 | beans::PropertyAttribute::MAYBEVOID
79 | beans::PropertyAttribute::MAYBEDEFAULT ));
81 // shadeMode
82 rOutProperties.push_back(
83 Property( "D3DSceneShadeMode",
84 PROP_SCENE_SHADE_MODE,
85 ::getCppuType( reinterpret_cast< const drawing::ShadeMode * >(0)),
86 beans::PropertyAttribute::BOUND
87 | beans::PropertyAttribute::MAYBEVOID
88 | beans::PropertyAttribute::MAYBEDEFAULT ));
90 // ambientColor
91 rOutProperties.push_back(
92 Property( "D3DSceneAmbientColor",
93 PROP_SCENE_AMBIENT_COLOR,
94 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
95 beans::PropertyAttribute::BOUND
96 | beans::PropertyAttribute::MAYBEVOID
97 | beans::PropertyAttribute::MAYBEDEFAULT ));
99 // lightingMode
100 rOutProperties.push_back(
101 Property( "D3DSceneTwoSidedLighting",
102 PROP_SCENE_TWO_SIDED_LIGHTING,
103 ::getBooleanCppuType(),
104 beans::PropertyAttribute::BOUND
105 | beans::PropertyAttribute::MAYBEVOID
106 | beans::PropertyAttribute::MAYBEDEFAULT ));
108 // camera geometry
109 rOutProperties.push_back(
110 Property( "D3DCameraGeometry",
111 PROP_SCENE_CAMERA_GEOMETRY,
112 ::getCppuType( reinterpret_cast< const drawing::CameraGeometry * >(0)),
113 beans::PropertyAttribute::BOUND
114 | beans::PropertyAttribute::MAYBEVOID
115 | beans::PropertyAttribute::MAYBEDEFAULT ));
117 // perspective
118 rOutProperties.push_back(
119 Property( "D3DScenePerspective",
120 PROP_SCENE_PERSPECTIVE,
121 ::getCppuType( reinterpret_cast< const drawing::ProjectionMode * >(0)),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::MAYBEVOID
124 | beans::PropertyAttribute::MAYBEDEFAULT ));
127 // Light Sources
128 // -------------
129 // light source 1
130 rOutProperties.push_back(
131 Property( "D3DSceneLightColor1",
132 PROP_SCENE_LIGHT_COLOR_1,
133 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
134 beans::PropertyAttribute::BOUND
135 | beans::PropertyAttribute::MAYBEVOID
136 | beans::PropertyAttribute::MAYBEDEFAULT ));
137 rOutProperties.push_back(
138 Property( "D3DSceneLightDirection1",
139 PROP_SCENE_LIGHT_DIRECTION_1,
140 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::MAYBEVOID
143 | beans::PropertyAttribute::MAYBEDEFAULT ));
144 rOutProperties.push_back(
145 Property( "D3DSceneLightOn1",
146 PROP_SCENE_LIGHT_ON_1,
147 ::getBooleanCppuType(),
148 beans::PropertyAttribute::BOUND
149 | beans::PropertyAttribute::MAYBEVOID
150 | beans::PropertyAttribute::MAYBEDEFAULT ));
151 // light source 2
152 rOutProperties.push_back(
153 Property( "D3DSceneLightColor2",
154 PROP_SCENE_LIGHT_COLOR_2,
155 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
156 beans::PropertyAttribute::BOUND
157 | beans::PropertyAttribute::MAYBEVOID
158 | beans::PropertyAttribute::MAYBEDEFAULT ));
159 rOutProperties.push_back(
160 Property( "D3DSceneLightDirection2",
161 PROP_SCENE_LIGHT_DIRECTION_2,
162 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)),
163 beans::PropertyAttribute::BOUND
164 | beans::PropertyAttribute::MAYBEVOID
165 | beans::PropertyAttribute::MAYBEDEFAULT ));
166 rOutProperties.push_back(
167 Property( "D3DSceneLightOn2",
168 PROP_SCENE_LIGHT_ON_2,
169 ::getBooleanCppuType(),
170 beans::PropertyAttribute::BOUND
171 | beans::PropertyAttribute::MAYBEVOID
172 | beans::PropertyAttribute::MAYBEDEFAULT ));
173 // light source 3
174 rOutProperties.push_back(
175 Property( "D3DSceneLightColor3",
176 PROP_SCENE_LIGHT_COLOR_3,
177 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
178 beans::PropertyAttribute::BOUND
179 | beans::PropertyAttribute::MAYBEVOID
180 | beans::PropertyAttribute::MAYBEDEFAULT ));
181 rOutProperties.push_back(
182 Property( "D3DSceneLightDirection3",
183 PROP_SCENE_LIGHT_DIRECTION_3,
184 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)),
185 beans::PropertyAttribute::BOUND
186 | beans::PropertyAttribute::MAYBEVOID
187 | beans::PropertyAttribute::MAYBEDEFAULT ));
188 rOutProperties.push_back(
189 Property( "D3DSceneLightOn3",
190 PROP_SCENE_LIGHT_ON_3,
191 ::getBooleanCppuType(),
192 beans::PropertyAttribute::BOUND
193 | beans::PropertyAttribute::MAYBEVOID
194 | beans::PropertyAttribute::MAYBEDEFAULT ));
195 // light source 4
196 rOutProperties.push_back(
197 Property( "D3DSceneLightColor4",
198 PROP_SCENE_LIGHT_COLOR_4,
199 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
200 beans::PropertyAttribute::BOUND
201 | beans::PropertyAttribute::MAYBEVOID
202 | beans::PropertyAttribute::MAYBEDEFAULT ));
203 rOutProperties.push_back(
204 Property( "D3DSceneLightDirection4",
205 PROP_SCENE_LIGHT_DIRECTION_4,
206 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)),
207 beans::PropertyAttribute::BOUND
208 | beans::PropertyAttribute::MAYBEVOID
209 | beans::PropertyAttribute::MAYBEDEFAULT ));
210 rOutProperties.push_back(
211 Property( "D3DSceneLightOn4",
212 PROP_SCENE_LIGHT_ON_4,
213 ::getBooleanCppuType(),
214 beans::PropertyAttribute::BOUND
215 | beans::PropertyAttribute::MAYBEVOID
216 | beans::PropertyAttribute::MAYBEDEFAULT ));
217 // light source 5
218 rOutProperties.push_back(
219 Property( "D3DSceneLightColor5",
220 PROP_SCENE_LIGHT_COLOR_5,
221 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
222 beans::PropertyAttribute::BOUND
223 | beans::PropertyAttribute::MAYBEVOID
224 | beans::PropertyAttribute::MAYBEDEFAULT ));
225 rOutProperties.push_back(
226 Property( "D3DSceneLightDirection5",
227 PROP_SCENE_LIGHT_DIRECTION_5,
228 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)),
229 beans::PropertyAttribute::BOUND
230 | beans::PropertyAttribute::MAYBEVOID
231 | beans::PropertyAttribute::MAYBEDEFAULT ));
232 rOutProperties.push_back(
233 Property( "D3DSceneLightOn5",
234 PROP_SCENE_LIGHT_ON_5,
235 ::getBooleanCppuType(),
236 beans::PropertyAttribute::BOUND
237 | beans::PropertyAttribute::MAYBEVOID
238 | beans::PropertyAttribute::MAYBEDEFAULT ));
239 // light source 6
240 rOutProperties.push_back(
241 Property( "D3DSceneLightColor6",
242 PROP_SCENE_LIGHT_COLOR_6,
243 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
244 beans::PropertyAttribute::BOUND
245 | beans::PropertyAttribute::MAYBEVOID
246 | beans::PropertyAttribute::MAYBEDEFAULT ));
247 rOutProperties.push_back(
248 Property( "D3DSceneLightDirection6",
249 PROP_SCENE_LIGHT_DIRECTION_6,
250 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)),
251 beans::PropertyAttribute::BOUND
252 | beans::PropertyAttribute::MAYBEVOID
253 | beans::PropertyAttribute::MAYBEDEFAULT ));
254 rOutProperties.push_back(
255 Property( "D3DSceneLightOn6",
256 PROP_SCENE_LIGHT_ON_6,
257 ::getBooleanCppuType(),
258 beans::PropertyAttribute::BOUND
259 | beans::PropertyAttribute::MAYBEVOID
260 | beans::PropertyAttribute::MAYBEDEFAULT ));
261 // light source 7
262 rOutProperties.push_back(
263 Property( "D3DSceneLightColor7",
264 PROP_SCENE_LIGHT_COLOR_7,
265 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
266 beans::PropertyAttribute::BOUND
267 | beans::PropertyAttribute::MAYBEVOID
268 | beans::PropertyAttribute::MAYBEDEFAULT ));
269 rOutProperties.push_back(
270 Property( "D3DSceneLightDirection7",
271 PROP_SCENE_LIGHT_DIRECTION_7,
272 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)),
273 beans::PropertyAttribute::BOUND
274 | beans::PropertyAttribute::MAYBEVOID
275 | beans::PropertyAttribute::MAYBEDEFAULT ));
276 rOutProperties.push_back(
277 Property( "D3DSceneLightOn7",
278 PROP_SCENE_LIGHT_ON_7,
279 ::getBooleanCppuType(),
280 beans::PropertyAttribute::BOUND
281 | beans::PropertyAttribute::MAYBEVOID
282 | beans::PropertyAttribute::MAYBEDEFAULT ));
283 // light source 8
284 rOutProperties.push_back(
285 Property( "D3DSceneLightColor8",
286 PROP_SCENE_LIGHT_COLOR_8,
287 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)),
288 beans::PropertyAttribute::BOUND
289 | beans::PropertyAttribute::MAYBEVOID
290 | beans::PropertyAttribute::MAYBEDEFAULT ));
291 rOutProperties.push_back(
292 Property( "D3DSceneLightDirection8",
293 PROP_SCENE_LIGHT_DIRECTION_8,
294 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)),
295 beans::PropertyAttribute::BOUND
296 | beans::PropertyAttribute::MAYBEVOID
297 | beans::PropertyAttribute::MAYBEDEFAULT ));
298 rOutProperties.push_back(
299 Property( "D3DSceneLightOn8",
300 PROP_SCENE_LIGHT_ON_8,
301 ::getBooleanCppuType(),
302 beans::PropertyAttribute::BOUND
303 | beans::PropertyAttribute::MAYBEVOID
304 | beans::PropertyAttribute::MAYBEDEFAULT ));
307 void SceneProperties::AddDefaultsToMap(
308 ::chart::tPropertyValueMap & rOutMap )
310 // Identity Matrix
311 drawing::HomogenMatrix aMtx;
312 aMtx.Line1.Column1 = aMtx.Line2.Column2 =
313 aMtx.Line3.Column3 = aMtx.Line4.Column4 = 1.0;
314 aMtx.Line1.Column2 = aMtx.Line1.Column3 = aMtx.Line1.Column4 =
315 aMtx.Line2.Column1 = aMtx.Line2.Column3 = aMtx.Line2.Column4 =
316 aMtx.Line3.Column1 = aMtx.Line3.Column2 = aMtx.Line3.Column4 =
317 aMtx.Line4.Column1 = aMtx.Line4.Column2 = aMtx.Line4.Column3 = 0.0;
319 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TRANSF_MATRIX, aMtx );
320 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCENE_DISTANCE, 4200 );
321 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCENE_FOCAL_LENGTH, 8000 );
323 // PROP_SCENE_SHADOW_SLANT;
324 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_SHADE_MODE, drawing::ShadeMode_SMOOTH );
326 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >(
327 rOutMap, PROP_SCENE_AMBIENT_COLOR, ChartTypeHelper::getDefaultAmbientLightColor(ThreeDLookScheme_Simple,0));
329 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TWO_SIDED_LIGHTING, true );
331 drawing::Position3D vrp( 0.0, 0.0, 1.0 );
332 drawing::Direction3D vpn( 0.0, 0.0, 1.0 );
333 drawing::Direction3D vup( 0.0, 1.0, 0.0 );
334 drawing::CameraGeometry aDefaultCameraGeometry( vrp, vpn, vup );
336 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_CAMERA_GEOMETRY, aDefaultCameraGeometry );
337 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_PERSPECTIVE, drawing::ProjectionMode_PERSPECTIVE );
339 // Light Sources
340 // -------------
341 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_1, false );
342 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_2, true );
343 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_3, false );
344 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_4, false );
345 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_5, false );
346 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_6, false );
347 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_7, false );
348 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_8, false );
350 uno::Any aDefaultLightDirection( uno::makeAny( drawing::Direction3D( 0.0, 0.0, 1.0 ) ) );
351 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_1, aDefaultLightDirection );
352 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_2, ChartTypeHelper::getDefaultSimpleLightDirection(0));
353 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_3, aDefaultLightDirection );
354 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_4, aDefaultLightDirection );
355 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_5, aDefaultLightDirection );
356 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_6, aDefaultLightDirection );
357 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_7, aDefaultLightDirection );
358 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_8, aDefaultLightDirection );
360 uno::Any aDefaultLightColor;
361 aDefaultLightColor <<= ChartTypeHelper::getDefaultDirectLightColor(ThreeDLookScheme_Simple,0);
362 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_1, aDefaultLightColor );
363 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_2, aDefaultLightColor );
364 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_3, aDefaultLightColor );
365 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_4, aDefaultLightColor );
366 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_5, aDefaultLightColor );
367 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_6, aDefaultLightColor );
368 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_7, aDefaultLightColor );
369 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_8, aDefaultLightColor );
372 } // namespace chart
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */