LCOV - code coverage report
Current view: top level - chart2/source/controller/dialogs - tp_3D_SceneGeometry.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 135 0.0 %
Date: 2012-08-25 Functions: 0 20 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 274 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : 
      21                 :            : #include "tp_3D_SceneGeometry.hxx"
      22                 :            : #include "tp_3D_SceneGeometry.hrc"
      23                 :            : #include "ResId.hxx"
      24                 :            : #include "NoWarningThisInCTOR.hxx"
      25                 :            : #include "BaseGFXHelper.hxx"
      26                 :            : #include "macros.hxx"
      27                 :            : #include "DiagramHelper.hxx"
      28                 :            : #include "ChartTypeHelper.hxx"
      29                 :            : #include "ThreeDHelper.hxx"
      30                 :            : #include <rtl/math.hxx>
      31                 :            : #include <editeng/unoprnms.hxx>
      32                 :            : #include <com/sun/star/drawing/ProjectionMode.hpp>
      33                 :            : 
      34                 :            : //.............................................................................
      35                 :            : namespace chart
      36                 :            : {
      37                 :            : //.............................................................................
      38                 :            : 
      39                 :            : using namespace ::com::sun::star;
      40                 :            : 
      41                 :            : namespace
      42                 :            : {
      43                 :            : 
      44                 :          0 : void lcl_shiftAngleToValidRange( sal_Int64& rnAngleDegree )
      45                 :            : {
      46                 :            :     //valid range:  ]-180,180]
      47         [ #  # ]:          0 :     while( rnAngleDegree<=-180 )
      48                 :          0 :         rnAngleDegree+=360;
      49         [ #  # ]:          0 :     while( rnAngleDegree>180 )
      50                 :          0 :         rnAngleDegree-=360;
      51                 :          0 : }
      52                 :            : 
      53                 :          0 : void lcl_SetMetricFieldLimits( MetricField& rField, sal_Int64 nLimit )
      54                 :            : {
      55                 :          0 :     rField.SetMin(-1*nLimit);
      56                 :          0 :     rField.SetFirst(-1*nLimit);
      57                 :          0 :     rField.SetMax(nLimit);
      58                 :          0 :     rField.SetLast(nLimit);
      59                 :          0 : }
      60                 :            : 
      61                 :            : }
      62                 :          0 : ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( Window* pWindow
      63                 :            :                 , const uno::Reference< beans::XPropertySet > & xSceneProperties
      64                 :            :                 , ControllerLockHelper & rControllerLockHelper )
      65                 :            :                 : TabPage       ( pWindow, SchResId( TP_3D_SCENEGEOMETRY ) )
      66                 :            :                 , m_xSceneProperties( xSceneProperties )
      67                 :            :                 , m_aCbxRightAngledAxes( this, SchResId( CBX_RIGHT_ANGLED_AXES ) )
      68                 :            :                 , m_aFtXRotation    ( this, SchResId( FT_X_ROTATION ) )
      69                 :            :                 , m_aMFXRotation    ( this, SchResId( MTR_FLD_X_ROTATION ) )
      70                 :            :                 , m_aFtYRotation    ( this, SchResId( FT_Y_ROTATION ) )
      71                 :            :                 , m_aMFYRotation    ( this, SchResId( MTR_FLD_Y_ROTATION ) )
      72                 :            :                 , m_aFtZRotation    ( this, SchResId( FT_Z_ROTATION ) )
      73                 :            :                 , m_aMFZRotation    ( this, SchResId( MTR_FLD_Z_ROTATION ) )
      74                 :            :                 , m_aCbxPerspective ( this, SchResId( CBX_PERSPECTIVE ) )
      75                 :            :                 , m_aMFPerspective  ( this, SchResId( MTR_FLD_PERSPECTIVE ) )
      76                 :            :                 , m_nXRotation(0)
      77                 :            :                 , m_nYRotation(0)
      78                 :            :                 , m_nZRotation(0)
      79                 :            :                 , m_bAngleChangePending( false )
      80                 :            :                 , m_bPerspectiveChangePending( false )
      81 [ #  # ][ #  # ]:          0 :                 , m_rControllerLockHelper( rControllerLockHelper )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      82                 :            : {
      83         [ #  # ]:          0 :     FreeResource();
      84                 :            : 
      85                 :            :     double fXAngle, fYAngle, fZAngle;
      86         [ #  # ]:          0 :     ThreeDHelper::getRotationAngleFromDiagram( m_xSceneProperties, fXAngle, fYAngle, fZAngle );
      87                 :            : 
      88         [ #  # ]:          0 :     fXAngle = BaseGFXHelper::Rad2Deg( fXAngle );
      89         [ #  # ]:          0 :     fYAngle = BaseGFXHelper::Rad2Deg( fYAngle );
      90         [ #  # ]:          0 :     fZAngle = BaseGFXHelper::Rad2Deg( fZAngle );
      91                 :            : 
      92                 :            :     OSL_ENSURE( fZAngle>=-90 && fZAngle<=90, "z angle is out of valid range" );
      93                 :            : 
      94         [ #  # ]:          0 :     lcl_SetMetricFieldLimits( m_aMFZRotation, 90 );
      95                 :            : 
      96         [ #  # ]:          0 :     m_nXRotation = ::basegfx::fround(fXAngle*pow(10.0,m_aMFXRotation.GetDecimalDigits()));
      97         [ #  # ]:          0 :     m_nYRotation = ::basegfx::fround(-1.0*fYAngle*pow(10.0,m_aMFYRotation.GetDecimalDigits()));
      98         [ #  # ]:          0 :     m_nZRotation = ::basegfx::fround(-1.0*fZAngle*pow(10.0,m_aMFZRotation.GetDecimalDigits()));
      99                 :            : 
     100                 :          0 :     lcl_shiftAngleToValidRange( m_nXRotation );
     101                 :          0 :     lcl_shiftAngleToValidRange( m_nYRotation );
     102                 :          0 :     lcl_shiftAngleToValidRange( m_nZRotation );
     103                 :            : 
     104         [ #  # ]:          0 :     m_aMFXRotation.SetValue(m_nXRotation);
     105         [ #  # ]:          0 :     m_aMFYRotation.SetValue(m_nYRotation);
     106         [ #  # ]:          0 :     m_aMFZRotation.SetValue(m_nZRotation);
     107                 :            : 
     108                 :          0 :     const sal_uLong nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT;
     109         [ #  # ]:          0 :     Link aAngleChangedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleChanged ));
     110         [ #  # ]:          0 :     Link aAngleEditedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleEdited ));
     111                 :            : 
     112         [ #  # ]:          0 :     m_aMFXRotation.EnableUpdateData( nTimeout );
     113                 :          0 :     m_aMFXRotation.SetUpdateDataHdl( aAngleChangedLink );
     114                 :          0 :     m_aMFXRotation.SetModifyHdl( aAngleEditedLink );
     115                 :            : 
     116         [ #  # ]:          0 :     m_aMFYRotation.EnableUpdateData( nTimeout );
     117                 :          0 :     m_aMFYRotation.SetUpdateDataHdl( aAngleChangedLink );
     118                 :          0 :     m_aMFYRotation.SetModifyHdl( aAngleEditedLink );
     119                 :            : 
     120         [ #  # ]:          0 :     m_aMFZRotation.EnableUpdateData( nTimeout );
     121                 :          0 :     m_aMFZRotation.SetUpdateDataHdl( aAngleChangedLink );
     122                 :          0 :     m_aMFZRotation.SetModifyHdl( aAngleEditedLink );
     123                 :            : 
     124                 :          0 :     drawing::ProjectionMode aProjectionMode = drawing::ProjectionMode_PERSPECTIVE;
     125 [ #  # ][ #  # ]:          0 :     m_xSceneProperties->getPropertyValue( C2U("D3DScenePerspective")) >>= aProjectionMode;
         [ #  # ][ #  # ]
     126         [ #  # ]:          0 :     m_aCbxPerspective.Check( aProjectionMode == drawing::ProjectionMode_PERSPECTIVE );
     127         [ #  # ]:          0 :     m_aCbxPerspective.SetToggleHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveToggled ));
     128                 :            : 
     129                 :          0 :     sal_Int32 nPerspectivePercentage = 20;
     130 [ #  # ][ #  # ]:          0 :     m_xSceneProperties->getPropertyValue( C2U("Perspective")) >>= nPerspectivePercentage;
                 [ #  # ]
     131         [ #  # ]:          0 :     m_aMFPerspective.SetValue( nPerspectivePercentage );
     132                 :            : 
     133         [ #  # ]:          0 :     m_aMFPerspective.EnableUpdateData( nTimeout );
     134         [ #  # ]:          0 :     m_aMFPerspective.SetUpdateDataHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveChanged ) );
     135         [ #  # ]:          0 :     m_aMFPerspective.SetModifyHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveEdited ) );
     136 [ #  # ][ #  # ]:          0 :     m_aMFPerspective.Enable( m_aCbxPerspective.IsChecked() );
     137                 :            : 
     138                 :            : 
     139                 :            :     //RightAngledAxes
     140                 :          0 :     sal_Bool bRightAngledAxes = false;
     141                 :            : 
     142         [ #  # ]:          0 :     uno::Reference< chart2::XDiagram > xDiagram( m_xSceneProperties, uno::UNO_QUERY );
     143         [ #  # ]:          0 :     if( ChartTypeHelper::isSupportingRightAngledAxes(
     144 [ #  # ][ #  # ]:          0 :             DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) )
     145                 :            :     {
     146 [ #  # ][ #  # ]:          0 :         m_xSceneProperties->getPropertyValue( C2U("RightAngledAxes")) >>= bRightAngledAxes;
                 [ #  # ]
     147         [ #  # ]:          0 :         m_aCbxRightAngledAxes.SetToggleHdl( LINK( this, ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled ));
     148         [ #  # ]:          0 :         m_aCbxRightAngledAxes.Check( bRightAngledAxes );
     149                 :            :     }
     150                 :            :     else
     151                 :            :     {
     152         [ #  # ]:          0 :         m_aCbxRightAngledAxes.Enable(false);
     153                 :            :     }
     154 [ #  # ][ #  # ]:          0 :     m_aMFPerspective.SetAccessibleName(m_aCbxPerspective.GetText());
                 [ #  # ]
     155         [ #  # ]:          0 :     m_aMFPerspective.SetAccessibleRelationLabeledBy(&m_aCbxPerspective);
     156                 :          0 : }
     157                 :            : 
     158 [ #  # ][ #  # ]:          0 : ThreeD_SceneGeometry_TabPage::~ThreeD_SceneGeometry_TabPage()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     159                 :            : {
     160         [ #  # ]:          0 : }
     161                 :            : 
     162                 :          0 : void ThreeD_SceneGeometry_TabPage::commitPendingChanges()
     163                 :            : {
     164         [ #  # ]:          0 :     ControllerLockHelperGuard aGuard( m_rControllerLockHelper );
     165                 :            : 
     166         [ #  # ]:          0 :     if( m_bAngleChangePending )
     167         [ #  # ]:          0 :         applyAnglesToModel();
     168         [ #  # ]:          0 :     if( m_bPerspectiveChangePending )
     169 [ #  # ][ #  # ]:          0 :         applyPerspectiveToModel();
     170                 :          0 : }
     171                 :            : 
     172                 :          0 : void ThreeD_SceneGeometry_TabPage::applyAnglesToModel()
     173                 :            : {
     174         [ #  # ]:          0 :     ControllerLockHelperGuard aGuard( m_rControllerLockHelper );
     175                 :            : 
     176                 :          0 :     double fXAngle = 0.0, fYAngle = 0.0, fZAngle = 0.0;
     177                 :            : 
     178 [ #  # ][ #  # ]:          0 :     if( !m_aMFZRotation.IsEmptyFieldValue() )
     179         [ #  # ]:          0 :         m_nZRotation = m_aMFZRotation.GetValue();
     180                 :            : 
     181         [ #  # ]:          0 :     fXAngle = double(m_nXRotation)/double(pow(10.0,m_aMFXRotation.GetDecimalDigits()));
     182         [ #  # ]:          0 :     fYAngle = double(-1.0*m_nYRotation)/double(pow(10.0,m_aMFYRotation.GetDecimalDigits()));
     183         [ #  # ]:          0 :     fZAngle = double(-1.0*m_nZRotation)/double(pow(10.0,m_aMFZRotation.GetDecimalDigits()));
     184                 :            : 
     185         [ #  # ]:          0 :     fXAngle = BaseGFXHelper::Deg2Rad( fXAngle );
     186         [ #  # ]:          0 :     fYAngle = BaseGFXHelper::Deg2Rad( fYAngle );
     187         [ #  # ]:          0 :     fZAngle = BaseGFXHelper::Deg2Rad( fZAngle );
     188                 :            : 
     189         [ #  # ]:          0 :     ThreeDHelper::setRotationAngleToDiagram( m_xSceneProperties, fXAngle, fYAngle, fZAngle );
     190                 :            : 
     191         [ #  # ]:          0 :     m_bAngleChangePending = false;
     192                 :          0 : }
     193                 :            : 
     194                 :          0 : IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, AngleEdited)
     195                 :            : {
     196                 :          0 :     m_nXRotation = m_aMFXRotation.GetValue();
     197                 :          0 :     m_nYRotation = m_aMFYRotation.GetValue();
     198                 :            : 
     199                 :          0 :     m_bAngleChangePending = true;
     200                 :          0 :     return 0;
     201                 :            : }
     202                 :            : 
     203                 :          0 : IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, AngleChanged)
     204                 :            : {
     205                 :          0 :     applyAnglesToModel();
     206                 :          0 :     return 0;
     207                 :            : }
     208                 :            : 
     209                 :          0 : void ThreeD_SceneGeometry_TabPage::applyPerspectiveToModel()
     210                 :            : {
     211         [ #  # ]:          0 :     ControllerLockHelperGuard aGuard( m_rControllerLockHelper );
     212                 :            : 
     213         [ #  # ]:          0 :     drawing::ProjectionMode aMode = m_aCbxPerspective.IsChecked()
     214                 :            :         ? drawing::ProjectionMode_PERSPECTIVE
     215         [ #  # ]:          0 :         : drawing::ProjectionMode_PARALLEL;
     216                 :            : 
     217                 :            :     try
     218                 :            :     {
     219 [ #  # ][ #  # ]:          0 :         m_xSceneProperties->setPropertyValue( C2U("D3DScenePerspective"), uno::makeAny( aMode ));
         [ #  # ][ #  # ]
     220 [ #  # ][ #  # ]:          0 :         m_xSceneProperties->setPropertyValue( C2U("Perspective"), uno::makeAny( (sal_Int32)m_aMFPerspective.GetValue() ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     221                 :            :     }
     222         [ #  # ]:          0 :     catch( const uno::Exception & ex )
     223                 :            :     {
     224                 :            :         ASSERT_EXCEPTION( ex );
     225                 :            :     }
     226                 :            : 
     227         [ #  # ]:          0 :     m_bPerspectiveChangePending = false;
     228                 :          0 : }
     229                 :            : 
     230                 :          0 : IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveEdited)
     231                 :            : {
     232                 :          0 :     m_bPerspectiveChangePending = true;
     233                 :          0 :     return 0;
     234                 :            : }
     235                 :            : 
     236                 :          0 : IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveChanged)
     237                 :            : {
     238                 :          0 :     applyPerspectiveToModel();
     239                 :          0 :     return 0;
     240                 :            : }
     241                 :            : 
     242                 :          0 : IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, PerspectiveToggled)
     243                 :            : {
     244                 :          0 :     m_aMFPerspective.Enable( m_aCbxPerspective.IsChecked() );
     245                 :          0 :     applyPerspectiveToModel();
     246                 :          0 :     return 0;
     247                 :            : }
     248                 :            : 
     249                 :          0 : IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled)
     250                 :            : {
     251         [ #  # ]:          0 :     ControllerLockHelperGuard aGuard( m_rControllerLockHelper );
     252                 :            : 
     253         [ #  # ]:          0 :     bool bEnableZ = !m_aCbxRightAngledAxes.IsChecked();
     254         [ #  # ]:          0 :     m_aFtZRotation.Enable( bEnableZ );
     255         [ #  # ]:          0 :     m_aMFZRotation.Enable( bEnableZ );
     256                 :          0 :     m_aMFZRotation.EnableEmptyFieldValue( !bEnableZ );
     257         [ #  # ]:          0 :     if( !bEnableZ )
     258                 :            :     {
     259         [ #  # ]:          0 :         m_nXRotation = m_aMFXRotation.GetValue();
     260         [ #  # ]:          0 :         m_nYRotation = m_aMFYRotation.GetValue();
     261         [ #  # ]:          0 :         m_nZRotation = m_aMFZRotation.GetValue();
     262                 :            : 
     263 [ #  # ][ #  # ]:          0 :         m_aMFXRotation.SetValue(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nXRotation), ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes())));
                 [ #  # ]
     264 [ #  # ][ #  # ]:          0 :         m_aMFYRotation.SetValue(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nYRotation), ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes())));
                 [ #  # ]
     265         [ #  # ]:          0 :         m_aMFZRotation.SetEmptyFieldValue();
     266                 :            : 
     267 [ #  # ][ #  # ]:          0 :         lcl_SetMetricFieldLimits( m_aMFXRotation, static_cast<sal_Int64>(ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes()));
     268 [ #  # ][ #  # ]:          0 :         lcl_SetMetricFieldLimits( m_aMFYRotation, static_cast<sal_Int64>(ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes()));
     269                 :            :     }
     270                 :            :     else
     271                 :            :     {
     272         [ #  # ]:          0 :         lcl_SetMetricFieldLimits( m_aMFXRotation, 180 );
     273         [ #  # ]:          0 :         lcl_SetMetricFieldLimits( m_aMFYRotation, 180 );
     274                 :            : 
     275         [ #  # ]:          0 :         m_aMFXRotation.SetValue(m_nXRotation);
     276         [ #  # ]:          0 :         m_aMFYRotation.SetValue(m_nYRotation);
     277         [ #  # ]:          0 :         m_aMFZRotation.SetValue(m_nZRotation);
     278                 :            :     }
     279                 :            : 
     280 [ #  # ][ #  # ]:          0 :     ThreeDHelper::switchRightAngledAxes( m_xSceneProperties, m_aCbxRightAngledAxes.IsChecked(), true /*bRotateLights*/ );
     281                 :            : 
     282         [ #  # ]:          0 :     return 0;
     283                 :            : }
     284                 :            : 
     285                 :            : //.............................................................................
     286                 :            : } //namespace chart
     287                 :            : //.............................................................................
     288                 :            : 
     289                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10