1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the QtDataVisualization API. It exists purely as an |
9 | // implementation detail. This header file may change from version to |
10 | // version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | |
14 | #ifndef CUSTOMRENDERITEM_P_H |
15 | #define CUSTOMRENDERITEM_P_H |
16 | |
17 | #include "abstractrenderitem_p.h" |
18 | #include "objecthelper_p.h" |
19 | #include <QtGui/QRgb> |
20 | #include <QtGui/QImage> |
21 | #include <QtGui/QColor> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QCustom3DItem; |
26 | class Abstract3DRenderer; |
27 | |
28 | class CustomRenderItem : public AbstractRenderItem |
29 | { |
30 | public: |
31 | CustomRenderItem(); |
32 | virtual ~CustomRenderItem(); |
33 | |
34 | inline void setTexture(GLuint texture) { m_texture = texture; } |
35 | inline GLuint texture() const { return m_texture; } |
36 | bool setMesh(const QString &meshFile); |
37 | inline ObjectHelper *mesh() const { return m_object; } |
38 | inline void setScaling(const QVector3D &scaling) { m_scaling = scaling; } |
39 | inline const QVector3D &scaling() const { return m_scaling; } |
40 | inline void setOrigScaling(const QVector3D &scaling) { m_origScaling = scaling; } |
41 | inline const QVector3D &origScaling() const { return m_origScaling; } |
42 | inline void setPosition(const QVector3D &position) { m_position = position; } |
43 | inline const QVector3D &position() const { return m_position; } |
44 | inline void setOrigPosition(const QVector3D &position) { m_origPosition = position; } |
45 | inline const QVector3D &origPosition() const { return m_origPosition; } |
46 | inline void setPositionAbsolute(bool absolute) { m_positionAbsolute = absolute; } |
47 | inline bool isPositionAbsolute() const { return m_positionAbsolute; } |
48 | inline void setScalingAbsolute(bool absolute) { m_scalingAbsolute = absolute; } |
49 | inline bool isScalingAbsolute() const { return m_scalingAbsolute; } |
50 | inline void setBlendNeeded(bool blend) { m_needBlend = blend; } |
51 | inline bool isBlendNeeded() const { return m_needBlend; } |
52 | inline void setVisible(bool visible) { m_visible = visible; } |
53 | inline bool isVisible() const { return m_visible; } |
54 | inline void setItemPointer(QCustom3DItem *item) { m_item = item; } |
55 | inline QCustom3DItem *itemPointer() const { return m_item; } |
56 | inline void setValid(bool valid) { m_valid = valid; } |
57 | inline bool isValid() const { return m_valid; } |
58 | inline void setIndex(int index) { m_index = index; } |
59 | inline int index() const { return m_index; } |
60 | inline void setShadowCasting(bool shadowCasting) { m_shadowCasting = shadowCasting; } |
61 | inline bool isShadowCasting() const { return m_shadowCasting; } |
62 | inline void setFacingCamera(bool facing) { m_isFacingCamera = facing; } |
63 | inline bool isFacingCamera() const { return m_isFacingCamera; } |
64 | inline void setRenderer(Abstract3DRenderer *renderer) { m_renderer = renderer; } |
65 | inline void setLabelItem(bool isLabel) { m_labelItem = isLabel; } |
66 | inline bool isLabel() const { return m_labelItem; } |
67 | |
68 | // Volume specific |
69 | inline void setTextureWidth(int width) { m_textureWidth = width; setSliceIndexX(m_sliceIndexX); } |
70 | inline int textureWidth() const { return m_textureWidth; } |
71 | inline void setTextureHeight(int height) { m_textureHeight = height; setSliceIndexY(m_sliceIndexY); } |
72 | inline int textureHeight() const { return m_textureHeight; } |
73 | inline void setTextureDepth(int depth) { m_textureDepth = depth; setSliceIndexZ(m_sliceIndexZ); } |
74 | inline int textureDepth() const { return m_textureDepth; } |
75 | inline int textureSize() const { return m_textureWidth * m_textureHeight * m_textureDepth; } |
76 | inline void setColorTable(const QList<QVector4D> &colors) { m_colorTable = colors; } |
77 | void setColorTable(const QList<QRgb> &colors); |
78 | inline const QList<QVector4D> &colorTable() const { return m_colorTable; } |
79 | inline void setVolume(bool volume) { m_isVolume = volume; } |
80 | inline bool isVolume() const { return m_isVolume; } |
81 | inline void setTextureFormat(QImage::Format format) { m_textureFormat = format; } |
82 | inline QImage::Format textureFormat() const { return m_textureFormat; } |
83 | inline void setSliceIndexX(int index) |
84 | { |
85 | m_sliceIndexX = index; |
86 | m_sliceFractions.setX((float(index) + 0.5f) / float(m_textureWidth) * 2.0 - 1.0); |
87 | } |
88 | inline void setSliceIndexY(int index) |
89 | { |
90 | m_sliceIndexY = index; |
91 | m_sliceFractions.setY((float(index) + 0.5f) / float(m_textureHeight) * 2.0 - 1.0); |
92 | } |
93 | inline void setSliceIndexZ(int index) |
94 | { |
95 | m_sliceIndexZ = index; |
96 | m_sliceFractions.setZ((float(index) + 0.5f) / float(m_textureDepth) * 2.0 - 1.0); |
97 | } |
98 | inline const QVector3D &sliceFractions() const { return m_sliceFractions; } |
99 | inline int sliceIndexX() const { return m_sliceIndexX; } |
100 | inline int sliceIndexY() const { return m_sliceIndexY; } |
101 | inline int sliceIndexZ() const { return m_sliceIndexZ; } |
102 | inline void setAlphaMultiplier(float mult) { m_alphaMultiplier = mult; } |
103 | inline float alphaMultiplier() const { return m_alphaMultiplier; } |
104 | inline void setPreserveOpacity(bool enable) { m_preserveOpacity = enable; } |
105 | inline bool preserveOpacity() const { return m_preserveOpacity; } |
106 | inline void setUseHighDefShader(bool enable) { m_useHighDefShader = enable; } |
107 | inline bool useHighDefShader() const {return m_useHighDefShader; } |
108 | void setMinBounds(const QVector3D &bounds); |
109 | inline const QVector3D &minBounds() const { return m_minBounds; } |
110 | void setMaxBounds(const QVector3D &bounds); |
111 | inline const QVector3D &maxBounds() const { return m_maxBounds; } |
112 | inline const QVector3D &minBoundsNormal() const { return m_minBoundsNormal; } |
113 | inline const QVector3D &maxBoundsNormal() const { return m_maxBoundsNormal; } |
114 | inline void setDrawSlices(bool enable) { m_drawSlices = enable; } |
115 | inline bool drawSlices() const {return m_drawSlices; } |
116 | inline void setDrawSliceFrames(bool enable) { m_drawSliceFrames = enable; } |
117 | inline bool drawSliceFrames() const {return m_drawSliceFrames; } |
118 | void setSliceFrameColor(const QColor &color); |
119 | inline const QVector4D &sliceFrameColor() const { return m_sliceFrameColor; } |
120 | inline void setSliceFrameWidths(const QVector3D &widths) { m_sliceFrameWidths = widths * 2.0f; } |
121 | inline const QVector3D &sliceFrameWidths() const { return m_sliceFrameWidths; } |
122 | inline void setSliceFrameGaps(const QVector3D &gaps) { m_sliceFrameGaps = gaps * 2.0f; } |
123 | inline const QVector3D &sliceFrameGaps() const { return m_sliceFrameGaps; } |
124 | inline void setSliceFrameThicknesses(const QVector3D &thicknesses) { m_sliceFrameThicknesses = thicknesses; } |
125 | inline const QVector3D &sliceFrameThicknesses() const { return m_sliceFrameThicknesses; } |
126 | |
127 | private: |
128 | Q_DISABLE_COPY(CustomRenderItem) |
129 | |
130 | GLuint m_texture; |
131 | QVector3D m_scaling; |
132 | QVector3D m_origScaling; |
133 | QVector3D m_position; |
134 | QVector3D m_origPosition; |
135 | bool m_positionAbsolute; |
136 | bool m_scalingAbsolute; |
137 | ObjectHelper *m_object; // shared reference |
138 | bool m_needBlend; |
139 | bool m_visible; |
140 | bool m_valid; |
141 | int m_index; |
142 | bool m_shadowCasting; |
143 | bool m_isFacingCamera; |
144 | QCustom3DItem *m_item; |
145 | Abstract3DRenderer *m_renderer; |
146 | bool m_labelItem; |
147 | |
148 | // Volume specific |
149 | int m_textureWidth; |
150 | int m_textureHeight; |
151 | int m_textureDepth; |
152 | QList<QVector4D> m_colorTable; |
153 | bool m_isVolume; |
154 | QImage::Format m_textureFormat; |
155 | int m_sliceIndexX; |
156 | int m_sliceIndexY; |
157 | int m_sliceIndexZ; |
158 | QVector3D m_sliceFractions; |
159 | float m_alphaMultiplier; |
160 | bool m_preserveOpacity; |
161 | bool m_useHighDefShader; |
162 | QVector3D m_minBounds; |
163 | QVector3D m_maxBounds; |
164 | QVector3D m_minBoundsNormal; |
165 | QVector3D m_maxBoundsNormal; |
166 | bool m_drawSlices; |
167 | bool m_drawSliceFrames; |
168 | QVector4D m_sliceFrameColor; |
169 | QVector3D m_sliceFrameWidths; |
170 | QVector3D m_sliceFrameGaps; |
171 | QVector3D m_sliceFrameThicknesses; |
172 | }; |
173 | typedef QHash<QCustom3DItem *, CustomRenderItem *> CustomRenderItemArray; |
174 | |
175 | QT_END_NAMESPACE |
176 | |
177 | #endif |
178 |