Files
Upsilon/apps/statistics/histogram_parameter_controller.cpp
Émilie Feral affda5eae9 [apps] Modular reimplementation of application models (stores and
ranges) and of curve views/curve view controllers.

Change-Id: If4ca9bf1bec024917ef540a3fc7baefa8700f7ba
2017-01-10 13:35:19 +01:00

57 lines
1.5 KiB
C++

#include "histogram_parameter_controller.h"
#include "app.h"
#include <assert.h>
namespace Statistics {
HistogramParameterController::HistogramParameterController(Responder * parentResponder, Store * store) :
FloatParameterController(parentResponder),
m_binWidthCell(EditableTextMenuListCell(&m_selectableTableView, this, m_draftTextBuffer, (char*)"Largeur des rectanges : ")),
m_minValueCell(EditableTextMenuListCell(&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("Value interdite");
return;
}
m_store->setBarWidth(f);
} else {
m_store->setFirstDrawnBarAbscissa(f);
}
}
int HistogramParameterController::numberOfRows() {
return 2;
};
TableViewCell * HistogramParameterController::reusableCell(int index) {
assert(index >= 0 && index < 2);
if (index == 0) {
return &m_binWidthCell;
}
return &m_minValueCell;
}
int HistogramParameterController::reusableCellCount() {
return 2;
}
}