Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / tools / SceneProperties.cxx
blob9d5746ef649dd5b148a181c719322d42b0087c0b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <SceneProperties.hxx>
21 #include <ChartTypeHelper.hxx>
22 #include <com/sun/star/beans/PropertyAttribute.hpp>
23 #include <com/sun/star/drawing/HomogenMatrix.hpp>
24 #include <com/sun/star/drawing/ShadeMode.hpp>
25 #include <com/sun/star/drawing/Direction3D.hpp>
26 #include <com/sun/star/drawing/ProjectionMode.hpp>
27 #include <com/sun/star/drawing/CameraGeometry.hpp>
29 using namespace ::com::sun::star;
31 using ::com::sun::star::beans::Property;
33 namespace chart
36 void SceneProperties::AddPropertiesToVector(
37 std::vector< Property > & rOutProperties )
39 // transformation matrix
40 rOutProperties.emplace_back( "D3DTransformMatrix",
41 PROP_SCENE_TRANSF_MATRIX,
42 cppu::UnoType<drawing::HomogenMatrix>::get(),
43 beans::PropertyAttribute::BOUND
44 | beans::PropertyAttribute::MAYBEVOID
45 | beans::PropertyAttribute::MAYBEDEFAULT );
47 // distance: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
48 rOutProperties.emplace_back( "D3DSceneDistance",
49 PROP_SCENE_DISTANCE,
50 cppu::UnoType<sal_Int32>::get(),
51 beans::PropertyAttribute::BOUND
52 | beans::PropertyAttribute::MAYBEVOID
53 | beans::PropertyAttribute::MAYBEDEFAULT );
55 // focalLength: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart )
56 rOutProperties.emplace_back( "D3DSceneFocalLength",
57 PROP_SCENE_FOCAL_LENGTH,
58 cppu::UnoType<sal_Int32>::get(),
59 beans::PropertyAttribute::BOUND
60 | beans::PropertyAttribute::MAYBEVOID
61 | beans::PropertyAttribute::MAYBEDEFAULT );
63 // shadowSlant
64 rOutProperties.emplace_back( "D3DSceneShadowSlant",
65 PROP_SCENE_SHADOW_SLANT,
66 cppu::UnoType<sal_Int32>::get(),
67 beans::PropertyAttribute::BOUND
68 | beans::PropertyAttribute::MAYBEVOID
69 | beans::PropertyAttribute::MAYBEDEFAULT );
71 // shadeMode
72 rOutProperties.emplace_back( "D3DSceneShadeMode",
73 PROP_SCENE_SHADE_MODE,
74 cppu::UnoType<drawing::ShadeMode>::get(),
75 beans::PropertyAttribute::BOUND
76 | beans::PropertyAttribute::MAYBEVOID
77 | beans::PropertyAttribute::MAYBEDEFAULT );
79 // ambientColor
80 rOutProperties.emplace_back( "D3DSceneAmbientColor",
81 PROP_SCENE_AMBIENT_COLOR,
82 cppu::UnoType<sal_Int32>::get(),
83 beans::PropertyAttribute::BOUND
84 | beans::PropertyAttribute::MAYBEVOID
85 | beans::PropertyAttribute::MAYBEDEFAULT );
87 // lightingMode
88 rOutProperties.emplace_back( "D3DSceneTwoSidedLighting",
89 PROP_SCENE_TWO_SIDED_LIGHTING,
90 cppu::UnoType<bool>::get(),
91 beans::PropertyAttribute::BOUND
92 | beans::PropertyAttribute::MAYBEVOID
93 | beans::PropertyAttribute::MAYBEDEFAULT );
95 // camera geometry
96 rOutProperties.emplace_back( "D3DCameraGeometry",
97 PROP_SCENE_CAMERA_GEOMETRY,
98 cppu::UnoType<drawing::CameraGeometry>::get(),
99 beans::PropertyAttribute::BOUND
100 | beans::PropertyAttribute::MAYBEVOID
101 | beans::PropertyAttribute::MAYBEDEFAULT );
103 // perspective
104 rOutProperties.emplace_back( "D3DScenePerspective",
105 PROP_SCENE_PERSPECTIVE,
106 cppu::UnoType<drawing::ProjectionMode>::get(),
107 beans::PropertyAttribute::BOUND
108 | beans::PropertyAttribute::MAYBEVOID
109 | beans::PropertyAttribute::MAYBEDEFAULT );
111 // Light Sources
112 // light source 1
113 rOutProperties.emplace_back( "D3DSceneLightColor1",
114 PROP_SCENE_LIGHT_COLOR_1,
115 cppu::UnoType<sal_Int32>::get(),
116 beans::PropertyAttribute::BOUND
117 | beans::PropertyAttribute::MAYBEVOID
118 | beans::PropertyAttribute::MAYBEDEFAULT );
119 rOutProperties.emplace_back( "D3DSceneLightDirection1",
120 PROP_SCENE_LIGHT_DIRECTION_1,
121 cppu::UnoType<drawing::Direction3D>::get(),
122 beans::PropertyAttribute::BOUND
123 | beans::PropertyAttribute::MAYBEVOID
124 | beans::PropertyAttribute::MAYBEDEFAULT );
125 rOutProperties.emplace_back( "D3DSceneLightOn1",
126 PROP_SCENE_LIGHT_ON_1,
127 cppu::UnoType<bool>::get(),
128 beans::PropertyAttribute::BOUND
129 | beans::PropertyAttribute::MAYBEVOID
130 | beans::PropertyAttribute::MAYBEDEFAULT );
131 // light source 2
132 rOutProperties.emplace_back( "D3DSceneLightColor2",
133 PROP_SCENE_LIGHT_COLOR_2,
134 cppu::UnoType<sal_Int32>::get(),
135 beans::PropertyAttribute::BOUND
136 | beans::PropertyAttribute::MAYBEVOID
137 | beans::PropertyAttribute::MAYBEDEFAULT );
138 rOutProperties.emplace_back( "D3DSceneLightDirection2",
139 PROP_SCENE_LIGHT_DIRECTION_2,
140 cppu::UnoType<drawing::Direction3D>::get(),
141 beans::PropertyAttribute::BOUND
142 | beans::PropertyAttribute::MAYBEVOID
143 | beans::PropertyAttribute::MAYBEDEFAULT );
144 rOutProperties.emplace_back( "D3DSceneLightOn2",
145 PROP_SCENE_LIGHT_ON_2,
146 cppu::UnoType<bool>::get(),
147 beans::PropertyAttribute::BOUND
148 | beans::PropertyAttribute::MAYBEVOID
149 | beans::PropertyAttribute::MAYBEDEFAULT );
150 // light source 3
151 rOutProperties.emplace_back( "D3DSceneLightColor3",
152 PROP_SCENE_LIGHT_COLOR_3,
153 cppu::UnoType<sal_Int32>::get(),
154 beans::PropertyAttribute::BOUND
155 | beans::PropertyAttribute::MAYBEVOID
156 | beans::PropertyAttribute::MAYBEDEFAULT );
157 rOutProperties.emplace_back( "D3DSceneLightDirection3",
158 PROP_SCENE_LIGHT_DIRECTION_3,
159 cppu::UnoType<drawing::Direction3D>::get(),
160 beans::PropertyAttribute::BOUND
161 | beans::PropertyAttribute::MAYBEVOID
162 | beans::PropertyAttribute::MAYBEDEFAULT );
163 rOutProperties.emplace_back( "D3DSceneLightOn3",
164 PROP_SCENE_LIGHT_ON_3,
165 cppu::UnoType<bool>::get(),
166 beans::PropertyAttribute::BOUND
167 | beans::PropertyAttribute::MAYBEVOID
168 | beans::PropertyAttribute::MAYBEDEFAULT );
169 // light source 4
170 rOutProperties.emplace_back( "D3DSceneLightColor4",
171 PROP_SCENE_LIGHT_COLOR_4,
172 cppu::UnoType<sal_Int32>::get(),
173 beans::PropertyAttribute::BOUND
174 | beans::PropertyAttribute::MAYBEVOID
175 | beans::PropertyAttribute::MAYBEDEFAULT );
176 rOutProperties.emplace_back( "D3DSceneLightDirection4",
177 PROP_SCENE_LIGHT_DIRECTION_4,
178 cppu::UnoType<drawing::Direction3D>::get(),
179 beans::PropertyAttribute::BOUND
180 | beans::PropertyAttribute::MAYBEVOID
181 | beans::PropertyAttribute::MAYBEDEFAULT );
182 rOutProperties.emplace_back( "D3DSceneLightOn4",
183 PROP_SCENE_LIGHT_ON_4,
184 cppu::UnoType<bool>::get(),
185 beans::PropertyAttribute::BOUND
186 | beans::PropertyAttribute::MAYBEVOID
187 | beans::PropertyAttribute::MAYBEDEFAULT );
188 // light source 5
189 rOutProperties.emplace_back( "D3DSceneLightColor5",
190 PROP_SCENE_LIGHT_COLOR_5,
191 cppu::UnoType<sal_Int32>::get(),
192 beans::PropertyAttribute::BOUND
193 | beans::PropertyAttribute::MAYBEVOID
194 | beans::PropertyAttribute::MAYBEDEFAULT );
195 rOutProperties.emplace_back( "D3DSceneLightDirection5",
196 PROP_SCENE_LIGHT_DIRECTION_5,
197 cppu::UnoType<drawing::Direction3D>::get(),
198 beans::PropertyAttribute::BOUND
199 | beans::PropertyAttribute::MAYBEVOID
200 | beans::PropertyAttribute::MAYBEDEFAULT );
201 rOutProperties.emplace_back( "D3DSceneLightOn5",
202 PROP_SCENE_LIGHT_ON_5,
203 cppu::UnoType<bool>::get(),
204 beans::PropertyAttribute::BOUND
205 | beans::PropertyAttribute::MAYBEVOID
206 | beans::PropertyAttribute::MAYBEDEFAULT );
207 // light source 6
208 rOutProperties.emplace_back( "D3DSceneLightColor6",
209 PROP_SCENE_LIGHT_COLOR_6,
210 cppu::UnoType<sal_Int32>::get(),
211 beans::PropertyAttribute::BOUND
212 | beans::PropertyAttribute::MAYBEVOID
213 | beans::PropertyAttribute::MAYBEDEFAULT );
214 rOutProperties.emplace_back( "D3DSceneLightDirection6",
215 PROP_SCENE_LIGHT_DIRECTION_6,
216 cppu::UnoType<drawing::Direction3D>::get(),
217 beans::PropertyAttribute::BOUND
218 | beans::PropertyAttribute::MAYBEVOID
219 | beans::PropertyAttribute::MAYBEDEFAULT );
220 rOutProperties.emplace_back( "D3DSceneLightOn6",
221 PROP_SCENE_LIGHT_ON_6,
222 cppu::UnoType<bool>::get(),
223 beans::PropertyAttribute::BOUND
224 | beans::PropertyAttribute::MAYBEVOID
225 | beans::PropertyAttribute::MAYBEDEFAULT );
226 // light source 7
227 rOutProperties.emplace_back( "D3DSceneLightColor7",
228 PROP_SCENE_LIGHT_COLOR_7,
229 cppu::UnoType<sal_Int32>::get(),
230 beans::PropertyAttribute::BOUND
231 | beans::PropertyAttribute::MAYBEVOID
232 | beans::PropertyAttribute::MAYBEDEFAULT );
233 rOutProperties.emplace_back( "D3DSceneLightDirection7",
234 PROP_SCENE_LIGHT_DIRECTION_7,
235 cppu::UnoType<drawing::Direction3D>::get(),
236 beans::PropertyAttribute::BOUND
237 | beans::PropertyAttribute::MAYBEVOID
238 | beans::PropertyAttribute::MAYBEDEFAULT );
239 rOutProperties.emplace_back( "D3DSceneLightOn7",
240 PROP_SCENE_LIGHT_ON_7,
241 cppu::UnoType<bool>::get(),
242 beans::PropertyAttribute::BOUND
243 | beans::PropertyAttribute::MAYBEVOID
244 | beans::PropertyAttribute::MAYBEDEFAULT );
245 // light source 8
246 rOutProperties.emplace_back( "D3DSceneLightColor8",
247 PROP_SCENE_LIGHT_COLOR_8,
248 cppu::UnoType<sal_Int32>::get(),
249 beans::PropertyAttribute::BOUND
250 | beans::PropertyAttribute::MAYBEVOID
251 | beans::PropertyAttribute::MAYBEDEFAULT );
252 rOutProperties.emplace_back( "D3DSceneLightDirection8",
253 PROP_SCENE_LIGHT_DIRECTION_8,
254 cppu::UnoType<drawing::Direction3D>::get(),
255 beans::PropertyAttribute::BOUND
256 | beans::PropertyAttribute::MAYBEVOID
257 | beans::PropertyAttribute::MAYBEDEFAULT );
258 rOutProperties.emplace_back( "D3DSceneLightOn8",
259 PROP_SCENE_LIGHT_ON_8,
260 cppu::UnoType<bool>::get(),
261 beans::PropertyAttribute::BOUND
262 | beans::PropertyAttribute::MAYBEVOID
263 | beans::PropertyAttribute::MAYBEDEFAULT );
266 void SceneProperties::AddDefaultsToMap(
267 ::chart::tPropertyValueMap & rOutMap )
269 // Identity Matrix
270 drawing::HomogenMatrix aMtx;
271 aMtx.Line1.Column1 = aMtx.Line2.Column2 =
272 aMtx.Line3.Column3 = aMtx.Line4.Column4 = 1.0;
273 aMtx.Line1.Column2 = aMtx.Line1.Column3 = aMtx.Line1.Column4 =
274 aMtx.Line2.Column1 = aMtx.Line2.Column3 = aMtx.Line2.Column4 =
275 aMtx.Line3.Column1 = aMtx.Line3.Column2 = aMtx.Line3.Column4 =
276 aMtx.Line4.Column1 = aMtx.Line4.Column2 = aMtx.Line4.Column3 = 0.0;
278 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TRANSF_MATRIX, aMtx );
279 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCENE_DISTANCE, 4200 );
280 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCENE_FOCAL_LENGTH, 8000 );
282 // PROP_SCENE_SHADOW_SLANT;
283 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_SHADE_MODE, drawing::ShadeMode_SMOOTH );
285 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >(
286 rOutMap, PROP_SCENE_AMBIENT_COLOR, ChartTypeHelper::getDefaultAmbientLightColor(false,nullptr));
288 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TWO_SIDED_LIGHTING, true );
290 drawing::Position3D vrp( 0.0, 0.0, 1.0 );
291 drawing::Direction3D vpn( 0.0, 0.0, 1.0 );
292 drawing::Direction3D vup( 0.0, 1.0, 0.0 );
293 drawing::CameraGeometry aDefaultCameraGeometry( vrp, vpn, vup );
295 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_CAMERA_GEOMETRY, aDefaultCameraGeometry );
296 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_PERSPECTIVE, drawing::ProjectionMode_PERSPECTIVE );
298 // Light Sources
299 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_1, false );
300 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_2, true );
301 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_3, false );
302 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_4, false );
303 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_5, false );
304 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_6, false );
305 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_7, false );
306 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_8, false );
308 uno::Any aDefaultLightDirection( drawing::Direction3D( 0.0, 0.0, 1.0 ) );
309 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_1, aDefaultLightDirection );
310 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_2, ChartTypeHelper::getDefaultSimpleLightDirection(nullptr));
311 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_3, aDefaultLightDirection );
312 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_4, aDefaultLightDirection );
313 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_5, aDefaultLightDirection );
314 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_6, aDefaultLightDirection );
315 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_7, aDefaultLightDirection );
316 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_8, aDefaultLightDirection );
318 uno::Any aDefaultLightColor;
319 aDefaultLightColor <<= ChartTypeHelper::getDefaultDirectLightColor(false,nullptr);
320 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_1, aDefaultLightColor );
321 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_2, aDefaultLightColor );
322 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_3, aDefaultLightColor );
323 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_4, aDefaultLightColor );
324 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_5, aDefaultLightColor );
325 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_6, aDefaultLightColor );
326 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_7, aDefaultLightColor );
327 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_8, aDefaultLightColor );
330 } // namespace chart
332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */