LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/chart2/source/view/axes - Tickmarks_Equidistant.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 12 100.0 %
Date: 2013-07-09 Functions: 3 3 100.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             : #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             : class EquidistantTickIter : public TickIter
      30             : {
      31             : public:
      32             :     EquidistantTickIter( const ::com::sun::star::uno::Sequence<
      33             :                 ::com::sun::star::uno::Sequence< double > >& rTicks
      34             :                 , const ExplicitIncrementData& rIncrement
      35             :             , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
      36             :     EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
      37             :             , const ExplicitIncrementData& rIncrement
      38             :             , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
      39             :     virtual ~EquidistantTickIter();
      40             : 
      41             :     virtual double*     firstValue();
      42             :     virtual double*     nextValue();
      43             : 
      44             :     virtual TickInfo*   firstInfo();
      45             :     virtual TickInfo*   nextInfo();
      46             : 
      47             :     sal_Int32   getCurrentDepth() const { return m_nCurrentDepth; }
      48             : 
      49             : private: //methods
      50             :     sal_Int32   getIntervalCount( sal_Int32 nDepth );
      51             :     bool        isAtLastPartTick();
      52             : 
      53             :     void        initIter( sal_Int32 nMinDepth, sal_Int32 nMaxDepth );
      54             :     sal_Int32   getStartDepth() const;
      55             : 
      56             :     bool        gotoFirst();
      57             :     bool        gotoNext();
      58             : 
      59             : 
      60       35464 :     double      getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const
      61             :                 {
      62       35464 :                     if(m_pSimpleTicks)
      63       27982 :                         return (*m_pSimpleTicks)[nDepth][nIndex];
      64             :                     else
      65        7482 :                         return (((*m_pInfoTicks)[nDepth])[nIndex]).fScaledTickValue;
      66             :                 }
      67       14037 :     sal_Int32   getTickCount( sal_Int32 nDepth ) const
      68             :                 {
      69       14037 :                     if(m_pSimpleTicks)
      70        7032 :                         return (*m_pSimpleTicks)[nDepth].getLength();
      71             :                     else
      72        7005 :                         return (*m_pInfoTicks)[nDepth].size();
      73             :                 }
      74        4917 :     sal_Int32   getMaxDepth() const
      75             :                 {
      76        4917 :                     if(m_pSimpleTicks)
      77        3516 :                         return (*m_pSimpleTicks).getLength()-1;
      78             :                     else
      79        1401 :                         return (*m_pInfoTicks).size()-1;
      80             :                 }
      81             : 
      82             : private: //member
      83             :     const ::com::sun::star::uno::Sequence<
      84             :         ::com::sun::star::uno::Sequence< double > >*  m_pSimpleTicks;
      85             :     ::std::vector< ::std::vector< TickInfo > >*       m_pInfoTicks;
      86             :     const ExplicitIncrementData& m_rIncrement;
      87             :     sal_Int32   m_nMaxDepth;
      88             :     sal_Int32   m_nTickCount;
      89             :     sal_Int32*  m_pnPositions; //current positions in the different sequences
      90             :     sal_Int32*  m_pnPreParentCount; //the tickmarks do not start with a major tick always,
      91             :                                     //the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark
      92             :     bool*       m_pbIntervalFinished;
      93             :     sal_Int32   m_nCurrentDepth;
      94             :     sal_Int32   m_nCurrentPos;
      95             :     double      m_fCurrentValue;
      96             : };
      97             : 
      98             : class EquidistantTickFactory
      99             : {
     100             : public:
     101             :     EquidistantTickFactory(
     102             :          const ExplicitScaleData& rScale
     103             :         , const ExplicitIncrementData& rIncrement );
     104             :     ~EquidistantTickFactory();
     105             : 
     106             :     void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
     107             :     void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
     108             : 
     109             :     static double getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement );
     110             :     static double getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement );
     111             : 
     112             : private: //methods
     113             :     void        addSubTicks( sal_Int32 nDepth,
     114             :                         ::com::sun::star::uno::Sequence<
     115             :                             ::com::sun::star::uno::Sequence< double > >& rParentTicks ) const;
     116             :     double*     getMajorTick( sal_Int32 nTick ) const;
     117             :     double*     getMinorTick( sal_Int32 nTick, sal_Int32 nDepth
     118             :                     , double fStartParentTick, double fNextParentTick ) const;
     119             :     sal_Int32   getMaxTickCount( sal_Int32 nDepth = 0 ) const;
     120             :     sal_Int32   getTickDepth() const;
     121             : 
     122             :     bool        isVisible( double fValue ) const;
     123             :     bool        isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks
     124             : 
     125             : private: //member
     126             :     ExplicitScaleData     m_rScale;
     127             :     ExplicitIncrementData m_rIncrement;
     128             :     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >
     129             :                                                 m_xInverseScaling;
     130             : 
     131             :     //minimum and maximum of the visible range after scaling
     132             :     double    m_fScaledVisibleMin;
     133             :     double    m_fScaledVisibleMax;
     134             : 
     135             :     double*   m_pfCurrentValues;
     136             :     //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders
     137             :     double    m_fOuterMajorTickBorderMin;
     138             :     double    m_fOuterMajorTickBorderMax;
     139             :     double    m_fOuterMajorTickBorderMin_Scaled;
     140             :     double    m_fOuterMajorTickBorderMax_Scaled;
     141             : };
     142             : 
     143             : //.............................................................................
     144             : } //namespace chart
     145             : //.............................................................................
     146             : #endif
     147             : 
     148             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10