2 #include "../apps_container.h" 17 m_view(store, &m_bannerView),
18 m_settingButton(this,
I18n::Message::HistogramSet,
Invocation([](void * context, void * sender) {
24 m_storeVersion(storeVersion),
25 m_barVersion(barVersion),
26 m_rangeVersion(rangeVersion),
27 m_selectedBarIndex(selectedBarIndex),
28 m_histogramParameterController(
nullptr, store)
46 return &m_histogramParameterController;
73 if (moveSelection(direction)) {
84 if (*m_storeVersion != storeChecksum) {
85 *m_storeVersion = storeChecksum;
89 if (*m_barVersion != barChecksum) {
90 *m_barVersion = barChecksum;
91 initRangeParameters();
94 if (*m_rangeVersion != rangeChecksum) {
95 *m_rangeVersion = rangeChecksum;
113 return (
Button *)&m_settingButton;
124 return I18n::Message::NoDataToPlot;
128 return tabController();
141 if (nextFirstResponder ==
nullptr || nextFirstResponder == tabController()) {
148 Responder * HistogramController::tabController()
const {
152 void HistogramController::reloadBannerView() {
154 int numberOfChar = 0;
155 const char * legend =
" [";
156 int legendLength =
strlen(legend);
157 strlcpy(buffer, legend, legendLength+1);
158 numberOfChar += legendLength;
161 buffer[numberOfChar++] =
';';
164 buffer[numberOfChar++] =
'[';
166 legendLength =
strlen(legend);
167 strlcpy(buffer+numberOfChar, legend, legendLength+1);
168 buffer[k_maxIntervalLegendLength] = 0;
173 legendLength =
strlen(legend);
174 strlcpy(buffer, legend, legendLength+1);
175 numberOfChar += legendLength;
179 legendLength =
strlen(legend);
180 strlcpy(buffer+numberOfChar, legend, legendLength+1);
181 buffer[k_maxLegendLength] = 0;
186 legendLength =
strlen(legend);
187 strlcpy(buffer, legend, legendLength+1);
188 numberOfChar += legendLength;
192 legendLength =
strlen(legend);
193 strlcpy(buffer+numberOfChar, legend, legendLength+1);
194 buffer[k_maxLegendLength] = 0;
198 bool HistogramController::moveSelection(
int deltaIndex) {
199 int newSelectedBarIndex = *m_selectedBarIndex;
200 if (deltaIndex > 0) {
202 newSelectedBarIndex++;
206 newSelectedBarIndex--;
207 }
while (m_store->
heightOfBarAtIndex(newSelectedBarIndex) == 0 && newSelectedBarIndex >= 0);
209 if (newSelectedBarIndex >= 0 && newSelectedBarIndex < m_store->numberOfBars() && *m_selectedBarIndex != newSelectedBarIndex) {
210 *m_selectedBarIndex = newSelectedBarIndex;
218 void HistogramController::initRangeParameters() {
221 float barWidth = m_store->
barWidth();
223 float xMax = max + barWidth;
225 if ((xMax - xMin)/barWidth > k_maxNumberOfBarsPerWindow) {
226 xMax = xMin + k_maxNumberOfBarsPerWindow*barWidth;
230 xMax = xMin + 10.0f*barWidth;
235 for (
int index = 0; index < m_store->
numberOfBars(); index++) {
242 yMax = yMax < 0 ? 1 : yMax;
247 void HistogramController::initBarParameters() {
252 float barWidth = m_store->
computeGridUnit(CurveViewRange::Axis::X, min, max);
253 if (barWidth <= 0.0f) {
259 void HistogramController::initBarSelection() {
260 *m_selectedBarIndex = 0;
263 *m_selectedBarIndex = *m_selectedBarIndex+1;
267 *m_selectedBarIndex = 0;
269 *m_selectedBarIndex = *m_selectedBarIndex+1;
void setLegendAtIndex(char *text, int index)
void viewWillAppear() override
bool isMainViewSelected() const
static constexpr float k_displayLeftMarginRatio
virtual void setYMax(float f)
void setFirstDrawnBarAbscissa(double firstDrawnBarAbscissa)
static constexpr float k_displayRightMarginRatio
void push(ViewController *vc, KDColor textColor=Palette::SubTab, KDColor backgroundColor=KDColorWhite, KDColor separatorColor=Palette::GreyBright)
Responder * parentResponder() const
double sumOfColumn(int i)
void didBecomeFirstResponder() override
Button * buttonAtIndex(int index, ButtonRowController::Position position) const override
size_t strlcpy(char *dst, const char *src, size_t len)
double heightOfBarAtIndex(int index)
double firstDrawnBarAbscissa()
bool handleEvent(Ion::Events::Event event) override
double endOfBarAtIndex(int index)
static constexpr float k_displayBottomMarginRatio
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
const char * title() override
size_t strlen(const char *s)
static constexpr float k_displayTopMarginRatio
bool isEmpty() const override
void setBarWidth(double barWidth)
I18n::Message emptyMessage() override
static constexpr int LargeNumberOfSignificantDigits
virtual uint32_t rangeChecksum()
float computeGridUnit(Axis axis, float min, float max)
virtual void setYMin(float f)
int numberOfButtons(ButtonRowController::Position) const override
void setFirstResponder(Responder *responder)
void willExitResponderChain(Responder *nextFirstResponder) override
void selectMainView(bool mainViewSelected)
bool scrollToSelectedBarIndex(int index)
StackViewController * stackController()
Responder * defaultController() override
void setHighlight(float start, float end)
virtual void setXMin(float f)
virtual void setXMax(float f)
double startOfBarAtIndex(int index)
HistogramParameterController * histogramParameterController()