merge the formfield patch from ooo-build
[ooovba.git] / chart2 / source / view / main / VPolarTransformation.cxx
blob5c6504fadbbadaa77f4cf84773e3dca851b1c50c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: VPolarTransformation.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "VPolarTransformation.hxx"
35 #include "ViewDefines.hxx"
36 #include "CommonConverters.hxx"
37 #include <algorithm>
39 using namespace ::com::sun::star;
41 using ::com::sun::star::uno::Sequence;
42 using ::com::sun::star::uno::RuntimeException;
44 namespace chart
48 VPolarTransformation::VPolarTransformation( const PolarPlottingPositionHelper& rPositionHelper )
49 : m_aPositionHelper(rPositionHelper)
50 , m_aUnitCartesianToScene( rPositionHelper.getUnitCartesianToScene() )
54 VPolarTransformation::~VPolarTransformation()
58 // ____ XTransformation ____
59 Sequence< double > SAL_CALL VPolarTransformation::transform(
60 const Sequence< double >& rSourceValues )
61 throw (RuntimeException,
62 lang::IllegalArgumentException)
64 double fScaledLogicAngle = rSourceValues[0];
65 double fScaledLogicRadius = rSourceValues[1];
67 if( m_aPositionHelper.isSwapXAndY() )
68 std::swap(fScaledLogicAngle,fScaledLogicRadius);
70 double fAngleDegree = m_aPositionHelper.transformToAngleDegree( fScaledLogicAngle, false );
71 double fAnglePi = fAngleDegree*F_PI/180.0;
72 double fRadius = m_aPositionHelper.transformToRadius( fScaledLogicRadius, false);
74 double fX=fRadius*cos(fAnglePi);
75 double fY=fRadius*sin(fAnglePi);
76 double fZ=rSourceValues[2];
78 //!! applying matrix to vector does ignore translation, so it is important to use a B3DPoint here instead of B3DVector
79 ::basegfx::B3DPoint aPoint(fX,fY,fZ);
80 ::basegfx::B3DPoint aRet = m_aUnitCartesianToScene * aPoint;
81 return B3DPointToSequence(aRet);
84 sal_Int32 SAL_CALL VPolarTransformation::getSourceDimension()
85 throw (RuntimeException)
87 return 3;
90 sal_Int32 SAL_CALL VPolarTransformation::getTargetDimension()
91 throw (RuntimeException)
93 return 3;
97 } // namespace chart