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 QCUSTOM3DITEM_H
31#define QCUSTOM3DITEM_H
32
33#include <QtDataVisualization/qdatavisualizationglobal.h>
34#include <QtGui/QImage>
35#include <QtGui/QVector3D>
36#include <QtGui/QQuaternion>
37
38QT_BEGIN_NAMESPACE_DATAVISUALIZATION
39
40class QCustom3DItemPrivate;
41
42class QT_DATAVISUALIZATION_EXPORT QCustom3DItem : public QObject
43{
44 Q_OBJECT
45 Q_PROPERTY(QString meshFile READ meshFile WRITE setMeshFile NOTIFY meshFileChanged)
46 Q_PROPERTY(QString textureFile READ textureFile WRITE setTextureFile NOTIFY textureFileChanged)
47 Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
48 Q_PROPERTY(bool positionAbsolute READ isPositionAbsolute WRITE setPositionAbsolute NOTIFY positionAbsoluteChanged)
49 Q_PROPERTY(QVector3D scaling READ scaling WRITE setScaling NOTIFY scalingChanged)
50 Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
51 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
52 Q_PROPERTY(bool shadowCasting READ isShadowCasting WRITE setShadowCasting NOTIFY shadowCastingChanged)
53 Q_PROPERTY(bool scalingAbsolute READ isScalingAbsolute WRITE setScalingAbsolute NOTIFY scalingAbsoluteChanged REVISION 1)
54
55public:
56 explicit QCustom3DItem(QObject *parent = nullptr);
57 explicit QCustom3DItem(const QString &meshFile, const QVector3D &position,
58 const QVector3D &scaling, const QQuaternion &rotation,
59 const QImage &texture, QObject *parent = nullptr);
60 virtual ~QCustom3DItem();
61
62 void setMeshFile(const QString &meshFile);
63 QString meshFile() const;
64
65 void setTextureFile(const QString &textureFile);
66 QString textureFile() const;
67
68 void setPosition(const QVector3D &position);
69 QVector3D position() const;
70
71 void setPositionAbsolute(bool positionAbsolute);
72 bool isPositionAbsolute() const;
73
74 void setScaling(const QVector3D &scaling);
75 QVector3D scaling() const;
76
77 void setScalingAbsolute(bool scalingAbsolute);
78 bool isScalingAbsolute() const;
79
80 void setRotation(const QQuaternion &rotation);
81 QQuaternion rotation();
82
83 void setVisible(bool visible);
84 bool isVisible() const;
85
86 void setShadowCasting(bool enabled);
87 bool isShadowCasting() const;
88
89 Q_INVOKABLE void setRotationAxisAndAngle(const QVector3D &axis, float angle);
90
91 void setTextureImage(const QImage &textureImage);
92
93Q_SIGNALS:
94 void meshFileChanged(const QString &meshFile);
95 void textureFileChanged(const QString &textureFile);
96 void positionChanged(const QVector3D &position);
97 void positionAbsoluteChanged(bool positionAbsolute);
98 void scalingChanged(const QVector3D &scaling);
99 void rotationChanged(const QQuaternion &rotation);
100 void visibleChanged(bool visible);
101 void shadowCastingChanged(bool shadowCasting);
102 Q_REVISION(1) void scalingAbsoluteChanged(bool scalingAbsolute);
103
104protected:
105 QCustom3DItem(QCustom3DItemPrivate *d, QObject *parent = nullptr);
106
107 QScopedPointer<QCustom3DItemPrivate> d_ptr;
108
109private:
110 Q_DISABLE_COPY(QCustom3DItem)
111
112 friend class Abstract3DRenderer;
113 friend class Abstract3DController;
114};
115
116QT_END_NAMESPACE_DATAVISUALIZATION
117
118#endif
119