diff options
author | Rüdiger Timm <rt@openoffice.org> | 2008-04-18 12:22:50 +0000 |
---|---|---|
committer | Rüdiger Timm <rt@openoffice.org> | 2008-04-18 12:22:50 +0000 |
commit | 745c4bcb57bceb560b34cd67fe86c75b2d9e41f4 (patch) | |
tree | 1a1a795ef358ae5e4a422526e13a4be8fea31112 /chart2 | |
parent | 3a923120e6b1e0b046ecb140a74d57c379e6239f (diff) |
INTEGRATION: CWS xmlfilter04 (1.3.82); FILE MERGED
2008/03/14 15:40:34 iha 1.3.82.1: #i72994# simpler access to 3D settings
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/tools/ThreeDHelper.cxx | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/chart2/source/tools/ThreeDHelper.cxx b/chart2/source/tools/ThreeDHelper.cxx index 08753de73d36..c41fd6e61240 100644 --- a/chart2/source/tools/ThreeDHelper.cxx +++ b/chart2/source/tools/ThreeDHelper.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ThreeDHelper.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.5 $ * * This file is part of OpenOffice.org. * @@ -363,6 +363,15 @@ double lcl_shiftAngleToIntervalMinusPiToPi( double fAngleRad ) return fAngleRad; } +void lcl_shiftAngleToIntervalMinus180To180( sal_Int32& rnAngleDegree ) +{ + //valid range: ]-180,180] + while( rnAngleDegree<=-180 ) + rnAngleDegree+=360; + while( rnAngleDegree>180 ) + rnAngleDegree-=360; +} + } double ThreeDHelper::getValueClippedToRange( double fAngle, const double& fPositivLimit ) @@ -522,6 +531,37 @@ void ThreeDHelper::setRotationAngleToDiagram( } } +void ThreeDHelper::getRotationFromDiagram( const uno::Reference< beans::XPropertySet >& xSceneProperties + , sal_Int32& rnHorizontalAngleDegree, sal_Int32& rnVerticalAngleDegree ) +{ + //todo: x and y is not equal to horz and vert in case of RightAngledAxes==false + + double fXAngle, fYAngle, fZAngle; + ThreeDHelper::getRotationAngleFromDiagram( xSceneProperties, fXAngle, fYAngle, fZAngle ); + + fXAngle = BaseGFXHelper::Rad2Deg( fXAngle ); + fYAngle = BaseGFXHelper::Rad2Deg( fYAngle ); + fZAngle = BaseGFXHelper::Rad2Deg( fZAngle ); + + rnHorizontalAngleDegree = ::basegfx::fround(fXAngle); + rnVerticalAngleDegree = ::basegfx::fround(-1.0*fYAngle); + //nZRotation = ::basegfx::fround(-1.0*fZAngle); + + lcl_shiftAngleToIntervalMinus180To180( rnHorizontalAngleDegree ); + lcl_shiftAngleToIntervalMinus180To180( rnVerticalAngleDegree ); +} + +void ThreeDHelper::setRotationToDiagram( const uno::Reference< beans::XPropertySet >& xSceneProperties + , sal_Int32 nHorizontalAngleDegree, sal_Int32 nVerticalYAngleDegree ) +{ + //todo: x and y is not equal to horz and vert in case of RightAngledAxes==false + double fXAngle = BaseGFXHelper::Deg2Rad( nHorizontalAngleDegree ); + double fYAngle = BaseGFXHelper::Deg2Rad( -1*nVerticalYAngleDegree ); + double fZAngle = 0.0; + + ThreeDHelper::setRotationAngleToDiagram( xSceneProperties, fXAngle, fYAngle, fZAngle ); +} + void ThreeDHelper::getCameraDistanceRange( double& rfMinimumDistance, double& rfMaximumDistance ) { rfMinimumDistance = 3.0/4.0*FIXED_SIZE_FOR_3D_CHART_VOLUME;//empiric value @@ -590,6 +630,38 @@ void ThreeDHelper::setCameraDistance( } //static +double ThreeDHelper::CameraDistanceToPerspective( double fCameraDistance ) +{ + double fRet = fCameraDistance; + double fMin, fMax; + ThreeDHelper::getCameraDistanceRange( fMin, fMax ); + //fMax <-> 0; fMin <->100 + //a/x + b = y + double a = 100.0*fMax*fMin/(fMax-fMin); + double b = -a/fMax; + + fRet = a/fCameraDistance + b; + + return fRet; +} + +//static +double ThreeDHelper::PerspectiveToCameraDistance( double fPerspective ) +{ + double fRet = fPerspective; + double fMin, fMax; + ThreeDHelper::getCameraDistanceRange( fMin, fMax ); + //fMax <-> 0; fMin <->100 + //a/x + b = y + double a = 100.0*fMax*fMin/(fMax-fMin); + double b = -a/fMax; + + fRet = a/(fPerspective - b); + + return fRet; +} + +//static ThreeDLookScheme ThreeDHelper::detectScheme( const uno::Reference< XDiagram >& xDiagram ) { ThreeDLookScheme aScheme = ThreeDLookScheme_Unknown; |