Files
Upsilon/apps/statistics/histogram_parameter_controller.cpp
Émilie Feral 2e16365100 [escher] Reorganize all cells'name and factorize their layouts
Change-Id: I69900ee98ff6a6868f96d70a0e335a589ef16c3f
2017-02-20 10:54:02 +01:00

59 lines
1.5 KiB
C++

#include "histogram_parameter_controller.h"
#include "app.h"
#include <assert.h>
using namespace Shared;
namespace Statistics {
HistogramParameterController::HistogramParameterController(Responder * parentResponder, Store * store) :
FloatParameterController(parentResponder),
m_binWidthCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Largeur des rectanges : ")),
m_minValueCell(PointerTableCellWithEditableText(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Debut de la serie : ")),
m_store(store)
{
}
const char * HistogramParameterController::title() const {
return "Histogramme";
}
float HistogramParameterController::parameterAtIndex(int index) {
assert(index >= 0 && index < 2);
if (index == 0) {
return m_store->barWidth();
}
return m_store->firstDrawnBarAbscissa();
}
void HistogramParameterController::setParameterAtIndex(int parameterIndex, float f) {
assert(parameterIndex >= 0 && parameterIndex < 2);
if (parameterIndex == 0) {
if (f <= 0.0f || isnan(f) || isinf(f)) {
app()->displayWarning("Valeur interdite");
return;
}
m_store->setBarWidth(f);
} else {
m_store->setFirstDrawnBarAbscissa(f);
}
}
int HistogramParameterController::numberOfRows() {
return 2;
};
HighlightCell * HistogramParameterController::reusableCell(int index) {
assert(index >= 0 && index < 2);
if (index == 0) {
return &m_binWidthCell;
}
return &m_minValueCell;
}
int HistogramParameterController::reusableCellCount() {
return 2;
}
}