diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-08-28 14:55:50 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2013-08-29 08:24:43 +0300 |
commit | 89007c36f04fb965167501a0d473451976548da3 (patch) | |
tree | 7289354f1ed9b63ec14d78cd6664dd0d0bbba8af /src/datavis3d/engine/q3dsurface.cpp | |
parent | 5bbd3b72540fd24ecb4538627e01bffe3d03acc6 (diff) |
Make axes ownership more useful
Chart can now own multiple axes while showing only one.
Default axes are no longer modifiable by users.
Task-number: QTRD-2212
Change-Id: I028f0d7539dbbf6e3474680290c7ec6bba5a4223
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavis3d/engine/q3dsurface.cpp')
-rw-r--r-- | src/datavis3d/engine/q3dsurface.cpp | 97 |
1 files changed, 82 insertions, 15 deletions
diff --git a/src/datavis3d/engine/q3dsurface.cpp b/src/datavis3d/engine/q3dsurface.cpp index d4b5f2f1..2201053d 100644 --- a/src/datavis3d/engine/q3dsurface.cpp +++ b/src/datavis3d/engine/q3dsurface.cpp @@ -154,42 +154,109 @@ void Q3DSurface::setSegmentCount(int segmentCount, qreal step, qreal minimum) d_ptr->m_shared->setSegmentCount(GLint(segmentCount), GLfloat(step), GLfloat(minimum)); } -void Q3DSurface::setValueAxisX(QValueAxis *axis) +/*! + * Sets a user-defined X-axis. Implicitly calls addAxis() to transfer ownership + * of the \a axis to this graph. + * + * If the \a axis is null, or if user doesn't explicitly set value axis at all, a temporary + * default axis with no labels and automatic range adjusting is used. + * + * \sa addAxis(), releaseAxis() + */ +void Q3DSurface::setAxisX(QValueAxis *axis) { - Q_ASSERT(axis); - - return d_ptr->m_shared->setAxisX(axis); + d_ptr->m_shared->setAxisX(axis); } -QValueAxis *Q3DSurface::valueAxisX() +/*! + * \return used X-axis. Returns null pointer if default axis is in use. + */ +QValueAxis *Q3DSurface::axisX() const { return static_cast<QValueAxis *>(d_ptr->m_shared->axisX()); } -void Q3DSurface::setValueAxisY(QValueAxis *axis) +/*! + * Sets a user-defined Y-axis. Implicitly calls addAxis() to transfer ownership + * of the \a axis to this graph. + * + * If the \a axis is null, or if user doesn't explicitly set value axis at all, a temporary + * default axis with no labels and automatic range adjusting is used. + * + * \sa addAxis(), releaseAxis() + */ +void Q3DSurface::setAxisY(QValueAxis *axis) { - Q_ASSERT(axis); - - return d_ptr->m_shared->setAxisY(axis); + d_ptr->m_shared->setAxisY(axis); } -QValueAxis *Q3DSurface::valueAxisY() +/*! + * \return used Y-axis. Returns null pointer if default axis is in use. + */ +QValueAxis *Q3DSurface::axisY() const { return static_cast<QValueAxis *>(d_ptr->m_shared->axisY()); } -void Q3DSurface::setValueAxisZ(QValueAxis *axis) +/*! + * Sets a user-defined Z-axis. Implicitly calls addAxis() to transfer ownership + * of the \a axis to this graph. + * + * If the \a axis is null, or if user doesn't explicitly set value axis at all, a temporary + * default axis with no labels and automatic range adjusting is used. + * + * \sa addAxis(), releaseAxis() + */ +void Q3DSurface::setAxisZ(QValueAxis *axis) { - Q_ASSERT(axis); - - return d_ptr->m_shared->setAxisZ(axis); + d_ptr->m_shared->setAxisZ(axis); } -QValueAxis *Q3DSurface::valueAxisZ() +/*! + * \return used Z-axis. Returns null pointer if default axis is in use. + */ +QValueAxis *Q3DSurface::axisZ() const { return static_cast<QValueAxis *>(d_ptr->m_shared->axisZ()); } +/*! + * Adds \a axis to the graph. The axes added via addAxis are not yet taken to use, + * addAxis is simply used to give the ownership of the \a axis to the graph. + * The \a axis must not be null or added to another graph. + * + * \sa releaseAxis(), setAxisX(), setAxisY(), setAxisZ() + */ +void Q3DSurface::addAxis(QValueAxis *axis) +{ + d_ptr->m_shared->addAxis(axis); +} + +/*! + * Releases the ownership of the \a axis back to the caller, if it is added to this graph. + * + * \sa addAxis(), setAxisX(), setAxisY(), setAxisZ() + */ +void Q3DSurface::releaseAxis(QValueAxis *axis) +{ + d_ptr->m_shared->releaseAxis(axis); +} + +/*! + * \return list of all added axes. + * + * \sa addAxis() + */ +QList<QValueAxis *> Q3DSurface::axes() const +{ + QList<QAbstractAxis *> abstractAxes = d_ptr->m_shared->axes(); + QList<QValueAxis *> retList; + foreach (QAbstractAxis *axis, abstractAxes) + retList.append(static_cast<QValueAxis *>(axis)); + + return retList; +} + void Q3DSurface::setGradientColorAt(qreal pos, const QColor &color) { d_ptr->m_shared->setGradientColorAt(pos, color); |