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