1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the QtGraphs API. It exists purely as an
10// implementation detail. This header file may change from version to
11// version without notice, or even be removed.
12//
13// We mean it.
14
15#ifndef AXISHELPER_P_H
16#define AXISHELPER_P_H
17
18#include "graphsglobal_p.h"
19#include <qvalue3daxisformatter_p.h>
20#include <QList>
21
22QT_BEGIN_NAMESPACE
23class AxisHelper : public QObject
24{
25 Q_OBJECT
26public:
27 AxisHelper();
28 virtual ~AxisHelper();
29 void updatePositions();
30
31 inline float scale() { return m_scale; }
32 inline void setScale(float scale) { m_scale = scale; }
33
34 inline float translate() { return m_translate; }
35 inline void setTranslate(float translate) { m_translate = translate; }
36
37 inline QValue3DAxisFormatter *formatter() { return m_formatter; }
38 inline void setFormatter(QValue3DAxisFormatter *formatter) { m_formatter = formatter; }
39
40 inline float itemPositionAt(float value)
41 {
42 return m_formatter->positionAt(value) * m_scale + m_translate;
43 }
44
45 inline float labelPositionAt(int index)
46 {
47 return m_formatter->labelPositions().at(i: index) * m_scale + m_translate;
48 }
49 inline float gridPositionAt(int gridLine)
50 {
51 return m_formatter->gridPositions().at(i: gridLine) * m_scale + m_translate;
52 }
53
54 inline float subGridPositionAt(int gridLine)
55 {
56 return m_formatter->subGridPositions().at(i: gridLine) * m_scale + m_translate;
57 }
58
59 inline void setMin(float min) { m_min = min; }
60 inline float min() const { return m_min; }
61 inline void setMax(float max) { m_max = max; }
62 inline float max() const { return m_max; }
63
64 inline void setReversed(bool enable) { m_reversed = enable; }
65 inline bool isReversed() const { return m_reversed; }
66
67private:
68 QList<float> m_adjustedGridPositions;
69 QList<float> m_adjustedSubGridPositions;
70
71 float m_scale;
72 float m_translate;
73 QValue3DAxisFormatter *m_formatter;
74
75 float m_min;
76 float m_max;
77
78 bool m_reversed = false;
79};
80
81QT_END_NAMESPACE
82
83#endif // AXISHELPER_P_H
84

source code of qtgraphs/src/graphs/engine/axishelper_p.h