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

source code of qtdatavis3d/src/datavisualization/data/qcustom3dvolume.h