1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "axisline_p.h"
5
6QT_BEGIN_NAMESPACE
7
8AxisLine::AxisLine(QQuickItem *parent) :
9 QQuickShaderEffect(parent)
10{
11
12}
13
14AxisLine::~AxisLine() {}
15
16void AxisLine::componentComplete()
17{
18 QQuickShaderEffect::componentComplete();
19 setupShaders();
20}
21
22void AxisLine::geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
23{
24 m_iResolution = QVector3D(newGeometry.width(), newGeometry.height(), 1.0);
25 emit iResolutionChanged();
26
27 QQuickShaderEffect::geometryChange(newGeometry, oldGeometry);
28}
29
30void AxisLine::setupShaders()
31{
32 if (m_isHorizontal) {
33 setFragmentShader(QUrl(QStringLiteral("qrc:/shaders/lineshaderhorizontal.frag.qsb")));
34 setVertexShader(QUrl(QStringLiteral("qrc:/shaders/lineshaderhorizontal.vert.qsb")));
35 } else {
36 setFragmentShader(QUrl(QStringLiteral("qrc:/shaders/lineshadervertical.frag.qsb")));
37 setVertexShader(QUrl(QStringLiteral("qrc:/shaders/lineshadervertical.vert.qsb")));
38 }
39}
40
41QVector3D AxisLine::iResolution() const
42{
43 return m_iResolution;
44}
45
46qreal AxisLine::smoothing() const
47{
48 return m_smoothing;
49}
50
51void AxisLine::setSmoothing(qreal newSmoothing)
52{
53 if (qFuzzyCompare(p1: m_smoothing, p2: newSmoothing))
54 return;
55 m_smoothing = newSmoothing;
56 emit smoothingChanged();
57}
58
59QColor AxisLine::color() const
60{
61 return m_color;
62}
63
64void AxisLine::setColor(QColor newColor)
65{
66 if (m_color == newColor)
67 return;
68 m_color = newColor;
69 emit colorChanged();
70}
71
72qreal AxisLine::lineWidth() const
73{
74 return m_lineWidth;
75}
76
77void AxisLine::setLineWidth(qreal newLineWidth)
78{
79 if (qFuzzyCompare(p1: m_lineWidth, p2: newLineWidth))
80 return;
81 m_lineWidth = newLineWidth;
82 emit lineWidthChanged();
83}
84
85bool AxisLine::isHorizontal() const
86{
87 return m_isHorizontal;
88}
89
90void AxisLine::setIsHorizontal(bool newIsHorizontal)
91{
92 if (m_isHorizontal == newIsHorizontal)
93 return;
94 m_isHorizontal = newIsHorizontal;
95 emit isHorizontalChanged();
96}
97
98QT_END_NAMESPACE
99

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtgraphs/src/graphs2d/axis/axisline.cpp