LCOV - code coverage report
Current view: top level - chart2/source/tools - BaseGFXHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 85 97 87.6 %
Date: 2012-08-25 Functions: 13 16 81.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 36 66 54.5 %

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

Generated by: LCOV version 1.10