mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
ranges) and of curve views/curve view controllers. Change-Id: If4ca9bf1bec024917ef540a3fc7baefa8700f7ba
29 lines
789 B
C++
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);
|
|
}
|