1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Data Visualization module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#ifndef QCUSTOM3DVOLUME_H
31#define QCUSTOM3DVOLUME_H
32
33#include <QtDataVisualization/qdatavisualizationglobal.h>
34#include <QtDataVisualization/QCustom3DItem>
35#include <QtGui/QColor>
36#include <QtGui/QImage>
37
38QT_BEGIN_NAMESPACE_DATAVISUALIZATION
39
40class QCustom3DVolumePrivate;
41
42class QT_DATAVISUALIZATION_EXPORT QCustom3DVolume : public QCustom3DItem
43{
44 Q_OBJECT
45 Q_PROPERTY(int textureWidth READ textureWidth WRITE setTextureWidth NOTIFY textureWidthChanged)
46 Q_PROPERTY(int textureHeight READ textureHeight WRITE setTextureHeight NOTIFY textureHeightChanged)
47 Q_PROPERTY(int textureDepth READ textureDepth WRITE setTextureDepth NOTIFY textureDepthChanged)
48 Q_PROPERTY(int sliceIndexX READ sliceIndexX WRITE setSliceIndexX NOTIFY sliceIndexXChanged)
49 Q_PROPERTY(int sliceIndexY READ sliceIndexY WRITE setSliceIndexY NOTIFY sliceIndexYChanged)
50 Q_PROPERTY(int sliceIndexZ READ sliceIndexZ WRITE setSliceIndexZ NOTIFY sliceIndexZChanged)
51 Q_PROPERTY(QVector<QRgb> colorTable READ colorTable WRITE setColorTable NOTIFY colorTableChanged)
52 Q_PROPERTY(QVector<uchar> *textureData READ textureData WRITE setTextureData NOTIFY textureDataChanged)
53 Q_PROPERTY(float alphaMultiplier READ alphaMultiplier WRITE setAlphaMultiplier NOTIFY alphaMultiplierChanged)
54 Q_PROPERTY(bool preserveOpacity READ preserveOpacity WRITE setPreserveOpacity NOTIFY preserveOpacityChanged)
55 Q_PROPERTY(bool useHighDefShader READ useHighDefShader WRITE setUseHighDefShader NOTIFY useHighDefShaderChanged)
56 Q_PROPERTY(bool drawSlices READ drawSlices WRITE setDrawSlices NOTIFY drawSlicesChanged)
57 Q_PROPERTY(bool drawSliceFrames READ drawSliceFrames WRITE setDrawSliceFrames NOTIFY drawSliceFramesChanged)
58 Q_PROPERTY(QColor sliceFrameColor READ sliceFrameColor WRITE setSliceFrameColor NOTIFY sliceFrameColorChanged)
59 Q_PROPERTY(QVector3D sliceFrameWidths READ sliceFrameWidths WRITE setSliceFrameWidths NOTIFY sliceFrameWidthsChanged)
60 Q_PROPERTY(QVector3D sliceFrameGaps READ sliceFrameGaps WRITE setSliceFrameGaps NOTIFY sliceFrameGapsChanged)
61 Q_PROPERTY(QVector3D sliceFrameThicknesses READ sliceFrameThicknesses WRITE setSliceFrameThicknesses NOTIFY sliceFrameThicknessesChanged)
62
63public:
64
65 explicit QCustom3DVolume(QObject *parent = nullptr);
66 explicit QCustom3DVolume(const QVector3D &position, const QVector3D &scaling,
67 const QQuaternion &rotation, int textureWidth,
68 int textureHeight, int textureDepth,
69 QVector<uchar> *textureData, QImage::Format textureFormat,
70 const QVector<QRgb> &colorTable, QObject *parent = nullptr);
71 virtual ~QCustom3DVolume();
72
73 void setTextureWidth(int value);
74 int textureWidth() const;
75 void setTextureHeight(int value);
76 int textureHeight() const;
77 void setTextureDepth(int value);
78 int textureDepth() const;
79 void setTextureDimensions(int width, int height, int depth);
80 int textureDataWidth() const;
81
82 void setSliceIndexX(int value);
83 int sliceIndexX() const;
84 void setSliceIndexY(int value);
85 int sliceIndexY() const;
86 void setSliceIndexZ(int value);
87 int sliceIndexZ() const;
88 void setSliceIndices(int x, int y, int z);
89
90 void setColorTable(const QVector<QRgb> &colors);
91 QVector<QRgb> colorTable() const;
92
93 void setTextureData(QVector<uchar> *data);
94 QVector<uchar> *createTextureData(const QVector<QImage *> &images);
95 QVector<uchar> *textureData() const;
96 void setSubTextureData(Qt::Axis axis, int index, const uchar *data);
97 void setSubTextureData(Qt::Axis axis, int index, const QImage &image);
98
99 void setTextureFormat(QImage::Format format);
100 QImage::Format textureFormat() const;
101
102 void setAlphaMultiplier(float mult);
103 float alphaMultiplier() const;
104 void setPreserveOpacity(bool enable);
105 bool preserveOpacity() const;
106
107 void setUseHighDefShader(bool enable);
108 bool useHighDefShader() const;
109
110 void setDrawSlices(bool enable);
111 bool drawSlices() const;
112 void setDrawSliceFrames(bool enable);
113 bool drawSliceFrames() const;
114
115 void setSliceFrameColor(const QColor &color);
116 QColor sliceFrameColor() const;
117 void setSliceFrameWidths(const QVector3D &values);
118 QVector3D sliceFrameWidths() const;
119 void setSliceFrameGaps(const QVector3D &values);
120 QVector3D sliceFrameGaps() const;
121 void setSliceFrameThicknesses(const QVector3D &values);
122 QVector3D sliceFrameThicknesses() const;
123
124 QImage renderSlice(Qt::Axis axis, int index);
125
126Q_SIGNALS:
127 void textureWidthChanged(int value);
128 void textureHeightChanged(int value);
129 void textureDepthChanged(int value);
130 void sliceIndexXChanged(int value);
131 void sliceIndexYChanged(int value);
132 void sliceIndexZChanged(int value);
133 void colorTableChanged();
134 void textureDataChanged(QVector<uchar> *data);
135 void textureFormatChanged(QImage::Format format);
136 void alphaMultiplierChanged(float mult);
137 void preserveOpacityChanged(bool enabled);
138 void useHighDefShaderChanged(bool enabled);
139 void drawSlicesChanged(bool enabled);
140 void drawSliceFramesChanged(bool enabled);
141 void sliceFrameColorChanged(const QColor &color);
142 void sliceFrameWidthsChanged(const QVector3D &values);
143 void sliceFrameGapsChanged(const QVector3D &values);
144 void sliceFrameThicknessesChanged(const QVector3D &values);
145
146protected:
147 QCustom3DVolumePrivate *dptr();
148 const QCustom3DVolumePrivate *dptrc() const;
149
150private:
151 Q_DISABLE_COPY(QCustom3DVolume)
152
153 friend class Abstract3DRenderer;
154};
155
156QT_END_NAMESPACE_DATAVISUALIZATION
157
158#endif
159

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