diff options
Diffstat (limited to 'src/datavisualization')
-rw-r--r-- | src/datavisualization/data/qbar3dseries.cpp | 43 | ||||
-rw-r--r-- | src/datavisualization/data/qbar3dseries.h | 5 | ||||
-rw-r--r-- | src/datavisualization/data/qbar3dseries_p.h | 4 | ||||
-rw-r--r-- | src/datavisualization/engine/bars3dcontroller.cpp | 5 | ||||
-rw-r--r-- | src/datavisualization/engine/bars3dcontroller_p.h | 1 | ||||
-rw-r--r-- | src/datavisualization/engine/bars3drenderer.cpp | 13 |
6 files changed, 68 insertions, 3 deletions
diff --git a/src/datavisualization/data/qbar3dseries.cpp b/src/datavisualization/data/qbar3dseries.cpp index afc3b3ba..1cd4c754 100644 --- a/src/datavisualization/data/qbar3dseries.cpp +++ b/src/datavisualization/data/qbar3dseries.cpp @@ -147,6 +147,18 @@ QT_BEGIN_NAMESPACE */ /*! + * \qmlproperty list<ThemeColor> Bar3DSeries::rowColors + * \since 6.3 + * This property can be used to draw the rows of the series in different colors. + * The \l{Theme3D::colorStyle}{Theme3D.colorStyle} must be set to + * \c ColorStyleUniform to use this property. + * \note If the property is set and the theme is changed, + * the rowColors list is not cleared automatically. + * + * \sa Q3DTheme::ColorStyleUniform + */ + +/*! * Constructsa bar 3D series with the parent \a parent. */ QBar3DSeries::QBar3DSeries(QObject *parent) : @@ -282,6 +294,27 @@ float QBar3DSeries::meshAngle() const } /*! + * \property QBar3DSeries::rowColors + * \since 6.3 + * + * \brief The list of row colors in the series. + * + * This property can be used to color + * the rows of the series in different colors. + * The Q3DTheme::ColorStyle must be set to + * Q3DTheme::ColorStyleUniform to use this property. + * + * \sa Q3DTheme::ColorStyleUniform + */ +void QBar3DSeries::setRowColors(const QList<QColor> &colors) +{ + dptr()->setRowColors(colors); +} +QList<QColor> QBar3DSeries::rowColors() const +{ + return dptrc()->m_rowColors; +} +/*! * \internal */ QBar3DSeriesPrivate *QBar3DSeries::dptr() @@ -355,6 +388,8 @@ void QBar3DSeriesPrivate::connectControllerAndProxy(Abstract3DController *newCon &Bars3DController::handleDataColumnLabelsChanged); QObject::connect(qptr(), &QBar3DSeries::dataProxyChanged, controller, &Bars3DController::handleArrayReset); + QObject::connect(qptr(), &QBar3DSeries::rowColorsChanged, controller, + &Bars3DController::handleRowColorsChanged); } } @@ -432,4 +467,12 @@ void QBar3DSeriesPrivate::connectSignals() &QBar3DSeriesPrivate::handleMeshRotationChanged); } +void QBar3DSeriesPrivate::setRowColors(const QList<QColor> &colors) +{ + if (m_rowColors != colors) { + m_rowColors = colors; + emit qptr()->rowColorsChanged(m_rowColors); + } +} + QT_END_NAMESPACE diff --git a/src/datavisualization/data/qbar3dseries.h b/src/datavisualization/data/qbar3dseries.h index 99fbad77..a174f0f5 100644 --- a/src/datavisualization/data/qbar3dseries.h +++ b/src/datavisualization/data/qbar3dseries.h @@ -44,6 +44,7 @@ class Q_DATAVISUALIZATION_EXPORT QBar3DSeries : public QAbstract3DSeries Q_PROPERTY(QBarDataProxy *dataProxy READ dataProxy WRITE setDataProxy NOTIFY dataProxyChanged) Q_PROPERTY(QPoint selectedBar READ selectedBar WRITE setSelectedBar NOTIFY selectedBarChanged) Q_PROPERTY(float meshAngle READ meshAngle WRITE setMeshAngle NOTIFY meshAngleChanged) + Q_PROPERTY(QList<QColor> rowColors READ rowColors WRITE setRowColors NOTIFY rowColorsChanged REVISION(6, 3)) public: explicit QBar3DSeries(QObject *parent = nullptr); @@ -60,10 +61,14 @@ public: void setMeshAngle(float angle); float meshAngle() const; + QList<QColor> rowColors() const; + void setRowColors(const QList<QColor> &colors); + Q_SIGNALS: void dataProxyChanged(QBarDataProxy *proxy); void selectedBarChanged(const QPoint &position); void meshAngleChanged(float angle); + Q_REVISION(6, 3) void rowColorsChanged(const QList<QColor> &rowcolors); protected: QBar3DSeriesPrivate *dptr(); diff --git a/src/datavisualization/data/qbar3dseries_p.h b/src/datavisualization/data/qbar3dseries_p.h index 0f5bb43a..cd94b7f4 100644 --- a/src/datavisualization/data/qbar3dseries_p.h +++ b/src/datavisualization/data/qbar3dseries_p.h @@ -62,11 +62,15 @@ public: void connectSignals(); + void setRowColors(const QList<QColor> &colors); + private: QBar3DSeries *qptr(); QPoint m_selectedBar; + QList<QColor> m_rowColors; + private: friend class QBar3DSeries; }; diff --git a/src/datavisualization/engine/bars3dcontroller.cpp b/src/datavisualization/engine/bars3dcontroller.cpp index 74ea1076..b5910c8e 100644 --- a/src/datavisualization/engine/bars3dcontroller.cpp +++ b/src/datavisualization/engine/bars3dcontroller.cpp @@ -328,6 +328,11 @@ void Bars3DController::handleDataColumnLabelsChanged() } } +void Bars3DController::handleRowColorsChanged() +{ + emitNeedRender(); +} + void Bars3DController::handleAxisAutoAdjustRangeChangedInOrientation( QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust) { diff --git a/src/datavisualization/engine/bars3dcontroller_p.h b/src/datavisualization/engine/bars3dcontroller_p.h index 818eea4f..fb028e92 100644 --- a/src/datavisualization/engine/bars3dcontroller_p.h +++ b/src/datavisualization/engine/bars3dcontroller_p.h @@ -165,6 +165,7 @@ public Q_SLOTS: void handleItemChanged(int rowIndex, int columnIndex); void handleDataRowLabelsChanged(); void handleDataColumnLabelsChanged(); + void handleRowColorsChanged(); Q_SIGNALS: void primarySeriesChanged(QBar3DSeries *series); diff --git a/src/datavisualization/engine/bars3drenderer.cpp b/src/datavisualization/engine/bars3drenderer.cpp index 0c51d187..a0c58b45 100644 --- a/src/datavisualization/engine/bars3drenderer.cpp +++ b/src/datavisualization/engine/bars3drenderer.cpp @@ -1628,10 +1628,17 @@ bool Bars3DRenderer::drawBars(BarRenderItem **selectedBar, } case Bars3DController::SelectionNone: { // Current bar is not selected, nor on a row or column - if (colorStyleIsUniform) - barColor = baseColor; - else + if (colorStyleIsUniform) { + QList<QColor> rowColors = cache->series()->rowColors(); + if (rowColors.size() == 0) { + barColor = baseColor; + } else { + int rowColorIndex = row % rowColors.size(); + barColor = Utils::vectorFromColor(rowColors[rowColorIndex]); + } + } else { gradientTexture = cache->baseGradientTexture(); + } break; } } |