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