1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SceneProperties.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "SceneProperties.hxx"
36 #include "ChartTypeHelper.hxx"
37 #include "ThreeDHelper.hxx"
38 #include <com/sun/star/beans/PropertyAttribute.hpp>
39 #include <com/sun/star/drawing/HomogenMatrix.hpp>
40 #include <com/sun/star/drawing/ShadeMode.hpp>
41 #include <com/sun/star/drawing/Direction3D.hpp>
42 #include <com/sun/star/drawing/ProjectionMode.hpp>
43 #include <com/sun/star/drawing/CameraGeometry.hpp>
46 #include <tools/solar.h>
48 using namespace ::com::sun::star
;
50 using ::com::sun::star::beans::Property
;
55 void SceneProperties::AddPropertiesToVector(
56 ::std::vector
< Property
> & rOutProperties
)
58 // transformation matrix
59 rOutProperties
.push_back(
60 Property( C2U( "D3DTransformMatrix" ),
61 PROP_SCENE_TRANSF_MATRIX
,
62 ::getCppuType( reinterpret_cast< const drawing::HomogenMatrix
* >(0)),
63 beans::PropertyAttribute::BOUND
64 | beans::PropertyAttribute::MAYBEVOID
65 | beans::PropertyAttribute::MAYBEDEFAULT
));
67 // distance: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
68 rOutProperties
.push_back(
69 Property( C2U( "D3DSceneDistance" ),
71 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
72 beans::PropertyAttribute::BOUND
73 | beans::PropertyAttribute::MAYBEVOID
74 | beans::PropertyAttribute::MAYBEDEFAULT
));
76 // focalLength: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
77 rOutProperties
.push_back(
78 Property( C2U( "D3DSceneFocalLength" ),
79 PROP_SCENE_FOCAL_LENGTH
,
80 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
81 beans::PropertyAttribute::BOUND
82 | beans::PropertyAttribute::MAYBEVOID
83 | beans::PropertyAttribute::MAYBEDEFAULT
));
86 rOutProperties
.push_back(
87 Property( C2U( "D3DSceneShadowSlant" ),
88 PROP_SCENE_SHADOW_SLANT
,
89 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
90 beans::PropertyAttribute::BOUND
91 | beans::PropertyAttribute::MAYBEVOID
92 | beans::PropertyAttribute::MAYBEDEFAULT
));
95 rOutProperties
.push_back(
96 Property( C2U( "D3DSceneShadeMode" ),
97 PROP_SCENE_SHADE_MODE
,
98 ::getCppuType( reinterpret_cast< const drawing::ShadeMode
* >(0)),
99 beans::PropertyAttribute::BOUND
100 | beans::PropertyAttribute::MAYBEVOID
101 | beans::PropertyAttribute::MAYBEDEFAULT
));
104 rOutProperties
.push_back(
105 Property( C2U( "D3DSceneAmbientColor" ),
106 PROP_SCENE_AMBIENT_COLOR
,
107 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
108 beans::PropertyAttribute::BOUND
109 | beans::PropertyAttribute::MAYBEVOID
110 | beans::PropertyAttribute::MAYBEDEFAULT
));
113 rOutProperties
.push_back(
114 Property( C2U( "D3DSceneTwoSidedLighting" ),
115 PROP_SCENE_TWO_SIDED_LIGHTING
,
116 ::getBooleanCppuType(),
117 beans::PropertyAttribute::BOUND
118 | beans::PropertyAttribute::MAYBEVOID
119 | beans::PropertyAttribute::MAYBEDEFAULT
));
122 rOutProperties
.push_back(
123 Property( C2U( "D3DCameraGeometry" ),
124 PROP_SCENE_CAMERA_GEOMETRY
,
125 ::getCppuType( reinterpret_cast< const drawing::CameraGeometry
* >(0)),
126 beans::PropertyAttribute::BOUND
127 | beans::PropertyAttribute::MAYBEVOID
128 | beans::PropertyAttribute::MAYBEDEFAULT
));
131 rOutProperties
.push_back(
132 Property( C2U( "D3DScenePerspective" ),
133 PROP_SCENE_PERSPECTIVE
,
134 ::getCppuType( reinterpret_cast< const drawing::ProjectionMode
* >(0)),
135 beans::PropertyAttribute::BOUND
136 | beans::PropertyAttribute::MAYBEVOID
137 | beans::PropertyAttribute::MAYBEDEFAULT
));
143 rOutProperties
.push_back(
144 Property( C2U( "D3DSceneLightColor1" ),
145 PROP_SCENE_LIGHT_COLOR_1
,
146 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
147 beans::PropertyAttribute::BOUND
148 | beans::PropertyAttribute::MAYBEVOID
149 | beans::PropertyAttribute::MAYBEDEFAULT
));
150 rOutProperties
.push_back(
151 Property( C2U( "D3DSceneLightDirection1" ),
152 PROP_SCENE_LIGHT_DIRECTION_1
,
153 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
154 beans::PropertyAttribute::BOUND
155 | beans::PropertyAttribute::MAYBEVOID
156 | beans::PropertyAttribute::MAYBEDEFAULT
));
157 rOutProperties
.push_back(
158 Property( C2U( "D3DSceneLightOn1" ),
159 PROP_SCENE_LIGHT_ON_1
,
160 ::getBooleanCppuType(),
161 beans::PropertyAttribute::BOUND
162 | beans::PropertyAttribute::MAYBEVOID
163 | beans::PropertyAttribute::MAYBEDEFAULT
));
165 rOutProperties
.push_back(
166 Property( C2U( "D3DSceneLightColor2" ),
167 PROP_SCENE_LIGHT_COLOR_2
,
168 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
169 beans::PropertyAttribute::BOUND
170 | beans::PropertyAttribute::MAYBEVOID
171 | beans::PropertyAttribute::MAYBEDEFAULT
));
172 rOutProperties
.push_back(
173 Property( C2U( "D3DSceneLightDirection2" ),
174 PROP_SCENE_LIGHT_DIRECTION_2
,
175 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
176 beans::PropertyAttribute::BOUND
177 | beans::PropertyAttribute::MAYBEVOID
178 | beans::PropertyAttribute::MAYBEDEFAULT
));
179 rOutProperties
.push_back(
180 Property( C2U( "D3DSceneLightOn2" ),
181 PROP_SCENE_LIGHT_ON_2
,
182 ::getBooleanCppuType(),
183 beans::PropertyAttribute::BOUND
184 | beans::PropertyAttribute::MAYBEVOID
185 | beans::PropertyAttribute::MAYBEDEFAULT
));
187 rOutProperties
.push_back(
188 Property( C2U( "D3DSceneLightColor3" ),
189 PROP_SCENE_LIGHT_COLOR_3
,
190 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
191 beans::PropertyAttribute::BOUND
192 | beans::PropertyAttribute::MAYBEVOID
193 | beans::PropertyAttribute::MAYBEDEFAULT
));
194 rOutProperties
.push_back(
195 Property( C2U( "D3DSceneLightDirection3" ),
196 PROP_SCENE_LIGHT_DIRECTION_3
,
197 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
198 beans::PropertyAttribute::BOUND
199 | beans::PropertyAttribute::MAYBEVOID
200 | beans::PropertyAttribute::MAYBEDEFAULT
));
201 rOutProperties
.push_back(
202 Property( C2U( "D3DSceneLightOn3" ),
203 PROP_SCENE_LIGHT_ON_3
,
204 ::getBooleanCppuType(),
205 beans::PropertyAttribute::BOUND
206 | beans::PropertyAttribute::MAYBEVOID
207 | beans::PropertyAttribute::MAYBEDEFAULT
));
209 rOutProperties
.push_back(
210 Property( C2U( "D3DSceneLightColor4" ),
211 PROP_SCENE_LIGHT_COLOR_4
,
212 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
213 beans::PropertyAttribute::BOUND
214 | beans::PropertyAttribute::MAYBEVOID
215 | beans::PropertyAttribute::MAYBEDEFAULT
));
216 rOutProperties
.push_back(
217 Property( C2U( "D3DSceneLightDirection4" ),
218 PROP_SCENE_LIGHT_DIRECTION_4
,
219 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
220 beans::PropertyAttribute::BOUND
221 | beans::PropertyAttribute::MAYBEVOID
222 | beans::PropertyAttribute::MAYBEDEFAULT
));
223 rOutProperties
.push_back(
224 Property( C2U( "D3DSceneLightOn4" ),
225 PROP_SCENE_LIGHT_ON_4
,
226 ::getBooleanCppuType(),
227 beans::PropertyAttribute::BOUND
228 | beans::PropertyAttribute::MAYBEVOID
229 | beans::PropertyAttribute::MAYBEDEFAULT
));
231 rOutProperties
.push_back(
232 Property( C2U( "D3DSceneLightColor5" ),
233 PROP_SCENE_LIGHT_COLOR_5
,
234 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
235 beans::PropertyAttribute::BOUND
236 | beans::PropertyAttribute::MAYBEVOID
237 | beans::PropertyAttribute::MAYBEDEFAULT
));
238 rOutProperties
.push_back(
239 Property( C2U( "D3DSceneLightDirection5" ),
240 PROP_SCENE_LIGHT_DIRECTION_5
,
241 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
242 beans::PropertyAttribute::BOUND
243 | beans::PropertyAttribute::MAYBEVOID
244 | beans::PropertyAttribute::MAYBEDEFAULT
));
245 rOutProperties
.push_back(
246 Property( C2U( "D3DSceneLightOn5" ),
247 PROP_SCENE_LIGHT_ON_5
,
248 ::getBooleanCppuType(),
249 beans::PropertyAttribute::BOUND
250 | beans::PropertyAttribute::MAYBEVOID
251 | beans::PropertyAttribute::MAYBEDEFAULT
));
253 rOutProperties
.push_back(
254 Property( C2U( "D3DSceneLightColor6" ),
255 PROP_SCENE_LIGHT_COLOR_6
,
256 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
257 beans::PropertyAttribute::BOUND
258 | beans::PropertyAttribute::MAYBEVOID
259 | beans::PropertyAttribute::MAYBEDEFAULT
));
260 rOutProperties
.push_back(
261 Property( C2U( "D3DSceneLightDirection6" ),
262 PROP_SCENE_LIGHT_DIRECTION_6
,
263 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
264 beans::PropertyAttribute::BOUND
265 | beans::PropertyAttribute::MAYBEVOID
266 | beans::PropertyAttribute::MAYBEDEFAULT
));
267 rOutProperties
.push_back(
268 Property( C2U( "D3DSceneLightOn6" ),
269 PROP_SCENE_LIGHT_ON_6
,
270 ::getBooleanCppuType(),
271 beans::PropertyAttribute::BOUND
272 | beans::PropertyAttribute::MAYBEVOID
273 | beans::PropertyAttribute::MAYBEDEFAULT
));
275 rOutProperties
.push_back(
276 Property( C2U( "D3DSceneLightColor7" ),
277 PROP_SCENE_LIGHT_COLOR_7
,
278 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
279 beans::PropertyAttribute::BOUND
280 | beans::PropertyAttribute::MAYBEVOID
281 | beans::PropertyAttribute::MAYBEDEFAULT
));
282 rOutProperties
.push_back(
283 Property( C2U( "D3DSceneLightDirection7" ),
284 PROP_SCENE_LIGHT_DIRECTION_7
,
285 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
286 beans::PropertyAttribute::BOUND
287 | beans::PropertyAttribute::MAYBEVOID
288 | beans::PropertyAttribute::MAYBEDEFAULT
));
289 rOutProperties
.push_back(
290 Property( C2U( "D3DSceneLightOn7" ),
291 PROP_SCENE_LIGHT_ON_7
,
292 ::getBooleanCppuType(),
293 beans::PropertyAttribute::BOUND
294 | beans::PropertyAttribute::MAYBEVOID
295 | beans::PropertyAttribute::MAYBEDEFAULT
));
297 rOutProperties
.push_back(
298 Property( C2U( "D3DSceneLightColor8" ),
299 PROP_SCENE_LIGHT_COLOR_8
,
300 ::getCppuType( reinterpret_cast< const sal_Int32
* >(0)),
301 beans::PropertyAttribute::BOUND
302 | beans::PropertyAttribute::MAYBEVOID
303 | beans::PropertyAttribute::MAYBEDEFAULT
));
304 rOutProperties
.push_back(
305 Property( C2U( "D3DSceneLightDirection8" ),
306 PROP_SCENE_LIGHT_DIRECTION_8
,
307 ::getCppuType( reinterpret_cast< const drawing::Direction3D
* >(0)),
308 beans::PropertyAttribute::BOUND
309 | beans::PropertyAttribute::MAYBEVOID
310 | beans::PropertyAttribute::MAYBEDEFAULT
));
311 rOutProperties
.push_back(
312 Property( C2U( "D3DSceneLightOn8" ),
313 PROP_SCENE_LIGHT_ON_8
,
314 ::getBooleanCppuType(),
315 beans::PropertyAttribute::BOUND
316 | beans::PropertyAttribute::MAYBEVOID
317 | beans::PropertyAttribute::MAYBEDEFAULT
));
320 void SceneProperties::AddDefaultsToMap(
321 ::chart::tPropertyValueMap
& rOutMap
)
324 drawing::HomogenMatrix aMtx
;
325 aMtx
.Line1
.Column1
= aMtx
.Line2
.Column2
=
326 aMtx
.Line3
.Column3
= aMtx
.Line4
.Column4
= 1.0;
327 aMtx
.Line1
.Column2
= aMtx
.Line1
.Column3
= aMtx
.Line1
.Column4
=
328 aMtx
.Line2
.Column1
= aMtx
.Line2
.Column3
= aMtx
.Line2
.Column4
=
329 aMtx
.Line3
.Column1
= aMtx
.Line3
.Column2
= aMtx
.Line3
.Column4
=
330 aMtx
.Line4
.Column1
= aMtx
.Line4
.Column2
= aMtx
.Line4
.Column3
= 0.0;
332 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_TRANSF_MATRIX
, aMtx
);
333 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_SCENE_DISTANCE
, 4200 );
334 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>( rOutMap
, PROP_SCENE_FOCAL_LENGTH
, 8000 );
336 // PROP_SCENE_SHADOW_SLANT;
337 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_SHADE_MODE
, drawing::ShadeMode_SMOOTH
);
339 ::chart::PropertyHelper::setPropertyValueDefault
< sal_Int32
>(
340 rOutMap
, PROP_SCENE_AMBIENT_COLOR
, ChartTypeHelper::getDefaultAmbientLightColor(ThreeDLookScheme_Simple
,0));
342 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_TWO_SIDED_LIGHTING
, true );
344 drawing::Position3D
vrp( 0.0, 0.0, 1.0 );
345 drawing::Direction3D
vpn( 0.0, 0.0, 1.0 );
346 drawing::Direction3D
vup( 0.0, 1.0, 0.0 );
347 drawing::CameraGeometry
aDefaultCameraGeometry( vrp
, vpn
, vup
);
349 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_CAMERA_GEOMETRY
, aDefaultCameraGeometry
);
350 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_PERSPECTIVE
, drawing::ProjectionMode_PERSPECTIVE
);
354 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_1
, false );
355 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_2
, true );
356 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_3
, false );
357 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_4
, false );
358 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_5
, false );
359 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_6
, false );
360 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_7
, false );
361 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_ON_8
, false );
363 uno::Any
aDefaultLightDirection( uno::makeAny( drawing::Direction3D( 0.0, 0.0, 1.0 ) ) );
364 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_1
, aDefaultLightDirection
);
365 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_2
, ChartTypeHelper::getDefaultSimpleLightDirection(0));
366 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_3
, aDefaultLightDirection
);
367 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_4
, aDefaultLightDirection
);
368 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_5
, aDefaultLightDirection
);
369 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_6
, aDefaultLightDirection
);
370 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_7
, aDefaultLightDirection
);
371 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_DIRECTION_8
, aDefaultLightDirection
);
373 uno::Any aDefaultLightColor
;
374 aDefaultLightColor
<<= ChartTypeHelper::getDefaultDirectLightColor(ThreeDLookScheme_Simple
,0);
375 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_1
, aDefaultLightColor
);
376 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_2
, aDefaultLightColor
);
377 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_3
, aDefaultLightColor
);
378 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_4
, aDefaultLightColor
);
379 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_5
, aDefaultLightColor
);
380 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_6
, aDefaultLightColor
);
381 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_7
, aDefaultLightColor
);
382 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap
, PROP_SCENE_LIGHT_COLOR_8
, aDefaultLightColor
);