diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2007-05-22 16:41:33 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2007-05-22 16:41:33 +0000 |
commit | d8427088ee9ad0b8aec13cc0c47f70d494a43d3b (patch) | |
tree | 5f107bcf853a3ea48b0d2bb69b796a2b0bab4162 /chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx | |
parent | a9e82a4eba4bcc654264ad144ba7b396224a0016 (diff) |
INTEGRATION: CWS chart2mst3 (1.1.2); FILE ADDED
2007/05/18 16:12:16 bm 1.1.2.17: #i74635# ResMgr cleanup ResId -> SchResId
2007/02/08 21:25:34 iha 1.1.2.16: resync m195 -> m202
2007/02/08 18:10:10 iha 1.1.2.15: #i71963# enable mixed mode on checkboxes
2006/12/07 23:21:20 iha 1.1.2.14: #i67833# simple 3D look - bring light to front
2006/01/14 15:09:51 iha 1.1.2.13: replaced rounded edges spin field by a chekbox, disable rouded edges if objectlines are on, added custom entry to the scheme listbox
2005/11/15 20:20:56 iha 1.1.2.12: remove superfluous view updates
2005/11/03 16:16:04 bm 1.1.2.11: live-preview changes, lock controllers for multiple changes
2005/11/03 09:48:24 bm 1.1.2.10: oops
2005/11/03 09:45:57 bm 1.1.2.9: forced view update test removed
2005/11/03 09:38:26 bm 1.1.2.8: changed to live-preview
2005/11/02 13:49:18 bm 1.1.2.7: scene properties changed from SceneDescriptor property to the D3D properties offered by SceneProperties.hxx (this way XML im-/export works with the xmloff helper)
2005/10/11 09:20:12 bm 1.1.2.6: license header change
2004/06/12 10:11:28 iha 1.1.2.5: renaming 3D scheme
2004/06/12 09:58:16 iha 1.1.2.4: shading interpretion error because of changed positions
2004/06/11 15:41:54 iha 1.1.2.3: replace shadinglist box by simple checkbox
2004/06/08 14:24:42 iha 1.1.2.2: #i20329# implementation
2004/06/01 17:27:18 iha 1.1.2.1: new 3D view/effects dialog
Diffstat (limited to 'chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx')
-rw-r--r-- | chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx | 343 |
1 files changed, 343 insertions, 0 deletions
diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx new file mode 100644 index 000000000000..af763be428be --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx @@ -0,0 +1,343 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneAppearance.cxx,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: vg $ $Date: 2007-05-22 17:41:33 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_3D_SceneAppearance.hxx" +#include "tp_3D_SceneAppearance.hrc" +#include "ResId.hxx" +#include "Strings.hrc" +#include "NoWarningThisInCTOR.hxx" +#include "ChartModelHelper.hxx" +#include "Pseudo3DHelper.hxx" +#include "macros.hxx" + +#ifndef INCLUDED_RTL_MATH_HXX +#include <rtl/math.hxx> +#endif + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif + +using namespace ::com::sun::star; + +namespace +{ + +struct lcl_ModelProperties +{ + drawing::ShadeMode m_aShadeMode; + sal_Int32 m_nRoundedEdges; + sal_Int32 m_nObjectLines; + ::chart::ThreeDLookScheme m_eScheme; + + lcl_ModelProperties() : + m_nRoundedEdges(-1), + m_nObjectLines(-1), + m_eScheme(::chart::ThreeDLookScheme_Unknown) + {} +}; + +lcl_ModelProperties lcl_getPropertiesFromModel( uno::Reference< frame::XModel > & xModel ) +{ + lcl_ModelProperties aProps; + try + { + uno::Reference< beans::XPropertySet > xDiaProp( ::chart::ChartModelHelper::findDiagram( xModel ), uno::UNO_QUERY_THROW ); + xDiaProp->getPropertyValue( C2U("D3DSceneShadeMode")) >>= aProps.m_aShadeMode; + ::chart::Pseudo3DHelper::getRoundedEdgesAndObjectLines( xModel, aProps.m_nRoundedEdges, aProps.m_nObjectLines ); + aProps.m_eScheme = ::chart::Pseudo3DHelper::detectScheme( xModel ); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return aProps; +} + +void lcl_setShadeModeAtModel( uno::Reference< frame::XModel > & xModel, drawing::ShadeMode aShadeMode ) +{ + try + { + uno::Reference< beans::XPropertySet > xDiaProp( + ::chart::ChartModelHelper::findDiagram( xModel ), uno::UNO_QUERY_THROW ); + xDiaProp->setPropertyValue( C2U("D3DSceneShadeMode"), uno::makeAny( aShadeMode )); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +} // anonymous namespace + +//............................................................................. +namespace chart +{ +//............................................................................. + +#define POS_3DSCHEME_SIMPLE 0 +#define POS_3DSCHEME_REALISTIC 1 +#define POS_3DSCHEME_CUSTOM 2 + +ThreeD_SceneAppearance_TabPage::ThreeD_SceneAppearance_TabPage( + Window* pWindow + , const uno::Reference< frame::XModel > & xChartModel + , ControllerLockHelper & rControllerLockHelper ) + : TabPage ( pWindow, SchResId( TP_3D_SCENEAPPEARANCE ) ) + , m_xChartModel ( xChartModel ) + , m_aFT_Scheme ( this, SchResId( FT_SCHEME ) ) + , m_aLB_Scheme ( this, SchResId( LB_SCHEME ) ) + , m_aFL_Seperator ( this, SchResId( FL_SEPERATOR ) ) + , m_aCB_RoundedEdge ( this, SchResId( CB_ROUNDEDEDGE ) ) + , m_aCB_Shading ( this, SchResId( CB_SHADING ) ) + , m_aCB_ObjectLines ( this, SchResId( CB_OBJECTLINES ) ) + , m_bCommitToModel( true ) + , m_bUpdateOtherControls( true ) + , m_rControllerLockHelper( rControllerLockHelper ) +{ + FreeResource(); + m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_SIMPLE)),POS_3DSCHEME_SIMPLE); + m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_REALISTIC)),POS_3DSCHEME_REALISTIC); + m_aLB_Scheme.SetDropDownLineCount(2); + + m_aLB_Scheme.SetSelectHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectSchemeHdl ) ); + + m_aCB_RoundedEdge.SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); + m_aCB_Shading.SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectShading ) ); + m_aCB_ObjectLines.SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); + + m_aCB_RoundedEdge.EnableTriState( TRUE ); + m_aCB_Shading.EnableTriState( TRUE ); + m_aCB_ObjectLines.EnableTriState( TRUE ); + + initControlsFromModel(); +} + +ThreeD_SceneAppearance_TabPage::~ThreeD_SceneAppearance_TabPage() +{} + +void ThreeD_SceneAppearance_TabPage::ActivatePage() +{ + updateScheme(); +} + +void ThreeD_SceneAppearance_TabPage::commitPendingChanges() +{ +} + +void ThreeD_SceneAppearance_TabPage::applyRoundedEdgeAndObjectLinesToModel() +{ + if(!m_bCommitToModel) + return; + + sal_Int32 nObjectLines = -1; + + switch( m_aCB_ObjectLines.GetState()) + { + case STATE_NOCHECK: + nObjectLines = 0; + break; + case STATE_CHECK: + nObjectLines = 1; + break; + case STATE_DONTKNOW: + nObjectLines = -1; + break; + } + + sal_Int32 nCurrentRoundedEdges = -1; + switch( m_aCB_RoundedEdge.GetState() ) + { + case STATE_NOCHECK: + nCurrentRoundedEdges = 0; + break; + case STATE_CHECK: + nCurrentRoundedEdges = 5; + break; + case STATE_DONTKNOW: + nCurrentRoundedEdges = -1; + break; + } + + // /-- locked controllers + ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); + Pseudo3DHelper::setRoundedEdgesAndObjectLines( + m_xChartModel, nCurrentRoundedEdges, nObjectLines ); + // \-- locked controllers +} + +void ThreeD_SceneAppearance_TabPage::applyShadeModeToModel() +{ + if(!m_bCommitToModel) + return; + + drawing::ShadeMode aShadeMode = drawing::ShadeMode_PHONG; + + switch( m_aCB_Shading.GetState()) + { + case STATE_NOCHECK: + aShadeMode = drawing::ShadeMode_FLAT; + break; + case STATE_CHECK: + aShadeMode = drawing::ShadeMode_SMOOTH; + break; + case STATE_DONTKNOW: + // nothing + break; + } + + lcl_setShadeModeAtModel( m_xChartModel, aShadeMode ); +} + +void ThreeD_SceneAppearance_TabPage::initControlsFromModel() +{ + m_bCommitToModel = false; + m_bUpdateOtherControls = false; + + lcl_ModelProperties aProps( lcl_getPropertiesFromModel( m_xChartModel )); + + if(aProps.m_aShadeMode == drawing::ShadeMode_FLAT) + m_aCB_Shading.Check(FALSE); + else if(aProps.m_aShadeMode == drawing::ShadeMode_SMOOTH) + m_aCB_Shading.Check(TRUE); + else + m_aCB_Shading.SetState( STATE_DONTKNOW ); + + if(aProps.m_nObjectLines == 0) + m_aCB_ObjectLines.Check(FALSE); + else if(aProps.m_nObjectLines==1) + m_aCB_ObjectLines.Check(TRUE); + else + m_aCB_ObjectLines.SetState( STATE_DONTKNOW ); + + if(aProps.m_nRoundedEdges >= 5) + m_aCB_RoundedEdge.Check(TRUE); + else if(aProps.m_nRoundedEdges<0) + m_aCB_RoundedEdge.SetState( STATE_DONTKNOW ); + else + m_aCB_RoundedEdge.Check(FALSE); + m_aCB_RoundedEdge.Enable( !m_aCB_ObjectLines.IsChecked() ); + + updateScheme(); + + m_bCommitToModel = true; + m_bUpdateOtherControls = true; +} + +void ThreeD_SceneAppearance_TabPage::updateScheme() +{ + lcl_ModelProperties aProps( lcl_getPropertiesFromModel( m_xChartModel )); + + if( m_aLB_Scheme.GetEntryCount() == (POS_3DSCHEME_CUSTOM+1) ) + { + m_aLB_Scheme.RemoveEntry(POS_3DSCHEME_CUSTOM); + m_aLB_Scheme.SetDropDownLineCount(2); + } + switch( aProps.m_eScheme ) + { + case ThreeDLookScheme_Simple: + m_aLB_Scheme.SelectEntryPos( POS_3DSCHEME_SIMPLE ); + break; + case ThreeDLookScheme_Realistic: + m_aLB_Scheme.SelectEntryPos( POS_3DSCHEME_REALISTIC ); + break; + case ThreeDLookScheme_Unknown: + { + m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_CUSTOM)),POS_3DSCHEME_CUSTOM); + m_aLB_Scheme.SelectEntryPos( POS_3DSCHEME_CUSTOM ); + m_aLB_Scheme.SetDropDownLineCount(3); + } + break; + } +} + +IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectSchemeHdl, void*, EMPTYARG ) +{ + if( !m_bUpdateOtherControls ) + return 0; + + { + // /-- locked controllers + ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); + + if( m_aLB_Scheme.GetSelectEntryPos() == POS_3DSCHEME_REALISTIC ) + Pseudo3DHelper::setScheme( m_xChartModel, ThreeDLookScheme_Realistic ); + else if( m_aLB_Scheme.GetSelectEntryPos() == POS_3DSCHEME_SIMPLE ) + Pseudo3DHelper::setScheme( m_xChartModel, ThreeDLookScheme_Simple ); + else + { + OSL_ENSURE( false, "Invalid Entry selected" ); + } + // \-- locked controllers + } + + // update other controls + initControlsFromModel(); + return 0; +} + +IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectShading, void*, EMPTYARG ) +{ + if( !m_bUpdateOtherControls ) + return 0; + + applyShadeModeToModel(); + updateScheme(); + return 0; +} +IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines, CheckBox*, pCheckBox ) +{ + if( !m_bUpdateOtherControls ) + return 0; + + if( pCheckBox == &m_aCB_ObjectLines ) + { + m_bUpdateOtherControls = false; + m_aCB_RoundedEdge.Enable( !m_aCB_ObjectLines.IsChecked() ); + if(!m_aCB_RoundedEdge.IsEnabled()) + m_aCB_RoundedEdge.Check(FALSE); + m_bUpdateOtherControls = true; + } + applyRoundedEdgeAndObjectLinesToModel(); + updateScheme(); + return 0; +} + +//............................................................................. +} //namespace chart +//............................................................................. |