Files
Upsilon/apps/statistics/data.h
Émilie Feral 9c1095092a [apps/statistics] Make data and data controller inherit from classes in
apps/

Change-Id: Ie6a0b95c13a212321c1bf8132c39255f31a71429
2017-01-09 15:08:55 +01:00

85 lines
2.2 KiB
C++

#ifndef STATISTICS_DATA_H
#define STATISTICS_DATA_H
#include "../curve_view_window.h"
#include "../data.h"
namespace Statistics {
class Data : public CurveViewWindow, public ::Data {
public:
Data();
// Delete the implicit copy constructor: the object is heavy
Data(const Data&) = delete;
// Raw numeric data
float xValueAtIndex(int index) override;
float yValueAtIndex(int index) override;
void setXValueAtIndex(float value, int index) override;
void setYValueAtIndex(float value, int index) override;
float valueAtIndex(int index);
int sizeAtIndex(int index);
void setValueAtIndex(float value, int index);
void setSizeAtIndex(int size, int index);
void deletePairAtIndex(int index) override;
int totalSize();
// Histogram bars
float barWidth();
void setBarWidth(float barWidth);
float firsBarAbscissa();
void setFirsBarAbscissa(float firsBarAbscissa);
int heightForBarAtValue(float value);
float selectedBar();
bool selectNextBarToward(int direction);
//CurveViewWindow
float xMin() override;
// if the range of value is to wide compared to the bar width, value max is capped
float xMax() override;
float yMin() override;
float yMax() override;
float xGridUnit() override;
// Calculation
float maxValue();
float minValue();
float range();
float mean();
float variance();
float standardDeviation();
float firstQuartile();
float thirdQuartile();
float quartileRange();
float median();
float sum();
float squaredValueSum();
// TODO: decide the max number of elements after optimization
constexpr static int k_maxNumberOfPairs = 500;
private:
constexpr static int k_maxNumberOfBarsPerWindow = 300;
float sumOfValuesBetween(float x1, float x2);
bool scrollToSelectedBar();
void initBarParameters();
void initWindowParameters();
float sortedElementNumber(int k);
int minIndex(float * bufferValues, int bufferLength);
float closestMiddleBarTo(float f);
// Raw numeric data
int m_sizes[k_maxNumberOfPairs];
float m_values[k_maxNumberOfPairs];
// Histogram bars
float m_barWidth;
float m_selectedBar;
float m_firstBarAbscissa;
// Window bounds of the data
float m_xMin;
float m_xMax;
float m_yMax;
float m_xGridUnit;
};
}
#endif