Files
Upsilon/apps/shared/curve_view_cursor.cpp
Émilie Feral d2597321d0 [apps/shared] A cursor can reach Infinity in ordinate but not in
abscissa (otherwise, the cursor is stuck...)

Change-Id: I6d64dd6289dc3674cfdad70f5c6d710bb771c5b4
2017-04-14 13:46:21 +02:00

33 lines
587 B
C++

#include "curve_view_cursor.h"
#include <math.h>
namespace Shared {
CurveViewCursor::CurveViewCursor() :
m_x(NAN),
m_y(NAN)
{
}
float CurveViewCursor::x() {
return m_x;
}
float CurveViewCursor::y() {
return m_y;
}
void CurveViewCursor::moveTo(float x, float y) {
m_x = clipped(x, false);
m_y = clipped(y, true);
}
float CurveViewCursor::clipped(float x, bool canBeInfinite) {
float maxValue = canBeInfinite ? INFINITY : k_maxFloat;
float clippedX = x > k_maxFloat ? maxValue : x;
clippedX = clippedX < - k_maxFloat ? -maxValue : clippedX;
return clippedX;
}
}