LCOV - code coverage report
Current view: top level - chart2/source/view/axes - Tickmarks.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 3 3 100.0 %
Date: 2014-11-03 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      131613 : 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             :     TickInfo( const css::uno::Reference<css::chart2::XScaling>& xInverse );
      49             : 
      50             :     double getUnscaledTickValue() const;
      51             :     sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const;
      52             : private:
      53             :     TickInfo();
      54             : };
      55             : 
      56             : typedef std::vector<TickInfo>           TickInfoArrayType;
      57             : typedef std::vector<TickInfoArrayType>  TickInfoArraysType;
      58             : 
      59        8667 : class TickIter
      60             : {
      61             : public:
      62        8667 :     virtual ~TickIter() {}
      63             :     virtual TickInfo* firstInfo() = 0;
      64             :     virtual TickInfo* nextInfo() = 0;
      65             : };
      66             : 
      67             : class PureTickIter : public TickIter
      68             : {
      69             : public:
      70             :     PureTickIter( TickInfoArrayType& rTickInfoVector );
      71             :     virtual ~PureTickIter();
      72             :     virtual TickInfo* firstInfo() SAL_OVERRIDE;
      73             :     virtual TickInfo* nextInfo() SAL_OVERRIDE;
      74             : 
      75             : private:
      76             :     TickInfoArrayType& m_rTickVector;
      77             :     TickInfoArrayType::iterator m_aTickIter;
      78             : };
      79             : 
      80             : class TickFactory
      81             : {
      82             : public:
      83             :     TickFactory(
      84             :          const ExplicitScaleData& rScale
      85             :         , const ExplicitIncrementData& rIncrement );
      86             :     virtual ~TickFactory();
      87             : 
      88             :     void getAllTicks( TickInfoArraysType& rAllTickInfos ) const;
      89             :     void getAllTicksShifted( TickInfoArraysType& rAllTickInfos ) const;
      90             : 
      91             :     /**
      92             :      * Determine the screen positions of all ticks based on their numeric values.
      93             :      */
      94             :     virtual void updateScreenValues( TickInfoArraysType& rAllTickInfos ) const;
      95             : 
      96             : private: //methods
      97             :     bool        isDateAxis() const;
      98             : 
      99             : protected: //member
     100             :     ExplicitScaleData     m_rScale;
     101             :     ExplicitIncrementData m_rIncrement;
     102             :     ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >
     103             :                                                 m_xInverseScaling;
     104             : 
     105             :     //minimum and maximum of the visible range after scaling
     106             :     double    m_fScaledVisibleMin;
     107             :     double    m_fScaledVisibleMax;
     108             : };
     109             : 
     110             : class TickFactory2D : public TickFactory
     111             : {
     112             : public:
     113             :     TickFactory2D(
     114             :         const ExplicitScaleData& rScale
     115             :         , const ExplicitIncrementData& rIncrement
     116             :         , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos
     117             :         , const ::basegfx::B2DVector& rAxisLineToLabelLineShift );
     118             : 
     119             :     virtual ~TickFactory2D();
     120             : 
     121             :     static sal_Int32    getTickScreenDistance( TickIter& rIter );
     122             : 
     123             :     void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const;
     124             :     void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints
     125             :                             , sal_Int32 nSequenceIndex
     126             :                             , double fScaledLogicTickValue, double fInnerDirectionSign
     127             :                             , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const;
     128             :     ::basegfx::B2DVector  getDistanceAxisTickToText( const AxisProperties& rAxisProperties
     129             :         , bool bIncludeFarAwayDistanceIfSo = false
     130             :         , bool bIncludeSpaceBetweenTickAndText = true ) const;
     131             : 
     132             :     virtual void updateScreenValues( TickInfoArraysType& rAllTickInfos ) const SAL_OVERRIDE;
     133             : 
     134             :     bool  isHorizontalAxis() const;
     135             :     bool  isVerticalAxis() const;
     136             : 
     137             : protected: //methods
     138             :     ::basegfx::B2DVector     getTickScreenPosition2D( double fScaledLogicTickValue ) const;
     139             : 
     140             : private: //member
     141             :     ::basegfx::B2DVector    m_aAxisStartScreenPosition2D;
     142             :     ::basegfx::B2DVector    m_aAxisEndScreenPosition2D;
     143             : 
     144             :     //labels might be posioned high or low on the border of the diagram far away from the axis
     145             :     //add this vector to go from the axis line to the label line (border of the diagram)
     146             :     ::basegfx::B2DVector    m_aAxisLineToLabelLineShift;
     147             : 
     148             :     double      m_fStrech_LogicToScreen;
     149             :     double      m_fOffset_LogicToScreen;
     150             : };
     151             : 
     152             : } //namespace chart
     153             : 
     154             : #endif
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10