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