From e57ed8602ac02ff86e3c08362ca4fbe23fe05bfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Thu, 5 Dec 2013 06:28:02 +0200 Subject: Notifys added to properties MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTRD-2671 Change-Id: If95696b01eab836c2b4d5c6a3c19d7da9b255ab3 Reviewed-by: Tomi Korpipää --- src/datavisualization/axis/q3dabstractaxis.cpp | 85 +++++++++++++++------- src/datavisualization/axis/q3dabstractaxis.h | 25 ++++--- src/datavisualization/axis/q3dcategoryaxis.cpp | 21 +++--- src/datavisualization/axis/q3dcategoryaxis.h | 9 ++- src/datavisualization/data/qabstract3dseries.h | 2 +- src/datavisualization/data/qabstractdataproxy.h | 2 +- src/datavisualization/data/qbardataproxy.cpp | 12 +++ src/datavisualization/data/qbardataproxy.h | 3 +- .../data/qheightmapsurfacedataproxy.cpp | 66 ++++++++++++----- .../data/qheightmapsurfacedataproxy.h | 21 ++++-- src/datavisualization/data/qscatterdataproxy.cpp | 6 ++ src/datavisualization/data/qscatterdataproxy.h | 4 +- src/datavisualization/data/qsurfacedataproxy.cpp | 7 ++ src/datavisualization/data/qsurfacedataproxy.h | 7 +- src/datavisualization/engine/q3dcamera.h | 4 +- src/datavisualizationqml2/colorgradient.cpp | 2 + src/datavisualizationqml2/colorgradient_p.h | 8 +- src/datavisualizationqml2/declarativebars.cpp | 8 ++ src/datavisualizationqml2/declarativebars_p.h | 9 ++- src/datavisualizationqml2/declarativescatter.cpp | 8 ++ src/datavisualizationqml2/declarativescatter_p.h | 10 ++- src/datavisualizationqml2/declarativesurface.cpp | 8 ++ src/datavisualizationqml2/declarativesurface_p.h | 11 ++- 23 files changed, 244 insertions(+), 94 deletions(-) (limited to 'src') diff --git a/src/datavisualization/axis/q3dabstractaxis.cpp b/src/datavisualization/axis/q3dabstractaxis.cpp index 82d6e775..0b284947 100644 --- a/src/datavisualization/axis/q3dabstractaxis.cpp +++ b/src/datavisualization/axis/q3dabstractaxis.cpp @@ -51,6 +51,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE /*! * \qmlproperty list AbstractAxis3D::labels * Defines the labels for the axis. + * \note Setting this property for ValueAxis3D does nothing, as it generates labels automatically. */ /*! @@ -123,27 +124,6 @@ Q3DAbstractAxis::~Q3DAbstractAxis() { } -/*! - * \property Q3DAbstractAxis::title - * - * Defines the title for the axis. - */ -QString Q3DAbstractAxis::title() const -{ - return d_ptr->m_title; -} - -/*! - * \property Q3DAbstractAxis::labels - * - * Defines the labels for the axis. - */ -QStringList Q3DAbstractAxis::labels() const -{ - d_ptr->updateLabels(); - return d_ptr->m_labels; -} - /*! * \property Q3DAbstractAxis::orientation * @@ -164,6 +144,11 @@ Q3DAbstractAxis::AxisType Q3DAbstractAxis::type() const return d_ptr->m_type; } +/*! + * \property Q3DAbstractAxis::title + * + * Defines the title for the axis. + */ void Q3DAbstractAxis::setTitle(QString title) { if (d_ptr->m_title != title) { @@ -172,6 +157,28 @@ void Q3DAbstractAxis::setTitle(QString title) } } +QString Q3DAbstractAxis::title() const +{ + return d_ptr->m_title; +} + +/*! + * \property Q3DAbstractAxis::labels + * + * Defines the labels for the axis. + * \note Setting this property for Q3DValueAxis does nothing, as it generates labels automatically. + */ +void Q3DAbstractAxis::setLabels(const QStringList &labels) +{ + Q_UNUSED(labels) +} + +QStringList Q3DAbstractAxis::labels() const +{ + d_ptr->updateLabels(); + return d_ptr->m_labels; +} + /*! * Sets value range of the axis from \a min to \a max. * When setting the range, the max is adjusted if necessary, to ensure that the range remains valid. @@ -241,6 +248,12 @@ bool Q3DAbstractAxis::isAutoAdjustRange() const return d_ptr->m_autoAdjust; } +/*! + * \fn Q3DAbstractAxis::rangeChanged(float min, float max) + * + * Emits range \a min and \a max values when range changes. + */ + // Q3DAbstractAxisPrivate Q3DAbstractAxisPrivate::Q3DAbstractAxisPrivate(Q3DAbstractAxis *q, Q3DAbstractAxis::AxisType type) @@ -263,10 +276,12 @@ Q3DAbstractAxisPrivate::~Q3DAbstractAxisPrivate() void Q3DAbstractAxisPrivate::setOrientation(Q3DAbstractAxis::AxisOrientation orientation) { - if (m_orientation == Q3DAbstractAxis::AxisOrientationNone) + if (m_orientation == Q3DAbstractAxis::AxisOrientationNone) { m_orientation = orientation; - else + emit q_ptr->orientationChanged(orientation); + } else { Q_ASSERT("Attempted to reset axis orientation."); + } } void Q3DAbstractAxisPrivate::updateLabels() @@ -290,10 +305,11 @@ void Q3DAbstractAxisPrivate::setRange(float min, float max) // If min >= max, we adjust ranges so that // m_max becomes (min + 1.0f) // as axes need some kind of valid range. - bool dirty = false; + bool minDirty = false; + bool maxDirty = false; if (m_min != min) { m_min = min; - dirty = true; + minDirty = true; } if (m_max != max || min > max || (!m_allowMinMaxSame && min == max)) { if (min > max || (!m_allowMinMaxSame && min == max)) { @@ -302,10 +318,10 @@ void Q3DAbstractAxisPrivate::setRange(float min, float max) } else { m_max = max; } - dirty = true; + maxDirty = true; } - if (dirty) { + if (minDirty || maxDirty) { if (adjusted) { qWarning() << "Warning: Tried to set invalid range for axis." " Range automatically adjusted to a valid one:" @@ -313,6 +329,11 @@ void Q3DAbstractAxisPrivate::setRange(float min, float max) } emit q_ptr->rangeChanged(m_min, m_max); } + + if (minDirty) + emit q_ptr->minChanged(m_min); + if (maxDirty) + emit q_ptr->maxChanged(m_max); } void Q3DAbstractAxisPrivate::setMin(float min) @@ -326,16 +347,21 @@ void Q3DAbstractAxisPrivate::setMin(float min) } if (m_min != min) { + bool maxChanged = false; if (min > m_max || (!m_allowMinMaxSame && min == m_max)) { float oldMax = m_max; m_max = min + 1.0f; qWarning() << "Warning: Tried to set minimum to equal or larger than maximum for" " value axis. Maximum automatically adjusted to a valid one:" << oldMax << "-->" << m_max; + maxChanged = true; } m_min = min; emit q_ptr->rangeChanged(m_min, m_max); + emit q_ptr->minChanged(m_min); + if (maxChanged) + emit q_ptr->maxChanged(m_max); } } @@ -350,6 +376,7 @@ void Q3DAbstractAxisPrivate::setMax(float max) } if (m_max != max) { + bool minChanged = false; if (m_min > max || (!m_allowMinMaxSame && m_min == max)) { float oldMin = m_min; m_min = max - 1.0f; @@ -364,9 +391,13 @@ void Q3DAbstractAxisPrivate::setMax(float max) qWarning() << "Warning: Tried to set maximum to equal or smaller than minimum for" " value axis. Minimum automatically adjusted to a valid one:" << oldMin << "-->" << m_min; + minChanged = true; } m_max = max; emit q_ptr->rangeChanged(m_min, m_max); + emit q_ptr->maxChanged(m_max); + if (minChanged) + emit q_ptr->minChanged(m_min); } } diff --git a/src/datavisualization/axis/q3dabstractaxis.h b/src/datavisualization/axis/q3dabstractaxis.h index c154c3ea..825290f5 100644 --- a/src/datavisualization/axis/q3dabstractaxis.h +++ b/src/datavisualization/axis/q3dabstractaxis.h @@ -35,11 +35,11 @@ class QT_DATAVISUALIZATION_EXPORT Q3DAbstractAxis : public QObject Q_ENUMS(AxisOrientation) Q_ENUMS(AxisType) Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) - Q_PROPERTY(QStringList labels READ labels NOTIFY labelsChanged) - Q_PROPERTY(AxisOrientation orientation READ orientation) - Q_PROPERTY(AxisType type READ type) - Q_PROPERTY(float min READ min WRITE setMin NOTIFY rangeChanged) - Q_PROPERTY(float max READ max WRITE setMax NOTIFY rangeChanged) + Q_PROPERTY(QStringList labels READ labels WRITE setLabels NOTIFY labelsChanged) + Q_PROPERTY(AxisOrientation orientation READ orientation NOTIFY orientationChanged) + Q_PROPERTY(AxisType type READ type CONSTANT) + Q_PROPERTY(float min READ min WRITE setMin NOTIFY minChanged) + Q_PROPERTY(float max READ max WRITE setMax NOTIFY maxChanged) Q_PROPERTY(bool autoAdjustRange READ isAutoAdjustRange WRITE setAutoAdjustRange NOTIFY autoAdjustRangeChanged) public: @@ -63,25 +63,32 @@ protected: public: virtual ~Q3DAbstractAxis(); + void setTitle(QString title); QString title() const; + + void setLabels(const QStringList &labels); QStringList labels() const; AxisOrientation orientation() const; AxisType type() const; + void setMin(float min); float min() const; + + void setMax(float max); float max() const; + + void setAutoAdjustRange(bool autoAdjust); bool isAutoAdjustRange() const; - void setTitle(QString title); void setRange(float min, float max); - void setMin(float min); - void setMax(float max); - void setAutoAdjustRange(bool autoAdjust); signals: void titleChanged(QString newTitle); void labelsChanged(); + void orientationChanged(AxisOrientation orientation); + void minChanged(float value); + void maxChanged(float value); void rangeChanged(float min, float max); void autoAdjustRangeChanged(bool autoAdjust); diff --git a/src/datavisualization/axis/q3dcategoryaxis.cpp b/src/datavisualization/axis/q3dcategoryaxis.cpp index 6d2dec3a..26a75f93 100644 --- a/src/datavisualization/axis/q3dcategoryaxis.cpp +++ b/src/datavisualization/axis/q3dcategoryaxis.cpp @@ -49,10 +49,14 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE */ /*! - * \qmlproperty list CategoryAxis3D::categoryLabels + * \qmlproperty list CategoryAxis3D::labels + * * Defines labels for axis applied to categories. If there are fewer labels than categories, the * remaining ones do not have a label. If category labels are not defined explicitly, labels are - * generated from the data row and column labels. + * generated from the data row (or column) labels. + * + * \note If the graph has multiple visible series and category labels are not defined explicitly, + * changing the rows (or columns) on any of the attached series will regenerate the labels. */ /*! @@ -61,6 +65,7 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE Q3DCategoryAxis::Q3DCategoryAxis(QObject *parent) : Q3DAbstractAxis(new Q3DCategoryAxisPrivate(this), parent) { + connect(this, &Q3DCategoryAxis::labelsChanged, this, &Q3DAbstractAxis::labelsChanged); } /*! @@ -71,7 +76,7 @@ Q3DCategoryAxis::~Q3DCategoryAxis() } /*! - * \property Q3DCategoryAxis::categoryLabels + * \property Q3DCategoryAxis::labels * * Defines labels for axis applied to categories. If there are fewer labels than categories, the * remaining ones do not have a label. If category labels are not defined explicitly, labels are @@ -79,17 +84,13 @@ Q3DCategoryAxis::~Q3DCategoryAxis() * * \note If the graph has multiple visible series and category labels are not defined explicitly, * changing the rows (or columns) on any of the attached series will regenerate the labels. - * - * \note CategoryLabels actually reads/writes the Q3DAbstractAxis::labels property, - * which is read only there. Since subclass cannot have property with same name, - * this partially duplicate property is necessary. */ -QStringList Q3DCategoryAxis::categoryLabels() const +QStringList Q3DCategoryAxis::labels() const { - return labels(); + return Q3DAbstractAxis::labels(); } -void Q3DCategoryAxis::setCategoryLabels(const QStringList &labels) +void Q3DCategoryAxis::setLabels(const QStringList &labels) { dptr()->m_labelsExplicitlySet = !labels.isEmpty(); bool labelsFromData = false; diff --git a/src/datavisualization/axis/q3dcategoryaxis.h b/src/datavisualization/axis/q3dcategoryaxis.h index ef545950..7b2b4744 100644 --- a/src/datavisualization/axis/q3dcategoryaxis.h +++ b/src/datavisualization/axis/q3dcategoryaxis.h @@ -28,14 +28,17 @@ class Q3DCategoryAxisPrivate; class QT_DATAVISUALIZATION_EXPORT Q3DCategoryAxis : public Q3DAbstractAxis { Q_OBJECT - Q_PROPERTY(QStringList categoryLabels READ categoryLabels WRITE setCategoryLabels) + Q_PROPERTY(QStringList labels READ labels WRITE setLabels NOTIFY labelsChanged) public: explicit Q3DCategoryAxis(QObject *parent = 0); virtual ~Q3DCategoryAxis(); - QStringList categoryLabels() const; - void setCategoryLabels(const QStringList &labels); + void setLabels(const QStringList &labels); + QStringList labels() const; + +signals: + void labelsChanged(); protected: Q3DCategoryAxisPrivate *dptr(); diff --git a/src/datavisualization/data/qabstract3dseries.h b/src/datavisualization/data/qabstract3dseries.h index 58346bec..f5dfcf09 100644 --- a/src/datavisualization/data/qabstract3dseries.h +++ b/src/datavisualization/data/qabstract3dseries.h @@ -32,7 +32,7 @@ class QT_DATAVISUALIZATION_EXPORT QAbstract3DSeries : public QObject Q_OBJECT Q_ENUMS(SeriesType) Q_ENUMS(Mesh) - Q_PROPERTY(SeriesType type READ type) + Q_PROPERTY(SeriesType type READ type CONSTANT) Q_PROPERTY(QString itemLabelFormat READ itemLabelFormat WRITE setItemLabelFormat NOTIFY itemLabelFormatChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibilityChanged) Q_PROPERTY(Mesh mesh READ mesh WRITE setMesh NOTIFY meshChanged) diff --git a/src/datavisualization/data/qabstractdataproxy.h b/src/datavisualization/data/qabstractdataproxy.h index 2320d254..2a053c60 100644 --- a/src/datavisualization/data/qabstractdataproxy.h +++ b/src/datavisualization/data/qabstractdataproxy.h @@ -31,7 +31,7 @@ class QT_DATAVISUALIZATION_EXPORT QAbstractDataProxy : public QObject { Q_OBJECT Q_ENUMS(DataType) - Q_PROPERTY(DataType type READ type) + Q_PROPERTY(DataType type READ type CONSTANT) public: enum DataType { diff --git a/src/datavisualization/data/qbardataproxy.cpp b/src/datavisualization/data/qbardataproxy.cpp index 2529eeac..80768059 100644 --- a/src/datavisualization/data/qbardataproxy.cpp +++ b/src/datavisualization/data/qbardataproxy.cpp @@ -129,6 +129,7 @@ QBar3DSeries *QBarDataProxy::series() void QBarDataProxy::resetArray() { resetArray(0, QStringList(), QStringList()); + emit rowCountChanged(rowCount()); } /*! @@ -142,6 +143,7 @@ void QBarDataProxy::resetArray(QBarDataArray *newArray) { dptr()->resetArray(newArray, 0, 0); emit arrayReset(); + emit rowCountChanged(rowCount()); } /*! @@ -156,6 +158,7 @@ void QBarDataProxy::resetArray(QBarDataArray *newArray, const QStringList &rowLa { dptr()->resetArray(newArray, &rowLabels, &columnLabels); emit arrayReset(); + emit rowCountChanged(rowCount()); } /*! @@ -221,6 +224,7 @@ int QBarDataProxy::addRow(QBarDataRow *row) { int addIndex = dptr()->addRow(row, 0); emit rowsAdded(addIndex, 1); + emit rowCountChanged(rowCount()); return addIndex; } @@ -233,6 +237,7 @@ int QBarDataProxy::addRow(QBarDataRow *row, const QString &label) { int addIndex = dptr()->addRow(row, &label); emit rowsAdded(addIndex, 1); + emit rowCountChanged(rowCount()); return addIndex; } @@ -246,6 +251,7 @@ int QBarDataProxy::addRows(const QBarDataArray &rows) { int addIndex = dptr()->addRows(rows, 0); emit rowsAdded(addIndex, rows.size()); + emit rowCountChanged(rowCount()); return addIndex; } @@ -258,6 +264,7 @@ int QBarDataProxy::addRows(const QBarDataArray &rows, const QStringList &labels) { int addIndex = dptr()->addRows(rows, &labels); emit rowsAdded(addIndex, rows.size()); + emit rowCountChanged(rowCount()); return addIndex; } @@ -272,6 +279,7 @@ void QBarDataProxy::insertRow(int rowIndex, QBarDataRow *row) { dptr()->insertRow(rowIndex, row, 0); emit rowsInserted(rowIndex, 1); + emit rowCountChanged(rowCount()); } /*! @@ -282,6 +290,7 @@ void QBarDataProxy::insertRow(int rowIndex, QBarDataRow *row, const QString &lab { dptr()->insertRow(rowIndex, row, &label); emit rowsInserted(rowIndex, 1); + emit rowCountChanged(rowCount()); } /*! @@ -295,6 +304,7 @@ void QBarDataProxy::insertRows(int rowIndex, const QBarDataArray &rows) { dptr()->insertRows(rowIndex, rows, 0); emit rowsInserted(rowIndex, rows.size()); + emit rowCountChanged(rowCount()); } /*! @@ -305,6 +315,7 @@ void QBarDataProxy::insertRows(int rowIndex, const QBarDataArray &rows, const QS { dptr()->insertRows(rowIndex, rows, &labels); emit rowsInserted(rowIndex, rows.size()); + emit rowCountChanged(rowCount()); } /*! @@ -319,6 +330,7 @@ void QBarDataProxy::removeRows(int rowIndex, int removeCount, bool removeLabels) if (rowIndex < rowCount() && removeCount >= 1) { dptr()->removeRows(rowIndex, removeCount, removeLabels); emit rowsRemoved(rowIndex, removeCount); + emit rowCountChanged(rowCount()); } } diff --git a/src/datavisualization/data/qbardataproxy.h b/src/datavisualization/data/qbardataproxy.h index accd7460..94e15116 100644 --- a/src/datavisualization/data/qbardataproxy.h +++ b/src/datavisualization/data/qbardataproxy.h @@ -36,7 +36,7 @@ class QT_DATAVISUALIZATION_EXPORT QBarDataProxy : public QAbstractDataProxy { Q_OBJECT - Q_PROPERTY(int rowCount READ rowCount) + Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged) Q_PROPERTY(QStringList rowLabels READ rowLabels WRITE setRowLabels NOTIFY rowLabelsChanged) Q_PROPERTY(QStringList columnLabels READ columnLabels WRITE setColumnLabels NOTIFY columnLabelsChanged) Q_PROPERTY(QBar3DSeries *series READ series NOTIFY seriesChanged) @@ -88,6 +88,7 @@ signals: void rowsInserted(int startIndex, int count); void itemChanged(int rowIndex, int columnIndex); + void rowCountChanged(int count); void rowLabelsChanged(); void columnLabelsChanged(); void seriesChanged(QBar3DSeries *series); 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. @@ -80,15 +81,6 @@ const float defaultMaxValue = 10.0f; * Not recommended formats: all mono formats (for example QImage::Format_Mono). */ -/*! - * \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 * @@ -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 diff --git a/src/datavisualization/data/qheightmapsurfacedataproxy.h b/src/datavisualization/data/qheightmapsurfacedataproxy.h index 3306059f..16132b0d 100644 --- a/src/datavisualization/data/qheightmapsurfacedataproxy.h +++ b/src/datavisualization/data/qheightmapsurfacedataproxy.h @@ -31,12 +31,12 @@ class QT_DATAVISUALIZATION_EXPORT QHeightMapSurfaceDataProxy : public QSurfaceDa { Q_OBJECT - Q_PROPERTY(QImage heightMap READ heightMap WRITE setHeightMap) - Q_PROPERTY(QString heightMapFile READ heightMapFile WRITE setHeightMapFile) - Q_PROPERTY(float minXValue READ minXValue WRITE setMinXValue) - Q_PROPERTY(float maxXValue READ maxXValue WRITE setMaxXValue) - Q_PROPERTY(float minZValue READ minZValue WRITE setMinZValue) - Q_PROPERTY(float maxZValue READ maxZValue WRITE setMaxZValue) + Q_PROPERTY(QImage heightMap READ heightMap WRITE setHeightMap NOTIFY heightMapChanged) + Q_PROPERTY(QString heightMapFile READ heightMapFile WRITE setHeightMapFile NOTIFY heightMapFileChanged) + Q_PROPERTY(float minXValue READ minXValue WRITE setMinXValue NOTIFY minXValueChanged) + Q_PROPERTY(float maxXValue READ maxXValue WRITE setMaxXValue NOTIFY maxXValueChanged) + Q_PROPERTY(float minZValue READ minZValue WRITE setMinZValue NOTIFY minZValueChanged) + Q_PROPERTY(float maxZValue READ maxZValue WRITE setMaxZValue NOTIFY maxZValueChanged) public: explicit QHeightMapSurfaceDataProxy(QObject *parent = 0); @@ -45,7 +45,6 @@ public: void setHeightMap(const QImage &image); QImage heightMap() const; - void setHeightMapFile(const QString &filename); QString heightMapFile() const; @@ -59,6 +58,14 @@ public: void setMaxZValue(float max); float maxZValue() const; +signals: + void heightMapChanged(QImage image); + void heightMapFileChanged(QString filename); + void minXValueChanged(float value); + void maxXValueChanged(float value); + void minZValueChanged(float value); + void maxZValueChanged(float value); + protected: explicit QHeightMapSurfaceDataProxy(QHeightMapSurfaceDataProxyPrivate *d, QObject *parent = 0); QHeightMapSurfaceDataProxyPrivate *dptr(); diff --git a/src/datavisualization/data/qscatterdataproxy.cpp b/src/datavisualization/data/qscatterdataproxy.cpp index ff37dd24..791e5dd6 100644 --- a/src/datavisualization/data/qscatterdataproxy.cpp +++ b/src/datavisualization/data/qscatterdataproxy.cpp @@ -109,6 +109,7 @@ void QScatterDataProxy::resetArray(QScatterDataArray *newArray) dptr()->resetArray(newArray); emit arrayReset(); + emit itemCountChanged(itemCount()); } /*! @@ -138,6 +139,7 @@ int QScatterDataProxy::addItem(const QScatterDataItem &item) { int addIndex = dptr()->addItem(item); emit itemsAdded(addIndex, 1); + emit itemCountChanged(itemCount()); return addIndex; } @@ -150,6 +152,7 @@ int QScatterDataProxy::addItems(const QScatterDataArray &items) { int addIndex = dptr()->addItems(items); emit itemsAdded(addIndex, items.size()); + emit itemCountChanged(itemCount()); return addIndex; } @@ -161,6 +164,7 @@ void QScatterDataProxy::insertItem(int index, const QScatterDataItem &item) { dptr()->insertItem(index, item); emit itemsInserted(index, 1); + emit itemCountChanged(itemCount()); } /*! @@ -170,6 +174,7 @@ void QScatterDataProxy::insertItems(int index, const QScatterDataArray &items) { dptr()->insertItems(index, items); emit itemsInserted(index, items.size()); + emit itemCountChanged(itemCount()); } /*! @@ -180,6 +185,7 @@ void QScatterDataProxy::removeItems(int index, int removeCount) { dptr()->removeItems(index, removeCount); emit itemsRemoved(index, removeCount); + emit itemCountChanged(itemCount()); } /*! diff --git a/src/datavisualization/data/qscatterdataproxy.h b/src/datavisualization/data/qscatterdataproxy.h index 13f10301..acb3d3d4 100644 --- a/src/datavisualization/data/qscatterdataproxy.h +++ b/src/datavisualization/data/qscatterdataproxy.h @@ -33,7 +33,7 @@ class QT_DATAVISUALIZATION_EXPORT QScatterDataProxy : public QAbstractDataProxy { Q_OBJECT - Q_PROPERTY(int itemCount READ itemCount) + Q_PROPERTY(int itemCount READ itemCount NOTIFY itemCountChanged) Q_PROPERTY(QScatter3DSeries *series READ series NOTIFY seriesChanged) public: @@ -64,6 +64,8 @@ signals: void itemsChanged(int startIndex, int count); void itemsRemoved(int startIndex, int count); void itemsInserted(int startIndex, int count); + + void itemCountChanged(int count); void seriesChanged(QScatter3DSeries *series); protected: diff --git a/src/datavisualization/data/qsurfacedataproxy.cpp b/src/datavisualization/data/qsurfacedataproxy.cpp index 678ffd8d..8deab6cc 100644 --- a/src/datavisualization/data/qsurfacedataproxy.cpp +++ b/src/datavisualization/data/qsurfacedataproxy.cpp @@ -137,6 +137,8 @@ void QSurfaceDataProxy::resetArray(QSurfaceDataArray *newArray) dptr()->resetArray(newArray); } emit arrayReset(); + emit rowCountChanged(rowCount()); + emit columnCountChanged(columnCount()); } /*! @@ -181,6 +183,7 @@ int QSurfaceDataProxy::addRow(QSurfaceDataRow *row) { int addIndex = dptr()->addRow(row); emit rowsAdded(addIndex, 1); + emit rowCountChanged(rowCount()); return addIndex; } @@ -194,6 +197,7 @@ int QSurfaceDataProxy::addRows(const QSurfaceDataArray &rows) { int addIndex = dptr()->addRows(rows); emit rowsAdded(addIndex, rows.size()); + emit rowCountChanged(rowCount()); return addIndex; } @@ -206,6 +210,7 @@ void QSurfaceDataProxy::insertRow(int rowIndex, QSurfaceDataRow *row) { dptr()->insertRow(rowIndex, row); emit rowsInserted(rowIndex, 1); + emit rowCountChanged(rowCount()); } /*! @@ -217,6 +222,7 @@ void QSurfaceDataProxy::insertRows(int rowIndex, const QSurfaceDataArray &rows) { dptr()->insertRows(rowIndex, rows); emit rowsInserted(rowIndex, rows.size()); + emit rowCountChanged(rowCount()); } /*! @@ -228,6 +234,7 @@ void QSurfaceDataProxy::removeRows(int rowIndex, int removeCount) if (rowIndex < rowCount() && removeCount >= 1) { dptr()->removeRows(rowIndex, removeCount); emit rowsRemoved(rowIndex, removeCount); + emit rowCountChanged(rowCount()); } } diff --git a/src/datavisualization/data/qsurfacedataproxy.h b/src/datavisualization/data/qsurfacedataproxy.h index c2a0fef2..04c6dbf7 100644 --- a/src/datavisualization/data/qsurfacedataproxy.h +++ b/src/datavisualization/data/qsurfacedataproxy.h @@ -34,8 +34,8 @@ class QT_DATAVISUALIZATION_EXPORT QSurfaceDataProxy : public QAbstractDataProxy { Q_OBJECT - Q_PROPERTY(int rowCount READ rowCount) - Q_PROPERTY(int columnCount READ columnCount) + Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged) + Q_PROPERTY(int columnCount READ columnCount NOTIFY columnCountChanged) Q_PROPERTY(QSurface3DSeries *series READ series NOTIFY seriesChanged) public: @@ -70,6 +70,9 @@ signals: void rowsRemoved(int startIndex, int count); void rowsInserted(int startIndex, int count); void itemChanged(int rowIndex, int columnIndex); + + void rowCountChanged(int count); + void columnCountChanged(int count); void seriesChanged(QSurface3DSeries *series); protected: diff --git a/src/datavisualization/engine/q3dcamera.h b/src/datavisualization/engine/q3dcamera.h index 36764f14..6a9d8a0d 100644 --- a/src/datavisualization/engine/q3dcamera.h +++ b/src/datavisualization/engine/q3dcamera.h @@ -42,8 +42,8 @@ class QT_DATAVISUALIZATION_EXPORT Q3DCamera : public Q3DObject Q_PROPERTY(QMatrix4x4 viewMatrix READ viewMatrix WRITE setViewMatrix NOTIFY viewMatrixChanged) Q_PROPERTY(QtDataVisualization::QDataVis::CameraPreset cameraPreset READ cameraPreset WRITE setCameraPreset NOTIFY cameraPresetChanged) Q_PROPERTY(bool viewMatrixAutoUpdateEnabled READ isViewMatrixAutoUpdateEnabled WRITE setViewMatrixAutoUpdateEnabled NOTIFY viewMatrixAutoUpdateChanged) - Q_PROPERTY(bool wrapXRotation READ wrapXRotation WRITE setWrapXRotation NOTIFY wrapXRotationChanged ) - Q_PROPERTY(bool wrapYRotation READ wrapYRotation WRITE setWrapYRotation NOTIFY wrapYRotationChanged ) + Q_PROPERTY(bool wrapXRotation READ wrapXRotation WRITE setWrapXRotation NOTIFY wrapXRotationChanged) + Q_PROPERTY(bool wrapYRotation READ wrapYRotation WRITE setWrapYRotation NOTIFY wrapYRotationChanged) Q_ENUMS(QtDataVisualization::QDataVis::CameraPreset) public: diff --git a/src/datavisualizationqml2/colorgradient.cpp b/src/datavisualizationqml2/colorgradient.cpp index 43efbd1c..e4c16ebe 100644 --- a/src/datavisualizationqml2/colorgradient.cpp +++ b/src/datavisualizationqml2/colorgradient.cpp @@ -34,6 +34,7 @@ void ColorGradientStop::setPosition(qreal position) { m_position = position; updateGradient(); + emit positionChanged(position); } QColor ColorGradientStop::color() const @@ -45,6 +46,7 @@ void ColorGradientStop::setColor(const QColor &color) { m_color = color; updateGradient(); + emit colorChanged(color); } void ColorGradientStop::updateGradient() diff --git a/src/datavisualizationqml2/colorgradient_p.h b/src/datavisualizationqml2/colorgradient_p.h index d1cc0543..21098142 100644 --- a/src/datavisualizationqml2/colorgradient_p.h +++ b/src/datavisualizationqml2/colorgradient_p.h @@ -39,8 +39,8 @@ class ColorGradientStop : public QObject { Q_OBJECT - Q_PROPERTY(qreal position READ position WRITE setPosition) - Q_PROPERTY(QColor color READ color WRITE setColor) + Q_PROPERTY(qreal position READ position WRITE setPosition NOTIFY positionChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) public: ColorGradientStop(QObject *parent = 0); @@ -51,6 +51,10 @@ public: QColor color() const; void setColor(const QColor &color); +signals: + void positionChanged(qreal position); + void colorChanged(QColor color); + private: void updateGradient(); diff --git a/src/datavisualizationqml2/declarativebars.cpp b/src/datavisualizationqml2/declarativebars.cpp index 4c7bccd7..a72e0399 100644 --- a/src/datavisualizationqml2/declarativebars.cpp +++ b/src/datavisualizationqml2/declarativebars.cpp @@ -37,6 +37,14 @@ DeclarativeBars::DeclarativeBars(QQuickItem *parent) // Create the shared component on the main GUI thread. m_barsController = new Bars3DController(boundingRect().toRect()); AbstractDeclarative::setSharedController(m_barsController); + + // TODO: Uncomment when doing QTRD-2669 +// connect(m_barsController, &Bars3DController::rowAxisChanged, +// this, &DeclarativeBars::rowAxisChanged); +// connect(m_barsController, &Bars3DController::valueAxisChanged, +// this, &DeclarativeBars::valueAxisChanged); +// connect(m_barsController, &Bars3DController::columnAxisChanged, +// this, &DeclarativeBars::columnAxisChanged); } DeclarativeBars::~DeclarativeBars() diff --git a/src/datavisualizationqml2/declarativebars_p.h b/src/datavisualizationqml2/declarativebars_p.h index 4bfe3755..6f93e2d1 100644 --- a/src/datavisualizationqml2/declarativebars_p.h +++ b/src/datavisualizationqml2/declarativebars_p.h @@ -48,9 +48,9 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE class DeclarativeBars : public AbstractDeclarative { Q_OBJECT - Q_PROPERTY(Q3DCategoryAxis *rowAxis READ rowAxis WRITE setRowAxis) - Q_PROPERTY(Q3DValueAxis *valueAxis READ valueAxis WRITE setValueAxis) - Q_PROPERTY(Q3DCategoryAxis *columnAxis READ columnAxis WRITE setColumnAxis) + Q_PROPERTY(Q3DCategoryAxis *rowAxis READ rowAxis WRITE setRowAxis NOTIFY rowAxisChanged) + Q_PROPERTY(Q3DValueAxis *valueAxis READ valueAxis WRITE setValueAxis NOTIFY valueAxisChanged) + Q_PROPERTY(Q3DCategoryAxis *columnAxis READ columnAxis WRITE setColumnAxis NOTIFY columnAxisChanged) Q_PROPERTY(float barThickness READ barThickness WRITE setBarThickness NOTIFY barThicknessChanged) Q_PROPERTY(QSizeF barSpacing READ barSpacing WRITE setBarSpacing NOTIFY barSpacingChanged) Q_PROPERTY(bool barSpacingRelative READ isBarSpacingRelative WRITE setBarSpacingRelative NOTIFY barSpacingRelativeChanged) @@ -88,6 +88,9 @@ public: Q_INVOKABLE void removeSeries(QBar3DSeries *series); signals: + void rowAxisChanged(Q3DCategoryAxis *axis); + void valueAxisChanged(Q3DValueAxis *axis); + void columnAxisChanged(Q3DCategoryAxis *axis); void barThicknessChanged(float thicknessRatio); void barSpacingChanged(QSizeF spacing); void barSpacingRelativeChanged(bool relative); diff --git a/src/datavisualizationqml2/declarativescatter.cpp b/src/datavisualizationqml2/declarativescatter.cpp index 40ef2926..483bb467 100644 --- a/src/datavisualizationqml2/declarativescatter.cpp +++ b/src/datavisualizationqml2/declarativescatter.cpp @@ -36,6 +36,14 @@ DeclarativeScatter::DeclarativeScatter(QQuickItem *parent) // Create the shared component on the main GUI thread. m_scatterController = new Scatter3DController(boundingRect().toRect()); setSharedController(m_scatterController); + + // TODO: Uncomment when doing QTRD-2669 +// connect(m_scatterController, &Scatter3DController::axisXChanged, +// this, &DeclarativeBars::axisXChanged); +// connect(m_scatterController, &Scatter3DController::axisYChanged, +// this, &DeclarativeBars::axisYChanged); +// connect(m_scatterController, &Scatter3DController::axisZChanged, +// this, &DeclarativeBars::axisZChanged); } DeclarativeScatter::~DeclarativeScatter() diff --git a/src/datavisualizationqml2/declarativescatter_p.h b/src/datavisualizationqml2/declarativescatter_p.h index 8445b3d6..b9f5a3b7 100644 --- a/src/datavisualizationqml2/declarativescatter_p.h +++ b/src/datavisualizationqml2/declarativescatter_p.h @@ -46,9 +46,9 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE class DeclarativeScatter : public AbstractDeclarative { Q_OBJECT - Q_PROPERTY(Q3DValueAxis *axisX READ axisX WRITE setAxisX) - Q_PROPERTY(Q3DValueAxis *axisY READ axisY WRITE setAxisY) - Q_PROPERTY(Q3DValueAxis *axisZ READ axisZ WRITE setAxisZ) + Q_PROPERTY(Q3DValueAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) + Q_PROPERTY(Q3DValueAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) + Q_PROPERTY(Q3DValueAxis *axisZ READ axisZ WRITE setAxisZ NOTIFY axisZChanged) Q_PROPERTY(QQmlListProperty seriesList READ seriesList) Q_CLASSINFO("DefaultProperty", "seriesList") @@ -72,7 +72,9 @@ public: Q_INVOKABLE void removeSeries(QScatter3DSeries *series); signals: - void meshFileNameChanged(QString filename); + void axisXChanged(Q3DValueAxis *axis); + void axisYChanged(Q3DValueAxis *axis); + void axisZChanged(Q3DValueAxis *axis); protected: Scatter3DController *m_scatterController; diff --git a/src/datavisualizationqml2/declarativesurface.cpp b/src/datavisualizationqml2/declarativesurface.cpp index a450645f..b0adeb21 100644 --- a/src/datavisualizationqml2/declarativesurface.cpp +++ b/src/datavisualizationqml2/declarativesurface.cpp @@ -38,6 +38,14 @@ DeclarativeSurface::DeclarativeSurface(QQuickItem *parent) // Create the shared component on the main GUI thread. m_surfaceController = new Surface3DController(boundingRect().toRect()); setSharedController(m_surfaceController); + + // TODO: Uncomment when doing QTRD-2669 +// connect(m_surfaceController, &Surface3DController::axisXChanged, +// this, &DeclarativeBars::axisXChanged); +// connect(m_surfaceController, &Surface3DController::axisYChanged, +// this, &DeclarativeBars::axisYChanged); +// connect(m_surfaceController, &Surface3DController::axisZChanged, +// this, &DeclarativeBars::axisZChanged); } DeclarativeSurface::~DeclarativeSurface() diff --git a/src/datavisualizationqml2/declarativesurface_p.h b/src/datavisualizationqml2/declarativesurface_p.h index 4c7377be..70963c4d 100644 --- a/src/datavisualizationqml2/declarativesurface_p.h +++ b/src/datavisualizationqml2/declarativesurface_p.h @@ -48,9 +48,9 @@ QT_DATAVISUALIZATION_BEGIN_NAMESPACE class DeclarativeSurface : public AbstractDeclarative { Q_OBJECT - Q_PROPERTY(Q3DValueAxis *axisX READ axisX WRITE setAxisX) - Q_PROPERTY(Q3DValueAxis *axisY READ axisY WRITE setAxisY) - Q_PROPERTY(Q3DValueAxis *axisZ READ axisZ WRITE setAxisZ) + Q_PROPERTY(Q3DValueAxis *axisX READ axisX WRITE setAxisX NOTIFY axisXChanged) + Q_PROPERTY(Q3DValueAxis *axisY READ axisY WRITE setAxisY NOTIFY axisYChanged) + Q_PROPERTY(Q3DValueAxis *axisZ READ axisZ WRITE setAxisZ NOTIFY axisZChanged) Q_PROPERTY(ColorGradient *gradient READ gradient WRITE setGradient) Q_PROPERTY(QQmlListProperty seriesList READ seriesList) Q_CLASSINFO("DefaultProperty", "seriesList") @@ -77,6 +77,11 @@ public: Q_INVOKABLE void addSeries(QSurface3DSeries *series); Q_INVOKABLE void removeSeries(QSurface3DSeries *series); +signals: + void axisXChanged(Q3DValueAxis *axis); + void axisYChanged(Q3DValueAxis *axis); + void axisZChanged(Q3DValueAxis *axis); + protected: void handleGradientUpdate(); -- cgit v1.2.3