LibreOffice Module chart2 (master) 1
Tickmarks_Equidistant.hxx
Go to the documentation of this file.
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#pragma once
20
21#include "Tickmarks.hxx"
22#include <memory>
23
24#include <o3tl/safeint.hxx>
25
26namespace chart
27{
28
30{
31public:
32 EquidistantTickIter( const css::uno::Sequence< css::uno::Sequence< double > >& rTicks
33 , const ExplicitIncrementData& rIncrement
34 , sal_Int32 nMaxDepth );
36 , const ExplicitIncrementData& rIncrement
37 , sal_Int32 nMaxDepth );
38 virtual ~EquidistantTickIter() override;
39
40 double* firstValue();
41 double* nextValue();
42
43 virtual TickInfo* firstInfo() override;
44 virtual TickInfo* nextInfo() override;
45
46private: //methods
47 sal_Int32 getIntervalCount( sal_Int32 nDepth );
48 bool isAtLastPartTick();
49
50 void initIter( sal_Int32 nMaxDepth );
51 sal_Int32 getStartDepth() const;
52
53 bool gotoFirst();
54 bool gotoNext();
55
56 double getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const
57 {
59 return (*m_pSimpleTicks)[nDepth][nIndex];
60 else
61 {
62 if ((*m_pInfoTicks)[nDepth].size() <= o3tl::make_unsigned(nIndex))
63 return std::numeric_limits<double>::max();
64 return (((*m_pInfoTicks)[nDepth])[nIndex]).fScaledTickValue;
65 }
66 }
67 sal_Int32 getTickCount( sal_Int32 nDepth ) const
68 {
70 return (*m_pSimpleTicks)[nDepth].getLength();
71 else
72 return (*m_pInfoTicks)[nDepth].size();
73 }
74 sal_Int32 getMaxDepth() const
75 {
77 return (*m_pSimpleTicks).getLength()-1;
78 else
79 return (*m_pInfoTicks).size()-1;
80 }
81
82private: //member
83 const css::uno::Sequence< css::uno::Sequence< double > >* m_pSimpleTicks;
86 sal_Int32 m_nMaxDepth;
87 sal_Int32 m_nTickCount;
88 std::unique_ptr<sal_Int32[]>
89 m_pnPositions; //current positions in the different sequences
90 std::unique_ptr<sal_Int32[]>
91 m_pnPreParentCount; //the tickmarks do not start with a major tick always,
92 //the PreParentCount states for each depth how many subtickmarks are available in front of the first parent tickmark
93 std::unique_ptr<bool[]>
95 sal_Int32 m_nCurrentDepth;
96 sal_Int32 m_nCurrentPos;
98};
99
101{
102public:
104 ExplicitScaleData aScale
105 , ExplicitIncrementData aIncrement );
107
108 void getAllTicks( TickInfoArraysType& rAllTickInfos ) const;
109 void getAllTicksShifted( TickInfoArraysType& rAllTickInfos ) const;
110
111 static double getMinimumAtIncrement( double fMin, const ExplicitIncrementData& rIncrement );
112 static double getMaximumAtIncrement( double fMax, const ExplicitIncrementData& rIncrement );
113
114private: //methods
115 void addSubTicks( sal_Int32 nDepth,
116 css::uno::Sequence< css::uno::Sequence< double > >& rParentTicks ) const;
117 double* getMajorTick( sal_Int32 nTick ) const;
118 double* getMinorTick( sal_Int32 nTick, sal_Int32 nDepth
119 , double fStartParentTick, double fNextParentTick ) const;
120 sal_Int32 getMaxTickCount( sal_Int32 nDepth ) const;
121 sal_Int32 getTickDepth() const;
122
123 bool isVisible( double fValue ) const;
124 bool isWithinOuterBorder( double fScaledValue ) const; //all within the outer major tick marks
125
126private: //member
129 css::uno::Reference< css::chart2::XScaling > m_xInverseScaling;
130
131 //minimum and maximum of the visible range after scaling
134
135 std::unique_ptr<double[]>
137 //major-tick positions that may lay outside the visible range but complete partly visible intervals at the borders
142};
143
144} //namespace chart
145
146/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::chart2::XScaling > m_xInverseScaling
static double getMinimumAtIncrement(double fMin, const ExplicitIncrementData &rIncrement)
bool isWithinOuterBorder(double fScaledValue) const
std::unique_ptr< double[]> m_pfCurrentValues
void getAllTicksShifted(TickInfoArraysType &rAllTickInfos) const
double * getMinorTick(sal_Int32 nTick, sal_Int32 nDepth, double fStartParentTick, double fNextParentTick) const
void addSubTicks(sal_Int32 nDepth, css::uno::Sequence< css::uno::Sequence< double > > &rParentTicks) const
static double getMaximumAtIncrement(double fMax, const ExplicitIncrementData &rIncrement)
bool isVisible(double fValue) const
EquidistantTickFactory(ExplicitScaleData aScale, ExplicitIncrementData aIncrement)
void getAllTicks(TickInfoArraysType &rAllTickInfos) const
sal_Int32 getMaxTickCount(sal_Int32 nDepth) const
double * getMajorTick(sal_Int32 nTick) const
sal_Int32 getIntervalCount(sal_Int32 nDepth)
double getTickValue(sal_Int32 nDepth, sal_Int32 nIndex) const
std::unique_ptr< sal_Int32[]> m_pnPreParentCount
virtual TickInfo * nextInfo() override
const ExplicitIncrementData & m_rIncrement
const css::uno::Sequence< css::uno::Sequence< double > > * m_pSimpleTicks
void initIter(sal_Int32 nMaxDepth)
EquidistantTickIter(const css::uno::Sequence< css::uno::Sequence< double > > &rTicks, const ExplicitIncrementData &rIncrement, sal_Int32 nMaxDepth)
virtual TickInfo * firstInfo() override
std::unique_ptr< sal_Int32[]> m_pnPositions
std::unique_ptr< bool[]> m_pbIntervalFinished
sal_Int32 getTickCount(sal_Int32 nDepth) const
sal_Int32 nIndex
size
std::vector< TickInfoArrayType > TickInfoArraysType
Definition: Tickmarks.hxx:59
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
describes how tickmarks are positioned on the scale of an axis.
This structure contains the explicit values for a scale like Minimum and Maximum.