mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/statistics] Create a histogram view inheriting from cruve view
Change-Id: I7e6d027e50ec040e1fe6ee6354d9275dc3a025d9
This commit is contained in:
@@ -5,6 +5,7 @@ app_objs += $(addprefix apps/statistics/,\
|
||||
data.o\
|
||||
data_controller.o\
|
||||
histogram_controller.o\
|
||||
histogram_view.o\
|
||||
)
|
||||
|
||||
app_images += apps/statistics/stat_icon.png
|
||||
|
||||
36
apps/statistics/histogram_view.cpp
Normal file
36
apps/statistics/histogram_view.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "histogram_view.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace Statistics {
|
||||
|
||||
HistogramView::HistogramView(Data * data) :
|
||||
CurveView(data),
|
||||
m_data(data)
|
||||
{
|
||||
}
|
||||
|
||||
void HistogramView::reload() {
|
||||
markRectAsDirty(bounds());
|
||||
computeLabels(Axis::Horizontal);
|
||||
}
|
||||
|
||||
void HistogramView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(rect, KDColorWhite);
|
||||
drawAxes(Axis::Horizontal, ctx, rect);
|
||||
drawAxes(Axis::Vertical, ctx, rect);
|
||||
drawLabels(Axis::Horizontal, true, ctx, rect);
|
||||
drawHistogram(nullptr, KDColorBlack, ctx, rect);
|
||||
}
|
||||
|
||||
char * HistogramView::label(Axis axis, int index) const {
|
||||
if (axis == Axis::Vertical) {
|
||||
return nullptr;
|
||||
}
|
||||
return (char *)m_labels[index];
|
||||
}
|
||||
|
||||
float HistogramView::evaluateCurveAtAbscissa(void * curve, float t) const {
|
||||
return m_data->sizeAtValue(t);
|
||||
}
|
||||
|
||||
}
|
||||
26
apps/statistics/histogram_view.h
Normal file
26
apps/statistics/histogram_view.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef STATISTICS_HISTOGRAM_VIEW_H
|
||||
#define STATISTICS_HISTOGRAM_VIEW_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "data.h"
|
||||
#include "../constant.h"
|
||||
#include "../curve_view.h"
|
||||
|
||||
namespace Statistics {
|
||||
|
||||
class HistogramView : public CurveView {
|
||||
public:
|
||||
HistogramView(Data * m_data);
|
||||
void reload();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
private:
|
||||
char * label(Axis axis, int index) const override;
|
||||
float evaluateCurveAtAbscissa(void * curve, float t) const override;
|
||||
Data * m_data;
|
||||
char m_labels[k_maxNumberOfXLabels][Constant::FloatBufferSizeInScientificMode];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user