| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QTGRAPHS_QSURFACE3DSERIES_H |
| 5 | #define QTGRAPHS_QSURFACE3DSERIES_H |
| 6 | |
| 7 | #include <QtGraphs/qabstract3dseries.h> |
| 8 | #include <QtGraphs/qsurfacedataproxy.h> |
| 9 | |
| 10 | QT_BEGIN_NAMESPACE |
| 11 | |
| 12 | class QSurface3DSeriesPrivate; |
| 13 | |
| 14 | class Q_GRAPHS_EXPORT QSurface3DSeries : public QAbstract3DSeries |
| 15 | { |
| 16 | Q_OBJECT |
| 17 | Q_DECLARE_PRIVATE(QSurface3DSeries) |
| 18 | Q_PROPERTY(QSurfaceDataProxy *dataProxy READ dataProxy WRITE setDataProxy NOTIFY |
| 19 | dataProxyChanged FINAL) |
| 20 | Q_PROPERTY( |
| 21 | QPoint selectedPoint READ selectedPoint WRITE setSelectedPoint NOTIFY selectedPointChanged) |
| 22 | Q_PROPERTY(bool flatShadingSupported READ isFlatShadingSupported NOTIFY |
| 23 | flatShadingSupportedChanged FINAL) |
| 24 | Q_PROPERTY(QSurface3DSeries::DrawFlags drawMode READ drawMode WRITE setDrawMode NOTIFY |
| 25 | drawModeChanged FINAL) |
| 26 | Q_PROPERTY(QSurface3DSeries::Shading shading READ shading WRITE setShading NOTIFY shadingChanged) |
| 27 | Q_PROPERTY(QImage texture READ texture WRITE setTexture NOTIFY textureChanged FINAL) |
| 28 | Q_PROPERTY( |
| 29 | QString textureFile READ textureFile WRITE setTextureFile NOTIFY textureFileChanged FINAL) |
| 30 | Q_PROPERTY(QColor wireframeColor READ wireframeColor WRITE setWireframeColor NOTIFY |
| 31 | wireframeColorChanged FINAL) |
| 32 | Q_PROPERTY( |
| 33 | QSurfaceDataArray dataArray READ dataArray WRITE setDataArray NOTIFY dataArrayChanged FINAL) |
| 34 | QML_ELEMENT |
| 35 | QML_UNCREATABLE("Trying to create uncreatable: QSurface3DSeries, use Surface3DSeries instead.") |
| 36 | |
| 37 | public: |
| 38 | enum DrawFlag { |
| 39 | DrawWireframe = 0x1, |
| 40 | DrawSurface = 0x2, |
| 41 | DrawSurfaceAndWireframe = DrawWireframe | DrawSurface, |
| 42 | DrawFilledSurface = 0x4, |
| 43 | }; |
| 44 | Q_FLAG(DrawFlag) |
| 45 | Q_DECLARE_FLAGS(DrawFlags, DrawFlag) |
| 46 | |
| 47 | enum class Shading { Smooth, Flat }; |
| 48 | Q_ENUM(Shading) |
| 49 | |
| 50 | explicit QSurface3DSeries(QObject *parent = nullptr); |
| 51 | explicit QSurface3DSeries(QSurfaceDataProxy *dataProxy, QObject *parent = nullptr); |
| 52 | ~QSurface3DSeries() override; |
| 53 | |
| 54 | void setDataProxy(QSurfaceDataProxy *proxy); |
| 55 | QSurfaceDataProxy *dataProxy() const; |
| 56 | |
| 57 | void setSelectedPoint(QPoint position); |
| 58 | QPoint selectedPoint() const; |
| 59 | static QPoint invalidSelectionPosition(); |
| 60 | |
| 61 | void setShading(const QSurface3DSeries::Shading shading); |
| 62 | QSurface3DSeries::Shading shading() const; |
| 63 | |
| 64 | void setDrawMode(QSurface3DSeries::DrawFlags mode); |
| 65 | QSurface3DSeries::DrawFlags drawMode() const; |
| 66 | |
| 67 | bool isFlatShadingSupported() const; |
| 68 | |
| 69 | void setTexture(const QImage &texture); |
| 70 | QImage texture() const; |
| 71 | void setTextureFile(const QString &filename); |
| 72 | QString textureFile() const; |
| 73 | |
| 74 | void setWireframeColor(QColor color); |
| 75 | QColor wireframeColor() const; |
| 76 | |
| 77 | void setDataArray(const QSurfaceDataArray &newDataArray); |
| 78 | void clearRow(qsizetype rowIndex); |
| 79 | void clearArray(); |
| 80 | const QSurfaceDataArray &dataArray() const &; |
| 81 | QSurfaceDataArray dataArray() &&; |
| 82 | |
| 83 | Q_SIGNALS: |
| 84 | void dataProxyChanged(QSurfaceDataProxy *proxy); |
| 85 | void selectedPointChanged(QPoint position); |
| 86 | void flatShadingSupportedChanged(bool enabled); |
| 87 | void drawModeChanged(QSurface3DSeries::DrawFlags mode); |
| 88 | void textureChanged(const QImage &image); |
| 89 | void textureFileChanged(const QString &filename); |
| 90 | void wireframeColorChanged(QColor color); |
| 91 | void dataArrayChanged(const QSurfaceDataArray &array); |
| 92 | void shadingChanged(const Shading shading); |
| 93 | |
| 94 | protected: |
| 95 | explicit QSurface3DSeries(QSurface3DSeriesPrivate &d, QObject *parent = nullptr); |
| 96 | |
| 97 | private: |
| 98 | Q_DISABLE_COPY(QSurface3DSeries) |
| 99 | |
| 100 | friend class QQuickGraphsSurface; |
| 101 | }; |
| 102 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSurface3DSeries::DrawFlags) |
| 103 | |
| 104 | QT_END_NAMESPACE |
| 105 | |
| 106 | #endif |
| 107 |
