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

source code of qtgraphs/src/graphs/data/qcustom3dvolume.h