1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef AXISGRID_H
5#define AXISGRID_H
6
7// W A R N I N G
8// -------------
9//
10// This file is not part of the QtGraphs API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15
16#include <QtQuick/private/qquickshadereffect_p.h>
17
18QT_BEGIN_NAMESPACE
19
20class AxisGrid : public QQuickShaderEffect
21{
22 Q_OBJECT
23 Q_PROPERTY(QVector3D iResolution READ iResolution NOTIFY iResolutionChanged FINAL)
24 Q_PROPERTY(qreal smoothing READ smoothing WRITE setSmoothing NOTIFY smoothingChanged FINAL)
25 Q_PROPERTY(int origo READ origo WRITE setOrigo NOTIFY origoChanged FINAL)
26 Q_PROPERTY(QVector4D gridVisibility READ gridVisibility WRITE setGridVisibility NOTIFY gridVisibilityChanged FINAL)
27 Q_PROPERTY(qreal gridWidth READ gridWidth WRITE setGridWidth NOTIFY gridWidthChanged FINAL)
28 Q_PROPERTY(qreal gridHeight READ gridHeight WRITE setGridHeight NOTIFY gridHeightChanged FINAL)
29 Q_PROPERTY(QPointF gridMovement READ gridMovement WRITE setGridMovement NOTIFY gridMovementChanged FINAL)
30 Q_PROPERTY(QColor subGridColor READ subGridColor WRITE setSubGridColor NOTIFY subGridColorChanged FINAL)
31 Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor NOTIFY gridColorChanged FINAL)
32 Q_PROPERTY(QColor plotAreaBackgroundColor READ plotAreaBackgroundColor
33 WRITE setPlotAreaBackgroundColor NOTIFY plotAreaBackgroundColorChanged FINAL)
34 Q_PROPERTY(qreal subGridLineWidth READ subGridLineWidth WRITE setSubGridLineWidth NOTIFY subGridLineWidthChanged FINAL)
35 Q_PROPERTY(qreal gridLineWidth READ gridLineWidth WRITE setGridLineWidth NOTIFY gridLineWidthChanged FINAL)
36 Q_PROPERTY(qreal verticalSubGridScale READ verticalSubGridScale WRITE setVerticalSubGridScale NOTIFY verticalSubGridScaleChanged FINAL)
37 Q_PROPERTY(qreal horizontalSubGridScale READ horizontalSubGridScale WRITE setHorizontalSubGridScale NOTIFY horizontalSubGridScaleChanged FINAL)
38public:
39 AxisGrid(QQuickItem *parent = nullptr);
40 ~AxisGrid() override;
41 void setupShaders();
42
43 QVector3D iResolution() const;
44
45 qreal smoothing() const;
46 void setSmoothing(qreal newSmoothing);
47
48 int origo() const;
49 void setOrigo(int newOrigo);
50
51 QVector4D gridVisibility() const;
52 void setGridVisibility(const QVector4D &newGridVisibility);
53
54 qreal gridWidth() const;
55 void setGridWidth(qreal newGridWidth);
56
57 qreal gridHeight() const;
58 void setGridHeight(qreal newGridHeight);
59
60 QPointF gridMovement() const;
61 void setGridMovement(QPointF newGridMovement);
62
63 QColor subGridColor() const;
64 void setSubGridColor(QColor newSubGridColor);
65
66 QColor gridColor() const;
67 void setGridColor(QColor newGridColor);
68
69 QColor plotAreaBackgroundColor() const;
70 void setPlotAreaBackgroundColor(QColor color);
71
72 qreal subGridLineWidth() const;
73 void setSubGridLineWidth(qreal newSubGridLineWidth);
74
75 qreal gridLineWidth() const;
76 void setGridLineWidth(qreal newGridLineWidth);
77
78 qreal verticalSubGridScale() const;
79 void setVerticalSubGridScale(qreal newVerticalSubGridScale);
80
81 qreal horizontalSubGridScale() const;
82 void setHorizontalSubGridScale(qreal newHorizontalSubGridScale);
83
84protected:
85 void componentComplete() override;
86 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
87
88Q_SIGNALS:
89 void iResolutionChanged();
90 void smoothingChanged();
91 void origoChanged();
92 void gridVisibilityChanged();
93 void gridWidthChanged();
94 void gridHeightChanged();
95 void gridMovementChanged();
96 void subGridColorChanged();
97 void gridColorChanged();
98 void plotAreaBackgroundColorChanged();
99 void subGridLineWidthChanged();
100 void gridLineWidthChanged();
101 void verticalSubGridScaleChanged();
102 void horizontalSubGridScaleChanged();
103
104private:
105 friend class AxisRenderer;
106 qreal m_smoothing = 1.0;
107 QVector3D m_iResolution;
108 int m_origo = 0;
109 QVector4D m_gridVisibility = QVector4D(1, 1, 1, 1);
110 qreal m_gridWidth = 100;
111 qreal m_gridHeight = 100;
112 QPointF m_gridMovement;
113 QColor m_subGridColor = QColor(150, 150, 150);
114 QColor m_gridColor = QColor(255, 255, 255);
115 QColor m_plotAreaBackgroundColor = QColor(0, 0, 0, 0);
116 qreal m_subGridLineWidth = 1.0;
117 qreal m_gridLineWidth = 2.0;
118 qreal m_verticalSubGridScale = 0.1;
119 qreal m_horizontalSubGridScale = 0.1;
120};
121
122QT_END_NAMESPACE
123
124#endif // AXISGRID_H
125

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtgraphs/src/graphs2d/axis/axisgrid_p.h