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