2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2007-05-22 16:42:51 +00:00
|
|
|
|
|
|
|
#include "tp_3D_SceneIllumination.hxx"
|
|
|
|
#include "ResId.hxx"
|
2017-04-25 15:35:10 +01:00
|
|
|
#include "bitmaps.hlst"
|
2007-05-22 16:42:51 +00:00
|
|
|
#include "CommonConverters.hxx"
|
|
|
|
|
2016-11-05 20:28:27 +00:00
|
|
|
#include <svx/colorbox.hxx>
|
2007-05-22 16:42:51 +00:00
|
|
|
#include "svx/dialogs.hrc"
|
|
|
|
#include <svx/dialmgr.hxx>
|
|
|
|
#include <rtl/math.hxx>
|
|
|
|
#include <svtools/colrdlg.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
2008-10-17 08:40:10 +00:00
|
|
|
#include <svx/svx3ditems.hxx>
|
|
|
|
#include <svx/svddef.hxx>
|
2015-05-09 16:46:56 +01:00
|
|
|
#include <vcl/builderfactory.hxx>
|
2008-10-17 08:40:10 +00:00
|
|
|
|
2007-05-22 16:42:51 +00:00
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::chart2;
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
LightButton::LightButton( vcl::Window* pParent)
|
2013-12-08 19:33:42 -02:00
|
|
|
: ImageButton( pParent)
|
2007-05-22 16:42:51 +00:00
|
|
|
, m_bLightOn(false)
|
|
|
|
{
|
2017-01-19 11:29:11 +00:00
|
|
|
SetModeImage(Image(BitmapEx(SVX_RES(RID_SVXBMP_LAMP_OFF))));
|
2013-12-08 19:33:42 -02:00
|
|
|
}
|
2007-05-22 16:42:51 +00:00
|
|
|
|
2015-05-09 16:46:56 +01:00
|
|
|
VCL_BUILDER_FACTORY(LightButton)
|
2010-11-13 00:32:23 -08:00
|
|
|
|
2007-05-22 16:42:51 +00:00
|
|
|
void LightButton::switchLightOn(bool bOn)
|
|
|
|
{
|
|
|
|
if( m_bLightOn==bOn )
|
|
|
|
return;
|
|
|
|
m_bLightOn = bOn;
|
|
|
|
if(m_bLightOn)
|
|
|
|
{
|
2017-01-19 11:29:11 +00:00
|
|
|
SetModeImage(Image(BitmapEx(SVX_RES(RID_SVXBMP_LAMP_ON))));
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-19 11:29:11 +00:00
|
|
|
SetModeImage(Image(BitmapEx(SVX_RES(RID_SVXBMP_LAMP_OFF))));
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-13 00:32:23 -08:00
|
|
|
|
2007-05-22 16:42:51 +00:00
|
|
|
struct LightSource
|
|
|
|
{
|
|
|
|
long nDiffuseColor;
|
2015-11-27 11:14:38 +02:00
|
|
|
css::drawing::Direction3D aDirection;
|
2007-05-22 16:42:51 +00:00
|
|
|
bool bIsEnabled;
|
|
|
|
|
|
|
|
LightSource() :
|
|
|
|
nDiffuseColor( 0xcccccc ),
|
|
|
|
aDirection( 1.0, 1.0, -1.0 ),
|
|
|
|
bIsEnabled( false )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LightSourceInfo
|
|
|
|
{
|
2015-03-09 14:29:30 +02:00
|
|
|
VclPtr<LightButton> pButton;
|
2007-05-22 16:42:51 +00:00
|
|
|
LightSource aLightSource;
|
|
|
|
|
|
|
|
LightSourceInfo();
|
|
|
|
void initButtonFromSource();
|
|
|
|
};
|
|
|
|
|
|
|
|
LightSourceInfo::LightSourceInfo()
|
2015-11-10 10:11:17 +01:00
|
|
|
: pButton(nullptr)
|
2007-05-22 16:42:51 +00:00
|
|
|
, aLightSource()
|
|
|
|
{
|
|
|
|
aLightSource.nDiffuseColor = 0xffffff; // white
|
|
|
|
aLightSource.aDirection = drawing::Direction3D(1,1,1);
|
2014-01-28 20:02:54 +01:00
|
|
|
aLightSource.bIsEnabled = false;
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
2010-11-13 00:32:23 -08:00
|
|
|
|
2007-05-22 16:42:51 +00:00
|
|
|
void LightSourceInfo::initButtonFromSource()
|
|
|
|
{
|
|
|
|
if(!pButton)
|
|
|
|
return;
|
2017-01-19 11:29:11 +00:00
|
|
|
pButton->SetModeImage(Image(BitmapEx(SVX_RES(
|
|
|
|
aLightSource.bIsEnabled ? RID_SVXBMP_LAMP_ON : RID_SVXBMP_LAMP_OFF
|
|
|
|
) ) ));
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2016-11-05 20:28:27 +00:00
|
|
|
OUString lcl_makeColorName(const Color& rColor)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
2013-01-05 12:13:57 -02:00
|
|
|
OUString aStr = SVX_RESSTR(RID_SVXFLOAT3D_FIX_R) +
|
2013-08-21 15:07:31 +02:00
|
|
|
OUString::number(rColor.GetRed()) +
|
2013-01-05 12:13:57 -02:00
|
|
|
" " +
|
|
|
|
SVX_RESSTR(RID_SVXFLOAT3D_FIX_G) +
|
2013-08-21 15:07:31 +02:00
|
|
|
OUString::number(rColor.GetGreen()) +
|
2013-01-05 12:13:57 -02:00
|
|
|
" " +
|
|
|
|
SVX_RESSTR(RID_SVXFLOAT3D_FIX_B) +
|
2013-08-21 15:07:31 +02:00
|
|
|
OUString::number(rColor.GetBlue());
|
2013-01-05 12:13:57 -02:00
|
|
|
return aStr;
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
2016-11-05 20:28:27 +00:00
|
|
|
|
|
|
|
void lcl_selectColor(SvxColorListBox& rListBox, const Color& rColor)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
|
|
|
rListBox.SetNoSelection();
|
2016-11-05 20:28:27 +00:00
|
|
|
rListBox.SelectEntry(std::make_pair(rColor, lcl_makeColorName(rColor)));
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
::chart::LightSource lcl_getLightSourceFromProperties(
|
|
|
|
const uno::Reference< beans::XPropertySet > & xSceneProperties,
|
|
|
|
sal_Int32 nIndex )
|
|
|
|
{
|
|
|
|
::chart::LightSource aResult;
|
|
|
|
if( 0 <= nIndex && nIndex < 8 )
|
|
|
|
{
|
2013-08-21 15:07:31 +02:00
|
|
|
OUString aIndex( OUString::number( nIndex + 1 ));
|
2007-05-22 16:42:51 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2015-11-06 09:23:33 +02:00
|
|
|
xSceneProperties->getPropertyValue( "D3DSceneLightColor" + aIndex ) >>= aResult.nDiffuseColor;
|
|
|
|
xSceneProperties->getPropertyValue( "D3DSceneLightDirection" + aIndex ) >>= aResult.aDirection;
|
|
|
|
xSceneProperties->getPropertyValue( "D3DSceneLightOn" + aIndex ) >>= aResult.bIsEnabled;
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
catch( const uno::Exception & ex )
|
|
|
|
{
|
2007-07-25 07:35:57 +00:00
|
|
|
(void)(ex); // no warning in non-debug builds
|
2014-12-18 13:21:05 +01:00
|
|
|
OSL_FAIL( OUStringToOString("Property Exception caught. Message: " +
|
2013-01-05 13:01:09 -02:00
|
|
|
ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return aResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcl_setLightSource(
|
|
|
|
const uno::Reference< beans::XPropertySet > & xSceneProperties,
|
|
|
|
const ::chart::LightSource & rLightSource,
|
|
|
|
sal_Int32 nIndex )
|
|
|
|
{
|
|
|
|
if( 0 <= nIndex && nIndex < 8 )
|
|
|
|
{
|
2013-08-21 15:07:31 +02:00
|
|
|
OUString aIndex( OUString::number( nIndex + 1 ));
|
2007-05-22 16:42:51 +00:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2015-11-06 09:23:33 +02:00
|
|
|
xSceneProperties->setPropertyValue( "D3DSceneLightColor" + aIndex,
|
2017-02-03 08:54:47 +02:00
|
|
|
uno::Any( rLightSource.nDiffuseColor ));
|
2015-11-06 09:23:33 +02:00
|
|
|
xSceneProperties->setPropertyValue( "D3DSceneLightDirection" + aIndex,
|
2017-02-03 08:54:47 +02:00
|
|
|
uno::Any( rLightSource.aDirection ));
|
2015-11-06 09:23:33 +02:00
|
|
|
xSceneProperties->setPropertyValue( "D3DSceneLightOn" + aIndex,
|
2017-02-03 08:54:47 +02:00
|
|
|
uno::Any( rLightSource.bIsEnabled ));
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
catch( const uno::Exception & ex )
|
|
|
|
{
|
2007-07-25 07:35:57 +00:00
|
|
|
(void)(ex); // no warning in non-debug builds
|
2014-12-18 13:21:05 +01:00
|
|
|
OSL_FAIL( OUStringToOString("Property Exception caught. Message: " +
|
2013-01-05 13:01:09 -02:00
|
|
|
ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Color lcl_getAmbientColor(
|
|
|
|
const uno::Reference< beans::XPropertySet > & xSceneProperties )
|
|
|
|
{
|
|
|
|
sal_Int32 nResult = 0x000000;
|
|
|
|
try
|
|
|
|
{
|
2013-06-29 21:24:12 +02:00
|
|
|
xSceneProperties->getPropertyValue("D3DSceneAmbientColor") >>= nResult;
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
catch( const uno::Exception & ex )
|
|
|
|
{
|
2007-07-25 07:35:57 +00:00
|
|
|
(void)(ex); // no warning in non-debug builds
|
2014-12-18 13:21:05 +01:00
|
|
|
OSL_FAIL( OUStringToOString("Property Exception caught. Message: " +
|
2013-01-05 13:01:09 -02:00
|
|
|
ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
return Color( nResult );
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcl_setAmbientColor(
|
|
|
|
const uno::Reference< beans::XPropertySet > & xSceneProperties,
|
|
|
|
const Color & rColor )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2013-06-29 21:24:12 +02:00
|
|
|
xSceneProperties->setPropertyValue("D3DSceneAmbientColor",
|
2017-02-03 08:54:47 +02:00
|
|
|
uno::Any( rColor.GetColor()));
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
catch( const uno::Exception & ex )
|
|
|
|
{
|
2007-07-25 07:35:57 +00:00
|
|
|
(void)(ex); // no warning in non-debug builds
|
2014-12-18 13:21:05 +01:00
|
|
|
OSL_FAIL( OUStringToOString( "Property Exception caught. Message: " +
|
2013-01-05 13:01:09 -02:00
|
|
|
ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( vcl::Window* pWindow
|
2007-05-22 16:42:51 +00:00
|
|
|
, const uno::Reference< beans::XPropertySet > & xSceneProperties
|
2016-11-05 20:28:27 +00:00
|
|
|
, const uno::Reference< frame::XModel >& xChartModel )
|
2013-12-08 19:33:42 -02:00
|
|
|
: TabPage ( pWindow
|
|
|
|
,"tp_3D_SceneIllumination"
|
|
|
|
,"modules/schart/ui/tp_3D_SceneIllumination.ui")
|
2015-11-10 10:11:17 +01:00
|
|
|
, m_pLightSourceInfoList(nullptr)
|
2007-05-22 16:42:51 +00:00
|
|
|
, m_xSceneProperties( xSceneProperties )
|
|
|
|
, m_aTimerTriggeredControllerLock( xChartModel )
|
|
|
|
, m_bInCommitToModel( false )
|
|
|
|
, m_xChartModel( xChartModel )
|
|
|
|
{
|
2013-12-08 19:33:42 -02:00
|
|
|
get(m_pBtn_Light1, "BTN_LIGHT_1");
|
|
|
|
get(m_pBtn_Light2, "BTN_LIGHT_2");
|
|
|
|
get(m_pBtn_Light3, "BTN_LIGHT_3");
|
|
|
|
get(m_pBtn_Light4, "BTN_LIGHT_4");
|
|
|
|
get(m_pBtn_Light5, "BTN_LIGHT_5");
|
|
|
|
get(m_pBtn_Light6, "BTN_LIGHT_6");
|
|
|
|
get(m_pBtn_Light7, "BTN_LIGHT_7");
|
|
|
|
get(m_pBtn_Light8, "BTN_LIGHT_8");
|
|
|
|
|
|
|
|
get(m_pLB_LightSource, "LB_LIGHTSOURCE");
|
|
|
|
get(m_pLB_AmbientLight, "LB_AMBIENTLIGHT");
|
|
|
|
get(m_pBtn_LightSource_Color, "BTN_LIGHTSOURCE_COLOR");
|
|
|
|
get(m_pBtn_AmbientLight_Color, "BTN_AMBIENT_COLOR");
|
|
|
|
|
|
|
|
get(m_pCtl_Preview, "CTL_LIGHT_PREVIEW");
|
2007-05-22 16:42:51 +00:00
|
|
|
|
|
|
|
m_pLightSourceInfoList = new LightSourceInfo[8];
|
2013-12-08 19:33:42 -02:00
|
|
|
m_pLightSourceInfoList[0].pButton = m_pBtn_Light1;
|
|
|
|
m_pLightSourceInfoList[1].pButton = m_pBtn_Light2;
|
|
|
|
m_pLightSourceInfoList[2].pButton = m_pBtn_Light3;
|
|
|
|
m_pLightSourceInfoList[3].pButton = m_pBtn_Light4;
|
|
|
|
m_pLightSourceInfoList[4].pButton = m_pBtn_Light5;
|
|
|
|
m_pLightSourceInfoList[5].pButton = m_pBtn_Light6;
|
|
|
|
m_pLightSourceInfoList[6].pButton = m_pBtn_Light7;
|
|
|
|
m_pLightSourceInfoList[7].pButton = m_pBtn_Light8;
|
2007-05-22 16:42:51 +00:00
|
|
|
|
2015-11-10 10:11:17 +01:00
|
|
|
fillControlsFromModel(nullptr);
|
2007-05-22 16:42:51 +00:00
|
|
|
|
2013-12-08 19:33:42 -02:00
|
|
|
m_pBtn_Light1->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
|
|
|
|
m_pBtn_Light2->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
|
|
|
|
m_pBtn_Light3->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
|
|
|
|
m_pBtn_Light4->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
|
|
|
|
m_pBtn_Light5->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
|
|
|
|
m_pBtn_Light6->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
|
|
|
|
m_pBtn_Light7->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
|
|
|
|
m_pBtn_Light8->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) );
|
|
|
|
|
|
|
|
m_pLB_AmbientLight->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) );
|
|
|
|
m_pLB_LightSource->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) );
|
|
|
|
|
|
|
|
m_pBtn_AmbientLight_Color->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) );
|
|
|
|
m_pBtn_LightSource_Color->SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) );
|
|
|
|
|
|
|
|
m_pCtl_Preview->SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewChangeHdl ) );
|
|
|
|
m_pCtl_Preview->SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewSelectHdl ) );
|
|
|
|
|
|
|
|
ClickLightSourceButtonHdl(m_pBtn_Light2);
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage()
|
2015-01-14 16:16:32 +02:00
|
|
|
{
|
2015-03-10 09:07:06 +02:00
|
|
|
disposeOnce();
|
2015-01-14 16:16:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ThreeD_SceneIllumination_TabPage::dispose()
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
|
|
|
delete[] m_pLightSourceInfoList;
|
2015-11-10 10:11:17 +01:00
|
|
|
m_pLightSourceInfoList = nullptr;
|
2015-03-09 14:29:30 +02:00
|
|
|
m_pBtn_Light1.clear();
|
|
|
|
m_pBtn_Light2.clear();
|
|
|
|
m_pBtn_Light3.clear();
|
|
|
|
m_pBtn_Light4.clear();
|
|
|
|
m_pBtn_Light5.clear();
|
|
|
|
m_pBtn_Light6.clear();
|
|
|
|
m_pBtn_Light7.clear();
|
|
|
|
m_pBtn_Light8.clear();
|
|
|
|
m_pLB_LightSource.clear();
|
|
|
|
m_pBtn_LightSource_Color.clear();
|
|
|
|
m_pLB_AmbientLight.clear();
|
|
|
|
m_pBtn_AmbientLight_Color.clear();
|
|
|
|
m_pCtl_Preview.clear();
|
2015-01-14 16:16:32 +02:00
|
|
|
TabPage::dispose();
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, fillControlsFromModel, void*, void)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
|
|
|
if( m_bInCommitToModel )//don't read own changes
|
2015-06-28 18:15:45 +02:00
|
|
|
return;
|
2007-05-22 16:42:51 +00:00
|
|
|
|
|
|
|
sal_Int32 nL=0;
|
|
|
|
for( nL=0; nL<8; nL++)
|
|
|
|
m_pLightSourceInfoList[nL].aLightSource = lcl_getLightSourceFromProperties( m_xSceneProperties, nL );
|
|
|
|
for( nL=0; nL<8; nL++)
|
|
|
|
m_pLightSourceInfoList[nL].initButtonFromSource();
|
|
|
|
|
2013-12-08 19:33:42 -02:00
|
|
|
lcl_selectColor( *m_pLB_AmbientLight, lcl_getAmbientColor( m_xSceneProperties ));
|
2007-05-22 16:42:51 +00:00
|
|
|
|
|
|
|
this->updatePreview();
|
|
|
|
}
|
|
|
|
|
2008-10-17 08:40:10 +00:00
|
|
|
void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( sal_uInt32 nLightNumber )
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
2013-10-15 07:55:26 +02:00
|
|
|
ControllerLockGuardUNO aGuard( m_xChartModel );
|
2007-05-22 16:42:51 +00:00
|
|
|
m_bInCommitToModel = true;
|
|
|
|
sal_Int32 nIndex( nLightNumber );
|
|
|
|
lcl_setLightSource( m_xSceneProperties, m_pLightSourceInfoList[nIndex].aLightSource, nIndex );
|
|
|
|
m_bInCommitToModel = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThreeD_SceneIllumination_TabPage::applyLightSourcesToModel()
|
|
|
|
{
|
|
|
|
m_aTimerTriggeredControllerLock.startTimer();
|
2013-10-15 07:55:26 +02:00
|
|
|
ControllerLockGuardUNO aGuard( m_xChartModel );
|
2007-05-22 16:42:51 +00:00
|
|
|
for( sal_Int32 nL=0; nL<8; nL++)
|
2008-10-17 08:40:10 +00:00
|
|
|
applyLightSourceToModel( nL );
|
2007-05-22 16:42:51 +00:00
|
|
|
m_aTimerTriggeredControllerLock.startTimer();
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewChangeHdl, SvxLightCtl3D*, void)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
|
|
|
m_aTimerTriggeredControllerLock.startTimer();
|
|
|
|
|
|
|
|
//update m_pLightSourceInfoList from preview
|
2013-12-08 19:33:42 -02:00
|
|
|
const SfxItemSet a3DLightAttributes(m_pCtl_Preview->GetSvx3DLightControl().Get3DAttributes());
|
2008-10-17 08:40:10 +00:00
|
|
|
LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
|
|
|
|
|
2014-10-21 08:24:48 +02:00
|
|
|
pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().GetColor();
|
|
|
|
pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue();
|
|
|
|
pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue());
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[1];
|
2014-10-21 08:24:48 +02:00
|
|
|
pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().GetColor();
|
|
|
|
pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue();
|
|
|
|
pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue());
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[2];
|
2014-10-21 08:24:48 +02:00
|
|
|
pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().GetColor();
|
|
|
|
pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue();
|
|
|
|
pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue());
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[3];
|
2014-10-21 08:24:48 +02:00
|
|
|
pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().GetColor();
|
|
|
|
pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue();
|
|
|
|
pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue());
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[4];
|
2014-10-21 08:24:48 +02:00
|
|
|
pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().GetColor();
|
|
|
|
pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue();
|
|
|
|
pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue());
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[5];
|
2014-10-21 08:24:48 +02:00
|
|
|
pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().GetColor();
|
|
|
|
pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue();
|
|
|
|
pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue());
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[6];
|
2014-10-21 08:24:48 +02:00
|
|
|
pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().GetColor();
|
|
|
|
pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue();
|
|
|
|
pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue());
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[7];
|
2014-10-21 08:24:48 +02:00
|
|
|
pInfo->aLightSource.nDiffuseColor = static_cast<const SvxColorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().GetColor();
|
|
|
|
pInfo->aLightSource.bIsEnabled = static_cast<const SfxBoolItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue();
|
|
|
|
pInfo->aLightSource.aDirection = B3DVectorToDirection3D(static_cast<const SvxB3DVectorItem&>(a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue());
|
2007-05-22 16:42:51 +00:00
|
|
|
|
|
|
|
applyLightSourcesToModel();
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, PreviewSelectHdl, SvxLightCtl3D*, void)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
2013-12-08 19:33:42 -02:00
|
|
|
sal_uInt32 nLightNumber = m_pCtl_Preview->GetSvx3DLightControl().GetSelectedLight();
|
2008-10-17 08:40:10 +00:00
|
|
|
if(nLightNumber<8)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
|
|
|
LightButton* pButton = m_pLightSourceInfoList[nLightNumber].pButton;
|
|
|
|
if(!pButton->IsChecked())
|
|
|
|
ClickLightSourceButtonHdl(pButton);
|
|
|
|
|
|
|
|
applyLightSourcesToModel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton, void )
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
2013-12-08 19:33:42 -02:00
|
|
|
bool bIsAmbientLight = (pButton==m_pBtn_AmbientLight_Color);
|
2016-11-25 16:23:17 +02:00
|
|
|
SvxColorListBox* pListBox = bIsAmbientLight ? m_pLB_AmbientLight.get() : m_pLB_LightSource.get();
|
2007-05-22 16:42:51 +00:00
|
|
|
|
|
|
|
SvColorDialog aColorDlg( this );
|
|
|
|
aColorDlg.SetColor( pListBox->GetSelectEntryColor() );
|
|
|
|
if( aColorDlg.Execute() == RET_OK )
|
|
|
|
{
|
|
|
|
Color aColor( aColorDlg.GetColor());
|
|
|
|
lcl_selectColor( *pListBox, aColor );
|
|
|
|
if( bIsAmbientLight )
|
|
|
|
{
|
|
|
|
m_bInCommitToModel = true;
|
|
|
|
lcl_setAmbientColor( m_xSceneProperties, aColor );
|
|
|
|
m_bInCommitToModel = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//get active lightsource:
|
2015-11-10 10:11:17 +01:00
|
|
|
LightSourceInfo* pInfo = nullptr;
|
2007-05-22 16:42:51 +00:00
|
|
|
sal_Int32 nL=0;
|
|
|
|
for( nL=0; nL<8; nL++)
|
|
|
|
{
|
|
|
|
pInfo = &m_pLightSourceInfoList[nL];
|
|
|
|
if(pInfo->pButton->IsChecked())
|
|
|
|
break;
|
2015-11-10 10:11:17 +01:00
|
|
|
pInfo = nullptr;
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
if(pInfo)
|
2008-10-17 08:40:10 +00:00
|
|
|
applyLightSourceToModel( nL );
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
2015-10-04 15:05:38 +02:00
|
|
|
SelectColorHdl( *pListBox );
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-05 20:28:27 +00:00
|
|
|
IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, SvxColorListBox&, rBox, void )
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
2016-11-05 20:28:27 +00:00
|
|
|
SvxColorListBox* pListBox = &rBox;
|
2013-12-08 19:33:42 -02:00
|
|
|
if(pListBox==m_pLB_AmbientLight)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
|
|
|
m_bInCommitToModel = true;
|
|
|
|
lcl_setAmbientColor( m_xSceneProperties, pListBox->GetSelectEntryColor().GetColor());
|
|
|
|
m_bInCommitToModel = false;
|
|
|
|
}
|
2013-12-08 19:33:42 -02:00
|
|
|
else if(pListBox==m_pLB_LightSource)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
|
|
|
//get active lightsource:
|
2015-11-10 10:11:17 +01:00
|
|
|
LightSourceInfo* pInfo = nullptr;
|
2007-05-22 16:42:51 +00:00
|
|
|
sal_Int32 nL=0;
|
|
|
|
for( nL=0; nL<8; nL++)
|
|
|
|
{
|
|
|
|
pInfo = &m_pLightSourceInfoList[nL];
|
|
|
|
if(pInfo->pButton->IsChecked())
|
|
|
|
break;
|
2015-11-10 10:11:17 +01:00
|
|
|
pInfo = nullptr;
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
if(pInfo)
|
|
|
|
{
|
|
|
|
pInfo->aLightSource.nDiffuseColor = pListBox->GetSelectEntryColor().GetColor();
|
2008-10-17 08:40:10 +00:00
|
|
|
applyLightSourceToModel( nL );
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this->updatePreview();
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK( ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl, Button*, pBtn, void )
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
2015-08-19 09:11:34 +02:00
|
|
|
LightButton* pButton = static_cast<LightButton*>(pBtn);
|
2007-05-22 16:42:51 +00:00
|
|
|
if( !pButton )
|
2015-08-19 09:11:34 +02:00
|
|
|
return;
|
2007-05-22 16:42:51 +00:00
|
|
|
|
2015-11-10 10:11:17 +01:00
|
|
|
LightSourceInfo* pInfo = nullptr;
|
2007-05-22 16:42:51 +00:00
|
|
|
sal_Int32 nL=0;
|
|
|
|
for( nL=0; nL<8; nL++)
|
|
|
|
{
|
|
|
|
if( m_pLightSourceInfoList[nL].pButton == pButton )
|
|
|
|
{
|
|
|
|
pInfo = &m_pLightSourceInfoList[nL];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//update light button
|
|
|
|
bool bIsChecked = pButton->IsChecked();
|
|
|
|
if(bIsChecked)
|
|
|
|
{
|
|
|
|
pButton->switchLightOn(!pButton->isLightOn());
|
|
|
|
if(pInfo)
|
|
|
|
{
|
|
|
|
pInfo->aLightSource.bIsEnabled=pButton->isLightOn();
|
2008-10-17 08:40:10 +00:00
|
|
|
applyLightSourceToModel( nL );
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-15 07:55:26 +02:00
|
|
|
ControllerLockGuardUNO aGuard( m_xChartModel );
|
2007-05-22 16:42:51 +00:00
|
|
|
for( nL=0; nL<8; nL++)
|
|
|
|
{
|
|
|
|
LightButton* pLightButton = m_pLightSourceInfoList[nL].pButton;
|
|
|
|
pLightButton->Check( pLightButton == pButton );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//update color list box
|
|
|
|
if(pInfo)
|
|
|
|
{
|
2013-12-08 19:33:42 -02:00
|
|
|
lcl_selectColor( *m_pLB_LightSource, pInfo->aLightSource.nDiffuseColor );
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
this->updatePreview();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ThreeD_SceneIllumination_TabPage::updatePreview()
|
|
|
|
{
|
2013-12-08 19:33:42 -02:00
|
|
|
SfxItemSet aItemSet(m_pCtl_Preview->GetSvx3DLightControl().Get3DAttributes());
|
2008-10-17 08:40:10 +00:00
|
|
|
LightSourceInfo* pInfo = &m_pLightSourceInfoList[0];
|
|
|
|
|
|
|
|
// AmbientColor
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DAmbientcolorItem(m_pLB_AmbientLight->GetSelectEntryColor()));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightcolor1Item(pInfo->aLightSource.nDiffuseColor));
|
2014-09-01 14:46:50 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightOnOff1Item(pInfo->aLightSource.bIsEnabled));
|
2014-09-01 16:46:59 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightDirection1Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[1];
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightcolor2Item(pInfo->aLightSource.nDiffuseColor));
|
2014-09-01 14:46:50 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightOnOff2Item(pInfo->aLightSource.bIsEnabled));
|
2014-09-01 16:46:59 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightDirection2Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[2];
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightcolor3Item(pInfo->aLightSource.nDiffuseColor));
|
2014-09-01 14:46:50 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightOnOff3Item(pInfo->aLightSource.bIsEnabled));
|
2014-09-01 16:46:59 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightDirection3Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[3];
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightcolor4Item(pInfo->aLightSource.nDiffuseColor));
|
2014-09-01 14:46:50 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightOnOff4Item(pInfo->aLightSource.bIsEnabled));
|
2014-09-01 16:46:59 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightDirection4Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[4];
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightcolor5Item(pInfo->aLightSource.nDiffuseColor));
|
2014-09-01 14:46:50 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightOnOff5Item(pInfo->aLightSource.bIsEnabled));
|
2014-09-01 16:46:59 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightDirection5Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[5];
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightcolor6Item(pInfo->aLightSource.nDiffuseColor));
|
2014-09-01 14:46:50 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightOnOff6Item(pInfo->aLightSource.bIsEnabled));
|
2014-09-01 16:46:59 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightDirection6Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[6];
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightcolor7Item(pInfo->aLightSource.nDiffuseColor));
|
2014-09-01 14:46:50 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightOnOff7Item(pInfo->aLightSource.bIsEnabled));
|
2014-09-01 16:46:59 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightDirection7Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
pInfo = &m_pLightSourceInfoList[7];
|
2014-09-01 16:16:49 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightcolor8Item(pInfo->aLightSource.nDiffuseColor));
|
2014-09-01 14:46:50 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightOnOff8Item(pInfo->aLightSource.bIsEnabled));
|
2014-09-01 16:46:59 +02:00
|
|
|
aItemSet.Put(makeSvx3DLightDirection8Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection)));
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
// set lights and ambient light
|
2013-12-08 19:33:42 -02:00
|
|
|
m_pCtl_Preview->GetSvx3DLightControl().Set3DAttributes(aItemSet);
|
2008-10-17 08:40:10 +00:00
|
|
|
|
|
|
|
// select light
|
|
|
|
for(sal_uInt32 a(0); a < 8; a++)
|
2007-05-22 16:42:51 +00:00
|
|
|
{
|
2008-10-17 08:40:10 +00:00
|
|
|
if(m_pLightSourceInfoList[a].pButton->IsChecked())
|
|
|
|
{
|
2013-12-08 19:33:42 -02:00
|
|
|
m_pCtl_Preview->GetSvx3DLightControl().SelectLight(a);
|
|
|
|
m_pCtl_Preview->CheckSelection();
|
2008-10-17 08:40:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-05-22 16:42:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace chart
|
2010-10-12 15:59:00 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|