| 1 | // Copyright (C) 2023 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QTGRAPHS_QCUSTOM3DVOLUME_H |
| 5 | #define QTGRAPHS_QCUSTOM3DVOLUME_H |
| 6 | |
| 7 | #include <QtGraphs/qcustom3ditem.h> |
| 8 | #include <QtGraphs/qgraphsglobal.h> |
| 9 | #include <QtGui/qcolor.h> |
| 10 | #include <QtGui/qimage.h> |
| 11 | |
| 12 | QT_BEGIN_NAMESPACE |
| 13 | |
| 14 | class QCustom3DVolumePrivate; |
| 15 | |
| 16 | class Q_GRAPHS_EXPORT QCustom3DVolume : public QCustom3DItem |
| 17 | { |
| 18 | Q_OBJECT |
| 19 | Q_DECLARE_PRIVATE(QCustom3DVolume) |
| 20 | Q_PROPERTY( |
| 21 | int textureWidth READ textureWidth WRITE setTextureWidth NOTIFY textureWidthChanged FINAL) |
| 22 | Q_PROPERTY(int textureHeight READ textureHeight WRITE setTextureHeight NOTIFY |
| 23 | textureHeightChanged FINAL) |
| 24 | Q_PROPERTY( |
| 25 | int textureDepth READ textureDepth WRITE setTextureDepth NOTIFY textureDepthChanged FINAL) |
| 26 | Q_PROPERTY(int sliceIndexX READ sliceIndexX WRITE setSliceIndexX NOTIFY sliceIndexXChanged FINAL) |
| 27 | Q_PROPERTY(int sliceIndexY READ sliceIndexY WRITE setSliceIndexY NOTIFY sliceIndexYChanged FINAL) |
| 28 | Q_PROPERTY(int sliceIndexZ READ sliceIndexZ WRITE setSliceIndexZ NOTIFY sliceIndexZChanged FINAL) |
| 29 | Q_PROPERTY( |
| 30 | QList<QRgb> colorTable READ colorTable WRITE setColorTable NOTIFY colorTableChanged FINAL) |
| 31 | Q_PROPERTY(QList<uchar> *textureData READ textureData WRITE setTextureData NOTIFY |
| 32 | textureDataChanged FINAL) |
| 33 | Q_PROPERTY(float alphaMultiplier READ alphaMultiplier WRITE setAlphaMultiplier NOTIFY |
| 34 | alphaMultiplierChanged FINAL) |
| 35 | Q_PROPERTY(bool preserveOpacity READ preserveOpacity WRITE setPreserveOpacity NOTIFY |
| 36 | preserveOpacityChanged FINAL) |
| 37 | Q_PROPERTY(bool useHighDefShader READ useHighDefShader WRITE setUseHighDefShader NOTIFY |
| 38 | useHighDefShaderChanged FINAL) |
| 39 | Q_PROPERTY(bool drawSlices READ drawSlices WRITE setDrawSlices NOTIFY drawSlicesChanged FINAL) |
| 40 | Q_PROPERTY(bool drawSliceFrames READ drawSliceFrames WRITE setDrawSliceFrames NOTIFY |
| 41 | drawSliceFramesChanged FINAL) |
| 42 | Q_PROPERTY(QColor sliceFrameColor READ sliceFrameColor WRITE setSliceFrameColor NOTIFY |
| 43 | sliceFrameColorChanged FINAL) |
| 44 | Q_PROPERTY(QVector3D sliceFrameWidths READ sliceFrameWidths WRITE setSliceFrameWidths NOTIFY |
| 45 | sliceFrameWidthsChanged FINAL) |
| 46 | Q_PROPERTY(QVector3D sliceFrameGaps READ sliceFrameGaps WRITE setSliceFrameGaps NOTIFY |
| 47 | sliceFrameGapsChanged FINAL) |
| 48 | Q_PROPERTY(QVector3D sliceFrameThicknesses READ sliceFrameThicknesses WRITE |
| 49 | setSliceFrameThicknesses NOTIFY sliceFrameThicknessesChanged FINAL) |
| 50 | |
| 51 | public: |
| 52 | explicit QCustom3DVolume(QObject *parent = nullptr); |
| 53 | explicit QCustom3DVolume(QVector3D position, |
| 54 | QVector3D scaling, |
| 55 | const QQuaternion &rotation, |
| 56 | int textureWidth, |
| 57 | int textureHeight, |
| 58 | int textureDepth, |
| 59 | QList<uchar> *textureData, |
| 60 | QImage::Format textureFormat, |
| 61 | const QList<QRgb> &colorTable, |
| 62 | QObject *parent = nullptr); |
| 63 | ~QCustom3DVolume() override; |
| 64 | |
| 65 | void setTextureWidth(int value); |
| 66 | int textureWidth() const; |
| 67 | void setTextureHeight(int value); |
| 68 | int textureHeight() const; |
| 69 | void setTextureDepth(int value); |
| 70 | int textureDepth() const; |
| 71 | void setTextureDimensions(int width, int height, int depth); |
| 72 | int textureDataWidth() const; |
| 73 | |
| 74 | void setSliceIndexX(int value); |
| 75 | int sliceIndexX() const; |
| 76 | void setSliceIndexY(int value); |
| 77 | int sliceIndexY() const; |
| 78 | void setSliceIndexZ(int value); |
| 79 | int sliceIndexZ() const; |
| 80 | void setSliceIndices(int x, int y, int z); |
| 81 | |
| 82 | void setColorTable(const QList<QRgb> &colors); |
| 83 | QList<QRgb> colorTable() const; |
| 84 | |
| 85 | void setTextureData(QList<uchar> *data); |
| 86 | QList<uchar> *createTextureData(const QList<QImage *> &images); |
| 87 | QList<uchar> *textureData() const; |
| 88 | void setSubTextureData(Qt::Axis axis, int index, const uchar *data); |
| 89 | void setSubTextureData(Qt::Axis axis, int index, const QImage &image); |
| 90 | |
| 91 | void setTextureFormat(QImage::Format format); |
| 92 | QImage::Format textureFormat() const; |
| 93 | |
| 94 | void setAlphaMultiplier(float mult); |
| 95 | float alphaMultiplier() const; |
| 96 | void setPreserveOpacity(bool enable); |
| 97 | bool preserveOpacity() const; |
| 98 | |
| 99 | void setUseHighDefShader(bool enable); |
| 100 | bool useHighDefShader() const; |
| 101 | |
| 102 | void setDrawSlices(bool enable); |
| 103 | bool drawSlices() const; |
| 104 | void setDrawSliceFrames(bool enable); |
| 105 | bool drawSliceFrames() const; |
| 106 | |
| 107 | void setSliceFrameColor(QColor color); |
| 108 | QColor sliceFrameColor() const; |
| 109 | void setSliceFrameWidths(QVector3D values); |
| 110 | QVector3D sliceFrameWidths() const; |
| 111 | void setSliceFrameGaps(QVector3D values); |
| 112 | QVector3D sliceFrameGaps() const; |
| 113 | void setSliceFrameThicknesses(QVector3D values); |
| 114 | QVector3D sliceFrameThicknesses() const; |
| 115 | |
| 116 | QImage renderSlice(Qt::Axis axis, int index); |
| 117 | |
| 118 | Q_SIGNALS: |
| 119 | void textureWidthChanged(int value); |
| 120 | void textureHeightChanged(int value); |
| 121 | void textureDepthChanged(int value); |
| 122 | void sliceIndexXChanged(int value); |
| 123 | void sliceIndexYChanged(int value); |
| 124 | void sliceIndexZChanged(int value); |
| 125 | void colorTableChanged(); |
| 126 | void textureDataChanged(QList<uchar> *data); |
| 127 | void textureFormatChanged(QImage::Format format); |
| 128 | void alphaMultiplierChanged(float mult); |
| 129 | void preserveOpacityChanged(bool enabled); |
| 130 | void useHighDefShaderChanged(bool enabled); |
| 131 | void drawSlicesChanged(bool enabled); |
| 132 | void drawSliceFramesChanged(bool enabled); |
| 133 | void sliceFrameColorChanged(QColor color); |
| 134 | void sliceFrameWidthsChanged(QVector3D values); |
| 135 | void sliceFrameGapsChanged(QVector3D values); |
| 136 | void sliceFrameThicknessesChanged(QVector3D values); |
| 137 | |
| 138 | private: |
| 139 | Q_DISABLE_COPY(QCustom3DVolume) |
| 140 | }; |
| 141 | |
| 142 | QT_END_NAMESPACE |
| 143 | |
| 144 | #endif |
| 145 | |