LCOV - code coverage report
Current view: top level - slideshow/source/engine/transitions - spiralwipe.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 58 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 4 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             : 
      21             : #include <canvas/debug.hxx>
      22             : #include "spiralwipe.hxx"
      23             : #include "transitiontools.hxx"
      24             : 
      25             : #include <basegfx/matrix/b2dhommatrix.hxx>
      26             : #include <basegfx/polygon/b2dpolygon.hxx>
      27             : #include <basegfx/numeric/ftools.hxx>
      28             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      29             : 
      30             : 
      31             : namespace slideshow {
      32             : namespace internal {
      33             : 
      34           0 : SpiralWipe::SpiralWipe( sal_Int32 nElements, bool flipOnYAxis )
      35             :     : m_elements(nElements),
      36             :       m_sqrtElements( static_cast<sal_Int32>(
      37           0 :                           sqrt( static_cast<double>(nElements) ) ) ),
      38           0 :       m_flipOnYAxis(flipOnYAxis)
      39             : {
      40           0 : }
      41             : 
      42           0 : ::basegfx::B2DPolyPolygon SpiralWipe::calcNegSpiral( double t ) const
      43             : {
      44           0 :     const double area = (t * m_elements);
      45           0 :     const double e = (sqrt(area) / 2.0);
      46           0 :     const sal_Int32 edge = (static_cast<sal_Int32>(e) * 2);
      47             : 
      48           0 :     basegfx::B2DHomMatrix aTransform(basegfx::tools::createTranslateB2DHomMatrix(-0.5, -0.5));
      49             :     const double edge_ = ::basegfx::pruneScaleValue(
      50           0 :         static_cast<double>(edge) / m_sqrtElements );
      51           0 :     aTransform.scale( edge_, edge_ );
      52           0 :     aTransform.translate( 0.5, 0.5 );
      53           0 :     ::basegfx::B2DPolygon poly( createUnitRect() );
      54           0 :     poly.transform( aTransform );
      55           0 :     ::basegfx::B2DPolyPolygon res(poly);
      56             : 
      57           0 :     if (! ::basegfx::fTools::equalZero( 1.0 - t )) {
      58           0 :         const sal_Int32 edge1 = (edge + 1);
      59           0 :         sal_Int32 len = static_cast<sal_Int32>( (e - (edge /2)) * edge1 * 4 );
      60           0 :         double w = M_PI_2;
      61           0 :         while (len > 0) {
      62           0 :             const sal_Int32 alen = (len > edge1 ? edge1 : len);
      63           0 :             len -= alen;
      64           0 :             poly = createUnitRect();
      65           0 :             aTransform = basegfx::tools::createScaleB2DHomMatrix(
      66             :                 ::basegfx::pruneScaleValue( static_cast<double>(alen) / m_sqrtElements ),
      67           0 :                 ::basegfx::pruneScaleValue( 1.0 / m_sqrtElements ) );
      68             :             aTransform.translate(
      69             :                 - ::basegfx::pruneScaleValue(
      70           0 :                     static_cast<double>(edge / 2) / m_sqrtElements ),
      71             :                 ::basegfx::pruneScaleValue(
      72           0 :                     static_cast<double>(edge / 2) / m_sqrtElements ) );
      73           0 :             aTransform.rotate( w );
      74           0 :             w -= M_PI_2;
      75           0 :             aTransform.translate( 0.5, 0.5 );
      76           0 :             poly.transform( aTransform );
      77           0 :             res.append(poly);
      78             :         }
      79             :     }
      80             : 
      81           0 :     return res;
      82             : }
      83             : 
      84           0 : ::basegfx::B2DPolyPolygon SpiralWipe::operator () ( double t )
      85             : {
      86           0 :     ::basegfx::B2DPolyPolygon res( createUnitRect() );
      87           0 :     ::basegfx::B2DPolyPolygon innerSpiral( calcNegSpiral( 1.0 - t ) );
      88           0 :     innerSpiral.flip();
      89           0 :     res.append(innerSpiral);
      90           0 :     return m_flipOnYAxis ? flipOnYAxis(res) : res;
      91             : }
      92             : 
      93           0 : ::basegfx::B2DPolyPolygon BoxSnakesWipe::operator () ( double t )
      94             : {
      95           0 :     ::basegfx::B2DPolyPolygon res( createUnitRect() );
      96           0 :     ::basegfx::B2DPolyPolygon innerSpiral( calcNegSpiral( 1.0 - t ) );
      97           0 :     innerSpiral.flip();
      98             : 
      99           0 :     if (m_fourBox) {
     100           0 :         ::basegfx::B2DHomMatrix aTransform;
     101           0 :         aTransform.scale( 0.5, 0.5 );
     102           0 :         innerSpiral.transform( aTransform );
     103           0 :         res.append(innerSpiral);
     104           0 :         res.append( flipOnXAxis(innerSpiral) );
     105           0 :         innerSpiral = flipOnYAxis(innerSpiral);
     106           0 :         res.append(innerSpiral);
     107           0 :         res.append( flipOnXAxis(innerSpiral) );
     108             :     }
     109             :     else {
     110           0 :         ::basegfx::B2DHomMatrix aTransform;
     111           0 :         aTransform.scale( 1.0, 0.5 );
     112           0 :         innerSpiral.transform( aTransform );
     113           0 :         res.append(innerSpiral);
     114           0 :         res.append( flipOnXAxis(innerSpiral) );
     115             :     }
     116             : 
     117           0 :     return m_flipOnYAxis ? flipOnYAxis(res) : res;
     118             : }
     119             : 
     120             : }
     121             : }
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11