diff options
Diffstat (limited to 'src/datavisualization/axis/q3dabstractaxis.cpp')
-rw-r--r-- | src/datavisualization/axis/q3dabstractaxis.cpp | 85 |
1 files changed, 58 insertions, 27 deletions
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. */ /*! @@ -124,27 +125,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 * * Defines the orientation of the axis, one of \c Q3DAbstractAxis::AxisOrientation. @@ -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); } } |