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 _CHART2_TICKMARKS_EQUIDISTANT_HXX
20 : #define _CHART2_TICKMARKS_EQUIDISTANT_HXX
21 :
22 : #include "Tickmarks.hxx"
23 :
24 : //.............................................................................
25 : namespace chart
26 : {
27 : //.............................................................................
28 :
29 : using ::basegfx::B2DVector;
30 : //-----------------------------------------------------------------------------
31 : /**
32 : */
33 :
34 : class EquidistantTickIter : public TickIter
35 : {
36 : public:
37 : EquidistantTickIter( const ::com::sun::star::uno::Sequence<
38 : ::com::sun::star::uno::Sequence< double > >& rTicks
39 : , const ExplicitIncrementData& rIncrement
40 : , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
41 : EquidistantTickIter( ::std::vector< ::std::vector< TickInfo > >& rTickInfos
42 : , const ExplicitIncrementData& rIncrement
43 : , sal_Int32 nMinDepth=0, sal_Int32 nMaxDepth=-1 );
44 : virtual ~EquidistantTickIter();
45 :
46 : virtual double* firstValue();
47 : virtual double* nextValue();
48 :
49 : virtual TickInfo* firstInfo();
50 : virtual TickInfo* nextInfo();
51 :
52 : sal_Int32 getCurrentDepth() const { return m_nCurrentDepth; }
53 :
54 : private: //methods
55 : sal_Int32 getIntervalCount( sal_Int32 nDepth );
56 : bool isAtLastPartTick();
57 :
58 : void initIter( sal_Int32 nMinDepth, sal_Int32 nMaxDepth );
59 : sal_Int32 getStartDepth() const;
60 :
61 : bool gotoFirst();
62 : bool gotoNext();
63 :
64 :
65 2993 : double getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const
66 : {
67 2993 : if(m_pSimpleTicks)
68 2337 : return (*m_pSimpleTicks)[nDepth][nIndex];
69 : else
70 656 : return (((*m_pInfoTicks)[nDepth])[nIndex]).fScaledTickValue;
71 : }
72 1189 : sal_Int32 getTickCount( sal_Int32 nDepth ) const
73 : {
74 1189 : if(m_pSimpleTicks)
75 574 : return (*m_pSimpleTicks)[nDepth].getLength();
76 : else
77 615 : return (*m_pInfoTicks)[nDepth].size();
78 : }
79 410 : sal_Int32 getMaxDepth() const
80 : {
81 410 : if(m_pSimpleTicks)
82 287 : return (*m_pSimpleTicks).getLength()-1;
83 : else
84 123 : return (*m_pInfoTicks).size()-1;
85 : }
86 :
87 : private: //member
88 : const ::com::sun::star::uno::Sequence<
89 : ::com::sun::star::uno::Sequence< double > >* m_pSimpleTicks;
90 : ::std::vector< ::std::vector< TickInfo > >* m_pInfoTicks;
91 : const ExplicitIncrementData& m_rIncrement;
92 : sal_Int32 m_nMaxDepth;
93 : sal_Int32 m_nTickCount;
94 : sal_Int32* m_pnPositions; //current positions in the different sequences
95 : sal_Int32* m_pnPreParentCount; //the tickmarks do not start with a major tick always,
96 : //the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark
97 : bool* m_pbIntervalFinished;
98 : sal_Int32 m_nCurrentDepth;
99 : sal_Int32 m_nCurrentPos;
100 : double m_fCurrentValue;
101 : };
102 :
103 : class EquidistantTickFactory
104 : {
105 : public:
106 : EquidistantTickFactory(
107 : const ExplicitScaleData& rScale
108 : , const ExplicitIncrementData& rIncrement );
109 : ~EquidistantTickFactory();
110 :
111 : void getAllTicks( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
112 : void getAllTicksShifted( ::std::vector< ::std::vector< TickInfo > >& rAllTickInfos ) const;
113 :
114 : static double getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement );
115 : static double getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement );
116 :
117 : private: //methods
118 : void addSubTicks( sal_Int32 nDepth,
119 : ::com::sun::star::uno::Sequence<
120 : ::com::sun::star::uno::Sequence< double > >& rParentTicks ) const;
121 : double* getMajorTick( sal_Int32 nTick ) const;
122 : double* getMinorTick( sal_Int32 nTick, sal_Int32 nDepth
123 : , double fStartParentTick, double fNextParentTick ) const;
124 : sal_Int32 getMaxTickCount( sal_Int32 nDepth = 0 ) const;
125 : sal_Int32 getTickDepth() const;
126 :
127 : bool isVisible( double fValue ) const;
128 : bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks
129 :
130 : private: //member
131 : ExplicitScaleData m_rScale;
132 : ExplicitIncrementData m_rIncrement;
133 : ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XScaling >
134 : m_xInverseScaling;
135 :
136 : //minimum and maximum of the visible range after scaling
137 : double m_fScaledVisibleMin;
138 : double m_fScaledVisibleMax;
139 :
140 : double* m_pfCurrentValues;
141 : //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders
142 : double m_fOuterMajorTickBorderMin;
143 : double m_fOuterMajorTickBorderMax;
144 : double m_fOuterMajorTickBorderMin_Scaled;
145 : double m_fOuterMajorTickBorderMax_Scaled;
146 : };
147 :
148 : //.............................................................................
149 : } //namespace chart
150 : //.............................................................................
151 : #endif
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|