summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/data
diff options
context:
space:
mode:
Diffstat (limited to 'src/datavisualization/data')
-rw-r--r--src/datavisualization/data/customrenderitem_p.h3
-rw-r--r--src/datavisualization/data/qcustom3ditem.cpp61
-rw-r--r--src/datavisualization/data/qcustom3ditem.h5
-rw-r--r--src/datavisualization/data/qcustom3ditem_p.h3
4 files changed, 66 insertions, 6 deletions
diff --git a/src/datavisualization/data/customrenderitem_p.h b/src/datavisualization/data/customrenderitem_p.h
index 81a78144..f05540d0 100644
--- a/src/datavisualization/data/customrenderitem_p.h
+++ b/src/datavisualization/data/customrenderitem_p.h
@@ -51,6 +51,8 @@ public:
inline QVector3D scaling() const { return m_scaling; }
inline void setPosition(const QVector3D &position) { m_position = position; }
inline QVector3D position() const { return m_position; }
+ inline void setPositionAbsolute(bool absolute) { m_absolute = absolute; }
+ inline bool isPositionAbsolute() const { return m_absolute; }
inline void setBlendNeeded(bool blend) { m_needBlend = blend; }
inline bool isBlendNeeded() const { return m_needBlend; }
inline void setVisible(bool visible) { m_visible = visible; }
@@ -68,6 +70,7 @@ private:
GLuint m_texture;
QVector3D m_scaling;
QVector3D m_position;
+ bool m_absolute;
ObjectHelper *m_object;
bool m_needBlend;
bool m_visible;
diff --git a/src/datavisualization/data/qcustom3ditem.cpp b/src/datavisualization/data/qcustom3ditem.cpp
index f39a0478..f1307d7a 100644
--- a/src/datavisualization/data/qcustom3ditem.cpp
+++ b/src/datavisualization/data/qcustom3ditem.cpp
@@ -62,15 +62,31 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
/*! \qmlproperty vector3d Custom3DItem::position
*
- * Holds the item \a position as a vector3d. Item position is in data coordinates. Defaults to
- * \c {vector3d(0.0, 0.0, 0.0)}.
+ * Holds the item \a position as a vector3d. Defaults to \c {vector3d(0.0, 0.0, 0.0)}.
*
- * \note Items positioned outside axis ranges are not rendered.
+ * Item position is either in data coordinates or in absolute coordinates, depending on
+ * positionAbsolute property. When using absolute coordinates, values between \c{-1.0...1.0} are
+ * within axis ranges.
+ *
+ * \note Items positioned outside any axis range are not rendered if positionAbsolute is \c{false}.
+ *
+ * \sa positionAbsolute
+ */
+
+/*! \qmlproperty bool Custom3DItem::positionAbsolute
+ *
+ * This property dictates if item position is to be handled in data coordinates or in absolute
+ * coordinates. Defaults to \c{false}. Items with absolute cooridnates will always be rendered,
+ * whereas items with data coordinates are only rendered if they are within axis ranges.
+ *
+ * \sa position
*/
/*! \qmlproperty vector3d Custom3DItem::scaling
*
* Holds the item \a scaling as a vector3d. Defaults to \c {vector3d(0.1, 0.1, 0.1)}.
+ * The default value sets the item to 10% of the height of the graph, provided the item size is
+ * normalized.
*/
/*! \qmlproperty quaternion Custom3DItem::rotation
@@ -148,10 +164,15 @@ QString QCustom3DItem::meshFile() const
/*! \property QCustom3DItem::position
*
- * Holds the item \a position as a QVector3D. Item position is in data coordinates. Defaults to
- * \c {QVector3D(0.0, 0.0, 0.0)}.
+ * Holds the item \a position as a QVector3D. Defaults to \c {QVector3D(0.0, 0.0, 0.0)}.
+ *
+ * Item position is either in data coordinates or in absolute coordinates, depending on
+ * positionAbsolute property. When using absolute coordinates, values between \c{-1.0...1.0} are
+ * within axis ranges.
+ *
+ * \note Items positioned outside any axis range are not rendered if positionAbsolute is \c{false}.
*
- * \note Items positioned outside axis ranges are not rendered.
+ * \sa positionAbsolute
*/
void QCustom3DItem::setPosition(const QVector3D &position)
{
@@ -168,9 +189,34 @@ QVector3D QCustom3DItem::position() const
return d_ptr->m_position;
}
+/*! \property QCustom3DItem::positionAbsolute
+ *
+ * This property dictates if item position is to be handled in data coordinates or in absolute
+ * coordinates. Defaults to \c{false}. Items with absolute cooridnates will always be rendered,
+ * whereas items with data coordinates are only rendered if they are within axis ranges.
+ *
+ * \sa position
+ */
+void QCustom3DItem::setPositionAbsolute(bool positionAbsolute)
+{
+ if (d_ptr->m_positionAbsolute != positionAbsolute) {
+ d_ptr->m_positionAbsolute = positionAbsolute;
+ d_ptr->m_dirtyBits.positionAbsoluteDirty = true;
+ emit positionAbsoluteChanged(positionAbsolute);
+ emit d_ptr->needUpdate();
+ }
+}
+
+bool QCustom3DItem::isPositionAbsolute() const
+{
+ return d_ptr->m_positionAbsolute;
+}
+
/*! \property QCustom3DItem::scaling
*
* Holds the item \a scaling as a QVector3D. Defaults to \c {QVector3D(0.1, 0.1, 0.1)}.
+ * The default value sets the item to 10% of the height of the graph, provided the item size is
+ * normalized.
*/
void QCustom3DItem::setScaling(const QVector3D &scaling)
{
@@ -313,6 +359,7 @@ QCustom3DItemPrivate::QCustom3DItemPrivate(QCustom3DItem *q, QObject *parent) :
QObject(parent),
q_ptr(q),
m_position(QVector3D(0.0f, 0.0f, 0.0f)),
+ m_positionAbsolute(false),
m_scaling(QVector3D(0.1f, 0.1f, 0.1f)),
m_rotation(QQuaternion(0.0f, 0.0f, 0.0f, 0.0f)),
m_visible(true),
@@ -327,6 +374,7 @@ QCustom3DItemPrivate::QCustom3DItemPrivate(QCustom3DItem *q, const QString &mesh
q_ptr(q),
m_meshFile(meshFile),
m_position(position),
+ m_positionAbsolute(false),
m_scaling(scaling),
m_rotation(rotation),
m_visible(true),
@@ -354,6 +402,7 @@ void QCustom3DItemPrivate::resetDirtyBits()
m_dirtyBits.textureDirty = false;
m_dirtyBits.meshDirty = false;
m_dirtyBits.positionDirty = false;
+ m_dirtyBits.positionAbsoluteDirty = false;
m_dirtyBits.scalingDirty = false;
m_dirtyBits.rotationDirty = false;
m_dirtyBits.visibleDirty = false;
diff --git a/src/datavisualization/data/qcustom3ditem.h b/src/datavisualization/data/qcustom3ditem.h
index 72aad604..53ec0bcf 100644
--- a/src/datavisualization/data/qcustom3ditem.h
+++ b/src/datavisualization/data/qcustom3ditem.h
@@ -34,6 +34,7 @@ class QT_DATAVISUALIZATION_EXPORT QCustom3DItem : public QObject
Q_PROPERTY(QString meshFile READ meshFile WRITE setMeshFile NOTIFY meshFileChanged)
Q_PROPERTY(QString textureFile READ textureFile WRITE setTextureFile NOTIFY textureFileChanged)
Q_PROPERTY(QVector3D position READ position WRITE setPosition NOTIFY positionChanged)
+ Q_PROPERTY(bool positionAbsolute READ isPositionAbsolute WRITE setPositionAbsolute NOTIFY positionAbsoluteChanged)
Q_PROPERTY(QVector3D scaling READ scaling WRITE setScaling NOTIFY scalingChanged)
Q_PROPERTY(QQuaternion rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
@@ -55,6 +56,9 @@ public:
void setPosition(const QVector3D &position);
QVector3D position() const;
+ void setPositionAbsolute(bool positionAbsolute);
+ bool isPositionAbsolute() const;
+
void setScaling(const QVector3D &scaling);
QVector3D scaling() const;
@@ -75,6 +79,7 @@ signals:
void meshFileChanged(const QString &meshFile);
void textureFileChanged(const QString &textureFile);
void positionChanged(const QVector3D &position);
+ void positionAbsoluteChanged(bool positionAbsolute);
void scalingChanged(const QVector3D &scaling);
void rotationChanged(const QQuaternion &rotation);
void visibleChanged(bool visible);
diff --git a/src/datavisualization/data/qcustom3ditem_p.h b/src/datavisualization/data/qcustom3ditem_p.h
index 2523abd4..3e807df3 100644
--- a/src/datavisualization/data/qcustom3ditem_p.h
+++ b/src/datavisualization/data/qcustom3ditem_p.h
@@ -37,6 +37,7 @@ struct QCustomItemDirtyBitField {
bool textureDirty : 1;
bool meshDirty : 1;
bool positionDirty : 1;
+ bool positionAbsoluteDirty : 1;
bool scalingDirty : 1;
bool rotationDirty : 1;
bool visibleDirty : 1;
@@ -46,6 +47,7 @@ struct QCustomItemDirtyBitField {
: textureDirty(false),
meshDirty(false),
positionDirty(false),
+ positionAbsoluteDirty(false),
scalingDirty(false),
rotationDirty(false),
visibleDirty(false),
@@ -73,6 +75,7 @@ public:
QString m_textureFile;
QString m_meshFile;
QVector3D m_position;
+ bool m_positionAbsolute;
QVector3D m_scaling;
QQuaternion m_rotation;
bool m_visible;