1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*cde9e8dcSAndrew Rist  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*cde9e8dcSAndrew Rist  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19*cde9e8dcSAndrew Rist  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "VPolarTransformation.hxx"
28cdf0e10cSrcweir #include "ViewDefines.hxx"
29cdf0e10cSrcweir #include "CommonConverters.hxx"
30cdf0e10cSrcweir #include <algorithm>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir using namespace ::com::sun::star;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
35cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace chart
38cdf0e10cSrcweir {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
VPolarTransformation(const PolarPlottingPositionHelper & rPositionHelper)41cdf0e10cSrcweir VPolarTransformation::VPolarTransformation( const PolarPlottingPositionHelper& rPositionHelper )
42cdf0e10cSrcweir         : m_aPositionHelper(rPositionHelper)
43cdf0e10cSrcweir         , m_aUnitCartesianToScene( rPositionHelper.getUnitCartesianToScene() )
44cdf0e10cSrcweir {
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
~VPolarTransformation()47cdf0e10cSrcweir VPolarTransformation::~VPolarTransformation()
48cdf0e10cSrcweir {
49cdf0e10cSrcweir }
50cdf0e10cSrcweir 
51cdf0e10cSrcweir // ____ XTransformation ____
transform(const Sequence<double> & rSourceValues)52cdf0e10cSrcweir Sequence< double > SAL_CALL VPolarTransformation::transform(
53cdf0e10cSrcweir                         const Sequence< double >& rSourceValues )
54cdf0e10cSrcweir     throw (RuntimeException,
55cdf0e10cSrcweir            lang::IllegalArgumentException)
56cdf0e10cSrcweir {
57cdf0e10cSrcweir     double fScaledLogicAngle  = rSourceValues[0];
58cdf0e10cSrcweir     double fScaledLogicRadius = rSourceValues[1];
59cdf0e10cSrcweir 
60cdf0e10cSrcweir     if( m_aPositionHelper.isSwapXAndY() )
61cdf0e10cSrcweir         std::swap(fScaledLogicAngle,fScaledLogicRadius);
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     double fAngleDegree = m_aPositionHelper.transformToAngleDegree( fScaledLogicAngle, false );
64cdf0e10cSrcweir     double fAnglePi     = fAngleDegree*F_PI/180.0;
65cdf0e10cSrcweir     double fRadius      = m_aPositionHelper.transformToRadius( fScaledLogicRadius, false);
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     double fX=fRadius*cos(fAnglePi);
68cdf0e10cSrcweir     double fY=fRadius*sin(fAnglePi);
69cdf0e10cSrcweir     double fZ=rSourceValues[2];
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     //!! applying matrix to vector does ignore translation, so it is important to use a B3DPoint here instead of B3DVector
72cdf0e10cSrcweir     ::basegfx::B3DPoint aPoint(fX,fY,fZ);
73cdf0e10cSrcweir     ::basegfx::B3DPoint aRet = m_aUnitCartesianToScene * aPoint;
74cdf0e10cSrcweir     return B3DPointToSequence(aRet);
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
getSourceDimension()77cdf0e10cSrcweir sal_Int32 SAL_CALL VPolarTransformation::getSourceDimension()
78cdf0e10cSrcweir     throw (RuntimeException)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     return 3;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
getTargetDimension()83cdf0e10cSrcweir sal_Int32 SAL_CALL VPolarTransformation::getTargetDimension()
84cdf0e10cSrcweir     throw (RuntimeException)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir     return 3;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
90cdf0e10cSrcweir }  // namespace chart
91