summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/data
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2014-09-09 11:30:15 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2014-09-10 12:30:54 +0300
commitddb9be979d93b7e17f1067dc6056de54d9828b29 (patch)
treedf612c56e4a804481297ae55b29f0ee379c5f8ab /src/datavisualization/data
parentbb30ea555c71604de9a2bc5096fa35c9532b26bd (diff)
Limit volume to axis ranges
The volume object that would go partially outside axis ranges is scale and repositioned so that it only renders the portion that is inside the axis ranges. Change-Id: I792494e437998ba6276f58fab645767276c1476d Reviewed-by: Mika Salmela <mika.salmela@digia.com>
Diffstat (limited to 'src/datavisualization/data')
-rw-r--r--src/datavisualization/data/customrenderitem_p.h26
-rw-r--r--src/datavisualization/data/qcustom3ditem.cpp10
-rw-r--r--src/datavisualization/data/qcustom3dvolume.cpp26
3 files changed, 54 insertions, 8 deletions
diff --git a/src/datavisualization/data/customrenderitem_p.h b/src/datavisualization/data/customrenderitem_p.h
index 8ea8e894..84fc898a 100644
--- a/src/datavisualization/data/customrenderitem_p.h
+++ b/src/datavisualization/data/customrenderitem_p.h
@@ -55,6 +55,8 @@ public:
inline QVector3D origScaling() const { return m_origScaling; }
inline void setPosition(const QVector3D &position) { m_position = position; }
inline QVector3D position() const { return m_position; }
+ inline void setOrigPosition(const QVector3D &position) { m_origPosition = position; }
+ inline QVector3D origPosition() const { return m_origPosition; }
inline void setPositionAbsolute(bool absolute) { m_positionAbsolute = absolute; }
inline bool isPositionAbsolute() const { return m_positionAbsolute; }
inline void setScalingAbsolute(bool absolute) { m_scalingAbsolute = absolute; }
@@ -104,6 +106,25 @@ public:
inline bool preserveOpacity() const { return m_preserveOpacity; }
inline void setUseHighDefShader(bool enable) { m_useHighDefShader = enable; }
inline bool useHighDefShader() const {return m_useHighDefShader; }
+ inline void setMinBounds(const QVector3D &bounds) {
+ m_minBounds = bounds;
+ m_minBoundsNormal = m_minBounds;
+ m_minBoundsNormal.setY(-m_minBoundsNormal.y());
+ m_minBoundsNormal.setZ(-m_minBoundsNormal.z());
+ m_minBoundsNormal = 0.5f * (m_minBoundsNormal + oneVector);
+
+ }
+ inline QVector3D minBounds() const { return m_minBounds; }
+ inline void setMaxBounds(const QVector3D &bounds) {
+ m_maxBounds = bounds;
+ m_maxBoundsNormal = m_maxBounds;
+ m_maxBoundsNormal.setY(-m_maxBoundsNormal.y());
+ m_maxBoundsNormal.setZ(-m_maxBoundsNormal.z());
+ m_maxBoundsNormal = 0.5f * (m_maxBoundsNormal + oneVector);
+ }
+ inline QVector3D maxBounds() const { return m_maxBounds; }
+ inline QVector3D minBoundsNormal() const { return m_minBoundsNormal; }
+ inline QVector3D maxBoundsNormal() const { return m_maxBoundsNormal; }
private:
Q_DISABLE_COPY(CustomRenderItem)
@@ -112,6 +133,7 @@ private:
QVector3D m_scaling;
QVector3D m_origScaling;
QVector3D m_position;
+ QVector3D m_origPosition;
bool m_positionAbsolute;
bool m_scalingAbsolute;
ObjectHelper *m_object; // shared reference
@@ -138,6 +160,10 @@ private:
float m_alphaMultiplier;
bool m_preserveOpacity;
bool m_useHighDefShader;
+ QVector3D m_minBounds;
+ QVector3D m_maxBounds;
+ QVector3D m_minBoundsNormal;
+ QVector3D m_maxBoundsNormal;
};
typedef QHash<QCustom3DItem *, CustomRenderItem *> CustomRenderItemArray;
diff --git a/src/datavisualization/data/qcustom3ditem.cpp b/src/datavisualization/data/qcustom3ditem.cpp
index 64cb4531..4e82d47a 100644
--- a/src/datavisualization/data/qcustom3ditem.cpp
+++ b/src/datavisualization/data/qcustom3ditem.cpp
@@ -67,10 +67,10 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* within axis ranges.
*
* \note Items positioned outside any axis range are not rendered if positionAbsolute is \c{false},
- * unless the item is a Custom3DVolume that would be partially visible. In that case, the visible
- * portion of the volume will be rendered.
+ * unless the item is a Custom3DVolume that would be partially visible and scalingAbsolute is also
+ * \c{false}. In that case, the visible portion of the volume will be rendered.
*
- * \sa positionAbsolute
+ * \sa positionAbsolute, scalingAbsolute
*/
/*! \qmlproperty bool Custom3DItem::positionAbsolute
@@ -206,8 +206,8 @@ QString QCustom3DItem::meshFile() const
* within axis ranges.
*
* \note Items positioned outside any axis range are not rendered if positionAbsolute is \c{false},
- * unless the item is a QCustom3DVolume that would be partially visible. In that case, the visible
- * portion of the volume will be rendered.
+ * unless the item is a QCustom3DVolume that would be partially visible and scalingAbsolute is also
+ * \c{false}. In that case, the visible portion of the volume will be rendered.
*
* \sa positionAbsolute
*/
diff --git a/src/datavisualization/data/qcustom3dvolume.cpp b/src/datavisualization/data/qcustom3dvolume.cpp
index d0e0c139..78c91802 100644
--- a/src/datavisualization/data/qcustom3dvolume.cpp
+++ b/src/datavisualization/data/qcustom3dvolume.cpp
@@ -31,9 +31,19 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* object is a box with a 3D texture. Three slice planes are supported for the volume, one along
* each main axis of the volume.
*
+ * Rendering volume objects is very performance intensive, especially when the volume is largely
+ * transparent, as the contents of the volume are ray-traced. The performance scales nearly linearly
+ * with the amount of pixels that the volume occupies on the screen, so showing the volume in a
+ * smaller view or limiting the zoom level of the graph are easy ways to improve performance.
+ * Similarly, the volume texture dimensions have a large impact on performance.
+ * If the frame rate is more important than pixel-perfect rendering of the volume contents, consider
+ * turning the high definition shader off by setting useHighDefShader property to \c{false}.
+ *
* \note Volumetric objects are only supported with orthographic projection.
*
- * \sa QAbstract3DGraph::addCustomItem(), QAbstract3DGraph::orthoProjection
+ * \note Volumetric objects utilize 3D textures, which are not supported in OpenGL ES2 environments.
+ *
+ * \sa QAbstract3DGraph::addCustomItem(), QAbstract3DGraph::orthoProjection, useHighDefShader
*/
/*!
@@ -48,13 +58,23 @@ QT_BEGIN_NAMESPACE_DATAVISUALIZATION
* object is a box with a 3D texture. Three slice planes are supported for the volume, one along
* each main axis of the volume.
*
+ * Rendering volume objects is very performance intensive, especially when the volume is largely
+ * transparent, as the contents of the volume are ray-traced. The performance scales nearly linearly
+ * with the amount of pixels that the volume occupies on the screen, so showing the volume in a
+ * smaller view or limiting the zoom level of the graph are easy ways to improve performance.
+ * Similarly, the volume texture dimensions have a large impact on performance.
+ * If the frame rate is more important than pixel-perfect rendering of the volume contents, consider
+ * turning the high definition shader off by setting useHighDefShader property to \c{false}.
+ *
* \note: Filling in the volume data would not typically be efficient or practical from pure QML,
* so properties directly related to that are not fully supported from QML.
- * Make a hybrid QML/C++ application if you want to use volume objects with QML ui.
+ * Make a hybrid QML/C++ application if you want to use volume objects with a QML UI.
*
* \note Volumetric objects are only supported with orthographic projection.
*
- * \sa AbstractGraph3D::orthoProjection
+ * \note Volumetric objects utilize 3D textures, which are not supported in OpenGL ES2 environments.
+ *
+ * \sa AbstractGraph3D::orthoProjection, useHighDefShader
*/
/*! \qmlproperty int Custom3DVolume::textureWidth