summaryrefslogtreecommitdiffstats
path: root/src/graphs2d/axis/axisticker.cpp
blob: 891df8b156705b7f4a8e47c2cef30c9322d537c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include "axisticker_p.h"

QT_BEGIN_NAMESPACE

AxisTicker::AxisTicker(QQuickItem *parent) :
      QQuickShaderEffect(parent)
{
}

AxisTicker::~AxisTicker() {}

void AxisTicker::componentComplete()
{
    QQuickShaderEffect::componentComplete();
    setupShaders();
}

void AxisTicker::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
{
    m_iResolution = QVector3D(newGeometry.width(), newGeometry.height(), 1.0);
    emit iResolutionChanged();

    QQuickShaderEffect::geometryChange(newGeometry, oldGeometry);
}

void AxisTicker::setupShaders()
{
    if (m_isHorizontal) {
        setFragmentShader(QUrl(QStringLiteral("qrc:/shaders/tickershaderhorizontal.frag.qsb")));
        setVertexShader(QUrl(QStringLiteral("qrc:/shaders/tickershaderhorizontal.vert.qsb")));
    } else {
        setFragmentShader(QUrl(QStringLiteral("qrc:/shaders/tickershader.frag.qsb")));
        setVertexShader(QUrl(QStringLiteral("qrc:/shaders/tickershader.vert.qsb")));
    }
}

QVector3D AxisTicker::iResolution() const
{
    return m_iResolution;
}

qreal AxisTicker::smoothing() const
{
    return m_smoothing;
}

void AxisTicker::setSmoothing(qreal newSmoothing)
{
    if (qFuzzyCompare(m_smoothing, newSmoothing))
        return;
    m_smoothing = newSmoothing;
    emit smoothingChanged();
}

int AxisTicker::origo() const
{
    return m_origo;
}

void AxisTicker::setOrigo(int newOrigo)
{
    if (m_origo == newOrigo)
        return;
    m_origo = newOrigo;
    emit origoChanged();
}

bool AxisTicker::subTicksVisible() const
{
    return m_subTicksVisible;
}

void AxisTicker::setSubTicksVisible(bool newSubTicksVisible)
{
    if (m_subTicksVisible == newSubTicksVisible)
        return;
    m_subTicksVisible = newSubTicksVisible;
    emit subTicksVisibleChanged();
}

qreal AxisTicker::spacing() const
{
    return m_spacing;
}

void AxisTicker::setSpacing(qreal newSpacing)
{
    if (qFuzzyCompare(m_spacing, newSpacing))
        return;
    m_spacing = newSpacing;
    emit spacingChanged();
}

qreal AxisTicker::displacement() const
{
    return m_displacement;
}

void AxisTicker::setDisplacement(qreal newDisplacement)
{
    if (qFuzzyCompare(m_displacement, newDisplacement))
        return;
    m_displacement = newDisplacement;
    emit displacementChanged();
}

QColor AxisTicker::subTickColor() const
{
    return m_subTickColor;
}

void AxisTicker::setSubTickColor(QColor newSubTickColor)
{
    if (m_subTickColor == newSubTickColor)
        return;
    m_subTickColor = newSubTickColor;
    emit subTickColorChanged();
}

QColor AxisTicker::tickColor() const
{
    return m_tickColor;
}

void AxisTicker::setTickColor(QColor newTickColor)
{
    if (m_tickColor == newTickColor)
        return;
    m_tickColor = newTickColor;
    emit tickColorChanged();
}

qreal AxisTicker::subTickLineWidth() const
{
    return m_subTickLineWidth;
}

void AxisTicker::setSubTickLineWidth(qreal newSubTickLineWidth)
{
    if (qFuzzyCompare(m_subTickLineWidth, newSubTickLineWidth))
        return;
    m_subTickLineWidth = newSubTickLineWidth;
    emit subTickLineWidthChanged();
}

qreal AxisTicker::tickLineWidth() const
{
    return m_tickLineWidth;
}

void AxisTicker::setTickLineWidth(qreal newTickLineWidth)
{
    if (qFuzzyCompare(m_tickLineWidth, newTickLineWidth))
        return;
    m_tickLineWidth = newTickLineWidth;
    emit tickLineWidthChanged();
}

qreal AxisTicker::subTickScale() const
{
    return m_subTickScale;
}

void AxisTicker::setSubTickScale(qreal newSubTickScale)
{
    if (qFuzzyCompare(m_subTickScale, newSubTickScale))
        return;
    m_subTickScale = newSubTickScale;
    emit subTickScaleChanged();
}

qreal AxisTicker::subTickLength() const
{
    return m_subTickLength;
}

void AxisTicker::setSubTickLength(qreal newSubTickLength)
{
    if (qFuzzyCompare(m_subTickLength, newSubTickLength))
        return;
    m_subTickLength = newSubTickLength;
    emit subTickLengthChanged();
}

bool AxisTicker::isHorizontal() const
{
    return m_isHorizontal;
}

void AxisTicker::setIsHorizontal(bool newIsHorizontal)
{
    if (m_isHorizontal == newIsHorizontal)
        return;
    m_isHorizontal = newIsHorizontal;
    setupShaders();
    emit isHorizontalChanged();
}

bool AxisTicker::isFlipped() const
{
    return m_flipped;
}

void AxisTicker::setFlipped(bool newFlipped)
{
    if (m_flipped == newFlipped)
        return;
    m_flipped = newFlipped;
    emit flippedChanged();
}

QT_END_NAMESPACE