diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-28 13:51:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-28 17:14:42 +0000 |
commit | ef1f51571654d6449c6ce2872a4bc2bc2475585d (patch) | |
tree | f6b62e77e29c7a42953eb2ff44c1bb0dafad2f18 /chart2 | |
parent | 983456a42dd2a5a08d7d053f8e3069fbd8c9777d (diff) |
move switchRightAngledAxes from ThreeDHelper to Diagram
so we can use the get/setFastPropertyValue methods
Change-Id: Id17fa2466f75a3b4530306143ce50f66fc5593b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149651
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx | 3 | ||||
-rw-r--r-- | chart2/source/inc/Diagram.hxx | 2 | ||||
-rw-r--r-- | chart2/source/inc/ThreeDHelper.hxx | 3 | ||||
-rw-r--r-- | chart2/source/model/main/Diagram.cxx | 27 | ||||
-rw-r--r-- | chart2/source/tools/ThreeDHelper.cxx | 101 |
5 files changed, 31 insertions, 105 deletions
diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx index fb05bfde0dbf..138952775e1e 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx @@ -249,7 +249,8 @@ IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled, weld::Togg m_xMFZRotation->set_value(m_nZRotation, FieldUnit::DEGREE); } - ThreeDHelper::switchRightAngledAxes( m_xDiagram, m_xCbxRightAngledAxes->get_active() ); + if (m_xDiagram) + m_xDiagram->switchRightAngledAxes( m_xCbxRightAngledAxes->get_active() ); } } //namespace chart diff --git a/chart2/source/inc/Diagram.hxx b/chart2/source/inc/Diagram.hxx index 2365d167c6a2..874e8e904e5d 100644 --- a/chart2/source/inc/Diagram.hxx +++ b/chart2/source/inc/Diagram.hxx @@ -350,6 +350,8 @@ public: void setDefaultRotation( bool bPieOrDonut ); + void switchRightAngledAxes( bool bRightAngledAxes ); + private: // ____ XModifyListener ____ virtual void SAL_CALL modified( diff --git a/chart2/source/inc/ThreeDHelper.hxx b/chart2/source/inc/ThreeDHelper.hxx index 1969b2305f6f..a8fc1d63fb40 100644 --- a/chart2/source/inc/ThreeDHelper.hxx +++ b/chart2/source/inc/ThreeDHelper.hxx @@ -59,9 +59,6 @@ public: */ static css::drawing::CameraGeometry getDefaultCameraGeometry( bool bPie=false ); - static void switchRightAngledAxes( const rtl::Reference< Diagram >& xSceneProperties - , bool bRightAngledAxes ); - static void adaptRadAnglesForRightAngledAxes( double& rfXAngleRad, double& rfYAngleRad ); static double getXDegreeAngleLimitForRightAngledAxes() { return 90.0; } static double getYDegreeAngleLimitForRightAngledAxes() { return 45.0; } diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index 8cbdda41422a..1522d168c542 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -2231,6 +2231,33 @@ void Diagram::setDefaultRotation( bool bPieOrDonut ) uno::Any( BaseGFXHelper::B3DHomMatrixToHomogenMatrix( aSceneRotation ))); } +void Diagram::switchRightAngledAxes( bool bRightAngledAxes ) +{ + try + { + bool bOldRightAngledAxes = false; + getFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES ) >>= bOldRightAngledAxes; // "RightAngledAxes" + if( bOldRightAngledAxes!=bRightAngledAxes) + { + setFastPropertyValue( PROP_DIAGRAM_RIGHT_ANGLED_AXES, uno::Any( bRightAngledAxes )); + if(bRightAngledAxes) + { + ::basegfx::B3DHomMatrix aInverseRotation( lcl_getInverseRotationMatrix( *this ) ); + lcl_rotateLights( aInverseRotation, *this ); + } + else + { + ::basegfx::B3DHomMatrix aCompleteRotation( lcl_getCompleteRotationMatrix( *this ) ); + lcl_rotateLights( aCompleteRotation, *this ); + } + } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } +} + } // namespace chart extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx index 13c4ca47af3b..5733c6f44ba2 100644 --- a/chart2/source/tools/ThreeDHelper.cxx +++ b/chart2/source/tools/ThreeDHelper.cxx @@ -65,77 +65,6 @@ bool lcl_isRightAngledAxesSetAndSupported( const rtl::Reference< Diagram >& xDia return false; } -void lcl_RotateLightSource( const Reference< beans::XPropertySet >& xSceneProperties - , const OUString& rLightSourceDirection - , const OUString& rLightSourceOn - , const ::basegfx::B3DHomMatrix& rRotationMatrix ) -{ - if( !xSceneProperties.is() ) - return; - - bool bLightOn = false; - if( !(xSceneProperties->getPropertyValue( rLightSourceOn ) >>= bLightOn) ) - return; - - if( bLightOn ) - { - drawing::Direction3D aLight; - if( xSceneProperties->getPropertyValue( rLightSourceDirection ) >>= aLight ) - { - ::basegfx::B3DVector aLightVector( BaseGFXHelper::Direction3DToB3DVector( aLight ) ); - aLightVector = rRotationMatrix*aLightVector; - - xSceneProperties->setPropertyValue( rLightSourceDirection - , uno::Any( BaseGFXHelper::B3DVectorToDirection3D( aLightVector ) ) ); - } - } -} - -void lcl_rotateLights( const ::basegfx::B3DHomMatrix& rLightRottion, const Reference< beans::XPropertySet >& xSceneProperties ) -{ - if(!xSceneProperties.is()) - return; - - ::basegfx::B3DHomMatrix aLightRottion( rLightRottion ); - BaseGFXHelper::ReduceToRotationMatrix( aLightRottion ); - - lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection1", "D3DSceneLightOn1", aLightRottion ); - lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection2", "D3DSceneLightOn2", aLightRottion ); - lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection3", "D3DSceneLightOn3", aLightRottion ); - lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection4", "D3DSceneLightOn4", aLightRottion ); - lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection5", "D3DSceneLightOn5", aLightRottion ); - lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection6", "D3DSceneLightOn6", aLightRottion ); - lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection7", "D3DSceneLightOn7", aLightRottion ); - lcl_RotateLightSource( xSceneProperties, "D3DSceneLightDirection8", "D3DSceneLightOn8", aLightRottion ); -} - -::basegfx::B3DHomMatrix lcl_getInverseRotationMatrix( const rtl::Reference< Diagram >& xSceneProperties ) -{ - ::basegfx::B3DHomMatrix aInverseRotation; - double fXAngleRad=0.0; - double fYAngleRad=0.0; - double fZAngleRad=0.0; - xSceneProperties->getRotationAngle( - fXAngleRad, fYAngleRad, fZAngleRad ); - aInverseRotation.rotate( 0.0, 0.0, -fZAngleRad ); - aInverseRotation.rotate( 0.0, -fYAngleRad, 0.0 ); - aInverseRotation.rotate( -fXAngleRad, 0.0, 0.0 ); - return aInverseRotation; -} - -::basegfx::B3DHomMatrix lcl_getCompleteRotationMatrix( const rtl::Reference< Diagram >& xSceneProperties ) -{ - ::basegfx::B3DHomMatrix aCompleteRotation; - double fXAngleRad=0.0; - double fYAngleRad=0.0; - double fZAngleRad=0.0; - xSceneProperties->getRotationAngle( - fXAngleRad, fYAngleRad, fZAngleRad ); - aCompleteRotation.rotate( fXAngleRad, fYAngleRad, fZAngleRad ); - return aCompleteRotation; -} - - } //end anonymous namespace drawing::CameraGeometry ThreeDHelper::getDefaultCameraGeometry( bool bPie ) @@ -679,36 +608,6 @@ void ThreeDHelper::adaptRadAnglesForRightAngledAxes( double& rfXAngleRad, double } -void ThreeDHelper::switchRightAngledAxes( const rtl::Reference< Diagram >& xSceneProperties, bool bRightAngledAxes ) -{ - try - { - if( xSceneProperties.is() ) - { - bool bOldRightAngledAxes = false; - xSceneProperties->getPropertyValue( "RightAngledAxes") >>= bOldRightAngledAxes; - if( bOldRightAngledAxes!=bRightAngledAxes) - { - xSceneProperties->setPropertyValue( "RightAngledAxes", uno::Any( bRightAngledAxes )); - if(bRightAngledAxes) - { - ::basegfx::B3DHomMatrix aInverseRotation( lcl_getInverseRotationMatrix( xSceneProperties ) ); - lcl_rotateLights( aInverseRotation, xSceneProperties ); - } - else - { - ::basegfx::B3DHomMatrix aCompleteRotation( lcl_getCompleteRotationMatrix( xSceneProperties ) ); - lcl_rotateLights( aCompleteRotation, xSceneProperties ); - } - } - } - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } -} - void ThreeDHelper::getCameraDistanceRange( double& rfMinimumDistance, double& rfMaximumDistance ) { rfMinimumDistance = 3.0/4.0*FIXED_SIZE_FOR_3D_CHART_VOLUME;//empiric value |