xref: /trunk/main/chart2/source/view/main/VPolarTransformation.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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_chartview.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 {
55     double fScaledLogicAngle  = rSourceValues[0];
56     double fScaledLogicRadius = rSourceValues[1];
57 
58     if( m_aPositionHelper.isSwapXAndY() )
59         std::swap(fScaledLogicAngle,fScaledLogicRadius);
60 
61     double fAngleDegree = m_aPositionHelper.transformToAngleDegree( fScaledLogicAngle, false );
62     double fAnglePi     = fAngleDegree*F_PI/180.0;
63     double fRadius      = m_aPositionHelper.transformToRadius( fScaledLogicRadius, false);
64 
65     double fX=fRadius*cos(fAnglePi);
66     double fY=fRadius*sin(fAnglePi);
67     double fZ=rSourceValues[2];
68 
69     //!! applying matrix to vector does ignore translation, so it is important to use a B3DPoint here instead of B3DVector
70     ::basegfx::B3DPoint aPoint(fX,fY,fZ);
71     ::basegfx::B3DPoint aRet = m_aUnitCartesianToScene * aPoint;
72     return B3DPointToSequence(aRet);
73 }
74 
getSourceDimension()75 sal_Int32 SAL_CALL VPolarTransformation::getSourceDimension()
76 {
77     return 3;
78 }
79 
getTargetDimension()80 sal_Int32 SAL_CALL VPolarTransformation::getTargetDimension()
81 {
82     return 3;
83 }
84 
85 
86 }  // namespace chart
87