| 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 | |
| 35 | public: |
| 36 | enum DrawFlag { |
| 37 | DrawWireframe = 1, |
| 38 | DrawSurface = 2, |
| 39 | DrawSurfaceAndWireframe = DrawWireframe | DrawSurface, |
| 40 | }; |
| 41 | Q_FLAG(DrawFlag) |
| 42 | Q_DECLARE_FLAGS(DrawFlags, DrawFlag) |
| 43 | |
| 44 | enum class Shading { Smooth, Flat }; |
| 45 | Q_ENUM(Shading) |
| 46 | |
| 47 | explicit QSurface3DSeries(QObject *parent = nullptr); |
| 48 | explicit QSurface3DSeries(QSurfaceDataProxy *dataProxy, QObject *parent = nullptr); |
| 49 | ~QSurface3DSeries() override; |
| 50 | |
| 51 | void setDataProxy(QSurfaceDataProxy *proxy); |
| 52 | QSurfaceDataProxy *dataProxy() const; |
| 53 | |
| 54 | void setSelectedPoint(QPoint position); |
| 55 | QPoint selectedPoint() const; |
| 56 | static QPoint invalidSelectionPosition(); |
| 57 | |
| 58 | void setShading(const QSurface3DSeries::Shading shading); |
| 59 | QSurface3DSeries::Shading shading() const; |
| 60 | |
| 61 | void setDrawMode(QSurface3DSeries::DrawFlags mode); |
| 62 | QSurface3DSeries::DrawFlags drawMode() const; |
| 63 | |
| 64 | bool isFlatShadingSupported() const; |
| 65 | |
| 66 | void setTexture(const QImage &texture); |
| 67 | QImage texture() const; |
| 68 | void setTextureFile(const QString &filename); |
| 69 | QString textureFile() const; |
| 70 | |
| 71 | void setWireframeColor(QColor color); |
| 72 | QColor wireframeColor() const; |
| 73 | |
| 74 | void setDataArray(const QSurfaceDataArray &newDataArray); |
| 75 | void clearRow(qsizetype rowIndex); |
| 76 | void clearArray(); |
| 77 | const QSurfaceDataArray &dataArray() const &; |
| 78 | QSurfaceDataArray dataArray() &&; |
| 79 | |
| 80 | Q_SIGNALS: |
| 81 | void dataProxyChanged(QSurfaceDataProxy *proxy); |
| 82 | void selectedPointChanged(QPoint position); |
| 83 | void flatShadingSupportedChanged(bool enabled); |
| 84 | void drawModeChanged(QSurface3DSeries::DrawFlags mode); |
| 85 | void textureChanged(const QImage &image); |
| 86 | void textureFileChanged(const QString &filename); |
| 87 | void wireframeColorChanged(QColor color); |
| 88 | void dataArrayChanged(const QSurfaceDataArray &array); |
| 89 | void shadingChanged(const Shading shading); |
| 90 | |
| 91 | protected: |
| 92 | explicit QSurface3DSeries(QSurface3DSeriesPrivate &d, QObject *parent = nullptr); |
| 93 | |
| 94 | private: |
| 95 | Q_DISABLE_COPY(QSurface3DSeries) |
| 96 | |
| 97 | friend class QQuickGraphsSurface; |
| 98 | }; |
| 99 | Q_DECLARE_OPERATORS_FOR_FLAGS(QSurface3DSeries::DrawFlags) |
| 100 | |
| 101 | QT_END_NAMESPACE |
| 102 | |
| 103 | #endif |
| 104 |
