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