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