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

Generated by: LCOV version 1.10