Line data Source code
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 :
21 : #include "VPolarTransformation.hxx"
22 : #include "ViewDefines.hxx"
23 : #include "CommonConverters.hxx"
24 : #include <algorithm>
25 :
26 : using namespace ::com::sun::star;
27 :
28 : using ::com::sun::star::uno::Sequence;
29 : using ::com::sun::star::uno::RuntimeException;
30 :
31 : namespace chart
32 : {
33 :
34 :
35 0 : VPolarTransformation::VPolarTransformation( const PolarPlottingPositionHelper& rPositionHelper )
36 : : m_aPositionHelper(rPositionHelper)
37 0 : , m_aUnitCartesianToScene( rPositionHelper.getUnitCartesianToScene() )
38 : {
39 0 : }
40 :
41 0 : VPolarTransformation::~VPolarTransformation()
42 : {
43 0 : }
44 :
45 : // ____ XTransformation ____
46 0 : Sequence< double > SAL_CALL VPolarTransformation::transform(
47 : const Sequence< double >& rSourceValues )
48 : throw (RuntimeException,
49 : lang::IllegalArgumentException)
50 : {
51 0 : double fScaledLogicAngle = rSourceValues[0];
52 0 : double fScaledLogicRadius = rSourceValues[1];
53 :
54 0 : if( m_aPositionHelper.isSwapXAndY() )
55 0 : std::swap(fScaledLogicAngle,fScaledLogicRadius);
56 :
57 0 : double fAngleDegree = m_aPositionHelper.transformToAngleDegree( fScaledLogicAngle, false );
58 0 : double fAnglePi = fAngleDegree*F_PI/180.0;
59 0 : double fRadius = m_aPositionHelper.transformToRadius( fScaledLogicRadius, false);
60 :
61 0 : double fX=fRadius*cos(fAnglePi);
62 0 : double fY=fRadius*sin(fAnglePi);
63 0 : double fZ=rSourceValues[2];
64 :
65 : //!! applying matrix to vector does ignore translation, so it is important to use a B3DPoint here instead of B3DVector
66 0 : ::basegfx::B3DPoint aPoint(fX,fY,fZ);
67 0 : ::basegfx::B3DPoint aRet = m_aUnitCartesianToScene * aPoint;
68 0 : return B3DPointToSequence(aRet);
69 : }
70 :
71 0 : sal_Int32 SAL_CALL VPolarTransformation::getSourceDimension()
72 : throw (RuntimeException)
73 : {
74 0 : return 3;
75 : }
76 :
77 0 : sal_Int32 SAL_CALL VPolarTransformation::getTargetDimension()
78 : throw (RuntimeException)
79 : {
80 0 : return 3;
81 : }
82 :
83 :
84 : } // namespace chart
85 :
86 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|