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