Files
Upsilon/apps/curve_view_range.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

29 lines
789 B
C++

#include "curve_view_range.h"
#include <math.h>
#include <float.h>
float CurveViewRange::yGridUnit() {
return 0.0f;
}
float CurveViewRange::computeGridUnit(Axis axis, float min, float max) {
int a = 0;
int b = 0;
float d = max - min;
float maxNumberOfUnits = k_maxNumberOfXGridUnits;
float minNumberOfUnits = k_minNumberOfXGridUnits;
if (axis == Axis::Y) {
maxNumberOfUnits = k_maxNumberOfYGridUnits;
minNumberOfUnits = k_minNumberOfYGridUnits;
}
float units[3] = {k_oneUnit, k_twoUnit, k_fiveUnit};
for (int k = 0; k < 3; k++) {
float unit = units[k];
if (floorf(log10f(d/(unit*maxNumberOfUnits))) != floorf(log10f(d/(unit*minNumberOfUnits)))) {
b = floorf(log10f(d/(unit*minNumberOfUnits)));
a = unit;
}
}
return a*powf(10,b);
}