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