Numworks Epsilon  1.4.1
Graphing Calculator Operating System
interactive_curve_view_range_delegate.cpp
Go to the documentation of this file.
3 #include <cmath>
4 #include <float.h>
5 
6 namespace Shared {
7 
8 
10  if (!interactiveCurveViewRange->yAuto()) {
11  return false;
12  }
13  Range yRange = computeYRange(interactiveCurveViewRange);
14  float max = yRange.max;
15  float min = yRange.min;
16  float range = max - min;
17  if (max < min) {
18  range = 0.0f;
19  }
20  if (interactiveCurveViewRange->yMin() == addMargin(min, range, true) && interactiveCurveViewRange->yMax() == addMargin(max, range, false)) {
21  return false;
22  }
23  if (min == max) {
24  float step = max != 0.0f ? interactiveCurveViewRange->computeGridUnit(CurveViewRange::Axis::Y, 0.0f, max) : 1.0f;
25  min = min - step;
26  max = max + step;
27  }
28  if (min == FLT_MAX && max == -FLT_MAX) {
29  min = -1.0f;
30  max = 1.0f;
31  }
32  if (min == FLT_MAX) {
33  float step = max != 0.0f ? interactiveCurveViewRange->computeGridUnit(CurveViewRange::Axis::Y, 0.0f, std::fabs(max)) : 1.0f;
34  min = max-step;
35  }
36  if (max == -FLT_MAX) {
37  float step = min != 0.0f ? interactiveCurveViewRange->computeGridUnit(CurveViewRange::Axis::Y, 0.0f, std::fabs(min)) : 1.0f;
38  max = min+step;
39  }
40  interactiveCurveViewRange->setYMin(addMargin(min, range, true));
41  interactiveCurveViewRange->setYMax(addMargin(max, range, false));
42  if (std::isinf(interactiveCurveViewRange->xMin())) {
43  interactiveCurveViewRange->setYMin(-FLT_MAX);
44  }
45  if (std::isinf(interactiveCurveViewRange->xMax())) {
46  interactiveCurveViewRange->setYMax(FLT_MAX);
47  }
48  return true;
49 }
50 
52  return 10.0f;
53 }
54 
55 }
#define isinf(x)
Definition: math.h:44
#define fabs(x)
Definition: math.h:178
#define FLT_MAX
Definition: float.h:6
float computeGridUnit(Axis axis, float min, float max)
bool didChangeRange(InteractiveCurveViewRange *interactiveCurveViewRange)