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