1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20 #include <VPolarTransformation.hxx>
21 #include <CommonConverters.hxx>
22
23 using namespace ::com::sun::star;
24
25 using ::com::sun::star::uno::Sequence;
26
27 namespace chart
28 {
29
VPolarTransformation(const PolarPlottingPositionHelper & rPositionHelper)30 VPolarTransformation::VPolarTransformation( const PolarPlottingPositionHelper& rPositionHelper )
31 : m_aPositionHelper(rPositionHelper)
32 , m_aUnitCartesianToScene( rPositionHelper.getUnitCartesianToScene() )
33 {
34 }
35
~VPolarTransformation()36 VPolarTransformation::~VPolarTransformation()
37 {
38 }
39
40 // ____ XTransformation ____
transform(const Sequence<double> & rSourceValues)41 Sequence< double > SAL_CALL VPolarTransformation::transform(
42 const Sequence< double >& rSourceValues )
43 {
44 double fScaledLogicAngle = rSourceValues[0];
45 double fScaledLogicRadius = rSourceValues[1];
46
47 if( m_aPositionHelper.isSwapXAndY() )
48 std::swap(fScaledLogicAngle,fScaledLogicRadius);
49
50 double fAngleDegree = m_aPositionHelper.transformToAngleDegree( fScaledLogicAngle, false );
51 double fAnglePi = basegfx::deg2rad(fAngleDegree);
52 double fRadius = m_aPositionHelper.transformToRadius( fScaledLogicRadius, false);
53
54 double fX=fRadius*cos(fAnglePi);
55 double fY=fRadius*sin(fAnglePi);
56 double fZ=rSourceValues[2];
57
58 //!! applying matrix to vector does ignore translation, so it is important to use a B3DPoint here instead of B3DVector
59 ::basegfx::B3DPoint aPoint(fX,fY,fZ);
60 ::basegfx::B3DPoint aRet = m_aUnitCartesianToScene * aPoint;
61 return B3DPointToSequence(aRet);
62 }
63
getSourceDimension()64 sal_Int32 SAL_CALL VPolarTransformation::getSourceDimension()
65 {
66 return 3;
67 }
68
getTargetDimension()69 sal_Int32 SAL_CALL VPolarTransformation::getTargetDimension()
70 {
71 return 3;
72 }
73
74 } // namespace chart
75
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
77