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

Generated by: LCOV version 1.10