/src/libreoffice/chart2/source/view/main/VPolarTransformation.cxx
Line | Count | Source (jump to first uncovered line) |
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 | | |
22 | | using namespace ::com::sun::star; |
23 | | |
24 | | using ::com::sun::star::uno::Sequence; |
25 | | |
26 | | namespace chart |
27 | | { |
28 | | |
29 | | VPolarTransformation::VPolarTransformation( const PolarPlottingPositionHelper& rPositionHelper ) |
30 | 0 | : m_aPositionHelper(rPositionHelper) |
31 | 0 | , m_aUnitCartesianToScene( rPositionHelper.getUnitCartesianToScene() ) |
32 | 0 | { |
33 | 0 | } |
34 | | |
35 | | VPolarTransformation::~VPolarTransformation() |
36 | 0 | { |
37 | 0 | } |
38 | | |
39 | | // ____ XTransformation2 ____ |
40 | | css::drawing::Position3D VPolarTransformation::transform( |
41 | | const Sequence< double >& rSourceValues ) const |
42 | 0 | { |
43 | 0 | double fScaledLogicAngle = rSourceValues[0]; |
44 | 0 | double fScaledLogicRadius = rSourceValues[1]; |
45 | |
|
46 | 0 | if( m_aPositionHelper.isSwapXAndY() ) |
47 | 0 | std::swap(fScaledLogicAngle,fScaledLogicRadius); |
48 | |
|
49 | 0 | double fAngleDegree = m_aPositionHelper.transformToAngleDegree( fScaledLogicAngle, false ); |
50 | 0 | double fAnglePi = basegfx::deg2rad(fAngleDegree); |
51 | 0 | double fRadius = m_aPositionHelper.transformToRadius( fScaledLogicRadius, false); |
52 | |
|
53 | 0 | double fX=fRadius*cos(fAnglePi); |
54 | 0 | double fY=fRadius*sin(fAnglePi); |
55 | 0 | double fZ=rSourceValues[2]; |
56 | | |
57 | | //!! applying matrix to vector does ignore translation, so it is important to use a B3DPoint here instead of B3DVector |
58 | 0 | ::basegfx::B3DPoint aPoint(fX,fY,fZ); |
59 | 0 | ::basegfx::B3DPoint aRet = m_aUnitCartesianToScene * aPoint; |
60 | 0 | return css::drawing::Position3D(aRet.getX(), aRet.getY(), aRet.getZ()); |
61 | 0 | } |
62 | | |
63 | | css::drawing::Position3D VPolarTransformation::transform( |
64 | | const css::drawing::Position3D& rSourceValues ) const |
65 | 0 | { |
66 | 0 | double fScaledLogicAngle = rSourceValues.PositionX; |
67 | 0 | double fScaledLogicRadius = rSourceValues.PositionY; |
68 | |
|
69 | 0 | if( m_aPositionHelper.isSwapXAndY() ) |
70 | 0 | std::swap(fScaledLogicAngle,fScaledLogicRadius); |
71 | |
|
72 | 0 | double fAngleDegree = m_aPositionHelper.transformToAngleDegree( fScaledLogicAngle, false ); |
73 | 0 | double fAnglePi = basegfx::deg2rad(fAngleDegree); |
74 | 0 | double fRadius = m_aPositionHelper.transformToRadius( fScaledLogicRadius, false); |
75 | |
|
76 | 0 | double fX=fRadius*cos(fAnglePi); |
77 | 0 | double fY=fRadius*sin(fAnglePi); |
78 | 0 | double fZ=rSourceValues.PositionZ; |
79 | | |
80 | | //!! applying matrix to vector does ignore translation, so it is important to use a B3DPoint here instead of B3DVector |
81 | 0 | ::basegfx::B3DPoint aPoint(fX,fY,fZ); |
82 | 0 | ::basegfx::B3DPoint aRet = m_aUnitCartesianToScene * aPoint; |
83 | 0 | return css::drawing::Position3D(aRet.getX(), aRet.getY(), aRet.getZ()); |
84 | 0 | } |
85 | | |
86 | | } // namespace chart |
87 | | |
88 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |