diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-04-02 12:16:05 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-04-03 09:27:54 +0300 |
commit | aaf51bfad10e0eac7a8ee64e36aab5f0c1119468 (patch) | |
tree | bd20d2ec028bf1acfe4dd418b3a639b17f75b591 /src/datavisualization/engine/scatter3drenderer.cpp | |
parent | e076fa05488bb9f58393f0e636c97d07b6fb446d (diff) |
Enable querying selection label via API
Also enable suppressing drawing the label on graph.
Selection label formatting was consequently moved from renderers
to series.
Task-number: QTRD-2896
Change-Id: Ia6a1a40298d8db0f54349de3eb27fb0b683dd302
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavisualization/engine/scatter3drenderer.cpp')
-rw-r--r-- | src/datavisualization/engine/scatter3drenderer.cpp | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/src/datavisualization/engine/scatter3drenderer.cpp b/src/datavisualization/engine/scatter3drenderer.cpp index a6633183..43c78137 100644 --- a/src/datavisualization/engine/scatter3drenderer.cpp +++ b/src/datavisualization/engine/scatter3drenderer.cpp @@ -171,18 +171,30 @@ void Scatter3DRenderer::updateSeries(const QList<QAbstract3DSeries *> &seriesLis if (m_cachedItemSize.size() != seriesCount) m_cachedItemSize.resize(seriesCount); + bool noSelection = true; for (int series = 0; series < seriesCount; series++) { - itemSize = static_cast<QScatter3DSeries *>(m_visibleSeriesList.at(series).series())->itemSize(); + QScatter3DSeries *scatterSeries = + static_cast<QScatter3DSeries *>(m_visibleSeriesList.at(series).series()); + itemSize = scatterSeries->itemSize(); if (maxItemSize < itemSize) maxItemSize = itemSize; if (m_cachedItemSize.at(series) != itemSize) m_cachedItemSize[series] = itemSize; + if (noSelection + && scatterSeries->selectedItem() != QScatter3DSeries::invalidSelectionIndex() + && m_selectionLabel != m_visibleSeriesList.at(series).itemLabel()) { + m_selectionLabelDirty = true; + noSelection = false; + } } m_maxItemSize = maxItemSize; if (maxItemSize > defaultMaxSize) m_backgroundMargin = maxItemSize / itemScaler; else m_backgroundMargin = defaultMaxSize; + + if (noSelection && !selectionLabel().isEmpty()) + m_selectionLabelDirty = true; } void Scatter3DRenderer::updateData() @@ -1251,38 +1263,7 @@ void Scatter3DRenderer::drawScene(const GLuint defaultFboHandle) || !labelItem.textureId() || m_selectionLabelDirty) { QString labelText = selectionLabel(); if (labelText.isNull() || m_selectionLabelDirty) { - static const QString xTitleTag(QStringLiteral("@xTitle")); - static const QString yTitleTag(QStringLiteral("@yTitle")); - static const QString zTitleTag(QStringLiteral("@zTitle")); - static const QString xLabelTag(QStringLiteral("@xLabel")); - static const QString yLabelTag(QStringLiteral("@yLabel")); - static const QString zLabelTag(QStringLiteral("@zLabel")); - static const QString seriesNameTag(QStringLiteral("@seriesName")); - - labelText = m_visibleSeriesList[m_selectedItemSeriesIndex].itemLabelFormat(); - - labelText.replace(xTitleTag, m_axisCacheX.title()); - labelText.replace(yTitleTag, m_axisCacheY.title()); - labelText.replace(zTitleTag, m_axisCacheZ.title()); - - if (labelText.contains(xLabelTag)) { - QString valueLabelText = m_axisCacheX.formatter()->stringForValue( - qreal(selectedItem->position().x()), m_axisCacheX.labelFormat()); - labelText.replace(xLabelTag, valueLabelText); - } - if (labelText.contains(yLabelTag)) { - QString valueLabelText = m_axisCacheY.formatter()->stringForValue( - qreal(selectedItem->position().y()), m_axisCacheY.labelFormat()); - labelText.replace(yLabelTag, valueLabelText); - } - if (labelText.contains(zLabelTag)) { - QString valueLabelText = m_axisCacheZ.formatter()->stringForValue( - qreal(selectedItem->position().z()), m_axisCacheZ.labelFormat()); - labelText.replace(zLabelTag, valueLabelText); - } - labelText.replace(seriesNameTag, - m_visibleSeriesList[m_selectedItemSeriesIndex].name()); - + labelText = m_visibleSeriesList[m_selectedItemSeriesIndex].itemLabel(); setSelectionLabel(labelText); m_selectionLabelDirty = false; } |