1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _CHART2_TICKMARKS_HXX 28 #define _CHART2_TICKMARKS_HXX 29 30 #include "TickmarkProperties.hxx" 31 #include "VAxisProperties.hxx" 32 #include "chartview/ExplicitScaleValues.hxx" 33 #include <basegfx/vector/b2dvector.hxx> 34 #include <com/sun/star/drawing/PointSequenceSequence.hpp> 35 #include <com/sun/star/drawing/XShape.hpp> 36 #include <com/sun/star/uno/Sequence.h> 37 38 #include <vector> 39 40 //............................................................................. 41 namespace chart 42 { 43 //............................................................................. 44 45 using ::basegfx::B2DVector; 46 //----------------------------------------------------------------------------- 47 /** 48 */ 49 50 struct TickInfo 51 { 52 double fScaledTickValue; 53 ::com::sun::star::uno::Reference< 54 ::com::sun::star::chart2::XScaling > xInverseScaling; 55 56 ::basegfx::B2DVector aTickScreenPosition; 57 bool bPaintIt; 58 59 ::com::sun::star::uno::Reference< 60 ::com::sun::star::drawing::XShape > xTextShape; 61 62 rtl::OUString aText;//used only for complex categories so far 63 sal_Int32 nFactorForLimitedTextWidth;//categories in higher levels of complex categories can have more place than a single simple category 64 65 //methods: 66 TickInfo( const ::com::sun::star::uno::Reference< 67 ::com::sun::star::chart2::XScaling >& xInverseScaling ); 68 69 double getUnscaledTickValue() const; 70 sal_Int32 getScreenDistanceBetweenTicks( const TickInfo& rOherTickInfo ) const; 71 private: 72 TickInfo(); 73 }; 74 class TickIter 75 { 76 public: 77 virtual ~TickIter(){}; 78 virtual TickInfo* firstInfo()=0; 79 virtual TickInfo* nextInfo()=0; 80 }; 81 82 class PureTickIter : public TickIter 83 { 84 public: 85 PureTickIter( ::std::vector< TickInfo >& rTickInfoVector ); 86 virtual ~PureTickIter(); 87 virtual TickInfo* firstInfo(); 88 virtual TickInfo* nextInfo(); 89 90 private: 91 ::std::vector< TickInfo >& m_rTickVector; 92 ::std::vector< TickInfo >::iterator m_aTickIter; 93 }; 94 95 class TickFactory 96 { 97 public: 98 TickFactory( 99 const ExplicitScaleData& rScale 100 , const ExplicitIncrementData& rIncrement ); 101 virtual ~TickFactory(); 102 103 void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 104 void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 105 virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& /*rAllTickInfos*/ ) const {} 106 107 private: //methods 108 bool isDateAxis() const; 109 110 protected: //member 111 ExplicitScaleData m_rScale; 112 ExplicitIncrementData m_rIncrement; 113 ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling > 114 m_xInverseScaling; 115 116 //minimum and maximum of the visible range after scaling 117 double m_fScaledVisibleMin; 118 double m_fScaledVisibleMax; 119 }; 120 121 class TickFactory_2D : public TickFactory 122 { 123 public: 124 TickFactory_2D( 125 const ExplicitScaleData& rScale 126 , const ExplicitIncrementData& rIncrement 127 , const ::basegfx::B2DVector& rStartScreenPos, const ::basegfx::B2DVector& rEndScreenPos 128 , const ::basegfx::B2DVector& rAxisLineToLabelLineShift ); 129 //, double fStrech_SceneToScreen, double fOffset_SceneToScreen ); 130 virtual ~TickFactory_2D(); 131 132 static sal_Int32 getTickScreenDistance( TickIter& rIter ); 133 134 void createPointSequenceForAxisMainLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints ) const; 135 void addPointSequenceForTickLine( ::com::sun::star::drawing::PointSequenceSequence& rPoints 136 , sal_Int32 nSequenceIndex 137 , double fScaledLogicTickValue, double fInnerDirectionSign 138 , const TickmarkProperties& rTickmarkProperties, bool bPlaceAtLabels ) const; 139 ::basegfx::B2DVector getDistanceAxisTickToText( const AxisProperties& rAxisProperties 140 , bool bIncludeFarAwayDistanceIfSo = false 141 , bool bIncludeSpaceBetweenTickAndText = true ) const; 142 143 virtual void updateScreenValues( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const; 144 145 bool isHorizontalAxis() const; 146 bool isVerticalAxis() const; 147 148 protected: //methods 149 ::basegfx::B2DVector getTickScreenPosition2D( double fScaledLogicTickValue ) const; 150 151 private: //member 152 ::basegfx::B2DVector m_aAxisStartScreenPosition2D; 153 ::basegfx::B2DVector m_aAxisEndScreenPosition2D; 154 155 //labels might be posioned high or low on the border of the diagram far away from the axis 156 //add this vector to go from the axis line to the label line (border of the diagram) 157 ::basegfx::B2DVector m_aAxisLineToLabelLineShift; 158 159 double m_fStrech_LogicToScreen; 160 double m_fOffset_LogicToScreen; 161 }; 162 163 //............................................................................. 164 } //namespace chart 165 //............................................................................. 166 #endif 167