1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir #ifndef _CHART2_TICKMARKS_EQUIDISTANT_HXX 28*cdf0e10cSrcweir #define _CHART2_TICKMARKS_EQUIDISTANT_HXX 29*cdf0e10cSrcweir 30*cdf0e10cSrcweir #include "Tickmarks.hxx" 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir //............................................................................. 33*cdf0e10cSrcweir namespace chart 34*cdf0e10cSrcweir { 35*cdf0e10cSrcweir //............................................................................. 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir using ::basegfx::B2DVector; 38*cdf0e10cSrcweir //----------------------------------------------------------------------------- 39*cdf0e10cSrcweir /** 40*cdf0e10cSrcweir */ 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir class EquidistantTickIter : public TickIter 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir public: 45*cdf0e10cSrcweir EquidistantTickIter( const ::com::sun::star::uno::Sequence< 46*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< double > >& rTicks 47*cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement 48*cdf0e10cSrcweir , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); 49*cdf0e10cSrcweir EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos 50*cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement 51*cdf0e10cSrcweir , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); 52*cdf0e10cSrcweir virtual ~EquidistantTickIter(); 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir virtual double* firstValue(); 55*cdf0e10cSrcweir virtual double* nextValue(); 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir virtual TickInfo* firstInfo(); 58*cdf0e10cSrcweir virtual TickInfo* nextInfo(); 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir sal_Int32 getCurrentDepth() const { return m_nCurrentDepth; } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir protected: 63*cdf0e10cSrcweir bool gotoIndex( sal_Int32 nTickIndex ); 64*cdf0e10cSrcweir sal_Int32 getCurrentIndex() const; 65*cdf0e10cSrcweir sal_Int32 getMaxIndex() const; 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir private: //methods 68*cdf0e10cSrcweir sal_Int32 getIntervalCount( sal_Int32 nDepth ); 69*cdf0e10cSrcweir bool isAtLastPartTick(); 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir void initIter( sal_Int32 nMinDepth, sal_Int32 nMaxDepth ); 72*cdf0e10cSrcweir sal_Int32 getStartDepth() const; 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir bool gotoFirst(); 75*cdf0e10cSrcweir bool gotoNext(); 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir double getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const 79*cdf0e10cSrcweir { 80*cdf0e10cSrcweir if(m_pSimpleTicks) 81*cdf0e10cSrcweir return (*m_pSimpleTicks)[nDepth][nIndex]; 82*cdf0e10cSrcweir else 83*cdf0e10cSrcweir return (((*m_pInfoTicks)[nDepth])[nIndex]).fScaledTickValue; 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir sal_Int32 getTickCount( sal_Int32 nDepth ) const 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir if(m_pSimpleTicks) 88*cdf0e10cSrcweir return (*m_pSimpleTicks)[nDepth].getLength(); 89*cdf0e10cSrcweir else 90*cdf0e10cSrcweir return (*m_pInfoTicks)[nDepth].size(); 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir sal_Int32 getMaxDepth() const 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir if(m_pSimpleTicks) 95*cdf0e10cSrcweir return (*m_pSimpleTicks).getLength()-1; 96*cdf0e10cSrcweir else 97*cdf0e10cSrcweir return (*m_pInfoTicks).size()-1; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir private: //member 101*cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 102*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< double > >* m_pSimpleTicks; 103*cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > >* m_pInfoTicks; 104*cdf0e10cSrcweir const ExplicitIncrementData& m_rIncrement; 105*cdf0e10cSrcweir //iteration from m_nMinDepth to m_nMaxDepth 106*cdf0e10cSrcweir sal_Int32 m_nMinDepth; 107*cdf0e10cSrcweir sal_Int32 m_nMaxDepth; 108*cdf0e10cSrcweir sal_Int32 m_nTickCount; 109*cdf0e10cSrcweir sal_Int32* m_pnPositions; //current positions in the different sequences 110*cdf0e10cSrcweir sal_Int32* m_pnPreParentCount; //the tickmarks do not start with a major tick always, 111*cdf0e10cSrcweir //the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark 112*cdf0e10cSrcweir bool* m_pbIntervalFinished; 113*cdf0e10cSrcweir sal_Int32 m_nCurrentDepth; 114*cdf0e10cSrcweir sal_Int32 m_nCurrentPos; 115*cdf0e10cSrcweir double m_fCurrentValue; 116*cdf0e10cSrcweir }; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir class EquidistantTickFactory 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir public: 121*cdf0e10cSrcweir EquidistantTickFactory( 122*cdf0e10cSrcweir const ExplicitScaleData& rScale 123*cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement ); 124*cdf0e10cSrcweir ~EquidistantTickFactory(); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 127*cdf0e10cSrcweir void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir static double getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement ); 130*cdf0e10cSrcweir static double getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement ); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir private: //methods 133*cdf0e10cSrcweir void addSubTicks( sal_Int32 nDepth, 134*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< 135*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< double > >& rParentTicks ) const; 136*cdf0e10cSrcweir double* getMajorTick( sal_Int32 nTick ) const; 137*cdf0e10cSrcweir double* getMinorTick( sal_Int32 nTick, sal_Int32 nDepth 138*cdf0e10cSrcweir , double fStartParentTick, double fNextParentTick ) const; 139*cdf0e10cSrcweir sal_Int32 getMaxTickCount( sal_Int32 nDepth = 0 ) const; 140*cdf0e10cSrcweir sal_Int32 getTickDepth() const; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir bool isVisible( double fValue ) const; 143*cdf0e10cSrcweir bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir private: //member 146*cdf0e10cSrcweir ExplicitScaleData m_rScale; 147*cdf0e10cSrcweir ExplicitIncrementData m_rIncrement; 148*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > 149*cdf0e10cSrcweir m_xInverseScaling; 150*cdf0e10cSrcweir 151*cdf0e10cSrcweir //minimum and maximum of the visible range after scaling 152*cdf0e10cSrcweir double m_fScaledVisibleMin; 153*cdf0e10cSrcweir double m_fScaledVisibleMax; 154*cdf0e10cSrcweir 155*cdf0e10cSrcweir double* m_pfCurrentValues; 156*cdf0e10cSrcweir //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders 157*cdf0e10cSrcweir double m_fOuterMajorTickBorderMin; 158*cdf0e10cSrcweir double m_fOuterMajorTickBorderMax; 159*cdf0e10cSrcweir double m_fOuterMajorTickBorderMin_Scaled; 160*cdf0e10cSrcweir double m_fOuterMajorTickBorderMax_Scaled; 161*cdf0e10cSrcweir }; 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir //............................................................................. 164*cdf0e10cSrcweir } //namespace chart 165*cdf0e10cSrcweir //............................................................................. 166*cdf0e10cSrcweir #endif 167