1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 "tp_3D_SceneIllumination.hxx"
22 #include "Bitmaps.hrc"
23 #include "CommonConverters.hxx"
25 #include "svx/dialogs.hrc"
26 #include <svx/dialmgr.hxx>
27 #include <rtl/math.hxx>
28 #include <svtools/colrdlg.hxx>
29 #include <vcl/msgbox.hxx>
30 #include <svx/svx3ditems.hxx>
31 #include <svx/svddef.hxx>
32 #include <vcl/builderfactory.hxx>
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::chart2
;
40 LightButton::LightButton( vcl::Window
* pParent
)
41 : ImageButton( pParent
)
44 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF
) ) );
47 VCL_BUILDER_FACTORY(LightButton
)
49 void LightButton::switchLightOn(bool bOn
)
56 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON
) ) );
60 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF
) ) );
67 ::com::sun::star::drawing::Direction3D aDirection
;
71 nDiffuseColor( 0xcccccc ),
72 aDirection( 1.0, 1.0, -1.0 ),
77 struct LightSourceInfo
79 VclPtr
<LightButton
> pButton
;
80 LightSource aLightSource
;
83 void initButtonFromSource();
86 LightSourceInfo::LightSourceInfo()
90 aLightSource
.nDiffuseColor
= 0xffffff; // white
91 aLightSource
.aDirection
= drawing::Direction3D(1,1,1);
92 aLightSource
.bIsEnabled
= false;
95 void LightSourceInfo::initButtonFromSource()
99 pButton
->SetModeImage( Image( SVX_RES(
100 aLightSource
.bIsEnabled
? RID_SVXIMAGE_LIGHT_ON
: RID_SVXIMAGE_LIGHT_OFF
106 OUString
lcl_makeColorName( Color rColor
)
108 OUString aStr
= SVX_RESSTR(RID_SVXFLOAT3D_FIX_R
) +
109 OUString::number(rColor
.GetRed()) +
111 SVX_RESSTR(RID_SVXFLOAT3D_FIX_G
) +
112 OUString::number(rColor
.GetGreen()) +
114 SVX_RESSTR(RID_SVXFLOAT3D_FIX_B
) +
115 OUString::number(rColor
.GetBlue());
118 void lcl_selectColor( ColorListBox
& rListBox
, const Color
& rColor
)
120 rListBox
.SetNoSelection();
121 rListBox
.SelectEntry( rColor
);
122 if( rListBox
.GetSelectEntryCount() == 0 )
124 sal_uInt16 nPos
= rListBox
.InsertEntry( rColor
, lcl_makeColorName( rColor
) );
125 rListBox
.SelectEntryPos( nPos
);
129 ::chart::LightSource
lcl_getLightSourceFromProperties(
130 const uno::Reference
< beans::XPropertySet
> & xSceneProperties
,
133 ::chart::LightSource aResult
;
134 if( 0 <= nIndex
&& nIndex
< 8 )
136 OUString
aColorPropertyPrefix("D3DSceneLightColor");
137 OUString
aDirectionPropertyPrefix("D3DSceneLightDirection");
138 OUString
aEnabledPropertyPrefix("D3DSceneLightOn");
139 OUString
aIndex( OUString::number( nIndex
+ 1 ));
143 xSceneProperties
->getPropertyValue( aColorPropertyPrefix
+ aIndex
) >>= aResult
.nDiffuseColor
;
144 xSceneProperties
->getPropertyValue( aDirectionPropertyPrefix
+ aIndex
) >>= aResult
.aDirection
;
145 xSceneProperties
->getPropertyValue( aEnabledPropertyPrefix
+ aIndex
) >>= aResult
.bIsEnabled
;
147 catch( const uno::Exception
& ex
)
149 (void)(ex
); // no warning in non-debug builds
150 OSL_FAIL( OUStringToOString("Property Exception caught. Message: " +
151 ex
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
157 void lcl_setLightSource(
158 const uno::Reference
< beans::XPropertySet
> & xSceneProperties
,
159 const ::chart::LightSource
& rLightSource
,
162 if( 0 <= nIndex
&& nIndex
< 8 )
164 OUString
aColorPropertyPrefix("D3DSceneLightColor");
165 OUString
aDirectionPropertyPrefix("D3DSceneLightDirection");
166 OUString
aEnabledPropertyPrefix("D3DSceneLightOn");
167 OUString
aIndex( OUString::number( nIndex
+ 1 ));
171 xSceneProperties
->setPropertyValue( aColorPropertyPrefix
+ aIndex
,
172 uno::makeAny( rLightSource
.nDiffuseColor
));
173 xSceneProperties
->setPropertyValue( aDirectionPropertyPrefix
+ aIndex
,
174 uno::makeAny( rLightSource
.aDirection
));
175 xSceneProperties
->setPropertyValue( aEnabledPropertyPrefix
+ aIndex
,
176 uno::makeAny( rLightSource
.bIsEnabled
));
178 catch( const uno::Exception
& ex
)
180 (void)(ex
); // no warning in non-debug builds
181 OSL_FAIL( OUStringToOString("Property Exception caught. Message: " +
182 ex
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
187 Color
lcl_getAmbientColor(
188 const uno::Reference
< beans::XPropertySet
> & xSceneProperties
)
190 sal_Int32 nResult
= 0x000000;
193 xSceneProperties
->getPropertyValue("D3DSceneAmbientColor") >>= nResult
;
195 catch( const uno::Exception
& ex
)
197 (void)(ex
); // no warning in non-debug builds
198 OSL_FAIL( OUStringToOString("Property Exception caught. Message: " +
199 ex
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
201 return Color( nResult
);
204 void lcl_setAmbientColor(
205 const uno::Reference
< beans::XPropertySet
> & xSceneProperties
,
206 const Color
& rColor
)
210 xSceneProperties
->setPropertyValue("D3DSceneAmbientColor",
211 uno::makeAny( rColor
.GetColor()));
213 catch( const uno::Exception
& ex
)
215 (void)(ex
); // no warning in non-debug builds
216 OSL_FAIL( OUStringToOString( "Property Exception caught. Message: " +
217 ex
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
222 ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( vcl::Window
* pWindow
223 , const uno::Reference
< beans::XPropertySet
> & xSceneProperties
224 , const uno::Reference
< frame::XModel
>& xChartModel
225 , const XColorListRef
& pColorTable
)
227 ,"tp_3D_SceneIllumination"
228 ,"modules/schart/ui/tp_3D_SceneIllumination.ui")
229 , m_pLightSourceInfoList(0)
230 , m_xSceneProperties( xSceneProperties
)
231 , m_aTimerTriggeredControllerLock( xChartModel
)
232 , m_bInCommitToModel( false )
233 , m_aModelChangeListener( LINK( this, ThreeD_SceneIllumination_TabPage
, fillControlsFromModel
) )
234 , m_xChartModel( xChartModel
)
236 get(m_pBtn_Light1
, "BTN_LIGHT_1");
237 get(m_pBtn_Light2
, "BTN_LIGHT_2");
238 get(m_pBtn_Light3
, "BTN_LIGHT_3");
239 get(m_pBtn_Light4
, "BTN_LIGHT_4");
240 get(m_pBtn_Light5
, "BTN_LIGHT_5");
241 get(m_pBtn_Light6
, "BTN_LIGHT_6");
242 get(m_pBtn_Light7
, "BTN_LIGHT_7");
243 get(m_pBtn_Light8
, "BTN_LIGHT_8");
245 get(m_pLB_LightSource
, "LB_LIGHTSOURCE");
246 get(m_pLB_AmbientLight
, "LB_AMBIENTLIGHT");
247 get(m_pBtn_LightSource_Color
, "BTN_LIGHTSOURCE_COLOR");
248 get(m_pBtn_AmbientLight_Color
, "BTN_AMBIENT_COLOR");
250 get(m_pCtl_Preview
, "CTL_LIGHT_PREVIEW");
252 if( pColorTable
.is() )
254 m_pLB_AmbientLight
->Fill( pColorTable
);
255 m_pLB_LightSource
->Fill( pColorTable
);
257 m_pLB_AmbientLight
->SetDropDownLineCount(10);
258 m_pLB_LightSource
->SetDropDownLineCount(10);
260 m_pLightSourceInfoList
= new LightSourceInfo
[8];
261 m_pLightSourceInfoList
[0].pButton
= m_pBtn_Light1
;
262 m_pLightSourceInfoList
[1].pButton
= m_pBtn_Light2
;
263 m_pLightSourceInfoList
[2].pButton
= m_pBtn_Light3
;
264 m_pLightSourceInfoList
[3].pButton
= m_pBtn_Light4
;
265 m_pLightSourceInfoList
[4].pButton
= m_pBtn_Light5
;
266 m_pLightSourceInfoList
[5].pButton
= m_pBtn_Light6
;
267 m_pLightSourceInfoList
[6].pButton
= m_pBtn_Light7
;
268 m_pLightSourceInfoList
[7].pButton
= m_pBtn_Light8
;
270 fillControlsFromModel(0);
272 m_pBtn_Light1
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
273 m_pBtn_Light2
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
274 m_pBtn_Light3
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
275 m_pBtn_Light4
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
276 m_pBtn_Light5
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
277 m_pBtn_Light6
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
278 m_pBtn_Light7
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
279 m_pBtn_Light8
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
281 m_pLB_AmbientLight
->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, SelectColorHdl
) );
282 m_pLB_LightSource
->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, SelectColorHdl
) );
284 m_pBtn_AmbientLight_Color
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ColorDialogHdl
) );
285 m_pBtn_LightSource_Color
->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ColorDialogHdl
) );
287 m_pCtl_Preview
->SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage
, PreviewChangeHdl
) );
288 m_pCtl_Preview
->SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage
, PreviewSelectHdl
) );
290 ClickLightSourceButtonHdl(m_pBtn_Light2
);
293 ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage()
298 void ThreeD_SceneIllumination_TabPage::dispose()
300 delete[] m_pLightSourceInfoList
;
301 m_pLightSourceInfoList
= NULL
;
302 m_pBtn_Light1
.clear();
303 m_pBtn_Light2
.clear();
304 m_pBtn_Light3
.clear();
305 m_pBtn_Light4
.clear();
306 m_pBtn_Light5
.clear();
307 m_pBtn_Light6
.clear();
308 m_pBtn_Light7
.clear();
309 m_pBtn_Light8
.clear();
310 m_pLB_LightSource
.clear();
311 m_pBtn_LightSource_Color
.clear();
312 m_pLB_AmbientLight
.clear();
313 m_pBtn_AmbientLight_Color
.clear();
314 m_pCtl_Preview
.clear();
318 IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage
, fillControlsFromModel
)
320 if( m_bInCommitToModel
)//don't read own changes
324 for( nL
=0; nL
<8; nL
++)
325 m_pLightSourceInfoList
[nL
].aLightSource
= lcl_getLightSourceFromProperties( m_xSceneProperties
, nL
);
326 for( nL
=0; nL
<8; nL
++)
327 m_pLightSourceInfoList
[nL
].initButtonFromSource();
329 lcl_selectColor( *m_pLB_AmbientLight
, lcl_getAmbientColor( m_xSceneProperties
));
331 this->updatePreview();
336 void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( sal_uInt32 nLightNumber
)
338 ControllerLockGuardUNO
aGuard( m_xChartModel
);
339 m_bInCommitToModel
= true;
340 sal_Int32
nIndex( nLightNumber
);
341 lcl_setLightSource( m_xSceneProperties
, m_pLightSourceInfoList
[nIndex
].aLightSource
, nIndex
);
342 m_bInCommitToModel
= false;
345 void ThreeD_SceneIllumination_TabPage::applyLightSourcesToModel()
347 m_aTimerTriggeredControllerLock
.startTimer();
348 ControllerLockGuardUNO
aGuard( m_xChartModel
);
349 for( sal_Int32 nL
=0; nL
<8; nL
++)
350 applyLightSourceToModel( nL
);
351 m_aTimerTriggeredControllerLock
.startTimer();
354 IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage
, PreviewChangeHdl
)
356 m_aTimerTriggeredControllerLock
.startTimer();
358 //update m_pLightSourceInfoList from preview
359 const SfxItemSet
a3DLightAttributes(m_pCtl_Preview
->GetSvx3DLightControl().Get3DAttributes());
360 LightSourceInfo
* pInfo
= &m_pLightSourceInfoList
[0];
362 pInfo
->aLightSource
.nDiffuseColor
= static_cast<const SvxColorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1
)).GetValue().GetColor();
363 pInfo
->aLightSource
.bIsEnabled
= static_cast<const SfxBoolItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_1
)).GetValue();
364 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1
)).GetValue());
366 pInfo
= &m_pLightSourceInfoList
[1];
367 pInfo
->aLightSource
.nDiffuseColor
= static_cast<const SvxColorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2
)).GetValue().GetColor();
368 pInfo
->aLightSource
.bIsEnabled
= static_cast<const SfxBoolItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_2
)).GetValue();
369 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2
)).GetValue());
371 pInfo
= &m_pLightSourceInfoList
[2];
372 pInfo
->aLightSource
.nDiffuseColor
= static_cast<const SvxColorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3
)).GetValue().GetColor();
373 pInfo
->aLightSource
.bIsEnabled
= static_cast<const SfxBoolItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_3
)).GetValue();
374 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3
)).GetValue());
376 pInfo
= &m_pLightSourceInfoList
[3];
377 pInfo
->aLightSource
.nDiffuseColor
= static_cast<const SvxColorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4
)).GetValue().GetColor();
378 pInfo
->aLightSource
.bIsEnabled
= static_cast<const SfxBoolItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_4
)).GetValue();
379 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4
)).GetValue());
381 pInfo
= &m_pLightSourceInfoList
[4];
382 pInfo
->aLightSource
.nDiffuseColor
= static_cast<const SvxColorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5
)).GetValue().GetColor();
383 pInfo
->aLightSource
.bIsEnabled
= static_cast<const SfxBoolItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_5
)).GetValue();
384 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5
)).GetValue());
386 pInfo
= &m_pLightSourceInfoList
[5];
387 pInfo
->aLightSource
.nDiffuseColor
= static_cast<const SvxColorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6
)).GetValue().GetColor();
388 pInfo
->aLightSource
.bIsEnabled
= static_cast<const SfxBoolItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_6
)).GetValue();
389 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6
)).GetValue());
391 pInfo
= &m_pLightSourceInfoList
[6];
392 pInfo
->aLightSource
.nDiffuseColor
= static_cast<const SvxColorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7
)).GetValue().GetColor();
393 pInfo
->aLightSource
.bIsEnabled
= static_cast<const SfxBoolItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_7
)).GetValue();
394 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7
)).GetValue());
396 pInfo
= &m_pLightSourceInfoList
[7];
397 pInfo
->aLightSource
.nDiffuseColor
= static_cast<const SvxColorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8
)).GetValue().GetColor();
398 pInfo
->aLightSource
.bIsEnabled
= static_cast<const SfxBoolItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_8
)).GetValue();
399 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem
&>(a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8
)).GetValue());
401 applyLightSourcesToModel();
406 IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage
, PreviewSelectHdl
)
408 sal_uInt32 nLightNumber
= m_pCtl_Preview
->GetSvx3DLightControl().GetSelectedLight();
411 LightButton
* pButton
= m_pLightSourceInfoList
[nLightNumber
].pButton
;
412 if(!pButton
->IsChecked())
413 ClickLightSourceButtonHdl(pButton
);
415 applyLightSourcesToModel();
420 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, ColorDialogHdl
, Button
*, pButton
)
422 bool bIsAmbientLight
= (pButton
==m_pBtn_AmbientLight_Color
);
423 ColorLB
* pListBox
= ( bIsAmbientLight
? m_pLB_AmbientLight
: m_pLB_LightSource
);
425 SvColorDialog
aColorDlg( this );
426 aColorDlg
.SetColor( pListBox
->GetSelectEntryColor() );
427 if( aColorDlg
.Execute() == RET_OK
)
429 Color
aColor( aColorDlg
.GetColor());
430 lcl_selectColor( *pListBox
, aColor
);
431 if( bIsAmbientLight
)
433 m_bInCommitToModel
= true;
434 lcl_setAmbientColor( m_xSceneProperties
, aColor
);
435 m_bInCommitToModel
= false;
439 //get active lightsource:
440 LightSourceInfo
* pInfo
= 0;
442 for( nL
=0; nL
<8; nL
++)
444 pInfo
= &m_pLightSourceInfoList
[nL
];
445 if(pInfo
->pButton
->IsChecked())
450 applyLightSourceToModel( nL
);
452 SelectColorHdl( pListBox
);
457 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, SelectColorHdl
, ColorLB
*, pListBox
)
459 if(pListBox
==m_pLB_AmbientLight
)
461 m_bInCommitToModel
= true;
462 lcl_setAmbientColor( m_xSceneProperties
, pListBox
->GetSelectEntryColor().GetColor());
463 m_bInCommitToModel
= false;
465 else if(pListBox
==m_pLB_LightSource
)
467 //get active lightsource:
468 LightSourceInfo
* pInfo
= 0;
470 for( nL
=0; nL
<8; nL
++)
472 pInfo
= &m_pLightSourceInfoList
[nL
];
473 if(pInfo
->pButton
->IsChecked())
479 pInfo
->aLightSource
.nDiffuseColor
= pListBox
->GetSelectEntryColor().GetColor();
480 applyLightSourceToModel( nL
);
483 this->updatePreview();
487 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
, LightButton
*, pButton
)
492 LightSourceInfo
* pInfo
= 0;
494 for( nL
=0; nL
<8; nL
++)
496 if( m_pLightSourceInfoList
[nL
].pButton
== pButton
)
498 pInfo
= &m_pLightSourceInfoList
[nL
];
503 //update light button
504 bool bIsChecked
= pButton
->IsChecked();
507 pButton
->switchLightOn(!pButton
->isLightOn());
510 pInfo
->aLightSource
.bIsEnabled
=pButton
->isLightOn();
511 applyLightSourceToModel( nL
);
516 ControllerLockGuardUNO
aGuard( m_xChartModel
);
517 for( nL
=0; nL
<8; nL
++)
519 LightButton
* pLightButton
= m_pLightSourceInfoList
[nL
].pButton
;
520 pLightButton
->Check( pLightButton
== pButton
);
524 //update color list box
527 lcl_selectColor( *m_pLB_LightSource
, pInfo
->aLightSource
.nDiffuseColor
);
529 this->updatePreview();
533 void ThreeD_SceneIllumination_TabPage::updatePreview()
535 SfxItemSet
aItemSet(m_pCtl_Preview
->GetSvx3DLightControl().Get3DAttributes());
536 LightSourceInfo
* pInfo
= &m_pLightSourceInfoList
[0];
539 aItemSet
.Put(makeSvx3DAmbientcolorItem(m_pLB_AmbientLight
->GetSelectEntryColor()));
541 aItemSet
.Put(makeSvx3DLightcolor1Item(pInfo
->aLightSource
.nDiffuseColor
));
542 aItemSet
.Put(makeSvx3DLightOnOff1Item(pInfo
->aLightSource
.bIsEnabled
));
543 aItemSet
.Put(makeSvx3DLightDirection1Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
545 pInfo
= &m_pLightSourceInfoList
[1];
546 aItemSet
.Put(makeSvx3DLightcolor2Item(pInfo
->aLightSource
.nDiffuseColor
));
547 aItemSet
.Put(makeSvx3DLightOnOff2Item(pInfo
->aLightSource
.bIsEnabled
));
548 aItemSet
.Put(makeSvx3DLightDirection2Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
550 pInfo
= &m_pLightSourceInfoList
[2];
551 aItemSet
.Put(makeSvx3DLightcolor3Item(pInfo
->aLightSource
.nDiffuseColor
));
552 aItemSet
.Put(makeSvx3DLightOnOff3Item(pInfo
->aLightSource
.bIsEnabled
));
553 aItemSet
.Put(makeSvx3DLightDirection3Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
555 pInfo
= &m_pLightSourceInfoList
[3];
556 aItemSet
.Put(makeSvx3DLightcolor4Item(pInfo
->aLightSource
.nDiffuseColor
));
557 aItemSet
.Put(makeSvx3DLightOnOff4Item(pInfo
->aLightSource
.bIsEnabled
));
558 aItemSet
.Put(makeSvx3DLightDirection4Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
560 pInfo
= &m_pLightSourceInfoList
[4];
561 aItemSet
.Put(makeSvx3DLightcolor5Item(pInfo
->aLightSource
.nDiffuseColor
));
562 aItemSet
.Put(makeSvx3DLightOnOff5Item(pInfo
->aLightSource
.bIsEnabled
));
563 aItemSet
.Put(makeSvx3DLightDirection5Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
565 pInfo
= &m_pLightSourceInfoList
[5];
566 aItemSet
.Put(makeSvx3DLightcolor6Item(pInfo
->aLightSource
.nDiffuseColor
));
567 aItemSet
.Put(makeSvx3DLightOnOff6Item(pInfo
->aLightSource
.bIsEnabled
));
568 aItemSet
.Put(makeSvx3DLightDirection6Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
570 pInfo
= &m_pLightSourceInfoList
[6];
571 aItemSet
.Put(makeSvx3DLightcolor7Item(pInfo
->aLightSource
.nDiffuseColor
));
572 aItemSet
.Put(makeSvx3DLightOnOff7Item(pInfo
->aLightSource
.bIsEnabled
));
573 aItemSet
.Put(makeSvx3DLightDirection7Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
575 pInfo
= &m_pLightSourceInfoList
[7];
576 aItemSet
.Put(makeSvx3DLightcolor8Item(pInfo
->aLightSource
.nDiffuseColor
));
577 aItemSet
.Put(makeSvx3DLightOnOff8Item(pInfo
->aLightSource
.bIsEnabled
));
578 aItemSet
.Put(makeSvx3DLightDirection8Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
580 // set lights and ambient light
581 m_pCtl_Preview
->GetSvx3DLightControl().Set3DAttributes(aItemSet
);
584 for(sal_uInt32
a(0); a
< 8; a
++)
586 if(m_pLightSourceInfoList
[a
].pButton
->IsChecked())
588 m_pCtl_Preview
->GetSvx3DLightControl().SelectLight(a
);
589 m_pCtl_Preview
->CheckSelection();
597 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */