summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-12-05 06:28:02 +0200
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-12-05 06:28:56 +0200
commite57ed8602ac02ff86e3c08362ca4fbe23fe05bfb (patch)
tree8182e15307cf5853255b6d6d9d0c0b017875cc1d /src/datavisualization/data/qheightmapsurfacedataproxy.cpp
parent78d4deb0be21f22d74e3e01315686857ef8edf2e (diff)
Notifys added to properties
Task-number: QTRD-2671 Change-Id: If95696b01eab836c2b4d5c6a3c19d7da9b255ab3 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/data/qheightmapsurfacedataproxy.cpp')
-rw-r--r--src/datavisualization/data/qheightmapsurfacedataproxy.cpp66
1 files changed, 48 insertions, 18 deletions
diff --git a/src/datavisualization/data/qheightmapsurfacedataproxy.cpp b/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
index 88ed2f5d..ce379592 100644
--- a/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
+++ b/src/datavisualization/data/qheightmapsurfacedataproxy.cpp
@@ -59,11 +59,12 @@ const float defaultMaxValue = 10.0f;
*/
/*!
- * \qmlproperty image HeightMapSurfaceDataProxy::heightMap
+ * \qmlproperty string HeightMapSurfaceDataProxy::heightMapFile
*
- * A height map to be visualized. Setting this property replaces current data with height map data.
+ * A file with a height map image to be visualized. Setting this property replaces current data
+ * with height map data.
*
- * There are several formats the image can be given in, but if it is not in a directly usable
+ * There are several formats the image file can be given in, but if it is not in a directly usable
* format, a conversion is made. \note If the result seems wrong, the automatic conversion failed
* and you should try converting the image yourself before setting it. Preferred format is
* QImage::Format_RGB32 in grayscale.
@@ -81,15 +82,6 @@ const float defaultMaxValue = 10.0f;
*/
/*!
- * \qmlproperty string HeightMapSurfaceDataProxy::heightMapFile
- *
- * A file with a height map image to be visualized. Setting this property replaces current data
- * with height map data.
- *
- * \sa heightMap
- */
-
-/*!
* \qmlproperty real HeightMapSurfaceDataProxy::minXValue
*
* The minimum X value for the generated surface points.
@@ -202,6 +194,7 @@ void QHeightMapSurfaceDataProxy::setHeightMapFile(const QString &filename)
{
dptr()->m_heightMapFile = filename;
setHeightMap(QImage(filename));
+ emit heightMapFileChanged(filename);
}
QString QHeightMapSurfaceDataProxy::heightMapFile() const
@@ -330,11 +323,17 @@ QHeightMapSurfaceDataProxy *QHeightMapSurfaceDataProxyPrivate::qptr()
void QHeightMapSurfaceDataProxyPrivate::setValueRanges(float minX, float maxX, float minZ, float maxZ)
{
- bool changed = false;
- if (m_minXValue != minX || m_minZValue != minZ) {
+ bool minXChanged = false;
+ bool maxXChanged = false;
+ bool minZChanged = false;
+ bool maxZChanged = false;
+ if (m_minXValue != minX) {
m_minXValue = minX;
+ minXChanged = true;
+ }
+ if (m_minZValue != minZ) {
m_minZValue = minZ;
- changed = true;
+ minZChanged = true;
}
if (m_maxXValue != maxX || minX >= maxX) {
if (minX >= maxX) {
@@ -345,7 +344,7 @@ void QHeightMapSurfaceDataProxyPrivate::setValueRanges(float minX, float maxX, f
} else {
m_maxXValue = maxX;
}
- changed = true;
+ maxXChanged = true;
}
if (m_maxZValue != maxZ || minZ >= maxZ) {
if (minZ >= maxZ) {
@@ -356,24 +355,38 @@ void QHeightMapSurfaceDataProxyPrivate::setValueRanges(float minX, float maxX, f
} else {
m_maxZValue = maxZ;
}
- changed = true;
+ maxZChanged = true;
}
- if (changed && !m_resolveTimer.isActive())
+ if (minXChanged)
+ emit qptr()->minXValueChanged(m_minXValue);
+ if (minZChanged)
+ emit qptr()->minZValueChanged(m_minZValue);
+ if (maxXChanged)
+ emit qptr()->maxXValueChanged(m_maxXValue);
+ if (maxZChanged)
+ emit qptr()->maxZValueChanged(m_maxZValue);
+
+ if ((minXChanged || minZChanged || maxXChanged || maxZChanged) && !m_resolveTimer.isActive())
m_resolveTimer.start(0);
}
void QHeightMapSurfaceDataProxyPrivate::setMinXValue(float min)
{
if (min != m_minXValue) {
+ bool maxChanged = false;
if (min >= m_maxXValue) {
float oldMax = m_maxXValue;
m_maxXValue = min + 1.0f;
qWarning() << "Warning: Tried to set minimum X to equal or larger than maximum X for"
" value range. Maximum automatically adjusted to a valid one:"
<< oldMax << "-->" << m_maxXValue;
+ maxChanged = true;
}
m_minXValue = min;
+ emit qptr()->minXValueChanged(m_minXValue);
+ if (maxChanged)
+ emit qptr()->maxXValueChanged(m_maxXValue);
if (!m_resolveTimer.isActive())
m_resolveTimer.start(0);
@@ -383,14 +396,19 @@ void QHeightMapSurfaceDataProxyPrivate::setMinXValue(float min)
void QHeightMapSurfaceDataProxyPrivate::setMaxXValue(float max)
{
if (m_maxXValue != max) {
+ bool minChanged = false;
if (max <= m_minXValue) {
float oldMin = m_minXValue;
m_minXValue = max - 1.0f;
qWarning() << "Warning: Tried to set maximum X to equal or smaller than minimum X for"
" value range. Minimum automatically adjusted to a valid one:"
<< oldMin << "-->" << m_minXValue;
+ minChanged = true;
}
m_maxXValue = max;
+ emit qptr()->maxXValueChanged(m_maxXValue);
+ if (minChanged)
+ emit qptr()->minXValueChanged(m_minXValue);
if (!m_resolveTimer.isActive())
m_resolveTimer.start(0);
@@ -400,14 +418,19 @@ void QHeightMapSurfaceDataProxyPrivate::setMaxXValue(float max)
void QHeightMapSurfaceDataProxyPrivate::setMinZValue(float min)
{
if (min != m_minZValue) {
+ bool maxChanged = false;
if (min >= m_maxZValue) {
float oldMax = m_maxZValue;
m_maxZValue = min + 1.0f;
qWarning() << "Warning: Tried to set minimum Z to equal or larger than maximum Z for"
" value range. Maximum automatically adjusted to a valid one:"
<< oldMax << "-->" << m_maxZValue;
+ maxChanged = true;
}
m_minZValue = min;
+ emit qptr()->minZValueChanged(m_minZValue);
+ if (maxChanged)
+ emit qptr()->maxZValueChanged(m_maxZValue);
if (!m_resolveTimer.isActive())
m_resolveTimer.start(0);
@@ -417,14 +440,19 @@ void QHeightMapSurfaceDataProxyPrivate::setMinZValue(float min)
void QHeightMapSurfaceDataProxyPrivate::setMaxZValue(float max)
{
if (m_maxZValue != max) {
+ bool minChanged = false;
if (max <= m_minZValue) {
float oldMin = m_minZValue;
m_minZValue = max - 1.0f;
qWarning() << "Warning: Tried to set maximum Z to equal or smaller than minimum Z for"
" value range. Minimum automatically adjusted to a valid one:"
<< oldMin << "-->" << m_minZValue;
+ minChanged = true;
}
m_maxZValue = max;
+ emit qptr()->maxZValueChanged(m_maxZValue);
+ if (minChanged)
+ emit qptr()->minZValueChanged(m_minZValue);
if (!m_resolveTimer.isActive())
m_resolveTimer.start(0);
@@ -434,6 +462,7 @@ void QHeightMapSurfaceDataProxyPrivate::setMaxZValue(float max)
void QHeightMapSurfaceDataProxyPrivate::handlePendingResolve()
{
QImage heightImage = m_heightMap;
+
// Convert to RGB32 to be sure we're reading the right bytes
if (heightImage.format() != QImage::Format_RGB32)
heightImage = heightImage.convertToFormat(QImage::Format_RGB32);
@@ -516,6 +545,7 @@ void QHeightMapSurfaceDataProxyPrivate::handlePendingResolve()
}
qptr()->resetArray(dataArray);
+ emit qptr()->heightMapChanged(m_heightMap);
}
QT_DATAVISUALIZATION_END_NAMESPACE