LCOV - code coverage report
Current view: top level - chart2/source/view/axes - Tickmarks_Equidistant.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 12 100.0 %
Date: 2012-08-25 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 6 100.0 %

           Branch data     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                 :            : #ifndef _CHART2_TICKMARKS_EQUIDISTANT_HXX
      20                 :            : #define _CHART2_TICKMARKS_EQUIDISTANT_HXX
      21                 :            : 
      22                 :            : #include "Tickmarks.hxx"
      23                 :            : 
      24                 :            : //.............................................................................
      25                 :            : namespace chart
      26                 :            : {
      27                 :            : //.............................................................................
      28                 :            : 
      29                 :            : using ::basegfx::B2DVector;
      30                 :            : //-----------------------------------------------------------------------------
      31                 :            : /**
      32                 :            : */
      33                 :            : 
      34                 :            : class EquidistantTickIter : public TickIter
      35                 :            : {
      36                 :            : public:
      37                 :            :     EquidistantTickIter( const ::com::sun::star::uno::Sequence<
      38                 :            :                 ::com::sun::star::uno::Sequence< double > >& rTicks
      39                 :            :                 , const ExplicitIncrementData& rIncrement
      40                 :            :             , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
      41                 :            :     EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
      42                 :            :             , const ExplicitIncrementData& rIncrement
      43                 :            :             , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
      44                 :            :     virtual ~EquidistantTickIter();
      45                 :            : 
      46                 :            :     virtual double*     firstValue();
      47                 :            :     virtual double*     nextValue();
      48                 :            : 
      49                 :            :     virtual TickInfo*   firstInfo();
      50                 :            :     virtual TickInfo*   nextInfo();
      51                 :            : 
      52                 :            :     sal_Int32   getCurrentDepth() const { return m_nCurrentDepth; }
      53                 :            : 
      54                 :            : private: //methods
      55                 :            :     sal_Int32   getIntervalCount( sal_Int32 nDepth );
      56                 :            :     bool        isAtLastPartTick();
      57                 :            : 
      58                 :            :     void        initIter( sal_Int32 nMinDepth, sal_Int32 nMaxDepth );
      59                 :            :     sal_Int32   getStartDepth() const;
      60                 :            : 
      61                 :            :     bool        gotoFirst();
      62                 :            :     bool        gotoNext();
      63                 :            : 
      64                 :            : 
      65                 :      65241 :     double      getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const
      66                 :            :                 {
      67         [ +  + ]:      65241 :                     if(m_pSimpleTicks)
      68                 :      51526 :                         return (*m_pSimpleTicks)[nDepth][nIndex];
      69                 :            :                     else
      70                 :      65241 :                         return (((*m_pInfoTicks)[nDepth])[nIndex]).fScaledTickValue;
      71                 :            :                 }
      72                 :      25770 :     sal_Int32   getTickCount( sal_Int32 nDepth ) const
      73                 :            :                 {
      74         [ +  + ]:      25770 :                     if(m_pSimpleTicks)
      75                 :      12930 :                         return (*m_pSimpleTicks)[nDepth].getLength();
      76                 :            :                     else
      77                 :      25770 :                         return (*m_pInfoTicks)[nDepth].size();
      78                 :            :                 }
      79                 :       9033 :     sal_Int32   getMaxDepth() const
      80                 :            :                 {
      81         [ +  + ]:       9033 :                     if(m_pSimpleTicks)
      82                 :       6465 :                         return (*m_pSimpleTicks).getLength()-1;
      83                 :            :                     else
      84                 :       9033 :                         return (*m_pInfoTicks).size()-1;
      85                 :            :                 }
      86                 :            : 
      87                 :            : private: //member
      88                 :            :     const ::com::sun::star::uno::Sequence<
      89                 :            :         ::com::sun::star::uno::Sequence< double > >*  m_pSimpleTicks;
      90                 :            :     ::std::vector< ::std::vector< TickInfo > >*       m_pInfoTicks;
      91                 :            :     const ExplicitIncrementData& m_rIncrement;
      92                 :            :     //iteration from m_nMinDepth to m_nMaxDepth
      93                 :            :     sal_Int32   m_nMinDepth;
      94                 :            :     sal_Int32   m_nMaxDepth;
      95                 :            :     sal_Int32   m_nTickCount;
      96                 :            :     sal_Int32*  m_pnPositions; //current positions in the different sequences
      97                 :            :     sal_Int32*  m_pnPreParentCount; //the tickmarks do not start with a major tick always,
      98                 :            :                                     //the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark
      99                 :            :     bool*       m_pbIntervalFinished;
     100                 :            :     sal_Int32   m_nCurrentDepth;
     101                 :            :     sal_Int32   m_nCurrentPos;
     102                 :            :     double      m_fCurrentValue;
     103                 :            : };
     104                 :            : 
     105                 :            : class EquidistantTickFactory
     106                 :            : {
     107                 :            : public:
     108                 :            :     EquidistantTickFactory(
     109                 :            :          const ExplicitScaleData& rScale
     110                 :            :         , const ExplicitIncrementData& rIncrement );
     111                 :            :     ~EquidistantTickFactory();
     112                 :            : 
     113                 :            :     void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
     114                 :            :     void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
     115                 :            : 
     116                 :            :     static double getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement );
     117                 :            :     static double getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement );
     118                 :            : 
     119                 :            : private: //methods
     120                 :            :     void        addSubTicks( sal_Int32 nDepth,
     121                 :            :                         ::com::sun::star::uno::Sequence<
     122                 :            :                             ::com::sun::star::uno::Sequence< double > >& rParentTicks ) const;
     123                 :            :     double*     getMajorTick( sal_Int32 nTick ) const;
     124                 :            :     double*     getMinorTick( sal_Int32 nTick, sal_Int32 nDepth
     125                 :            :                     , double fStartParentTick, double fNextParentTick ) const;
     126                 :            :     sal_Int32   getMaxTickCount( sal_Int32 nDepth = 0 ) const;
     127                 :            :     sal_Int32   getTickDepth() const;
     128                 :            : 
     129                 :            :     bool        isVisible( double fValue ) const;
     130                 :            :     bool        isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks
     131                 :            : 
     132                 :            : private: //member
     133                 :            :     ExplicitScaleData     m_rScale;
     134                 :            :     ExplicitIncrementData m_rIncrement;
     135                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >
     136                 :            :                                                 m_xInverseScaling;
     137                 :            : 
     138                 :            :     //minimum and maximum of the visible range after scaling
     139                 :            :     double    m_fScaledVisibleMin;
     140                 :            :     double    m_fScaledVisibleMax;
     141                 :            : 
     142                 :            :     double*   m_pfCurrentValues;
     143                 :            :     //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders
     144                 :            :     double    m_fOuterMajorTickBorderMin;
     145                 :            :     double    m_fOuterMajorTickBorderMax;
     146                 :            :     double    m_fOuterMajorTickBorderMin_Scaled;
     147                 :            :     double    m_fOuterMajorTickBorderMax_Scaled;
     148                 :            : };
     149                 :            : 
     150                 :            : //.............................................................................
     151                 :            : } //namespace chart
     152                 :            : //.............................................................................
     153                 :            : #endif
     154                 :            : 
     155                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10