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