[apps/statistics] Forbid to set histogram paramaters which would draw

too
many bars

Change-Id: I94c79a7e91ff02510eb5b00039a27ccdfc181d91
This commit is contained in:
Émilie Feral
2017-04-27 13:43:38 +02:00
parent 61ed9a128f
commit 9ebe2d5d62
2 changed files with 8 additions and 1 deletions

View File

@@ -50,12 +50,18 @@ float HistogramParameterController::parameterAtIndex(int index) {
bool HistogramParameterController::setParameterAtIndex(int parameterIndex, float f) {
assert(parameterIndex >= 0 && parameterIndex < k_numberOfCells);
if (parameterIndex == 0) {
if (f <= 0.0f) {
float newNumberOfBars = ceilf((m_store->maxValue() - m_store->firstDrawnBarAbscissa())/f);
if (f <= 0.0f || newNumberOfBars > Store::k_maxNumberOfBars) {
app()->displayWarning(I18n::Message::ForbiddenValue);
return false;
}
m_store->setBarWidth(f);
} else {
float newNumberOfBars = ceilf((m_store->maxValue() - f)/m_store->barWidth());
if (newNumberOfBars > Store::k_maxNumberOfBars) {
app()->displayWarning(I18n::Message::ForbiddenValue);
return false;
}
m_store->setFirstDrawnBarAbscissa(f);
}
return true;