1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef Q3DGRAPHSWIDGETITEM_H
5#define Q3DGRAPHSWIDGETITEM_H
6
7#include <QtCore/qlocale.h>
8#include <QtGraphs/q3dscene.h>
9#include <QtGraphs/qgraphs3dnamespace.h>
10#include <QtGraphs/qgraphstheme.h>
11#include <QtGraphsWidgets/qgraphswidgetsglobal.h>
12#include <QtQuick/qquickitemgrabresult.h>
13#include <QtQuickWidgets/qquickwidget.h>
14
15QT_BEGIN_NAMESPACE
16
17class QCustom3DItem;
18class QAbstract3DAxis;
19class QAbstract3DSeries;
20class QQuickGraphsItem;
21class QQuickItemGrabResult;
22class QQuickWheelEvent;
23class Q3DGraphsWidgetItemPrivate;
24
25class Q_GRAPHSWIDGETS_EXPORT Q3DGraphsWidgetItem : public QObject
26{
27 Q_OBJECT
28 Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
29 Q_PROPERTY(QGraphsTheme *activeTheme READ activeTheme WRITE setActiveTheme NOTIFY activeThemeChanged)
30 Q_PROPERTY(QtGraphs3D::SelectionFlags selectionMode READ selectionMode WRITE setSelectionMode
31 NOTIFY selectionModeChanged)
32 Q_PROPERTY(QtGraphs3D::ShadowQuality shadowQuality READ shadowQuality WRITE setShadowQuality
33 NOTIFY shadowQualityChanged)
34 Q_PROPERTY(Q3DScene *scene READ scene CONSTANT)
35 Q_PROPERTY(bool measureFps READ measureFps WRITE setMeasureFps NOTIFY measureFpsChanged)
36 Q_PROPERTY(int currentFps READ currentFps NOTIFY currentFpsChanged)
37 Q_PROPERTY(bool orthoProjection READ isOrthoProjection WRITE setOrthoProjection NOTIFY
38 orthoProjectionChanged)
39 Q_PROPERTY(
40 QtGraphs3D::ElementType selectedElement READ selectedElement NOTIFY selectedElementChanged)
41 Q_PROPERTY(qreal aspectRatio READ aspectRatio WRITE setAspectRatio NOTIFY aspectRatioChanged)
42 Q_PROPERTY(QtGraphs3D::OptimizationHint optimizationHint READ optimizationHint WRITE
43 setOptimizationHint NOTIFY optimizationHintChanged)
44 Q_PROPERTY(bool polar READ isPolar WRITE setPolar NOTIFY polarChanged)
45 Q_PROPERTY(float labelMargin READ labelMargin WRITE setLabelMargin NOTIFY labelMarginChanged)
46 Q_PROPERTY(float radialLabelOffset READ radialLabelOffset WRITE setRadialLabelOffset NOTIFY
47 radialLabelOffsetChanged)
48 Q_PROPERTY(qreal horizontalAspectRatio READ horizontalAspectRatio WRITE setHorizontalAspectRatio
49 NOTIFY horizontalAspectRatioChanged)
50 Q_PROPERTY(QLocale locale READ locale WRITE setLocale NOTIFY localeChanged)
51 Q_PROPERTY(
52 QVector3D queriedGraphPosition READ queriedGraphPosition NOTIFY queriedGraphPositionChanged)
53 Q_PROPERTY(qreal margin READ margin WRITE setMargin NOTIFY marginChanged)
54 Q_PROPERTY(QtGraphs3D::CameraPreset cameraPreset READ cameraPreset WRITE setCameraPreset NOTIFY
55 cameraPresetChanged)
56 Q_PROPERTY(float cameraXRotation READ cameraXRotation WRITE setCameraXRotation NOTIFY
57 cameraXRotationChanged)
58 Q_PROPERTY(float cameraYRotation READ cameraYRotation WRITE setCameraYRotation NOTIFY
59 cameraYRotationChanged)
60 Q_PROPERTY(float cameraZoomLevel READ cameraZoomLevel WRITE setCameraZoomLevel NOTIFY
61 cameraZoomLevelChanged)
62 Q_PROPERTY(float minCameraZoomLevel READ minCameraZoomLevel WRITE setMinCameraZoomLevel NOTIFY
63 minCameraZoomLevelChanged)
64 Q_PROPERTY(float maxCameraZoomLevel READ maxCameraZoomLevel WRITE setMaxCameraZoomLevel NOTIFY
65 maxCameraZoomLevelChanged)
66 Q_PROPERTY(bool wrapCameraXRotation READ wrapCameraXRotation WRITE setWrapCameraXRotation NOTIFY
67 wrapCameraXRotationChanged)
68 Q_PROPERTY(bool wrapCameraYRotation READ wrapCameraYRotation WRITE setWrapCameraYRotation NOTIFY
69 wrapCameraYRotationChanged)
70 Q_PROPERTY(float minCameraXRotation READ minCameraXRotation WRITE setMinCameraXRotation NOTIFY
71 minCameraXRotationChanged)
72 Q_PROPERTY(float maxCameraXRotation READ maxCameraXRotation WRITE setMaxCameraXRotation NOTIFY
73 maxCameraXRotationChanged)
74 Q_PROPERTY(float minCameraYRotation READ minCameraYRotation WRITE setMinCameraYRotation NOTIFY
75 minCameraYRotationChanged)
76 Q_PROPERTY(float maxCameraYRotation READ maxCameraYRotation WRITE setMaxCameraYRotation NOTIFY
77 maxCameraYRotationChanged)
78 Q_PROPERTY(QVector3D cameraTargetPosition READ cameraTargetPosition WRITE
79 setCameraTargetPosition NOTIFY cameraTargetPositionChanged)
80 Q_PROPERTY(int msaaSamples READ msaaSamples WRITE setMsaaSamples NOTIFY msaaSamplesChanged)
81 Q_PROPERTY(bool rotationEnabled READ isRotationEnabled WRITE setRotationEnabled NOTIFY
82 rotationEnabledChanged)
83 Q_PROPERTY(bool zoomAtTargetEnabled READ isZoomAtTargetEnabled WRITE setZoomAtTargetEnabled NOTIFY
84 zoomAtTargetEnabledChanged)
85 Q_PROPERTY(bool selectionEnabled READ isSelectionEnabled WRITE setSelectionEnabled NOTIFY
86 selectionEnabledChanged)
87 Q_PROPERTY(bool zoomEnabled READ isZoomEnabled WRITE setZoomEnabled NOTIFY
88 zoomEnabledChanged)
89
90 Q_PROPERTY(QColor lightColor READ lightColor WRITE setLightColor NOTIFY lightColorChanged)
91 Q_PROPERTY(float ambientLightStrength READ ambientLightStrength WRITE setAmbientLightStrength
92 NOTIFY ambientLightStrengthChanged)
93 Q_PROPERTY(
94 float lightStrength READ lightStrength WRITE setLightStrength NOTIFY lightStrengthChanged)
95 Q_PROPERTY(float shadowStrength READ shadowStrength WRITE setShadowStrength NOTIFY
96 shadowStrengthChanged)
97 Q_PROPERTY(QtGraphs3D::GridLineType gridLineType READ gridLineType WRITE setGridLineType NOTIFY
98 gridLineTypeChanged FINAL)
99
100public:
101 void addTheme(QGraphsTheme *theme);
102 void releaseTheme(QGraphsTheme *theme);
103 QGraphsTheme *activeTheme() const;
104 void setActiveTheme(QGraphsTheme *activeTheme);
105 QList<QGraphsTheme *> themes() const;
106
107 QtGraphs3D::ShadowQuality shadowQuality() const;
108 void setShadowQuality(const QtGraphs3D::ShadowQuality &shadowQuality);
109
110 QtGraphs3D::SelectionFlags selectionMode() const;
111 void setSelectionMode(const QtGraphs3D::SelectionFlags &selectionMode);
112
113 Q3DScene *scene() const;
114
115 void setMeasureFps(bool enable);
116 bool measureFps() const;
117 int currentFps() const;
118
119 void setOrthoProjection(bool enable);
120 bool isOrthoProjection() const;
121
122 QtGraphs3D::ElementType selectedElement() const;
123
124 void setAspectRatio(qreal ratio);
125 qreal aspectRatio() const;
126
127 void setOptimizationHint(QtGraphs3D::OptimizationHint hint);
128 QtGraphs3D::OptimizationHint optimizationHint() const;
129
130 void setPolar(bool enable);
131 bool isPolar() const;
132
133 void setLabelMargin(float margin);
134 float labelMargin() const;
135
136 void setRadialLabelOffset(float offset);
137 float radialLabelOffset() const;
138
139 void setHorizontalAspectRatio(qreal ratio);
140 qreal horizontalAspectRatio() const;
141
142 void setLocale(const QLocale &locale);
143 QLocale locale() const;
144
145 QVector3D queriedGraphPosition() const;
146
147 void setMargin(qreal margin);
148 qreal margin() const;
149
150 void clearSelection();
151
152 bool hasSeries(QAbstract3DSeries *series) const;
153
154 qsizetype addCustomItem(QCustom3DItem *item);
155 void removeCustomItems();
156 void removeCustomItem(QCustom3DItem *item);
157 void removeCustomItemAt(QVector3D position);
158 void releaseCustomItem(QCustom3DItem *item);
159 QList<QCustom3DItem *> customItems() const;
160
161 int selectedLabelIndex() const;
162 QAbstract3DAxis *selectedAxis() const;
163
164 qsizetype selectedCustomItemIndex() const;
165 QCustom3DItem *selectedCustomItem() const;
166
167 QSharedPointer<QQuickItemGrabResult> renderToImage(QSize imageSize = QSize()) const;
168
169 QtGraphs3D::CameraPreset cameraPreset() const;
170 void setCameraPreset(QtGraphs3D::CameraPreset preset);
171
172 float cameraXRotation() const;
173 void setCameraXRotation(float rotation);
174 float cameraYRotation() const;
175 void setCameraYRotation(float rotation);
176
177 float minCameraXRotation() const;
178 void setMinCameraXRotation(float rotation);
179 float maxCameraXRotation() const;
180 void setMaxCameraXRotation(float rotation);
181
182 float minCameraYRotation() const;
183 void setMinCameraYRotation(float rotation);
184 float maxCameraYRotation() const;
185 void setMaxCameraYRotation(float rotation);
186
187 void setZoomAtTargetEnabled(bool enable);
188 bool isZoomAtTargetEnabled() const;
189 void setZoomEnabled(bool enable);
190 bool isZoomEnabled() const;
191 void setSelectionEnabled(bool enable);
192 bool isSelectionEnabled() const;
193 void setRotationEnabled(bool enable);
194 bool isRotationEnabled() const;
195
196 void setDefaultInputHandler();
197 void unsetDefaultInputHandler();
198 void unsetDefaultTapHandler();
199 void unsetDefaultDragHandler();
200 void unsetDefaultWheelHandler();
201 void unsetDefaultPinchHandler();
202 void setDragButton(Qt::MouseButtons button);
203
204 float cameraZoomLevel() const;
205 void setCameraZoomLevel(float level);
206
207 float minCameraZoomLevel() const;
208 void setMinCameraZoomLevel(float level);
209
210 float maxCameraZoomLevel() const;
211 void setMaxCameraZoomLevel(float level);
212
213 QVector3D cameraTargetPosition() const;
214 void setCameraTargetPosition(QVector3D target);
215
216 bool wrapCameraXRotation() const;
217 void setWrapCameraXRotation(bool wrap);
218
219 bool wrapCameraYRotation() const;
220 void setWrapCameraYRotation(bool wrap);
221
222 void setCameraPosition(float horizontal, float vertical, float zoom = 100.0f);
223
224 int msaaSamples() const;
225 void setMsaaSamples(int samples);
226
227 void doPicking(QPoint point);
228
229 float ambientLightStrength() const;
230 void setAmbientLightStrength(float newAmbientLightStrength);
231 float lightStrength() const;
232 void setLightStrength(float newLightStrength);
233 float shadowStrength() const;
234 void setShadowStrength(float newShadowStrength);
235 QColor lightColor() const;
236 void setLightColor(QColor newLightColor);
237 QtGraphs3D::GridLineType gridLineType() const;
238 void setGridLineType(const QtGraphs3D::GridLineType &gridLineType);
239
240 void setWidget(QQuickWidget *widget);
241 QQuickWidget *widget() const;
242
243 ~Q3DGraphsWidgetItem() override;
244
245protected:
246 Q3DGraphsWidgetItem(Q3DGraphsWidgetItemPrivate &dd, QObject *parent, const QString &graph);
247
248 bool event(QEvent *event) override;
249 bool eventFilter(QObject *obj, QEvent *event) override;
250
251Q_SIGNALS:
252 void activeThemeChanged(QGraphsTheme *activeTheme);
253 void shadowQualityChanged(QtGraphs3D::ShadowQuality quality);
254 void selectionModeChanged(const QtGraphs3D::SelectionFlags selectionMode);
255 void selectedElementChanged(QtGraphs3D::ElementType type);
256 void measureFpsChanged(bool enabled);
257 void currentFpsChanged(int fps);
258 void orthoProjectionChanged(bool enabled);
259 void aspectRatioChanged(qreal ratio);
260 void optimizationHintChanged(QtGraphs3D::OptimizationHint hint);
261 void polarChanged(bool enabled);
262 void labelMarginChanged(float margin);
263 void radialLabelOffsetChanged(float offset);
264 void horizontalAspectRatioChanged(qreal ratio);
265 void localeChanged(const QLocale &locale);
266 void queriedGraphPositionChanged(QVector3D data);
267 void marginChanged(qreal margin);
268 void cameraPresetChanged(QtGraphs3D::CameraPreset preset);
269 void cameraXRotationChanged(float rotation);
270 void cameraYRotationChanged(float rotation);
271 void cameraZoomLevelChanged(float zoomLevel);
272 void cameraTargetPositionChanged(QVector3D target);
273 void minCameraZoomLevelChanged(float zoomLevel);
274 void maxCameraZoomLevelChanged(float zoomLevel);
275 void minCameraXRotationChanged(float rotation);
276 void minCameraYRotationChanged(float rotation);
277 void maxCameraXRotationChanged(float rotation);
278 void maxCameraYRotationChanged(float rotation);
279 void wrapCameraXRotationChanged(bool wrap);
280 void wrapCameraYRotationChanged(bool wrap);
281 void msaaSamplesChanged(int samples);
282
283 void tapped(QEventPoint eventPoint, Qt::MouseButton button);
284 void doubleTapped(QEventPoint eventPoint, Qt::MouseButton button);
285 void longPressed();
286 void dragged(QVector2D delta);
287 void wheel(QWheelEvent *event);
288 void pinch(qreal delta);
289 void mouseMove(QPoint mousePos);
290
291 void zoomEnabledChanged(bool enable);
292 void zoomAtTargetEnabledChanged(bool enable);
293 void rotationEnabledChanged(bool enable);
294 void selectionEnabledChanged(bool enable);
295
296 void ambientLightStrengthChanged();
297 void lightStrengthChanged();
298 void shadowStrengthChanged();
299 void lightColorChanged();
300 void gridLineTypeChanged();
301
302private:
303 Q_DISABLE_COPY_MOVE(Q3DGraphsWidgetItem)
304 Q_DECLARE_PRIVATE(Q3DGraphsWidgetItem)
305};
306
307QT_END_NAMESPACE
308
309#endif
310

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

source code of qtgraphs/src/graphs3d/widget/q3dgraphswidgetitem.h