1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICKGRAPHSNODE_P_H
5#define QQUICKGRAPHSNODE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the QtGraphs API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16
17#include "qgraphs3dnamespace.h"
18#include "qquickgraphsitem_p.h"
19#include <QtQuick3D/private/qquick3dnode_p.h>
20
21QT_BEGIN_NAMESPACE
22
23class Q_GRAPHS_EXPORT QQuickGraphsNode : public QQuick3DNode
24{
25 Q_OBJECT
26 Q_PROPERTY(QtGraphs3D::SelectionFlags selectionMode READ selectionMode WRITE setSelectionMode
27 NOTIFY selectionModeChanged)
28 Q_PROPERTY(QGraphsTheme *theme READ theme WRITE setTheme NOTIFY themeChanged)
29 Q_PROPERTY(QQmlListProperty<QCustom3DItem> customItemList READ customItemList CONSTANT)
30 Q_PROPERTY(
31 QtGraphs3D::ElementType selectedElement READ selectedElement NOTIFY selectedElementChanged)
32 Q_PROPERTY(qreal aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged)
33 Q_PROPERTY(QtGraphs3D::OptimizationHint optimizationHint READ optimizationHint WRITE
34 setOptimizationHint NOTIFY optimizationHintChanged)
35 Q_PROPERTY(bool polar READ isPolar WRITE setPolar NOTIFY polarChanged)
36 Q_PROPERTY(float labelMargin READ labelMargin WRITE setLabelMargin NOTIFY labelMarginChanged)
37 Q_PROPERTY(float radialLabelOffset READ radialLabelOffset WRITE setRadialLabelOffset NOTIFY
38 radialLabelOffsetChanged)
39 Q_PROPERTY(qreal horizontalAspectRatio READ horizontalAspectRatio WRITE setHorizontalAspectRatio
40 NOTIFY horizontalAspectRatioChanged)
41 Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged)
42 Q_PROPERTY(
43 QVector3D queriedGraphPosition READ queriedGraphPosition NOTIFY queriedGraphPositionChanged)
44 Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged)
45 Q_PROPERTY(QtGraphs3D::GridLineType gridLineType READ gridLineType WRITE setGridLineType NOTIFY
46 gridLineTypeChanged FINAL)
47
48 QML_NAMED_ELEMENT(GraphsNode)
49 QML_UNCREATABLE("")
50
51public:
52 explicit QQuickGraphsNode(QQuick3DNode *parent = nullptr);
53 ~QQuickGraphsNode();
54
55 void componentComplete() override;
56
57 QtGraphs3D::ElementType selectedElement() const;
58
59 virtual void setSelectionMode(QtGraphs3D::SelectionFlags selectionMode);
60 QtGraphs3D::SelectionFlags selectionMode() const;
61
62 void setTheme(QGraphsTheme *theme);
63 QGraphsTheme *theme() const;
64
65 QQmlListProperty<QCustom3DItem> customItemList() const;
66
67 void setAspectRatio(qreal aspectRatio);
68 qreal aspectRatio() const;
69
70 void setOptimizationHint(QtGraphs3D::OptimizationHint optimizationHint);
71 QtGraphs3D::OptimizationHint optimizationHint() const;
72
73 void setPolar(bool enabled);
74 bool isPolar() const;
75
76 void setLabelMargin(float labelMargin);
77 float labelMargin() const;
78
79 void setRadialLabelOffset(float radialLabelOffset);
80 float radialLabelOffset() const;
81
82 void setHorizontalAspectRatio(qreal horizontalAspectRatio);
83 qreal horizontalAspectRatio() const;
84
85 void setLocale(QLocale locale);
86 QLocale locale() const;
87
88 QVector3D queriedGraphPosition() const;
89
90 void setMargin(qreal margin);
91 qreal margin() const;
92
93 QtGraphs3D::GridLineType gridLineType() const;
94 void setGridLineType(const QtGraphs3D::GridLineType &gridLineType);
95
96 Q_INVOKABLE virtual bool hasSeries(QAbstract3DSeries *series);
97 Q_INVOKABLE virtual void clearSelection() = 0;
98
99 virtual void addSeriesInternal(QAbstract3DSeries *series);
100 void insertSeries(qsizetype index, QAbstract3DSeries *series);
101 virtual void removeSeriesInternal(QAbstract3DSeries *series);
102 QList<QAbstract3DSeries *> seriesList();
103
104 Q_INVOKABLE virtual qsizetype addCustomItem(QCustom3DItem *item);
105 Q_INVOKABLE virtual void removeCustomItems();
106 Q_INVOKABLE virtual void removeCustomItem(QCustom3DItem *item);
107 Q_INVOKABLE virtual void removeCustomItemAt(QVector3D position);
108 Q_INVOKABLE virtual void releaseCustomItem(QCustom3DItem *item);
109
110 Q_INVOKABLE virtual int selectedLabelIndex() const;
111 Q_INVOKABLE virtual QAbstract3DAxis *selectedAxis() const;
112
113 Q_INVOKABLE virtual qsizetype selectedCustomItemIndex() const;
114 Q_INVOKABLE virtual QCustom3DItem *selectedCustomItem() const;
115
116 Q_INVOKABLE virtual bool doPicking(QPointF point) = 0;
117 Q_INVOKABLE virtual bool doRayPicking(const QVector3D &origin, const QVector3D &direction) = 0;
118
119protected:
120 void setGraphParent();
121 std::unique_ptr<QQuickGraphsItem> m_graph;
122 QList<QAbstract3DSeries *> m_seriesList;
123 QtGraphs3D::SelectionFlags m_selectionMode;
124
125 QAbstract3DAxis *m_axisX = nullptr;
126 QAbstract3DAxis *m_axisY = nullptr;
127 QAbstract3DAxis *m_axisZ = nullptr;
128
129Q_SIGNALS:
130 void queriedGraphPositionChanged();
131 void selectedElementChanged();
132 void optimizationHintChanged();
133 void selectionModeChanged();
134 void themeChanged();
135 void aspectRatioChanged();
136 void polarChanged();
137 void labelMarginChanged();
138 void radialLabelOffsetChanged();
139 void horizontalAspectRatioChanged();
140 void localeChanged();
141 void marginChanged(qreal margin);
142 void gridLineTypeChanged();
143
144private:
145 QGraphsTheme *m_theme = nullptr;
146 qreal m_aspectRatio;
147 QtGraphs3D::OptimizationHint m_optimizationHint;
148 bool m_polar;
149 float m_labelMargin;
150 float m_radialLabelOffset;
151 qreal m_horizontalAspectRatio;
152 QLocale m_locale;
153 qreal m_margin;
154 QtGraphs3D::GridLineType m_gridLineType;
155 QList<QCustom3DItem *> m_customItemList = {};
156};
157
158QT_END_NAMESPACE
159
160#endif // QQUICKGRAPHSNODE_P_H
161

source code of qtgraphs/src/graphs3d/qml/qquickgraphsnode_p.h