diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-05-28 09:23:54 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2014-05-28 11:35:38 +0300 |
commit | bda4432c80fd340a3d75ba077830ed93724fd9f1 (patch) | |
tree | 7d2b8a1438a07ca129f60f525f593f0f1185de4f /tests/surfacetest/graphmodifier.cpp | |
parent | f48233015f5b3694002a456b9db61d3e58541c5c (diff) |
Implement binary search for determining surface sample space
Task-number: QTRD-3066
Change-Id: I3a6d727c528e37e914aa1c3f08ee6d268a2c5230
Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'tests/surfacetest/graphmodifier.cpp')
-rw-r--r-- | tests/surfacetest/graphmodifier.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/surfacetest/graphmodifier.cpp b/tests/surfacetest/graphmodifier.cpp index 13cf9fad..ed86f03c 100644 --- a/tests/surfacetest/graphmodifier.cpp +++ b/tests/surfacetest/graphmodifier.cpp @@ -721,6 +721,62 @@ void GraphModifier::toggleAxisTitleFixed(bool enabled) m_graph->axisZ()->setTitleFixed(enabled); } +void GraphModifier::toggleXAscending(bool enabled) +{ + // Flip data array contents if necessary + foreach (QSurface3DSeries *series, m_graph->seriesList()) { + QSurfaceDataArray *array = const_cast<QSurfaceDataArray *>(series->dataProxy()->array()); + const int rowCount = array->size(); + const int columnCount = array->at(0)->size(); + const bool dataAscending = array->at(0)->at(0).x() < array->at(0)->at(columnCount - 1).x(); + if (dataAscending != enabled) { + // Create new array of equal size + QSurfaceDataArray *newArray = new QSurfaceDataArray; + newArray->reserve(rowCount); + for (int i = 0; i < rowCount; i++) + newArray->append(new QSurfaceDataRow(columnCount)); + + // Flip each row + for (int i = 0; i < rowCount; i++) { + QSurfaceDataRow *oldRow = array->at(i); + QSurfaceDataRow *newRow = newArray->at(i); + for (int j = 0; j < columnCount; j++) + (*newRow)[j] = oldRow->at(columnCount - 1 - j); + } + + series->dataProxy()->resetArray(newArray); + } + } +} + +void GraphModifier::toggleZAscending(bool enabled) +{ + // Flip data array contents if necessary + foreach (QSurface3DSeries *series, m_graph->seriesList()) { + QSurfaceDataArray *array = const_cast<QSurfaceDataArray *>(series->dataProxy()->array()); + const int rowCount = array->size(); + const int columnCount = array->at(0)->size(); + const bool dataAscending = array->at(0)->at(0).z() < array->at(rowCount - 1)->at(0).z(); + if (dataAscending != enabled) { + // Create new array of equal size + QSurfaceDataArray *newArray = new QSurfaceDataArray; + newArray->reserve(rowCount); + for (int i = 0; i < rowCount; i++) + newArray->append(new QSurfaceDataRow(columnCount)); + + // Flip each column + for (int i = 0; i < rowCount; i++) { + QSurfaceDataRow *oldRow = array->at(rowCount - 1 - i); + QSurfaceDataRow *newRow = newArray->at(i); + for (int j = 0; j < columnCount; j++) + (*newRow)[j] = oldRow->at(j); + } + + series->dataProxy()->resetArray(newArray); + } + } +} + void GraphModifier::resetArrayAndSliders(QSurfaceDataArray *array, float minZ, float maxZ, float minX, float maxX) { m_axisMinSliderX->setValue(minX); |