Blame view

epsilon-master/apps/shared/curve_view_cursor.cpp 594 Bytes
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
  #include "curve_view_cursor.h"
  #include <cmath>
  
  namespace Shared {
  
  CurveViewCursor::CurveViewCursor() :
    m_x(NAN),
    m_y(NAN)
  {
  }
  
  double CurveViewCursor::x() {
    return m_x;
  }
  
  double CurveViewCursor::y() {
    return m_y;
  }
  
  void CurveViewCursor::moveTo(double x, double y) {
    m_x = clipped(x, false);
    m_y = clipped(y, true);
  }
  
  double CurveViewCursor::clipped(double x, bool canBeInfinite) {
    double maxValue = canBeInfinite ? INFINITY : k_maxFloat;
    double clippedX = x > k_maxFloat ? maxValue : x;
    clippedX = clippedX < - k_maxFloat ? -maxValue : clippedX;
    return clippedX;
  }
  
  }