xref: /AOO41X/main/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_chart2.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "tp_3D_SceneIllumination.hxx"
32*cdf0e10cSrcweir #include "tp_3D_SceneIllumination.hrc"
33*cdf0e10cSrcweir #include "ResId.hxx"
34*cdf0e10cSrcweir #include "Strings.hrc"
35*cdf0e10cSrcweir #include "Bitmaps.hrc"
36*cdf0e10cSrcweir #include "Bitmaps_HC.hrc"
37*cdf0e10cSrcweir #include "CommonConverters.hxx"
38*cdf0e10cSrcweir #include "NoWarningThisInCTOR.hxx"
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #ifndef _SVX_DIALOGS_HRC
41*cdf0e10cSrcweir #include "svx/dialogs.hrc"
42*cdf0e10cSrcweir #endif
43*cdf0e10cSrcweir // header for define SVX_RES
44*cdf0e10cSrcweir #include <svx/dialmgr.hxx>
45*cdf0e10cSrcweir #include <rtl/math.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir // header for class SvColorDialog
48*cdf0e10cSrcweir #include <svtools/colrdlg.hxx>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir // header for define RET_OK
51*cdf0e10cSrcweir #include <vcl/msgbox.hxx>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #include <svx/svx3ditems.hxx>
54*cdf0e10cSrcweir #include <svx/svddef.hxx>
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir //.............................................................................
57*cdf0e10cSrcweir namespace chart
58*cdf0e10cSrcweir {
59*cdf0e10cSrcweir //.............................................................................
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir using namespace ::com::sun::star;
62*cdf0e10cSrcweir using namespace ::com::sun::star::chart2;
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir LightButton::LightButton( Window* pParent, const ResId& rResId, sal_Int32 nLightNumber )
65*cdf0e10cSrcweir             : ImageButton( pParent, rResId )
66*cdf0e10cSrcweir             , m_bLightOn(false)
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir     SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF)   ), BMP_COLOR_NORMAL );
69*cdf0e10cSrcweir     SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF_H) ), BMP_COLOR_HIGHCONTRAST );
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir     String aTipHelpStr( SchResId(STR_TIP_LIGHTSOURCE_X) );
72*cdf0e10cSrcweir     rtl::OUString aTipHelp( aTipHelpStr  );
73*cdf0e10cSrcweir     const rtl::OUString aReplacementStr( RTL_CONSTASCII_USTRINGPARAM( "%LIGHTNUMBER" ));
74*cdf0e10cSrcweir     sal_Int32 nIndex = aTipHelp.indexOf( aReplacementStr );
75*cdf0e10cSrcweir     if( nIndex != -1 )
76*cdf0e10cSrcweir     {
77*cdf0e10cSrcweir         aTipHelp = aTipHelp.replaceAt(nIndex, aReplacementStr.getLength(),
78*cdf0e10cSrcweir             rtl::OUString::valueOf( nLightNumber ) );
79*cdf0e10cSrcweir     }
80*cdf0e10cSrcweir     this->SetQuickHelpText( String( aTipHelp ) );
81*cdf0e10cSrcweir }
82*cdf0e10cSrcweir LightButton::~LightButton()
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir }
85*cdf0e10cSrcweir void LightButton::switchLightOn(bool bOn)
86*cdf0e10cSrcweir {
87*cdf0e10cSrcweir     if( m_bLightOn==bOn )
88*cdf0e10cSrcweir         return;
89*cdf0e10cSrcweir     m_bLightOn = bOn;
90*cdf0e10cSrcweir     if(m_bLightOn)
91*cdf0e10cSrcweir     {
92*cdf0e10cSrcweir         SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON)   ), BMP_COLOR_NORMAL );
93*cdf0e10cSrcweir         SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON_H) ), BMP_COLOR_HIGHCONTRAST );
94*cdf0e10cSrcweir     }
95*cdf0e10cSrcweir     else
96*cdf0e10cSrcweir     {
97*cdf0e10cSrcweir         SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF)   ), BMP_COLOR_NORMAL );
98*cdf0e10cSrcweir         SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF_H) ), BMP_COLOR_HIGHCONTRAST );
99*cdf0e10cSrcweir     }
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir bool LightButton::isLightOn() const
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir     return m_bLightOn;
104*cdf0e10cSrcweir }
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir //-----------------------------------------------------------------------------
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir ColorButton::ColorButton( Window* pParent, const ResId& rResId )
109*cdf0e10cSrcweir             : ImageButton( pParent, rResId )
110*cdf0e10cSrcweir {
111*cdf0e10cSrcweir     SetModeImage( Image( SVX_RES(RID_SVXIMAGE_COLORDLG)   ), BMP_COLOR_NORMAL );
112*cdf0e10cSrcweir     SetModeImage( Image( SVX_RES(RID_SVXIMAGE_COLORDLG_H) ), BMP_COLOR_HIGHCONTRAST );
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     this->SetQuickHelpText( String( SchResId(STR_TIP_CHOOSECOLOR) ) );
115*cdf0e10cSrcweir }
116*cdf0e10cSrcweir ColorButton::~ColorButton()
117*cdf0e10cSrcweir {
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir //-----------------------------------------------------------------------------
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir struct LightSource
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir     long nDiffuseColor;
125*cdf0e10cSrcweir     ::com::sun::star::drawing::Direction3D aDirection;
126*cdf0e10cSrcweir     bool bIsEnabled;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     LightSource() :
129*cdf0e10cSrcweir             nDiffuseColor( 0xcccccc ),
130*cdf0e10cSrcweir             aDirection( 1.0, 1.0, -1.0 ),
131*cdf0e10cSrcweir             bIsEnabled( false )
132*cdf0e10cSrcweir     {}
133*cdf0e10cSrcweir };
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir struct LightSourceInfo
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir     LightButton* pButton;
138*cdf0e10cSrcweir     LightSource  aLightSource;
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     LightSourceInfo();
141*cdf0e10cSrcweir     void initButtonFromSource();
142*cdf0e10cSrcweir };
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir LightSourceInfo::LightSourceInfo()
145*cdf0e10cSrcweir     : pButton(0)
146*cdf0e10cSrcweir     , aLightSource()
147*cdf0e10cSrcweir {
148*cdf0e10cSrcweir     aLightSource.nDiffuseColor = 0xffffff; // white
149*cdf0e10cSrcweir     aLightSource.aDirection = drawing::Direction3D(1,1,1);
150*cdf0e10cSrcweir     aLightSource.bIsEnabled = sal_False;
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir void LightSourceInfo::initButtonFromSource()
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir     if(!pButton)
155*cdf0e10cSrcweir         return;
156*cdf0e10cSrcweir     pButton->SetModeImage( Image( SVX_RES( aLightSource.bIsEnabled ? RID_SVXIMAGE_LIGHT_ON : RID_SVXIMAGE_LIGHT_OFF )   ), BMP_COLOR_NORMAL );
157*cdf0e10cSrcweir     pButton->SetModeImage( Image( SVX_RES( aLightSource.bIsEnabled ? RID_SVXIMAGE_LIGHT_ON_H : RID_SVXIMAGE_LIGHT_OFF_H ) ), BMP_COLOR_HIGHCONTRAST );
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir //-----------------------------------------------------------------------------
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir namespace
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir     rtl::OUString lcl_makeColorName( Color rColor )
165*cdf0e10cSrcweir     {
166*cdf0e10cSrcweir 		String aStr(SVX_RES(RID_SVXFLOAT3D_FIX_R));
167*cdf0e10cSrcweir 		aStr += String::CreateFromInt32((sal_Int32)rColor.GetRed());
168*cdf0e10cSrcweir 		aStr += sal_Unicode(' ');
169*cdf0e10cSrcweir 		aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_G));
170*cdf0e10cSrcweir 		aStr += String::CreateFromInt32((sal_Int32)rColor.GetGreen());
171*cdf0e10cSrcweir 		aStr += sal_Unicode(' ');
172*cdf0e10cSrcweir 		aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_B));
173*cdf0e10cSrcweir 		aStr += String::CreateFromInt32((sal_Int32)rColor.GetBlue());
174*cdf0e10cSrcweir         return aStr;
175*cdf0e10cSrcweir     }
176*cdf0e10cSrcweir     void lcl_selectColor( ColorListBox& rListBox, const Color& rColor )
177*cdf0e10cSrcweir     {
178*cdf0e10cSrcweir         rListBox.SetNoSelection();
179*cdf0e10cSrcweir         rListBox.SelectEntry( rColor );
180*cdf0e10cSrcweir         if( rListBox.GetSelectEntryCount() == 0 )
181*cdf0e10cSrcweir         {
182*cdf0e10cSrcweir             sal_uInt16 nPos = rListBox.InsertEntry( rColor, lcl_makeColorName( rColor ) );
183*cdf0e10cSrcweir 		    rListBox.SelectEntryPos( nPos );
184*cdf0e10cSrcweir         }
185*cdf0e10cSrcweir     }
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     ::chart::LightSource lcl_getLightSourceFromProperties(
188*cdf0e10cSrcweir         const uno::Reference< beans::XPropertySet > & xSceneProperties,
189*cdf0e10cSrcweir         sal_Int32 nIndex )
190*cdf0e10cSrcweir     {
191*cdf0e10cSrcweir         ::chart::LightSource aResult;
192*cdf0e10cSrcweir         if( 0 <= nIndex && nIndex < 8 )
193*cdf0e10cSrcweir         {
194*cdf0e10cSrcweir             ::rtl::OUString aColorPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor"));
195*cdf0e10cSrcweir             ::rtl::OUString aDirectionPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection"));
196*cdf0e10cSrcweir             ::rtl::OUString aEnabledPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn"));
197*cdf0e10cSrcweir             ::rtl::OUString aIndex( ::rtl::OUString::valueOf( nIndex + 1 ));
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir             try
200*cdf0e10cSrcweir             {
201*cdf0e10cSrcweir                 xSceneProperties->getPropertyValue( aColorPropertyPrefix + aIndex ) >>= aResult.nDiffuseColor;
202*cdf0e10cSrcweir                 xSceneProperties->getPropertyValue( aDirectionPropertyPrefix + aIndex ) >>= aResult.aDirection;
203*cdf0e10cSrcweir                 xSceneProperties->getPropertyValue( aEnabledPropertyPrefix + aIndex ) >>= aResult.bIsEnabled;
204*cdf0e10cSrcweir             }
205*cdf0e10cSrcweir             catch( const uno::Exception & ex )
206*cdf0e10cSrcweir             {
207*cdf0e10cSrcweir                 (void)(ex); // no warning in non-debug builds
208*cdf0e10cSrcweir                 OSL_ENSURE( false, ::rtl::OUStringToOString(
209*cdf0e10cSrcweir                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
210*cdf0e10cSrcweir                                 ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
211*cdf0e10cSrcweir             }
212*cdf0e10cSrcweir         }
213*cdf0e10cSrcweir         return aResult;
214*cdf0e10cSrcweir     }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     void lcl_setLightSource(
217*cdf0e10cSrcweir         const uno::Reference< beans::XPropertySet > & xSceneProperties,
218*cdf0e10cSrcweir         const ::chart::LightSource & rLightSource,
219*cdf0e10cSrcweir         sal_Int32 nIndex )
220*cdf0e10cSrcweir     {
221*cdf0e10cSrcweir         if( 0 <= nIndex && nIndex < 8 )
222*cdf0e10cSrcweir         {
223*cdf0e10cSrcweir             ::rtl::OUString aColorPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor"));
224*cdf0e10cSrcweir             ::rtl::OUString aDirectionPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection"));
225*cdf0e10cSrcweir             ::rtl::OUString aEnabledPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn"));
226*cdf0e10cSrcweir             ::rtl::OUString aIndex( ::rtl::OUString::valueOf( nIndex + 1 ));
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir             try
229*cdf0e10cSrcweir             {
230*cdf0e10cSrcweir                 xSceneProperties->setPropertyValue( aColorPropertyPrefix + aIndex,
231*cdf0e10cSrcweir                                                     uno::makeAny( rLightSource.nDiffuseColor ));
232*cdf0e10cSrcweir                 xSceneProperties->setPropertyValue( aDirectionPropertyPrefix + aIndex,
233*cdf0e10cSrcweir                                                     uno::makeAny( rLightSource.aDirection ));
234*cdf0e10cSrcweir                 xSceneProperties->setPropertyValue( aEnabledPropertyPrefix + aIndex,
235*cdf0e10cSrcweir                                                     uno::makeAny( rLightSource.bIsEnabled ));
236*cdf0e10cSrcweir             }
237*cdf0e10cSrcweir             catch( const uno::Exception & ex )
238*cdf0e10cSrcweir             {
239*cdf0e10cSrcweir                 (void)(ex); // no warning in non-debug builds
240*cdf0e10cSrcweir                 OSL_ENSURE( false, ::rtl::OUStringToOString(
241*cdf0e10cSrcweir                                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
242*cdf0e10cSrcweir                                 ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
243*cdf0e10cSrcweir             }
244*cdf0e10cSrcweir         }
245*cdf0e10cSrcweir     }
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir     Color lcl_getAmbientColor(
248*cdf0e10cSrcweir         const uno::Reference< beans::XPropertySet > & xSceneProperties )
249*cdf0e10cSrcweir     {
250*cdf0e10cSrcweir         sal_Int32 nResult = 0x000000;
251*cdf0e10cSrcweir         try
252*cdf0e10cSrcweir         {
253*cdf0e10cSrcweir             xSceneProperties->getPropertyValue(
254*cdf0e10cSrcweir                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor"))) >>= nResult;
255*cdf0e10cSrcweir         }
256*cdf0e10cSrcweir         catch( const uno::Exception & ex )
257*cdf0e10cSrcweir         {
258*cdf0e10cSrcweir             (void)(ex); // no warning in non-debug builds
259*cdf0e10cSrcweir             OSL_ENSURE( false, ::rtl::OUStringToOString(
260*cdf0e10cSrcweir                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
261*cdf0e10cSrcweir                             ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
262*cdf0e10cSrcweir         }
263*cdf0e10cSrcweir         return Color( nResult );
264*cdf0e10cSrcweir     }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir     void lcl_setAmbientColor(
267*cdf0e10cSrcweir         const uno::Reference< beans::XPropertySet > & xSceneProperties,
268*cdf0e10cSrcweir         const Color & rColor )
269*cdf0e10cSrcweir     {
270*cdf0e10cSrcweir         try
271*cdf0e10cSrcweir         {
272*cdf0e10cSrcweir             xSceneProperties->setPropertyValue(
273*cdf0e10cSrcweir                 ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor")),
274*cdf0e10cSrcweir                 uno::makeAny( rColor.GetColor()));
275*cdf0e10cSrcweir         }
276*cdf0e10cSrcweir         catch( const uno::Exception & ex )
277*cdf0e10cSrcweir         {
278*cdf0e10cSrcweir             (void)(ex); // no warning in non-debug builds
279*cdf0e10cSrcweir             OSL_ENSURE( false, ::rtl::OUStringToOString(
280*cdf0e10cSrcweir                             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) +
281*cdf0e10cSrcweir                             ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
282*cdf0e10cSrcweir         }
283*cdf0e10cSrcweir     }
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir //-----------------------------------------------------------------------------
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( Window* pWindow
289*cdf0e10cSrcweir                 , const uno::Reference< beans::XPropertySet > & xSceneProperties
290*cdf0e10cSrcweir                 , const uno::Reference< frame::XModel >& xChartModel
291*cdf0e10cSrcweir                 , XColorTable* pColorTable )
292*cdf0e10cSrcweir                 : TabPage 	        ( pWindow, SchResId( TP_3D_SCENEILLUMINATION ) )
293*cdf0e10cSrcweir                 , m_aFT_LightSource( this, SchResId( FT_LIGHTSOURCE ) )
294*cdf0e10cSrcweir                 , m_aBtn_Light1( this, SchResId( BTN_LIGHT_1 ), 1 )
295*cdf0e10cSrcweir                 , m_aBtn_Light2( this, SchResId( BTN_LIGHT_2 ), 2 )
296*cdf0e10cSrcweir                 , m_aBtn_Light3( this, SchResId( BTN_LIGHT_3 ), 3 )
297*cdf0e10cSrcweir                 , m_aBtn_Light4( this, SchResId( BTN_LIGHT_4 ), 4 )
298*cdf0e10cSrcweir                 , m_aBtn_Light5( this, SchResId( BTN_LIGHT_5 ), 5 )
299*cdf0e10cSrcweir                 , m_aBtn_Light6( this, SchResId( BTN_LIGHT_6 ), 6 )
300*cdf0e10cSrcweir                 , m_aBtn_Light7( this, SchResId( BTN_LIGHT_7 ), 7 )
301*cdf0e10cSrcweir                 , m_aBtn_Light8( this, SchResId( BTN_LIGHT_8 ), 8 )
302*cdf0e10cSrcweir                 , m_aLB_LightSource( this, SchResId( LB_LIGHTSOURCE ) )
303*cdf0e10cSrcweir                 , m_aBtn_LightSource_Color( this, SchResId( BTN_LIGHTSOURCE_COLOR ) )
304*cdf0e10cSrcweir                 , m_aFT_AmbientLight( this, SchResId( FT_AMBIENTLIGHT ) )
305*cdf0e10cSrcweir                 , m_aLB_AmbientLight( this, SchResId( LB_AMBIENTLIGHT ) )
306*cdf0e10cSrcweir                 , m_aBtn_AmbientLight_Color( this, SchResId( BTN_AMBIENT_COLOR ) )
307*cdf0e10cSrcweir                 , m_aCtl_Preview( this, SchResId( CTL_LIGHT_PREVIEW ) )
308*cdf0e10cSrcweir                 , m_pLightSourceInfoList(0)
309*cdf0e10cSrcweir                 , m_xSceneProperties( xSceneProperties )
310*cdf0e10cSrcweir                 , m_aTimerTriggeredControllerLock( xChartModel )
311*cdf0e10cSrcweir                 , m_bInCommitToModel( false )
312*cdf0e10cSrcweir                 , m_aModelChangeListener( LINK( this, ThreeD_SceneIllumination_TabPage, fillControlsFromModel ) )
313*cdf0e10cSrcweir                 , m_xChartModel( xChartModel )
314*cdf0e10cSrcweir {
315*cdf0e10cSrcweir 	FreeResource();
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir     if(pColorTable)
318*cdf0e10cSrcweir     {
319*cdf0e10cSrcweir         m_aLB_AmbientLight.Fill( pColorTable );
320*cdf0e10cSrcweir         m_aLB_LightSource.Fill( pColorTable );
321*cdf0e10cSrcweir     }
322*cdf0e10cSrcweir     m_aLB_AmbientLight.SetDropDownLineCount(10);
323*cdf0e10cSrcweir     m_aLB_LightSource.SetDropDownLineCount(10);
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir     m_pLightSourceInfoList = new LightSourceInfo[8];
326*cdf0e10cSrcweir     m_pLightSourceInfoList[0].pButton = &m_aBtn_Light1;
327*cdf0e10cSrcweir     m_pLightSourceInfoList[1].pButton = &m_aBtn_Light2;
328*cdf0e10cSrcweir     m_pLightSourceInfoList[2].pButton = &m_aBtn_Light3;
329*cdf0e10cSrcweir     m_pLightSourceInfoList[3].pButton = &m_aBtn_Light4;
330*cdf0e10cSrcweir     m_pLightSourceInfoList[4].pButton = &m_aBtn_Light5;
331*cdf0e10cSrcweir     m_pLightSourceInfoList[5].pButton = &m_aBtn_Light6;
332*cdf0e10cSrcweir     m_pLightSourceInfoList[6].pButton = &m_aBtn_Light7;
333*cdf0e10cSrcweir     m_pLightSourceInfoList[7].pButton = &m_aBtn_Light8;
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     fillControlsFromModel(0);
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir     m_aBtn_Light1.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
338*cdf0e10cSrcweir     m_aBtn_Light2.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
339*cdf0e10cSrcweir     m_aBtn_Light3.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
340*cdf0e10cSrcweir     m_aBtn_Light4.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
341*cdf0e10cSrcweir     m_aBtn_Light5.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
342*cdf0e10cSrcweir     m_aBtn_Light6.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
343*cdf0e10cSrcweir     m_aBtn_Light7.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
344*cdf0e10cSrcweir     m_aBtn_Light8.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir     m_aLB_AmbientLight.SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) );
347*cdf0e10cSrcweir     m_aLB_LightSource.SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) );
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir     m_aBtn_AmbientLight_Color.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) );
350*cdf0e10cSrcweir     m_aBtn_LightSource_Color.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) );
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     m_aCtl_Preview.SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewChangeHdl ) );
353*cdf0e10cSrcweir 	m_aCtl_Preview.SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewSelectHdl ) );
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir     ClickLightSourceButtonHdl(&m_aBtn_Light2);
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir     //m_aDelyedModelChangeTimer.SetTimeout( 4*EDIT_UPDATEDATA_TIMEOUT );
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir     m_aModelChangeListener.startListening( uno::Reference< util::XModifyBroadcaster >(m_xSceneProperties, uno::UNO_QUERY) );
360*cdf0e10cSrcweir 	m_aBtn_Light1.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
361*cdf0e10cSrcweir     m_aBtn_Light2.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
362*cdf0e10cSrcweir     m_aBtn_Light3.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
363*cdf0e10cSrcweir     m_aBtn_Light4.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
364*cdf0e10cSrcweir     m_aBtn_Light5.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
365*cdf0e10cSrcweir     m_aBtn_Light6.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
366*cdf0e10cSrcweir     m_aBtn_Light7.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
367*cdf0e10cSrcweir     m_aBtn_Light8.SetAccessibleRelationLabeledBy(&m_aFT_LightSource);
368*cdf0e10cSrcweir 	m_aCtl_Preview.SetAccessibleName(String(SchResId( STR_LIGHT_PREVIEW )));
369*cdf0e10cSrcweir }
370*cdf0e10cSrcweir 
371*cdf0e10cSrcweir ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage()
372*cdf0e10cSrcweir {
373*cdf0e10cSrcweir     delete[] m_pLightSourceInfoList;
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir void ThreeD_SceneIllumination_TabPage::commitPendingChanges()
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir }
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir IMPL_LINK( ThreeD_SceneIllumination_TabPage, fillControlsFromModel, void *, EMPTYARG )
381*cdf0e10cSrcweir {
382*cdf0e10cSrcweir     if( m_bInCommitToModel )//don't read own changes
383*cdf0e10cSrcweir         return 0;
384*cdf0e10cSrcweir 
385*cdf0e10cSrcweir     sal_Int32 nL=0;
386*cdf0e10cSrcweir     for( nL=0; nL<8; nL++)
387*cdf0e10cSrcweir         m_pLightSourceInfoList[nL].aLightSource = lcl_getLightSourceFromProperties( m_xSceneProperties, nL );
388*cdf0e10cSrcweir     for( nL=0; nL<8; nL++)
389*cdf0e10cSrcweir         m_pLightSourceInfoList[nL].initButtonFromSource();
390*cdf0e10cSrcweir 
391*cdf0e10cSrcweir     lcl_selectColor( m_aLB_AmbientLight, lcl_getAmbientColor( m_xSceneProperties ));
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir     this->updatePreview();
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir     return 0;
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( sal_uInt32 nLightNumber )
399*cdf0e10cSrcweir {
400*cdf0e10cSrcweir     ControllerLockGuard aGuard( m_xChartModel );
401*cdf0e10cSrcweir 	m_bInCommitToModel = true;
402*cdf0e10cSrcweir     sal_Int32 nIndex( nLightNumber );
403*cdf0e10cSrcweir     lcl_setLightSource( m_xSceneProperties, m_pLightSourceInfoList[nIndex].aLightSource, nIndex );
404*cdf0e10cSrcweir     m_bInCommitToModel = false;
405*cdf0e10cSrcweir }
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir void ThreeD_SceneIllumination_TabPage::applyLightSourcesToModel()
408*cdf0e10cSrcweir {
409*cdf0e10cSrcweir     m_aTimerTriggeredControllerLock.startTimer();
410*cdf0e10cSrcweir     ControllerLockGuard aGuard( m_xChartModel );
411*cdf0e10cSrcweir     for( sal_Int32 nL=0; nL<8; nL++)
412*cdf0e10cSrcweir         applyLightSourceToModel( nL );
413*cdf0e10cSrcweir     m_aTimerTriggeredControllerLock.startTimer();
414*cdf0e10cSrcweir }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir IMPL_LINK( ThreeD_SceneIllumination_TabPage, PreviewChangeHdl, void*, EMPTYARG )
417*cdf0e10cSrcweir {
418*cdf0e10cSrcweir     m_aTimerTriggeredControllerLock.startTimer();
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir     //update m_pLightSourceInfoList from preview
421*cdf0e10cSrcweir 	const SfxItemSet a3DLightAttributes(m_aCtl_Preview.GetSvx3DLightControl().Get3DAttributes());
422*cdf0e10cSrcweir     LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
423*cdf0e10cSrcweir 
424*cdf0e10cSrcweir     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().GetColor();
425*cdf0e10cSrcweir     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue();
426*cdf0e10cSrcweir     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue());
427*cdf0e10cSrcweir 
428*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[1];
429*cdf0e10cSrcweir     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().GetColor();
430*cdf0e10cSrcweir     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue();
431*cdf0e10cSrcweir     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue());
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[2];
434*cdf0e10cSrcweir     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().GetColor();
435*cdf0e10cSrcweir     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue();
436*cdf0e10cSrcweir     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue());
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[3];
439*cdf0e10cSrcweir     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().GetColor();
440*cdf0e10cSrcweir     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue();
441*cdf0e10cSrcweir     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue());
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[4];
444*cdf0e10cSrcweir     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().GetColor();
445*cdf0e10cSrcweir     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue();
446*cdf0e10cSrcweir     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue());
447*cdf0e10cSrcweir 
448*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[5];
449*cdf0e10cSrcweir     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().GetColor();
450*cdf0e10cSrcweir     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue();
451*cdf0e10cSrcweir     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue());
452*cdf0e10cSrcweir 
453*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[6];
454*cdf0e10cSrcweir     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().GetColor();
455*cdf0e10cSrcweir     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue();
456*cdf0e10cSrcweir     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue());
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[7];
459*cdf0e10cSrcweir     pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().GetColor();
460*cdf0e10cSrcweir     pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue();
461*cdf0e10cSrcweir     pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue());
462*cdf0e10cSrcweir 
463*cdf0e10cSrcweir     applyLightSourcesToModel();
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir     return 0;
466*cdf0e10cSrcweir }
467*cdf0e10cSrcweir 
468*cdf0e10cSrcweir IMPL_LINK( ThreeD_SceneIllumination_TabPage, PreviewSelectHdl, void*, EMPTYARG )
469*cdf0e10cSrcweir {
470*cdf0e10cSrcweir     sal_uInt32 nLightNumber = m_aCtl_Preview.GetSvx3DLightControl().GetSelectedLight();
471*cdf0e10cSrcweir     if(nLightNumber<8)
472*cdf0e10cSrcweir     {
473*cdf0e10cSrcweir         LightButton* pButton = m_pLightSourceInfoList[nLightNumber].pButton;
474*cdf0e10cSrcweir         if(!pButton->IsChecked())
475*cdf0e10cSrcweir             ClickLightSourceButtonHdl(pButton);
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir         applyLightSourcesToModel();
478*cdf0e10cSrcweir     }
479*cdf0e10cSrcweir     return 0;
480*cdf0e10cSrcweir }
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton )
483*cdf0e10cSrcweir {
484*cdf0e10cSrcweir     bool bIsAmbientLight = (pButton==&m_aBtn_AmbientLight_Color);
485*cdf0e10cSrcweir     ColorLB* pListBox = ( bIsAmbientLight ? &m_aLB_AmbientLight : &m_aLB_LightSource);
486*cdf0e10cSrcweir 
487*cdf0e10cSrcweir     SvColorDialog aColorDlg( this );
488*cdf0e10cSrcweir     aColorDlg.SetColor( pListBox->GetSelectEntryColor() );
489*cdf0e10cSrcweir 	if( aColorDlg.Execute() == RET_OK )
490*cdf0e10cSrcweir 	{
491*cdf0e10cSrcweir         Color aColor( aColorDlg.GetColor());
492*cdf0e10cSrcweir         lcl_selectColor( *pListBox, aColor );
493*cdf0e10cSrcweir         if( bIsAmbientLight )
494*cdf0e10cSrcweir         {
495*cdf0e10cSrcweir             m_bInCommitToModel = true;
496*cdf0e10cSrcweir             lcl_setAmbientColor( m_xSceneProperties, aColor );
497*cdf0e10cSrcweir             m_bInCommitToModel = false;
498*cdf0e10cSrcweir         }
499*cdf0e10cSrcweir         else
500*cdf0e10cSrcweir         {
501*cdf0e10cSrcweir         //get active lightsource:
502*cdf0e10cSrcweir             LightSourceInfo* pInfo = 0;
503*cdf0e10cSrcweir             sal_Int32 nL=0;
504*cdf0e10cSrcweir             for( nL=0; nL<8; nL++)
505*cdf0e10cSrcweir             {
506*cdf0e10cSrcweir                 pInfo = &m_pLightSourceInfoList[nL];
507*cdf0e10cSrcweir                 if(pInfo->pButton->IsChecked())
508*cdf0e10cSrcweir                     break;
509*cdf0e10cSrcweir                 pInfo = 0;
510*cdf0e10cSrcweir             }
511*cdf0e10cSrcweir             if(pInfo)
512*cdf0e10cSrcweir                 applyLightSourceToModel( nL );
513*cdf0e10cSrcweir         }
514*cdf0e10cSrcweir         SelectColorHdl( pListBox );
515*cdf0e10cSrcweir 	}
516*cdf0e10cSrcweir     return 0;
517*cdf0e10cSrcweir }
518*cdf0e10cSrcweir 
519*cdf0e10cSrcweir IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, ColorLB*, pListBox )
520*cdf0e10cSrcweir {
521*cdf0e10cSrcweir     if(pListBox==&m_aLB_AmbientLight)
522*cdf0e10cSrcweir     {
523*cdf0e10cSrcweir         m_bInCommitToModel = true;
524*cdf0e10cSrcweir         lcl_setAmbientColor( m_xSceneProperties, pListBox->GetSelectEntryColor().GetColor());
525*cdf0e10cSrcweir         m_bInCommitToModel = false;
526*cdf0e10cSrcweir     }
527*cdf0e10cSrcweir     else if(pListBox==&m_aLB_LightSource)
528*cdf0e10cSrcweir     {
529*cdf0e10cSrcweir         //get active lightsource:
530*cdf0e10cSrcweir         LightSourceInfo* pInfo = 0;
531*cdf0e10cSrcweir         sal_Int32 nL=0;
532*cdf0e10cSrcweir         for( nL=0; nL<8; nL++)
533*cdf0e10cSrcweir         {
534*cdf0e10cSrcweir             pInfo = &m_pLightSourceInfoList[nL];
535*cdf0e10cSrcweir             if(pInfo->pButton->IsChecked())
536*cdf0e10cSrcweir                 break;
537*cdf0e10cSrcweir             pInfo = 0;
538*cdf0e10cSrcweir         }
539*cdf0e10cSrcweir         if(pInfo)
540*cdf0e10cSrcweir         {
541*cdf0e10cSrcweir             pInfo->aLightSource.nDiffuseColor = pListBox->GetSelectEntryColor().GetColor();
542*cdf0e10cSrcweir             applyLightSourceToModel( nL );
543*cdf0e10cSrcweir         }
544*cdf0e10cSrcweir     }
545*cdf0e10cSrcweir     this->updatePreview();
546*cdf0e10cSrcweir     return 0;
547*cdf0e10cSrcweir }
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir IMPL_LINK( ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl, LightButton*, pButton )
550*cdf0e10cSrcweir {
551*cdf0e10cSrcweir     if( !pButton )
552*cdf0e10cSrcweir         return 0;
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir     LightSourceInfo* pInfo = 0;
555*cdf0e10cSrcweir     sal_Int32 nL=0;
556*cdf0e10cSrcweir     for( nL=0; nL<8; nL++)
557*cdf0e10cSrcweir     {
558*cdf0e10cSrcweir         if( m_pLightSourceInfoList[nL].pButton == pButton )
559*cdf0e10cSrcweir         {
560*cdf0e10cSrcweir             pInfo = &m_pLightSourceInfoList[nL];
561*cdf0e10cSrcweir             break;
562*cdf0e10cSrcweir         }
563*cdf0e10cSrcweir     }
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir     //update light button
566*cdf0e10cSrcweir     bool bIsChecked = pButton->IsChecked();
567*cdf0e10cSrcweir     if(bIsChecked)
568*cdf0e10cSrcweir     {
569*cdf0e10cSrcweir         pButton->switchLightOn(!pButton->isLightOn());
570*cdf0e10cSrcweir         if(pInfo)
571*cdf0e10cSrcweir         {
572*cdf0e10cSrcweir             pInfo->aLightSource.bIsEnabled=pButton->isLightOn();
573*cdf0e10cSrcweir             applyLightSourceToModel( nL );
574*cdf0e10cSrcweir         }
575*cdf0e10cSrcweir     }
576*cdf0e10cSrcweir     else
577*cdf0e10cSrcweir     {
578*cdf0e10cSrcweir         ControllerLockGuard aGuard( m_xChartModel );
579*cdf0e10cSrcweir         for( nL=0; nL<8; nL++)
580*cdf0e10cSrcweir         {
581*cdf0e10cSrcweir             LightButton* pLightButton = m_pLightSourceInfoList[nL].pButton;
582*cdf0e10cSrcweir             pLightButton->Check( pLightButton == pButton );
583*cdf0e10cSrcweir         }
584*cdf0e10cSrcweir     }
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir     //update color list box
587*cdf0e10cSrcweir     if(pInfo)
588*cdf0e10cSrcweir     {
589*cdf0e10cSrcweir         lcl_selectColor( m_aLB_LightSource, pInfo->aLightSource.nDiffuseColor );
590*cdf0e10cSrcweir     }
591*cdf0e10cSrcweir     this->updatePreview();
592*cdf0e10cSrcweir     return 0;
593*cdf0e10cSrcweir }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir void ThreeD_SceneIllumination_TabPage::updatePreview()
596*cdf0e10cSrcweir {
597*cdf0e10cSrcweir     SfxItemSet aItemSet(m_aCtl_Preview.GetSvx3DLightControl().Get3DAttributes());
598*cdf0e10cSrcweir     LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir 	// AmbientColor
601*cdf0e10cSrcweir 	aItemSet.Put(Svx3DAmbientcolorItem(m_aLB_AmbientLight.GetSelectEntryColor()));
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightcolor1Item(pInfo->aLightSource.nDiffuseColor));
604*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightOnOff1Item(pInfo->aLightSource.bIsEnabled));
605*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightDirection1Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
606*cdf0e10cSrcweir 
607*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[1];
608*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightcolor2Item(pInfo->aLightSource.nDiffuseColor));
609*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightOnOff2Item(pInfo->aLightSource.bIsEnabled));
610*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightDirection2Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[2];
613*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightcolor3Item(pInfo->aLightSource.nDiffuseColor));
614*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightOnOff3Item(pInfo->aLightSource.bIsEnabled));
615*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightDirection3Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
616*cdf0e10cSrcweir 
617*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[3];
618*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightcolor4Item(pInfo->aLightSource.nDiffuseColor));
619*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightOnOff4Item(pInfo->aLightSource.bIsEnabled));
620*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightDirection4Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[4];
623*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightcolor5Item(pInfo->aLightSource.nDiffuseColor));
624*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightOnOff5Item(pInfo->aLightSource.bIsEnabled));
625*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightDirection5Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[5];
628*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightcolor6Item(pInfo->aLightSource.nDiffuseColor));
629*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightOnOff6Item(pInfo->aLightSource.bIsEnabled));
630*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightDirection6Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
631*cdf0e10cSrcweir 
632*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[6];
633*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightcolor7Item(pInfo->aLightSource.nDiffuseColor));
634*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightOnOff7Item(pInfo->aLightSource.bIsEnabled));
635*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightDirection7Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir     pInfo = &m_pLightSourceInfoList[7];
638*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightcolor8Item(pInfo->aLightSource.nDiffuseColor));
639*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightOnOff8Item(pInfo->aLightSource.bIsEnabled));
640*cdf0e10cSrcweir 	aItemSet.Put(Svx3DLightDirection8Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir     // set lights and ambient light
643*cdf0e10cSrcweir     m_aCtl_Preview.GetSvx3DLightControl().Set3DAttributes(aItemSet);
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir     // select light
646*cdf0e10cSrcweir     for(sal_uInt32 a(0); a < 8; a++)
647*cdf0e10cSrcweir     {
648*cdf0e10cSrcweir         if(m_pLightSourceInfoList[a].pButton->IsChecked())
649*cdf0e10cSrcweir         {
650*cdf0e10cSrcweir             m_aCtl_Preview.GetSvx3DLightControl().SelectLight(a);
651*cdf0e10cSrcweir             m_aCtl_Preview.CheckSelection();
652*cdf0e10cSrcweir             break;
653*cdf0e10cSrcweir         }
654*cdf0e10cSrcweir     }
655*cdf0e10cSrcweir }
656*cdf0e10cSrcweir 
657*cdf0e10cSrcweir //.............................................................................
658*cdf0e10cSrcweir } //namespace chart
659*cdf0e10cSrcweir //.............................................................................
660