summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2014-05-20 08:54:07 +0300
committerTomi Korpipää <tomi.korpipaa@digia.com>2014-05-20 09:54:02 +0300
commitb6da9160b2d81283ec9fc082c08987ecc95650da (patch)
treebc2cab637d9a8b23bab4218cd7183ebbbcb4160e
parent0004b7598d5826bf5e1e4fb7256b13dbc220ec47 (diff)
Do not draw custom items outside axis ranges
Task-number: QTRD-3057 Change-Id: Icb8904fa0a1c009985ac21ee6fa51eefda81d9cc Change-Id: Icb8904fa0a1c009985ac21ee6fa51eefda81d9cc Reviewed-by: Titta Heikkala <titta.heikkala@digia.com> Reviewed-by: Mika Salmela <mika.salmela@digia.com>
-rw-r--r--src/datavisualization/data/customrenderitem_p.h3
-rw-r--r--src/datavisualization/data/qcustom3ditem.cpp7
-rw-r--r--src/datavisualization/engine/abstract3drenderer.cpp11
-rw-r--r--tests/qmlcamera/qml/qmlcamera/main.qml3
4 files changed, 17 insertions, 7 deletions
diff --git a/src/datavisualization/data/customrenderitem_p.h b/src/datavisualization/data/customrenderitem_p.h
index 1dce62e5..81a78144 100644
--- a/src/datavisualization/data/customrenderitem_p.h
+++ b/src/datavisualization/data/customrenderitem_p.h
@@ -49,6 +49,8 @@ public:
inline ObjectHelper *mesh() const { return m_object; }
inline void setScaling(const QVector3D &scaling) { m_scaling = scaling; }
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 setBlendNeeded(bool blend) { m_needBlend = blend; }
inline bool isBlendNeeded() const { return m_needBlend; }
inline void setVisible(bool visible) { m_visible = visible; }
@@ -65,6 +67,7 @@ public:
private:
GLuint m_texture;
QVector3D m_scaling;
+ QVector3D m_position;
ObjectHelper *m_object;
bool m_needBlend;
bool m_visible;
diff --git a/src/datavisualization/data/qcustom3ditem.cpp b/src/datavisualization/data/qcustom3ditem.cpp
index 3254ac3b..f39a0478 100644
--- a/src/datavisualization/data/qcustom3ditem.cpp
+++ b/src/datavisualization/data/qcustom3ditem.cpp
@@ -60,14 +60,12 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* \note To conserve memory the Image loaded from the file is cleared after a texture is created.
*/
-// TODO: Position check in task QTRD-3057
/*! \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)}.
*
- * \note No validity checks are made for the position of the item, so it is up to the user to
- * provide a valid position. Items positioned outside axis ranges are still rendered.
+ * \note Items positioned outside axis ranges are not rendered.
*/
/*! \qmlproperty vector3d Custom3DItem::scaling
@@ -153,8 +151,7 @@ QString QCustom3DItem::meshFile() const
* Holds the item \a position as a QVector3D. Item position is in data coordinates. Defaults to
* \c {QVector3D(0.0, 0.0, 0.0)}.
*
- * \note No validity checks are made for the position of the item, so it is up to the user to
- * provide a valid position. Items positioned outside axis ranges are still rendered.
+ * \note Items positioned outside axis ranges are not rendered.
*/
void QCustom3DItem::setPosition(const QVector3D &position)
{
diff --git a/src/datavisualization/engine/abstract3drenderer.cpp b/src/datavisualization/engine/abstract3drenderer.cpp
index 82952a26..684db1a5 100644
--- a/src/datavisualization/engine/abstract3drenderer.cpp
+++ b/src/datavisualization/engine/abstract3drenderer.cpp
@@ -573,6 +573,7 @@ CustomRenderItem *Abstract3DRenderer::addCustomItem(QCustom3DItem *item)
newItem->setItemPointer(item); // Store pointer for render item updates
newItem->setMesh(item->meshFile());
newItem->setScaling(item->scaling());
+ newItem->setPosition(item->position());
newItem->setRotation(item->rotation());
QImage textureImage = item->d_ptr->textureImage();
newItem->setBlendNeeded(textureImage.hasAlphaChannel());
@@ -614,6 +615,7 @@ void Abstract3DRenderer::updateCustomItem(CustomRenderItem *renderItem)
}
if (item->d_ptr->m_dirtyBits.positionDirty) {
QVector3D translation = convertPositionToTranslation(item->position());
+ renderItem->setPosition(item->position());
renderItem->setTranslation(translation);
item->d_ptr->m_dirtyBits.positionDirty = false;
}
@@ -651,7 +653,14 @@ void Abstract3DRenderer::drawCustomItems(RenderingState state,
// Draw custom items
foreach (CustomRenderItem *item, m_customRenderCache) {
- if (!item->isVisible())
+ // Check that the render item is visible and within axis ranges, and skip drawing if not
+ if (!item->isVisible()
+ || item->position().x() < m_axisCacheX.min()
+ || item->position().x() > m_axisCacheX.max()
+ || item->position().z() < m_axisCacheZ.min()
+ || item->position().z() > m_axisCacheZ.max()
+ || item->position().y() < m_axisCacheY.min()
+ || item->position().y() > m_axisCacheY.max())
continue;
QMatrix4x4 modelMatrix;
diff --git a/tests/qmlcamera/qml/qmlcamera/main.qml b/tests/qmlcamera/qml/qmlcamera/main.qml
index d2109772..c357accf 100644
--- a/tests/qmlcamera/qml/qmlcamera/main.qml
+++ b/tests/qmlcamera/qml/qmlcamera/main.qml
@@ -74,7 +74,7 @@ Rectangle {
id: shuttleItem
meshFile: ":/items/shuttle.obj"
textureFile: ":/items/shuttle.png"
- position: Qt.vector3d(5.0,35.0,3.0)
+ position: Qt.vector3d(5.0,29.0,3.0)
scaling: Qt.vector3d(0.2,0.2,0.2)
}
@@ -152,6 +152,7 @@ Rectangle {
onClicked: {
currentAngle += 5
chartData.series.meshAngle = currentAngle
+ shuttleItem.setRotationAxisAndAngle(Qt.vector3d(0.0, 1.0, 1.0), currentAngle)
}
}