Blame view

build3/apps/shared/memoized_curve_view_range.cpp 1.75 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  #include "memoized_curve_view_range.h"
  #include <cmath>
  #include <assert.h>
  #include <ion.h>
  
  namespace Shared {
  
  MemoizedCurveViewRange::MemoizedCurveViewRange() :
    m_xMin(-10.0f),
    m_xMax(10.0f),
    m_yMin(-10.0f),
    m_yMax(10.0f),
    m_xGridUnit(2.0f),
    m_yGridUnit(2.0f)
  {
  }
  
  float MemoizedCurveViewRange::xMin() {
    return m_xMin;
  }
  
  float MemoizedCurveViewRange::xMax() {
    return m_xMax;
  }
  
  float MemoizedCurveViewRange::yMin() {
    return m_yMin;
  }
  
  float MemoizedCurveViewRange::yMax() {
    return m_yMax;
  }
  
  float MemoizedCurveViewRange::xGridUnit() {
    return m_xGridUnit;
  }
  
  float MemoizedCurveViewRange::yGridUnit() {
    return m_yGridUnit;
  }
  
  void MemoizedCurveViewRange::setXMin(float xMin) {
    if (std::isnan(xMin)) {
      return;
    }
    m_xMin = xMin;
    if (m_xMin >= m_xMax) {
      m_xMax = xMin + std::pow(10.0f, std::floor(std::log10(std::fabs(xMin)))-1.0f);
    }
    m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
  }
  
  void MemoizedCurveViewRange::setXMax(float xMax) {
    if (std::isnan(xMax)) {
      return;
    }
    m_xMax = xMax;
    if (m_xMin >= m_xMax) {
      m_xMin = xMax - std::pow(10.0f, std::floor(std::log10(std::fabs(xMax)))-1.0f);
    }
    m_xGridUnit = computeGridUnit(Axis::X, m_xMin, m_xMax);
  }
  
  void MemoizedCurveViewRange::setYMin(float yMin) {
    if (std::isnan(yMin)) {
      return;
    }
    m_yMin = yMin;
    if (m_yMin >= m_yMax) {
      m_yMax = yMin + std::pow(10.0f, std::floor(std::log10(std::fabs(yMin)))-1.0f);
    }
    m_yGridUnit = computeGridUnit(Axis::Y, m_yMin, m_yMax);
  }
  
  void MemoizedCurveViewRange::setYMax(float yMax) {
    if (std::isnan(yMax)) {
      return;
    }
    m_yMax = yMax;
    if (m_yMin >= m_yMax) {
      m_yMin = yMax - + std::pow(10.0f, std::floor(std::log10(std::fabs(yMax)))-1.0f);
  
    }
    m_yGridUnit = computeGridUnit(Axis::Y, m_yMin, m_yMax);
  }
  
  }