1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_chart2.hxx" 26 27 #include "SceneProperties.hxx" 28 #include "macros.hxx" 29 #include "ChartTypeHelper.hxx" 30 #include "ThreeDHelper.hxx" 31 #include <com/sun/star/beans/PropertyAttribute.hpp> 32 #include <com/sun/star/drawing/HomogenMatrix.hpp> 33 #include <com/sun/star/drawing/ShadeMode.hpp> 34 #include <com/sun/star/drawing/Direction3D.hpp> 35 #include <com/sun/star/drawing/ProjectionMode.hpp> 36 #include <com/sun/star/drawing/CameraGeometry.hpp> 37 38 // for F_PI 39 #include <tools/solar.h> 40 41 using namespace ::com::sun::star; 42 43 using ::com::sun::star::beans::Property; 44 45 namespace chart 46 { 47 48 void SceneProperties::AddPropertiesToVector( 49 ::std::vector< Property > & rOutProperties ) 50 { 51 // transformation matrix 52 rOutProperties.push_back( 53 Property( C2U( "D3DTransformMatrix" ), 54 PROP_SCENE_TRANSF_MATRIX, 55 ::getCppuType( reinterpret_cast< const drawing::HomogenMatrix * >(0)), 56 beans::PropertyAttribute::BOUND 57 | beans::PropertyAttribute::MAYBEVOID 58 | beans::PropertyAttribute::MAYBEDEFAULT )); 59 60 // distance: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart ) 61 rOutProperties.push_back( 62 Property( C2U( "D3DSceneDistance" ), 63 PROP_SCENE_DISTANCE, 64 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 65 beans::PropertyAttribute::BOUND 66 | beans::PropertyAttribute::MAYBEVOID 67 | beans::PropertyAttribute::MAYBEDEFAULT )); 68 69 // focalLength: deprecated ( this is not used by the chart view; it's only here for compatibility with old chart ) 70 rOutProperties.push_back( 71 Property( C2U( "D3DSceneFocalLength" ), 72 PROP_SCENE_FOCAL_LENGTH, 73 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 74 beans::PropertyAttribute::BOUND 75 | beans::PropertyAttribute::MAYBEVOID 76 | beans::PropertyAttribute::MAYBEDEFAULT )); 77 78 // shadowSlant 79 rOutProperties.push_back( 80 Property( C2U( "D3DSceneShadowSlant" ), 81 PROP_SCENE_SHADOW_SLANT, 82 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 83 beans::PropertyAttribute::BOUND 84 | beans::PropertyAttribute::MAYBEVOID 85 | beans::PropertyAttribute::MAYBEDEFAULT )); 86 87 // shadeMode 88 rOutProperties.push_back( 89 Property( C2U( "D3DSceneShadeMode" ), 90 PROP_SCENE_SHADE_MODE, 91 ::getCppuType( reinterpret_cast< const drawing::ShadeMode * >(0)), 92 beans::PropertyAttribute::BOUND 93 | beans::PropertyAttribute::MAYBEVOID 94 | beans::PropertyAttribute::MAYBEDEFAULT )); 95 96 // ambientColor 97 rOutProperties.push_back( 98 Property( C2U( "D3DSceneAmbientColor" ), 99 PROP_SCENE_AMBIENT_COLOR, 100 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 101 beans::PropertyAttribute::BOUND 102 | beans::PropertyAttribute::MAYBEVOID 103 | beans::PropertyAttribute::MAYBEDEFAULT )); 104 105 // lightingMode 106 rOutProperties.push_back( 107 Property( C2U( "D3DSceneTwoSidedLighting" ), 108 PROP_SCENE_TWO_SIDED_LIGHTING, 109 ::getBooleanCppuType(), 110 beans::PropertyAttribute::BOUND 111 | beans::PropertyAttribute::MAYBEVOID 112 | beans::PropertyAttribute::MAYBEDEFAULT )); 113 114 // camera geometry 115 rOutProperties.push_back( 116 Property( C2U( "D3DCameraGeometry" ), 117 PROP_SCENE_CAMERA_GEOMETRY, 118 ::getCppuType( reinterpret_cast< const drawing::CameraGeometry * >(0)), 119 beans::PropertyAttribute::BOUND 120 | beans::PropertyAttribute::MAYBEVOID 121 | beans::PropertyAttribute::MAYBEDEFAULT )); 122 123 // perspective 124 rOutProperties.push_back( 125 Property( C2U( "D3DScenePerspective" ), 126 PROP_SCENE_PERSPECTIVE, 127 ::getCppuType( reinterpret_cast< const drawing::ProjectionMode * >(0)), 128 beans::PropertyAttribute::BOUND 129 | beans::PropertyAttribute::MAYBEVOID 130 | beans::PropertyAttribute::MAYBEDEFAULT )); 131 132 133 // Light Sources 134 // ------------- 135 // light source 1 136 rOutProperties.push_back( 137 Property( C2U( "D3DSceneLightColor1" ), 138 PROP_SCENE_LIGHT_COLOR_1, 139 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 140 beans::PropertyAttribute::BOUND 141 | beans::PropertyAttribute::MAYBEVOID 142 | beans::PropertyAttribute::MAYBEDEFAULT )); 143 rOutProperties.push_back( 144 Property( C2U( "D3DSceneLightDirection1" ), 145 PROP_SCENE_LIGHT_DIRECTION_1, 146 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)), 147 beans::PropertyAttribute::BOUND 148 | beans::PropertyAttribute::MAYBEVOID 149 | beans::PropertyAttribute::MAYBEDEFAULT )); 150 rOutProperties.push_back( 151 Property( C2U( "D3DSceneLightOn1" ), 152 PROP_SCENE_LIGHT_ON_1, 153 ::getBooleanCppuType(), 154 beans::PropertyAttribute::BOUND 155 | beans::PropertyAttribute::MAYBEVOID 156 | beans::PropertyAttribute::MAYBEDEFAULT )); 157 // light source 2 158 rOutProperties.push_back( 159 Property( C2U( "D3DSceneLightColor2" ), 160 PROP_SCENE_LIGHT_COLOR_2, 161 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 162 beans::PropertyAttribute::BOUND 163 | beans::PropertyAttribute::MAYBEVOID 164 | beans::PropertyAttribute::MAYBEDEFAULT )); 165 rOutProperties.push_back( 166 Property( C2U( "D3DSceneLightDirection2" ), 167 PROP_SCENE_LIGHT_DIRECTION_2, 168 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)), 169 beans::PropertyAttribute::BOUND 170 | beans::PropertyAttribute::MAYBEVOID 171 | beans::PropertyAttribute::MAYBEDEFAULT )); 172 rOutProperties.push_back( 173 Property( C2U( "D3DSceneLightOn2" ), 174 PROP_SCENE_LIGHT_ON_2, 175 ::getBooleanCppuType(), 176 beans::PropertyAttribute::BOUND 177 | beans::PropertyAttribute::MAYBEVOID 178 | beans::PropertyAttribute::MAYBEDEFAULT )); 179 // light source 3 180 rOutProperties.push_back( 181 Property( C2U( "D3DSceneLightColor3" ), 182 PROP_SCENE_LIGHT_COLOR_3, 183 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 184 beans::PropertyAttribute::BOUND 185 | beans::PropertyAttribute::MAYBEVOID 186 | beans::PropertyAttribute::MAYBEDEFAULT )); 187 rOutProperties.push_back( 188 Property( C2U( "D3DSceneLightDirection3" ), 189 PROP_SCENE_LIGHT_DIRECTION_3, 190 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)), 191 beans::PropertyAttribute::BOUND 192 | beans::PropertyAttribute::MAYBEVOID 193 | beans::PropertyAttribute::MAYBEDEFAULT )); 194 rOutProperties.push_back( 195 Property( C2U( "D3DSceneLightOn3" ), 196 PROP_SCENE_LIGHT_ON_3, 197 ::getBooleanCppuType(), 198 beans::PropertyAttribute::BOUND 199 | beans::PropertyAttribute::MAYBEVOID 200 | beans::PropertyAttribute::MAYBEDEFAULT )); 201 // light source 4 202 rOutProperties.push_back( 203 Property( C2U( "D3DSceneLightColor4" ), 204 PROP_SCENE_LIGHT_COLOR_4, 205 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 206 beans::PropertyAttribute::BOUND 207 | beans::PropertyAttribute::MAYBEVOID 208 | beans::PropertyAttribute::MAYBEDEFAULT )); 209 rOutProperties.push_back( 210 Property( C2U( "D3DSceneLightDirection4" ), 211 PROP_SCENE_LIGHT_DIRECTION_4, 212 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)), 213 beans::PropertyAttribute::BOUND 214 | beans::PropertyAttribute::MAYBEVOID 215 | beans::PropertyAttribute::MAYBEDEFAULT )); 216 rOutProperties.push_back( 217 Property( C2U( "D3DSceneLightOn4" ), 218 PROP_SCENE_LIGHT_ON_4, 219 ::getBooleanCppuType(), 220 beans::PropertyAttribute::BOUND 221 | beans::PropertyAttribute::MAYBEVOID 222 | beans::PropertyAttribute::MAYBEDEFAULT )); 223 // light source 5 224 rOutProperties.push_back( 225 Property( C2U( "D3DSceneLightColor5" ), 226 PROP_SCENE_LIGHT_COLOR_5, 227 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 228 beans::PropertyAttribute::BOUND 229 | beans::PropertyAttribute::MAYBEVOID 230 | beans::PropertyAttribute::MAYBEDEFAULT )); 231 rOutProperties.push_back( 232 Property( C2U( "D3DSceneLightDirection5" ), 233 PROP_SCENE_LIGHT_DIRECTION_5, 234 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)), 235 beans::PropertyAttribute::BOUND 236 | beans::PropertyAttribute::MAYBEVOID 237 | beans::PropertyAttribute::MAYBEDEFAULT )); 238 rOutProperties.push_back( 239 Property( C2U( "D3DSceneLightOn5" ), 240 PROP_SCENE_LIGHT_ON_5, 241 ::getBooleanCppuType(), 242 beans::PropertyAttribute::BOUND 243 | beans::PropertyAttribute::MAYBEVOID 244 | beans::PropertyAttribute::MAYBEDEFAULT )); 245 // light source 6 246 rOutProperties.push_back( 247 Property( C2U( "D3DSceneLightColor6" ), 248 PROP_SCENE_LIGHT_COLOR_6, 249 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 250 beans::PropertyAttribute::BOUND 251 | beans::PropertyAttribute::MAYBEVOID 252 | beans::PropertyAttribute::MAYBEDEFAULT )); 253 rOutProperties.push_back( 254 Property( C2U( "D3DSceneLightDirection6" ), 255 PROP_SCENE_LIGHT_DIRECTION_6, 256 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)), 257 beans::PropertyAttribute::BOUND 258 | beans::PropertyAttribute::MAYBEVOID 259 | beans::PropertyAttribute::MAYBEDEFAULT )); 260 rOutProperties.push_back( 261 Property( C2U( "D3DSceneLightOn6" ), 262 PROP_SCENE_LIGHT_ON_6, 263 ::getBooleanCppuType(), 264 beans::PropertyAttribute::BOUND 265 | beans::PropertyAttribute::MAYBEVOID 266 | beans::PropertyAttribute::MAYBEDEFAULT )); 267 // light source 7 268 rOutProperties.push_back( 269 Property( C2U( "D3DSceneLightColor7" ), 270 PROP_SCENE_LIGHT_COLOR_7, 271 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 272 beans::PropertyAttribute::BOUND 273 | beans::PropertyAttribute::MAYBEVOID 274 | beans::PropertyAttribute::MAYBEDEFAULT )); 275 rOutProperties.push_back( 276 Property( C2U( "D3DSceneLightDirection7" ), 277 PROP_SCENE_LIGHT_DIRECTION_7, 278 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)), 279 beans::PropertyAttribute::BOUND 280 | beans::PropertyAttribute::MAYBEVOID 281 | beans::PropertyAttribute::MAYBEDEFAULT )); 282 rOutProperties.push_back( 283 Property( C2U( "D3DSceneLightOn7" ), 284 PROP_SCENE_LIGHT_ON_7, 285 ::getBooleanCppuType(), 286 beans::PropertyAttribute::BOUND 287 | beans::PropertyAttribute::MAYBEVOID 288 | beans::PropertyAttribute::MAYBEDEFAULT )); 289 // light source 8 290 rOutProperties.push_back( 291 Property( C2U( "D3DSceneLightColor8" ), 292 PROP_SCENE_LIGHT_COLOR_8, 293 ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), 294 beans::PropertyAttribute::BOUND 295 | beans::PropertyAttribute::MAYBEVOID 296 | beans::PropertyAttribute::MAYBEDEFAULT )); 297 rOutProperties.push_back( 298 Property( C2U( "D3DSceneLightDirection8" ), 299 PROP_SCENE_LIGHT_DIRECTION_8, 300 ::getCppuType( reinterpret_cast< const drawing::Direction3D * >(0)), 301 beans::PropertyAttribute::BOUND 302 | beans::PropertyAttribute::MAYBEVOID 303 | beans::PropertyAttribute::MAYBEDEFAULT )); 304 rOutProperties.push_back( 305 Property( C2U( "D3DSceneLightOn8" ), 306 PROP_SCENE_LIGHT_ON_8, 307 ::getBooleanCppuType(), 308 beans::PropertyAttribute::BOUND 309 | beans::PropertyAttribute::MAYBEVOID 310 | beans::PropertyAttribute::MAYBEDEFAULT )); 311 } 312 313 void SceneProperties::AddDefaultsToMap( 314 ::chart::tPropertyValueMap & rOutMap ) 315 { 316 // Identity Matrix 317 drawing::HomogenMatrix aMtx; 318 aMtx.Line1.Column1 = aMtx.Line2.Column2 = 319 aMtx.Line3.Column3 = aMtx.Line4.Column4 = 1.0; 320 aMtx.Line1.Column2 = aMtx.Line1.Column3 = aMtx.Line1.Column4 = 321 aMtx.Line2.Column1 = aMtx.Line2.Column3 = aMtx.Line2.Column4 = 322 aMtx.Line3.Column1 = aMtx.Line3.Column2 = aMtx.Line3.Column4 = 323 aMtx.Line4.Column1 = aMtx.Line4.Column2 = aMtx.Line4.Column3 = 0.0; 324 325 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TRANSF_MATRIX, aMtx ); 326 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCENE_DISTANCE, 4200 ); 327 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_SCENE_FOCAL_LENGTH, 8000 ); 328 329 // PROP_SCENE_SHADOW_SLANT; 330 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_SHADE_MODE, drawing::ShadeMode_SMOOTH ); 331 332 ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( 333 rOutMap, PROP_SCENE_AMBIENT_COLOR, ChartTypeHelper::getDefaultAmbientLightColor(ThreeDLookScheme_Simple,0)); 334 335 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_TWO_SIDED_LIGHTING, true ); 336 337 drawing::Position3D vrp( 0.0, 0.0, 1.0 ); 338 drawing::Direction3D vpn( 0.0, 0.0, 1.0 ); 339 drawing::Direction3D vup( 0.0, 1.0, 0.0 ); 340 drawing::CameraGeometry aDefaultCameraGeometry( vrp, vpn, vup ); 341 342 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_CAMERA_GEOMETRY, aDefaultCameraGeometry ); 343 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_PERSPECTIVE, drawing::ProjectionMode_PERSPECTIVE ); 344 345 // Light Sources 346 // ------------- 347 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_1, false ); 348 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_2, true ); 349 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_3, false ); 350 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_4, false ); 351 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_5, false ); 352 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_6, false ); 353 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_7, false ); 354 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_ON_8, false ); 355 356 uno::Any aDefaultLightDirection( uno::makeAny( drawing::Direction3D( 0.0, 0.0, 1.0 ) ) ); 357 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_1, aDefaultLightDirection ); 358 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_2, ChartTypeHelper::getDefaultSimpleLightDirection(0)); 359 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_3, aDefaultLightDirection ); 360 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_4, aDefaultLightDirection ); 361 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_5, aDefaultLightDirection ); 362 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_6, aDefaultLightDirection ); 363 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_7, aDefaultLightDirection ); 364 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_DIRECTION_8, aDefaultLightDirection ); 365 366 uno::Any aDefaultLightColor; 367 aDefaultLightColor <<= ChartTypeHelper::getDefaultDirectLightColor(ThreeDLookScheme_Simple,0); 368 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_1, aDefaultLightColor ); 369 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_2, aDefaultLightColor ); 370 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_3, aDefaultLightColor ); 371 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_4, aDefaultLightColor ); 372 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_5, aDefaultLightColor ); 373 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_6, aDefaultLightColor ); 374 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_7, aDefaultLightColor ); 375 ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_SCENE_LIGHT_COLOR_8, aDefaultLightColor ); 376 } 377 378 } // namespace chart 379