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