LCOV - code coverage report
Current view: top level - chart2/source/tools - BaseGFXHelper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 95 99 96.0 %
Date: 2014-11-03 Functions: 16 17 94.1 %
Legend: Lines: hit not hit

          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 "BaseGFXHelper.hxx"
      21             : #include <com/sun/star/drawing/DoubleSequence.hpp>
      22             : 
      23             : using namespace ::com::sun::star;
      24             : using namespace ::com::sun::star::drawing;
      25             : using namespace ::basegfx;
      26             : 
      27             : namespace chart
      28             : {
      29             : namespace BaseGFXHelper
      30             : {
      31             : 
      32         415 : ::basegfx::B3DRange getBoundVolume( const drawing::PolyPolygonShape3D& rPolyPoly )
      33             : {
      34         415 :     ::basegfx::B3DRange aRet;
      35             : 
      36         415 :     bool bInited = false;
      37         415 :     sal_Int32 nPolyCount = rPolyPoly.SequenceX.getLength();
      38         830 :     for(sal_Int32 nPoly = 0; nPoly < nPolyCount; nPoly++)
      39             :     {
      40         415 :         sal_Int32 nPointCount = rPolyPoly.SequenceX[nPoly].getLength();
      41        4282 :         for( sal_Int32 nPoint = 0; nPoint < nPointCount; nPoint++)
      42             :         {
      43        3867 :             if(!bInited)
      44             :             {
      45             :                 aRet = ::basegfx::B3DRange(::basegfx::B3DTuple(
      46         415 :                           rPolyPoly.SequenceX[nPoly][nPoint]
      47         415 :                         , rPolyPoly.SequenceY[nPoly][nPoint]
      48        1245 :                         , rPolyPoly.SequenceZ[nPoly][nPoint]));
      49         415 :                 bInited = true;
      50             :             }
      51             :             else
      52             :             {
      53             :                 aRet.expand( ::basegfx::B3DTuple(
      54        3452 :                           rPolyPoly.SequenceX[nPoly][nPoint]
      55        3452 :                         , rPolyPoly.SequenceY[nPoly][nPoint]
      56       10356 :                         , rPolyPoly.SequenceZ[nPoly][nPoint]));
      57             :             }
      58             :         }
      59             :     }
      60             : 
      61         415 :     return aRet;
      62             : }
      63             : 
      64       25488 : B2IRectangle makeRectangle( const awt::Point& rPos, const awt::Size& rSize )
      65             : {
      66       25488 :     return B2IRectangle(rPos.X,rPos.Y,rPos.X+rSize.Width,rPos.Y+rSize.Height);
      67             : }
      68             : 
      69         544 : B2IRectangle makeRectangle( const awt::Rectangle& rRect )
      70             : {
      71         544 :     return B2IRectangle(rRect.X, rRect.Y, rRect.X+rRect.Width, rRect.Y+rRect.Height);
      72             : }
      73             : 
      74        1580 : awt::Point B2IRectangleToAWTPoint( const ::basegfx::B2IRectangle& rB2IRectangle )
      75             : {
      76        1580 :     return awt::Point( rB2IRectangle.getMinX(), rB2IRectangle.getMinY() );
      77             : }
      78             : 
      79        1580 : awt::Size B2IRectangleToAWTSize( const ::basegfx::B2IRectangle& rB2IRectangle )
      80             : {
      81        1580 :     return awt::Size( static_cast< sal_Int32 >( rB2IRectangle.getWidth()),
      82        3160 :                       static_cast< sal_Int32 >( rB2IRectangle.getHeight()));
      83             : }
      84             : 
      85           0 : awt::Rectangle B2IRectangleToAWTRectangle(
      86             :     const ::basegfx::B2IRectangle& rB2IRectangle )
      87             : {
      88           0 :     return awt::Rectangle( rB2IRectangle.getMinX(), rB2IRectangle.getMinY(),
      89           0 :                            static_cast< sal_Int32 >( rB2IRectangle.getWidth()),
      90           0 :                            static_cast< sal_Int32 >( rB2IRectangle.getHeight()));
      91             : }
      92             : 
      93        1486 : B3DVector Direction3DToB3DVector( const Direction3D& rDirection )
      94             : {
      95             :     return B3DVector(
      96             :           rDirection.DirectionX
      97             :         , rDirection.DirectionY
      98             :         , rDirection.DirectionZ
      99        1486 :         );
     100             : }
     101             : 
     102          24 : Direction3D B3DVectorToDirection3D( const B3DVector& rB3DVector )
     103             : {
     104             :     return Direction3D(
     105          24 :           rB3DVector.getX()
     106          24 :         , rB3DVector.getY()
     107          24 :         , rB3DVector.getZ()
     108          72 :         );
     109             : }
     110             : 
     111         133 : B3DVector Position3DToB3DVector( const Position3D& rPosition )
     112             : {
     113             :     return B3DVector(
     114             :           rPosition.PositionX
     115             :         , rPosition.PositionY
     116             :         , rPosition.PositionZ
     117         133 :         );
     118             : }
     119             : 
     120          70 : Position3D B3DVectorToPosition3D( const B3DVector& rB3DVector )
     121             : {
     122             :     return Position3D(
     123          70 :           rB3DVector.getX()
     124          70 :         , rB3DVector.getY()
     125          70 :         , rB3DVector.getZ()
     126         210 :         );
     127             : }
     128             : 
     129        1916 : B3DHomMatrix HomogenMatrixToB3DHomMatrix( const HomogenMatrix & rHomogenMatrix )
     130             : {
     131        1916 :     B3DHomMatrix aResult;
     132             : 
     133        1916 :     aResult.set( 0, 0, rHomogenMatrix.Line1.Column1 );
     134        1916 :     aResult.set( 0, 1, rHomogenMatrix.Line1.Column2 );
     135        1916 :     aResult.set( 0, 2, rHomogenMatrix.Line1.Column3 );
     136        1916 :     aResult.set( 0, 3, rHomogenMatrix.Line1.Column4 );
     137             : 
     138        1916 :     aResult.set( 1, 0, rHomogenMatrix.Line2.Column1 );
     139        1916 :     aResult.set( 1, 1, rHomogenMatrix.Line2.Column2 );
     140        1916 :     aResult.set( 1, 2, rHomogenMatrix.Line2.Column3 );
     141        1916 :     aResult.set( 1, 3, rHomogenMatrix.Line2.Column4 );
     142             : 
     143        1916 :     aResult.set( 2, 0, rHomogenMatrix.Line3.Column1 );
     144        1916 :     aResult.set( 2, 1, rHomogenMatrix.Line3.Column2 );
     145        1916 :     aResult.set( 2, 2, rHomogenMatrix.Line3.Column3 );
     146        1916 :     aResult.set( 2, 3, rHomogenMatrix.Line3.Column4 );
     147             : 
     148        1916 :     aResult.set( 3, 0, rHomogenMatrix.Line4.Column1 );
     149        1916 :     aResult.set( 3, 1, rHomogenMatrix.Line4.Column2 );
     150        1916 :     aResult.set( 3, 2, rHomogenMatrix.Line4.Column3 );
     151        1916 :     aResult.set( 3, 3, rHomogenMatrix.Line4.Column4 );
     152             : 
     153        1916 :     return aResult;
     154             : }
     155             : 
     156         434 : HomogenMatrix B3DHomMatrixToHomogenMatrix( const B3DHomMatrix & rB3DMatrix )
     157             : {
     158         434 :     HomogenMatrix aResult;
     159             : 
     160         434 :     aResult.Line1.Column1 = rB3DMatrix.get( 0, 0 );
     161         434 :     aResult.Line1.Column2 = rB3DMatrix.get( 0, 1 );
     162         434 :     aResult.Line1.Column3 = rB3DMatrix.get( 0, 2 );
     163         434 :     aResult.Line1.Column4 = rB3DMatrix.get( 0, 3 );
     164             : 
     165         434 :     aResult.Line2.Column1 = rB3DMatrix.get( 1, 0 );
     166         434 :     aResult.Line2.Column2 = rB3DMatrix.get( 1, 1 );
     167         434 :     aResult.Line2.Column3 = rB3DMatrix.get( 1, 2 );
     168         434 :     aResult.Line2.Column4 = rB3DMatrix.get( 1, 3 );
     169             : 
     170         434 :     aResult.Line3.Column1 = rB3DMatrix.get( 2, 0 );
     171         434 :     aResult.Line3.Column2 = rB3DMatrix.get( 2, 1 );
     172         434 :     aResult.Line3.Column3 = rB3DMatrix.get( 2, 2 );
     173         434 :     aResult.Line3.Column4 = rB3DMatrix.get( 2, 3 );
     174             : 
     175         434 :     aResult.Line4.Column1 = rB3DMatrix.get( 3, 0 );
     176         434 :     aResult.Line4.Column2 = rB3DMatrix.get( 3, 1 );
     177         434 :     aResult.Line4.Column3 = rB3DMatrix.get( 3, 2 );
     178         434 :     aResult.Line4.Column4 = rB3DMatrix.get( 3, 3 );
     179             : 
     180         434 :     return aResult;
     181             : }
     182             : 
     183        2121 : B3DTuple GetRotationFromMatrix( const B3DHomMatrix & rB3DMatrix )
     184             : {
     185        4242 :     B3DTuple aScale, aTranslation, aRotation, aShearing;
     186        2121 :     rB3DMatrix.decompose( aScale, aTranslation, aRotation, aShearing );
     187        4242 :     return aRotation;
     188             : }
     189             : 
     190         550 : B3DTuple GetScaleFromMatrix( const B3DHomMatrix & rB3DMatrix )
     191             : {
     192        1100 :     B3DTuple aScale, aTranslation, aRotation, aShearing;
     193         550 :     rB3DMatrix.decompose( aScale, aTranslation, aRotation, aShearing );
     194        1100 :     return aScale;
     195             : }
     196             : 
     197        1346 : void ReduceToRotationMatrix( ::basegfx::B3DHomMatrix & rB3DMatrix )
     198             : {
     199        1346 :     B3DTuple aR( GetRotationFromMatrix( rB3DMatrix ) );
     200        2692 :     ::basegfx::B3DHomMatrix aRotationMatrix;
     201        1346 :     aRotationMatrix.rotate(aR.getX(),aR.getY(),aR.getZ());
     202        2692 :     rB3DMatrix = aRotationMatrix;
     203        1346 : }
     204             : 
     205         504 : double Deg2Rad( double fDegrees )
     206             : {
     207         504 :     return fDegrees * ( F_PI / 180.0 );
     208             : }
     209             : 
     210         544 : double Rad2Deg( double fRadians )
     211             : {
     212         544 :     return fRadians * ( 180.0 / F_PI );
     213             : }
     214             : 
     215             : } //  namespace BaseGFXHelper
     216             : } //  namespace chart
     217             : 
     218             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10