27#include <svx/strings.hrc>
37#include <com/sun/star/beans/XPropertySet.hpp>
88 OUString lcl_makeColorName(
const Color& rColor)
91 OUString::number(rColor.
GetRed()) +
94 OUString::number(rColor.
GetGreen()) +
97 OUString::number(rColor.
GetBlue());
104 rListBox.
SelectEntry({rColor, lcl_makeColorName(rColor)});
107 ::chart::LightSource lcl_getLightSourceFromProperties(
108 const uno::Reference< beans::XPropertySet > & xSceneProperties,
111 ::chart::LightSource aResult;
112 if( 0 <= nIndex && nIndex < 8 )
114 OUString
aIndex( OUString::number( nIndex + 1 ));
118 xSceneProperties->getPropertyValue(
"D3DSceneLightColor" + aIndex ) >>= aResult.nDiffuseColor;
119 xSceneProperties->getPropertyValue(
"D3DSceneLightDirection" + aIndex ) >>= aResult.aDirection;
120 xSceneProperties->getPropertyValue(
"D3DSceneLightOn" + aIndex ) >>= aResult.bIsEnabled;
122 catch(
const uno::Exception & )
130 void lcl_setLightSource(
131 const uno::Reference< beans::XPropertySet > & xSceneProperties,
132 const ::chart::LightSource & rLightSource,
135 if( 0 > nIndex || nIndex >= 8 )
138 OUString
aIndex( OUString::number( nIndex + 1 ));
142 xSceneProperties->setPropertyValue(
"D3DSceneLightColor" + aIndex,
143 uno::Any( rLightSource.nDiffuseColor ));
144 xSceneProperties->setPropertyValue(
"D3DSceneLightDirection" + aIndex,
145 uno::Any( rLightSource.aDirection ));
146 xSceneProperties->setPropertyValue(
"D3DSceneLightOn" + aIndex,
147 uno::Any( rLightSource.bIsEnabled ));
149 catch(
const uno::Exception & )
155 Color lcl_getAmbientColor(
156 const uno::Reference< beans::XPropertySet > & xSceneProperties )
161 xSceneProperties->getPropertyValue(
"D3DSceneAmbientColor") >>= nResult;
163 catch(
const uno::Exception & )
170 void lcl_setAmbientColor(
171 const uno::Reference< beans::XPropertySet > & xSceneProperties,
172 const Color & rColor )
176 xSceneProperties->setPropertyValue(
"D3DSceneAmbientColor",
179 catch(
const uno::Exception & )
190 : m_xSceneProperties(
std::move( xSceneProperties ))
191 , m_aTimerTriggeredControllerLock( xChartModel )
192 , m_bInCommitToModel( false )
194 , m_xChartModel( xChartModel )
195 , m_pTopLevel(pTopLevel)
196 , m_xBuilder(
Application::CreateBuilder(pParent,
"modules/schart/ui/tp_3D_SceneIllumination.ui"))
197 ,
m_xContainer(m_xBuilder->weld_container(
"tp_3D_SceneIllumination"))
198 , m_aBtn_Light1(m_xBuilder->weld_toggle_button(
"BTN_LIGHT_1"))
199 , m_aBtn_Light2(m_xBuilder->weld_toggle_button(
"BTN_LIGHT_2"))
200 , m_aBtn_Light3(m_xBuilder->weld_toggle_button(
"BTN_LIGHT_3"))
201 , m_aBtn_Light4(m_xBuilder->weld_toggle_button(
"BTN_LIGHT_4"))
202 , m_aBtn_Light5(m_xBuilder->weld_toggle_button(
"BTN_LIGHT_5"))
203 , m_aBtn_Light6(m_xBuilder->weld_toggle_button(
"BTN_LIGHT_6"))
204 , m_aBtn_Light7(m_xBuilder->weld_toggle_button(
"BTN_LIGHT_7"))
205 , m_aBtn_Light8(m_xBuilder->weld_toggle_button(
"BTN_LIGHT_8"))
206 , m_xLB_LightSource(new
ColorListBox(m_xBuilder->weld_menu_button(
"LB_LIGHTSOURCE"), [this]{
return m_pTopLevel; }))
207 , m_xBtn_LightSource_Color(m_xBuilder->weld_button(
"BTN_LIGHTSOURCE_COLOR"))
208 , m_xLB_AmbientLight(
new ColorListBox(m_xBuilder->weld_menu_button(
"LB_AMBIENTLIGHT"), [
this]{ return m_pTopLevel; }))
209 , m_xBtn_AmbientLight_Color(m_xBuilder->weld_button(
"BTN_AMBIENT_COLOR"))
210 , m_xHoriScale(m_xBuilder->weld_scale(
"hori"))
211 , m_xVertScale(m_xBuilder->weld_scale(
"vert"))
212 , m_xBtn_Corner(m_xBuilder->weld_button(
"corner"))
214 , m_xPreviewWnd(
new weld::CustomWeld(*m_xBuilder,
"CTL_LIGHT_PREVIEW", *m_xPreview))
215 , m_xCtl_Preview(
new SvxLightCtl3D(*m_xPreview, *m_xHoriScale, *m_xVertScale, *m_xBtn_Corner))
218 m_pLightSourceInfoList[0].pButton = &m_aBtn_Light1;
219 m_pLightSourceInfoList[1].pButton = &m_aBtn_Light2;
220 m_pLightSourceInfoList[2].pButton = &m_aBtn_Light3;
221 m_pLightSourceInfoList[3].pButton = &m_aBtn_Light4;
222 m_pLightSourceInfoList[4].pButton = &m_aBtn_Light5;
223 m_pLightSourceInfoList[5].pButton = &m_aBtn_Light6;
224 m_pLightSourceInfoList[6].pButton = &m_aBtn_Light7;
225 m_pLightSourceInfoList[7].pButton = &m_aBtn_Light8;
227 fillControlsFromModel(
nullptr);
247 ClickLightSourceButtonHdl(*m_aBtn_Light2.get_widget());
258 if( m_bInCommitToModel )
262 for( nL=0; nL<8; nL++)
263 m_pLightSourceInfoList[nL].aLightSource = lcl_getLightSourceFromProperties( m_xSceneProperties, nL );
264 for( nL=0; nL<8; nL++)
265 m_pLightSourceInfoList[nL].initButtonFromSource();
267 lcl_selectColor( *m_xLB_AmbientLight, lcl_getAmbientColor( m_xSceneProperties ));
276 sal_Int32
nIndex( nLightNumber );
285 for( sal_Int32 nL=0; nL<8; nL++)
292 m_aTimerTriggeredControllerLock.startTimer();
295 const SfxItemSet a3DLightAttributes(m_xCtl_Preview->GetSvx3DLightControl().Get3DAttributes());
302 pInfo = &m_pLightSourceInfoList[1];
307 pInfo = &m_pLightSourceInfoList[2];
312 pInfo = &m_pLightSourceInfoList[3];
317 pInfo = &m_pLightSourceInfoList[4];
322 pInfo = &m_pLightSourceInfoList[5];
327 pInfo = &m_pLightSourceInfoList[6];
332 pInfo = &m_pLightSourceInfoList[7];
337 applyLightSourcesToModel();
342 sal_uInt32 nLightNumber = m_xCtl_Preview->GetSvx3DLightControl().GetSelectedLight();
345 LightButton* pButton = m_pLightSourceInfoList[nLightNumber].pButton;
347 ClickLightSourceButtonHdl(*pButton->
get_widget());
349 applyLightSourcesToModel();
355 bool bIsAmbientLight = (&rButton == m_xBtn_AmbientLight_Color.get());
356 ColorListBox* pListBox = bIsAmbientLight ? m_xLB_AmbientLight.get() : m_xLB_LightSource.get();
364 lcl_selectColor( *pListBox, aColor );
365 if( bIsAmbientLight )
367 m_bInCommitToModel =
true;
368 lcl_setAmbientColor( m_xSceneProperties, aColor );
369 m_bInCommitToModel =
false;
376 for( nL=0; nL<8; nL++)
378 pInfo = &m_pLightSourceInfoList[nL];
384 applyLightSourceToModel( nL );
386 SelectColorHdl( *pListBox );
392 if (pListBox == m_xLB_AmbientLight.get())
394 m_bInCommitToModel =
true;
396 m_bInCommitToModel =
false;
398 else if (pListBox == m_xLB_LightSource.get())
403 for( nL=0; nL<8; nL++)
405 pInfo = &m_pLightSourceInfoList[nL];
413 applyLightSourceToModel( nL );
424 for( nL=0; nL<8; nL++)
426 if (m_pLightSourceInfoList[nL].pButton->
get_widget() == &rBtn)
428 pButton = m_pLightSourceInfoList[nL].pButton;
429 pInfo = &m_pLightSourceInfoList[nL];
439 for (sal_Int32
i = 0;
i < 8; ++
i)
441 LightButton* pLightButton = m_pLightSourceInfoList[
i].pButton;
442 if (pLightButton == pButton)
447 m_pLightSourceInfoList[
i].pButton->set_prev_active(
true);
452 m_pLightSourceInfoList[
i].pButton->set_prev_active(
false);
461 applyLightSourceToModel( nL );
465 lcl_selectColor( *m_xLB_LightSource, pInfo->
aLightSource.nDiffuseColor );
520 for(sal_uInt32
a(0);
a < 8;
a++)
Color const & GetSelectEntryColor() const
void SelectEntry(const NamedColor &rColor)
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
const Color & GetColor() const
short Execute(weld::Window *pParent)
void SetColor(const Color &rColor)
This guard calls lockControllers at the given Model in the CTOR and unlockControllers in the DTOR.
void applyLightSourceToModel(sal_uInt32 nLightNumber)
rtl::Reference<::chart::ChartModel > m_xChartModel
css::uno::Reference< css::beans::XPropertySet > m_xSceneProperties
ThreeD_SceneIllumination_TabPage(weld::Container *pParent, weld::Window *pTopLevel, css::uno::Reference< css::beans::XPropertySet > xSceneProperties, const rtl::Reference<::chart::ChartModel > &xChartModel)
TimerTriggeredControllerLock m_aTimerTriggeredControllerLock
std::unique_ptr< LightSourceInfo[]> m_pLightSourceInfoList
void applyLightSourcesToModel()
std::unique_ptr< ColorListBox > m_xLB_AmbientLight
std::unique_ptr< SvxLightCtl3D > m_xCtl_Preview
weld::Window * m_pTopLevel
~ThreeD_SceneIllumination_TabPage()
#define DBG_UNHANDLED_EXCEPTION(...)
SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId)
std::deque< AttacherIndex_Impl > aIndex
#define LINK(Instance, Class, Member)
OOO_DLLPUBLIC_CHARTTOOLS::basegfx::B3DVector Direction3DToB3DVector(const css::drawing::Direction3D &rDirection)
Direction3D -> B3DVector.
OOO_DLLPUBLIC_CHARTTOOLS css::drawing::Direction3D B3DVectorToDirection3D(const ::basegfx::B3DVector &rVector)
B3DVector -> Direction3D.
IMPL_LINK(StackingResourceGroup, StackingChangeHdl, weld::Toggleable &, rRadio, void)
IMPL_LINK_NOARG(SplinePropertiesDialog, SplineTypeListBoxHdl, weld::ComboBox &, void)
Reference< XNameAccess > m_xContainer
void initButtonFromSource()
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DSCENE_LIGHTON_8(SDRATTR_3DSCENE_FIRST+20)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DSCENE_LIGHTON_4(SDRATTR_3DSCENE_FIRST+16)
constexpr TypedWhichId< SvxB3DVectorItem > SDRATTR_3DSCENE_LIGHTDIRECTION_1(SDRATTR_3DSCENE_FIRST+21)
constexpr TypedWhichId< SvxB3DVectorItem > SDRATTR_3DSCENE_LIGHTDIRECTION_3(SDRATTR_3DSCENE_FIRST+23)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DSCENE_LIGHTON_1(SDRATTR_3DSCENE_FIRST+13)
constexpr TypedWhichId< SvxB3DVectorItem > SDRATTR_3DSCENE_LIGHTDIRECTION_2(SDRATTR_3DSCENE_FIRST+22)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DSCENE_LIGHTCOLOR_1(SDRATTR_3DSCENE_FIRST+4)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DSCENE_LIGHTON_3(SDRATTR_3DSCENE_FIRST+15)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DSCENE_LIGHTCOLOR_5(SDRATTR_3DSCENE_FIRST+8)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DSCENE_LIGHTON_5(SDRATTR_3DSCENE_FIRST+17)
constexpr TypedWhichId< SvxB3DVectorItem > SDRATTR_3DSCENE_LIGHTDIRECTION_7(SDRATTR_3DSCENE_FIRST+27)
constexpr TypedWhichId< SvxB3DVectorItem > SDRATTR_3DSCENE_LIGHTDIRECTION_6(SDRATTR_3DSCENE_FIRST+26)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DSCENE_LIGHTCOLOR_6(SDRATTR_3DSCENE_FIRST+9)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DSCENE_LIGHTCOLOR_4(SDRATTR_3DSCENE_FIRST+7)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DSCENE_LIGHTCOLOR_7(SDRATTR_3DSCENE_FIRST+10)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DSCENE_LIGHTON_6(SDRATTR_3DSCENE_FIRST+18)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DSCENE_LIGHTON_2(SDRATTR_3DSCENE_FIRST+14)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DSCENE_LIGHTCOLOR_8(SDRATTR_3DSCENE_FIRST+11)
constexpr TypedWhichId< SvxB3DVectorItem > SDRATTR_3DSCENE_LIGHTDIRECTION_8(SDRATTR_3DSCENE_FIRST+28)
constexpr TypedWhichId< SvxB3DVectorItem > SDRATTR_3DSCENE_LIGHTDIRECTION_4(SDRATTR_3DSCENE_FIRST+24)
constexpr TypedWhichId< SvxB3DVectorItem > SDRATTR_3DSCENE_LIGHTDIRECTION_5(SDRATTR_3DSCENE_FIRST+25)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DSCENE_LIGHTCOLOR_2(SDRATTR_3DSCENE_FIRST+5)
constexpr TypedWhichId< SvxColorItem > SDRATTR_3DSCENE_LIGHTCOLOR_3(SDRATTR_3DSCENE_FIRST+6)
constexpr TypedWhichId< SfxBoolItem > SDRATTR_3DSCENE_LIGHTON_7(SDRATTR_3DSCENE_FIRST+19)
SvxB3DVectorItem makeSvx3DLightDirection6Item(const basegfx::B3DVector &rVec)
SfxBoolItem makeSvx3DLightOnOff2Item(bool bVal)
SvxColorItem makeSvx3DLightcolor1Item(const Color &rCol)
SvxColorItem makeSvx3DLightcolor8Item(const Color &rCol)
SfxBoolItem makeSvx3DLightOnOff5Item(bool bVal)
SvxB3DVectorItem makeSvx3DLightDirection3Item(const basegfx::B3DVector &rVec)
SvxColorItem makeSvx3DLightcolor2Item(const Color &rCol)
SvxColorItem makeSvx3DLightcolor6Item(const Color &rCol)
SvxB3DVectorItem makeSvx3DLightDirection5Item(const basegfx::B3DVector &rVec)
SvxB3DVectorItem makeSvx3DLightDirection8Item(const basegfx::B3DVector &rVec)
SvxColorItem makeSvx3DLightcolor5Item(const Color &rCol)
SvxColorItem makeSvx3DAmbientcolorItem(const Color &rCol)
SfxBoolItem makeSvx3DLightOnOff7Item(bool bVal)
SvxB3DVectorItem makeSvx3DLightDirection4Item(const basegfx::B3DVector &rVec)
SfxBoolItem makeSvx3DLightOnOff1Item(bool bVal)
SvxColorItem makeSvx3DLightcolor3Item(const Color &rCol)
SfxBoolItem makeSvx3DLightOnOff3Item(bool bVal)
SvxColorItem makeSvx3DLightcolor4Item(const Color &rCol)
SvxB3DVectorItem makeSvx3DLightDirection1Item(const basegfx::B3DVector &rVec)
SfxBoolItem makeSvx3DLightOnOff4Item(bool bVal)
SfxBoolItem makeSvx3DLightOnOff8Item(bool bVal)
SvxB3DVectorItem makeSvx3DLightDirection2Item(const basegfx::B3DVector &rVec)
SfxBoolItem makeSvx3DLightOnOff6Item(bool bVal)
SvxB3DVectorItem makeSvx3DLightDirection7Item(const basegfx::B3DVector &rVec)
SvxColorItem makeSvx3DLightcolor7Item(const Color &rCol)
css::drawing::Direction3D aDirection