LCOV - code coverage report
Current view: top level - chart2/source/view/axes - Tickmarks.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 3 3 100.0 %
Date: 2015-06-13 12:38:46 Functions: 4 5 80.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_HXX
      20             : #define INCLUDED_CHART2_SOURCE_VIEW_AXES_TICKMARKS_HXX
      21             : 
      22             : #include "TickmarkProperties.hxx"
      23             : #include "VAxisProperties.hxx"
      24             : #include "chartview/ExplicitScaleValues.hxx"
      25             : #include <basegfx/vector/b2dvector.hxx>
      26             : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
      27             : #include <com/sun/star/drawing/XShape.hpp>
      28             : #include <com/sun/star/uno/Sequence.h>
      29             : 
      30             : #include <vector>
      31             : 
      32             : namespace chart {
      33             : 
      34      240156 : struct TickInfo
      35             : {
      36             :     double      fScaledTickValue;
      37             :     css::uno::Reference<css::chart2::XScaling> xInverseScaling;
      38             : 
      39             :     ::basegfx::B2DVector  aTickScreenPosition;
      40             :     bool        bPaintIt;
      41             : 
      42             :     css::uno::Reference<css::drawing::XShape> xTextShape;
      43             : 
      44             :     OUString aText;//used only for complex categories so far
      45             :     sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category
      46             : 
      47             : //methods:
      48             :     explicit TickInfo( const css::uno::Reference<css::chart2::XScaling>& xInverse );
      49             : 
      50             :     /**
      51             :      * Return a value associated with the tick mark. It's normally an original
      52             :      * value from the data source, or 1-based integer index in case the axis
      53             :      * is a category axis.
      54             :      */
      55             :     double getUnscaledTickValue() const;
      56             :     sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const;
      57             : private:
      58             :     TickInfo();
      59             : };
      60             : 
      61             : typedef std::vector<TickInfo>           TickInfoArrayType;
      62             : typedef std::vector<TickInfoArrayType>  TickInfoArraysType;
      63             : 
      64       16788 : class TickIter
      65             : {
      66             : public:
      67       16788 :     virtual ~TickIter() {}
      68             :     virtual TickInfo* firstInfo() = 0;
      69             :     virtual TickInfo* nextInfo() = 0;
      70             : };
      71             : 
      72             : class PureTickIter : public TickIter
      73             : {
      74             : public:
      75             :     explicit PureTickIter( TickInfoArrayType& rTickInfoVector );
      76             :     virtual ~PureTickIter();
      77             :     virtual TickInfo* firstInfo() SAL_OVERRIDE;
      78             :     virtual TickInfo* nextInfo() SAL_OVERRIDE;
      79             : 
      80             : private:
      81             :     TickInfoArrayType& m_rTickVector;
      82             :     TickInfoArrayType::iterator m_aTickIter;
      83             : };
      84             : 
      85             : class TickFactory
      86             : {
      87             : public:
      88             :     TickFactory(
      89             :          const ExplicitScaleData& rScale
      90             :         , const ExplicitIncrementData& rIncrement );
      91             :     virtual ~TickFactory();
      92             : 
      93             :     void getAllTicks( TickInfoArraysType& rAllTickInfos ) const;
      94             :     void getAllTicksShifted( TickInfoArraysType& rAllTickInfos ) const;
      95             : 
      96             :     /**
      97             :      * Determine the screen positions of all ticks based on their numeric values.
      98             :      */
      99             :     virtual void updateScreenValues( TickInfoArraysType& rAllTickInfos ) const;
     100             : 
     101             : private: //methods
     102             :     bool        isDateAxis() const;
     103             : 
     104             : protected: //member
     105             :     ExplicitScaleData     m_rScale;
     106             :     ExplicitIncrementData m_rIncrement;
     107             :     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >
     108             :                                                 m_xInverseScaling;
     109             : 
     110             :     //minimum and maximum of the visible range after scaling
     111             :     double    m_fScaledVisibleMin;
     112             :     double    m_fScaledVisibleMax;
     113             : };
     114             : 
     115             : class TickFactory2D : public TickFactory
     116             : {
     117             : public:
     118             :     TickFactory2D(
     119             :         const ExplicitScaleData& rScale
     120             :         , const ExplicitIncrementData& rIncrement
     121             :         , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos
     122             :         , const ::basegfx::B2DVector& rAxisLineToLabelLineShift );
     123             : 
     124             :     virtual ~TickFactory2D();
     125             : 
     126             :     static sal_Int32    getTickScreenDistance( TickIter& rIter );
     127             : 
     128             :     void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const;
     129             :     void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints
     130             :                             , sal_Int32 nSequenceIndex
     131             :                             , double fScaledLogicTickValue, double fInnerDirectionSign
     132             :                             , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const;
     133             :     ::basegfx::B2DVector  getDistanceAxisTickToText( const AxisProperties& rAxisProperties
     134             :         , bool bIncludeFarAwayDistanceIfSo = false
     135             :         , bool bIncludeSpaceBetweenTickAndText = true ) const;
     136             : 
     137             :     virtual void updateScreenValues( TickInfoArraysType& rAllTickInfos ) const SAL_OVERRIDE;
     138             : 
     139             :     bool  isHorizontalAxis() const;
     140             :     bool  isVerticalAxis() const;
     141             : 
     142             : protected: //methods
     143             :     ::basegfx::B2DVector     getTickScreenPosition2D( double fScaledLogicTickValue ) const;
     144             : 
     145             : private: //member
     146             :     ::basegfx::B2DVector    m_aAxisStartScreenPosition2D;
     147             :     ::basegfx::B2DVector    m_aAxisEndScreenPosition2D;
     148             : 
     149             :     //labels might be posioned high or low on the border of the diagram far away from the axis
     150             :     //add this vector to go from the axis line to the label line (border of the diagram)
     151             :     ::basegfx::B2DVector    m_aAxisLineToLabelLineShift;
     152             : 
     153             :     double      m_fStretch_LogicToScreen;
     154             :     double      m_fOffset_LogicToScreen;
     155             : };
     156             : 
     157             : } //namespace chart
     158             : 
     159             : #endif
     160             : 
     161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11