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