LCOV - code coverage report
Current view: top level - chart2/source/tools - BaseGFXHelper.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 95 95 100.0 %
Date: 2015-06-13 12:38:46 Functions: 16 16 100.0 %
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         386 : ::basegfx::B3DRange getBoundVolume( const drawing::PolyPolygonShape3D& rPolyPoly )
      33             : {
      34         386 :     ::basegfx::B3DRange aRet;
      35             : 
      36         386 :     bool bInited = false;
      37         386 :     sal_Int32 nPolyCount = rPolyPoly.SequenceX.getLength();
      38         780 :     for(sal_Int32 nPoly = 0; nPoly < nPolyCount; nPoly++)
      39             :     {
      40         394 :         sal_Int32 nPointCount = rPolyPoly.SequenceX[nPoly].getLength();
      41        3686 :         for( sal_Int32 nPoint = 0; nPoint < nPointCount; nPoint++)
      42             :         {
      43        3292 :             if(!bInited)
      44             :             {
      45             :                 aRet = ::basegfx::B3DRange(::basegfx::B3DTuple(
      46         386 :                           rPolyPoly.SequenceX[nPoly][nPoint]
      47         386 :                         , rPolyPoly.SequenceY[nPoly][nPoint]
      48        1158 :                         , rPolyPoly.SequenceZ[nPoly][nPoint]));
      49         386 :                 bInited = true;
      50             :             }
      51             :             else
      52             :             {
      53             :                 aRet.expand( ::basegfx::B3DTuple(
      54        2906 :                           rPolyPoly.SequenceX[nPoly][nPoint]
      55        2906 :                         , rPolyPoly.SequenceY[nPoly][nPoint]
      56        8718 :                         , rPolyPoly.SequenceZ[nPoly][nPoint]));
      57             :             }
      58             :         }
      59             :     }
      60             : 
      61         386 :     return aRet;
      62             : }
      63             : 
      64       46443 : B2IRectangle makeRectangle( const awt::Point& rPos, const awt::Size& rSize )
      65             : {
      66       46443 :     return B2IRectangle(rPos.X,rPos.Y,rPos.X+rSize.Width,rPos.Y+rSize.Height);
      67             : }
      68             : 
      69        1053 : B2IRectangle makeRectangle( const awt::Rectangle& rRect )
      70             : {
      71        1053 :     return B2IRectangle(rRect.X, rRect.Y, rRect.X+rRect.Width, rRect.Y+rRect.Height);
      72             : }
      73             : 
      74        3070 : awt::Point B2IRectangleToAWTPoint( const ::basegfx::B2IRectangle& rB2IRectangle )
      75             : {
      76        3070 :     return awt::Point( rB2IRectangle.getMinX(), rB2IRectangle.getMinY() );
      77             : }
      78             : 
      79        3070 : awt::Size B2IRectangleToAWTSize( const ::basegfx::B2IRectangle& rB2IRectangle )
      80             : {
      81        3070 :     return awt::Size( static_cast< sal_Int32 >( rB2IRectangle.getWidth()),
      82        6140 :                       static_cast< sal_Int32 >( rB2IRectangle.getHeight()));
      83             : }
      84             : 
      85        1266 : B3DVector Direction3DToB3DVector( const Direction3D& rDirection )
      86             : {
      87             :     return B3DVector(
      88             :           rDirection.DirectionX
      89             :         , rDirection.DirectionY
      90             :         , rDirection.DirectionZ
      91        1266 :         );
      92             : }
      93             : 
      94          12 : Direction3D B3DVectorToDirection3D( const B3DVector& rB3DVector )
      95             : {
      96             :     return Direction3D(
      97          12 :           rB3DVector.getX()
      98          12 :         , rB3DVector.getY()
      99          12 :         , rB3DVector.getZ()
     100          36 :         );
     101             : }
     102             : 
     103         104 : B3DVector Position3DToB3DVector( const Position3D& rPosition )
     104             : {
     105             :     return B3DVector(
     106             :           rPosition.PositionX
     107             :         , rPosition.PositionY
     108             :         , rPosition.PositionZ
     109         104 :         );
     110             : }
     111             : 
     112          36 : Position3D B3DVectorToPosition3D( const B3DVector& rB3DVector )
     113             : {
     114             :     return Position3D(
     115          36 :           rB3DVector.getX()
     116          36 :         , rB3DVector.getY()
     117          36 :         , rB3DVector.getZ()
     118         108 :         );
     119             : }
     120             : 
     121        2276 : B3DHomMatrix HomogenMatrixToB3DHomMatrix( const HomogenMatrix & rHomogenMatrix )
     122             : {
     123        2276 :     B3DHomMatrix aResult;
     124             : 
     125        2276 :     aResult.set( 0, 0, rHomogenMatrix.Line1.Column1 );
     126        2276 :     aResult.set( 0, 1, rHomogenMatrix.Line1.Column2 );
     127        2276 :     aResult.set( 0, 2, rHomogenMatrix.Line1.Column3 );
     128        2276 :     aResult.set( 0, 3, rHomogenMatrix.Line1.Column4 );
     129             : 
     130        2276 :     aResult.set( 1, 0, rHomogenMatrix.Line2.Column1 );
     131        2276 :     aResult.set( 1, 1, rHomogenMatrix.Line2.Column2 );
     132        2276 :     aResult.set( 1, 2, rHomogenMatrix.Line2.Column3 );
     133        2276 :     aResult.set( 1, 3, rHomogenMatrix.Line2.Column4 );
     134             : 
     135        2276 :     aResult.set( 2, 0, rHomogenMatrix.Line3.Column1 );
     136        2276 :     aResult.set( 2, 1, rHomogenMatrix.Line3.Column2 );
     137        2276 :     aResult.set( 2, 2, rHomogenMatrix.Line3.Column3 );
     138        2276 :     aResult.set( 2, 3, rHomogenMatrix.Line3.Column4 );
     139             : 
     140        2276 :     aResult.set( 3, 0, rHomogenMatrix.Line4.Column1 );
     141        2276 :     aResult.set( 3, 1, rHomogenMatrix.Line4.Column2 );
     142        2276 :     aResult.set( 3, 2, rHomogenMatrix.Line4.Column3 );
     143        2276 :     aResult.set( 3, 3, rHomogenMatrix.Line4.Column4 );
     144             : 
     145        2276 :     return aResult;
     146             : }
     147             : 
     148         418 : HomogenMatrix B3DHomMatrixToHomogenMatrix( const B3DHomMatrix & rB3DMatrix )
     149             : {
     150         418 :     HomogenMatrix aResult;
     151             : 
     152         418 :     aResult.Line1.Column1 = rB3DMatrix.get( 0, 0 );
     153         418 :     aResult.Line1.Column2 = rB3DMatrix.get( 0, 1 );
     154         418 :     aResult.Line1.Column3 = rB3DMatrix.get( 0, 2 );
     155         418 :     aResult.Line1.Column4 = rB3DMatrix.get( 0, 3 );
     156             : 
     157         418 :     aResult.Line2.Column1 = rB3DMatrix.get( 1, 0 );
     158         418 :     aResult.Line2.Column2 = rB3DMatrix.get( 1, 1 );
     159         418 :     aResult.Line2.Column3 = rB3DMatrix.get( 1, 2 );
     160         418 :     aResult.Line2.Column4 = rB3DMatrix.get( 1, 3 );
     161             : 
     162         418 :     aResult.Line3.Column1 = rB3DMatrix.get( 2, 0 );
     163         418 :     aResult.Line3.Column2 = rB3DMatrix.get( 2, 1 );
     164         418 :     aResult.Line3.Column3 = rB3DMatrix.get( 2, 2 );
     165         418 :     aResult.Line3.Column4 = rB3DMatrix.get( 2, 3 );
     166             : 
     167         418 :     aResult.Line4.Column1 = rB3DMatrix.get( 3, 0 );
     168         418 :     aResult.Line4.Column2 = rB3DMatrix.get( 3, 1 );
     169         418 :     aResult.Line4.Column3 = rB3DMatrix.get( 3, 2 );
     170         418 :     aResult.Line4.Column4 = rB3DMatrix.get( 3, 3 );
     171             : 
     172         418 :     return aResult;
     173             : }
     174             : 
     175        1841 : B3DTuple GetRotationFromMatrix( const B3DHomMatrix & rB3DMatrix )
     176             : {
     177        3682 :     B3DTuple aScale, aTranslation, aRotation, aShearing;
     178        1841 :     rB3DMatrix.decompose( aScale, aTranslation, aRotation, aShearing );
     179        3682 :     return aRotation;
     180             : }
     181             : 
     182        1074 : B3DTuple GetScaleFromMatrix( const B3DHomMatrix & rB3DMatrix )
     183             : {
     184        2148 :     B3DTuple aScale, aTranslation, aRotation, aShearing;
     185        1074 :     rB3DMatrix.decompose( aScale, aTranslation, aRotation, aShearing );
     186        2148 :     return aScale;
     187             : }
     188             : 
     189        1194 : void ReduceToRotationMatrix( ::basegfx::B3DHomMatrix & rB3DMatrix )
     190             : {
     191        1194 :     B3DTuple aR( GetRotationFromMatrix( rB3DMatrix ) );
     192        2388 :     ::basegfx::B3DHomMatrix aRotationMatrix;
     193        1194 :     aRotationMatrix.rotate(aR.getX(),aR.getY(),aR.getZ());
     194        2388 :     rB3DMatrix = aRotationMatrix;
     195        1194 : }
     196             : 
     197         648 : double Deg2Rad( double fDegrees )
     198             : {
     199         648 :     return fDegrees * ( F_PI / 180.0 );
     200             : }
     201             : 
     202         278 : double Rad2Deg( double fRadians )
     203             : {
     204         278 :     return fRadians * ( 180.0 / F_PI );
     205             : }
     206             : 
     207             : } //  namespace BaseGFXHelper
     208             : } //  namespace chart
     209             : 
     210             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11