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/q3dbars.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/q3dbars.cpp')
-rw-r--r-- | src/datavis3d/engine/q3dbars.cpp | 86 |
1 files changed, 76 insertions, 10 deletions
diff --git a/src/datavis3d/engine/q3dbars.cpp b/src/datavis3d/engine/q3dbars.cpp index cf196ac8..5c2cf0c8 100644 --- a/src/datavis3d/engine/q3dbars.cpp +++ b/src/datavis3d/engine/q3dbars.cpp @@ -20,6 +20,7 @@ #include "q3dbars_p.h" #include "bars3dcontroller_p.h" #include "qvalueaxis.h" +#include "qcategoryaxis.h" #include <QMouseEvent> @@ -394,7 +395,7 @@ QPoint Q3DBars::selectedBarPos() const */ void Q3DBars::setShadowQuality(QDataVis::ShadowQuality quality) { - return d_ptr->m_shared->setShadowQuality(quality); + d_ptr->m_shared->setShadowQuality(quality); } QDataVis::ShadowQuality Q3DBars::shadowQuality() const @@ -403,33 +404,65 @@ QDataVis::ShadowQuality Q3DBars::shadowQuality() const } /*! - * \return category axis for rows. + * Sets a user-defined row \a 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 row axis at all, a temporary + * default axis with no labels is used. + * + * \sa addAxis(), releaseAxis() + */ +void Q3DBars::setRowAxis(QCategoryAxis *axis) +{ + d_ptr->m_shared->setAxisX(axis); +} + +/*! + * \return category axis for rows. Returns null pointer if default axis is in use. */ QCategoryAxis *Q3DBars::rowAxis() const { - return reinterpret_cast<QCategoryAxis *>(d_ptr->m_shared->axisX()); + return static_cast<QCategoryAxis *>(d_ptr->m_shared->axisX()); +} + +/*! + * Sets a user-defined column \a 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 column axis at all, a temporary + * default axis with no labels is used. + * + * \sa addAxis(), releaseAxis() + */ +void Q3DBars::setColumnAxis(QCategoryAxis *axis) +{ + d_ptr->m_shared->setAxisZ(axis); } /*! - * \return category axis for columns. + * \return category axis for columns. Returns null pointer if default axis is in use. */ QCategoryAxis *Q3DBars::columnAxis() const { - return reinterpret_cast<QCategoryAxis *>(d_ptr->m_shared->axisZ()); + return static_cast<QCategoryAxis *>(d_ptr->m_shared->axisZ()); } /*! - * Sets a user-defined value \a axis (Y-axis). Ownership of the axis is transferred to Q3DBars. + * Sets a user-defined value \a axis (the 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 Q3DBars::setValueAxis(QValueAxis *axis) { - Q_ASSERT(axis); - - return d_ptr->m_shared->setAxisY(axis); + d_ptr->m_shared->setAxisY(axis); } /*! - * \return used value axis (Y-axis). + * \return used value axis (Y-axis). Returns null pointer if default axis is in use. */ QValueAxis *Q3DBars::valueAxis() const { @@ -437,6 +470,39 @@ QValueAxis *Q3DBars::valueAxis() const } /*! + * 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(), setValueAxis(), setRowAxis(), setColumnAxis() + */ +void Q3DBars::addAxis(QAbstractAxis *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. + * If the released \a axis is in use, a temporary default axis will be set active. + * + * \sa addAxis(), setValueAxis(), setRowAxis(), setColumnAxis() + */ +void Q3DBars::releaseAxis(QAbstractAxis *axis) +{ + d_ptr->m_shared->releaseAxis(axis); +} + +/*! + * \return list of all added axes. + * + * \sa addAxis() + */ +QList<QAbstractAxis *> Q3DBars::axes() const +{ + return d_ptr->m_shared->axes(); +} + +/*! * Sets a user-defined data \a proxy. Ownership of the proxy is transferred to Q3DBars. */ void Q3DBars::setDataProxy(QBarDataProxy *proxy) |