1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc
** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
** This file is part of the QtDataVisualization module.
**
** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.
**
** If you have questions regarding the use of this file, please use
** contact form at http://qt.digia.com
**
****************************************************************************/
#include "customrenderitem_p.h"
QT_BEGIN_NAMESPACE_DATAVISUALIZATION
CustomRenderItem::CustomRenderItem()
: AbstractRenderItem(),
m_texture(0),
m_absolute(false),
m_object(0),
m_needBlend(true),
m_visible(true),
m_valid(true),
m_index(0),
m_shadowCasting(false),
m_isFacingCamera(false),
m_item(0),
m_renderer(0),
m_textureWidth(0),
m_textureHeight(0),
m_textureDepth(0),
m_isVolume(false),
m_textureFormat(QImage::Format_ARGB32),
m_sliceIndexX(-1),
m_sliceIndexY(-1),
m_sliceIndexZ(-1),
m_alphaMultiplier(1.0f),
m_preserveOpacity(true)
{
}
CustomRenderItem::~CustomRenderItem()
{
ObjectHelper::releaseObjectHelper(m_renderer, m_object);
}
void CustomRenderItem::setMesh(const QString &meshFile)
{
ObjectHelper::resetObjectHelper(m_renderer, m_object, meshFile);
}
void CustomRenderItem::setColorTable(const QVector<QRgb> &colors)
{
m_colorTable.resize(256);
for (int i = 0; i < 256; i++) {
if (i < colors.size()) {
const QRgb &rgb = colors.at(i);
m_colorTable[i] = QVector4D(float(qRed(rgb)) / 255.0f,
float(qGreen(rgb)) / 255.0f,
float(qBlue(rgb)) / 255.0f,
float(qAlpha(rgb)) / 255.0f);
} else {
m_colorTable[i] = QVector4D(0.0f, 0.0f, 0.0f, 0.0f);
}
}
}
QT_END_NAMESPACE_DATAVISUALIZATION
|