summaryrefslogtreecommitdiffstats
path: root/src/datavisualization
diff options
context:
space:
mode:
authorMika Salmela <mika.salmela@digia.com>2014-02-11 13:55:59 +0200
committerMika Salmela <mika.salmela@digia.com>2014-02-11 14:16:13 +0200
commit64acaf065f8f04b78713196fec4d71993f858053 (patch)
tree7b5fcac6e3580045945f796cd310eda2adae4dcb /src/datavisualization
parent911770952a1e4a70a97d82d8400fa85bd9b0664d (diff)
Multiseries support for surface slice
Task-number: QTRD-2867 Change-Id: I705e3b743ab9d561d93039a60288d71627db8661 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavisualization')
-rw-r--r--src/datavisualization/engine/surface3drenderer.cpp109
-rw-r--r--src/datavisualization/engine/surface3drenderer_p.h1
-rw-r--r--src/datavisualization/utils/surfaceobject.cpp7
-rw-r--r--src/datavisualization/utils/surfaceobject_p.h1
4 files changed, 70 insertions, 48 deletions
diff --git a/src/datavisualization/engine/surface3drenderer.cpp b/src/datavisualization/engine/surface3drenderer.cpp
index f9f4a45a..194509f8 100644
--- a/src/datavisualization/engine/surface3drenderer.cpp
+++ b/src/datavisualization/engine/surface3drenderer.cpp
@@ -395,59 +395,72 @@ void Surface3DRenderer::updateItem(const QVector<Surface3DController::ChangeItem
void Surface3DRenderer::updateSliceDataModel(const QPoint &point)
{
- int column = point.y();
- int row = point.x();
-
- foreach (SurfaceSeriesRenderCache *cache, m_renderCacheList) {
- QSurfaceDataArray &sliceDataArray = cache->sliceDataArray();
- for (int i = 0; i < sliceDataArray.size(); i++)
- delete sliceDataArray.at(i);
- sliceDataArray.clear();
- sliceDataArray.reserve(2);
-
- QSurfaceDataRow *sliceRow;
- QSurfaceDataArray &dataArray = cache->dataArray();
- float adjust = (0.025f * m_heightNormalizer) / 2.0f;
- float stepDown = 2.0f * adjust;
- if (m_cachedSelectionMode.testFlag(QAbstract3DGraph::SelectionRow)) {
- QSurfaceDataRow *src = dataArray.at(row);
- sliceRow = new QSurfaceDataRow(src->size());
- for (int i = 0; i < sliceRow->size(); i++)
- (*sliceRow)[i].setPosition(QVector3D(src->at(i).x(), src->at(i).y() + adjust, -1.0f));
- } else {
- QRect sampleSpace = cache->sampleSpace();
- sliceRow = new QSurfaceDataRow(sampleSpace.height());
- for (int i = 0; i < sampleSpace.height(); i++) {
- (*sliceRow)[i].setPosition(QVector3D(dataArray.at(i)->at(column).z(),
- dataArray.at(i)->at(column).y() + adjust,
- -1.0f));
- }
- }
-
- sliceDataArray << sliceRow;
+ foreach (SurfaceSeriesRenderCache *cache, m_renderCacheList)
+ cache->sliceSurfaceObject()->clear();
- // Make a duplicate, so that we get a little bit depth
- QSurfaceDataRow *duplicateRow = new QSurfaceDataRow(*sliceRow);
- for (int i = 0; i < sliceRow->size(); i++) {
- (*sliceRow)[i].setPosition(QVector3D(sliceRow->at(i).x(),
- sliceRow->at(i).y() - stepDown,
- 1.0f));
+ if (m_cachedSelectionMode.testFlag(QAbstract3DGraph::SelectionMultiSeries)) {
+ foreach (SurfaceSeriesRenderCache *cache, m_renderCacheList)
+ updateSliceObject(cache, point);
+ } else {
+ if (m_selectedSeries) {
+ SurfaceSeriesRenderCache *cache =
+ m_renderCacheList.value(const_cast<QSurface3DSeries *>(m_selectedSeries));
+ if (cache)
+ updateSliceObject(cache, point);
}
+ }
+}
- sliceDataArray << duplicateRow;
+void Surface3DRenderer::updateSliceObject(SurfaceSeriesRenderCache *cache, const QPoint &point)
+{
+ int column = point.y();
+ int row = point.x();
- QRect sliceRect(0, 0, sliceRow->size(), 2);
+ QSurfaceDataArray &sliceDataArray = cache->sliceDataArray();
+ for (int i = 0; i < sliceDataArray.size(); i++)
+ delete sliceDataArray.at(i);
+ sliceDataArray.clear();
+ sliceDataArray.reserve(2);
- if (sliceRow->size() > 0) {
- if (cache->isFlatShadingEnabled()) {
- cache->sliceSurfaceObject()->setUpData(sliceDataArray, sliceRect,
- m_heightNormalizer,
- m_axisCacheY.min(), true);
- } else {
- cache->sliceSurfaceObject()->setUpSmoothData(sliceDataArray, sliceRect,
- m_heightNormalizer,
- m_axisCacheY.min(), true);
- }
+ QSurfaceDataRow *sliceRow;
+ QSurfaceDataArray &dataArray = cache->dataArray();
+ float adjust = (0.025f * m_heightNormalizer) / 2.0f;
+ float stepDown = 2.0f * adjust;
+ if (m_cachedSelectionMode.testFlag(QAbstract3DGraph::SelectionRow)) {
+ QSurfaceDataRow *src = dataArray.at(row);
+ sliceRow = new QSurfaceDataRow(src->size());
+ for (int i = 0; i < sliceRow->size(); i++)
+ (*sliceRow)[i].setPosition(QVector3D(src->at(i).x(), src->at(i).y() + adjust, -1.0f));
+ } else {
+ QRect sampleSpace = cache->sampleSpace();
+ sliceRow = new QSurfaceDataRow(sampleSpace.height());
+ for (int i = 0; i < sampleSpace.height(); i++) {
+ (*sliceRow)[i].setPosition(QVector3D(dataArray.at(i)->at(column).z(),
+ dataArray.at(i)->at(column).y() + adjust,
+ -1.0f));
+ }
+ }
+ sliceDataArray << sliceRow;
+
+ // Make a duplicate, so that we get a little bit depth
+ QSurfaceDataRow *duplicateRow = new QSurfaceDataRow(*sliceRow);
+ for (int i = 0; i < sliceRow->size(); i++) {
+ (*sliceRow)[i].setPosition(QVector3D(sliceRow->at(i).x(),
+ sliceRow->at(i).y() - stepDown,
+ 1.0f));
+ }
+ sliceDataArray << duplicateRow;
+
+ QRect sliceRect(0, 0, sliceRow->size(), 2);
+ if (sliceRow->size() > 0) {
+ if (cache->isFlatShadingEnabled()) {
+ cache->sliceSurfaceObject()->setUpData(sliceDataArray, sliceRect,
+ m_heightNormalizer,
+ m_axisCacheY.min(), true);
+ } else {
+ cache->sliceSurfaceObject()->setUpSmoothData(sliceDataArray, sliceRect,
+ m_heightNormalizer,
+ m_axisCacheY.min(), true);
}
}
}
diff --git a/src/datavisualization/engine/surface3drenderer_p.h b/src/datavisualization/engine/surface3drenderer_p.h
index e8d8bf35..4649fd72 100644
--- a/src/datavisualization/engine/surface3drenderer_p.h
+++ b/src/datavisualization/engine/surface3drenderer_p.h
@@ -131,6 +131,7 @@ private:
void checkFlatSupport(SurfaceSeriesRenderCache *cache);
void updateObjects(SurfaceSeriesRenderCache *cache, bool dimensionChanged);
void updateSliceDataModel(const QPoint &point);
+ void updateSliceObject(SurfaceSeriesRenderCache *cache, const QPoint &point);
void updateShadowQuality(QAbstract3DGraph::ShadowQuality quality);
void updateTextures();
void initShaders(const QString &vertexShader, const QString &fragmentShader);
diff --git a/src/datavisualization/utils/surfaceobject.cpp b/src/datavisualization/utils/surfaceobject.cpp
index cfaab09c..1cb576c4 100644
--- a/src/datavisualization/utils/surfaceobject.cpp
+++ b/src/datavisualization/utils/surfaceobject.cpp
@@ -682,6 +682,13 @@ QVector3D SurfaceObject::vertexAt(int column, int row)
return m_vertices.at(pos);
}
+void SurfaceObject::clear()
+{
+ m_gridIndexCount = 0;
+ m_indexCount = 0;
+ m_surfaceType = Undefined;
+}
+
QVector3D SurfaceObject::normal(const QVector3D &a, const QVector3D &b, const QVector3D &c)
{
QVector3D v1 = b - a;
diff --git a/src/datavisualization/utils/surfaceobject_p.h b/src/datavisualization/utils/surfaceobject_p.h
index f51c2909..ebae1149 100644
--- a/src/datavisualization/utils/surfaceobject_p.h
+++ b/src/datavisualization/utils/surfaceobject_p.h
@@ -70,6 +70,7 @@ public:
GLuint gridElementBuf();
GLuint gridIndexCount();
QVector3D vertexAt(int column, int row);
+ void clear();
private:
QVector3D normal(const QVector3D &a, const QVector3D &b, const QVector3D &c);