LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/basegfx/tools - keystoplerp.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2012-08-25 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2008 by Sun Microsystems, Inc.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _BGFX_TOOLS_KEYSTOPLERP_HXX
      30                 :            : #define _BGFX_TOOLS_KEYSTOPLERP_HXX
      31                 :            : 
      32                 :            : #include <basegfx/numeric/ftools.hxx>
      33                 :            : #include <vector>
      34                 :            : #include <basegfx/basegfxdllapi.h>
      35                 :            : 
      36                 :            : namespace com{ namespace sun{ namespace star{ namespace uno {
      37                 :            :     template<typename T> class Sequence;
      38                 :            : }}}}
      39                 :            : 
      40                 :            : namespace basegfx
      41                 :            : {
      42                 :            :     namespace tools
      43                 :            :     {
      44                 :            :         /** Lerp in a vector of key stops
      45                 :            : 
      46                 :            :             This class holds a key stop vector and provides the
      47                 :            :             functionality to lerp inside it. Useful e.g. for
      48                 :            :             multi-stop gradients, or the SMIL key time activity.
      49                 :            : 
      50                 :            :             For those, given a global [0,1] lerp alpha, one need to
      51                 :            :             find the suitable bucket index from key stop vector, and
      52                 :            :             then calculate the relative alpha between the two buckets
      53                 :            :             found.
      54                 :            :          */
      55                 :          5 :         class BASEGFX_DLLPUBLIC KeyStopLerp
      56                 :            :         {
      57                 :            :         public:
      58                 :            :             typedef std::pair<std::ptrdiff_t,double> ResultType;
      59                 :            : 
      60                 :            :             /** Create lerper with given vector of stops
      61                 :            : 
      62                 :            :                 @param rKeyStops
      63                 :            : 
      64                 :            :                 Vector of stops, must contain at least two elements
      65                 :            :                 (though preferrably more, otherwise you probably don't
      66                 :            :                 need key stop lerping in the first place). All
      67                 :            :                 elements must be of monotonically increasing value.
      68                 :            :              */
      69                 :            :             explicit KeyStopLerp( const std::vector<double>& rKeyStops );
      70                 :            : 
      71                 :            :             /** Create lerper with given sequence of stops
      72                 :            : 
      73                 :            :                 @param rKeyStops
      74                 :            : 
      75                 :            :                 Sequence of stops, must contain at least two elements
      76                 :            :                 (though preferrably more, otherwise you probably don't
      77                 :            :                 need key stop lerping in the first place). All
      78                 :            :                 elements must be of monotonically increasing value.
      79                 :            :              */
      80                 :            :             explicit KeyStopLerp( const ::com::sun::star::uno::Sequence<double>& rKeyStops );
      81                 :            : 
      82                 :            :             /** Find two nearest bucket index & interpolate
      83                 :            : 
      84                 :            :                 @param fAlpha
      85                 :            :                 Find bucket index i, with keyStops[i] < fAlpha <=
      86                 :            :                 keyStops[i+1]. Return new alpha value in [0,1),
      87                 :            :                 proportional to fAlpha's position between keyStops[i]
      88                 :            :                 and keyStops[i+1]
      89                 :            :              */
      90                 :            :             ResultType lerp(double fAlpha) const;
      91                 :            : 
      92                 :            :         private:
      93                 :            :             std::vector<double>    maKeyStops;
      94                 :            :             mutable std::ptrdiff_t mnLastIndex;
      95                 :            :         };
      96                 :            :     }
      97                 :            : }
      98                 :            : 
      99                 :            : #endif
     100                 :            : 
     101                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10