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_HXX 24cdf0e10cSrcweir #define _CHART2_TICKMARKS_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "TickmarkProperties.hxx" 27cdf0e10cSrcweir #include "VAxisProperties.hxx" 28cdf0e10cSrcweir #include "chartview/ExplicitScaleValues.hxx" 29cdf0e10cSrcweir #include <basegfx/vector/b2dvector.hxx> 30cdf0e10cSrcweir #include <com/sun/star/drawing/PointSequenceSequence.hpp> 31cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp> 32cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <vector> 35cdf0e10cSrcweir 36cdf0e10cSrcweir //............................................................................. 37cdf0e10cSrcweir namespace chart 38cdf0e10cSrcweir { 39cdf0e10cSrcweir //............................................................................. 40cdf0e10cSrcweir 41cdf0e10cSrcweir using ::basegfx::B2DVector; 42cdf0e10cSrcweir //----------------------------------------------------------------------------- 43cdf0e10cSrcweir /** 44cdf0e10cSrcweir */ 45cdf0e10cSrcweir 46cdf0e10cSrcweir struct TickInfo 47cdf0e10cSrcweir { 48cdf0e10cSrcweir double fScaledTickValue; 49cdf0e10cSrcweir ::com::sun::star::uno::Reference< 50cdf0e10cSrcweir ::com::sun::star::chart2::XScaling > xInverseScaling; 51cdf0e10cSrcweir 52cdf0e10cSrcweir ::basegfx::B2DVector aTickScreenPosition; 53cdf0e10cSrcweir bool bPaintIt; 54cdf0e10cSrcweir 55cdf0e10cSrcweir ::com::sun::star::uno::Reference< 56cdf0e10cSrcweir ::com::sun::star::drawing::XShape > xTextShape; 57cdf0e10cSrcweir 58cdf0e10cSrcweir rtl::OUString aText;//used only for complex categories so far 59cdf0e10cSrcweir sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category 60cdf0e10cSrcweir 61cdf0e10cSrcweir //methods: 62cdf0e10cSrcweir TickInfo( const ::com::sun::star::uno::Reference< 63cdf0e10cSrcweir ::com::sun::star::chart2::XScaling >& xInverseScaling ); 64cdf0e10cSrcweir 65cdf0e10cSrcweir double getUnscaledTickValue() const; 66cdf0e10cSrcweir sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const; 67cdf0e10cSrcweir private: 68cdf0e10cSrcweir TickInfo(); 69cdf0e10cSrcweir }; 70cdf0e10cSrcweir class TickIter 71cdf0e10cSrcweir { 72cdf0e10cSrcweir public: ~TickIter()73cdf0e10cSrcweir virtual ~TickIter(){}; 74cdf0e10cSrcweir virtual TickInfo* firstInfo()=0; 75cdf0e10cSrcweir virtual TickInfo* nextInfo()=0; 76cdf0e10cSrcweir }; 77cdf0e10cSrcweir 78cdf0e10cSrcweir class PureTickIter : public TickIter 79cdf0e10cSrcweir { 80cdf0e10cSrcweir public: 81cdf0e10cSrcweir PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ); 82cdf0e10cSrcweir virtual ~PureTickIter(); 83cdf0e10cSrcweir virtual TickInfo* firstInfo(); 84cdf0e10cSrcweir virtual TickInfo* nextInfo(); 85cdf0e10cSrcweir 86cdf0e10cSrcweir private: 87cdf0e10cSrcweir ::std::vector< TickInfo >& m_rTickVector; 88cdf0e10cSrcweir ::std::vector< TickInfo >::iterator m_aTickIter; 89cdf0e10cSrcweir }; 90cdf0e10cSrcweir 91cdf0e10cSrcweir class TickFactory 92cdf0e10cSrcweir { 93cdf0e10cSrcweir public: 94cdf0e10cSrcweir TickFactory( 95cdf0e10cSrcweir const ExplicitScaleData& rScale 96cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement ); 97cdf0e10cSrcweir virtual ~TickFactory(); 98cdf0e10cSrcweir 99cdf0e10cSrcweir void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 100cdf0e10cSrcweir void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; updateScreenValues(::std::vector<::std::vector<TickInfo>> &) const101cdf0e10cSrcweir virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {} 102cdf0e10cSrcweir 103cdf0e10cSrcweir private: //methods 104cdf0e10cSrcweir bool isDateAxis() const; 105cdf0e10cSrcweir 106cdf0e10cSrcweir protected: //member 107cdf0e10cSrcweir ExplicitScaleData m_rScale; 108cdf0e10cSrcweir ExplicitIncrementData m_rIncrement; 109cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > 110cdf0e10cSrcweir m_xInverseScaling; 111cdf0e10cSrcweir 112cdf0e10cSrcweir //minimum and maximum of the visible range after scaling 113cdf0e10cSrcweir double m_fScaledVisibleMin; 114cdf0e10cSrcweir double m_fScaledVisibleMax; 115cdf0e10cSrcweir }; 116cdf0e10cSrcweir 117cdf0e10cSrcweir class TickFactory_2D : public TickFactory 118cdf0e10cSrcweir { 119cdf0e10cSrcweir public: 120cdf0e10cSrcweir TickFactory_2D( 121cdf0e10cSrcweir const ExplicitScaleData& rScale 122cdf0e10cSrcweir , const ExplicitIncrementData& rIncrement 123cdf0e10cSrcweir , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos 124cdf0e10cSrcweir , const ::basegfx::B2DVector& rAxisLineToLabelLineShift ); 125cdf0e10cSrcweir //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ); 126cdf0e10cSrcweir virtual ~TickFactory_2D(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir static sal_Int32 getTickScreenDistance( TickIter& rIter ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const; 131cdf0e10cSrcweir void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints 132cdf0e10cSrcweir , sal_Int32 nSequenceIndex 133cdf0e10cSrcweir , double fScaledLogicTickValue, double fInnerDirectionSign 134cdf0e10cSrcweir , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const; 135cdf0e10cSrcweir ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties 136cdf0e10cSrcweir , bool bIncludeFarAwayDistanceIfSo = false 137cdf0e10cSrcweir , bool bIncludeSpaceBetweenTickAndText = true ) const; 138cdf0e10cSrcweir 139cdf0e10cSrcweir virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 140cdf0e10cSrcweir 141cdf0e10cSrcweir bool isHorizontalAxis() const; 142cdf0e10cSrcweir bool isVerticalAxis() const; 143cdf0e10cSrcweir 144cdf0e10cSrcweir protected: //methods 145cdf0e10cSrcweir ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const; 146cdf0e10cSrcweir 147cdf0e10cSrcweir private: //member 148cdf0e10cSrcweir ::basegfx::B2DVector m_aAxisStartScreenPosition2D; 149cdf0e10cSrcweir ::basegfx::B2DVector m_aAxisEndScreenPosition2D; 150cdf0e10cSrcweir 151cdf0e10cSrcweir //labels might be posioned high or low on the border of the diagram far away from the axis 152cdf0e10cSrcweir //add this vector to go from the axis line to the label line (border of the diagram) 153cdf0e10cSrcweir ::basegfx::B2DVector m_aAxisLineToLabelLineShift; 154cdf0e10cSrcweir 155cdf0e10cSrcweir double m_fStrech_LogicToScreen; 156cdf0e10cSrcweir double m_fOffset_LogicToScreen; 157cdf0e10cSrcweir }; 158cdf0e10cSrcweir 159cdf0e10cSrcweir //............................................................................. 160cdf0e10cSrcweir } //namespace chart 161cdf0e10cSrcweir //............................................................................. 162cdf0e10cSrcweir #endif 163