[apps/statistics] Change name: barStart -> firsBarAbscissa

Change-Id: Ia5d39ff3d4b8539b9028afd55476a0d310578dde
This commit is contained in:
Émilie Feral
2016-12-27 10:39:51 +01:00
parent e8bb416bec
commit fecf0eb3a5
6 changed files with 26 additions and 26 deletions

View File

@@ -231,14 +231,14 @@ void CurveView::drawDiscreteHistogram(KDContext * ctx, KDRect rect, KDColor colo
}
}
void CurveView::drawHistogram(KDContext * ctx, KDRect rect, float barStart, float barWidth, KDColor color, KDColor highlightColor, float coloredBin) const {
void CurveView::drawHistogram(KDContext * ctx, KDRect rect, float firsBarAbscissa, float barWidth, KDColor color, KDColor highlightColor, float coloredBin) const {
KDCoordinate pixelBarWidth = floatToPixel(Axis::Horizontal, barWidth) - floatToPixel(Axis::Horizontal, 0.0f);
float rectMin = pixelToFloat(Axis::Horizontal, rect.left());
int rectMinBinNumber = floorf((rectMin - barStart)/barWidth);
float rectMinLowerBound = barStart + rectMinBinNumber*barWidth + barWidth/2;
int rectMinBinNumber = floorf((rectMin - firsBarAbscissa)/barWidth);
float rectMinLowerBound = firsBarAbscissa + rectMinBinNumber*barWidth + barWidth/2;
float rectMax = pixelToFloat(Axis::Horizontal, rect.right());
int rectMaxBinNumber = floorf((rectMax - barStart)/barWidth);
float rectMaxUpperBound = barStart + (rectMaxBinNumber+1)*barWidth + barWidth;
int rectMaxBinNumber = floorf((rectMax - firsBarAbscissa)/barWidth);
float rectMaxUpperBound = firsBarAbscissa + (rectMaxBinNumber+1)*barWidth + barWidth;
for (float x = rectMinLowerBound; x < rectMaxUpperBound; x += barWidth) {
float y = evaluateCurveAtAbscissa(nullptr, x);
if (!isnan(y)) {

View File

@@ -37,7 +37,7 @@ protected:
void drawAxes(KDContext * ctx, KDRect rect, Axis axis) const;
void drawCurve(KDContext * ctx, KDRect rect, Model * curve, KDColor color, bool colorUnderCurve = false, float colorLowerBound = 0.0f, float colorUpperBound = 0.0f, bool continuously = false) const;
void drawDiscreteHistogram(KDContext * ctx, KDRect rect, KDColor color, bool colorHighlightBin = false, KDColor highlightColor = KDColorBlack, float colorLowerBound = 0.0f, float colorUpperBound = 0.0f) const;
void drawHistogram(KDContext * ctx, KDRect rect, float barStart, float barWidth, KDColor color, KDColor highlightColor, float coloredBin) const;
void drawHistogram(KDContext * ctx, KDRect rect, float firsBarAbscissa, float barWidth, KDColor color, KDColor highlightColor, float coloredBin) const;
void computeLabels(Axis axis);
void drawLabels(KDContext * ctx, KDRect rect, Axis axis, bool shiftOrigin) const;
private:

View File

@@ -10,7 +10,7 @@ Data::Data() :
m_numberOfPairs(0),
m_barWidth(1.0f),
m_selectedBar(0.0f),
m_barStart(0.0f),
m_firstBarAbscissa(0.0f),
m_xMin(0.0f),
m_xMax(10.0f),
m_yMax(1.0f),
@@ -92,20 +92,20 @@ void Data::setBarWidth(float barWidth) {
initWindowParameters();
}
float Data::barStart() {
return m_barStart;
float Data::firsBarAbscissa() {
return m_firstBarAbscissa;
}
void Data::setBarStart(float barStart) {
m_barStart = barStart;
void Data::setFirsBarAbscissa(float firsBarAbscissa) {
m_firstBarAbscissa = firsBarAbscissa;
initWindowParameters();
}
int Data::heightForBarAtValue(float value) {
float width = barWidth();
int barNumber = floorf((value - m_barStart)/width);
float lowerBound = m_barStart + barNumber*width;
float upperBound = m_barStart + (barNumber+1)*width;
int barNumber = floorf((value - m_firstBarAbscissa)/width);
float lowerBound = m_firstBarAbscissa + barNumber*width;
float upperBound = m_firstBarAbscissa + (barNumber+1)*width;
return sumOfValuesBetween(lowerBound, upperBound);
}
@@ -264,7 +264,7 @@ bool Data::scrollToSelectedBar() {
void Data::initBarParameters() {
float min = minValue();
float max = maxValue();
m_barStart = min;
m_firstBarAbscissa = min;
m_barWidth = computeGridUnit(Axis::X, min, max);
if (m_barWidth <= 0.0f) {
m_barWidth = 1.0f;
@@ -274,7 +274,7 @@ void Data::initBarParameters() {
void Data::initWindowParameters() {
float min = minValue();
float max = maxValue();
m_xMin = m_barStart;
m_xMin = m_firstBarAbscissa;
m_xMax = max + m_barWidth;
if ((m_xMax - m_xMin)/m_barWidth > k_maxNumberOfBarsPerWindow) {
m_xMax = m_xMin + k_maxNumberOfBarsPerWindow*m_barWidth;
@@ -292,13 +292,13 @@ void Data::initWindowParameters() {
m_yMax = m_yMax/(float)totalSize();
m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
m_selectedBar = m_barStart + m_barWidth/2;
m_selectedBar = m_firstBarAbscissa + m_barWidth/2;
while (heightForBarAtValue(m_selectedBar) == 0 && m_selectedBar < max + m_barWidth) {
m_selectedBar += m_barWidth;
}
if (m_selectedBar > max + m_barWidth) {
/* No bar is after m_barStart */
m_selectedBar = m_barStart + m_barWidth/2;
/* No bar is after m_firstBarAbscissa */
m_selectedBar = m_firstBarAbscissa + m_barWidth/2;
while (heightForBarAtValue(m_selectedBar) == 0 && m_selectedBar > min - m_barWidth) {
m_selectedBar -= m_barWidth;
}

View File

@@ -23,8 +23,8 @@ public:
// Histogram bars
float barWidth();
void setBarWidth(float barWidth);
float barStart();
void setBarStart(float barStart);
float firsBarAbscissa();
void setFirsBarAbscissa(float firsBarAbscissa);
int heightForBarAtValue(float value);
float selectedBar();
bool selectNextBarToward(int direction);
@@ -68,7 +68,7 @@ private:
// Histogram bars
float m_barWidth;
float m_selectedBar;
float m_barStart;
float m_firstBarAbscissa;
// Window bounds of the data
float m_xMin;
float m_xMax;

View File

@@ -26,7 +26,7 @@ float HistogramParameterController::parameterAtIndex(int index) {
if (index == 0) {
return m_data->barWidth();
}
return m_data->barStart();
return m_data->firsBarAbscissa();
}
void HistogramParameterController::setParameterAtIndex(int parameterIndex, float f) {
@@ -38,7 +38,7 @@ void HistogramParameterController::setParameterAtIndex(int parameterIndex, float
}
m_data->setBarWidth(f);
} else {
m_data->setBarStart(f);
m_data->setFirsBarAbscissa(f);
}
}

View File

@@ -45,9 +45,9 @@ void HistogramView::drawRect(KDContext * ctx, KDRect rect) const {
drawAxes(ctx, rect, Axis::Horizontal);
drawLabels(ctx, rect, Axis::Horizontal, true);
if (m_selectedBins) {
drawHistogram(ctx, rect, m_data->barStart(), m_data->barWidth(), KDColorBlack, KDColorRed, m_data->selectedBar());
drawHistogram(ctx, rect, m_data->firsBarAbscissa(), m_data->barWidth(), KDColorBlack, KDColorRed, m_data->selectedBar());
} else {
drawHistogram(ctx, rect, m_data->barStart(), m_data->barWidth(), KDColorBlack, KDColorRed, NAN);
drawHistogram(ctx, rect, m_data->firsBarAbscissa(), m_data->barWidth(), KDColorBlack, KDColorRed, NAN);
}
}