summaryrefslogtreecommitdiffstats
path: root/src/graphs2d/axis/axisline_p.h
blob: 59c5416b3fffabaff6d3dfce2a0f136d8fcbce69 (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#ifndef AXISLINE_H
#define AXISLINE_H

//  W A R N I N G
//  -------------
//
// This file is not part of the QtGraphs API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.

#include <QtQuick/private/qquickshadereffect_p.h>
#include <QQmlEngine>

QT_BEGIN_NAMESPACE

class AxisLine : public QQuickShaderEffect
{
    Q_OBJECT
    Q_PROPERTY(QVector3D iResolution READ iResolution NOTIFY iResolutionChanged FINAL)
    Q_PROPERTY(qreal smoothing READ smoothing WRITE setSmoothing NOTIFY smoothingChanged FINAL)
    Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged FINAL)
    Q_PROPERTY(qreal lineWidth READ lineWidth WRITE setLineWidth NOTIFY lineWidthChanged FINAL)
    Q_PROPERTY(bool isHorizontal READ isHorizontal WRITE setIsHorizontal NOTIFY isHorizontalChanged FINAL)
public:
    explicit AxisLine(QQuickItem *parent = nullptr);
    ~AxisLine() override;
    void setupShaders();

    QVector3D iResolution() const;

    qreal smoothing() const;
    void setSmoothing(qreal newSmoothing);

    QColor color() const;
    void setColor(QColor newColor);

    qreal lineWidth() const;
    void setLineWidth(qreal newLineWidth);

    bool isHorizontal() const;
    void setIsHorizontal(bool newIsHorizontal);

protected:
    void componentComplete() override;
    void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;

Q_SIGNALS:
    void iResolutionChanged();
    void smoothingChanged();
    void colorChanged();
    void lineWidthChanged();
    void isHorizontalChanged();

private:
    friend class AxisRenderer;
    QVector3D m_iResolution;
    qreal m_smoothing = 1.0;
    QColor m_color = QColor(255, 255, 255);
    qreal m_lineWidth = 2.0;
    bool m_isHorizontal = false;
};

QT_END_NAMESPACE

#endif // AXISLINE_H