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: tp_3D_SceneIllumination.cxx,v $
10 * $Revision: 1.4.68.1 $
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 "tp_3D_SceneIllumination.hxx"
35 #include "tp_3D_SceneIllumination.hrc"
37 #include "Strings.hrc"
38 #include "Bitmaps.hrc"
39 #include "Bitmaps_HC.hrc"
40 #include "CommonConverters.hxx"
41 #include "NoWarningThisInCTOR.hxx"
43 #ifndef _SVX_DIALOGS_HRC
44 #include "svx/dialogs.hrc"
46 // header for define SVX_RES
47 #include <svx/dialmgr.hxx>
48 #include <rtl/math.hxx>
50 // header for class SvColorDialog
51 #include <svtools/colrdlg.hxx>
53 // header for define RET_OK
54 #include <vcl/msgbox.hxx>
56 #include <svx/svx3ditems.hxx>
57 #include <svx/svddef.hxx>
59 //.............................................................................
62 //.............................................................................
64 using namespace ::com::sun::star
;
65 using namespace ::com::sun::star::chart2
;
67 LightButton::LightButton( Window
* pParent
, const ResId
& rResId
, sal_Int32 nLightNumber
)
68 : ImageButton( pParent
, rResId
)
71 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF
) ), BMP_COLOR_NORMAL
);
72 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF_H
) ), BMP_COLOR_HIGHCONTRAST
);
74 String
aTipHelpStr( SchResId(STR_TIP_LIGHTSOURCE_X
) );
75 rtl::OUString
aTipHelp( aTipHelpStr
);
76 const rtl::OUString
aReplacementStr( RTL_CONSTASCII_USTRINGPARAM( "%LIGHTNUMBER" ));
77 sal_Int32 nIndex
= aTipHelp
.indexOf( aReplacementStr
);
80 aTipHelp
= aTipHelp
.replaceAt(nIndex
, aReplacementStr
.getLength(),
81 rtl::OUString::valueOf( nLightNumber
) );
83 this->SetQuickHelpText( String( aTipHelp
) );
85 LightButton::~LightButton()
88 void LightButton::switchLightOn(bool bOn
)
95 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON
) ), BMP_COLOR_NORMAL
);
96 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON_H
) ), BMP_COLOR_HIGHCONTRAST
);
100 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF
) ), BMP_COLOR_NORMAL
);
101 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF_H
) ), BMP_COLOR_HIGHCONTRAST
);
104 bool LightButton::isLightOn() const
109 //-----------------------------------------------------------------------------
111 ColorButton::ColorButton( Window
* pParent
, const ResId
& rResId
)
112 : ImageButton( pParent
, rResId
)
114 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_COLORDLG
) ), BMP_COLOR_NORMAL
);
115 SetModeImage( Image( SVX_RES(RID_SVXIMAGE_COLORDLG_H
) ), BMP_COLOR_HIGHCONTRAST
);
117 this->SetQuickHelpText( String( SchResId(STR_TIP_CHOOSECOLOR
) ) );
119 ColorButton::~ColorButton()
123 //-----------------------------------------------------------------------------
128 ::com::sun::star::drawing::Direction3D aDirection
;
132 nDiffuseColor( 0xcccccc ),
133 aDirection( 1.0, 1.0, -1.0 ),
138 struct LightSourceInfo
140 LightButton
* pButton
;
141 LightSource aLightSource
;
144 void initButtonFromSource();
147 LightSourceInfo::LightSourceInfo()
151 aLightSource
.nDiffuseColor
= 0xffffff; // white
152 aLightSource
.aDirection
= drawing::Direction3D(1,1,1);
153 aLightSource
.bIsEnabled
= sal_False
;
155 void LightSourceInfo::initButtonFromSource()
159 pButton
->SetModeImage( Image( SVX_RES( aLightSource
.bIsEnabled
? RID_SVXIMAGE_LIGHT_ON
: RID_SVXIMAGE_LIGHT_OFF
) ), BMP_COLOR_NORMAL
);
160 pButton
->SetModeImage( Image( SVX_RES( aLightSource
.bIsEnabled
? RID_SVXIMAGE_LIGHT_ON_H
: RID_SVXIMAGE_LIGHT_OFF_H
) ), BMP_COLOR_HIGHCONTRAST
);
163 //-----------------------------------------------------------------------------
167 rtl::OUString
lcl_makeColorName( Color rColor
)
169 String
aStr(SVX_RES(RID_SVXFLOAT3D_FIX_R
));
170 aStr
+= String::CreateFromInt32((INT32
)rColor
.GetRed());
171 aStr
+= sal_Unicode(' ');
172 aStr
+= String(SVX_RES(RID_SVXFLOAT3D_FIX_G
));
173 aStr
+= String::CreateFromInt32((INT32
)rColor
.GetGreen());
174 aStr
+= sal_Unicode(' ');
175 aStr
+= String(SVX_RES(RID_SVXFLOAT3D_FIX_B
));
176 aStr
+= String::CreateFromInt32((INT32
)rColor
.GetBlue());
179 void lcl_selectColor( ColorListBox
& rListBox
, const Color
& rColor
)
181 rListBox
.SetNoSelection();
182 rListBox
.SelectEntry( rColor
);
183 if( rListBox
.GetSelectEntryCount() == 0 )
185 USHORT nPos
= rListBox
.InsertEntry( rColor
, lcl_makeColorName( rColor
) );
186 rListBox
.SelectEntryPos( nPos
);
190 ::chart::LightSource
lcl_getLightSourceFromProperties(
191 const uno::Reference
< beans::XPropertySet
> & xSceneProperties
,
194 ::chart::LightSource aResult
;
195 if( 0 <= nIndex
&& nIndex
< 8 )
197 ::rtl::OUString
aColorPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor"));
198 ::rtl::OUString
aDirectionPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection"));
199 ::rtl::OUString
aEnabledPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn"));
200 ::rtl::OUString
aIndex( ::rtl::OUString::valueOf( nIndex
+ 1 ));
204 xSceneProperties
->getPropertyValue( aColorPropertyPrefix
+ aIndex
) >>= aResult
.nDiffuseColor
;
205 xSceneProperties
->getPropertyValue( aDirectionPropertyPrefix
+ aIndex
) >>= aResult
.aDirection
;
206 xSceneProperties
->getPropertyValue( aEnabledPropertyPrefix
+ aIndex
) >>= aResult
.bIsEnabled
;
208 catch( const uno::Exception
& ex
)
210 (void)(ex
); // no warning in non-debug builds
211 OSL_ENSURE( false, ::rtl::OUStringToOString(
212 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
213 ex
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
219 void lcl_setLightSource(
220 const uno::Reference
< beans::XPropertySet
> & xSceneProperties
,
221 const ::chart::LightSource
& rLightSource
,
224 if( 0 <= nIndex
&& nIndex
< 8 )
226 ::rtl::OUString
aColorPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor"));
227 ::rtl::OUString
aDirectionPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection"));
228 ::rtl::OUString
aEnabledPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn"));
229 ::rtl::OUString
aIndex( ::rtl::OUString::valueOf( nIndex
+ 1 ));
233 xSceneProperties
->setPropertyValue( aColorPropertyPrefix
+ aIndex
,
234 uno::makeAny( rLightSource
.nDiffuseColor
));
235 xSceneProperties
->setPropertyValue( aDirectionPropertyPrefix
+ aIndex
,
236 uno::makeAny( rLightSource
.aDirection
));
237 xSceneProperties
->setPropertyValue( aEnabledPropertyPrefix
+ aIndex
,
238 uno::makeAny( rLightSource
.bIsEnabled
));
240 catch( const uno::Exception
& ex
)
242 (void)(ex
); // no warning in non-debug builds
243 OSL_ENSURE( false, ::rtl::OUStringToOString(
244 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
245 ex
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
250 Color
lcl_getAmbientColor(
251 const uno::Reference
< beans::XPropertySet
> & xSceneProperties
)
253 sal_Int32 nResult
= 0x000000;
256 xSceneProperties
->getPropertyValue(
257 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor"))) >>= nResult
;
259 catch( const uno::Exception
& ex
)
261 (void)(ex
); // no warning in non-debug builds
262 OSL_ENSURE( false, ::rtl::OUStringToOString(
263 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
264 ex
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
266 return Color( nResult
);
269 void lcl_setAmbientColor(
270 const uno::Reference
< beans::XPropertySet
> & xSceneProperties
,
271 const Color
& rColor
)
275 xSceneProperties
->setPropertyValue(
276 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor")),
277 uno::makeAny( rColor
.GetColor()));
279 catch( const uno::Exception
& ex
)
281 (void)(ex
); // no warning in non-debug builds
282 OSL_ENSURE( false, ::rtl::OUStringToOString(
283 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
284 ex
.Message
, RTL_TEXTENCODING_ASCII_US
).getStr());
289 //-----------------------------------------------------------------------------
291 ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( Window
* pWindow
292 , const uno::Reference
< beans::XPropertySet
> & xSceneProperties
293 , const uno::Reference
< frame::XModel
>& xChartModel
294 , XColorTable
* pColorTable
)
295 : TabPage ( pWindow
, SchResId( TP_3D_SCENEILLUMINATION
) )
296 , m_aFT_LightSource( this, SchResId( FT_LIGHTSOURCE
) )
297 , m_aBtn_Light1( this, SchResId( BTN_LIGHT_1
), 1 )
298 , m_aBtn_Light2( this, SchResId( BTN_LIGHT_2
), 2 )
299 , m_aBtn_Light3( this, SchResId( BTN_LIGHT_3
), 3 )
300 , m_aBtn_Light4( this, SchResId( BTN_LIGHT_4
), 4 )
301 , m_aBtn_Light5( this, SchResId( BTN_LIGHT_5
), 5 )
302 , m_aBtn_Light6( this, SchResId( BTN_LIGHT_6
), 6 )
303 , m_aBtn_Light7( this, SchResId( BTN_LIGHT_7
), 7 )
304 , m_aBtn_Light8( this, SchResId( BTN_LIGHT_8
), 8 )
305 , m_aLB_LightSource( this, SchResId( LB_LIGHTSOURCE
) )
306 , m_aBtn_LightSource_Color( this, SchResId( BTN_LIGHTSOURCE_COLOR
) )
307 , m_aFT_AmbientLight( this, SchResId( FT_AMBIENTLIGHT
) )
308 , m_aLB_AmbientLight( this, SchResId( LB_AMBIENTLIGHT
) )
309 , m_aBtn_AmbientLight_Color( this, SchResId( BTN_AMBIENT_COLOR
) )
310 , m_aCtl_Preview( this, SchResId( CTL_LIGHT_PREVIEW
) )
311 , m_pLightSourceInfoList(0)
312 , m_xSceneProperties( xSceneProperties
)
313 , m_aTimerTriggeredControllerLock( xChartModel
)
314 , m_bInCommitToModel( false )
315 , m_aModelChangeListener( LINK( this, ThreeD_SceneIllumination_TabPage
, fillControlsFromModel
) )
316 , m_xChartModel( xChartModel
)
322 m_aLB_AmbientLight
.Fill( pColorTable
);
323 m_aLB_LightSource
.Fill( pColorTable
);
325 m_aLB_AmbientLight
.SetDropDownLineCount(10);
326 m_aLB_LightSource
.SetDropDownLineCount(10);
328 m_pLightSourceInfoList
= new LightSourceInfo
[8];
329 m_pLightSourceInfoList
[0].pButton
= &m_aBtn_Light1
;
330 m_pLightSourceInfoList
[1].pButton
= &m_aBtn_Light2
;
331 m_pLightSourceInfoList
[2].pButton
= &m_aBtn_Light3
;
332 m_pLightSourceInfoList
[3].pButton
= &m_aBtn_Light4
;
333 m_pLightSourceInfoList
[4].pButton
= &m_aBtn_Light5
;
334 m_pLightSourceInfoList
[5].pButton
= &m_aBtn_Light6
;
335 m_pLightSourceInfoList
[6].pButton
= &m_aBtn_Light7
;
336 m_pLightSourceInfoList
[7].pButton
= &m_aBtn_Light8
;
338 fillControlsFromModel(0);
340 m_aBtn_Light1
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
341 m_aBtn_Light2
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
342 m_aBtn_Light3
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
343 m_aBtn_Light4
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
344 m_aBtn_Light5
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
345 m_aBtn_Light6
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
346 m_aBtn_Light7
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
347 m_aBtn_Light8
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
) );
349 m_aLB_AmbientLight
.SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, SelectColorHdl
) );
350 m_aLB_LightSource
.SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, SelectColorHdl
) );
352 m_aBtn_AmbientLight_Color
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ColorDialogHdl
) );
353 m_aBtn_LightSource_Color
.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage
, ColorDialogHdl
) );
355 m_aCtl_Preview
.SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage
, PreviewChangeHdl
) );
356 m_aCtl_Preview
.SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage
, PreviewSelectHdl
) );
358 ClickLightSourceButtonHdl(&m_aBtn_Light2
);
360 //m_aDelyedModelChangeTimer.SetTimeout( 4*EDIT_UPDATEDATA_TIMEOUT );
362 m_aModelChangeListener
.startListening( uno::Reference
< util::XModifyBroadcaster
>(m_xSceneProperties
, uno::UNO_QUERY
) );
365 ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage()
367 delete[] m_pLightSourceInfoList
;
370 void ThreeD_SceneIllumination_TabPage::commitPendingChanges()
374 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, fillControlsFromModel
, void *, EMPTYARG
)
376 if( m_bInCommitToModel
)//don't read own changes
380 for( nL
=0; nL
<8; nL
++)
381 m_pLightSourceInfoList
[nL
].aLightSource
= lcl_getLightSourceFromProperties( m_xSceneProperties
, nL
);
382 for( nL
=0; nL
<8; nL
++)
383 m_pLightSourceInfoList
[nL
].initButtonFromSource();
385 lcl_selectColor( m_aLB_AmbientLight
, lcl_getAmbientColor( m_xSceneProperties
));
387 this->updatePreview();
392 void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( sal_uInt32 nLightNumber
)
394 ControllerLockGuard
aGuard( m_xChartModel
);
395 m_bInCommitToModel
= true;
396 sal_Int32
nIndex( nLightNumber
);
397 lcl_setLightSource( m_xSceneProperties
, m_pLightSourceInfoList
[nIndex
].aLightSource
, nIndex
);
398 m_bInCommitToModel
= false;
401 void ThreeD_SceneIllumination_TabPage::applyLightSourcesToModel()
403 m_aTimerTriggeredControllerLock
.startTimer();
404 ControllerLockGuard
aGuard( m_xChartModel
);
405 for( sal_Int32 nL
=0; nL
<8; nL
++)
406 applyLightSourceToModel( nL
);
407 m_aTimerTriggeredControllerLock
.startTimer();
410 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, PreviewChangeHdl
, void*, EMPTYARG
)
412 m_aTimerTriggeredControllerLock
.startTimer();
414 //update m_pLightSourceInfoList from preview
415 const SfxItemSet
a3DLightAttributes(m_aCtl_Preview
.GetSvx3DLightControl().Get3DAttributes());
416 LightSourceInfo
* pInfo
= &m_pLightSourceInfoList
[0];
418 pInfo
->aLightSource
.nDiffuseColor
= ((const Svx3DLightcolor1Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1
)).GetValue().GetColor();
419 pInfo
->aLightSource
.bIsEnabled
= ((const Svx3DLightOnOff1Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_1
)).GetValue();
420 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(((const Svx3DLightDirection1Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1
)).GetValue());
422 pInfo
= &m_pLightSourceInfoList
[1];
423 pInfo
->aLightSource
.nDiffuseColor
= ((const Svx3DLightcolor2Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2
)).GetValue().GetColor();
424 pInfo
->aLightSource
.bIsEnabled
= ((const Svx3DLightOnOff2Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_2
)).GetValue();
425 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(((const Svx3DLightDirection2Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2
)).GetValue());
427 pInfo
= &m_pLightSourceInfoList
[2];
428 pInfo
->aLightSource
.nDiffuseColor
= ((const Svx3DLightcolor3Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3
)).GetValue().GetColor();
429 pInfo
->aLightSource
.bIsEnabled
= ((const Svx3DLightOnOff3Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_3
)).GetValue();
430 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(((const Svx3DLightDirection3Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3
)).GetValue());
432 pInfo
= &m_pLightSourceInfoList
[3];
433 pInfo
->aLightSource
.nDiffuseColor
= ((const Svx3DLightcolor4Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4
)).GetValue().GetColor();
434 pInfo
->aLightSource
.bIsEnabled
= ((const Svx3DLightOnOff4Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_4
)).GetValue();
435 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(((const Svx3DLightDirection4Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4
)).GetValue());
437 pInfo
= &m_pLightSourceInfoList
[4];
438 pInfo
->aLightSource
.nDiffuseColor
= ((const Svx3DLightcolor5Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5
)).GetValue().GetColor();
439 pInfo
->aLightSource
.bIsEnabled
= ((const Svx3DLightOnOff5Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_5
)).GetValue();
440 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(((const Svx3DLightDirection5Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5
)).GetValue());
442 pInfo
= &m_pLightSourceInfoList
[5];
443 pInfo
->aLightSource
.nDiffuseColor
= ((const Svx3DLightcolor6Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6
)).GetValue().GetColor();
444 pInfo
->aLightSource
.bIsEnabled
= ((const Svx3DLightOnOff6Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_6
)).GetValue();
445 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(((const Svx3DLightDirection6Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6
)).GetValue());
447 pInfo
= &m_pLightSourceInfoList
[6];
448 pInfo
->aLightSource
.nDiffuseColor
= ((const Svx3DLightcolor7Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7
)).GetValue().GetColor();
449 pInfo
->aLightSource
.bIsEnabled
= ((const Svx3DLightOnOff7Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_7
)).GetValue();
450 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(((const Svx3DLightDirection7Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7
)).GetValue());
452 pInfo
= &m_pLightSourceInfoList
[7];
453 pInfo
->aLightSource
.nDiffuseColor
= ((const Svx3DLightcolor8Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8
)).GetValue().GetColor();
454 pInfo
->aLightSource
.bIsEnabled
= ((const Svx3DLightOnOff8Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTON_8
)).GetValue();
455 pInfo
->aLightSource
.aDirection
= B3DVectorToDirection3D(((const Svx3DLightDirection8Item
&)a3DLightAttributes
.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8
)).GetValue());
457 applyLightSourcesToModel();
462 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, PreviewSelectHdl
, void*, EMPTYARG
)
464 sal_uInt32 nLightNumber
= m_aCtl_Preview
.GetSvx3DLightControl().GetSelectedLight();
467 LightButton
* pButton
= m_pLightSourceInfoList
[nLightNumber
].pButton
;
468 if(!pButton
->IsChecked())
469 ClickLightSourceButtonHdl(pButton
);
471 applyLightSourcesToModel();
476 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, ColorDialogHdl
, Button
*, pButton
)
478 bool bIsAmbientLight
= (pButton
==&m_aBtn_AmbientLight_Color
);
479 ColorLB
* pListBox
= ( bIsAmbientLight
? &m_aLB_AmbientLight
: &m_aLB_LightSource
);
481 SvColorDialog
aColorDlg( this );
482 aColorDlg
.SetColor( pListBox
->GetSelectEntryColor() );
483 if( aColorDlg
.Execute() == RET_OK
)
485 Color
aColor( aColorDlg
.GetColor());
486 lcl_selectColor( *pListBox
, aColor
);
487 if( bIsAmbientLight
)
489 m_bInCommitToModel
= true;
490 lcl_setAmbientColor( m_xSceneProperties
, aColor
);
491 m_bInCommitToModel
= false;
495 //get active lightsource:
496 LightSourceInfo
* pInfo
= 0;
498 for( nL
=0; nL
<8; nL
++)
500 pInfo
= &m_pLightSourceInfoList
[nL
];
501 if(pInfo
->pButton
->IsChecked())
506 applyLightSourceToModel( nL
);
508 SelectColorHdl( pListBox
);
513 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, SelectColorHdl
, ColorLB
*, pListBox
)
515 if(pListBox
==&m_aLB_AmbientLight
)
517 m_bInCommitToModel
= true;
518 lcl_setAmbientColor( m_xSceneProperties
, pListBox
->GetSelectEntryColor().GetColor());
519 m_bInCommitToModel
= false;
521 else if(pListBox
==&m_aLB_LightSource
)
523 //get active lightsource:
524 LightSourceInfo
* pInfo
= 0;
526 for( nL
=0; nL
<8; nL
++)
528 pInfo
= &m_pLightSourceInfoList
[nL
];
529 if(pInfo
->pButton
->IsChecked())
535 pInfo
->aLightSource
.nDiffuseColor
= pListBox
->GetSelectEntryColor().GetColor();
536 applyLightSourceToModel( nL
);
539 this->updatePreview();
543 IMPL_LINK( ThreeD_SceneIllumination_TabPage
, ClickLightSourceButtonHdl
, LightButton
*, pButton
)
548 LightSourceInfo
* pInfo
= 0;
550 for( nL
=0; nL
<8; nL
++)
552 if( m_pLightSourceInfoList
[nL
].pButton
== pButton
)
554 pInfo
= &m_pLightSourceInfoList
[nL
];
559 //update light button
560 bool bIsChecked
= pButton
->IsChecked();
563 pButton
->switchLightOn(!pButton
->isLightOn());
566 pInfo
->aLightSource
.bIsEnabled
=pButton
->isLightOn();
567 applyLightSourceToModel( nL
);
572 ControllerLockGuard
aGuard( m_xChartModel
);
573 for( nL
=0; nL
<8; nL
++)
575 LightButton
* pLightButton
= m_pLightSourceInfoList
[nL
].pButton
;
576 pLightButton
->Check( pLightButton
== pButton
);
580 //update color list box
583 lcl_selectColor( m_aLB_LightSource
, pInfo
->aLightSource
.nDiffuseColor
);
585 this->updatePreview();
589 void ThreeD_SceneIllumination_TabPage::updatePreview()
591 SfxItemSet
aItemSet(m_aCtl_Preview
.GetSvx3DLightControl().Get3DAttributes());
592 LightSourceInfo
* pInfo
= &m_pLightSourceInfoList
[0];
595 aItemSet
.Put(Svx3DAmbientcolorItem(m_aLB_AmbientLight
.GetSelectEntryColor()));
597 aItemSet
.Put(Svx3DLightcolor1Item(pInfo
->aLightSource
.nDiffuseColor
));
598 aItemSet
.Put(Svx3DLightOnOff1Item(pInfo
->aLightSource
.bIsEnabled
));
599 aItemSet
.Put(Svx3DLightDirection1Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
601 pInfo
= &m_pLightSourceInfoList
[1];
602 aItemSet
.Put(Svx3DLightcolor2Item(pInfo
->aLightSource
.nDiffuseColor
));
603 aItemSet
.Put(Svx3DLightOnOff2Item(pInfo
->aLightSource
.bIsEnabled
));
604 aItemSet
.Put(Svx3DLightDirection2Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
606 pInfo
= &m_pLightSourceInfoList
[2];
607 aItemSet
.Put(Svx3DLightcolor3Item(pInfo
->aLightSource
.nDiffuseColor
));
608 aItemSet
.Put(Svx3DLightOnOff3Item(pInfo
->aLightSource
.bIsEnabled
));
609 aItemSet
.Put(Svx3DLightDirection3Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
611 pInfo
= &m_pLightSourceInfoList
[3];
612 aItemSet
.Put(Svx3DLightcolor4Item(pInfo
->aLightSource
.nDiffuseColor
));
613 aItemSet
.Put(Svx3DLightOnOff4Item(pInfo
->aLightSource
.bIsEnabled
));
614 aItemSet
.Put(Svx3DLightDirection4Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
616 pInfo
= &m_pLightSourceInfoList
[4];
617 aItemSet
.Put(Svx3DLightcolor5Item(pInfo
->aLightSource
.nDiffuseColor
));
618 aItemSet
.Put(Svx3DLightOnOff5Item(pInfo
->aLightSource
.bIsEnabled
));
619 aItemSet
.Put(Svx3DLightDirection5Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
621 pInfo
= &m_pLightSourceInfoList
[5];
622 aItemSet
.Put(Svx3DLightcolor6Item(pInfo
->aLightSource
.nDiffuseColor
));
623 aItemSet
.Put(Svx3DLightOnOff6Item(pInfo
->aLightSource
.bIsEnabled
));
624 aItemSet
.Put(Svx3DLightDirection6Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
626 pInfo
= &m_pLightSourceInfoList
[6];
627 aItemSet
.Put(Svx3DLightcolor7Item(pInfo
->aLightSource
.nDiffuseColor
));
628 aItemSet
.Put(Svx3DLightOnOff7Item(pInfo
->aLightSource
.bIsEnabled
));
629 aItemSet
.Put(Svx3DLightDirection7Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
631 pInfo
= &m_pLightSourceInfoList
[7];
632 aItemSet
.Put(Svx3DLightcolor8Item(pInfo
->aLightSource
.nDiffuseColor
));
633 aItemSet
.Put(Svx3DLightOnOff8Item(pInfo
->aLightSource
.bIsEnabled
));
634 aItemSet
.Put(Svx3DLightDirection8Item(Direction3DToB3DVector(pInfo
->aLightSource
.aDirection
)));
636 // set lights and ambient light
637 m_aCtl_Preview
.GetSvx3DLightControl().Set3DAttributes(aItemSet
);
640 for(sal_uInt32
a(0); a
< 8; a
++)
642 if(m_pLightSourceInfoList
[a
].pButton
->IsChecked())
644 m_aCtl_Preview
.GetSvx3DLightControl().SelectLight(a
);
645 m_aCtl_Preview
.CheckSelection();
651 //.............................................................................
653 //.............................................................................