summaryrefslogtreecommitdiffstats
path: root/src/datavis3d/engine/bars3dcontroller.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-08-07 14:52:28 +0300
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-08-08 08:21:37 +0300
commitebee290095f9a32dbcf5956e9fed50d2610cbfe1 (patch)
treec9260232aa82517c12bbcd94ef3d004b29860959 /src/datavis3d/engine/bars3dcontroller.cpp
parentb3e10fcc8403bc1a0d9d4c107b52eb10af0ecffa (diff)
Tickcount and both automatic and explicit range setting via axes
- Tick count moved to QValueAxis. - QValueAxis adjusts range to data by default on barcharts. - QValueaxis explicit range setting now works for barchart. Change-Id: I2c0afcab34b74a848144fda41d9135dcdb510354 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'src/datavis3d/engine/bars3dcontroller.cpp')
-rw-r--r--src/datavis3d/engine/bars3dcontroller.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/src/datavis3d/engine/bars3dcontroller.cpp b/src/datavis3d/engine/bars3dcontroller.cpp
index c1dc09ef..6188d203 100644
--- a/src/datavis3d/engine/bars3dcontroller.cpp
+++ b/src/datavis3d/engine/bars3dcontroller.cpp
@@ -44,7 +44,7 @@
#include "camerahelper_p.h"
#include "utils_p.h"
#include "qabstractaxis_p.h"
-#include "qvalueaxis.h"
+#include "qvalueaxis_p.h"
#include "qcategoryaxis.h"
#include "qbardataproxy_p.h"
@@ -71,9 +71,6 @@ Bars3dController::Bars3dController(QRect boundRect)
m_objFile(QStringLiteral(":/defaultMeshes/bar")),
m_isGridEnabled(true),
m_isBackgroundEnabled(true),
- m_tickCount(0),
- m_tickStep(0),
- m_tickMinimum(0.0f),
m_renderer(0),
m_data(0),
m_valuesDirty(false)
@@ -284,7 +281,7 @@ QBarDataProxy *Bars3dController::dataProxy()
void Bars3dController::handleArrayReset()
{
setSlicingActive(false);
- handleLimitChange();
+ adjustValueAxisRange();
m_valuesDirty = true;
}
@@ -295,7 +292,7 @@ void Bars3dController::handleRowsAdded(int startIndex, int count)
// TODO check if affects data window
// TODO should update slice instead of deactivating?
setSlicingActive(false);
- handleLimitChange();
+ adjustValueAxisRange();
m_valuesDirty = true;
}
@@ -306,7 +303,7 @@ void Bars3dController::handleRowsChanged(int startIndex, int count)
// TODO check if affects data window
// TODO should update slice instead of deactivating?
setSlicingActive(false);
- handleLimitChange();
+ adjustValueAxisRange();
m_valuesDirty = true;
}
@@ -317,7 +314,7 @@ void Bars3dController::handleRowsRemoved(int startIndex, int count)
// TODO check if affects data window
// TODO should update slice instead of deactivating?
setSlicingActive(false);
- handleLimitChange();
+ adjustValueAxisRange();
m_valuesDirty = true;
}
@@ -328,10 +325,16 @@ void Bars3dController::handleRowsInserted(int startIndex, int count)
// TODO check if affects data window
// TODO should update slice instead of deactivating?
setSlicingActive(false);
- handleLimitChange();
+ adjustValueAxisRange();
m_valuesDirty = true;
}
+void Bars3dController::handleAxisAutoAdjustRangeChanged(bool autoAdjust)
+{
+ Q_UNUSED(autoAdjust)
+ adjustValueAxisRange();
+}
+
void Bars3dController::setBarSpecs(QSizeF thickness, QSizeF spacing, bool relative)
{
m_barThickness = thickness;
@@ -416,6 +419,8 @@ void Bars3dController::setupSampleSpace(int rowCount, int columnCount)
m_rowCount = rowCount;
m_columnCount = columnCount;
+ adjustValueAxisRange();
+
emit sampleSpaceChanged(rowCount, columnCount);
}
@@ -460,14 +465,6 @@ bool Bars3dController::backgroundEnabled()
return m_isBackgroundEnabled;
}
-void Bars3dController::setTickCount(GLint tickCount, GLfloat step, GLfloat minimum)
-{
- m_tickCount = tickCount;
- m_tickStep = step;
- m_tickMinimum = minimum;
- emit tickCountChanged(m_tickCount, m_tickStep, m_tickMinimum);
-}
-
int Bars3dController::columnCount()
{
return m_columnCount;
@@ -478,12 +475,20 @@ int Bars3dController::rowCount()
return m_rowCount;
}
-void Bars3dController::handleLimitChange()
+void Bars3dController::adjustValueAxisRange()
{
- // Get the limits for data window
- QPair<GLfloat, GLfloat> limits = m_data->dptr()->limitValues(0, m_rowCount, 0, m_columnCount);
-
- emit limitsChanged(limits);
+ QValueAxis *valueAxis = static_cast<QValueAxis *>(m_axisY);
+ if (valueAxis && valueAxis->isAutoAdjustRange()) {
+ QPair<GLfloat, GLfloat> limits = m_data->dptr()->limitValues(0, m_rowCount, 0, m_columnCount);
+ if (limits.first < 0) {
+ // TODO: Currently we only support symmetric y-axis for bar chart if there are negative values
+ qreal maxAbs = qMax(qFabs(limits.first), qFabs(limits.second));
+ // Call private implementation to avoid unsetting auto adjust flag
+ valueAxis->dptr()->setRange(-maxAbs, maxAbs);
+ } else {
+ valueAxis->dptr()->setRange(0.0, limits.second);
+ }
+ }
}
QT_DATAVIS3D_END_NAMESPACE