1*de7b3f82SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*de7b3f82SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*de7b3f82SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*de7b3f82SAndrew Rist * distributed with this work for additional information 6*de7b3f82SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*de7b3f82SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*de7b3f82SAndrew Rist * "License"); you may not use this file except in compliance 9*de7b3f82SAndrew Rist * with the License. You may obtain a copy of the License at 10*de7b3f82SAndrew Rist * 11*de7b3f82SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*de7b3f82SAndrew Rist * 13*de7b3f82SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*de7b3f82SAndrew Rist * software distributed under the License is distributed on an 15*de7b3f82SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*de7b3f82SAndrew Rist * KIND, either express or implied. See the License for the 17*de7b3f82SAndrew Rist * specific language governing permissions and limitations 18*de7b3f82SAndrew Rist * under the License. 19*de7b3f82SAndrew Rist * 20*de7b3f82SAndrew Rist *************************************************************/ 21*de7b3f82SAndrew Rist 22*de7b3f82SAndrew Rist 23cdf0e10cSrcweir #ifndef _CHART2_TICKMARKS_EQUIDISTANT_HXX 24cdf0e10cSrcweir #define _CHART2_TICKMARKS_EQUIDISTANT_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "Tickmarks.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir //............................................................................. 29cdf0e10cSrcweir namespace chart 30cdf0e10cSrcweir { 31cdf0e10cSrcweir //............................................................................. 32cdf0e10cSrcweir 33cdf0e10cSrcweir using ::basegfx::B2DVector; 34cdf0e10cSrcweir //----------------------------------------------------------------------------- 35cdf0e10cSrcweir /** 36cdf0e10cSrcweir */ 37cdf0e10cSrcweir 38cdf0e10cSrcweir class EquidistantTickIter : public TickIter 39cdf0e10cSrcweir { 40cdf0e10cSrcweir public: 41cdf0e10cSrcweir EquidistantTickIter( const ::com::sun::star::uno::Sequence< 42cdf0e10cSrcweir ::com::sun::star::uno::Sequence< double > >& rTicks 43cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement 44cdf0e10cSrcweir , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); 45cdf0e10cSrcweir EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos 46cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement 47cdf0e10cSrcweir , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 ); 48cdf0e10cSrcweir virtual ~EquidistantTickIter(); 49cdf0e10cSrcweir 50cdf0e10cSrcweir virtual double* firstValue(); 51cdf0e10cSrcweir virtual double* nextValue(); 52cdf0e10cSrcweir 53cdf0e10cSrcweir virtual TickInfo* firstInfo(); 54cdf0e10cSrcweir virtual TickInfo* nextInfo(); 55cdf0e10cSrcweir getCurrentDepth() const56cdf0e10cSrcweir sal_Int32 getCurrentDepth() const { return m_nCurrentDepth; } 57cdf0e10cSrcweir 58cdf0e10cSrcweir protected: 59cdf0e10cSrcweir bool gotoIndex( sal_Int32 nTickIndex ); 60cdf0e10cSrcweir sal_Int32 getCurrentIndex() const; 61cdf0e10cSrcweir sal_Int32 getMaxIndex() const; 62cdf0e10cSrcweir 63cdf0e10cSrcweir private: //methods 64cdf0e10cSrcweir sal_Int32 getIntervalCount( sal_Int32 nDepth ); 65cdf0e10cSrcweir bool isAtLastPartTick(); 66cdf0e10cSrcweir 67cdf0e10cSrcweir void initIter( sal_Int32 nMinDepth, sal_Int32 nMaxDepth ); 68cdf0e10cSrcweir sal_Int32 getStartDepth() const; 69cdf0e10cSrcweir 70cdf0e10cSrcweir bool gotoFirst(); 71cdf0e10cSrcweir bool gotoNext(); 72cdf0e10cSrcweir 73cdf0e10cSrcweir getTickValue(sal_Int32 nDepth,sal_Int32 nIndex) const74cdf0e10cSrcweir double getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const 75cdf0e10cSrcweir { 76cdf0e10cSrcweir if(m_pSimpleTicks) 77cdf0e10cSrcweir return (*m_pSimpleTicks)[nDepth][nIndex]; 78cdf0e10cSrcweir else 79cdf0e10cSrcweir return (((*m_pInfoTicks)[nDepth])[nIndex]).fScaledTickValue; 80cdf0e10cSrcweir } getTickCount(sal_Int32 nDepth) const81cdf0e10cSrcweir sal_Int32 getTickCount( sal_Int32 nDepth ) const 82cdf0e10cSrcweir { 83cdf0e10cSrcweir if(m_pSimpleTicks) 84cdf0e10cSrcweir return (*m_pSimpleTicks)[nDepth].getLength(); 85cdf0e10cSrcweir else 86cdf0e10cSrcweir return (*m_pInfoTicks)[nDepth].size(); 87cdf0e10cSrcweir } getMaxDepth() const88cdf0e10cSrcweir sal_Int32 getMaxDepth() const 89cdf0e10cSrcweir { 90cdf0e10cSrcweir if(m_pSimpleTicks) 91cdf0e10cSrcweir return (*m_pSimpleTicks).getLength()-1; 92cdf0e10cSrcweir else 93cdf0e10cSrcweir return (*m_pInfoTicks).size()-1; 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir private: //member 97cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< 98cdf0e10cSrcweir ::com::sun::star::uno::Sequence< double > >* m_pSimpleTicks; 99cdf0e10cSrcweir ::std::vector< ::std::vector< TickInfo > >* m_pInfoTicks; 100cdf0e10cSrcweir const ExplicitIncrementData& m_rIncrement; 101cdf0e10cSrcweir //iteration from m_nMinDepth to m_nMaxDepth 102cdf0e10cSrcweir sal_Int32 m_nMinDepth; 103cdf0e10cSrcweir sal_Int32 m_nMaxDepth; 104cdf0e10cSrcweir sal_Int32 m_nTickCount; 105cdf0e10cSrcweir sal_Int32* m_pnPositions; //current positions in the different sequences 106cdf0e10cSrcweir sal_Int32* m_pnPreParentCount; //the tickmarks do not start with a major tick always, 107cdf0e10cSrcweir //the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark 108cdf0e10cSrcweir bool* m_pbIntervalFinished; 109cdf0e10cSrcweir sal_Int32 m_nCurrentDepth; 110cdf0e10cSrcweir sal_Int32 m_nCurrentPos; 111cdf0e10cSrcweir double m_fCurrentValue; 112cdf0e10cSrcweir }; 113cdf0e10cSrcweir 114cdf0e10cSrcweir class EquidistantTickFactory 115cdf0e10cSrcweir { 116cdf0e10cSrcweir public: 117cdf0e10cSrcweir EquidistantTickFactory( 118cdf0e10cSrcweir const ExplicitScaleData& rScale 119cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement ); 120cdf0e10cSrcweir ~EquidistantTickFactory(); 121cdf0e10cSrcweir 122cdf0e10cSrcweir void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 123cdf0e10cSrcweir void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 124cdf0e10cSrcweir 125cdf0e10cSrcweir static double getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement ); 126cdf0e10cSrcweir static double getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement ); 127cdf0e10cSrcweir 128cdf0e10cSrcweir private: //methods 129cdf0e10cSrcweir void addSubTicks( sal_Int32 nDepth, 130cdf0e10cSrcweir ::com::sun::star::uno::Sequence< 131cdf0e10cSrcweir ::com::sun::star::uno::Sequence< double > >& rParentTicks ) const; 132cdf0e10cSrcweir double* getMajorTick( sal_Int32 nTick ) const; 133cdf0e10cSrcweir double* getMinorTick( sal_Int32 nTick, sal_Int32 nDepth 134cdf0e10cSrcweir , double fStartParentTick, double fNextParentTick ) const; 135cdf0e10cSrcweir sal_Int32 getMaxTickCount( sal_Int32 nDepth = 0 ) const; 136cdf0e10cSrcweir sal_Int32 getTickDepth() const; 137cdf0e10cSrcweir 138cdf0e10cSrcweir bool isVisible( double fValue ) const; 139cdf0e10cSrcweir bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks 140cdf0e10cSrcweir 141cdf0e10cSrcweir private: //member 142cdf0e10cSrcweir ExplicitScaleData m_rScale; 143cdf0e10cSrcweir ExplicitIncrementData m_rIncrement; 144cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > 145cdf0e10cSrcweir m_xInverseScaling; 146cdf0e10cSrcweir 147cdf0e10cSrcweir //minimum and maximum of the visible range after scaling 148cdf0e10cSrcweir double m_fScaledVisibleMin; 149cdf0e10cSrcweir double m_fScaledVisibleMax; 150cdf0e10cSrcweir 151cdf0e10cSrcweir double* m_pfCurrentValues; 152cdf0e10cSrcweir //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders 153cdf0e10cSrcweir double m_fOuterMajorTickBorderMin; 154cdf0e10cSrcweir double m_fOuterMajorTickBorderMax; 155cdf0e10cSrcweir double m_fOuterMajorTickBorderMin_Scaled; 156cdf0e10cSrcweir double m_fOuterMajorTickBorderMax_Scaled; 157cdf0e10cSrcweir }; 158cdf0e10cSrcweir 159cdf0e10cSrcweir //............................................................................. 160cdf0e10cSrcweir } //namespace chart 161cdf0e10cSrcweir //............................................................................. 162cdf0e10cSrcweir #endif 163